text
stringlengths 28
935k
| meta
stringlengths 137
139
| red_pajama_subset
stringclasses 1
value |
---|---|---|
\section{Introduction}\label{sec:intro}
Credit card frauds, a concept included in the wider notion of financial frauds \cite{ngai2011application, west2016intelligent}, is a topic attracting an increasing attention from the scientific community. This is due, on the one hand, to the raising costs that they generate for the system, reaching billions of dollars in yearly losses and a percentage loss of revenues equal to the $1.4\%$ of online payments \cite{bhatla2003understanding}. On the other hand, credit card frauds have important social consequences and ramifications, as they support organised crime, terrorism funding and international narcotics trafficking - see \cite{rollins2006terrorist} for a complete review.
Detecting unauthorised credit card transactions is an extremely complex problem, as features are seldom useful if taken individually. To illustrate, a large transaction is not {\it prima facie} suspicious, unless it is performed at usual times ({\it e.g.} at night) or in an unusual store ({\it i.e.} a store never visited before by the card owner, located in a different city, {\it etc.}).
When different features have to be combined in non-trivial ways, the customary solution is to resort to data mining, a sub-field of computer science dealing with the automatic discovery of patterns in data sets \cite{friedman2001elements, han2011data, witten2016data}.
Most of the data mining models to detect credit card frauds are based on artificial neural networks (ANN), a model inspired on the structural aspects of biological neural networks, and in which a set of nodes process the input signal by interacting between them \cite{zurada1992introduction, hagan1996neural}. This does not come as a surprise, as ANN are able to extract complex non-linear patterns from data, with almost no hypotheses on the underlying structure. ANN yielded good results in credit card classification tasks, as for instance in \cite{ghosh1994credit, aleskerov1997cardwatch, brause1999neural, maes2002credit, syeda2002parallel, carneiro2015cluster} - see \cite{bhattacharyya2011data, sethi2014revived, zojaji2016survey} for reviews.
While data mining algorithms are able to detect hidden patterns in data, they usually lack the capacity of synthesising metrics describing the global structure created by the interactions between the different features. In recent years, the use of complex networks theory has been proposed as a way of overcoming this limitation. Complex networks are a statistical-mechanics understanding of the classical graph theory, aimed at describing and characterising the structure of complex systems \cite{strogatz2001exploring, albert2002statistical, boccaletti2006complex}. The interaction between network theory and data mining is bidirectional: the former can be used to synthesise high-level features to be fed into a classification problem; while the latter can endow networks with an objective way of validating results - see \cite{zanin2016combining} for a complete review.
More specifically, complex networks and data mining can be integrated as complementary tools in order to extract, synthesise and create new representations of a data source, with the aim of, for instance, discover new hidden patterns in a complex structure. The appropriate integration of complex network metrics can result in improved classification rates with respect to classical data mining algorithms and, reciprocally, there are many situations in which data mining can be used to solve important issues in complex network theory and applications \cite{zanin2016combining}.
In this contribution we explore the possibility of using complex networks as a way of improving credit card fraud detection. Specifically, networks are used to synthesise complex features representing card transactions, relying on the recently proposed approach of {\it parenclitic networks} (Section \ref{sec:methods}). Afterwards, their relevance is evaluated by means of a large dataset of real transactions, by comparing the yielded increase in the classification score when compared to the use of a standard ANN algorithm (Section \ref{sec:results}). We additionally show that the combined data mining / complex networks approach is able to outperform a commercial system in some specific situations.
\section{Methods}\label{sec:methods}
In this section we present the main tools that are going to be used for the classification of credit card transactions between licit and illicit. Given a credit card transaction $t_i$ with features $f_{i1},\cdots,f_{ik}$, the problem entails detecting if it is illicit or not from its features and the knowledge obtained from an historical training dataset - what is known as a supervised learning problem. From a mathematical point of view, we have to model a function $H:\mathbb{R}^k\longrightarrow\mathbb{R}$ and find $\delta>0$ such that if $|H(f_{i1},\cdots,f_{ik})|\le \delta$, then $t_i$ is not illicit. Note that, while there are multiple types of illicit patterns, such aspect is here not considered, in that any suspicious transaction is considered as a potential fraudulent one.
We firstly introduce the concept of {\it parenclitic networks} in Section \ref{sec:parenclitic}, a network reconstruction technique that allows highlighting the differences between one instance and a set of standard ({\it i.e.} baseline, or in this case licit) instances \cite{zanin2011complex, zanin2014parenclitic}. We subsequently describe the real data set used for validation (Section \ref{sec:dataset}), including the available raw features (Table \ref{tab:Features}); and the global classification model (Section \ref{sec:ClassModels}).
\subsection{Parenclitic networks reconstruction}\label{sec:parenclitic}
As initially proposed in \cite{zanin2011complex}, one may hypothesise that the right classification of an observation does not only come from its features, but also from the structure of correlations between them. Following the mathematica formalism introduced before, if we consider the set
\[
L=\left\{(x_1,\cdots,x_k)\in\mathbb{R}^k;\enspace |H(x_1,\cdots,x_k)|\le \delta\right\}\subseteq\mathbb{R}^k,
\]
then $L$ is a manifold in $\mathbb{R}^k$ such that if we take a (new) transaction $t$ with features $t_1,\cdots,t_k$ such that $(t_1,\cdots,t_k)\notin L$, then $t$ is considered as an illicit transaction. In general it is computationally impossible to obtain the set $L$ directly from the training dataset, since it is a high dimensional problem. As an alternative, the parenclitic approach analyses the family of projections of $L$ into 2-dimensional spaces corresponding to couples of features $(x_i,x_j)$ with $1\le i\ne j\le k$. Hence, if we consider a training dataset with $n\in\mathbb{N}$ transactions, each of them described by $k\in\mathbb{N}$ (numeric) features, we can analyse up to ${k\choose 2}=k(k-1)/2$ two-dimensional projections of pairs of different features, each of them with up to $n$ points in $\mathbb{R}^2$. In order to quantify the correlation between pairs of features, the parenclitic approach proposes associating a network to each transaction with $k$ nodes (as many as features considered) and the links measure the correlation between features \cite{zanin2014parenclitic}. Hence the following pre-processing must be completed: for every two-dimensional projection of $L$ given by a couple of features $(f_i,f_j)$ with $1\le i\ne j\le k$, the correlation for the licit transactions in the training dataset is measured (by means of, for instance, a linear regression or other curve fitting techniques). For the shake of simplicity, we have here considered a linear regression, such that every pair of features $(f_i,f_j)$ with $1\le i\ne j\le k$ yields a linear fitting between $f_i$ and $f_j$ for the licit transactions in the training dataset. Mathematically, this is represented by a linear equation of the form:
\[
r_{ij}:\,x_j=a_{ij}x_i+b_{ij}.
\]
Once these ${k\choose 2}$ linear regression lines are computed, a threshold $\alpha>0$ is fixed. Given a new ({\it i.e.} not included in the training set) transaction $t$ with features $t_1,\cdots,t_k$ , a network $G=G(t)$ is associated to $t$ as follows:
\begin{itemize}
\item $G$ has $k$ nodes $1,\cdots,k$,
\item For every pair of nodes $1\le i\ne j\le k$ we compute $w_ij\ge 0$ as the (euclidian) distance from $(t_i,t_j)$ to the line $r_{ij}$ in $\mathbb{R}^2$, i.e.
\[
w_{ij}=d((t_i,t_j),r_{ij}).
\]
As an alternative, the euclidian distance could be replaced by any pseudo-distance function in $\mathbb{R}^2$. For the shake of simplicity, the euclidian distance will be used in this paper, but similar results can be obtained for other pseudo-distance functions.
\item For every pair of nodes $1\le i\ne j\le k$, the (undirected) link $(i,j)$ is in graph $G$ if and only if $w_{ij}\ge \alpha$.
\end{itemize}
Note that the parenclitic network $G(t)$ summarises the couples of features whose correlation strongly differs from a typical licit transaction; the structure of this network thus contains valuable information about the (abnormal) correlation of features in the credit card transaction. Once this parenclitic network is computed, it is necessary to transform it in a set of features compatible with a data mining algorithm. Towards this end, several structural measures have been extracted, and will be considered as new features associated with the transaction (see next section for details). Among all possible structural measures that could be computed (see, for example, Ref.~\cite{costa2007characterization} and references therein), those here selected are summarised in Table~\ref{table:measures}.
\begin{table}[!tb]
\begin{center}
\begin{tabular}{ | p{4cm} | p{10cm} | }
\hline
Name & Description \\
\hline
Maximum node degree~\cite{costa2007characterization} & Maximum degree of all nodes in the network. It is calculated as $M_k = \max_i k_i$, $k_i$ being the degree of nodes $i$ \\
Entropy of the degree distribution~\cite{wang2006entropy} & Shannon entropy of the distribution of nodes degrees. It is given by $E = - \sum _{i=0} ^{M_k} p_i \log p_i$, $p_i$ being the probability of finding a node of degree $i$. \\
Assortativity~\cite{costa2007characterization} & Pearson's correlation coefficient between the degree of connected nodes. \\
Clustering coefficient~\cite{costa2007characterization} & Measure of the presence of triangles in the network. It is defined as the number of triangles (groups of three fully-connected nodes) over the number of connected triplets (groups of three nodes connected by at least two links). \\
Geodesic distance~\cite{costa2007characterization} & Average length of the shortest path connecting pairs of nodes. \\
Efficiency~\cite{latora2001efficient} & Inverse of the harmonic mean of the length of all shortest distances. \\
Information Content~\cite{zanin2014information} & Metric assessing the presence of meso-scale structures in the network. \\
\hline
\end{tabular}
\end{center}
\caption{\label{tab:Topological} List of topological metrics used to describe the structure of parenclitic networks.}\label{table:measures}
\end{table}
\subsection{Data set description}\label{sec:dataset}
The data set here considered includes all credit and debit card transactions of clients of the Spanish bank BBVA, from January 2011 to December 2012. Each month, an average of $15$ million operations were realized by $7$ million cards, for a total of $250$ GB of information.
Transactions are automatically screened by an algorithm designed to detect suspected transactions, and returning a score from $0$ (no suspect) to $100$ (potentially illegal). Afterwards, transactions are classified in two categories, {\it i.e.} {\it legal} and {\it illegal}, as the result of a manual classification performed by the bank's legal personnel - using both information of the automatic algorithm, and customers' complaints. This allows us to detect which transactions were positively detected as frauds by the automatic algorithm, and which were false negatives.
Available fields included a time stamp of the operation, the quantity (both in Euro and in the original currency, if different), and the origin (the card) and destination (the store) of the operation; the two latter fields were anonymised, so that the exact card number and the name of the store could not be recovered. Some additional features have been synthesised from the previous ones, {\it e.g.} the average transaction size of a given user. A full list of the available fields is reported in Tab~\ref{tab:Features}. Additionally, a full statistical characterisation of the features can be found in Ref.~\cite{Zanin2016}, including the temporal evolution of the structure of the transactions network.
\begin{table}[!tb]
\begin{center}
\begin{tabular}{ | l | l | p{10cm} | }
\hline
Name & Type & Description \\ \hline
Transaction size & Integer & Size, in Euro, of the transaction under analysis. \\
Time since last transaction & Integer & Time, in seconds, since the last transaction of the same card. \\
Last transaction size & Integer & Size, in Euro, of the previous transaction executed by the same card. \\
Average transaction size & Float & Average size, in Euro, of the transactions executed by the card in the last month. \\
Average time between transactions & Float & Average time, in seconds, between consecutive transactions of the same card. \\
Same shop & Boolean & $1$ is the shop corresponds to the one of the last transaction of the same card, $0$ otherwise. \\
Hour of the day & Integer & Hour (from $1$ to $24$) at which the operation was realised. \\
Fraud rate & Float & Average rate of illegal operations, for all cards, in the last $50.000$ transactions. \\ \hline
Fraud suspectness & Integer & Number representing the likelihood for the transaction to be illicit, according to the bank automatic fraud detection algorithm. Values range between $0$ (no fraud suspected) to $100$ (certain fraud). \\
Fraud & Boolean & $1$ if the transaction has been recognised as a fraud, $0$ otherwise. \\ \hline
\end{tabular}
\end{center}
\caption{\label{tab:Features}Features composing the credit card transactions dataset.}
\end{table}
\subsection{Classification models}\label{sec:ClassModels}
As previously introduced, in this contribution we are going to explore two different ways of detecting illicit credit card transactions: a classical data mining approach, and the introduction of features extracted from a network representation. In both cases, the process must follow some common steps: it is first necessary to extract the expected behavior, {\it i.e.} a set of features representing the typical legal and illegal transaction; for then building a model that learns from those features, and yields an expected classification for a new transaction not yet studied.
Fig.~\ref{fig01} depicts an overview of the whole process. It starts from the original data set, from which a set of raw features are extracted - as described in Section \ref{sec:dataset} and listed in Tab. \ref{tab:Features}. The features corresponding to the licit transactions are then used to recover the normal relations, as described in Section \ref{sec:parenclitic}, and to reconstruct the parenclitic networks of all transactions. These networks are then binarised, {\it i.e.} links with weight below a given threshold are deleted, and a set of topological metrics are extracted - see Table~\ref{tab:Topological} for a complete list. Note that, at the end of this analysis, all transactions are described by $15$ features: $8$ coming from the raw data, and $7$ from the network analysis.
\begin{figure}[!tb]
\begin{center}
\includegraphics[width=0.5\textwidth]{Fig01.pdf}
\end{center}
\caption{\label{fig01} Schematic representation of the classification model. See main text for details.}
\end{figure}
Artificial Neural Networks (ANNs), and specifically Muti-Layer Perceptrons (MLP) have been chosen as the final model for classifying new transactions. They are inspired by the structural aspects of biological neural networks, and are represented by a set of connected nodes in which each connection has a weight associated with it, and the network learns the classification function adjusting the node weights~\cite{rosenblatt1958perceptron, hagan1996neural}. The output of each artificial neuron $j$ is defined by:
\begin{equation}
f(W^T, x_j)=\sum^{n}_{i=1}{W_i x_i + b},
\end{equation}
$W$ being the vector of weights, and $f$ the sigmoid activation function:
\begin{equation}
f(x)= \frac{1}{1 + \exp(-x)}.
\end{equation}
Following the standard configuration, neurons were organized in three layers: an input one, with a number of neurons equal to the input features; an intermediate, or hidden one, with ten neurons; and a final output layer comprising just one computational element. The training has been performed with the standard back-propagation algorithm~\cite{Werbos74}. Finally, the reconstruction of the MLP models has been performed using the KNIME software \cite{berthold2009knime}.
The evaluation of the classification efficiency has been performed using both sensitivity (also known as True Positive Rate - TPR) and Receiver Operating Characteristic (ROC) curves \cite{hanley1982meaning}. These curves are created by plotting the True Positive Rate (TPR) against the False Positive Rate (FPR) at various threshold settings. ROC plots present the important advantage of showing the performance of the classification model for different sensitivity values. This is relevant for the problem at hand, as false positives are extremely expensive, {\it e.g.} in terms of the negative commercial image of the bank; conservative solutions are therefore usually preferred.
\section{Results}
\label{sec:results}
As explained in Section \ref{sec:parenclitic}, the parenclitic approach usually requires the definition of a threshold $\alpha$, which is used to binarise the (initially weighted) networks. Instead of using an {\it a priori} approach, {\it i.e.} the definition of $\alpha$ using expert judgement, we here tackle the problem indirectly, by following the procedure proposed in Ref. \cite{zanin2012optimizing}. Specifically, we optimise the network reconstruction by finding the link density (and hence the value of $\alpha$) that optimises the efficacy of the classification model.
\begin{figure}[!tb]
\begin{center}
\includegraphics[width=0.95\textwidth]{Fig02.pdf}
\end{center}
\caption{\label{fig02} (Left) Classification error as a function of the link density of the parenclitic networks. Black squares, black circles and blue triangles respectively represent the error for the classification for the original raw features, for the classification using parenclitic features alone, and for the classification with all features. (Right) Error reduction, in percentage, when using only parenclitic features (black circles) and the full set of features (blue triangles), w.r.t. the use of the raw data set.}
\end{figure}
Fig.~\ref{fig02} Left presents the evolution of the classification error (sensitivity or TPR) as a function of the considered link density, for three different scenarios: the use of only the raw features, as described in Tab.~\ref{tab:Features} (solid black squares); the use of the features extracted from the parenclitic representation alone (hollow black circles); and the use of the combined sets of features (solid blue triangles). Note that, in the former case, the result is constant, as the original features are not affected by the binarisation process. In order to avoid overfitting, this classification has been performed on a balanced sub data set, composed of an equal number of legal and illegal transactions.
Several conclusions can be drawn from Fig.~\ref{fig02}. First of all, the features extracted from the parenclitic networks are not enough, alone, to reach a low classification error. This has to be expected: while important information can be codified in the interaction between raw features, some important clues may be hidden in the latter, {\it e.g.} abnormal transaction sizes or timings. At the same time, the addition of parenclitic features to the raw data set enhance the obtained results, with the error dropping from a $19.2\%$ to a $12.23\%$. This is further illustrated in Fig.~\ref{fig02} Right, depicting the reduction in the classification error (in percentage) when considering only parenclitic features and the whole data set - note that, in the first case, the reduction is negative as the error increases. Finally, the best classification suggests that the optimal link density that should be considered is of a $60\%$ - meaning that the $40\%$ of links with less weight should be deleted.
\begin{figure}[!tb]
\begin{center}
\includegraphics[width=0.4\textwidth]{Fig03a.pdf}
\hspace{0.5cm}
\includegraphics[width=0.4\textwidth]{Fig03b.pdf}
\end{center}
\caption{\label{fig03} (Left) ROC curves of the classification, corresponding to the use of the raw features alone (blue line), of the parenclitic features (green line), and of the combined sets (black line). (Right) ROC curves, obtained through the combined data set, as a function of the transaction sizes.}
\end{figure}
If Fig.~\ref{fig02} is useful to detect the best link density for the analysis, it does not convey information about the real performance of the classification algorithm in an operational environment. For that, Fig.~\ref{fig03} Left presents three ROC curves, corresponding to the use of raw (blue line), parenclitic (green line), and combined features (black line) as before. Note that results here presented correspond to the optimal link density of $60\%$, as previously estimated.
As previously discussed, the most interesting operational configuration is the one minimising the number of false positives, as this minimises the commercial costs of the organisation. The inset of Fig.~\ref{fig03} thus shows the bottom left part of the curves. It can be appreciated that, after an initial part in which results are comparable, the addition of the parenclitic features slightly increases the number of true positives - note how the black line is above the blue one.
Even though this may seem a negligible difference, it is worth noting that any improvement, however small, has a significant impact due to the large number of transactions managed by the system. Increasing the fraud detection rate by $1\%$ would allow identify $\approx 20.000$ new illicit transactions per year, or $\approx 2$M\euro~in saved costs.
\begin{figure}[!tb]
\begin{center}
\includegraphics[width=0.40\textwidth]{Fig04a.pdf}
\hspace{0.5cm}
\includegraphics[width=0.40\textwidth]{Fig04b.pdf}
\end{center}
\caption{\label{fig04} (Left) ROC curves for the network-based model (black line) and a commercial system (blue line). (Right) ROC curves, for the proposed network-based algorithm and a commercial system, when only on-line (Internet) transactions are considered.}
\end{figure}
Fig. \ref{fig03} Right further presents four ROC curves calculated for different transaction sizes: all transactions (black line), and transactions above $100$\euro~(green line), $400$\euro~(red line) and $1.600$\euro~(blue line). Deleting small transactions results in an improvement of the detection efficiency - note how the green and red lines lay above the black one. Additionally, the proposed algorithm fails for large transactions; this does not come as a surprise, as the larger the size, the fewer the available instances, making training more challenging.
If what previously presented illustrates that the use of a network representation can improve a fraud detection algorithm, it does not clarify how it ranks against a commercial system. As may be expected, the proposed algorithm is less efficient than the fraud score included in the original data set - see Fig. \ref{fig04} Left\footnote{Due to confidentiality issues, the name and characteristics of the commercial fraud detection system cannot be included in this publication.}. Nevertheless, there are niches in which the opposite happens, the most important being the analysis of on-line transactions. Fig. \ref{fig04} Right depicts two ROC curves, respectively for the algorithm based on parenclitic networks (black line) and the commercial system (blue line), when only transactions realised through Internet are considered. While the commercial system clearly outperforms the proposed algorithm, with an Area Under the Curve (AUC) close to $1.0$, the latter is slightly better for a low ratio of False Positive - as previously explained, the plane region most interesting for real operations.
\section{Conclusions}
Complex networks and data mining models share more characteristics that what may {\it prima facie} appear, most notably having similar objectives: both aim at extracting information from (potentially complex) systems to ultimately generate new compact quantifiable representations. At the same time, they approach this common problem from two different approaches: the former by extracting and quantitatively evaluating the underlying structure, the latter by creating predictive models based on historical data \cite{zanin2016combining}.
In this contribution we test the hypothesis that complex networks can be used as a way to improve data mining models, framed within the problem of detecting fraud instances in credit card transactions, providing a new example about how complex networks and data mining may be integrated as complementary tools in a synergistic manner in order to improve the classification rates obtained by classical data mining algorithms.
Results confirm that features extracted from a network-based representation of data, leveraging on a recently proposed parenclitic approach \cite{zanin2011complex, zanin2014parenclitic}, can play an important role: while not effective in themselves, such features can improve the score obtained by a standard ANN classification model.
We further show how the resulting model is especially efficient in detecting frauds in some niches of operations, like medium-sized and on-line transactions. Finally, we illustrate as, in the latter case, the network-based model is able to yield better results than a commercial fraud detection system. All results have been obtained with a unique data set, comprising all transactions managed during two years by a major Spanish bank, and including more than $180$ million operations.
| {'timestamp': '2017-06-08T02:01:53', 'yymm': '1706', 'arxiv_id': '1706.01953', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01953'} | arxiv |
\section{Introduction} %
Iterative Learning Control (ILC) enables significant performance improvements for batch-to-batch control applications, by generating a command signal that compensates for repetitive disturbances through learning from previous iterations, also called batches or trials. Theoretical and implementation aspects, including convergence, causality, and robustness, have been addressed in, e.g., \cite{BristowThaAll2006}, \cite{AhnMooChe2007}, \cite{RogersGalOwe2007}, \cite{Owens2016}, \cite{PipeleersMoo2014}. Furthermore, successful applications have been reported in, e.g., robotics \cite{WallenDreGunRob2014}, mechatronics \cite{BolderZunKoeOom2017}, manufacturing \cite{HoelzleBar2016}, building control \cite{PengSunZhaTom2016}, nuclear fusion \cite{FeliciOom2015}, and rehabilitation \cite{FreemanHugBurChaLewRog2009}. However, several disadvantages of present ILC frameworks that limit further applications include
\begin{inparaenum}[i)]
\item high implementation cost due to highly unstructured command signals, which are expensive to implement;\label{item:1}
\item amplification of trial-varying disturbances, including measurement noise;\label{item:2}
\item inflexibility to changing reference trajectories.\label{item:3}
\end{inparaenum}
The aim of the present paper is to develop an ILC framework that addresses these aspects \ref{item:1})-\ref{item:3}) by enforcing sparsity.
Regarding \ref{item:1}) ILC typically generates signals that require a large number of command signal updates thus leading to an expensive implementation. ILC directly learns from measured signals that are contaminated by trial-varying disturbances such as measurement noise. These trial-varying disturbances are often modeled as a realization of a stochastic process \cite{Ljung1999}. As a result, the ILC command signals have infinite support. In sharp contrast, command signals that are obtained through traditional feedforward designs, including \cite{LambrechtsBoeSte2005}, have finite support and are highly sparse. Command signals with a high number of non-zero elements, or another appropriate structural constraint, may lead to a prohibitively expensive implementation, e.g., in wireless sensor networks, wireless control applications, or embedded platforms with shared resources \cite{GoossensAzeChaDevGooKoeLiMirMolBeyNelSin2013}. Note that this is a different aspect than the actual computation of the command signal itself, which can be done in between subsequent tasks, see \cite{ZundertBolKoeOom2016b} for results in this direction.
Regarding \ref{item:2}), ILC typically amplifies trial-varying disturbances. In fact, typical ILC approaches amplify these disturbances by a factor of two, as is shown in the present paper. Approaches to attenuate trial-varying disturbances include norm-optimal ILC with appropriate input weighting \cite{BristowThaAll2006}, higher-order ILC for addressing disturbances with trial-domain dynamics \cite{GunnarssonNor2006}, and stochastic approximation-based ILC \cite{ButcherKar2011}. Also, a wavelet filtering-based approach is presented in \cite{MerryMolSte2008}, where a certain noise attenuation is achieved by setting certain wavelet coefficients to zero. In the present paper, a different approach is pursued to attenuate disturbances, where also wavelets immediately fit into the formulation, yet the sparsity can be enforced in an optimal way.
Regarding \ref{item:3}), changing reference signals typically lead to performance degradation of ILC algorithms \cite{BoerenBarKokOom2016}, since these essentially constitute trial-varying disturbances. This is in sharp contrast to traditional feedforward designs \cite{LambrechtsBoeSte2005} and is widely recognized in ILC designs. A basis task approach is proposed in \cite{HoelzleAllWag2011}, where the command input is segmented. A basis function framework is developed and applied in \cite{WijdevenBos2010}, \cite{MeulenTouBos2008}, \cite{BolderOomKoeSte2014c} using polynomial basis functions, which is further extended to rational basis functions in \cite{ZundertBolOom2015}. These basis functions are typically selected based on prior information, e.g., based on the approach in \cite{LambrechtsBoeSte2005}, and trial-and-error.
In model estimation and signal processing, the use of measured signals has comparable consequences, which has led to new regularization-based approaches that enforce sparsity. Early approaches include the non-negative garrote \cite{Breiman1995} and Least Absolute Shrinkage and Selection Operator (LASSO) \cite{Tibshirani1996}. These are further generalized in \cite{TibshiraniTay2011}, \cite{HastieTibWai2015}, \cite{BuhlmannGee2011}, \cite{BachJenMaiObo2011}. Related applications in system identification include \cite{RojasHja2011}, \cite{OhlssonLjuBoy2010}.
Although important developments have been made in ILC and several successful applications have been reported, present approaches do not yet exploit the potential of enforcing additional structure and sparsity. The aim of the present paper is to develop a unified optimization-based approach to ILC that allows for explicitly enforcing structure and sparsity, enabling improved resource efficiency, disturbance attenuation, and flexibility to varying reference signals. The approach employs convex relaxations, enabling the use of standard optimization routines.
The main contribution of the present paper is a unified framework to sparse ILC. As subcontributions, trial-varying disturbances are analyzed in detail for explicit ILC algorithms (Sec.~\ref{sec:analyzeexplicitILC}). Subsequently, a general optimization-based framework to sparse ILC is developed (Sec.~\ref{sec:spilc}), including many specific cases that are relevant to ILC applications. The results are confirmed through an application to a wafer stage system (Sec.~\ref{sec:examples}). Related developments to the results in the present paper include the use of sparsity in control, where the main results have been related to Model Predictive Control (MPC), see \cite{AnnergrenHanWah2012}, \cite{KhoshfetratOhlLju2013}, \cite{Gallieri2015}.
\emph{Notation:} Throughout, $\|x\|_{\ell_p}$ denotes the usual $\ell_p$ norm, $p \in \mathbb{Z}_{> 0}$. Also, $\|x\|_0 = \sum_{i} \mathbf{1} (x_i \neq 0)$, i.e., the cardinality of $x$. Note that $\|x\|_0$ is not a norm, since it does not satisfy the homogeneity property. It relates to the general $p$-norm by considering the limit $p\rightarrow 0$ of $\|x\|_p$. In addition, $\|\tf[X]\|_{\mathcal{L}_\infty}$ and $\|\tf[X]\|_{\mathcal{H}_\infty}$ denote the usual $\mathcal{L}_\infty$ and $\mathcal{H}_\infty$ norms of discrete time systems, respectively. Throughout, $J$ denotes a system that maps an input space to an output space, operating either over finite or infinite time, which follows from the context. In certain cases, the system is assumed linear, time invariant, and scalar, with transfer function representation $\tf[J]$. The spectrum of a signal $x$ is denoted $\phi_{x}$.
\section{Problem formulation}\label{sec:probform}
\begin{figure}%
\centering
\includegraphics[width=.9\linewidth]{closedloop2}%
\caption{Parallel ILC structure \eqref{eq:parallelILC} as an example of \eqref{eq:generalILCsystem}.}
\label{fig:parallelILC}
\end{figure}
Consider the ILC system
\begin{equation}\label{eq:generalILCsystem}
e_{j} = r -J f_j -v_j
\end{equation}
be given, where $e_j\in \ell_2$ denotes the error signal to be minimized, $r\in \ell_2$ is the reference signal, $f_j \in \ell_2$ denotes the command signal, and $v_j \in \ell_2$ represents trial-varying disturbances, including measurement noise. Here and in the sequel, all signals are tacitly assumed to have appropriate dimensions. Furthermore, $J$ represents the true system, either open-loop or closed-loop, with causal and stable transfer function $\tf[J] \in \ensuremath{\mathcal{RH}_\infty}$. The index $j \in \ensuremath{\mathbb{Z}}_{\ge 0}$ refers to the trial number. Throughout, the command signal $f_{j+1}$ is generated by an ILC algorithm
\begin{equation}\label{eq:generalILCupdate}
f_{j+1} = F(f_j, e_j),
\end{equation}
where the ILC update $F$ is defined in more detail later on. The general setup \eqref{eq:generalILCsystem} encompasses the parallel ILC setup in Figure~\ref{fig:parallelILC}, where
\begin{equation}\label{eq:parallelILC}
e_j = S\tilde r - SGf_j - S \tilde v_j
\end{equation}
where $S$ follows from its transfer function $\tf[S] = \frac{1}{1+\tf[G]\tf[C]}$, $r = S\bar r$, $J = SG$, $v_j = S \tilde v_j$, and $\tf[C]$, $\tf[G]$ are assumed to be linear.
From \eqref{eq:generalILCupdate} and \eqref{eq:generalILCsystem}, it is immediate that the trial-varying disturbance $v_j$ directly affects the ILC command signal. In view of this observation, the problem investigated in this paper is to develop an ILC algorithm \eqref{eq:generalILCupdate} that satisfies the following requirements:
\begin{compactenum}[{R}1)]
\item the iteration \eqref{eq:generalILCsystem}-\eqref{eq:generalILCupdate} is convergent over $j$;\label{item:converge}
\item the iteration \eqref{eq:generalILCsystem}-\eqref{eq:generalILCupdate} leads to a small error $e_j$ in the presence of trial-invariant disturbances $r$ and trial-variant disturbances $v_j$;\label{item:disturbanceattenuation}
\item the resulting command signal $f_j$ has a certain structure, including\label{item:resourceefficient}
\begin{compactenum}
\item \label{eq:fjspare} a small $\|f_j\|_0$, and/or,
\item \label{eq:dfjspare} a piecewise constant $f_j$ with a small number of jumps.
\end{compactenum}
\end{compactenum}
Here, R\ref{item:converge} is a basic requirement for any ILC algorithm and ensures stability in the trial domain, in addition to the assumed stability in the time domain that is guaranteed by stability of $J$ in \eqref{eq:generalILCsystem}, see also \cite{RogersGalOwe2007} for the stability of such two-dimensional systems. Requirement~R\ref{item:disturbanceattenuation} essentially states that the ILC algorithm should effectively compensate for $r$, while avoiding amplification of trial-varying disturbances $v_j$. Requirement~R\ref{item:resourceefficient} is imposed to enable resource-efficient implementations in terms of sampling or communication requirements, depending on the particular application requirements.
\section{Analysis of Trial-Varying Disturbances in Explicit ILC}\label{sec:analyzeexplicitILC}
In this section, trial-varying disturbances in ILC algorithms are analyzed. In particular, explicit linear ILC algorithms of the general form
\begin{equation}\label{eq:freqilcupdate}
f_{j+1} = Q (f_j + L e_j)
\end{equation}
are considered. The infinite time scalar case is considered, where $Q: \ell_2 \mapsto \ell_2$ and $L: \ell_2 \mapsto \ell_2$. Here, $Q$ and $L$ have associated transfer functions $\tf[Q] \in \ensuremath{\mathcal{RL}_\infty}$ and $\tf[L] \in \ensuremath{\mathcal{RL}_\infty}$. Note that $\tf[J] \in \ensuremath{\mathcal{RH}_\infty}$ reflects causality and stability of the system. The fact that $\tf[Q] \in \ensuremath{\mathcal{RL}_\infty}$ and $\tf[L] \in \ensuremath{\mathcal{RL}_\infty}$ reflects that typical ILC algorithms are typically non-causal, and are usually implemented such that bounded solutions are obtained through finite-time preview or via stable inversion through a bilateral $Z$-transform \cite{ZundertBolKoeOom2016b}. %
The trial-varying disturbance $v_j$ in \eqref{eq:generalILCsystem} will propagate throughout the iterations through the iteration-domain update \eqref{eq:freqilcupdate}. The following assumption is widely adopted \cite{Ljung1999}.
\begin{assum}\label{assum:noise}
Let $v_j = H n_j$, where $n_j$ is i.i.d. zero-mean white noise with variance $\lambda_e$, $\tf[H]$ monic and bistable.
\end{assum}
Clearly, $v_j$ typically does not have compact support. As a result, $f_{j+1}$ will not have compact support in general due to ILC algorithm \eqref{eq:freqilcupdate}.
To enable a more detailed analysis, the following auxiliary result provides a suitable condition to guarantee that the iteration defined by \eqref{eq:generalILCsystem} and \eqref{eq:freqilcupdate} converges.
\begin{thm}\label{thm:contractionmap}
The iteration defined by \eqref{eq:generalILCsystem} - \eqref{eq:freqilcupdate} converges monotonically in the $\ell_2$ norm to a fixed point $f_\infty$ and resulting $e_\infty$ iff
\begin{equation}
\|\tf[Q](1-\tf[L]\tf[J])\|_{\mathcal{L}_\infty} < 1.
\end{equation}
\end{thm}
\begin{proof}
Substituting \eqref{eq:generalILCsystem} into \eqref{eq:freqilcupdate} leads to
\begin{math}
f_{j+1} = Q(I-LJ)f_j + QLr - QLv_j.
\end{math}
Using transfer function representations and subsequent application of the Banach fixed-point theorem in conjunction with \cite[Theorem 4.4]{ZhouDoyGlo1996} yields the desired result.
\end{proof}
Note that Theorem~\ref{thm:contractionmap} allows for non-causal ILC algorithms, i.e., $Q, L \in \ensuremath{\mathcal{RL}_\infty}$. This is more general compared to related analyses, including \cite[Chapter 3]{Moore1993}, which only allow for causal ILC algorithms by restricting to the $\mathcal{H}_\infty$ norm.
The following result is the main result of this section and reveals the propagation of noise in the iteration defined by \eqref{eq:generalILCsystem} and \eqref{eq:freqilcupdate}.
\begin{thm}\label{thm:noiseanalysis}
Given the system \eqref{eq:generalILCsystem} and ILC update \eqref{eq:freqilcupdate} with $f_0 = 0$, Assumption~\ref{assum:noise}, and that the iteration is stable in the sense of Theorem~\ref{thm:contractionmap}, then,
\begin{equation}\label{eq:limiterrorspectrum}
\textstyle
\phi_{e_\infty} =
\left|
\frac{1- \tf[Q]}{1-\tf[Q](1-\tf[L]\tf[J])}
\right|^2 \phi_r
+
\left(
1
+
\frac{\left|
\tf[J]\tf[Q]\tf[L]
\right|^2}{1-|\tf[Q](1-\tf[L]\tf[J])|^2}
\right)\phi_v.
\end{equation}
\end{thm}
Theorem~\ref{thm:noiseanalysis} provides a detailed analysis of the propagation of noise for the general ILC algorithm \eqref{eq:freqilcupdate}. In special cases, the result can be further simplified. For instance, in inverse-model ILC, $\tf[Q]= 1$ and $\tf[L] = \tf[J]^{-1} \in \ensuremath{\mathcal{RH}_\infty}$, in which case Theorem~\ref{thm:noiseanalysis} reveals that
\begin{equation}\label{eq:noiseamplification}
\phi_{e_\infty} = 2 \phi_v.
\end{equation}
The result \eqref{eq:noiseamplification} reveals that the limit error spectrum involves an amplification of the noise spectrum by a factor of two.
Inclusion of a learning gain $\alpha \in (0,1]$ in inverse-model ILC, i.e., replacing \eqref{eq:freqilcupdate}
by $f_{j+1} = Q (f_j + \alpha L e_j)$, mitigates the amplification of trial-varying disturbances, i.e.,
\begin{equation}
\phi_{e_\infty} = \left(
1 + \frac{\alpha^2}{2\alpha - \alpha^2}
\right)\phi_v.
\end{equation}
By taking $\alpha \rightarrow 0$, a first-order Taylor series approximation yields
\begin{equation}\label{eq:rolealpha}
\phi_{e_\infty} \approx \left(
1 + \frac{1}{2} \alpha
\right)\phi_v.
\end{equation}
Hence, choosing $\alpha$ small leads to a limit error $\phi_{e_\infty} = \phi_v$, which intuitively corresponds to the optimal result, since the iteration-domain feedback \eqref{eq:freqilcupdate} cannot attenuate $v_j$ in iteration $j$. An alternative to attenuate $\phi_v$ is to re-design the controller $C$ in \eqref{eq:parallelILC}, which should from a disturbance attenuation perspective be designed such that $\tf[S] \approx \tf[H]^{-1}$, as is advocated in \cite{BoerenBruOom2017}. Note that this affects $J$ in \eqref{eq:generalILCsystem}.%
\begin{remark}
The results in this section rely on infinite time signals and LTI systems. Alternative ILC designs based on finite-time optimization \cite{BristowThaAll2006}, see also the forthcoming section, explicitly address the boundary effects, typically leading to an LTV ILC update \eqref{eq:generalILCupdate}, even if $J$ is LTI. In~\cite{ZundertBolKoeOom2016b}, it is shown that these optimization-based designs are equivalent to a certain linear-quadratic-tracking problem. As a result, the solution reaches a certain stationary value for sufficiently long task lengths, in which case an LTI $L$ and $Q$ can be derived for which the results of Theorem~\ref{thm:noiseanalysis} apply. This also implies that the design of weighting filters for such optimization-based design can be further investigated, as is briefly summarized in the next section.%
\end{remark}
\section{Sparse ILC}\label{sec:spilc}
In this section, the general optimization-based ILC framework is presented that allows for enforcing additional structure compared to alternative ILC structure. In fact, traditional norm-optimal ILC algorithms \cite{BristowThaAll2006} are recovered as a special case. In the next subsection, the general framework is presented and motivated, followed by specific design choices in the subsequent sections.
\subsection{General approach}\label{sec:generalapproach}
Throughout, the criterion
\begin{equation}\label{eq:gencrit}
\begin{split}
\crit(f_{j+1}) = &
\frac{1}{2}
\|W_e e_{j+1}
\|_2^2
+
\frac{1}{2}
\|W_f f_{j+1}
\|_2^2
\\&+
\frac{1}{2}
\|W_{{\ensuremath{{\Delta f}}}}
\left(
f_{j+1} - f_j
\right)
\|_2^2
+ \lambda \|D f_{j+1} \|_1
\end{split}
\end{equation}
is considered. Here, finite time signals of length $N$ are considered to obtain an optimization problem with a finite number of decision variables, i.e., $e_j, f_j \in \mathbb{R}^N$. The matrices are defined in the sequel and are assumed to have compatible dimensions. In addition, existence of a unique solution is typically assumed, which can be directly enforced by assuming appropriate positive (semi-) definiteness assumptions on the design variables $W_e$, $W_f$, $W_{\ensuremath{{\Delta f}}}$, $D$, and $\lambda$. Also, $e_{j+1}$ in \eqref{eq:gencrit} is considered to be the noise-free prediction $e_{j+1} = r-Jf_{j+1}$. Since also $r$ is unknown, the main idea in ILC is to use this approximation also for $e_j$, leading to
\begin{equation}\label{eq:iterativeej}
e_{j+1} = e_j - J(f_{j+1} - f_j),
\end{equation}
where $e_j$ is the measured error signal during trial $j$. Thus, substituting \eqref{eq:iterativeej} into \eqref{eq:gencrit} renders the optimization problem as a function of the known variables $e_j, f_j$, user-defined variables, and the decision variable $f_{j+1}$.
The motivation for considering \eqref{eq:gencrit} is as follows. First, if $\lambda = 0$, then standard norm-optimal ILC is recovered, e.g., as in \cite{GunnarssonNor2001}. In this case, an analytic solution of the form \eqref{eq:freqilcupdate} is directly obtained with
\begin{align}
L &= (J^T \bar W_e J + W_{{\ensuremath{{\Delta f}}}})^{-1}J^T \bar W_e \label{eq:NOILC1} \\
Q &= (J^T \bar W_e J + \bar W_f + \bar W_{{\ensuremath{{\Delta f}}}})^{-1}(J^T \bar W_e J + \bar W_{{\ensuremath{{\Delta f}}}}),\label{eq:NOILC2}
\end{align}
where $\bar W_e = W_e^T W_e$, $\bar W_f = W_f^TW_f$, and $\bar W_{\ensuremath{{\Delta f}}} = W_{\ensuremath{{\Delta f}}}^TW_{\ensuremath{{\Delta f}}}$.
The second motivation stems from the observation that the terms $\frac{1}{2}
\|W_f f_{j+1}
\|_2^2$
and
$\frac{1}{2}
\|W_{{\ensuremath{{\Delta f}}}}
\left(
f_{j+1} - f_j
\right)
\|_2^2$
essentially involve a ridge regression or Tikhonov regularization. If $f_j = 0$, then the two terms coincide. If $f_j \neq 0$, i.e., during the ILC iterations, then $W_f$ typically leads to $Q \neq I$ in \eqref{eq:freqilcupdate}, providing robustness with respect to modeling errors \cite{Bristow2008}. Increasing $W_{\ensuremath{{\Delta f}}}$ attenuates trial-varying disturbances, which is similar to reducing $\alpha$ in \eqref{eq:rolealpha}. Note that $W_f$ also plays a small role to decrease trial-varying disturbances, since it essentially leads to a smaller mean-square error. However, it leads to a non-zero limit error $e_\infty$, even in the absence of $v_j$ due to the weight on $f_j$, which coincides with a $\tf[Q] \neq 1$ in Theorem~\ref{thm:noiseanalysis}.
The third and main motivation for considering the extended criterion \eqref{eq:gencrit} is the additional term $\lambda \|D f_j \|_1$ that is used to enforce sparsity and structure. Note that sparsity is measured directly through the $\ell_0$ norm. However, inclusion of an $\ell_0$ penalty in the criterion \eqref{eq:gencrit} leads to a non-convex optimization problem, which in fact is NP-hard, see \cite{Natarajan1995}. The $\ell_1$ norm is a convex relaxation of the $\ell_0$ norm. To see this, note that \eqref{eq:gencrit} is essentially in Lagrangian form. For the purpose of explanation, consider the simplified form by selecting $W_e = I$, $j = 1$, $f_0 = 0$, $W_f = 0$, $W_{\ensuremath{{\Delta f}}} = 0$, and $D = I$. Using \eqref{eq:iterativeej}
\begin{equation}\label{eq:l1simplified}
\crit(f_1) = \frac{1}{2} \|e_0 - J f_1 \|_2^2 + \lambda \|f_1\|_1,
\end{equation}
which is equivalent to the primal optimization problem
\begin{equation}
\begin{aligned}
& \min_{f_1}
& & \frac{1}{2}\|e_0 - J f_1 \|_2^2 \\
& \text{subject to}
& & \|f_1\|_1 \leq t. \label{eq:l1primal}
\end{aligned}
\end{equation}
for the range of $t$ where the constraint in \eqref{eq:l1primal} is active. This implies that for a given value of $\lambda$, there exists a value of $t$ for which \eqref{eq:l1simplified} and \eqref{eq:l1primal} have identical minima. In this simplified case, the interpretation in \cite{Tibshirani1996} applies to the ILC problem. In particular, the constraint in \eqref{eq:l1primal} is plotted in Fig.~\ref{fig:motivationellone} in addition to several elliptical contour lines of the objective function in \eqref{eq:l1primal}. The solution to \eqref{eq:l1primal} corresponds to the smallest ellipsoid that touches the rhombus of the constraint. If this happens at the corner, as is common and also in this case, then one of the coefficients is zero and a sparse solution is obtained.
In contrast, traditional norm-optimal ILC, i.e., corresponding to the solution \eqref{eq:NOILC1} - \eqref{eq:NOILC2}, typically does not lead to a sparse solution with zero entries in $f_1$. To see this, consider a similar simplified case as in \eqref{eq:l1simplified}
\begin{equation}\label{eq:l2simplified}
J(f_1) = \frac{1}{2} \|e_0- J f_1 \|_2^2 + \tau \|f_1\|_2,
\end{equation}
which is again in Lagrangian form. Here, $\tau$ directly relates to the weights in \eqref{eq:gencrit} if $W_f$ and $W_{\ensuremath{{\Delta f}}}$ are selected as the common diagonal case with initialization $f_0 = 0$. The primal optimization problem corresponding to \eqref{eq:l2simplified} is given by
\begin{equation}
\begin{aligned}
& \min_{f_1}
& & \frac{1}{2}\|e_0 - J f_1 \|_2^2 \\
& \text{subject to}
& & \|f_1\|_2 \leq t. \label{eq:l2primal}
\end{aligned}
\end{equation}
In Fig.~\ref{fig:motivationellone}, the constraint is again shown together with the contour lines of the objective function. Due to the lack of corners of the constraint, the presence of zeros in the solution of \eqref{eq:l2primal} is very unlikely in general. Hence, the $\ell_1$ norm promotes sparse solutions, whereas the $\ell_2$ norm in general does not.
\begin{figure}%
\centering
\includegraphics[width=.75\linewidth]{lassoV2}%
\caption{Enforcing sparsity in ILC. Assuming $N = 2$, $f_1$ contains two elements. The constraint set, i.e., the $\ell_1$ ball is plotted in green. In addition, ellipsoidal contour lines corresponding to the objective in \eqref{eq:l1primal} are plotted. The optimal solution is found at the point where the contour line first touches the constraint set, which in this case implies $f_1(1) = 0$, hence $f_1$ is sparse. In contrast, in the ridge regression case of \eqref{eq:l2primal} (whose constraint is shown in red), the solution is not sparse. In particular, this solution is obtained when the contour lines of the objective function in \eqref{eq:l2primal} first touches the constraint set corresponding to the $\ell_2$ ball. In addition, $f_1^{\star}$ denotes the unconstrained solution to the objective function in \eqref{eq:l1primal} and \eqref{eq:l2primal}.}
\label{fig:motivationellone}
\end{figure}
Finally, it is remarked that if $\lambda > 0$, then the solution to \eqref{eq:gencrit} typically cannot be obtained in closed-form as in \eqref{eq:NOILC1}-\eqref{eq:NOILC2}. Interestingly, a unique solution to \eqref{eq:gencrit} exists due to convexity. The optimization problem \eqref{eq:gencrit} can be readily solved using general convex optimizers. In addition, several efficient algorithms have been developed, see, e.g., \cite[Chapter 5]{HastieTibWai2015} for an overview. Several of such algorithms provide the entire solution path as a function of $\lambda$. The particular algorithm depends on the choice of $D$, but several relevant choices are outlined below.
\subsection{Sparse command signals via lasso}\label{sec:lassoilc}
In view of requirement R\ref{eq:fjspare} in Sec.~\ref{sec:probform}, in certain applications it is required to have a sparse command signal $f_j$. To this end, $D$ in \eqref{eq:gencrit} can be selected as $D = I$. As a result, the value of $\lambda > 0$ will dictate the sparsity of the solution. In addition, in this classical lasso approach, $W_f$ and $W_{\ensuremath{{\Delta f}}}$ may be selected as $W_f = 0$ and $W_{\ensuremath{{\Delta f}}} = 0$, i.e., traditional design guidelines for norm-optimal ILC regarding positive definiteness of these matrices, as in \cite{GunnarssonNor2001}, need not be considered, even for the situation where $J$ is singular. The resulting criterion becomes
\begin{equation}\label{eq:lassocrit}
\begin{split}
\crit(f_{j+1}) = &
\frac{1}{2}
\|W_e (e_j - J f_{j+1})
\|_2^2
+ \lambda \|f_{j+1}\|_1,
\end{split}
\end{equation}
which closely reflects the original lasso approach in \cite{Tibshirani1996}.
\subsection{Elastic net lasso}\label{sec:elasticnet}
In the lasso ILC approach in Sec.~\ref{sec:lassoilc}, the commonly used weighting matrices in $W_f$ and $W_{\ensuremath{{\Delta f}}}$ are set to zero. Interestingly, by selecting either $W_f$ or $W_{{\ensuremath{{\Delta f}}}}$ unequal to zero, an ILC algorithm that relates to the elastic net is obtained, see \cite{ZouHas2005}, which combines lasso and ridge regression. An important advantage is that the elastic net improves group sparsity, where several components become zero simultaneously. Notice that a drawback of the so-called naive elastic net, which coincides with $W_f \neq 0$, $W_{{\ensuremath{{\Delta f}}}} = 0$, is that it leads to a double shrinkage, and it benefits from a correction step \cite{ZouHas2005}. In contrast, in ILC the alternative choice $W_f = 0$, $W_{{\ensuremath{{\Delta f}}}} \neq 0$ can be made, which enforces sparsity in addition to attenuating trial-varying disturbances, see Sec.~\ref{sec:generalapproach}.
\subsection{Sparse updates via fused lasso}\label{sec:fusedlasso}
In view of Requirement R\ref{eq:dfjspare}, it may be required that the signal $f_j$ is not necessarily sparse but piecewise constant, i.e., its value is only changed occasionally in time. This requires a certain structure of signal, which is different than sparsity $\|f_j\|_0$. The main idea is to select $D$ as
\begin{equation}\label{eq:fusedlassoD}
D_{f} =
\begin{bmatrix}
-1 & 1 & \\
& -1 & 1 \\
& & \ddots & \ddots\\
& & & -1 & 1
\end{bmatrix},
\end{equation}
a choice which is also known as the fused lasso, e.g., \cite{TibshiraniSauRosZhuKni2005} and leads to the criterion
\begin{equation}\label{eq:fusedlassocrit}
\begin{split}
\crit(f_{j+1}) = &
\frac{1}{2}
\|W_e (e_j - J f_{j+1})
\|_2^2
+ \lambda \|D_ff_{j+1} \|_1.
\end{split}
\end{equation}
Interestingly, the fused lasso \eqref{eq:fusedlassocrit} can be recast as a traditional lasso of the form \eqref{eq:lassocrit}, yet with an increment-input-output system description. To establish the connection, let $\tf[J^i] = \tf[J] (1-z^{-1})$ be the increment-input-output system. Also, expand $D_f$ in \eqref{eq:fusedlassoD} as
\begin{equation}\label{eq:fusedlassoD2}
D_{f}^i =
\begin{bmatrix}
1 \\
-1 & 1 & \\
& -1 & 1 \\
& & \ddots & \ddots\\
& & & -1 & 1
\end{bmatrix}.
\end{equation}
Then, a change of variables
\begin{equation}
f^i_{j+1} = D_f^i f_{j+1},
\end{equation}
where $f^i_{j+1} $ denotes the incremental input,
leads to
\begin{equation}\label{eq:fusedlassocrittransformed}
\begin{split}
\crit(f_{j+1}) = &
\frac{1}{2}
\|W_e (e_j - J^i f_{j+1}^i)
\|_2^2
+ \lambda \|f_{j+1}^i \|_1,
\end{split}
\end{equation}
with $J^i = J (D_f^i)^{-1}$ corresponding to $\tf[J^i]$.
\subsection{Sparse fused lasso}\label{sec:sparsefusedlasso}
Up to this point, Requirement R\ref{eq:fjspare} and Requirement R\ref{eq:dfjspare} have been addressed separately in Sec.~\ref{sec:lassoilc} and Sec.~\ref{sec:fusedlasso}, respectively. In certain applications, it may be desired to impose both Requirement R\ref{eq:fjspare} and Requirement R\ref{eq:dfjspare}.
Interestingly, Requirement R\ref{eq:fjspare} and Requirement R\ref{eq:dfjspare} can be enforced both by selecting
\begin{align}\label{eq:sparsefusedlasso}
D = \begin{bmatrix}
\alpha D_f & I
\end{bmatrix},
\end{align}
in \eqref{eq:gencrit}. Here, the parameter $\lambda$ can still be chosen to enforce sparsity, i.e., Requirement R\ref{eq:fjspare}, whereas the additional tuning parameter $\alpha \in \mathbb{R}_{\geq 0}$ enforces Requirement R\ref{eq:dfjspare}. This leads to the so-called sparse fused lasso \cite{TibshiraniTay2011}. Note that additional requirements can easily be incorporated using a similar construction as \eqref{eq:sparsefusedlasso}.
\subsection{Basis function ILC}
In recent extensions to ILC, several basis functions are employed. On the one hand, wavelet basis functions are used in, e.g., \cite{MerryMolSte2008}. These immediately fit in the formulation \eqref{eq:gencrit}, see also \cite[Sec.\ 2.1.3]{TibshiraniTay2011}, enabling a systematic way for thresholding while explicitly addressing the performance criterion.
On the other hand, flexibility to varying reference signals is achieved by employing basis functions that depend on the reference. In particular, the command signal is parameterized as $f_{j+1} = \Psi(r) \theta_{j+1}$, see, e.g., \cite{WijdevenBos2010}, \cite{MeulenTouBos2008}, \cite{BolderOomKoeSte2014c}, \cite{ZundertBolOom2015}. The proposed framework can be employed to minimize the number of required basis functions. For instance, a large set can be postulated, e.g., following the guidelines in \cite{LambrechtsBoeSte2005}. Next, an alternative formulation of \eqref{eq:gencrit} can be considered, e.g.,
\begin{equation}\label{eq:gencritbasis}
\begin{aligned}
& \min_{\theta_{j+1}}
& & \|\theta_{j+1}\|_1 \\
& \text{subject to}
& & \frac{1}{2}
\|W_e e_{j+1}
\|_2^2
+
\frac{1}{2}
\|W_f \Psi(r) \theta_{j+1}
\|_2^2
\\ & & &\quad +
\frac{1}{2}
\|W_{{\ensuremath{{\Delta f}}}} \Psi(r)
\left(
\theta_{j+1} - \theta_{j}
\right)
\|_2^2 \leq t,
\end{aligned}
\end{equation}
where a suitable value of $t$ can be obtained by solving the standard norm-optimal ILC in \eqref{eq:NOILC1}-\eqref{eq:NOILC2}.
\subsection{Extensions, analysis, and discussion} \label{sec:extensions}
A general framework for enforcing sparsity and structure in iterative learning control has been proposed, and several specific choices have been outlined. Further extensions that are beyond the scope of the present paper but can be directly incorporated include group lasso \cite{YuanLin2006}, adaptive lasso \cite{Zou2006}, reweighted $\ell_1$ \cite{CandesWakBoy2008}, and the use of non-convex penalties \cite{BertsimasKinMaz2016}.
\subsubsection{Reestimation for debiasing}
Note that the lasso shrinks the estimate compared to the least-squares terms in \eqref{eq:gencrit}. Through a reestimation step of the nonzero coefficients, debiasing is obtained. Note that in certain cases, the bias helps to obtain a smaller overall error, i.e., including both bias and variance aspects, which closely relates to the well-known Stein estimator \cite{Stein1956}. However, for ILC such a bias is undesired, since it is automatically eliminated by performing iterations, see Theorem~\ref{thm:contractionmap}. Thus, it is expected that as the ILC iterations increase, the advantages of reestimating for debiasing become more important. Similar reestimation steps are proposed in \cite{RojasHja2011}, \cite{RojasTotHja2014}, \cite[Page 439]{Murphy2012}, \cite[Sec. \ 7.1]{KimKohBoyGor2009}. Interestingly, in the context of ILC, the idea of enforcing sparsity followed by a reestimation step essentially has the same role as a $Q$-filter in traditional ILC, see \cite{BoerenBarKokOom2016} for details.
\subsubsection{Sparse signal recovery}
The main motivation for using the $\ell_1$ norm in \eqref{eq:gencrit} essentially is to provide a convex relaxation of the $\ell_0$ norm. In case the optimal command input, i.e., for $j \rightarrow \infty$ and $v_j = 0$, the signal $f_{\infty}$ that minimizes $J(f_\infty)$, is sparse, a relevant question is whether this optimal sparse vector can be recovered using the formulation \eqref{eq:gencrit}. The answer depends on the sparsity of the underlying optimal command input $f_j$, as well as on the matrix $J$. In \cite{CandesTao2005}, a sufficient condition that relies on the restriced isometry property is provided. However, these conditions are violated for many practical cases. Nonetheless, the formulation \eqref{eq:gencrit} provides an effective way to enforce sparsity.
\subsubsection{Monotonic convergence}
Monotonic convergence is a commonly used requirement for practical applications. Indeed, it is well-known that poorly designed ILC algorithms can lead to a significant learning transient. It is well-known that traditional norm-optimal ILC, i.e., setting $\lambda = 0$ in \eqref{eq:gencrit}, is monotonically convergent in $f_j$, see, e.g., \cite{Bristow2008}, where the usual assumption $v_j = 0$ is tacitly assumed to analyze monotonic convergence. However, if $\lambda > 0$, the criterion \eqref{eq:gencrit} involves multiple norms, i.e., both the $\ell_1$ and the $\ell_2$ norm. As a result, monotonic convergence requires a more detailed analyis.
To proceed, consider for instance the elastic net lasso of Sec.~\ref{sec:elasticnet} with $D = I$, $W_f = 0$, $W_{\ensuremath{{\Delta f}}} \succ 0$. In this case, monotonic convergence of the ILC cannot be guaranteed in general if $\lambda = 0$. Interestingly, in this case the criterion \eqref{eq:gencrit} can be recast as
\begin{equation}\label{eq:gencritmonconv}
\begin{split}
\crit(f_{j+1}) = &
\frac{1}{2}
\left\|
\left(
\begin{bmatrix}
W_e e_j \\ 0
\end{bmatrix}
+
\begin{bmatrix}
W_e \\ W_{\ensuremath{{\Delta f}}}
\end{bmatrix}f_j
\right)
-
\begin{bmatrix}
W_e \\ W_{\ensuremath{{\Delta f}}}
\end{bmatrix}
f_{j+1}
\right\|_2^2
\\ &+ \lambda \| f_{j+1} \|_1.
\end{split}
\end{equation}
Next, there exists a value of $\tau$ such that the optimization problem
\begin{equation}\label{eq:critformonconv}
\begin{aligned}
& \min_{f_{j+1}}
& & \| f_{j+1} \|_1 \\
& \text{subject to}
& &\frac{1}{2}
\left\|
\begin{bmatrix}
W_e e_j \\ 0
\end{bmatrix}
-
\begin{bmatrix}
W_e \\ W_{\ensuremath{{\Delta f}}}
\end{bmatrix}
(f_{j+1}-f_j)
\right\|_2^2 \leq \tau.
\end{aligned}
\end{equation}
has an identical solution as \eqref{eq:gencritmonconv} at a certain iteration $j$. If $\tau$ is fixed, then the criterion \eqref{eq:critformonconv} can be directly used to enforce monotonic convergence of $f_j$ in the $\ell_1$-norm.
\section{Application to a Wafer Stage}\label{sec:examples}
\subsection{Setup}
\begin{figure}%
\centering
\fbox{\includegraphics[width=.9\linewidth]{A7}}%
\caption{Considered wafer stage application.}
\label{fig:systemdef}
\end{figure}
The considered system is a wafer stage, see Fig.~\ref{fig:systemdef}. Wafer stages are positioning systems that are used in the production of integrated circuits (ICs) through a photolithographic process. The considered wafer stage is controlled in all six motion degrees-of-freedom, i.e., three translations and three rotations. The system is a dual-stage system, where the long stroke enables a stroke of $1 \ \mathrm{m}$ in the horizontal plane, whereas the short stroke enables a positioning accuracy of $1 \ \mathrm{nm}$. Further details on the system and the considered actuation and sensor system are provided in \cite{OomenHerQuiWalBosSte2014}. Throughout, a sampling frequency of $1 \ \mathrm{kHz}$ is adopted, as in \cite{Oomen2014}.
To enable a detailed comparison between the various approaches in Sec.~\ref{sec:spilc}, the identified model in \cite{Oomen2014} is considered as true system, i.e., the result as described in \cite{Oomen2014} is denoted $G_o$. In addition, the feedback controller designed in \cite{Oomen2014} is adopted to stabilize the system. In Fig.~\ref{fig:system}, the open-loop $G_o$ and closed-loop $S_o G_o$ are depicted. In addition, a closed-loop model is made, where a model error is introduced by selecting $J = 0.7 S_oG_o$. This model error is introduced to investigate robust convergence properties of ILC. The resulting model $J$ is also depicted in Fig.~\ref{fig:system}.
The additive noise $\tilde v_j$ is zero mean white noise with a normal distribution and variance $\lambda_e = 1.5 \cdot 10^{-7}$. As a result, $H$ in Assumption~\ref{assum:noise} has transfer function $\tilde H = \frac{1}{1+\tilde G \tilde C}$.
\begin{figure}%
\centering
\includegraphics[width=.9\linewidth]{system}%
\caption{Open-loop true system $G_o$ in (\Colorone), closed-loop true system $S_oG_o$ (\Colortwo), closed-loop model $J$ (\Colorthree).}
\label{fig:system}
\end{figure}
\begin{figure}%
\centering
\includegraphics[width=.9\linewidth]{task}%
\caption{Reference $r$ in \eqref{eq:generalILCsystem} (\Colorone), scaled acceleration profile (\Colortwo).}
\label{fig:task}
\end{figure}
The task $r$ is shown in Fig.~\ref{fig:task}, which is a position signal. In addition, the corresponding scaled acceleration profile is depicted, which is expected to constitute the main contribution of $f_j$ \cite{LambrechtsBoeSte2005}, \cite{MeulenTouBos2008}. For the considered wafer stage application in Fig.~\ref{fig:systemdef}, the constant velocity phase is most important for performance, see \cite[Fig.\ 16 and Fig.\ 20]{Butler2011}, which takes place between $0.03\ \mathrm{s}$ and $0.24 \ \mathrm{s}$.
The goal of this section is to illustrate and compare the proposed approaches in Sec~\ref{sec:spilc}. The reference situation, i.e., feedback only with $f_0 = 0$ in Fig.~\ref{fig:parallelILC} is shown in Fig.~\ref{fig:ilctikresults} (\Colorone), Fig.~\ref{fig:ilctikresults2}, and Fig.~\ref{fig:spectra}. In particular, the approaches in Sec.~\ref{sec:spilc} are applied in this section. %
\subsection{Traditional Norm-Optimal ILC}\label{sec:exampleNOILC}
First, the traditional norm-optimal ILC solution is implemented with $\lambda = 0$ in \eqref{eq:gencrit} with the analytic solution \eqref{eq:NOILC1}-\eqref{eq:NOILC2}. Here, $W_e = I$, $W_f = 0$, and $W_{{\ensuremath{{\Delta f}}}} = 10^{-10}$. Notice that $W_{{\ensuremath{{\Delta f}}}}$ is relatively small but nonzero, since a nonzero $W_{{\ensuremath{{\Delta f}}}}$ or $W_f$ is required to enforce a unique optimal solution.
The results after $40$ iterations are depicted in Fig.~\ref{fig:ilctikresults}. Clearly, the error is reduced to a very small value. As is expected, the feedforward is nonzero at every time instant and very noisy.
To further analyze these results, the $2$-norm of the stochastic, i.e., trial-varying, part of the error is computed as $\sqrt{\sum_{t = 1}^N (e_j(t) - \hat e_\infty(t))^2}$, see Fig.~\ref{fig:ilctikresults2}. Here, $\hat e_\infty $ is computed as follows. After a sufficient number of iterations $n_{\text{conv}}$, the ILC algorithm is assumed to have converged, after which an additional iterations $n_{\text{iter}}$ is used to compute
\begin{math}
\hat e_\infty = \frac{1}{n_{\text{iter}}} \sum_{j = n_{\text{conv}}}^{n_{\text{conv}}+n_{\text{iter}}-1}e_j.
\end{math}
Clearly, Fig.~\ref{fig:ilctikresults2} reveals that the trial-varying part of the error is amplified by a factor $2$, which corroborates the result of Theorem~\ref{thm:noiseanalysis}, where $Q \approx 1$ due to the specific selection of weighting filters.
To further investigate the amplification of trial-varying disturbances, the spectrum of the trial-varying part of the errors in Fig.~\ref{fig:ilctikresults2} is estimated, see Fig.~\ref{fig:spectra}. In addition, the spectrum $\phi_v = \left| \frac{1}{1+\tilde G \tilde C}\right|^2 \lambda_e$ is computed, as well as $2\phi_v$. Again, this clearly confirms the result of Theorem~\ref{thm:noiseanalysis}. In particular, the presented ILC approach with $\lambda = 0$ and small $W_f$ and $W_{\ensuremath{{\Delta f}}}$ leads to a perfect attenuation of trial-invariant disturbances. However, it amplifies trial-varying disturbances by a factor two, and leads to an $f_j$ with large $\|f_j\|_0$, violating Requirement R\ref{eq:fjspare}, as well as R\ref{eq:dfjspare}.
Summarizing, the results in Fig.~\ref{fig:ilctikresults}, Fig.~\ref{fig:ilctikresults2}, and Fig.~\ref{fig:spectra} confirm that norm-optimal ILC amplifies trial-varying disturbances, and leads to a non-sparse solution in view of Requirement R\ref{eq:fjspare} and Requirement R\ref{eq:dfjspare}.
\begin{figure}%
\centering
\includegraphics[width=.9\linewidth]{ilctikresults}%
\caption{Top: error $e_{j}$. Bottom: command signal $f_{j}$. Shown are iteration $j=0$ (\Colorone), iteration $j=40$ for traditional norm-optimal ILC of Sec.~\ref{sec:exampleNOILC} (\Colortwo).}
\label{fig:ilctikresults}
\end{figure}
\begin{figure}%
\centering
\includegraphics[width=.9\linewidth]{ilctikresults2}%
\caption{Iteration $j=0$ (\Colorone), iteration $j=40$ for traditional norm-optimal ILC of Sec.~\ref{sec:exampleNOILC} (\Colortwo).}
\label{fig:ilctikresults2}
\end{figure}
\begin{figure}%
\centering
\includegraphics[width=.9\linewidth]{spectra}%
\caption{Estimated spectrum of trial-varying part of the error without ILC (solid blue) and for traditional norm-optimal ILC of Sec.~\ref{sec:exampleNOILC} (solid red). Also shown are the spectra $2\phi_v$ (dashed blue) and $\phi_v$ (dashed red).}
\label{fig:spectra}
\end{figure}
\subsection{Lasso ILC}\label{sec:exampleLassoILC}
To address Requirement R\ref{eq:fjspare}, the approach in Sec.~\ref{sec:lassoilc} is applied. In particular, $W_e = I$, $W_f = 0$, and $W_{{\ensuremath{{\Delta f}}}} = 0$, $D = I$, and $\lambda = 5 \cdot 10^{-9}$. Next, the ILC iteration is started, and after $40$ iterations it leads to $e_{40}$ and $f_{40}$ in Fig.~\ref{fig:ilclasresults}. Interestingly, $\|f_{40}\|_0$ is much smaller for the lasso ILC approach compared to the results of Sec.~\ref{sec:exampleNOILC}, as is confirmed in Fig.~\ref{fig:ilclasresults3}, thereby addressing Requirement R\ref{eq:fjspare}.
Also, the $2$-norm of the error signal is computed, see Fig.~\ref{fig:ilclasresults2}. Clearly, the error reduces significantly over the iterations. Finally, also the re-estimated lasso, as is explained in Sec.~\ref{sec:extensions}, is implemented. The results are also depicted in Fig.~\ref{fig:ilclasresults2}. Interestingly, it can be observed that re-estimating leads to a smaller limit error, as is expected. However, note that during the iterations, the approach of Sec.~\ref{sec:lassoilc} leads to a smaller error compared to the re-estimated version in several of the initial iterations. An explanation for this aspect is that the biased estimate leads to a smaller overall error, which is a similar effect as in the Stein estimator. Hence, it is concluded that for non-iterative approaches, the biased estimate can be useful in terms of a bias/variance trade-off, but in the iterative schemes the benefit of re-estimation is clearly confirmed in Fig.~\ref{fig:ilclasresults}.
\begin{figure}%
\centering
\includegraphics[width=.9\linewidth]{ilclasresults3}%
\caption{$\ell_0$-norm of the error for norm-optimal ILC of Sec.~\ref{sec:exampleNOILC} (\Colortwo) and lasso ILC of Sec.~\ref{sec:exampleLassoILC} (\Colorthree), which leads to a reduced error signal.}
\label{fig:ilclasresults3}
\end{figure}
\begin{figure}%
\centering
\includegraphics[width=.9\linewidth]{ilclasENresults1}%
\caption{Computed 2-norm of the error for various ILC algorithms. Traditional norm-optimal ILC in Sec.~\ref{sec:exampleNOILC} (\Colortwo) leads to a significant error reduction in the initial iterations, and then remains at a certain level due to the amplification of trial-varying disturbances. The lasso approach of Sec.~\ref{sec:exampleLassoILC} with re-estimation (\Colorfour) leads to a significant reduction in the initial iterations, in addition to a reduced limit error, since it reduces amplification of trial-varying disturbances. Also note that the lasso approach without re-estimation (\Colorthree) leads to an improved estimate in the first iteration, yet remains at a large error after convergence, which is due to the bias error in the solution. Finally, the elastic-net lasso approach of Sec.~\ref{sec:exampleENLassoILC} is shown (\Colorfive), which leads to a comparable converged performance as the lasso ILC (\Colorthree), since both do not include re-estimation in this case.}
\label{fig:ilclasresults2}
\end{figure}
\begin{figure}%
\centering
\includegraphics[width=.9\linewidth]{ilclasresults}%
\caption{Top: error $e_{40}$ at iteration $j=40$. Bottom: command signal $f_{40}$ at iteration $j=40$. Shown are lasso ILC of Sec.~\ref{sec:exampleLassoILC} (\Colorthree) and re-estimated lasso ILC of Sec.~\ref{sec:exampleLassoILC} (\Colorfour).}
\label{fig:ilclasresults}
\end{figure}
\subsection{Elastic net lasso ILC}\label{sec:exampleENLassoILC}
In this section, the approach of Sec.~\ref{sec:elasticnet} is pursued, where the lasso regularisation is extended with a ridge regression term. In particular, $W_f = 0$, while $W_{{\ensuremath{{\Delta f}}}} = 1\cdot 10^{-6} I$. The resulting error $e_{40}$ and command input $f_{40}$ are depicted in Fig.~\ref{fig:ilclasENresults}. The error is of comparable magnitude as the lasso ILC in Sec.~\ref{fig:ilclasresults}, while the command input is substantially smoother. The error in fact has slightly reduced compared to lasso ILC, as is shown in Fig.~\ref{fig:ilclasresults2}, which comes at the price of a slower convergence rate due to an increased $W_{{\ensuremath{{\Delta f}}}}$. Notice that the elastic net lasso can also be improved by re-estimation, which is not done here to facilitate the presentation.
\begin{figure}%
\centering
\includegraphics[width=.9\linewidth]{ilclasENresults}%
\caption{Top: error $e_{40}$ at iteration $j=40$. Bottom: command signal $f_{40}$ at iteration $j=40$. Shown is the elastic net lasso ILC of Sec.~\ref{sec:exampleENLassoILC} (\Colorfive), leading to a smooth command input $f_j$.}
\label{fig:ilclasENresults}
\end{figure}
\subsection{Fused lasso ILC}\label{sec:examplefusedLassoILC}
The results in the previous sections have addressed Requirement R\ref{eq:fjspare}. In certain situations, e.g., wireless sensors or embedded implementations, it may be required to minimize the number of times the command input is updated, i.e., Requirement R\ref{eq:dfjspare}. This is a different form of structure compared to sparsity. To address this, the fused lasso of Sec.~\ref{sec:fusedlasso} is employed.
In particular, in the general criterion \eqref{eq:gencrit} is considered, where the weighting filters are selected as $W_f = W_{\ensuremath{{\Delta f}}} = 0$, $D = D_f$ in \eqref{eq:fusedlassoD}, and $\lambda = 3 \cdot 10^{-12}$.
Next, the ILC iteration is invoked. The results are shown in Fig.~\ref{fig:ilclasfusedresults}. Compared to the results of Fig.~\ref{fig:ilclasresults} in Sec.~\ref{sec:exampleLassoILC}, the error has reduced significantly. However, this comes at the price of sparsity. Indeed, only the first samples are zero, since the algorithm is initialized with $f_1(0) = 0$. Interestingly, only a limited number of command signal updates are required to achieve a small error signal. This will also attenuate the effect of trial-varying disturbances. Note that the error can be further reduced by including a re-estimation step, which is not shown here to facilitate the presentation.
\begin{figure}%
\centering
\includegraphics[width=.9\linewidth]{ilclassparseresultsNEW2}%
\caption{Top: error $e_{40}$ at iteration $j=40$. Bottom: command signal $f_{40}$ at iteration $j=40$. Shown is the fused lasso ILC of Sec.~\ref{sec:examplefusedLassoILC} (\Colorfive), leading to a command input $f_j$ that addresses Requirement R\ref{eq:dfjspare}. In particular, the command signal $f_{40}$ aims to minimize the error signal in addition to the updates, i.e., instants where $f_{40}$ changes as a function of time. This does not explicitly address sparsity of $f_{40}$ itself, as can be clearly observed from the zoom plot.}
\label{fig:ilclasfusedresults}
\end{figure}
\subsection{Sparse fused lasso ILC}\label{sec:examplesparsefusedLassoILC}
In the previous sections, Requirement R\ref{eq:fjspare} and Requirement R\ref{eq:dfjspare} are achieved separately in Sec.~\ref{sec:exampleLassoILC} and Sec.~\ref{sec:examplefusedLassoILC}, respectively. To address both requirements simultaneously, the sparse fused lasso approach of Sec.~\ref{sec:sparsefusedlasso} is adopted. The regularization penalties in \eqref{eq:sparsefusedlasso} are selected such that these essentially combine the two penalties in Sec.~\ref{sec:exampleLassoILC} and Sec.~\ref{sec:examplefusedLassoILC}.
The results are depicted in Fig.~\ref{fig:ilclassparsefusedresults}. It can directly be observed that it combines the sparsity of Sec.~\ref{sec:exampleLassoILC} while at the same time reducing the number of command signal updates as in Sec.~\ref{sec:examplefusedLassoILC}. As such, it is concluded that the sparse fused lasso addresses Requirement R\ref{eq:fjspare} and Requirement R\ref{eq:dfjspare} simultaneously. The relative penalties can be further tuned to balance the importance of both penalties, as well as the resulting error signal. In addition, the resulting error signal can be further enhanced through a re-estimation step.
\begin{figure}%
\centering
\includegraphics[width=.9\linewidth]{ilclassparsefusedresultsNEW2}%
\caption{Top: error $e_{40}$ at iteration $j=40$. Bottom: command signal $f_{40}$ at iteration $j=40$. Shown is the sparsefused lasso ILC of Sec.~\ref{sec:examplesparsefusedLassoILC} (\Colorfive), leading to a command input $f_j$ that addresses Requirement R\ref{eq:dfjspare}. In comparison to the fused lasso approach in Sec~\ref{sec:examplefusedLassoILC}, here additional regularization parameters enforce a zero input signal, which can clearly be seen in the zoom plot.}
\label{fig:ilclassparsefusedresults}
\end{figure}
\section{Conclusion}
A general framework is presented that extends optimization-based iterative learning control to include additional structure, including sparsity. The approach is shown on a mechatronic system, where it is shown to have significant benefits, including
\begin{inparaenum}[i)]
\item resource-efficiency in terms of sparse command signals, e.g., facilitating embedded controller implementations;
\item resource-efficiency in terms of limiting the number of changes in the command signal, e.g., facilitating implementation in limited-capacity communication networks;
\item automated basis function selection in flexible iterative learning control employing basis functions; and
\item attenuation of trial-varying disturbances, which for the considered wafer scanner example leads to significant performance increase.
\end{inparaenum}
Regarding the latter, a detailed analysis of trial-varying disturbances in ILC reveals that such trial-varying exogenous signals are often amplified by typical ILC algorithms. The proposed framework enables a significant reduction of this amplification, typically up to a factor of two.
The proposed framework enables many user-specific choices, and can be easily extended. For instance, for third-order or higher-order setpoints, it may be useful to impose regularization parameters of equally high polynomial orders, known as polynomial trend filtering \cite[Sec.\ 2.1.2]{TibshiraniTay2011}, which is a special case of the general criterion \eqref{eq:gencrit}.
Ongoing research focusses on specialized algorithms for the considered scenarios, enabling faster computation. In addition, the correlation between variables is subject of further investigation. Finally, various aspects of monotonic convergence, which has here been analyzed in terms of the $\ell_1$-norm, are being investigated, including robust monotonic convergence conditions \cite{WijdevenDonBos2009}, \cite{DuysonPipSwe2016} and data-driven ILC frameworks \cite{JanssensPipSwe2013}, \cite{AAABolderKleOom}.%
\section*{Appendix}
In this section, a proof of Theorem~\ref{thm:noiseanalysis} is provided. Several auxiliary results are presented. In particular, note that at iteration $j$, the error is a function of all previous signals affecting the loop due to the iteration-domain integrator in \eqref{eq:freqilcupdate}. In the following lemma, the summation of $j$ terms of the trial-invariant disturbance $r$ in \eqref{eq:generalILCsystem} is eliminated.
\begin{lemma}\label{lemma:firststepproof}
Consider the system \eqref{eq:generalILCsystem} and ILC update \eqref{eq:freqilcupdate} with $f_0 = 0$ and assume that iteration is stable in the sense of Theorem~\ref{thm:contractionmap}. Then,
\begin{align}\label{eq:eliminater}
e_j =& \left(
1 - \tf[J] \frac{1-(\tf[Q](1-\tf[L]\tf[J]))^{j}}{1-\tf[Q](1-\tf[L]\tf[J])}\tf[Q]\tf[L]\right)r\\
&-
v_j
-
\tf[J] \sum_{n=0}^{j-1}(\tf[Q](1-\tf[L]\tf[J])^n\tf[Q]\tf[L]v_{j-n-1}.
\end{align}
\end{lemma}
\begin{proof}
Substituting \eqref{eq:generalILCsystem} into \eqref{eq:freqilcupdate} yields
\begin{equation}
f_{j+1} = \tf[Q]((1-\tf[L]\tf[J])f_j + \tf[L]r - \tf[L] v_j).
\end{equation}
Given $f_0 = 0$ and subsequent successive substitution yields
\begin{math}
f_1 = \tf[Q](\tf[L]r - \tf[L]v_0)
\end{math},
\begin{math}
f_2 = \tf[Q]((1-\tf[L]\tf[J])+1)\tf[Q]\tf[L]r - \tf[Q](1-\tf[L]\tf[J])\tf[Q]\tf[L]v_0 -\tf[Q]\tf[L]v_1,
\end{math}
and hence
\begin{equation}
f_j = \sum_{i=0}^{j-1}(\tf[Q](1-\tf[L]\tf[J]))^{i} \tf[Q]\tf[L]r - \sum_{n=0}^{j-1}(\tf[Q](1-\tf[L]\tf[J]))^{n}\tf[Q]\tf[L]v_{j-1-n}.
\end{equation}
Next, using the geometric series
\begin{equation}\label{eq:geometricseries}
\sum_{l = 0}^{j-1} r^l = \frac{1 - r^j}{1-r},
\end{equation}
this leads to
\begin{equation}\label{eq:almostfinalstep}
f_j = \frac{1-(\tf[Q](1-\tf[L]\tf[J]))^{j}}{1-\tf[Q](1-\tf[L]\tf[J])}\tf[Q]\tf[L]r - \sum_{n=0}^{j-1}(\tf[Q](1-\tf[L]\tf[J]))^{n}\tf[Q]\tf[L]v_{j-1-n}.
\end{equation}
Finally, substitution of \eqref{eq:almostfinalstep} into \eqref{eq:generalILCsystem} yields the desired result \eqref{eq:eliminater}.
\end{proof}
The result~\eqref{eq:eliminater} reveals that the error contains a summation over $j$ trial-varying disturbance terms $v_j$, whereas the influence of the trial-invariant disturbances is captured in a single term through the use of a geometric series. Although the trial-varying disturbance varies on each experiment, a closed-form expression can be obtained by exploiting Assumption~\ref{assum:noise}.
\begin{lemma}\label{lemma:secondstepproof}
Let Assumption~\ref{assum:noise} hold. Then, under the assumptions of Lemma~\ref{lemma:firststepproof},
\begin{align}\label{eq:eliminatev}
\phi_{e_j} =& \left|
1 - \tf[J] \frac{1-(\tf[Q](1-\tf[L]\tf[J]))^{j}}{1-\tf[Q](1-\tf[L]\tf[J])}\tf[Q]\tf[L]
\right|^2 \phi_r \\
&+
\left(
1
+
\left|
\tf[J]\tf[Q]\tf[L]
\right|^2
\frac{1-|\tf[Q](1-\tf[L]\tf[J])|^{2j}}{1-|\tf[Q](1-\tf[L]\tf[J])|^2}
\right)\phi_v
\end{align}
\end{lemma}
\begin{proof}
Taking spectra yields
\begin{align}
\phi_{e_j} =& \left|
1 - \tf[J] \frac{1-(\tf[Q](1-\tf[L]\tf[J]))^{j}}{1-\tf[Q](1-\tf[L]\tf[J])}\tf[Q]\tf[L]
\right|^2 \phi_r \\
&+
\left(
1
+
\left|
\tf[J]\tf[Q]\tf[L]
\right|^2
\sum_{n=0}^{j-1}
\left|
(\tf[Q](1-\tf[L]\tf[J]))^n
\right|^2
\right)\phi_v.
\end{align}
Next, using \eqref{eq:geometricseries} yields the desired result \eqref{eq:eliminatev}.
\end{proof}
The closed-form solution~\eqref{eq:eliminatev} enables a direct proof of Theorem~\ref{thm:noiseanalysis}.
\begin{proof}(of Theorem~\ref{thm:noiseanalysis})
Taking the limit $j \rightarrow \infty$ implies that $|(1-\tf[L]\tf[J]))^{j}| \rightarrow 0$, directly leading to the desired result \eqref{eq:limiterrorspectrum}.
\end{proof}
\section*{Acknowledgements}
This paper is the result of several research visits of both authors, which is supported in part of the research programme VENI with project number 13073, which is (partly) financed by the Netherlands Organisation for Scientific Research (NWO). In addition, the authors gratefully acknowledge the fruitful discussions with Jurgen van Zundert, Maurice Heemels, Dip Goswami, and Martijn Koedam for resource-efficient control, as part of the Robust Cyber-Physical Systems (RCPS) project (no. 12694).
\bibliographystyle{abbrv}
| {'timestamp': '2017-06-07T02:04:20', 'yymm': '1706', 'arxiv_id': '1706.01647', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01647'} | arxiv |
\section{Introduction}\label{sec:introduction}}
\IEEEPARstart{S}{ensor} Networks and Wireless Sensor Networks (WSN) are two main components involved in the development of the
Internet of Things (IoT). Security and privacy handling for Sensor Networks present new issues due to specific constraints. Low resources on computation, hardware functionalities and energy consumption in WSNs. We can divide research work into two categories: security and privacy for the data being sent over the network on one side, and node authentication and trust management on the other side.
Both have been actively explored the last ten years, and some solutions have been brought by researchers. However, from our knowledge none of these works propose a complete model for both content access, security, privacy and trust management. In this paper, we focus on addressing authentication and trust management issues.
\subsection{Overview}
During our researches, we have separated existing work into two distinct research areas. The first one is authentication and trust management issues in decentralized networks and WSN. Then we consider ongoing work on blockchains and their applications.
\subsubsection{Authentication and trust for decentralized networks}
We can find a lot of different approaches for authentication in WSN and the IoT in the literature. As outlined by Medaglia {\textit et al.}\cite{Medaglia2010}, WSNs have specific security constraints on node authentication to ensure data validity and confidentiality.
Trust management is tied to authentication mechanisms, as a the mean to identify the trustee and the truster. We take previous work on trust evaluation in distributed networks by Sun {\textit et al.}\cite{sun2006trust}, as a reference on issues concerning trust in decentralized networks for our work.
\subsubsection{Blockchain as a secured data structure}
Recent work by Zyskind et al.\cite{Zyskind2015} shows the interest of the blockchain as a personal data management platform focused on privacy. They outlined how the blockchain helps leveraging user control over data in the context of social networks and big data. Foutiou et al.\cite{Fotiou2016} describe a decentralized name based security system using blockchains to secure contents access in Information-Centric Networking based architectures. These approaches prove usability of the blockchain as a secure decentralized data structure for new applications, but none has been used to provide node authentication and trust management in Wireless Sensor Networks (WSN) and in the Internet of Things (IoT).
\subsection{Our Contribution}
We propose a model based on blockchain data structure used to store decentralized authentication and node trust informations. This model is evolutive, adaptative and ensure reliability over time.
\subsection{Organization}
We first explain briefly the blockchain data structure as presented in Bitcoin. Then we present issues in decentralized node authentication and trust management for WSN. The last part of this paper describes our model of a blockchain based solution for authentication and trust management which provide a solution to overcome decentralized networks issues.
\section{The blockchain technology}
In 2008, a person or group of persons known under the name of Satoshi Nakamoto published a paper\cite{Nakamoto2008} dealing with a new decentralized peer-to-peer electronic cash system. This paper introduces the blockchain as a new data structure to store financial transactions, as well as an associate protocol to ensure the validity of the blockchain in the network.
\subsection{Data structure}
In his paper, Nakamoto describes the blockchain as a database modeled by a linear sequence of blocks, each one containing cryptographic hashes corresponding to the previous and current block to ensure continuity and immutability. Bitcoin uses the blockchain to store financial transactions and contracts.
\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{blockchain-bitcoin-link-blocks}
\caption{Bitcoin block chaining mechanism. The Merkle root of all transactions is included in the block header and then used as input for the next block in the chain.}
\label{fig:Bitcoin-block-chaining}
\end{figure}
The chaining method used in Bitcoin (Figure \ref{fig:Bitcoin-block-chaining}) ensures the immutability by using the hash of the previous header block hash in the current block. The header includes the root hash of the Merkle tree of all transactions in the block. This way transactions cannot be changed without changing the root Merkle hash and then invalidating the block. Due to the way the blockchain is built, fork chains can append with different valid blocks storing different transactions. The Bitcoin protocol resolves this issue by selecting the longest blockchain as the correct one. Note that due to this choice, even after being included in a valid block, transactions can be considered valid only after a subsequent block has been calculated and successfully included in the blockchain by the majority of the network \cite{eyal2016bitcoin}.
\subsection{Secure distributed storage based on blockchains}
We consider the blockchain data structure outside of its application in Bitcoin, as a generic decentralized secured data storage structure. It is possible to use any data payloads other than transactions as parts of the block. The block is then divided in two parts, (a) the block constants and header and (b) the data payloads, as shown in Figure \ref{fig:generic-block-parts}.
\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{generic-block-parts}
\caption{Blocks used as generic storage. We use structured payloads and replace transactions by payloads in the Merkle root hash computation.}
\label{fig:generic-block-parts}
\end{figure}
A single modification in one payload of a block will change its Merkle root hash value, and then invalidate it. This solution thus provides secure and reliable storage distributed among all peers in the network. Note that this implies that the complete blockchain and all datas linked to it must be duplicate on all peers. The size of data payloads will influence both the hash calculation algorithm and bandwidth used to maintain the blockchain. Due to bandwidth restriction in the platform we use, we choose to limit the total size of a block to 5 MB to ensure we have enough storage for important security and trust informations without overloading the network with blockchain control data.
\section{Authentication and Trust in WSN}
Authentication and trust can be seen as two parts of the same problem \cite{solhaug2007trust}. Authentication allows us to be sure to who we are dealing with, trust giving us insights of how we can rely on and dealing with a potential risk on an action. If we consider the presence of a master authority in charge of authentication and trust management, we can easily ensure a good security and privacy level in the network. However, this has a major drawback, the master authority becomes the central part of the network security and thus the critical point of vulnerability in the network. In decentralized and ad-hoc networks, this approach is impossible, because we don't have a node which can assure to be connected at every moment of the network life.
\subsection{Our Framework}
To ensure proper organization and content management in decentralized networks, we use a common content model based on Service Oriented Architecture\cite{erl2005service} adapted for our application and compatible with CoAP protocol\cite{shelby2014constrained}. This approach allows us to design a RESTful model for interaction with the internet, and his currently outlined at one promising approach to organize sensor networks\cite{de2011service}.
\subsubsection{Network services model}
Before further introspection on our blockchain based model, we must define the network model we use. Wireless Sensor Networks can be well described as decentralized networks composed of resource constrained nodes based on embedded devices. We choose to model the network as an undirected graph \(G=(V,E)\), each vertex describing a node in the network, and each edge links two nodes within transmission range from each other. Then we associate abilities and services to nodes, providing resources on the network. In this model we define two entities formalized as a set of characteristics vectors.
\begin{itemize}
\item Network Node (NN) defines a vector of Node Properties (NP) and another of Node Abilities (NA)
\end{itemize}
\begin{equation}
NN = \begin{pmatrix}
NP = \begin{bmatrix}
name & energy & cpu \\
\end{bmatrix} \\
NA = \begin{bmatrix}
camera & storage \\
\end{bmatrix}
\end{pmatrix}
\end{equation}%
\begin{itemize}
\item Available Services (AS) defines an Abilities Dependencies (AD) vector, a Resources Dependencies (RD) vector and a Resources Provider (RP) vector
\end{itemize}
\begin{equation}
AS = \begin{pmatrix}
AD = \begin{bmatrix}
camera & storage \\
\end{bmatrix} \\
RD = \begin{bmatrix}
\\
\end{bmatrix} \\
RP = \begin{bmatrix}
videostream & videorecording \\
\end{bmatrix}
\end{pmatrix}
\end{equation}%
Each node stores services in a Service Registry (SR). Nodes having the storage ability can store services they cannot deploy to ensure reuse of these services in the future on other nodes.
In the next section, we refer to our service model and related abbreviations to describe our solution providing authentication and trust management mechanisms for decentralized networks.
\section{Blockchain Authentication and Trust Module (BATM)}
Public Key Infrastructure (PKI) is a major component to resolve authentication in networks. In 1991, Zimmerman introduce a new concept named web of trust for his Pretty Good Privacy (PGP) encryption program~\cite{zimmermann1995official}, which was then standardized by the IETF under the OpenPGP name. Current version of the standard is described in RFC 4880\cite{callas2007rfc}. OpenPGP use PKI to provide three main functionalities.
\begin{itemize}
\item Confidentiality with Encryption
\item Authentication via Digital Signature
\item Web of Trust via identity validation from peers
\end{itemize}
BATM proposes a new way to achieve these goals using the blockchain as the database to store public keys, digital signature and peer informations, allowing each component of the network to validate informations about every other node in the network.
This section explains the global design of BATM in regard to three aspects. First, we focus on authentication, public keys, block mining and their mutual influence. Then we explain principles and particularities of the block exchange protocol and associate rules. Finally, we describe how the combination of authentication and protocol rules allows to define a trust management model.
\subsection{BATM authentication}
BATM associates cryptographic keys with each NN and AS in the network. We use the idea contained in the PGP model of a master key to identify a NN or AS among its lifespan. This key is only used to generate secondary keys for encryption and digital signature. As in most PKI, private keys are the main component of the system, and so key management is particularly critical. An attacker can easily spoof NN identity if he retrieves its keys. In this regard, implementations will need to be careful in the choice of the keyring to store private keys, but we won't address this issue in this paper.
\subsubsection{BATM block mining}
We assimilate each data payload as an event providing informations about the status of a NN and its cryptographic informations. At authentication, a node submits a credential payload containing its master public key along with secondary keys. We ensure key renewal to mitigate attacks known for guessing keys by using key validity timeouts.
As network security and privacy relies on informations contained in the blockchain, our design forbid to add blocks uniquely by resolving the problem and satisfy header hash requirement. More precisely, only authenticated nodes can mine new blocks, and only if they haven't issued a payload to be included in the block. To fullfill these requirements, miners must choose which payloads to include in the block they try to resolve.
To be valid, a block must both resolves the problem and contains a valid Miner Approval (MA) payload generated by the Miner, illustrated by the algorithm in Figure \ref{alg:block-validation}. This kind of payload contain a digital signature of a random value contained in the previous block MA payload, and must correspond to a successfully authenticated node.
\begin{figure}
\begin{algorithmic}[1]
\Require currentblock previousblock
\Ensure block validity
\If{ not(HashCurrentBlock resolves problem)}
\State return false
\EndIf
\If{ not(MinerApproval payload valid)}
\State return false
\EndIf
\If{ CurrentBlock has event payload for miner NN}
\State return false
\EndIf
\If{ not(all payloads in block valid)}
\State return false
\EndIf
\State return true
\end{algorithmic}
\caption{Block validity check algorithm.}
\label{alg:block-validation}
\end{figure}
\subsubsection{BATM data payloads}
When a NN or AS requests to join the network for the first time, it issues a specific Credential Payload (CP) to all NNs. A CP contains public keys needed to operate in the network. Authentication request is approved when an authenticated NN includes the CP in a valid block.
Credential status of the NN / AS can be subsequently updated by renew payload and revoke payload. Note that when revoking his credential, a NN / AS must provide a new credential payload to remain authenticated in the network. Miners will try to include revoke payload and new credential payload in the same block to ensure continuity of node status in the network.
If we allow submission of payloads without further verification, every node could be allowed to propose payloads in the network. To overcome this issue, payloads use a system of signed hash digests. Every payload must have a hash digest signed by payload issuer as its last entry. This way, our payload verification algorithm can easily check the validity of the data. Note that revoke payload use the master key to sign data hash, whereas other payloads use the current signature subkey.
BATM uses 6 different payload types as follows.
\begin{itemize}
\item MA (Miner Approval)
\item NN and AS Payloads
\begin{itemize}
\item Credentials
\item Renew
\item Blame
\item Ban
\item Revoke
\end{itemize}
\end{itemize}
We provide a detailed description of data contained in BATM payloads in Figure \ref{fig:batm-data-payload}. Note that Blame and Ban payloads are specific payloads used in BATM trust management model.
\begin{figure}
\centering
\includegraphics[width=0.45\textwidth]{batm-data-payloads}
\caption{Data payloads available in BATM. All blocks must have a Miner Approval payload to be valid, to verify which node has allowed the authentication entry.}
\label{fig:batm-data-payload}
\end{figure}
We showed how our model of a PKI using the blockchain ensure reliable storage for cryptographic material, and how we use it to perform NN authentication on the network. We then propose a trust management model using informations contained in the blockchain.
\subsection{BATM trust management}
The first need for a definition of trust originated from social studies to characterize relations between people in the society. In this context, we consider relevant to use Gambetta's definition of trust\cite{Gambetta1990} as an assumption on the level of subjective probability about how a particular agent will perform an action from a subjective point of view. Note that we understand the term of subjective probability as a reputation level applied to the realization correctness of a subsequent action in the future.
This interpretation of trust implies that the reputation level associated with an agent must vary over time to match the actual realization of the action. Good behaviour must be rewarded, and bad behaviour must be punished to maintain accurate prediction on the realization of actions.
\subsubsection{Knowledge based trust for BATM}
The BATM module includes a trust model called Human-like Knowledge based Trust (HKT), based on human like behaviour to maintain a reputation level for each node. HKT is a compromise between a mutual surveillance by all nodes on the network and the presence of a trust center.
We use the payloads contained in the blockchain as an indication of each node behaviour on the network over time. This way, we ensure a node cannot fool others by tampering data or pretending to be someone else. Thus we ensure reliability of trust evaluation without the need of a trust center. Following development will be targeted at NN trust evaluation, but same principles apply to AS, with the particularity that AS reputation level is echoed on each node in the network, thus modifying reputation level on each node using it.\\
For each payload type, HKT defines events and associates them reputation factors. We note \(C_{evt}\) the reputation factor for the event, and \(T_{evt}\) the time the event occured.
To make the NN reputation evolve naturally over time, each event reputation factor must be weighted by a function evolving in time since the event occurs. As we want to decreasing contribution of a particular event to the NN reputation level over time, we need to use a continuous decreasing function such as \(e^{-x}\).
During it first authentication, a NN has no passed action to compute a reliable trust value. Thus we choose to grant a base trust value to all nodes when a trusted node gives them access to the network by including their credentials in the blockchain.
For the simulations, we used the following values for event reputation factors.
\begin{itemize}
\item \(C_{approval} = 1\)
\item \(C_{auth} = 8\)
\item \(C_{renew} = 2\)
\item \(C_{blame} = -8\)
\item \(C_{ban} = -16\)
\end{itemize}
We have estimated the following formulas to determine the reputation of node over time.\\
\begin{equation}
\forall evt \in (N,Blk(t)): C_{N,t} = \sum C_{evt}
\end{equation
\vspace{-.2cm}
\begin{equation}
Reputation(N,t_{now}) = C_{auth} + \sum_{t=t_{first}}^{t=t_{now}} C_{N,t} * e^{\frac{-(t_{now}-t)}{256}}
\end{equation}%
In this formula, \(t_{first}\) corresponds to the first block in the blockchain after node has authenticated. \(C_{t}\) is used as the global coefficient for all events concerning the node at \(t\) (the sum of all \(C_{evt}\) at \(t\)).
\begin{figure}
\centering
\includegraphics[width=0.45\textwidth]{trust-simul-3-nodes-modif.png}
\caption{Reputation level simulation over 500 hours with 3 NN. After 2 blames, a ban is declared on the node and becomes effective for a 84 hours.}
\label{fig:trust-simul-3-nodes}
\end{figure}
\subsubsection{Trust evaluation}
As we defined it earlier, we consider trust as a probability level that an action will be performed correctly by a NN. In this context, we perform trust evaluation by comparing the current reputation level of a NN to trust him doing certain actions in the network. Currently, we only defined blockchain related actions and associate them with a trust level \(A_{evt}\). This level quantifies the minimum reputation level for a node to be trusted to fullfill subsequent event \(evt\). The trust level is weighted by the number of authenticated NN noted \(N_{auth}\), in order to be less restrictive on actions in a small network and more on huge networks. This behaviour allows NN on the network to work properly and becoming trust defaultive in small network, and then raise the trust level required when more nodes are available.
BATM defines the following trust levels, as equivalent for trust events \(C_{evt}\) described earlier.
\begin{itemize}
\item \(A_{auth}\)
\item \(A_{ban}\)
\item \(A_{blame}\)
\item \(A_{approval}\)
\end{itemize}
We provide following formula to compute values of \(A_{act}\) over time, with \(A_{app}\) being an application factor, allowing applications to be more or less restrictive on actions.
\begin{equation}
A_{evt} = C_{evt} + \frac{A_{app} * (N_{auth} - 1)}{ C_{evt}}
\end{equation}
Note that reputation level simulation in Figure \ref{fig:trust-simul-3-nodes} does not consider minimum trust level required for a NN to fullfill an action.
We showed how BATM with HKT provide a powerful solution to authenticate nodes and evaluate trust in decentralized networks. The system can be made instable by malicious authenticated nodes overloading the network and submitting lots of valid payloads for inclusion in the blockchain. To overcome this issue, we define specific rules for payload submission in the network to improve stability of the system over time.
\subsection{BATM payload rules}
To avoid abuse from NN which can overload the network with payloads to be validated, we introduce specific rules on the payload exchange protocol for BATM. We consider two type of rules : timers, key validity timeouts and event reputation factors described earlier. Timers are limitation in time used to discard payloads and blocks submitted by NN overloading the network.
A set of timers defines the minimum amount of time expected between two payloads of the same type. BATM currently uses 3 timers as follows.
\begin{itemize}
\item \(T_{renew}\) is the usual time between two key renewal by a node. If needed, a node is authorized to renew its keys at \(T_{renew} / 2\). Here we ensure there are at most 2 renews in a \(T_{renew}\) for a given NN.
\item \(T_{blame}\) is the minimum time between two blames on a NN given by the same blamer NN.
\item \(T_{banrecover}\) is the time during which a banned NN will be forbidden to mine subsequent block as punishment for a bad behaviour in the network.
\end{itemize}
These timers imply that key validity timeouts must respect the following rules for BATM to work properly.
\begin{itemize}
\item \(T_{subkey}\) is the timeout for subkeys before renewal. It must be greater than \(T_{renew}\), but less than \(50 * T_{renew}\) to be overcome issue that an attacker may be able to guess the key from data collected in the network.
\item \(T_{masterkey}\) is the timeout for the master key. In our model, it should be greater than \(10 * T_{subkey}\) and no more than \(50 * T_{subkey}\) to protect it from key guessing attacks.
\end{itemize}
As indication, simulation results showed in Figure \ref{fig:trust-simul-3-nodes} used following timer values, in hours.
\begin{itemize}
\item \(T_{renew} = 168\)
\item \(T_{blame} = 42\)
\item \(T_{banrecover} = 84\)
\end{itemize}
As these rules can be defined to different values regarding the application using BATM, we use the first block in the blockchain to store values to be used. Thresholds will be defined in the future to overcome a problem with a malicious initial NN, and what we called the origin block problem.
\subsubsection{Origin block problem}
At startup, the network contains no authenticated node to realize BATM authentication and trust evaluation, and the blockchain is empty. This means we need a method to forge the first block. We choose to let any node craft this special block from its own parameters. In fact, the main problem is to ensure proper operation in the beginning of the network life, then BATM will adapt itself to events occuring in the network. If the first NN is malicious, it will be banned by others node early in the network.
Since the first block contains all mutable values used in BATM, a possible attack will be the inclusion of specific values which will tend the system to misbehave. To counter this threat, future work will provide a formula to estimate the probability of BATM instability from these values.
\section{Future work}
We presented the concept and model of BATM, with early results on reputation evaluation over time. The next step is to evaluate each part of BATM completely and the global model. The model itself will be improved depending on the results, with the objective of more adaptative algorithms taking AS and NN characteristics as defined in our model.
\subsection{Trust model}
BATM with HKT provide a simple way to manage trust in decentralized networks. More researches on HKT performance must be conducted, and the model itself may evolve to consider more parameters in trust and reputation evaluation. We think about considering NN and AS abilities in account for specific actions, and enhance the reputation calculations. For example, a blamer reputation could influence the reputation factor of its blame, and we may introduce a time coefficient to raise trust on the overall time presence of the NN or AS in the network. Another possibility is to raise resilience over DoS attacks by requiring blames from different NN or AS before banning one.
In this paper, we consider self-organizing networks with no constraints on which NN may ask to authenticate. We also let possible a derivative model, using a network master key to allow blockchain supervision and eliminate the first block problem. A possibility may be to allow specific network, for example vendor-specific networks, where NN can provide a proof of membership by prior network master key signature.
\subsection{Real world testing}
If simulation results fullfill our expectations, BATM will be included in Multicast Services for Linux (MSL), an implementation our SOA network model. Note that MSL is at development stage for now with now release date. Moreover, MSL is intended to be used as a real world proof of concept for our overall design including SOA model and BATM with HKT.
\section{Conclusion}
This paper proposes a new application for the blockchain as a secured decentralized storage for cryptographic keys as well as trust informations in the context of autonomous Wireless Sensor Networks. The Blockchain Authentication and Trust Module and its Human-like Knowledge based Trust model shows how to use to immutability of the blockchain to provide solutions to high problematics in the field of decentralized ad-hoc networks. More precisely, we show how it is possible to build a complete solution providing authentication mechanisms as well as trust evaluation in a self-organized and evolutive network.
\subsubsection*{Resources}
The Service Oriented model is currently under development into the Multicast Services for Linux (MSL) framework. MSL is a free software and will be publicly available at https://bullekeup.github.io/MSL, under the AGPL license. BATM will be available in MSL in the next months. HKT simulation files for GNU Octave and MATLAB are available by mail on request at axel.moinet@u-bourgogne.fr.
\ifCLASSOPTIONcompsoc
\section*{Acknowledgments}
\else
\section*{Acknowledgment}
\fi
The authors would like to thank the Burgundy Region and the FEDER european fund for funding this research work.
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\enlargethispage{.5cm}
\bibliographystyle{IEEEtran}
| {'timestamp': '2017-06-07T02:05:59', 'yymm': '1706', 'arxiv_id': '1706.01730', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01730'} | arxiv |
\section{Introduction}
\label{sec:1}
Diffusion MRI is a powerful non-invasive imaging technique widely used to explore white matter in the human brain.
Diffusion Tensor Imaging (DTI)~\citep{Basser1994} is used to reconstruct a tensor field from diffusion weighted images (DWIs).
High Angular Resolution Diffusion Imaging~\citep{TuchMRM2002,frank_MRM2002,Descoteaux2007,tournier_NI2007,Cheng_PDF_MICCAI2010,cheng_MICCAI2015,cheng_NI2014,ozarslan_NI13},
which makes no assumption of a 3D Gaussian distribution of the diffusion propagator, is used to reconstruct a general function field from DWIs,
(e.g., an Orientation Distribution Function (ODF) or Ensemble Average Propagator (EAP) field).
Both the ODF and the EAP fields with a given radius are spherical function fields.
Exploring microstructural information from the reconstructed tensor field or spherical function field is of interest in many biological and clinical application areas,
which makes diffusion MRI a powerful means to study white matter.
For example, in an voxel exhibiting anisotropic diffusion, local peaks of the reconstructed spherical function or the principal eigenvector of the reconstructed 2nd-order diffusion tensor normally prescribe the fiber directions in that voxel.
Some scalar indices have been proposed to be estimated voxel-wise from tensors/ODFs/EAPs.
For DTI, well-established tensor scalar indices, including the mean diffusivity and Fractional Anisotropy (FA), are widely used as biologically meaningful descriptors~\citep{Pierpaoli1996}.
\cite{Kindlmann_TMI2007} proposed two sets of scalar indices (three scalar indices per set), which are orthogonal in terms of tensor changes and the Euclidean inner product.
For High Angular Resolution Diffusion Imaging (HARDI), the generalized FA~\citep{Tuch2004}, Orientation Dispersion index (OD)~\citep{zhang_NODDI_NI2012}, return-to-origin probability~\citep{helmer_MRM2003,Wu_NI2007}, and mean-squared displacement~\citep{basser_MRM2002,Wu_NI2007}
were all proposed for ODFs and EAPs.
These indices indicate some information inside a voxel, but cannot describe local geometric or topological information, including fiber crossing, fanning, bending, and twisting, in a local spatial neighborhood.
Some previous works have extracted local geometric information by considering the local spatial change of tensor fields or ODF fields.
\cite{pajevic_JMR2002} demonstrated that the norm of the spatial gradient of the tensor's isotropic and anisotropic parts can detect boundaries between white matter, CSF, and gray matter.
\cite{Kindlmann_TMI2007} proposed tangents of scalar invariants and rotation tangents, which are 2nd-order tensors,
and also proposed projecting the 3rd-order spatial gradient tensor onto these 2nd-order tangents to obtain the spatial direction with the largest change of scalar indices or rotation of tensors.
Based on the rotation tangents of tensors, \cite{Savadjiev_NI2010} proposed fiber curving and fiber dispersion indices.
\cite{tax_NI2016} proposed a sheet probability index to quantify the local sheet structure by using spatial changes of ODF peaks.
\cite{duits:2009,duits:IJCV2011,portegies:PLOSOne2015} proposed spatial and spherical smoothing to enhance an ODF field in a PDE framework, preserving crossing structures.
\cite{reisert_TMI11,JianCheng_NNSD_ISBI13,michailovich:TMI2011} considered spatial coherence in ODF estimation.
The terms ``splay'', ``bend'' and ``twist'' have been used to qualitatively describe complex local white matter structural configuration in literature of diffusion MRI for about 20 years~\citep{basser_ANYAS1997,pajevic_JMR2002,dMRI_book2009}.
However, to our knowledge, there is no existing work that \emph{quantitatively} describes the degree of local orientational change of white matter,
including splay, bend, and twist, from general ODF fields in dMRI,
although the fiber curving and dispersion indices in~\cite{Savadjiev_NI2010} can be seen to quantify ``splay'' and ``bend'' for a tensor field in DTI.
\cite{basser_ANYAS1997} discussed the initial idea to study the torsion and curvature of a fiber tract by using the Frenet frame~\footnote{\href{https://en.wikipedia.org/wiki/Frenet-Serret_formulas}{https://en.wikipedia.org/wiki/Frenet-Serret\_formulas}} along the tract.
Torsion and curvature from the Frenet frame were later used in diffusion data analysis in~\cite{batchelor_MRM2006}.
\cite{savadjiev_ICCV2007} used the Frenet frame as a prior in the relaxation labeling algorithm to regularize the data and estimate ODFs in voxels.
These works on the Frenet frame studied geometric information along a single tract.
However, tractography is known to be sensitive to a large number of parameters,
and any flaws in the reconstructed tracts due to noise or parameter selection will inevitably be reflected in the geometric information that is extracted subsequently.
\cite{piuze_PAMI2015} proposed moving frames determined by the geometry of cardiac data, and calculated Maurer-Cartan connections.
However this method is not applicable to general diffusion MRI data, and does not consider the sign ambiguity in the frame.
There exist some connections between diffusion MRI data analysis and liquid crystals.
Orientational order parameter is well-established to describe the degree of alignment in liquid crystals~\cite{andrienko_2006}.
\cite{lasivc:FrontiersInPhysics2014,szczepankiewicz:NI2015} calculated the order parameter map by estimating variance of microscopic diffusion parameters from the contrast between diffusion signals measured by directional and isotropic diffusion encoding.
However, it cannot be used for general DTI and HARDI data.
\cite{topgaard:PCCP2016} used a diffusion tensor method to estimate the director orientations of a lyotropic liquid crystal as a spatially resolved field of Saupe order tensors.
In this paper, inspired by orientation and distortion analyses applied to liquid crystals,
we propose a unified framework, called Director Field Analysis (DFA), to study the local geometric information of white matter from the reconstructed spherical function field.
DFA works both for tensor fields obtained from DTI and for spherical function fields from HARDI.
At the voxel level,
1) the Orientational Order index (OO) and Orientational Dispersion index (OD) are defined for the spherical function in a voxel with a given axis (e.g., the ODF with its principal direction);
and 2) the principal direction is extracted from the spherical function in such a voxel exhibiting anisotropic diffusion.
At a local neighborhood level,
1) an orthogonal coordinate frame is defined for each voxel with anisotropic diffusion, where the first axis is the extracted principal direction;
2) OO is defined for spherical functions in a local neighborhood with the given principal direction;
and 3) three distortion indices (splay, bend, twist) and a total distortion index are defined based on the spatial directional derivatives of the principal direction.
An overview of the DFA pipeline for a spherical function field is shown in Fig.~\ref{fig:DFA}.
\begin{figure*}[t!]
\centering
\includegraphics[width=1.0\textwidth]{DFA_pipeline2}
\caption{\label{fig:DFA}Director Field Analysis (DFA) pipeline for an ODF field obtained from DTI or HARDI.
DFA provides total six scalar indices calculated from a spherical function field at the voxel level and at the local neighborhood level.}
\end{figure*}
This paper is organized as follows.
Section~\ref{sec:method_tensor} provides a unified overview of existing works on tensor field analysis for exploring local geometric information~\citep{pajevic_JMR2002,Kindlmann_TMI2007,Savadjiev_NI2010},
which is also a motivation for the proposed DFA.
Section~\ref{sec:method} proposes the DFA framework that works for both diffusion tensor fields and ODF fields.
Section~\ref{sec:experiments} demonstrates some results of synthetic and real data experiments by using DFA.
Section~\ref{sec:discussion} discusses some issues on implementing DFA.
\section{Tensor Field Analysis}
\label{sec:method_tensor}
This section provides an overview of existing works exploring the local geometric features of a 2nd-order diffusion tensor field by using the spatial gradient of tensors~\citep{pajevic_JMR2002,Kindlmann_TMI2007,Savadjiev_NI2010} in a unified framework.
It also proposes a new 4th-order structure tensor applied to 2nd-order tensor data that generalizes the conventional 2nd-order structure tensor applied to scalar fields.
\textbf{The 2nd-order diffusion tensor field}.
In a diffusion tensor field denoted as $\BM{D}$, there is a diffusion tensor $\BM{D}(\mathbi{x})$ at the voxel $\mathbi{x}$, where $\BM{D}(\mathbi{x}) \in S_+^3$,
and $S_+^3$ is the set of $3\times 3$ symmetric positive definite matrices.
The diffusion tensor is symmetric with six unique (i.e., independent) elements.
\textbf{The 3rd-order spatial gradient of the diffusion tensor}.
For a tensor field denoted as $\BM{D}$ with elements $[D_{ij}(\mathbi{x})]$ at the voxel $\mathbi{x}$, its spatial gradient at voxel $\mathbi{x}$, denoted as $\nabla_\mathbi{x} \BM{D}(\mathbi{x})$, is a 3rd-order tensor with elements $[D_{ij,k}(\mathbi{x})=\frac{\partial D_{ij}}{\partial x_k}(\mathbi{x})]$, where $i,j,k\in \{1,2,3\}$.
Since the diffusion tensor is symmetric with six unique elements, the 3rd-order spatial gradient has 18 unique elements.
\textbf{Mapping the 3rd-order spatial gradient to a vector}.
Let $\BM{W}=[W_{ij}]$ be a designed 2nd-order weighting tensor in tensor space,
then the tensor inner product
\begin{footnotesize}
\begin{equation}\label{eq:tensor2vector}
\BM{W} : \nabla_\mathbi{x} \BM{D} =\sum_{ij} W_{ij} D_{ij,k} = \sum_{ij} W_{ij} \frac{\partial D_{ij}}{\partial x_k} = \frac{\partial \sum_{ij}W_{ij} D_{ij}}{\partial x_k}
\end{equation}
\end{footnotesize}%
produces a vector in the image space that is the spatial gradient of the scalar field $\sum_{ij}W_{ij} D_{ij}$ at the voxel $\mathbi{x}$.
Note that the inner product in~\EEqref{eq:tensor2vector} is performed at voxel $\mathbi{x}$, and the $\mathbi{x}$ dependency is omitted in the notation if there is no ambiguity.
There are several ways to design a physically meaningful weighting tensor, $\BM{W}$.
$\BM{W}$ could be a constant independent of spatial position, $\mathbi{x}$, or a function of $\mathbi{x}$.
1) If $\BM{W}=\frac{1}{3} \BM{I}$, then $\sum_{ij}W_{ij} D_{ij}$ is the mean diffusivity field, and~\EEqref{eq:tensor2vector} is its spatial gradient.
2) If $f: \BM{D}\in S_+^3 \mapsto f(\BM{D})\in \mathbb{R}^1 $ is a scalar function that maps $\BM{D}$ to a scalar value, then $\frac{\partial f(\BM{D})}{\partial \BM{D}}$ is the gradient of the scalar function, which is also a 2nd-order tensor with elements $[\frac{\partial f(\BM{D})}{\partial D_{ij}}]$.
If we set $\BM{W}=\frac{\partial f(\BM{D})}{\partial \BM{D}}$, then the vector in~\EEqref{eq:tensor2vector} is the spatial gradient of the scalar field $f(\BM{D}(\mathbi{x}))$,
because of $\frac{\partial f}{ \partial \mathbi{x}} = \frac{\partial f}{\partial \BM{D}} : \frac{\partial \BM{D}}{\partial \mathbi{x}}$ by the chain rule.
If $f(\BM{D})$ is the mean diffusivity function, then $\frac{\partial f}{\partial \BM{D}}=\frac{1}{3}\BM{I}$.
We can also use other scalar invariants of tensors, e.g., FA.
3) If we choose $\BM{W}$ as the rotation tangent $\Phi_p(\BM{D})$~\citep{Kindlmann_TMI2007} defined as the change of tensor value due to infinitesimal rotations
around the $p$-th eigenvector, then~\EEqref{eq:tensor2vector} denotes the direction in which the tensor orientation
around the $p$-th eigenvector varies the fastest.
\textbf{Mapping the 3rd-order spatial gradient to a scalar value}.
Let $\BM{W}=[W_{ij}]$ be a 2nd-order weighting tensor in tensor space, and let $\mathbi{v}$ be a vector,
then the tensor inner product
\begin{align}
\BM{W} : \nabla_\mathbi{x} \BM{D} : \mathbi{v} &= \sum_{ijk} W_{ij}v_k \frac{\partial D_{ij}}{\partial x_k} \nonumber \\
&= \frac{\partial \sum_{ij}W_{ij} D_{ij}}{\partial \mathbi{v}} = \sum_{ij} W_{ij} \frac{\partial D_{ij}}{\partial \mathbi{v}} \label{eq:tensor2scalar}
\end{align}
produces a scalar value
that is the directional derivative of the scalar field $\sum_{ij}W_{ij} D_{ij}$ at voxel $\mathbi{x}$ along the vector $\mathbi{v}$,
and is also the weighted mean of the directional derivative of $\BM{D}(\mathbi{x})$ along the vector $\mathbi{v}$.
1) If we set $W_{ij}v_k = D_{ij,k}$, then~\EEqref{eq:tensor2scalar} is the squared norm of the tensor gradient,
which is useful for detecting boundaries of a tensor field~\citep{pajevic_JMR2002}.
2) By choosing $\mathbi{v}$ as the three eigenvectors of $\BM{D}$, and $\BM{W}$ as three rotation tangents around three eigenvectors, respectively,
we have total 9 scalar values to distinguish 9 configurations of tensor fields~\citep{Savadjiev_NI2010}.
3) The above 9 scalar indices can be combined to devise the fiber curving and fiber dispersion indices~\citep{Savadjiev_NI2010}.
\textbf{The 4th-order structure tensor}.
We propose a new 4th-order structure tensor with elements
$D_{ij,kl}= \frac{\partial D_{ij}}{\partial x_k} \frac{\partial D_{ij}}{\partial x_l}$,
which is analogous, but generalizes the structure tensor of a scalar field~\footnote{\href{https://en.wikipedia.org/wiki/Structure_tensor}{https://en.wikipedia.org/wiki/Structure\_tensor}}.
The above 4th-order structure tensor is minor symmetric~\citep{moakher_2009}, i.e., $D_{ij,kl}=D_{ji,kl}$, $D_{ij,kl}=D_{ij,lk}$.
Thus, there are 36 unique elements out of a possible total of $81$ elements, and there is one-to-one mapping between this 4th-order tensor and a 2nd-order tensor (i.e., a $6\times 6$ matrix).
However, since the 4th-order tensor is minor symmetric, the corresponding $6\times 6$ matrix is not symmetric in general.
Thus, eigenvalues and the 2nd-order left and right eigenvectors can be calculated based on eigen-decomposition of the non-symmetric $6\times 6$ matrix.
We may define some scalar invariants from these six eigenvalues of the 4th-order structure tensor, which can be used as features in this high dimensional space.
We can also contract the 4th-order structure tensor to a scalar value by using the tensor inner product
$\sum_{ijkl} W_{ij} D_{ij,kl} v_kv_l$,
which is the weighed mean of the squared spatial directional derivative along vector $\mathbi{v}$.
When setting $\mathbi{v}$ as three eigenvectors and corresponding weighting $\BM{W}$ as rotation tangents divided by the spatial gradient,
then the tensor inner product produces nine scalar indices that are the squares of the corresponding nine indices in~\cite{Savadjiev_NI2010}.
Thus, the curving and dispersion indices in~\cite{Savadjiev_NI2010} can also be obtained by choosing the corresponding $\BM{W}$.
\section{Method: Director Field Analysis}
\label{sec:method}
Section~\ref{sec:method_tensor} provides a unified framework to explore geometric structure information (e.g., boundary, curving, dispersion, etc.) from a tensor field, by considering a different weighting matrix on the spatial gradients.
However, it is challenging to generalize this framework to ODFs in HARDI, where ODFs are normally general spherical functions with antipodal symmetry.
In this section, we propose a novel mathematical framework, called Director Field Analysis (DFA).
Section~\ref{sec:dir} defines director related concepts to deal with vectors with sign ambiguity.
Section~\ref{sec:math_dir} provides a set of mathematical tools for DFA.
Section~\ref{sec:order} proposes OO and OD for tensors and ODFs in voxels and in a spatial neighborhood, and gives closed-form results in some specific cases.
Section~\ref{sec:frame} extracts the principal direction and its related local orthogonal frame in voxels exhibiting anisotropic diffusion.
Section~\ref{sec:distortion} defines four orientational distortion indices and demonstrates the implementation of the calculation by using the local orthogonal frame in Section~\ref{sec:frame}.
Section~\ref{sec:dir} and~\ref{sec:math_dir} are the theory part of DFA.
Section~\ref{sec:order}, \ref{sec:frame}, and~\ref{sec:distortion} are the application part of DFA in diffusion MRI.
Fig.~\ref{fig:DFA} demonstrates DFA to a spherical function field obtained from DTI or HARDI.
\subsection{Director and Director Field}
\label{sec:dir}
We define a \emph{director} as a unit norm vector $\mathbi{v}$ that is equivalent to $-\mathbi{v}$.
The \emph{director} term is borrowed from studies of liquid crystals~\footnote{\label{nt:lq}\href{https://en.wikipedia.org/wiki/Liquid_crystal}{https://en.wikipedia.org/wiki/Liquid\_crystal}}.
We also define a \emph{director with weight}, or \emph{weighted directors}, as a vector associated with a weight $(\mathbi{v}, w)$, which is equivalent to $(-\mathbi{v}, w)$, where $\|\mathbi{v}\|=1$, $w\in \mathbb{R}^1$.
If $w\geq 0$, then a weighted director $(\mathbi{v},w)$ can be represented as $w\mathbi{v}$. See Fig.~\ref{fig:directors}.
A director $\mathbi{v}$ can be uniquely represented as a dyadic tensor, $\mathbi{v}\Vv^T$, which avoids the sign ambiguity,
and a director with weight $(\mathbi{v},w)$ can be uniquely represented as a dyadic tensor, $w\mathbi{v} \mathbi{v}^T$.
We define a \emph{director field} as $\{(\ensuremath{\mathbf{u}}_i(\mathbi{x}), w_i(\mathbi{x}))\}$, where there are some weighted directors in each voxel $\mathbi{x}$.
Directors occur very often in diffusion MRI studies.
Eigenvectors of diffusion tensors, local maxima of ODFs, and local fiber directions are all directors.
Based on eigen-decomposition, a tensor $\BM{D}=\sum_{i=1}^3 \lambda_i \mathbi{v}_i\mathbi{v}_i^T$ is the sum of three dyadic tensors that represent three weighted directors.
A spherical function $f(\ensuremath{\mathbf{u}})$ which satisfies antipodal symmetry, i.e., $f(\ensuremath{\mathbf{u}})=f(-\ensuremath{\mathbf{u}})$, can be seen as infinite weighted directors $\{(\ensuremath{\mathbf{u}}_i, f(\ensuremath{\mathbf{u}}_i))\}$.
Thus, a spherical function field, $f(\ensuremath{\mathbf{u}},\mathbi{x})$, is a director field by definition.
An ODF in a voxel exhibiting anisotropic diffusion is anisotropic, and the orientations where the ODF takes its local peak (i.e., local maximal values) are normally considered to be local fiber directions in that voxel.
A normal peak detection algorithm for ODFs performs a grid search in a spherical mesh, and then refines the solution by using a gradient ascent on the continuous sphere~\citep{TournierNI2004}.
Note that peak detection is only performed for voxels exhibiting anisotropic diffusion (e.g., where ODFs have Generalized FA (GFA)~\citep{Tuch2004} values larger than $0.3$).
Moreover, in order to avoid including small peaks produced by noise, only peaks whose values are larger than a threshold percentage (e.g., $0.5$) of the largest ODF value are counted.
After peak detection, for each voxel $\mathbi{x}$, we obtain a discrete spherical function $g(\ensuremath{\mathbf{u}},\mathbi{x})=\sum_{i}f(\ensuremath{\mathbf{u}}_i,\mathbi{x})\delta(\ensuremath{\mathbf{u}}-\ensuremath{\mathbf{u}}_i)$ from the continuous spherical function $f(\ensuremath{\mathbf{u}},\mathbi{x})$, where $\{\ensuremath{\mathbf{u}}_i\}$ are local peaks.
This discrete spherical function field is also a \emph{director field}, or called a \emph{peak field}, which emphasizes local peaks and suppresses weights for other directors.
A peak field can also be extracted from a tensor field.
In each voxel for a tensor field, there is 0 or 1 peak,
and the principal eigenvector of the tensor is considered as a peak, if the tensor has a large FA value (e.g., larger than $0.3$).
\subsection{Mathematical Tools for Directors}
\label{sec:math_dir}
We provide a set of mathematical tools for analyzing directors and director fields.
These tools are useful not only for this paper, but also for other applications which deal with continuous or discrete director data.
\begin{figure*}[t!]
\begin{tabular}{c@{\hskip 0.1in} c@{\hskip 0.1in} c }
\includegraphics[scale=2,draft=false]{my_director_two} &
\includegraphics[scale=.26,draft=false]{director_3} &
\includegraphics[scale=2,draft=false]{my_director_two_difference} \\
(a) & (b) & (c)
\end{tabular}
\caption{\label{fig:directors}The mean, main, and difference of directors.
Directors $(\mathbi{v}_i, w_i)$, $i=1,2,3$, are visualized as vectors $w_i\mathbi{v}_i$ and $-w_i\mathbi{v}_i$, and the length of $w_i\mathbi{v}_i$ is the positive weight $w_i$.
(a) the mean (in blue) and main (in red) directors of two directors (in black), where $w_1=w_2$, and $\mathbi{v}_1^T\mathbi{v}_2>0$. See Proposition~\ref{prop:twodir}.
(b) the mean (in blue) and main directors of three directors (in black) which are orthogonal to each other, where $w_1>w_2>w_3$, $\mathbi{v}_i^T\mathbi{v}_j=\delta_i^j$.
The mean director is not unique, because $\frac{1}{3}\sum_i s_iw_i\mathbi{v}_i$ with an arbitrary sign assignment $\{s_i\}$ can be the mean director.
The main director is $w_1\mathbi{v}_1$.
(c) the difference of two directors.
The two blue vectors denote the director representation of the difference, i.e., $\texttt{Diff}_\text{d}(w_1\mathbi{v}_1, w_2\mathbi{v}_2)=w_1\mathbi{v}_1-w_2\mathbi{v}_2$.
The two red arcs denote the rotation matrix representation of the difference, i.e., $\texttt{Diff}_\text{r}(w_1\mathbi{v}_1, w_2\mathbi{v}_2)= \BM{R}$, where $\BM{R}$ is a scaled rotation matrix such that $w_1\mathbi{v}_1=\BM{R}w_2\mathbi{v}_2$.
The rotation matrix representation has no sign ambiguity, while the director representation has the sign ambiguity.}
\end{figure*}
\subsubsection{Mean Director of a Set of Directors}
For a given $N$ weighted directors $\{(\mathbi{v}_i, w_i)\}_{i=1}^N$, if we convert a director to a vector by assigning a sign, we have total $2^N$ possible sign assignments.
Thus, we have $2^N$ possible Euclidean mean vectors for the $N$ vectors.
We define a \emph{mean weighted director} of a set of weighted directors as the Euclidean mean vector with the sign assignment that takes the maximal norm among the $2^N$ mean vectors.
\begin{definition}{Mean director of weighted directors.}\label{def:mean_dir}
A mean weighted director of a set of weighted directors $\{(\mathbi{v}_i, w_i) \}_{i=1}^N$ is defined as $\texttt{Mean}(\{(\mathbi{v}_i, w_i) \}_{i=1}^N)=\frac{1}{N}\sum_{i=1}^N w_i s_i \mathbi{v}_i$,
where the signs $\{s_i\}= \argmax_{s_i=\{1,-1\}} \|\sum_{i=1}^N w_i s_i \mathbi{v}_i\|^2$, and $\texttt{Mean}(\cdot)$ is the mean director operator.
\end{definition}
It is obvious that $\{(\mathbi{v}_i, w_i)\}_{i=1}^N$ and $\{(\mathbi{v}_i, |w_i|)\}_{i=1}^N$ have the same mean director.
Thus, without loss of generality, we assume non-negative weights for calculating the mean director.
If the angle between any two vectors $\mathbi{v}_i$ and $\mathbi{v}_j$ is no more than $90^\circ$, then the sign assignment for the mean director can be proved to be $s_i=1$, $\forall i$.
See Proposition~\ref{prop:mean_cone_dir} whose proof is based on the proof of the mean director of two directors, which is trivial.
The mean director may be not unique when some directors are orthogonal.
\begin{proposition}{Mean director of weighted directors in a $90^\circ$ cone.}\label{prop:mean_cone_dir}
For a set of weighted directors $\{(\mathbi{v}_i, w_i)\}_{i=1}^N$ with non-negative weights,
if all directors are in a $90^\circ$ cone, i.e., $\mathbi{v}_i^T\mathbi{v}_j \geq 0 $, $\forall i, j$,
then the mean weighted director is $\frac{1}{N}\sum_{i=1}^N w_i \mathbi{v}_i$.
\end{proposition}
\subsubsection{Main Director of a Set of Directors}
We define the \emph{main director} of a set of weighted directors as the main axis in Principal Component Analysis (PCA) by using eigen-decomposition.
This concept is from the average director of molecule orientations in liquid crystals.
\begin{definition}{Main director of weighted directors.}\label{def:main_dir}
A \emph{main weighted director} of a set of weighted directors $\{(\mathbi{v}_i, w_i) \}_{i=1}^N$ is defined as $ \texttt{Main}(\{(\mathbi{v}_i, w_i) \}_{i=1}^N) = (\mathbi{v}_0, \lambda_0)$,
where $\lambda_0$ is the eigenvalue of the tensor $\sum_{i=1}^N w_i \mathbi{v}_i\mathbi{v}_i^T$ which has the largest absolute value among all eigenvalues, and $\mathbi{v}_0$ is its corresponding eigenvector, and $\texttt{Main}(\cdot)$ is the main director operator.
\end{definition}
Note
1) The dyadic tensor of the largest eigenvalue and eigenvector $\lambda_0 \mathbi{v}_0\mathbi{v}_0^T $ is the best rank-1 approximation of $\sum_{i=1}^N w_i \mathbi{v}_i\mathbi{v}_i^T$ in terms of the L2 norm.
2) The main director may not be unique, considering there may be more than one eigenvalues which are equal, and are all the largest eigenvalue.
3) Unlike the mean director which is independent of the signs of the weights, the main director is dependent on the weight signs.
4) Although, in general, the mean and the main directors are not the same, in some cases, they may give the same direction.
See Proposition~\ref{prop:twodir} and Fig.~\ref{fig:directors} (a) for the two director case.
See Fig.~\ref{fig:directors} (a) and (b) for an illustration of the mean and main directors.
\begin{proposition}{Two weighted directors with the same weight.}\label{prop:twodir}
For two weighted directors with the same weight, denoted as $(\mathbi{v}_1, w)$ and $(\mathbi{v}_2, w)$,
the main director is $(\frac{\mathbi{v}_1+\mathbi{v}_2}{\|\mathbi{v}_1+\mathbi{v}_2\|}, w(1+ \mathbi{v}_1^T\mathbi{v}_2))$ if $w \mathbi{v}_1^T\mathbi{v}_2 \geq 0$,
and is $(\frac{\mathbi{v}_1-\mathbi{v}_2}{\|\mathbi{v}_1-\mathbi{v}_2\|}, w(1 - \mathbi{v}_1^T\mathbi{v}_2))$ if $w \mathbi{v}_1^T\mathbi{v}_2 \leq 0 $.
The mean director is $\frac{|w|}{2}(\mathbi{v}_1+\mathbi{v}_2)$, if $\mathbi{v}_1^T\mathbi{v}_2 \geq 0$,
and is $\frac{|w|}{2}(\mathbi{v}_1-\mathbi{v}_2)$, if $\mathbi{v}_1^T\mathbi{v}_2 \leq 0$.
\end{proposition}
The mean director and main director describe different meaningful information about directors.
Take a diffusion tensor $\BM{D}=\sum_{i=1}^3 \lambda_i \mathbi{v}_i \mathbi{v}_i^T$, $\lambda_1>\lambda_2>\lambda_3>0$, as an example.
There are three weighted directors $\{(\mathbi{v}_i, \lambda_i)\}_{i=1}^3$, or represented as $\{\lambda_i\mathbi{v}_i\}$ because of non-negative weights.
The mean director is $\frac{1}{3}\sum_{i=1}^3 s_i \lambda_i \mathbi{v}_i$ with any sign assignment of $\{s_i\}$,
while the main director is $\lambda_1\mathbi{v}_1$.
See Fig.~\ref{fig:directors} (b).
Additionally, small changes in $\lambda_2$, $\lambda_3$, $\mathbi{v}_2$, and $\mathbi{v}_3$ may change the mean director, but not the main director, if $\lambda_1$ and $\mathbi{v}_1$ are still the largest eigenvalue and eigenvector.
This example clearly shows that the mean director concept is a generalization of the mean vector concept in vector space, while the main director emphasizes the main axis in PCA.
Please note that in a general case, the change of any director $(\mathbi{v}_i, w_i)$ may cause the change of the main director (i.e., the largest eigenvector and eigenvalue of the tensor $\sum_{i}w_i \mathbi{v}_i \mathbi{v}_i^T$) and also the mean director.
\subsubsection{Two Representations of the Difference between Two Directors}
\label{sec:diff_dir}
We aim to generalize the tensor field analysis in Section~\ref{sec:method_tensor} to director fields (i.e., ODF fields),
and explore geometric structure information by using spatial derivatives which rely on the concept of difference between two directors.
We propose two ways, i.e., the director representation denoted as $\texttt{Diff}_\text{d}$ and the rotation matrix representation denoted as $\texttt{Diff}_\text{r}$,
to represent the difference between two weighted directors with non-negative weights, $w_1\mathbi{v}_1$ and $w_2\mathbi{v}_2$.
These two directors can be converted to the vectors $w_1s_1\mathbi{v}_1$ and $w_2s_2\mathbi{v}_2$ by assigning the sign $s_1=1$ (or $s_1=-1$), and $s_2$ such that $w_1w_2s_1s_2\mathbi{v}_1^T\mathbi{v}_2 \geq 0$.
Thus, there are two different cases because of the sign ambiguity.
We can represent the difference as a director, i.e., $\texttt{Diff}_\text{d}(w_1\mathbi{v}_1, w_2\mathbi{v}_2) = w_1s_1\mathbi{v}_1 - w_2s_2\mathbi{v}_2$.
We can also represent the difference as a scaled rotation matrix $\BM{R}$ which rotates $w_2s_2\mathbi{v}_2$ to $w_1s_1\mathbi{v}_1$, i.e., $w_1s_1\mathbi{v}_1 = \BM{R}w_2s_2\mathbi{v}_2 $, $\texttt{Diff}_\text{r}(w_1\mathbi{v}_1, w_2\mathbi{v}_2) = \BM{R}$.
The rotation matrix can be calculated from the rotation axis $s_2\mathbi{v}_2\times s_1\mathbi{v}_1$ (i.e., the cross product of $s_2\mathbi{v}_2$ and $s_1\mathbi{v}_1$) and the rotation angle (i.e., the angle between $s_2\mathbi{v}_2$ and $s_1\mathbi{v}_1$)~\footnote{\url{https://en.wikipedia.org/wiki/Rotation_matrix\#Rotation_matrix_from_axis_and_angle}},
and the scale can be calculated from the weights $w_1$ and $w_2$.
Note that this rotation matrix is the same for the above two cases, without sign ambiguity.
See Fig.~\ref{fig:directors} (c) as an illustration.
The director representation of the difference has the sign ambiguity, but it gives a vector without a sign which can be projected onto axes.
The rotation matrix representation is unique without sign ambiguity, but cannot be projected onto axes.
\subsubsection{Spatial Gradient and Directional Derivative of a Director Field}
\label{sec:derivative_dir}
Considering a director field where there is only one director with non-negative weight $w\mathbi{v}(\mathbi{x})$ (simplified notation for $w(\mathbi{x})\mathbi{v}(\mathbi{x})$) at each position $\mathbi{x} \in \mathbb{R}^3$,
a directional derivative along $\ensuremath{\mathbf{u}}$ at $\mathbi{x}$ is defined as
\begin{equation}\label{eq:derivative_dir}
\frac{\partial w \mathbi{v}}{ \partial \ensuremath{\mathbf{u}}} = \lim_{k\to 0} \frac{\texttt{Diff}( w\mathbi{v}(\mathbi{x}+ k\ensuremath{\mathbf{u}}), w\mathbi{v}(\mathbi{x}- k\ensuremath{\mathbf{u}}))}{ 2 k}.
\end{equation}
Thus, there are also director and rotation matrix representations of the directional derivative because of the two representations of $\texttt{Diff}$, i.e., $\texttt{Diff}_\text{d}$ and $\texttt{Diff}_\text{r}$.
For the director field where directors $w\mathbi{v}(\mathbi{x})$ are only obtained in a integer lattice,
the central difference can be used to approximate the spatial gradient $[\frac{\partial w\mathbi{v} }{ \partial x_i}]$, where
\begin{small}
\begin{equation}\label{eq:central_diff}
\frac{\partial w\mathbi{v} }{ \partial x_i} \approx \texttt{Diff}(w\mathbi{v}(\mathbi{x}+\VV{o}_i) , \texttt{Mean}(\{w\mathbi{v}(\mathbi{x}-\VV{o}_i), w\mathbi{v}(\mathbi{x}+\VV{o}_i)\}) ),
\end{equation}
\end{small}%
$\VV{o}_1=[1,0,0]^T$, $\VV{o}_2=[0,1,0]^T$, $\VV{o}_3=[0,0,1]^T$ are the unit norm vectors along spatial axes,
and $\texttt{Mean}$ is the mean director operator in Definition~\ref{def:mean_dir}.
We normally use the rotation matrix representation for the spatial gradient $\frac{\partial w\mathbi{v}}{ \partial x_i}$, considering this representation is unique.
Let $\{\BM{R}_i(\mathbi{x})\}$ be the rotation matrices for the spatial gradient at $\mathbi{x}$ along axes $\{\mathbi{x}_i\}$, i.e., $\texttt{Diff}_\text{r}$ is used in~\EEqref{eq:central_diff}.
Then, analogously to the spatial gradient of a vector field, the director $w\mathbi{v}(\mathbi{x}+ k\ensuremath{\mathbf{u}})$ at position $\mathbi{x}+k\ensuremath{\mathbf{u}}$ with small $k$ can be approximated as the sum of rotated directors, i.e.,
\begin{footnotesize}
\begin{equation}\label{eq:weighted_ratation_dir}
\sum_{i=1}^3 k\VV{p}_i(\mathbi{x}), \quad \text{where} \ \ \VV{p}_i(\mathbi{x}) = \left\{ \begin{aligned}
& u_i\BM{R}_i(\mathbi{x}) w(\mathbi{x})\mathbi{v}(\mathbi{x}), \ \text{if}\ \ u_i \geq 0\\
& -u_i\BM{R}_i^T(\mathbi{x}) w(\mathbi{x})\mathbi{v}(\mathbi{x}), \ \text{if}\ \ u_i<0.
\end{aligned}
\right.
\end{equation}
\end{footnotesize}%
Note that every director in the above sum is a rotated $w(\mathbi{x})\mathbi{v}(\mathbi{x})$ in a small local rotation,
thus we assume all directors are in a $90^\circ$ cone to obtain a simple sum of vector representation.
See Proposition~\ref{prop:mean_cone_dir}.
If~\EEqref{eq:central_diff} is used to approximate $\BM{R}_i$, then the angle between $w\mathbi{v}(\mathbi{x})$ and $\BM{R}_i w\mathbi{v}(\mathbi{x})$ is no more than $45^\circ$,
thus all three rotated directors are indeed in a $90^\circ$ cone.
\subsection{Orientational Order and Dispersion}
\label{sec:order}
Before working on a field of ODFs, an ODF in a voxel can provide some geometric information at the voxel level,
including GFA~\citep{Tuch2004}, and orientation dispersion~\citep{zhang_NODDI_NI2012}.
\subsubsection{Orientational Order Transform and Orientational Tensor}
The NODDI model is increasingly used to study neurite orientation dispersion~\citep{zhang_NODDI_NI2012}.
NODDI uses the Watson distribution in~\EEqref{eq:watson} to model the ODF with a single orientation,
where $M$ is the confluent hypergeometric function,
$\mathbi{n}_0 \in \mathbb{S}^2$ is a given axis
\begin{footnotesize}
\begin{equation}\label{eq:watson}
f(\ensuremath{\mathbf{u}} \mid (\mathbi{n}_0, \kappa) ) = \frac{1}{4 \pi \ M(1/2, 3/2, \kappa) } \exp(\kappa (\ensuremath{\mathbf{u}}^T \mathbi{n}_0 )^2), \quad \ensuremath{\mathbf{u}} \in \mathbb{S}^2.
\end{equation}%
\end{footnotesize}%
Note that the original formula of the Watson distribution in~\cite{zhang_NODDI_NI2012} has no unit integral in $\mathbb{S}^2$, because it missed $4\pi$.
An orientation dispersion index (OD) was defined as~\EEqref{eq:OD_w}, where we denote it as $\text{OD}_{\text{w}}$ because it only applies to the Watson distribution.
\begin{equation}\label{eq:OD_w}
\text{OD}_{\text{w}}=\frac{2}{\pi}\arctan(\frac{1}{\kappa})
\end{equation
Note that in order to obtain good contrast in the dispersion index map,
in the NODDI toolbox provided by the authors, a scaled $\kappa$ ($10\kappa$ in the codes) is used in~\EEqref{eq:OD_w} to calculate $\text{OD}_{\text{w}}$, instead of the estimated $\kappa$ from the NODDI model.
$\text{OD}_{\text{w}}$ can not be used for ODFs that have general shapes, have more than one peak, or are not antipodally symmetric.
Some other works also proposed dispersion indices based on different models of ODFs, e.g., Bingham distributions~\cite{tariq:NI2016} and mv-$\Gamma$ distributions in DIAMOND~\cite{scherrer:MRM2015}.
These dispersion indices cannot work for general ODFs.
Inspired by liquid crystals, we would like to define the degree of dispersion for general ODFs, independent of microscopic diffusion signal models.
For a general spherical function $f(\ensuremath{\mathbf{u}})$, $\ensuremath{\mathbf{u}}\in\mathbb{S}^2$,
we define the \emph{orientational tensor} as
\begin{equation}\label{eq:OO_qtensor}
\BM{Q}(f) = \int_{\mathbb{S}^2} \ensuremath{\mathbf{u}}\uu^T f(\ensuremath{\mathbf{u}}) \rmd \ensuremath{\mathbf{u}},
\end{equation}
which is related to the Q-tensor in liquid crystal modeling~\citep{andrienko_2006}~\textsuperscript{\ref{nt:lq}}.
$\BM{Q}(f)$ is a $3\times 3$ symmetric matrix dependent on $f(\ensuremath{\mathbf{u}})$.
If $f(\ensuremath{\mathbf{u}})$ is non-negative, then $\BM{Q}(f)$ is positive semidefinite.
We propose the \emph{orientational order index (OO)} from the theory of liquid crystals~\citep{andrienko_2006}
to describe the orientation or dispersion of a general spherical function along a given axis $\VV{n}$:
\begin{footnotesize}
\begin{align}
\text{OO}(\VV{n}) &= \int_{\ensuremath{\mathbf{u}}\in\mathbb{S}^2} P_2(\ensuremath{\mathbf{u}}^T\VV{n}) f(\ensuremath{\mathbf{u}}) \rmd \ensuremath{\mathbf{u}} \nonumber \\
&=\int_{\ensuremath{\mathbf{u}}\in\mathbb{S}^2} \frac{3(\ensuremath{\mathbf{u}}^T \VV{n})^2 -1}{2} f(\ensuremath{\mathbf{u}}) \rmd \ensuremath{\mathbf{u}} \label{eq:OO}
\end{align}
\end{footnotesize}%
where $P_2$ is the 2nd-order Legendre polynomial.
By definition, \EEqref{eq:OO} is an \emph{integral transform} in $\mathbb{S}^2$ which converts the spherical function $f(\ensuremath{\mathbf{u}})$ to another spherical function $\text{OO}(\VV{n})$, and the kernel is $P_2(\ensuremath{\mathbf{u}}^T\VV{n})$,
similar to the Funk-Radon transform used in Q-Ball imaging~\citep{Tuch2004}, where the kernel is $\delta(\ensuremath{\mathbf{u}}^T\VV{n})$.
We call~\EEqref{eq:OO} the \emph{Orientational Order Transform (OOT)}, i.e., $\text{OOT}(f)=\text{OO}(\mathbi{n})$.
Note that we have
\begin{equation}
\text{OO}(\mathbi{n})= \frac{3}{2}\mathbi{n}^T \BM{Q}(f) \mathbi{n} - \frac{1}{2} \int_{\mathbb{S}^2} f(\ensuremath{\mathbf{u}}) \rmd \ensuremath{\mathbf{u}}.
\end{equation}
By definition, $\text{OO}(\mathbi{n})$ is antipodally symmetric and has a global maximum and a global minimum on the unit sphere, which correspond to the largest and smallest eigenvectors of $\BM{Q}(f)$, respectively.
Based on Definition~\ref{def:main_dir}, the main director of infinite weighted directors $\{(\ensuremath{\mathbf{u}}_i, f(\ensuremath{\mathbf{u}}_i))\}$ is the maximum point of $\text{OO}(\mathbi{n})$.
\begin{figure}[t!]
\centering
\includegraphics[scale=1.4,draft=false]{my_orientationalOrder_2d}
\caption{\label{fig:OO}A cross-section view of a spherical function $f(\ensuremath{\mathbf{u}})$ along axis $\mathbi{n}$. The projection of $f(\ensuremath{\mathbf{u}})\ensuremath{\mathbf{u}}$ onto $\mathbi{n}$ is $(f(\ensuremath{\mathbf{u}})\cos\theta)\mathbi{n}$.}
\end{figure}
Although $\text{OO}(\VV{n})$ is a spherical function, it is a scalar index when $\VV{n}$ is chosen as a physically meaningful axis, e.g., $f(\ensuremath{\mathbf{u}})$ takes its maximal value at $\VV{n}$.
Let $\theta$ be the angle between $\ensuremath{\mathbf{u}}$ and axis $\VV{n}$, then $P_2(\ensuremath{\mathbf{u}}^T\VV{n})=\frac{3\cos^2\theta-1}{2}$.
Thus, if $f(\ensuremath{\mathbf{u}})$ is a Probability Density Function (PDF) on the unit sphere,
then $\text{OO}(\VV{n})$ is $\langle \frac{3\cos^2\theta -1}{2} \rangle $, where $\langle \cdot \rangle$ signifies the expectation operation.
As shown in Fig.~\ref{fig:OO}, $\langle \cos^2\theta \rangle $ is the expectation of the squared projected length of $\ensuremath{\mathbf{u}}$ onto the axis $\VV{n}$.
If $f(\ensuremath{\mathbf{u}})$ is more concentrated along $\mathbi{n}$, then $\langle \cos^2\theta \rangle $ is larger, so is $\text{OO}(\mathbi{n})$.
Based on the definition, when $f(\ensuremath{\mathbf{u}})$ is a PDF, then we have $\text{OO}(\VV{n})\in[-0.5, 1]$.
If $f(\ensuremath{\mathbf{u}})=\delta(\ensuremath{\mathbf{u}}^T\VV{n}_0-1)$, i.e., the delta function along a given $\VV{n}_0$ axis, then $\text{OO}(\VV{n}_0)=1$.
If $f(\ensuremath{\mathbf{u}})=0$, $\forall \ensuremath{\mathbf{u}} \in \mathbb{S}^2$ such that $\ensuremath{\mathbf{u}}^T\VV{n}_0\neq 0 $, i.e., $f(\ensuremath{\mathbf{u}})$ is non-zero only in the plane orthogonal to $\VV{n}_0$, then $\text{OO}(\VV{n}_0)=-0.5$.
If $f(\ensuremath{\mathbf{u}})$ is the isotropic PDF, i.e., $f(\ensuremath{\mathbf{u}})=\frac{1}{4\pi}$, then $\text{OO}(\VV{n})=0$.
In practice, if we choose the axis $\VV{n}$ such that $f(\ensuremath{\mathbf{u}})$ takes its local or global maximal value, then $\text{OO}(\VV{n})$ is normally non-negative.
We define the \emph{orientational dispersion} along axis $\VV{n}$ as
\begin{equation}
\text{OD}(\VV{n})=1-\text{OO}(\VV{n}).
\end{equation}
Then $\text{OD}(\VV{n})\in [0,1.5]$.
Note that the proposed OO is different from the order parameter in~\cite{lasivc:FrontiersInPhysics2014,szczepankiewicz:NI2015} which was also inspired by liquid crystals~\citep{andrienko_2006}.
In \cite{lasivc:FrontiersInPhysics2014,szczepankiewicz:NI2015}, the order parameter is calculated by estimating the variance of microscopic diffusion parameters from the contrast between signals measured by directional and isotropic diffusion encoding.
However, it cannot be used for general DTI and HARDI data.
The proposed OO in this paper is defined for general spherical functions (i.e., ODFs) along a given axis, independent of microscopic diffusion models and reconstruction of the ODFs.
\subsubsection{Axisymmetric Spherical Functions}
When $f(\ensuremath{\mathbf{u}})$ is axisymmetric, and its axis is given by $\VV{n}_0$, i.e., $f(\ensuremath{\mathbf{u}})=f'(\ensuremath{\mathbf{u}}^T\VV{n}_0)$, where $f'(x)$ is the corresponding scalar function defined in $[-1,1]$,
then OOT has a closed form:
\begin{footnotesize}
\begin{align}
\text{OO}(\VV{n}) & = \int_0^\pi \left( \int_0^{2\pi} P_2( \cos\theta \cos t + \sin\theta\cos t \sin \phi)\rmd t \right)f'(\cos\theta) \rmd \theta \nonumber \\
&= \frac{(1+3\cos(2\phi))\pi}{2} a_2 = \frac{1+3\cos(2\phi)}{4} \text{OO}(\mathbi{n}_0) \label{eq:OOT_sym}
\end{align}
\end{footnotesize}
where $\phi=\arccos(|\mathbi{n}^T\mathbi{n}_0|)$ is the angle between $\mathbi{n}$ and the axis $\mathbi{n}_0$,
and $a_2 = \int_{-1}^1 P_2(x) f'(x) \rmd x$ is the 2nd-order Legendre coefficient of $f'(x)$.
Note that if $a_2>0$, when $\VV{n}=\VV{n}_0$, $\phi=0$, then $\text{OO}=2\pi a_2$ is the global maximum of $\text{OO}(\VV{n})$.
When $\VV{n}^T\VV{n}_0=0$, $\phi=\pi/2$, then $\text{OO}=-\pi a_2$ is the global minimum of $\text{OO}(\VV{n})$.
In the following development, without any ambiguity, we will use OO to denote $\text{OO}(\mathbi{n}_0)$, and OD to denote $\text{OD}(\mathbi{n}_0)$, for axisymmetric spherical functions.
\subsubsection{Watson Distributions}
The Watson distribution defined in~\EEqref{eq:watson} is axisymmetric with the axis $\VV{n}_0$.
Thus, based on the above analysis of axisymmetric spherical functions,
we have $\text{OO}(\mathbi{n})= \frac{1+3\cos(2\phi)}{4} \text{OO}$, and
\begin{equation}\label{eq:OO_watson}
\text{OO} = \frac{3 e^\kappa}{2\sqrt{\kappa\pi}\ \texttt{Erfi}(\sqrt{\kappa}) } - \frac{3+2\kappa}{4\kappa}
\end{equation}
where $\texttt{Erfi}(x)=\frac{2}{\sqrt{\pi}}\int_0^x \exp(t^2)\rmd t$ is the imaginary error function.
Then $\text{OD}=1-\text{OO}$.
The left part of Fig.~\ref{fig:OO_tensor_watson} shows the above $\text{OD}$ and $\text{OD}_{\text{w}}$ as functions of $\kappa$,
where the axis $\VV{n}$ is set as the Watson distribution's axis $\mathbi{n}_0$.
Both dispersion indices decrease as $\kappa$ increases.
Based on the derivation of $\kappa$, $\text{OD}_{\text{w}}$ is more sensitive to changes of $\kappa$ when $\kappa$ is small ($<2$),
while it is less sensitive when $\kappa$ is large ($>2$).
Compared with $\text{OD}_{\text{w}}$, the change of $\text{OD}$ is smoother for the change of $\kappa$ over the entire range of $\kappa$.
\subsubsection{Tensors}
For the tensor model in DTI, denoted as $\BM{D}$, OOT is defined for its ODF, i.e.,
\begin{equation}\label{eq:odf_tensor}
\Phi (\ensuremath{\mathbf{u}} \mid \BM{D}) = \frac{1}{4\pi |\BM{D}|^{\frac{1}{2}} } \frac{1}{(\ensuremath{\mathbf{u}}^T \BM{D}^{-1}\ensuremath{\mathbf{u}})^{\frac{3}{2}}},
\end{equation}%
which is a PDF on the unit sphere.
When the three eigenvalues of $\BM{D}$ satisfy $\lambda_1>\lambda_2=\lambda_3>0$,
$\Phi (\ensuremath{\mathbf{u}} \mid \BM{D})$ is an axisymmetric function with the axis $\mathbi{v}_1$ that is the principal eigenvector of $\BM{D}$.
OOT has a closed-form expression in~\EEqref{eq:OOT_sym}, and
\begin{footnotesize}
\begin{equation}\label{eq:OO_tensor}
\text{OO} = \frac{ \sqrt{\lambda_1-\lambda_2}(2\lambda_1+\lambda_2) - 3\lambda_1\sqrt{\lambda_2}\arctan\left(\sqrt{\frac{\lambda_1-\lambda_2}{\lambda_2}}\right) }{2(\lambda_1 - \lambda_2)^{\frac{3}{2}}}.
\end{equation}%
\end{footnotesize}%
The right panel of Fig.~\ref{fig:OO_tensor_watson} shows $\text{OO}$ and FA as functions of $\lambda_1/\lambda_2$, where we set $\VV{n}=\mathbi{v}_1$.
Both $\text{OO}$ and FA increases as $\lambda_1/\lambda_2$ increases.
Thus, $\text{OO}$ can be seen as a type of anisotropy index for tensors.
For general tensors with $\lambda_1>\lambda_2>\lambda_3>0$, no such closed form solution like~\EEqref{eq:OO_tensor} and~\EEqref{eq:OOT_sym} exists,
but we can calculate OO using the spherical harmonic representation of the ODF.
\begin{figure*}[t!]
\centering
\includegraphics[width=0.48\linewidth]{OO_watson}
\includegraphics[width=0.48\linewidth]{OO_symmetricTensor}
\caption{\label{fig:OO_tensor_watson}
Left: dispersion indices ($\text{OD}$ and $\text{OD}_{\text{w}}$) of a Watson distribution as functions of $\kappa$.
Right: OO and FA of prolate tensors ($\lambda_2 = \lambda_3$) as functions of $\frac{\lambda_1}{\lambda_2}$.}
\end{figure*}
\subsubsection{Spherical Harmonic Representation}
For a general spherical function $f(\ensuremath{\mathbf{u}})$, OO and OD can be analytically calculated from the spherical harmonic coefficients of the rotated function.
Considering $f(\ensuremath{\mathbf{u}})$ is a real function on the unit sphere, it can always be linearly represented by the real Spherical Harmonic (SH) basis $\{Y_l^m(\ensuremath{\mathbf{u}})\}$, i.e.,
\begin{equation}\label{eq:SH_f}
f(\ensuremath{\mathbf{u}}) = \sum_{l,m} c_{l,m} Y_l^m(\ensuremath{\mathbf{u}})
\end{equation}
\begin{equation}\label{eq:SH}
Y_l^m(\theta,\phi) =
\left\{ \begin{array}{lcl}
\sqrt{2}\mbox{Re}(y_l^{|m|}(\theta,\phi)) & \mbox{if} & -l\leq m<0 \\
y_l^m(\theta,\phi) & \mbox{if} & m=0 \\
\sqrt{2}\mbox{Im}(y_l^m(\theta,\phi)) & \mbox{if} & l\geq m>0
\end{array}\right.
\end{equation}%
where $y_l^m(\theta,\phi) = \sqrt{\frac{2l+1}{4\pi}\frac{(l-m)!}{(l+m)!}} e^{im\phi} P_l^m(\cos\theta)$ is the complex SH basis, $P_l^m(\cdot)$ is the associated Legendre polynomial.
For any rotation matrix, the SH coefficients of the rotated function can be calculated with very high accuracy
based on the Wigner D-matrix~\footnote{\href{https://en.wikipedia.org/wiki/Spherical_harmonics}{https://en.wikipedia.org/wiki/Spherical\_harmonics}},
or based on fitting rotated function samples~\citep{lessig_2012}.
Let $\BM{R}$ be the rotation matrix which rotates the axis $\VV{n}$ to $\VV{z}$-axis,
and $\{a_{l,m}\}$ be the real SH coefficients of the rotated function $(Rf)(\ensuremath{\mathbf{u}})=f(\BM{R}^{-1}\ensuremath{\mathbf{u}})$,
considering the orthogonality of the real SH basis and $Y_2^0(\theta,\phi)=\sqrt{\frac{5}{4\pi}}P_2(\cos\theta)$, we have
\begin{footnotesize}
\begin{align}
\text{OO}(\VV{n}) &= \int_{\ensuremath{\mathbf{u}}\in\mathbb{S}^2} P_2(\ensuremath{\mathbf{u}}^T\VV{n}) f(\ensuremath{\mathbf{u}}) \rmd \ensuremath{\mathbf{u}} \nonumber \\
&=\int_{\ensuremath{\mathbf{u}}\in\mathbb{S}^2} P_2(\cos \theta) \sum_{l,m} a_{l,m} Y_l^m(\theta, \phi) \rmd \ensuremath{\mathbf{u}} = \sqrt{\frac{4\pi}{5}} a_{2,0}. \label{eq:OO_sh}
\end{align}
\end{footnotesize}%
Note that $\text{OO}(\VV{n})$ is only determined by the rotated SH coefficient $a_{2,0}$ that is only related to $\{c_{2,m}\}_{-2\leq m \leq 2}$ and the axis $\VV{n}$, based on the rotation property of the SH basis.
Thus, $\text{OO}(\VV{n})$ is only related to the SH coefficients of $f(\ensuremath{\mathbf{u}})$ with $l=2$, and also the axis $\mathbi{n}$.
\subsubsection{Relationship Between OO, OD, and GFA}
\label{sec:gfa_OO}
For an ODF in an SH representation in~\EEqref{eq:SH_f}, its GFA~\citep{Tuch2004} is
\begin{equation}\label{eq:GFA}
\text{GFA} = \sqrt{ 1- \frac{ c_{0,0}^2}{\sum_{lm} c_{l,m}^2}}.
\end{equation}
Note that the rotation of a spherical function does not change the shape of the function and the norm of SH coefficients,
thus we have $\sum_{m}a_{2,m}^2=\sum_{m}c_{2,m}^2$.
Based on~\EEqref{eq:OO_sh}, we have
\begin{align}
\text{OO}(\mathbi{n}) &= \sqrt{\frac{4\pi}{5}} a_{2,0} \leq\sqrt{\frac{4\pi}{5}} \sqrt{\sum_{m=-2}^2 c_{2,m}^2} \nonumber \\
& \leq \sqrt{\frac{4\pi}{5}} \sqrt{\sum_{l\geq 2}\sum_{m=-l}^l c_{l,m}^2}.\label{eq:OO_ineq_1}
\end{align}
Combining~\EEqref{eq:GFA} and~\EEqref{eq:OO_ineq_1}, we have
\begin{equation}
\text{OO}(\mathbi{n}) \leq \sqrt{\frac{4\pi c_{0,0}^2}{5}} \sqrt{ \frac{1}{1-\text{GFA}^2} - 1}.
\end{equation}
The above inequality gives an upper bound of $\text{OO}(\mathbi{n})$ as a function of $\text{GFA}$ which is independent of $\mathbi{n}$.
Note that the above upper bound is tight, and the equality holds when $c_{l,m}=0$, for $l>2$, and $a_{2,m}=0$ for $m\neq 0$ after rotation.
If the ODF has unit integral, i.e., $\int_{\mathbb{S}^2} f(\ensuremath{\mathbf{u}}) \rmd \ensuremath{\mathbf{u}} =1$~\footnote{Note that ODFs estimated by some methods (e.g., constrained spherical deconvolution~\citep{tournier_NI2007}, Q-Ball Imaging~\citep{Tuch2004,Descoteaux2007}),
do not have the unit integral, if there is no normalization after estimation.}, then $c_{0,0}= \frac{1}{\sqrt{4\pi}}$, and we have
\begin{equation}\label{eq:OO_ineq}
\text{OO}(\mathbi{n}) \leq \sqrt{\frac{1}{5}} \sqrt{ \frac{1}{1-\text{GFA}^2} - 1 }
\end{equation}
Thus, for an ODF with low GFA, OO is also low, and OD is high, no matter how we choose the axis $\mathbi{n}$.
Note that~\EEqref{eq:OO_ineq} does not imply that an ODF with high GFA tends to have high OO, because it is an upper bound of $\text{OO}(\mathbi{n})$, not a lower bound.
\subsubsection{Mixture Model}
OOT in~\EEqref{eq:OO} is a linear transform.
Thus, if $f(\ensuremath{\mathbf{u}})=\sum_i w_i f_i(\ensuremath{\mathbf{u}})$ is the PDF of a mixture of models, where $f_i(\ensuremath{\mathbf{u}})$ is the PDF for the $i$-th model, and $w_i$ is the weight,
then $\text{OO}(\VV{n})= \sum_i w_i \text{OO}_i(\VV{n})$ is also a mixture of OO functions.
Fig.~\ref{fig:OO_tensor2} illustrates OO for a two-tensor model with a crossing angle $\phi$,
where two tensors share the same eigenvalues $[1.7,0.2,0.2]\times 10^{-3} mm^2/s$, the weights are $0.5$ and $0.5$,
and one tensor component is along the $y$-axis and the other one rotates from the $y$-axis to the $x$-axis.
Based on~\EEqref{eq:OOT_sym} and~\EEqref{eq:OO_tensor}, OO for the mixture model can be analytically calculated.
\subsubsection{OO and OD for a General ODF Along the Principal Peak}
\label{sec:OO_OD_odf}
In the above context, we focus on $\text{OO}(\mathbi{n})$ and $\text{OO}(\mathbi{n})$ as spherical functions.
A physically meaningful axis $\mathbi{n}_0$ is needed to obtain scalar indices of OO and OD from $\text{OO}(\mathbi{n})$ and $\text{OO}(\mathbi{n})$.
For an axisymmetric function $f(\ensuremath{\mathbf{u}})$, its axis can be used as described above.
For a general function (e.g., an ODF), we can set the axis as the local maxima of $f(\ensuremath{\mathbf{u}})$ (e.g., detected peaks of the ODF),
because the peaks of ODFs are considered as local fiber directions in dMRI.
A general ODF may have more than one peak.
The \emph{principal peak} of the anisotropic ODF $f(\ensuremath{\mathbf{u}})$, where the ODF takes its global maximum $\ensuremath{\mathbf{u}}_1$, i.e., $f(\ensuremath{\mathbf{u}}_1,\mathbi{x})>f(\ensuremath{\mathbf{u}},\mathbi{x})$, $\forall \ensuremath{\mathbf{u}}\in \mathbb{S}^2$,
is used to calculate OO and OD for the ODF.
Note that peaks are detected from ODFs with all orders of SH coefficients, not only SH coefficients with $l=2$.
Thus, the scalar indices of OO and OD are actually dependent on SH coefficients of ODFs with all orders.
See Algorithm~\ref{alg:OO_OD} for the pipeline to calculate OO and OD maps from a given ODF field with SH representation,
where peaks are detected for voxels whose GFA values are larger than a given threshold (e.g., $0.3$).
It is also possible to calculate OO and OD for all voxels by setting the GFA threshold as $0$.
As shown in Section~\ref{sec:gfa_OO}, for the voxels with $\text{GFA}<0.3$, we have $\text{OO}<0.14$ and $\text{OD}>0.86$.
\begin{algorithm}[!h]
\caption{\label{alg:OO_OD}\textbf{Calculation of OO and OD for ODFs with SH representation along principal peaks:}}
\SetAlgoLined
\KwIn{ODF field $f(\ensuremath{\mathbf{u}},\mathbi{x})=\sum_{lm}c_{l,m}(\mathbi{x})Y_l^m(\ensuremath{\mathbf{u}})$ in SH representation.}
\KwOut{OO map, OD map.}
Peak detection using gradient ascent for ODFs in voxels with the anisotropy higher than a given threshold (e.g., $\text{GFA}>0.3$). See Section~\ref{sec:dir}\;
\For{each voxel $\mathbi{x}$ with detected peaks $\{\ensuremath{\mathbf{u}}_i(\mathbi{x})\}$}{
1) Find the principal peak $\ensuremath{\mathbf{u}}_1$ with the largest ODF value, i.e., $f(\ensuremath{\mathbf{u}}_1,\mathbi{x})>f(\ensuremath{\mathbf{u}}_i,\mathbi{x})$, $\forall i$ \;
2) Calculate rotation matrix $\BM{R}$, which rotates $\ensuremath{\mathbf{u}}_1$ to the $\VV{z}$-axis \;
3) Calculate the rotated SH coefficient $a_{2,0}$ from $\{ c_{2,m}\}_{-2\leq m \leq 2}$ under the rotation $\BM{R}$ \;
4) $\text{OO}=\sqrt{\frac{4\pi}{5}} a_{2,0}$ as shown in~\EEqref{eq:OO_sh}, and $\text{OD}=1-\text{OO}$ \;
}
\end{algorithm}
\begin{figure*}[t!]
\centering
\includegraphics[width=0.45\linewidth]{OO_tensor2_phi}
\includegraphics[width=0.45\linewidth]{OO_tensor2_angles}
\caption{\label{fig:OO_tensor2}
OO for the mixture tensor model.
Left: OO as a function of the angle between two tensor components.
Right: ODF glyphs of the two-tensor model for different crossing angles,
where the yellow tube shows the $y$-axis which is used to calculate OO. }
\end{figure*}
\subsubsection{OO, OD and the Orientational Tensor in a Spatial Region}
The above OO, OD, and the orientational tensor are defined for a single voxel.
They can also be defined for voxels in a spatial region of voxels.
A linear weighting generalization of OO can be defined as
\begin{equation}\label{eq:OOT_region}
\text{OO}(\VV{n}) = \int_{\mathbi{x}\in \Omega} \int_{\ensuremath{\mathbf{u}}\in\mathbb{S}^2} P_2(\ensuremath{\mathbf{u}}^T\VV{n}) w(\mathbi{x}) f(\ensuremath{\mathbf{u}}, \mathbi{x}) \rmd \ensuremath{\mathbf{u}} \rmd \mathbi{x}.
\end{equation}
The orientational tensor in a spatial region is
\begin{equation}\label{eq:OO_qtensor_region}
\BM{Q}(f) = \int_{\mathbi{x}\in \Omega} \int_{\ensuremath{\mathbf{u}}\in\mathbb{S}^2} w(\mathbi{x}) f(\ensuremath{\mathbf{u}}, \mathbi{x}) \ensuremath{\mathbf{u}}\uu^T \rmd \ensuremath{\mathbf{u}} \rmd \mathbi{x}.
\end{equation}
Because of the linearity of the integration,
\EEqref{eq:OOT_region} is actually OOT in~\EEqref{eq:OO} performed on the region smoothed spherical function $\int_{\mathbi{x}\in \Omega} w(\mathbi{x}) f(\ensuremath{\mathbf{u}}, \mathbi{x}) \rmd \mathbi{x}$,
and \EEqref{eq:OO_qtensor_region} is the orientational tensor for the region smoothed function.
The largest eigenvector of $\BM{Q}(f)$ in~\EEqref{eq:OO_qtensor_region} indicates the main orientation of all ODFs $f(\ensuremath{\mathbf{u}},\mathbi{x})$ in the region $\Omega$.
\subsection{Local Orthogonal Frame}
\label{sec:frame}
\begin{figure*}[t!]
\centering
\begin{tabular}{c@{\hskip 0.1in} c@{\hskip 0.1in} c }
\includegraphics[width=0.31\textwidth]{fodf_splay_demo_odf_peaks} &
\includegraphics[width=0.31\textwidth]{fodf_splay_demo_odf_peaks_plane} &
\includegraphics[width=0.31\textwidth]{fodf_splay_demo_odf_peaks_plane_frame} \\
(a) & (b) & (c)
\end{tabular}
\caption{\label{fig:demo_frame}Sketch to determine local orthogonal frames from an ODF field, where an ODF may have 0, 1, or more than 1 peaks.
(a) an ODF field with peaks, where yellow tubes denote peaks.
(b) the orthogonal plane for the principal peak, where red tubes denote principal peaks.
(c) local orthogonal frames, where three tubes in red, green, and blue colors denote three directors in local orthogonal frames.}
\end{figure*}
As described in Section~\ref{sec:dir}, after peak detection on a spherical function field or a tensor field, the obtained peak field is also a director field.
We propose extracting a local orthogonal frame in each voxel exhibiting anisotropic diffusion from the detected peak field.
The orthogonal frame has three orthogonal orientations.
Denote the peaks at voxel $\mathbi{x}$ as $\{\ensuremath{\mathbf{u}}_i(\mathbi{x})\}$.
The first orientation is the \emph{principal peak} where the ODF takes its global maximum $\ensuremath{\mathbf{u}}_1(\mathbi{x})$, i.e., $f(\ensuremath{\mathbf{u}}_1,\mathbi{x})>f(\ensuremath{\mathbf{u}},\mathbi{x})$, $\forall \ensuremath{\mathbf{u}} \in \mathbb{S}^2$.
We call it the \emph{principal director} of the voxel $\mathbi{x}$.
The other two orientations are in the orthogonal plane of the principal direction.
Considering $f(\ensuremath{\mathbf{u}})$ is normally antipodally symmetric in diffusion MRI, all these orientations are equivalent to their antipodal ones.
Thus, we project all peaks in a spatial local neighborhood onto the orthogonal plane,
and define a weighted sum of dyadic tensors in voxel $\mathbi{x}$:
\begin{equation}\label{eq:dyadic_tensor}
\BM{Q}_\mathbi{x} = \sum_{\mathbi{y}\in\Omega_\mathbi{x}}\sum_{i} w(\mathbi{y},\mathbi{x}) f(\ensuremath{\mathbf{u}}_i(\mathbi{y}),\mathbi{y})\ensuremath{\mathbf{u}}_{i,\perp}(\mathbi{y})\ensuremath{\mathbf{u}}_{i,\perp}^T(\mathbi{y})
\end{equation}
\begin{equation}\label{eq:dyadic_tensor_2}
\ensuremath{\mathbf{u}}_{i,\perp}(\mathbi{y})=\ensuremath{\mathbf{u}}_i(\mathbi{y})-(\ensuremath{\mathbf{u}}_i^T(\mathbi{y})\ensuremath{\mathbf{u}}_1(\mathbi{x})) \ensuremath{\mathbf{u}}_1(\mathbi{x})
\end{equation}
where $\Omega_\mathbi{x}$ is a local neighborhood of voxel $\mathbi{x}$, $w(\mathbi{y},\mathbi{x})$ is the spatial weight which is normally set to be proportional to $\exp(-\frac{\|\mathbi{y}-\mathbi{x}\|^2}{2\sigma^2})$,
$\delta$ which is normally set as 1 voxel controls spatial weight concentration,
$\ensuremath{\mathbf{u}}_{i,\perp}(\mathbi{y})$ is the projected orientation $\ensuremath{\mathbf{u}}_i(\mathbi{y})$ onto the orthogonal plane of $\ensuremath{\mathbf{u}}_1(\mathbi{x})$.
The above $3\times 3$ matrix $\BM{Q}_\mathbi{x}$ is actually the orientational tensor of all projected peaks in region $\Omega_\mathbi{x}$ based on~\EEqref{eq:OO_qtensor_region},
where the continuous integral is replaced by a discrete summation over all projected peaks in region $\Omega_\mathbi{x}$.
Note that although we can define $\BM{Q}_\mathbi{x}$ using continuous ODF $f(\ensuremath{\mathbf{u}},\mathbi{x})$ with projected directors in a continuous integration like~\EEqref{eq:OO_qtensor_region},
we choose a discrete summation over peaks, which actually focuses only on peaks and sets zero weights for orientations that are not peaks in the continuous integration.
$\BM{Q}_\mathbi{x}$ in~\EEqref{eq:dyadic_tensor} has at most two non-zero eigenvalues, because it is defined by using $\{\ensuremath{\mathbf{u}}_{i,\perp}(\mathbi{y})\}$ in the orthogonal plane.
The eigenvector for the largest absolute eigenvalue of $\BM{Q}_\mathbi{x}$ is set as the second orientation of the orthogonal frame,
which is the main director of directors $\{(\ensuremath{\mathbf{u}}_{i,\perp},\ w(\mathbi{y},\mathbi{x})f(\ensuremath{\mathbf{u}}_i,\mathbi{y}) )\}$, and indicates the main orientation of the local spatial change of $\ensuremath{\mathbf{u}}_1(\mathbi{x})$ in the orientational plane.
Note that we define $\BM{Q}_\mathbi{x}$ using the isotropic spatial weight $w(\mathbi{y},\mathbi{x})$ to capture the general spatial change of the principal director $\ensuremath{\mathbf{u}}_1(\mathbi{x})$ in the orthogonal plane.
If one has a good motivation and specific spatial prior knowledge (e.g., to capture local change only in a specific region like hippocampus),
an anisotropic spatial weight $w(\mathbi{y},\mathbi{x})$ with consideration of spatial prior knowledge may be useful.
The third orientation in the orthogonal frame is set as the cross product of the first two orientations.
These three orientations are three orthogonal directors due to sign ambiguity.
Please see the sketch map in Fig.~\ref{fig:demo_frame} to determine local orthogonal frames from a given ODF field.
If these two eigenvalues of $\BM{Q}_\mathbi{x}$ are equal or their difference is very small, then we set the second and third orientations in the orthogonal frame to zero,
which means any two orthogonal vectors in the orthogonal plane can be the second and third axes in the orthogonal frame.
\subsection{Local Distortion Indices: Splay, Bend, and Twist}
\label{sec:distortion}
\begin{figure*}[t!]
\centering
\begin{tabular}{c@{\hskip 0.5in} c@{\hskip 0.5in} c }
\includegraphics[scale=.15]{dti_splay_demo} &
\includegraphics[scale=.15]{dti_bend_demo} &
\includegraphics[scale=.15]{dti_twist_demo} \\
splay & bend & twist
\end{tabular}
\caption{\label{fig:distortion}Demonstration of three types of distortions, i.e., splay, bend, and twist.}
\end{figure*}
\textbf{Three types of orientational distributions in liquid crystals}.
Based on the liquid crystal analogy, there are three fundamental types of distortions~\textsuperscript{\ref{nt:lq}} for the director field as demonstrated in Fig.~\ref{fig:distortion}.
1) \emph{splay}: bending occurs perpendicular to the director;
2) \emph{bend}: bending is parallel to the director and molecular axis;
3) \emph{twist}: neighboring directors are rotated with respect to one another, rather than aligned.
These three fundamental distortions can be used to describe a myriad of complex geometric patterns that liquid crystals can assume.
We would like to quantify these fundamental distortion patterns in dMRI by exploring the local spatial changes of principal directors.
\textbf{Spatial derivatives of the local orthogonal frame}.
With the local orthogonal frame $\{\ensuremath{\mathbf{u}}_1(\mathbi{x}),\ensuremath{\mathbf{u}}_2(\mathbi{x}),\ensuremath{\mathbf{u}}_3(\mathbi{x})\}$ at each voxel $\mathbi{x}$ obtained above,
we can define the spatial directional derivatives of $\ensuremath{\mathbf{u}}_i(\mathbi{x})$ along a direction $\mathbi{v}$ as
\begin{equation}\label{eq:derivative_dir_v}
\frac{\partial \ensuremath{\mathbf{u}}_i}{\partial \mathbi{v}}= \lim_{k\to 0} \frac{ \texttt{Diff}_\text{d}(\ensuremath{\mathbf{u}}_i(\mathbi{x}+ k\mathbi{v}), \ensuremath{\mathbf{u}}_i(\mathbi{x}- k\mathbi{v}))}{ 2 k}.
\end{equation}%
$\texttt{Diff}_\text{d}$ is the director representation of the difference of two directors as described in Section~\ref{sec:diff_dir}.
Note that we use the director representation for the spatial derivative, instead of a rotation matrix representation, because we would like to project the director onto different axes.
See Section~\ref{sec:diff_dir} and~\ref{sec:derivative_dir}.
\textbf{Spatial derivatives of vectors, and Maurer-Cartan connection forms in the moving frame method}.
If we assume $\{\ensuremath{\mathbf{u}}_i\}$ are all well-aligned unit vectors (i.e., no sign ambiguity),
then we have
\begin{equation}\label{eq:frame_derivative}
\frac{\partial \ensuremath{\mathbf{u}}_i}{\partial \mathbi{v}} = \nabla_\mathbi{x} \BM{\ensuremath{\mathbf{u}}}_i : \mathbi{v}
\end{equation}
with elements $\left[ \sum_k \frac{\partial u_{il}}{\partial x_k} v_k \right]$,
where $u_{il}$ is the $l$-th element of $\ensuremath{\mathbf{u}}_i$, and $\nabla_\mathbi{x} \BM{\ensuremath{\mathbf{u}}}_i=[ \frac{\partial u_{il}}{\partial x_k}]$ is the spatial gradient matrix of $\ensuremath{\mathbf{u}}_i(\mathbi{x})$.
Similarly with~\EEqref{eq:tensor2scalar}, we can extract some features by devising $\mathbi{v}$ and a weighting vector $\mathbi{w}$:
\begin{equation}\label{eq:frame_weight}
\mathbi{w}^T\frac{\partial \ensuremath{\mathbf{u}}_i}{\partial \mathbi{v}}= \mathbi{w} : \nabla_\mathbi{x} \BM{\ensuremath{\mathbf{u}}}_i : \mathbi{v} = \sum_{lm} w_l v_m \frac{\partial u_{il}}{\partial x_m}.
\end{equation}
\EEqref{eq:frame_weight} can be seen as a generalization of~\EEqref{eq:tensor2scalar} in tensor field analysis.
When we set $\mathbi{w}=\ensuremath{\mathbf{u}}_j$ and $\mathbi{v}=\ensuremath{\mathbf{u}}_k$, \EEqref{eq:frame_weight} is the projection of the directional derivatives onto $\ensuremath{\mathbf{u}}_j(\mathbi{x})$, denoted as $c_{ijk}$:
\begin{equation}
c_{ijk} = \ensuremath{\mathbf{u}}_j^T\frac{\partial \ensuremath{\mathbf{u}}_i}{\partial \ensuremath{\mathbf{u}}_k}= \ensuremath{\mathbf{u}}_j : \nabla_\mathbi{x} \BM{\ensuremath{\mathbf{u}}}_i : \ensuremath{\mathbf{u}}_k = \sum_{lm}u_{jl} u_{km} \frac{\partial u_{il}}{\partial x_m}.
\end{equation}%
$\{c_{ijk}(\mathbi{x})\}$ is the Maurer-Cartan connection form in the moving frame method~\footnote{\url{https://en.wikipedia.org/wiki/Maurer-Cartan_form}}.
$c_{ijk}(\mathbi{x})$ denotes the spatial change rate of frame vector $\ensuremath{\mathbf{u}}_i$ towards $\ensuremath{\mathbf{u}}_j$ when moving the frame along $\ensuremath{\mathbf{u}}_k$ at voxel $\mathbi{x}$~\citep{piuze_PAMI2015}.
\textbf{Orientational distortion indices}.
In this paper, instead of directly using the connections $\{c_{ijk}(\mathbi{x})\}$,
we propose three scalar indices to describe the relative prevalence of each of the three types of local distortions of white matter, inspired by liquid crystals~\citep{andrienko_2006}.
We define three indices and a total distortion index as
\begin{footnotesize}
\begin{align}
\text{Splay index:} \ \ & s = \sqrt{c_{122}^2 + c_{133}^2} = \sqrt{ (\ensuremath{\mathbf{u}}_2^T\frac{\partial \ensuremath{\mathbf{u}}_1}{\partial \ensuremath{\mathbf{u}}_2} )^2 + (\ensuremath{\mathbf{u}}_3^T\frac{\partial \ensuremath{\mathbf{u}}_1}{\partial \ensuremath{\mathbf{u}}_3} )^2} \label{eq:splay}\\
\text{Bend index:} \ \ & b = \sqrt{c_{121}^2 + c_{131}^2} = \sqrt{ (\ensuremath{\mathbf{u}}_2^T\frac{\partial \ensuremath{\mathbf{u}}_1}{\partial \ensuremath{\mathbf{u}}_1} )^2 + (\ensuremath{\mathbf{u}}_3^T\frac{\partial \ensuremath{\mathbf{u}}_1}{\partial \ensuremath{\mathbf{u}}_1} )^2} \label{eq:bend}\\
\text{Twist index:} \ \ & t = \sqrt{c_{123}^2 + c_{132}^2} = \sqrt{ (\ensuremath{\mathbf{u}}_2^T\frac{\partial \ensuremath{\mathbf{u}}_1}{\partial \ensuremath{\mathbf{u}}_3} )^2 + (\ensuremath{\mathbf{u}}_3^T\frac{\partial \ensuremath{\mathbf{u}}_1}{\partial \ensuremath{\mathbf{u}}_2} )^2} \label{eq:twist}
\end{align}
\begin{equation}\label{eq:distortion}
\text{Total distortion index:} \ \ d = \sqrt{s^2+b^2+t^2}.
\end{equation}
\end{footnotesize}%
\begin{algorithm}[t!]
\caption{\label{alg:derivative}\textbf{Calculation of spatial directional derivatives of the principal director:}}
\SetAlgoLined
\KwIn{A local orthogonal frame field $\{\ensuremath{\mathbf{u}}_1(\mathbi{x}), \ensuremath{\mathbf{u}}_2(\mathbi{x}), \ensuremath{\mathbf{u}}_3(\mathbi{x})\}$.}
\KwOut{Three spatial directional derivatives $\frac{\partial \ensuremath{\mathbf{u}}_1}{\partial \ensuremath{\mathbf{u}}_i}$, $i=1,2,3$.}
// Calculate three rotational matrices $\{\BM{R}_i\}$, $i=1,2,3$ \;
$\VV{o}_1=[1,0,0]^T$, $\VV{o}_2=[0,1,0]^T$, $\VV{o}_3=[0,0,1]^T$ \;
\For{$i=1,2,3$}{
$\mathbi{v}_1 = \ensuremath{\mathbf{u}}_1(\mathbi{x}+\VV{o}_i)$, $\mathbi{v}_0 = \ensuremath{\mathbf{u}}_1(\mathbi{x}-\VV{o}_i)$ \;
\eIf{$\mathbi{v}_1^T\mathbi{v}_0\geq 0$}
{$\mathbi{v}_2 = (\mathbi{v}_1+\mathbi{v}_0)/2$}
{$\mathbi{v}_2 = (\mathbi{v}_1-\mathbi{v}_0)/2$}
$\mathbi{v}_2= \frac{\mathbi{v}_2}{\|\mathbi{v}_2\|}$ \ \ \ \ // $\mathbi{v}_2$ is the normalized mean director of $\mathbi{v}_1$ and $\mathbi{v}_0$ \;
Calculate rotation matrix $\BM{R}_i$ which rotates $\mathbi{v}_2$ to $\mathbi{v}_1$ \;
}
// Calculate spatial directional derivatives from rotation matrices \;
\For{$i=1,2,3$}{
\For{$j=1,2,3$}{
$u_{i,j}=\ensuremath{\mathbf{u}}_i^T\VV{o}_j$ \;
\eIf{$u_{i,j}\geq 0$}
{ $\VV{p}_j = u_{i,j} \BM{R}_j \ensuremath{\mathbf{u}}_1 $, $\VV{n}_j = u_{i,j} \BM{R}_j^T \ensuremath{\mathbf{u}}_1 $ \;}
{ $\VV{p}_j = -u_{i,j} \BM{R}_j^T \ensuremath{\mathbf{u}}_1 $, $\VV{n}_j = -u_{i,j} \BM{R}_j \ensuremath{\mathbf{u}}_1 $ \; }
}
$\VV{p}_0 = \VV{p}_1+\VV{p}_2+\VV{p}_3$, $\VV{p}_0=\frac{\VV{p}_0}{\|\VV{p}_0\|}$ \;
$\VV{n}_0 = \VV{n}_1+\VV{n}_2+\VV{n}_3$, $\VV{n}_0=\frac{\VV{n}_0}{\|\VV{n}_0\|}$ \;
\eIf{$\|\VV{p}_0-\VV{n}_0\| \leq \|\VV{p}_0+\VV{n}_0\|$ }
{ $\frac{\partial \ensuremath{\mathbf{u}}_1}{\partial \ensuremath{\mathbf{u}}_i} = \VV{p}_0-\VV{n}_0$}
{ $\frac{\partial \ensuremath{\mathbf{u}}_1}{\partial \ensuremath{\mathbf{u}}_i} = \VV{p}_0+\VV{n}_0$}
}
\end{algorithm}
\textbf{Numerical calculation of spatial derivatives of directors and orientational distortion indices}.
Note that the above definitions of four indices and the formulae from~\EEqref{eq:frame_derivative} to~\EEqref{eq:distortion} are for a general vector frame in a vector field without sign ambiguity.
We would like to calculate the above four indices for the local orthogonal frames in Section~\ref{sec:frame} with sign ambiguity.
Squared values of $\ensuremath{\mathbf{u}}_j^T\frac{\partial \ensuremath{\mathbf{u}}_1}{\partial \ensuremath{\mathbf{u}}_i}$ in definitions are used to avoid the sign ambiguity of $\{\ensuremath{\mathbf{u}}_i\}$ and $\{\frac{\partial \ensuremath{\mathbf{u}}_1}{\partial \ensuremath{\mathbf{u}}_i}\}$.
The difficulty of numerically calculating the above four indices is that it is challenging to calculate the three spatial directional derivatives $\{\frac{\partial \ensuremath{\mathbf{u}}_1}{\partial \ensuremath{\mathbf{u}}_i}\}$, $i=1,2,3$,
because the local orthogonal frame $\{\ensuremath{\mathbf{u}}_i(\mathbi{x})\}$ with three directors is ambiguous with respect to its sign.
In other words, $\ensuremath{\mathbf{u}}_i$ is equivalent to $-\ensuremath{\mathbf{u}}_i$, considering the ODF and its peaks are antipodally symmetric.
We propose calculating the above spatial directional derivatives using a rotation matrix representation and a central difference approximation as described in Section~\ref{sec:derivative_dir}.
See Algorithm~\ref{alg:derivative} for a detailed implementation.
The algorithm first calculates three rotation matrices respectively along the $x$, $y$, $z$ axes, which is analogous to the spatial gradient of a vector field.
Then $\frac{\partial \ensuremath{\mathbf{u}}_1}{\partial \ensuremath{\mathbf{u}}_i}$ is numerically approximated by the director representation of the difference, i.e., $\texttt{Diff}_\text{d}(\ensuremath{\mathbf{u}}_1(\mathbi{x}+ \ensuremath{\mathbf{u}}_i), \ensuremath{\mathbf{u}}_1(\mathbi{x}- \ensuremath{\mathbf{u}}_i))$,
where $\ensuremath{\mathbf{u}}_1(\mathbi{x}+ \ensuremath{\mathbf{u}}_i)$ and $\ensuremath{\mathbf{u}}_1(\mathbi{x}- \ensuremath{\mathbf{u}}_i)$ are approximated by the weighted mean of three rotated vectors along three axes, as shown in~\EEqref{eq:weighted_ratation_dir}.
After $\{\frac{\partial \ensuremath{\mathbf{u}}_1}{\partial \ensuremath{\mathbf{u}}_i}\}$ are obtained, we can calculate the above four indices in~\EEqref{eq:splay},~\EEqref{eq:bend},~\EEqref{eq:twist}, and~\EEqref{eq:distortion}, from the directional derivatives.
Note that Algorithm~\ref{alg:derivative} avoids alignment of local frames in~\cite{piuze_PAMI2015} that does not work for general dMRI data.
\section{Experiments}
\label{sec:experiments}
\subsection{Synthetic Data Experiments}
\begin{figure*}[t!]
\resizebox{\textwidth}{!}{%
\begin{tabular}{c | c | c | c | c}
& splay & bend & twist & total distortion \\
\hline
\includegraphics[width=0.19\textwidth]{dti_splay} & \includegraphics[width=0.19\textwidth]{dti_splay_frame_splay} & \includegraphics[width=0.19\textwidth]{dti_splay_frame_bend} & \includegraphics[width=0.19\textwidth]{dti_splay_frame_twist} & \includegraphics[width=0.19\textwidth]{dti_splay_frame_distortion}\\
\hline
\includegraphics[width=0.19\textwidth]{dti_bend} & \includegraphics[width=0.19\textwidth]{dti_bend_frame_splay} & \includegraphics[width=0.19\textwidth]{dti_bend_frame_bend} & \includegraphics[width=0.19\textwidth]{dti_bend_frame_twist} & \includegraphics[width=0.19\textwidth]{dti_bend_frame_distortion}\\
\hline
\includegraphics[width=0.18\textwidth]{dti_twist} & \includegraphics[width=0.18\textwidth]{dti_twist_frame_splay} & \includegraphics[width=0.18\textwidth]{dti_twist_frame_bend} & \includegraphics[width=0.18\textwidth]{dti_twist_frame_twist} & \includegraphics[width=0.18\textwidth]{dti_twist_frame_distortion}\\
\end{tabular}
}
\caption{\label{fig:distortion_exp}Distortion indices calculated from different tensor fields.
In each row, the four distortion indices are calculated from the ODF field obtained from the tensor field.
The tensors were visualized by using superquadric tensor glyphs~\citep{kindlmann_2004}.}
\end{figure*}
Fig.~\ref{fig:distortion_exp} demonstrates these four orientational distortion indices (i.e, splay, bend, twist, and total distortion) calculated from idealized tensor fields.
The tensors are visualized by using superquadric tensor glyphs~\citep{kindlmann_2004}.
The first column of Fig.~\ref{fig:distortion_exp} shows different tensor fields.
The middle area of the first tensor field is the splaying area, while the middle area of the second tensor field is the bending region.
These two tensor fields are generated by rotating a tensor from left to right around the $z$-axis perpendicular to the page and decreasing the tensor mode~\citep{Kindlmann_TMI2007} from the bottom row to the top row.
The third tensor field shows the twist of tensor orientations,
which is generated by rotating a tensor around the $x$-axis (i.e., the left-to-right axis), and decreasing the tensor mode from bottom to top.
Fig.~\ref{fig:distortion_exp} shows that
1) the four indices only depend on the orientations (i.e., local orthogonal frame), not on the tensor or ODF shape;
2) splay, bend, twist indices provide complementary information about the orientational change, and demonstrate different types of orientational distortions.
Note that the twist index for the third tensor field is actually a constant, and the index value around the boundary is different due to the Neumann boundary condition used in the calculation.
Although the results in Fig.~\ref{fig:distortion_exp} are for tensor fields,
the distortion indices are actually determined by the local orthogonal frame field that can be calculated from a general spherical function field as described in Section~\ref{sec:frame}.
\begin{figure*}[t!]
\centering
\includegraphics[scale=.3]{dti_rotation}
\vspace{2mm} \\
\begin{tabular}{c c c}
\includegraphics[scale=.4]{dti_rotation_splay} & \includegraphics[scale=.4]{dti_rotation_bend} & \includegraphics[scale=.4]{dti_rotation_twist}\\
splay & bend & twist
\vspace{2mm}
\\
\includegraphics[scale=.4]{dti_rotation_dispersion} & \includegraphics[scale=.4]{dti_rotation_curving} & \includegraphics[scale=.4]{dti_rotation_distortion}\\
dispersion & curving & total distortion
\end{tabular}
\caption{\label{fig:distortion_exp_compare}Dispersion, curving~\citep{Savadjiev_NI2010}, and the proposed four orientational distortion indices calculated from a tensor field.}
\end{figure*}
We would like to compare the four orientational distortion indices with the curving and dispersion indices proposed for tensor fields in~\cite{Savadjiev_NI2010}.
The tensor field in Fig.~\ref{fig:distortion_exp_compare} was used in~\cite{Savadjiev_NI2010}.
It has three areas where the tensors rotate about its three eigenvectors, respectively.
From bottom to top, the mode of the tensors changes linearly.
Fig.~\ref{fig:distortion_exp_circle} shows two other synthetic tensor fields used in~\cite{Savadjiev_NI2010}.
Fig.~\ref{fig:distortion_exp_compare} and Fig.~\ref{fig:distortion_exp_circle} demonstrate all six scalar indices.
It can be seen that
1) the splay index is similar to the dispersion index;
2) the bend index is similar to the curving index;
3) the four orientational distortion indices are independent of tensor shapes, while curving and dispersion indices are dependent on the tensor mode;
4) when the principal directions are well aligned (e.g., in the left part of the tensor field in Fig.~\ref{fig:distortion_exp_compare}), all distortion indices are close to zero, because they are calculated based on the spatial difference of principal directions;
5) the definition and calculation of distortion indices are rotationally invariant.
Note that the singular values of these scalar indices around the central point in the tensor fields in Fig.~\ref{fig:distortion_exp_circle} are attributable to the singularity of the tensor orientation in the central point.
Although the proposed splay and bend indices have similar contrast compared with the dispersion and curving indices that are only for tensor fields,
the proposed distortion indices can be defined for both tensor fields and ODF fields.
Moreover, the proposed splay and bend indices are independent of tensor shapes, while the dispersion and curving indices are related with tensor shapes.
\begin{figure*}[t!]
\centering
\begin{tabular}{c c c c}
\includegraphics[scale=.18]{dti_circleBend} & \includegraphics[scale=.3]{dti_circleBend_dispersion} & \includegraphics[scale=.3]{dti_circleBend_curving} & \includegraphics[scale=.3]{dti_circleBend_distortion} \\
tensor field & dispersion & curving & total distortion
\vspace{2mm} \\
& \includegraphics[scale=.3]{dti_circleBend_splay} & \includegraphics[scale=.3]{dti_circleBend_bend} & \includegraphics[scale=.3]{dti_circleBend_twist} \\
& splay & bend & twist \\
\end{tabular}
\begin{tabular}{c c c c}
\includegraphics[scale=.18]{dti_circleSplay} & \includegraphics[scale=.3]{dti_circleSplay_dispersion} & \includegraphics[scale=.3]{dti_circleSplay_curving} & \includegraphics[scale=.3]{dti_circleSplay_distortion}\\
tensor field & dispersion & curving & total distortion
\vspace{2mm} \\
& \includegraphics[scale=.3]{dti_circleSplay_splay} & \includegraphics[scale=.3]{dti_circleSplay_bend} & \includegraphics[scale=.3]{dti_circleSplay_twist} \\
& splay & bend & twist
\end{tabular}
\caption{\label{fig:distortion_exp_circle}Dispersion, curving~\citep{Savadjiev_NI2010}, and the proposed four orientational distortion indices calculated from two tensor fields.}
\end{figure*}
\subsection{Real Data Experiments}
The experimental data are from Human Connectome Project (HCP), Q3 release~\citep{sotiropoulos_HCP_NI13,van:NI2013:HCP}.
This data set is acquired using three shells, with 90 staggered directions per shell, and at $b=1000,2000$, and $3000\,\text{s}/\text{mm}^2$.
We perform NODDI on the HCP multi-shell data using the released matlab toolbox by the authors~\citep{zhang_NODDI_NI2012}.
The first row in Fig.~\ref{fig:HCP_oo} shows the parameter maps by the NODDI toolbox, i.e., the $\kappa$ map and $\text{OD}_\text{w}$ map.
It should be noted that $\text{OD}_\text{w}$ is calculated based on $10\kappa$ and~\EEqref{eq:OD_w} in the author-released toolbox.
Fig.~\ref{fig:HCP_oo} also shows OO and OD from NODDI, based on the closed form in~\EEqref{eq:OO_watson} with a scaled $25\kappa$.
The scale on $\kappa$ is used for a better contrast in the obtained dispersion index map.
The obtained $\kappa$ map has intensities that are less than $0.4$ in most voxels.
Thus, as shown in Fig.~\ref{fig:OO_tensor_watson}, $10\kappa$ obtains the range $[0,4]$ which is good for $\text{OD}_\text{w}$,
and $25\kappa$ obtains the range $[0,10]$ which is good for $\text{OD}$.
The two dispersion index maps calculated in two ways from $\kappa$ visually have similar contrast.
Non-negative spherical deconvolution (NNSD)~\citep{cheng_NI2014} is performed to estimate non-negative fiber ODFs from three-shell DWI data.
NNSD works for multi-shell data.
It is more robust to noise, and the obtained fiber ODFs (fODFs) in isotropic regions are closer to the isotropic spherical PDF, compared with conventional constrained spherical deconvolution~\citep{tournier_NI2007}.
After obtaining the fODFs by NNSD, the peaks are detected from the estimated fODFs with GFA larger than $0.3$, as described in Section~\ref{sec:frame}.
OO and OD are calculated from the spherical harmonic representation of fODFs along their principal peaks as shown in Algorithm~\ref{alg:OO_OD}.
The second row in Fig.~\ref{fig:HCP_oo} demonstrates FA from tensors estimated by DTI, OO and OD from fODFs estimated by NNSD,
and the total distortion map estimated from the local orthogonal frames of fODFs.
Fig.~\ref{fig:HCP_region1} and~\ref{fig:HCP_region2} show the close-up views of
fODFs, local orthogonal frames, and the six proposed indices for the red and blue regions in Fig.~\ref{fig:HCP_oo},
where the region shown in~\ref{fig:HCP_region1} is also visualized in the DFA pipeline in Fig.~\ref{fig:DFA}.
The fODF glyphs are colored by using its sampled directions.
The three orientations in the local orthogonal frame in each voxel are visualized by using three tubes in red, green, and blue colors respectively.
There is no local orthogonal frame in some voxels because those voxels have GFA values lower than $0.3$.
These figures show the following:
1) OO is high in anisotropic areas with well-aligned directions, while OD is high in isotropic or crossing areas.
2) The four orientational distortion indices are low in areas with well aligned principal directions, and zero in isotropic voxels without peaks.
Distortion indices are high in voxels where the principal directions in its local neighborhood change largely.
3) The central voxels in red region is the crossing area of the Corpus Callosum from left to right and Fornix that goes through the coronal slice.
The twist index showed high value in this crossing area as expected.
OO and OD by NODDI are different from OO and OD by NNSD in Fig.~\ref{fig:HCP_oo}.
We propose OO and OD as general properties (i.e., the degree of aligment and dispersion along peaks) for general ODFs, like GFA for ODFs, independent of diffusion signal models.
OO and OD can be calculated from ODFs estimated by the NODDI model~\citep{zhang_NODDI_NI2012}, the tensor model in DTI~\citep{Basser1994}, and various spherical deconvolution methods~\citep{tournier_NI2007,cheng_NI2014}, etc.
In this sense, we claim that the proposed OD (and OO) inspired from liquid crystals is more general than the dispersion index in NODDI that only works for Watson distributions.
\begin{figure*}[t!]
\small
\centering
\begin{subfigure}[b]{0.24\textwidth}
\includegraphics[width=\textwidth]{hcp_c88_noddi_kappa}
\caption*{$\kappa$ from NODDI}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\includegraphics[width=\textwidth]{hcp_c88_noddi_odi}
\caption*{$\text{OD}_{\text{w}}$ from NODDI ($10\kappa$)}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\includegraphics[width=\textwidth]{hcp_c88_noddi_kappa25_OO}
\caption*{$\text{OO}$ from NODDI ($25\kappa$)}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\includegraphics[width=\textwidth]{hcp_c88_noddi_kappa25_OD}
\caption*{$\text{OD}$ from NODDI ($25\kappa$)}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\includegraphics[width=\textwidth]{hcp_c88_fa_with2regions}
\caption*{FA from tensors}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\includegraphics[width=\textwidth]{hcp_c88_NNSD_distortion}
\caption*{total distortion from fODFs}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\includegraphics[width=\textwidth]{hcp_c88_NNSD_OO}
\caption*{OO from fODFs}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\includegraphics[width=\textwidth]{hcp_c88_NNSD_OD}
\caption*{OD from fODFs}
\end{subfigure}
\caption{\label{fig:HCP_oo}
First row: NODDI results for multi-shell HCP data,
where $\kappa$ is estimated from NODDI model,
$\text{OD}_\text{w}$ is calculated from~\EEqref{eq:OD_w} by using $10\kappa$,
and $\text{OO}$ and $\text{OD}$ are calculated from~\EEqref{eq:OO_watson} by using $25\kappa$.
Second row: DTI and NNSD results for HCP data, where OO, OD and total orientational distortion are calculated from fODFs by NNSD.
The close-up views of red and blue regions are in Fig.~\ref{fig:HCP_region1} and~\ref{fig:HCP_region2}.
}
\end{figure*}
\begin{figure*}[t!]
\begin{tabular}{c c c }
\includegraphics[width=0.32\textwidth]{hcp_c88_region1_fODF_OO} & \includegraphics[width=0.32\textwidth]{hcp_c88_region1_fODF_OD} & \includegraphics[width=0.32\textwidth]{hcp_c88_region1_fODF_distortion} \\
OO & OD & total distortion\\
\includegraphics[width=0.32\textwidth]{hcp_c88_region1_fODF_splay} & \includegraphics[width=0.32\textwidth]{hcp_c88_region1_fODF_bend} & \includegraphics[width=0.32\textwidth]{hcp_c88_region1_fODF_twist}\\
splay & bend & twist
\end{tabular}
\caption{\label{fig:HCP_region1}fODFs, local orthogonal frames, and six scalar indices for the red region in Fig.~\ref{fig:HCP_oo}.
Local orthogonal frames are visualized using tubes in red, green, and blue colors.
The scalar indices are shown in the background. This region is also used in the DFA pipeline in Fig.~\ref{fig:DFA}
}
\end{figure*}
\begin{figure*}[t!]
\begin{tabular}{c c c }
\includegraphics[width=0.32\textwidth]{hcp_c88_region2_fODF_OO} & \includegraphics[width=0.32\textwidth]{hcp_c88_region2_fODF_OD} & \includegraphics[width=0.32\textwidth]{hcp_c88_region2_fODF_distortion}\\
OO & OD & total distortion\\
\includegraphics[width=0.32\textwidth]{hcp_c88_region2_fODF_splay} & \includegraphics[width=0.32\textwidth]{hcp_c88_region2_fODF_bend} & \includegraphics[width=0.32\textwidth]{hcp_c88_region2_fODF_twist}\\
splay & bend & twist
\end{tabular}
\caption{\label{fig:HCP_region2}fODFs, local orthogonal frames, and six scalar indices for the blue region in Fig.~\ref{fig:HCP_oo}.
Local orthogonal frames are visualized using tubes in red, green, and blue colors.
The scalar indices are shown in the background.
}
\end{figure*}
We perform whole brain streamline tractography on the estimated fODF field using mrtrix~\citep{tournier_mrtrix_12}~\footnote{\href{http://www.mrtrix.org}{http://www.mrtrix.org/}}.
The voxels with GFA larger than $0.3$ are used as seed voxels to generate $10000$ tracts by using \texttt{tckgen} in mrtrix.
All other parameters are default parameters in mrtrix.
The obtained fiber tracts are then visualized by using trackvis~\footnote{\href{http://trackvis.org}{http://trackvis.org}}.
Fig.~\ref{fig:HCP_roi2_track} and~\ref{fig:HCP_roi_track} demonstrate the tracts respectively cross two given ball ROIs.
The tracts are colored by using the proposed six scalar indices.
Note that the proposed scalar indices are calculated based on estimated fODFs, not based on fiber tracts.
It can be seen that
1) OO is high in areas with well aligned fibers, while OD is high in crossing areas and distortion areas;
2) distortion indices are low when fibers are well aligned;
3) the total distortion index is high in areas with highly curved fibers or crossing fibers.
4) although splay, bend, twist indices may be separable (e.g., one is large while another one is close to zero) in synthetic data,
in real data, these three types of distortions normally occur together, especially for bending and splaying.
5) the ROI in Fig.~\ref{fig:HCP_roi2_track} is the crossing area of the Corpus Callosum and the Fornix, where all distortion indices have high values, especially for twist and total distortion indices.
This finding agrees with Fig.~\ref{fig:HCP_region1}.
\begin{figure*}[t!]
\centering
\includegraphics[width=0.265\textwidth]{hcp_track_roi2} \\
ROI on OO map \\
\begin{tabular}{c c c }
\includegraphics[width=0.32\textwidth]{hcp_track_roi2_OO} & \includegraphics[width=0.32\textwidth]{hcp_track_roi2_OD} & \includegraphics[width=0.32\textwidth]{hcp_track_roi2_distortion}\\
OO & OD & total distortion \\
\includegraphics[width=0.32\textwidth]{hcp_track_roi2_splay} & \includegraphics[width=0.32\textwidth]{hcp_track_roi2_bend} & \includegraphics[width=0.32\textwidth]{hcp_track_roi2_twist}\\
splay & bend & twist
\end{tabular}
\caption{\label{fig:HCP_roi2_track}Fiber tracts cross a given ROI are colored by the six indices, respectively.}
\end{figure*}
\begin{figure*}[t!]
\centering
\includegraphics[width=0.265\textwidth]{hcp_track_roi} \\
ROI on OO map \\
\begin{tabular}{c c c }
\includegraphics[width=0.32\textwidth]{hcp_track_roi_OO} & \includegraphics[width=0.32\textwidth]{hcp_track_roi_OD} & \includegraphics[width=0.32\textwidth]{hcp_track_roi_distortion}\\
OO & OD & total distortion \\
\includegraphics[width=0.32\textwidth]{hcp_track_roi_splay} & \includegraphics[width=0.32\textwidth]{hcp_track_roi_bend} & \includegraphics[width=0.32\textwidth]{hcp_track_roi_twist}\\
splay & bend & twist
\end{tabular}
\caption{\label{fig:HCP_roi_track}Fiber tracts cross a given ROI colored by the six indices, respectively.}
\end{figure*}
\section{Discussion}
\label{sec:discussion}
\subsection{Effect of the Spatial Resolution on Directional Derivatives and Distortion Indices}
The definition of the spatial directional derivative in~\EEqref{eq:derivative_dir} is for continuous spatial domain.
The unit of the spatial directional derivative $\frac{\partial \ensuremath{\mathbf{u}}_i}{ \partial \mathbi{v}}$ in~\EEqref{eq:derivative_dir_v} is $[\si{mm^{-1}},\si{mm^{-1}},\si{mm^{-1}}]$,
considering the numerator is a director with no unit and the unit of the denominator is $\si{mm}$.
Thus, the four distortion indices have the unit of $\si{mm^{-1}}$.
The spherical function field and peak field in diffusion MRI are obtained in a discrete integer lattice.
In Algorithm~\ref{alg:derivative}, rotation matrices $\{\BM{R}_i\}$ are calculated based on directors in neighborhood voxels $\ensuremath{\mathbf{u}}_1(\mathbi{x}+\VV{o}_i)$ and $\ensuremath{\mathbf{u}}_1(\mathbi{x}-\VV{o}_i)$.
Thus, these three rotation matrices are dependent on spatial resolution of the diffusion image.
So are the central difference approximation of the spatial gradient in~\EEqref{eq:central_diff}, and the distortion indices calculated based on directional derivatives.
Consider the twisting synthetic tensor image in Fig.~\ref{fig:distortion_exp} as an example, where the tensor from left to right rotates about the $x$-axis by the angle $\pi$.
If there are $N+1$ tensors from left to right, then the spatial gradient along the $x$-axis is the rotation matrix with a rotation angle of $\pi/N$.
With the local linear change assumption of rotation angles, finer spatial resolution will produce smaller rotation angles of central differences in the three rotation matrices,
which results in smaller spatial gradients, directional derivatives and smaller distortion indices.
An improved version of calculation of the spatial directional derivatives in Algorithm~\ref{alg:derivative} is to consider the spatial resolution of the image as the step size of the central difference.
The image resolution should be used to normalize the rotation angles in the rotation matrices.
We can approximate the spatial gradient using all directors within a given physical resolution, e.g., $3\times 3\times 3~\si{mm}$.
If the image resolution is also $3~\si{mm}$ isotropic, then we just use the central difference described in Section~\ref{sec:derivative_dir}.
If the image resolution is $1.5~\si{mm}$ isotropic, then we can use a mean of rotation matrices from two central differences.
One rotation matrix is generated by $w\mathbi{v}(\mathbi{x}+\VV{o}_i)$, $w\mathbi{v}(\mathbi{x}-\VV{o}_i)$, then we keep the rotation axis, but scale the rotation angle by $2$, based on the local linear rotation angle assumption.
The other one is generated by $w\mathbi{v}(\mathbi{x}+2\VV{o}_i)$, $w\mathbi{v}(\mathbi{x}-2\VV{o}_i)$.
The Riemannian mean is used to calculate the mean of rotation matrices~\citep{moakher_SIAM2002}.
In this way, for the twisting synthetic tensor image in Fig.~\ref{fig:distortion_exp}, the rotation matrix representation of the central difference along the $x$-axis remains the same for different spatial resolutions of the synthetic image.
Note that the local linear rotation change assumption only holds in a small local neighborhood, not for a large spatial scale.
With the correct consideration of image resolution in calculation,
the image resolution effect can be reduced in numerical calculation of the proposed distortion indices.
\subsection{DFA For General Spherical Functions Without Antipodal Symmetry}
\label{sec:DFA_vector}
Considering spherical functions obtained in diffusion MRI are normally antipodally symmetric, the detected principal directors and local orthogonal frames all have sign ambiguity.
Thus, the proposed DFA is mainly for director data analysis.
However, if the reconstructed spherical function in a voxel (e.g., an ODF) is not antipodally symmetric, the detected principal peak field is a traditional vector field.
Then DFA can be modified for vector field analysis.
The difference of two vectors, the spatial gradient, and the spatial derivative of a vector field are all well defined.
Note that the definitions of OO and OD in Section~\ref{sec:order} work for a general spherical function $f(\ensuremath{\mathbf{u}})$ without requiring antipodal symmetry, although $\text{OO}(\mathbi{n})$ is always antipodally symmetric by definition.
If the detected peaks have no sign ambiguity, then the three orientations in the local orthogonal frame can all be traditional vectors.
The first orientation is the principal peak at voxel $\mathbi{x}$.
As described in Section~\ref{sec:frame}, after projecting all peaks onto the orthogonal plane, we obtain vectors $\{w(\mathbi{y},\mathbi{x}) f(\ensuremath{\mathbf{u}}_i,\mathbi{y}) (\ensuremath{\mathbf{u}}_i-(\ensuremath{\mathbf{u}}_i^T\ensuremath{\mathbf{u}}_1) \ensuremath{\mathbf{u}}_1)\}$ without sign ambiguity.
Then, the second orientation can be set as the orientation in the orthogonal plan with maximal value among $|w(\mathbi{y},\mathbi{x}) f(\ensuremath{\mathbf{u}}_i,\mathbi{y})|\|\ensuremath{\mathbf{u}}_i-(\ensuremath{\mathbf{u}}_i^T\ensuremath{\mathbf{u}}_1) \ensuremath{\mathbf{u}}_1)\|$, $\forall i$, or the mean orientation of the projected vectors in the orthogonal plane,
and the third orientation is the cross product of the first and second orientations.
Finally, the four orientational distortion indices in~\EEqref{eq:splay}, \EEqref{eq:bend}, \EEqref{eq:twist}, and~\EEqref{eq:distortion} can still be used for the spatial derivatives of the vector field, which are actually functions of Maurer-Cartan connections in the moving frame method.
\section{Conclusion}
\label{sec:conclusion}
In this paper, we propose a unified mathematical framework, called Director Field Analysis (DFA), to analyze a spherical function field and its extracted peak field.
See Fig.~\ref{fig:DFA} for an overview of the DFA pipeline.
First, in DFA, we detect peaks from the spherical function field, and define the Orientational Order (OO) and the Orientational Dispersion (OD) indices in voxels or within spatial regions.
Closed-form solutions of OO and OD are obtained for some specific spherical functions.
We propose OO and OD as properties for general ODFs along peaks, independent of diffusion signal models.
Second, we define a local orthogonal frame in each voxel exhibiting anisotropic diffusion, where the principal peak is its first axis, and the other two axes describe the local spatial change directions of principal peaks.
Third, from the extracted local orthogonal frames in voxels, DFA estimates three distortion indices (splay, bend, twist) that are able to distinguish three types of distortions and a total orientational distortion index.
To our knowledge, this paper is the first work to \emph{quantitatively} describe orientational distortion (splay, bend, and twist) in general spherical function fields from DTI or HARDI data.
The experiments demonstrate the following:
1) The proposed OO is another type of anisotropy index for spherical functions, and OD is more general and natural than the previous dispersion index proposed in NODDI~\citep{zhang_NODDI_NI2012}, which only works for Watson distributions.
2) The proposed splay and bend indices can be seen as a generalization of the dispersion and curving indices in~\cite{Savadjiev_NI2010}, considering they have similar contrast in the same tensor field.
The proposed four orientational distortion indices work not only for tensors but also for general spherical functions.
3) The proposed distortion indices demonstrate good sensitivity for the three different types of orientational distortion in Fig.~\ref{fig:distortion}.
4) Orientational distortion indices normally have large values in areas with fiber curving and crossing.
Note that the proposed DFA and its related mathematical tools can be used not only for diffusion MRI data, but also for general director data.
Moreover, there are many applications in which vector fields, like velocity fields, can be easily processed by using the modified DFA described in Section~\ref{sec:DFA_vector} to analyze their spatial features.
Considering the proposed scalar indices are sensitive to different distortions of principal directions,
these indices have potential in voxel-based analysis and tract-based analysis for group studies and longitudinal studies~\citep{smith:TBSS:NI2006,liu:NI2013},
which is a goal of future work.
We will release the related codes and demos for DFA in DMRITool~\footnote{\label{fn:dmritool}\url{https://diffusionmritool.github.io}}, which is an open source toolbox for diffusion MRI data processing.
\section*{Acknowledgments}
The authors thank Dr.~Carlo Pierpaoli and Dr.~Elizabeth Hutchinson for useful discussions on the Fornix, and Ms. Liz Salak for editing the manuscript.
This work was supported by funds provided by the Intramural Research Program of the \emph{Eunice Kennedy Shriver} National Institute of Child Health and Human Development (NICHD) (ZIA-HD000266).
The data were provided in part by the Human Connectome Project, WU-Minn Consortium
(Principal Investigators: David Van Essen and Kamil Ugurbil; 1U54MH091657) funded by the 16 NIH institutes and centers that support the NIH Blueprint for Neuroscience Research;
and by the McDonnell Center for Systems Neuroscience at Washington University.
| {'timestamp': '2017-10-17T02:05:28', 'yymm': '1706', 'arxiv_id': '1706.01862', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01862'} | arxiv |
\section{Introduction}
Cloud radio access network (C-RAN) \cite{CRAN2011} is a promising and flexible architecture to accommodate the exponential growth of mobile data traffic in the next-generation cellular network. In a C-RAN, all~the base-band signal processing is shifted to a single base-band unit (BBU) pool \cite{Shi2015}. The conventional base-stations (BSs), however, are replaced by geographically distributed remote antenna ports (RAPs) with only antenna elements and power amplifiers, which are connected to the BBU pool via high-speed low-latency fronthaul links by fiber. Thanks to its simple structure, it is promising to deploy ultra-dense RAPs in a C-RAN with low cost.
With highly dense geographically distributed RAPs, significant rate gains can be expected over that with the same amount of co-located antennas in both the single-user and multi-user cases \cite{Liu2014,Liu2017,Wang2015}. Due to the huge differences among the distance between the user and the geographically distributed RAPs, it has been shown in \cite{Liu2014} that the capacity in the single-user case is crucially determined by the access distance from the user to its closest RAP. This motivates us to investigate whether it is possible to achieve a significant proportion of the sum rate by using a subset of the RAPs. {When the number of active RAPs is small, the other RAPs will operate in the sleeping mode with very low power consumption, which reduces the network power consumption, and significantly improves the energy efficiency \cite{Dai2016, Nguyen2017}. Moreover, it is also able to improve the rate performance under limited fronthaul link capacity, as each RAP will only serve users with small access distances \cite{Zhao2013, Dai2013, Ha2016, Wang2017}.} In the single-user case, it is straightforward to avoid distant RAPs transmitting, as they have little contribution to improving the capacity. In the multi-user case, the problem becomes challenging, as the beamformers of all users should be jointly designed.
To tackle this problem, a branch of sparse beamforming technologies are therefore proposed, where the beamforming vectors are designed to be sparse
with respect to the total number of transmit antennas \cite{Zhao2013,Mehanna2013,Dai2013}. {Intuitively, a sparse beamforming vector implies that the number of active BS antennas is much smaller than the total number of BS antennas, leading to a significant reduction on both active fronthaul links and the circuit power consumption. Typically, the sparse constraint is introduced by imposing the $\ell_0$ norm of the beamforming vector as a regularization of the original objective function. As the $\ell_0$ norm is neither convex nor continuous, the sparse beamforming problem is in general a mixed-integer optimization problem, which is difficult to be globally optimized.} Motivated by the recent theoretical breakthroughs in compressive sensing \cite{Zhang2015}, the sparse beamforming problem is formulated by including the $\ell_1$ norm of the beamforming vectors as a regularization such that the problem becomes convex. By iteratively updating the weights of the $\ell_1$ norm, the sparse beamformer that minimizes the total transmit power can be obtained by iteratively solving a second-order-conic-programming (SOCP) \cite{Zhao2013} or a semi-definite-programming (SDP) \cite{Mehanna2013}. The problem can be further simplified to {an} uplink beamformer design problem via uplink-downlink duality \cite{Dai2013}.
Nevertheless, when each RAP includes multiple antennas, one RAP will be switched off only when all the coefficients in its beamformer are set to be zero. In other words, all antennas at a RAP should be selected or ignored simultaneously, {otherwise the number of active links from the BBU pool to the RAPs and the circuit power consumption cannot be reduced.} {Recently, the group sparse beamforming problem has been proposed where the antennas at the same RAP are restricted to be switched on or off simultaneously \cite{Dai2014a,Shi2014,Shi2015a, Dai2016, Ha2016, Luong2017,Nguyen2017}, which further complicates the problem. Luong et al. \cite{Luong2017}
{formulated} the sum rate and power consumption tradeoff problem as a mixed-integer-second-order-conic-programming (MI-SOCP) problem to obtain the global optimum by using branch-and-reduce-and-bound (BRB) algorithm, which imposes prohibitively computational complexity when the numbers of the RAPs and the users are large. To reduce the complexity, convex approximations are usually used to make it convex, continuous, and differentiable. For instance, Dai~and~Yu \cite{Dai2014a} {introduces} a reweighted $\ell_1$ norm of the vector that identifies the transmission power at each RAP to approximate the number of active RAPs, and the non-convex weighted sum rate maximization problem is approximated by weighted minimum mean square error (WMMSE) minimization and can be solved via a quadratical-constrained-quadratic-programming (QCQP). A more commonly used method is to replace the rate constraint by its equivalent signal-to-interference-plus-noise ratio (SINR) constraint, so as to solve the problem via SOCP \cite{Shi2014, Shi2015a, Dai2016, Luong2017}.} Compared to the individual sparse beamforming, the group sparse beamforming further reduces the network power consumption, and the energy efficiency can be improved as well.
So far, most algorithms focus on the situation where each user has a single antenna \cite{Zhao2013,Mehanna2013,Dai2013,Dai2014a,Shi2014,Shi2015a, Dai2016, Luong2017}. As suggested by the multiple-input-multiple-output (MIMO) theory, the capacity increases linearly with the minimum number of transmit and receive antennas \cite{Telatar1999}. In a C-RAN, it is desirable to employ multiple antennas at each user to exploit the potential multiplexing gains, which, however, further complicates the sparse precoder design. {In fact, most techniques \cite{Zhao2013,Mehanna2013,Dai2013,Shi2014,Shi2015a, Dai2016, Luong2017} developed for single-antenna users cannot be directly applied to the multiple-antenna user case. The difficulty originates from the fact that the rate is determined by not only the SINR but also by the power allocated to the multiple sub-channels, and thus the problem cannot be transformed into an SOCP problem as in the group sparse beamformer design. Therefore, Pan et al. \cite{Pan2017} {proposed} to adopt the reweighted $\ell_1$ norm to make the sparse constraint smooth and use the WMMSE method to make the rate expression convex, and a low-complexity algorithm is proposed to solve the network power consumption minimization problem by exploiting the special structure of the WMMSE approximation. This motivates us to extend some well-structured precoding scheme to C-RAN, and design a group sparse precoding approach with low computational complexity. In particular, we focus on designing a group sparse precoder based on a orthogonal precoding scheme, block diagonalization (BD) \cite{Spencer2004}, which has gained widespread popularity thanks to its low complexity and near-capacity performance when the number of transmit antennas is large \cite{Shen2006,Shen2007,Shim2008,Ravindran2008}. With BD, the receiving beamformer can be directly calculated from the channel gain matrix and the transmit precoder, and the design of the receive beamformer, which is mutually coupled with the transmit beamformer and difficult to be optimized in the multiple antenna user case \cite{Cai2011}, can be further simplified}.
In this paper, we address the joint problem of RAP selection and joint precoder design in a C-RAN with multiple antennas at each user and each RAP. Whereas the problem is typically non-deterministic polynomial-time hard (NP-hard),
we show that the problem becomes convex by inducing the reweighted $\ell_1$ norm of a vector that indicates the transmit power at each RAP as a regularization. Based on its Lagrangian dual problem, we propose an algorithm by iteratively updating the weights of the $\ell_1$ norm to generate a sparse solution. Simulation results verify that the proposed algorithm can achieve almost the same sum rate as {that from exhaustive search}
The rest of this paper is organized as follows: Section 2 introduces the system model and formulates the problem. Section 3 proposes an iterative algorithm to solve the group sparse precoding problem. {The complexity analysis of the proposed algorithm is presented in Section 4.} Simulation results are presented and discussed in Section 5. Section 6 concludes this paper.
{\textit{Notation:} Italic letters denote scalars, and boldface upper-case and lower-case letters denote matrices and vectors, respectively. $\|\mathbf{x}\|_p$ denotes the $\ell_p$ norm of vector $\mathbf{x}$. $\mathbf{X}^T$, $\mathbf{X}^{\dag}$, $\textmd{Tr}\{\mathbf{X}\}$ and $\det\{\mathbf{X}\}$ denote the transpose, conjugate transpose, trace and determinant of matrix $\mathbf{X}$, respectively. $\textrm{diag}(a_1,\dots,a_N)$ denotes an $N\times N$ diagonal matrix with diagonal entries $\{a_i\}$. $\mathbf{I}_N$ denotes an $N\times N$ identity matrix. $\mathbf{0}_{N\times M}$ and $\mathbf{1}_{N\times M}$ denote $N\times M$ matrices with all entries zero and one, respectively. $|\mathcal{X}|$~denotes the cardinality of set $\mathcal{X}$. $\lceil\cdot\rceil$ and $\mathbb{E}[\cdot]$ denote the ceiling and expectation operators,~respectively.}
\section{System Model and Problem Formulation}\label{s2}
Consider a C-RAN with a set of remote antenna ports (RAPs), denoted as $\mathcal{L}$, and a set of users, denoted as $\mathcal{K}$, with $|\mathcal{L}|=L$ and $|\mathcal{K}|=K$, as shown in Figure~\ref{Fig cran}. Suppose that each RAP is equipped with $N_c$ antennas, and each user is equipped with $N$ antennas. {Then we have a total number of $M=N_c L$ BS antennas.} The baseband units (BBUs) are moved to a single BBU pool which are connected to the RAPs via high-speed fronthaul links, such that the BBU pool has access to the perfect channel state information (CSI) between the RAPs and the users, and the signals of all RAPs can be jointly processed. With a high density of geographically distributed RAPs, the access distances from each user to the RAPs varies significantly, and the distant RAPs have little contribution to improve the capacity. This motivates us to find a subset of RAPs that can provide near optimal sum rate~ performance.
In particular, let $\mathcal{A}\subseteq \mathcal{L}$ denote the set of active RAPs, with $|\mathcal{A}|=A$. To utilize the multiplexing gains from the use of multiple user antennas, we assume that $AN_c\geq N$. The received signal at user $k$ can be then modeled as
\begin{equation}\label{System Model}
\mathbf{y}_k=\mathbf{H}_{k,\mathcal{A}}\mathbf{x}_{k,\mathcal{A}}+\sum_{j\ne k}\mathbf{H}_{k,\mathcal{A}}\mathbf{x}_{k,\mathcal{A}}+\mathbf{z}_k,
\end{equation}
where $\mathbf{x}_{k,\mathcal{A}}\in\mathbb{C}^{AN_c\times 1}$ and $\mathbf{y}_k\in\mathbb{C}^{N\times 1}$ denote the transmit and receive signal vectors, respectively. $\mathbf{H}_{k,\mathcal{A}}\in\mathbb{C}^{N\times AN_c}$ is the channel gain matrix between the active RAPs and user $k$. $\mathbf{z}_k$ denotes the additive noise, which is modeled as a Gaussian random vector with zero mean and covariance $\sigma^2 \mathbf{I}$. With linear precoding, the transmit signal vector $\mathbf{x}_{k,\mathcal{A}}$ can be expressed as
\begin{equation}
\mathbf{x}_{k,\mathcal{A}}=\mathbf{T}_{k,\mathcal{A}} \mathbf{s}_k,
\end{equation}
where $\mathbf{T}_{k,\mathcal{A}}\in\mathbb{C}^{AN_c\times N}$ is the precoding matrix. $\mathbf{s}_k\in\mathbb{C}^{N\times 1}$ is the information bearing symbols. It is assumed that Gaussian codebook is used for each user at the transmitter, and therefore $\mathbf{s}_k\sim\mathcal{CN}\left(\mathbf{0},\mathbf{I}\right)$. The transmit covariance matrix for user $k$ can be then written as $\mathbf{S}_{k,\mathcal{A}}=\mathbb{E}\left[\mathbf{x}_{k,\mathcal{A}}\mathbf{x}_{k,\mathcal{A}}^\dag\right]$. It is easy to verify that $\mathbf{S}_{k,\mathcal{A}}=\mathbf{T}_{k,\mathcal{A}}\mathbf{T}_{k,\mathcal{A}}^\dag$. The sum rate can be written from (\ref{System Model}) as
\begin{equation}\label{sum rate}
R=\sum_{k\in\mathcal{K}} \log_2 \det\left(\mathbf{I}_N+\frac{\mathbf{H}_{k,\mathcal{A}}\mathbf{S}_{k,\mathcal{A}}\mathbf{H}_{k,\mathcal{A}}^\dag}{\sigma^2\mathbf{I}_N+\sum_{j\ne k}\mathbf{H}_{k,\mathcal{A}}\mathbf{S}_{j,\mathcal{A}}\mathbf{H}_{k,\mathcal{A}}^\dag}\right).
\end{equation}
\begin{figure}[H]
\begin{center}
\includegraphics[width=.4\textwidth]{Fig1.eps}
\caption{Graphic illustration of a Cloud radio access network {(C-RAN)}; BBU: baseband unit; RAP: remote antenna port. }\label{Fig cran}
\end{center}
\end{figure}
Note that it is difficult to find the optimal linear precoder that maximizes the sum rate $R$ due to the non-convexity of (\ref{sum rate}), and the mutual coupling of the transmit and receive beamformers makes it difficult to jointly optimize the beamformers \cite{Cai2011}. In this paper, we assume that block diagonalization (BD) is adopted, where {the desired signal is projected to the null space of the channel gain matrices of all the other users,} such that $\mathbf{H}_{k,\mathcal{A}}\mathbf{x}_{j,\mathcal{A}}=\mathbf{0}$, or equivalently $\mathbf{H}_{k,\mathcal{A}}\mathbf{S}_{j,\mathcal{A}}\mathbf{H}_{k,\mathcal{A}}^\dag=\mathbf{0}$ for all $j\ne k$. With BD, the sum rate can be obtained as
\begin{equation}
R=\sum_{k\in\mathcal{K}} \log_2 \det\left(\mathbf{I}_N+\frac{1}{\sigma^2}\mathbf{H}_{k,\mathcal{A}}\mathbf{S}_{k,\mathcal{A}}\mathbf{H}_{k,\mathcal{A}}^\dag\right).
\end{equation}
As the signals come from more than one RAP, they need to satisfy a set of per-RAP power constraints, i.e.,
\begin{equation}
\text{Tr}\left\{\mathbf{B}_l\sum_k\mathbf{S}_{k,\mathcal{A}}\right\}\leq P_{l,\max},\forall l\in\mathcal{A},
\end{equation}
where $P_{l,\max}$ denotes the per-RAP power constraint. $\mathbf{B}_l=\text{diag}\{\mathbf{b}_l\}$ is a diagonal matrix, whose diagonal entries is defined as
\begin{equation}
\mathbf{b}_l=[\underbrace{0,\cdots,0}_{N_c(l-1)},\underbrace{1,\cdots,1}_{N_c},\underbrace{0,\cdots,0}_{M-N_c l}].
\end{equation}
This paper focuses on the tradeoff between the sum rate and the group sparsity. In particular, the problem can be formulated as the following optimization problem:
\begin{align}
&\mathop{\text{maximize}}\limits_{\mathcal{A},\{\mathbf{S}_{k,\mathcal{A}}\}}&& \sum_{k\in\mathcal{K}}\log_2\det\left(\mathbf{I}_N+\frac{1}{\sigma^2}\mathbf{H}_{k,\mathcal{A}}\mathbf{S}_{k,\mathcal{A}}\mathbf{H}_{k,\mathcal{A}}^{\dag}\right) -\eta|\mathcal{A}| &&\label{Primal Constraint 1}\\
&\text{s.t.} && \mathbf{H}_{j,\mathcal{A}}\mathbf{S}_{k,\mathcal{A}}\mathbf{H}_{j,\mathcal{A}}=\mathbf{0}&& \forall j,k\in\mathcal{K},j\ne k \label{Primal Constraint 2}\\
&&& \text{Tr}\left\{\mathbf{B}_l\sum_k\mathbf{S}_{k,\mathcal{A}}\right\}\leq P_{l,\max} && \forall l\in\mathcal{A}\label{Primal Constraint 3} \\
&&& \mathbf{S}_{k,\mathcal{A}}\succeq 0&& \forall k\in\mathcal{K}\label{Primal Constraint 4}
\end{align}
where (\ref{Primal Constraint 2}) is the zero-forcing (ZF) constraint, which ensures that the inter-user interference can be completely eliminated at the optimum. $\eta\geq 0$ is the tradeoff constant, which controls the sparsity of the solution, and thus the number of active RAPs. With $\eta=0$, the problem reduces to a BD precoder optimization problem with per-RAP power constraint. The group sparsity can be improved by assigning a larger $\eta$.
Note that the optimization problem {defined in (\ref{Primal Constraint 1})--(\ref{Primal Constraint 4})} needs to jointly determine the subset $\mathcal{A}$ and design the transmit covariance matrices $\mathbf{S}_{k,\mathcal{A}}$ for $K$ users, which is a combinatorial optimization problem and is NP-hard. A brute-force solution to a combinatorial optimization problem like (\ref{Primal Constraint 1})--(\ref{Primal Constraint 4}) is exhaustive search. Specifically, we must check all possible combinations of the active RAPs. For each combination, we must search for the optimal $\{\mathbf{S}_{k,\mathcal{A}}\}$ that satisfies the constraints (\ref{Primal Constraint 2})--(\ref{Primal Constraint 4}). In the end, we pick out the combination that maximizes the sum rate. However, the complexity grows exponentially with $L$, which cannot be applied to real-world application. Instead, we use the concept of $\ell_0$ norm to reformulate problem (\ref{Primal Constraint 1})--(\ref{Primal Constraint 4}). In particular, define $\bm{\omega}\in\mathbb{R}^{1\times L}$ as
\begin{equation}
\bm{\omega}=\left[\text{Tr}\{\mathbf{B}_1\sum_{k\in\mathcal{K}}\mathbf{S}_k\},\text{Tr}\{\mathbf{B}_2\sum_k\mathbf{S}_{k\in\mathcal{K}}\},\cdots,\text{Tr}\{\mathbf{B}_l\sum_{k\in\mathcal{K}}\mathbf{S}_k\},\cdots,\text{Tr}\{\mathbf{B}_L\sum_{k\in\mathcal{K}}\mathbf{S}_k\}\right],
\end{equation}
where $\mathbf{S}_k=\mathbb{E}\left[\mathbf{x}_k\mathbf{x}_k^\dag\right]$, with $\mathbf{x}_k\in\mathbb{C}^{M\times 1}$ denoting the transmit signal vector from all RAPs in $\mathcal{L}$ to user $k$. The $(N_c(l-1)+1)$-th to the $N_cl$-th entries of $\mathbf{x}_k$ are zero if RAP $l$ is inactive. It is clear that the $l$-th entry $\omega_l=\text{Tr}\{\mathbf{B}_l\sum_k\mathbf{S}_k\}$ is the transmit power of RAP $l$, which is non-zero if and only if RAP $l\in\mathcal{A}$. It~is easy to verify that $\|\bm{\omega}\|_0=|\mathcal{A}|$. We then have the following lemma:
\newtheorem{Th1}{Lemma}
\begin{Th1}\label{Lemma1}
{The problem defined in (\ref{Primal Constraint 1})--(\ref{Primal Constraint 4}) is} equivalent to the following optimization problem
\begin{equation}\label{P_l0}
\begin{aligned}
&\mathop{\text{maximize}}\limits_{\{\mathbf{S}_k\}}&&\sum_{k\in\mathcal{K}}\log_2\det\left(\mathbf{I}_N+\frac{1}{\sigma^2}\mathbf{H}_{k}\mathbf{S}_{k}\mathbf{H}_{k}^{\dag}\right) -\eta\|\bm\omega\|_0 &&\\
&\text{s.t.} && \mathbf{H}_j\mathbf{S}_k\mathbf{H}_j=\mathbf{0}&& \forall j,k\in\mathcal{K},j\ne k \\
&&& \text{Tr}\left\{\mathbf{B}_l\sum_{k\in\mathcal{K}}\mathbf{S}_{k}\right\}\leq P_{l,\max} && \forall l\in\mathcal{L} \\
&&& \mathbf{S}_{k}\succeq 0&& \forall k\in\mathcal{K}
\end{aligned}
\end{equation}
where $\mathbf{H}_k\in\mathbb{C}^{N\times M}$ is the channel gain matrix from all RAPs in $\mathcal{L}$ to user $k$, $k\in\mathcal{K}$.
\end{Th1}
\begin{proof}
Please refer to Appendix \ref{app_1} for detailed proof.
\end{proof}
Lemma \ref{Lemma1} indicates that instead of searching over the possible combinations of $\mathcal{A}$ and then optimizing according to the corresponding channel gain matrices $\{\mathbf{H}_{k,\mathcal{A}}\}$, (\ref{Primal Constraint 1})--(\ref{Primal Constraint 4}) can be solved based on the channel between the users and all RAP antennas, i.e., $\{\mathbf{H}_{k}\}$. However, the problem (\ref{P_l0}) is non-convex due to the existence of the $\ell_0$ norm, making it difficult to find the global optimal solution.
In compressive sensing theory, the $\ell_0$ norm is usually replaced by a $\ell_1$ norm, and sparse solution can be achieved. However, simply substituting $\|\bm\omega\|_0$ by $\|\bm\omega\|_1$ in (\ref{P_l0}) will not necessarily produce sparse solution in general, as $\|\bm\omega\|_1$ equals the sum power consumption instead of the number of non-zero entries. By replacing $\|\bm\omega\|_0$ by $\|\bm\omega\|_1$, the transmit power at all RAPs still tend to satisfy the power constraints with equality at the optimum, leading to a non-sparse solution. In this paper, we propose to solve (\ref{P_l0}) heuristically by iteratively relaxing the $\ell_0$ norm as a weighted $\ell_1$ norm. In particular, at the $t$-th iteration, {the $\ell_0$ norm $\|\bm\omega^{(t)}\|_0$ is approximated by}
\begin{equation}\label{l0 approx}
\|\bm \omega^{(t)}\|_0\approx \sum_{l=1}^L \beta_l^{(t)}\omega_l^{(t)},
\end{equation}
where $\beta_l^{(t)}=\frac{1}{\text{Tr}\{\mathbf{B}_l\sum_{k}\mathbf{S}_k^{(t-1)}\}+\epsilon}$, with $\epsilon>0$ denoting a small positive constant. (\ref{P_l0}) can be then reformulated as
\begin{equation}\label{P_l0_approx}
\begin{aligned}
&\text{maximize}&& \sum_{k\in\mathcal{K}}\log_2\det\left(\mathbf{I}_N+\frac{1}{\sigma^2}\mathbf{H}_{k}\mathbf{S}_{k}\mathbf{H}_{k}^{\dag}\right)-\text{Tr}\left\{\bm{\Psi}^{(t)}\sum_{k\in\mathcal{K}}{\mathbf{S}_k}\right\} &&\\
&\text{s.t.} && \text{Constraints in (\ref{P_l0})},
\end{aligned}
\end{equation}
where
\begin{equation}\label{Psi}
\bm{\Psi}^{(t)}=\eta\sum_{l}\beta_l^{(t)}\mathbf{B}_l.
\end{equation}
{By noting that the first item of the objective function, i.e., $\sum_{k\in\mathcal{K}}\log_2\det\left(\mathbf{I}+\frac{1}{\sigma^2}\mathbf{H}_{k}\mathbf{S}_{k}\mathbf{H}_{k}^{\dag}\right)$, is~concave with respect to $\mathbf{S}_k$, and the second item $\text{Tr}\left\{\bm{\Psi}^{(t)}\sum_{k\in\mathcal{K}}{\mathbf{S}_k}\right\}$ is affine with respect to $\mathbf{S}_k$, we can then conclude that (\ref{P_l0_approx}) is a convex optimization problem. The problem } can be solved by standard convex optimization techniques, e.g. interior point method \cite{Boyd2004}, which, however, is typically slow. In fact, by utilizing the structure of BD precoding, the problem can be efficiently solved by its Lagrangian dual.
\section{Reweighted \boldmath{$\ell_1$} Based Algorithm}\label{s3}
In this section, the algorithm to solve the group sparse linear precoding problem will be presented. To solve (\ref{P_l0_approx}), it is desirable to remove the set of ZF constraints in the first place. It has been proved in~\cite{Zhang2010} that the optimal solution for BD precoding with per-RAP constraint is given by
\begin{equation}\label{Sopt_form}
\mathbf{S}_k=\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag,
\end{equation}
where $\mathbf{Q}_k\succeq 0$. $\mathbf{\tilde{V}}_k$ is given from the singular value decomposition (SVD) of $\mathbf{G}_k=[\mathbf{H}_1^T,\cdots,\mathbf{H}_{k-1}^T,\mathbf{H}_{k}^T,\cdots,\mathbf{H}_{K}^T]^T$ as
\begin{equation}
\mathbf{G}_k=\mathbf{U}_k\bm{\Sigma}_k[\mathbf{V}_k,\mathbf{\tilde{V}}_k]^\dag,
\end{equation}
where $\mathbf{\tilde{V}}_k\in\mathbb{C}^{M\times (M-N(K-1))}$ is the last $M-N(K-1)$ columns of the right singular matrix of $\mathbf{G}_k$. It is easy to verify that $\mathbf{H}_j\mathbf{S}_k\mathbf{H}_j^{\dag}=\mathbf{0}$ for all $j\ne k$.
Therefore, by substituting (\ref{Sopt_form}) into (\ref{P_l0_approx}), the problem reduces to
\begin{equation}\label{P_l0_approx1}
\begin{aligned}
&\text{maximize}&& \sum_{k\in\mathcal{K}}\log_2\det\left(\mathbf{I}_N+\frac{1}{\sigma^2}\mathbf{H}_{k}\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\mathbf{H}_{k}^{\dag}\right)-\sum_{k\in\mathcal{K}}\text{Tr}\left\{\bm{\Psi}^{(t)}\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\right\} &&\\
&\text{s.t.} && \sum_k\text{Tr}\left\{\mathbf{B}_l\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\right\}\leq P_{l,\max} && \forall l\in\mathcal{L} \\
&&& \mathbf{Q}_{k}\succeq 0&& \forall k\in\mathcal{K}
\end{aligned}
\end{equation}
Note that (\ref{P_l0_approx1}) is a convex problem, its Lagrangian dual can be written as
\begin{align}
L\left(\{\mathbf{Q}_k\}_{k\in\mathcal{K}},\bm{\lambda}\right)&=\sum_{k\in\mathcal{K}}\log_2\det\left(\mathbf{I}_N+\frac{1}{\sigma^2}\mathbf{H}_{k}\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\mathbf{H}_{k}^{\dag}\right) \nonumber \\
&-\sum_{k\in\mathcal{K}}\text{Tr}\left\{\bm{\Psi}^{(t)}\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\right\} \\
&-\sum_{l}\lambda_l\left(\sum_k\text{Tr}\left\{\mathbf{B}_l\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\right\}-P_{l,\max}\right)\nonumber
\end{align}
where $\lambda_l\geq 0$ denoting the Lagrangian dual variables. The Lagrangian dual function can be given as
\begin{equation}
g(\bm{\lambda})=\max_{\mathbf{Q}_k\succeq 0, k\in\mathcal{K}} L\left(\{\mathbf{Q}_k\}_{k\in\mathcal{K}},\bm{\lambda}\right),
\end{equation}
where $\bm\lambda=[\lambda_1,\lambda_2,\cdots,\lambda_L]$. We can then obtain the Lagrangian dual problem of (\ref{P_l0_approx1}) as
\begin{equation}\label{P_dual}
\min_{\bm\lambda\geq\mathbf{0}} g(\bm{\lambda}).
\end{equation}
Since the problem (\ref{P_l0_approx1}) is convex and satisfies the Slater's condition, strong duality holds. The~respective primal and dual objective values in (\ref{P_l0_approx1}) and (\ref{P_dual}) must be equal at the global optimum, and the complementary slackness must hold at the optimum, i.e.,
\begin{equation}\label{com_slack}
\lambda_l^*\left(\sum_{k\in\mathcal{K}}\text{Tr}\left\{\mathbf{B}_l\mathbf{\tilde{V}}_k\mathbf{Q}^*_k\mathbf{\tilde{V}}_k^\dag\right\}-P_{l,\max}\right)=0,\;l=1,\cdots,L,
\end{equation}
where $\{\mathbf{Q}_k^*\}$ and $\{\lambda_l^*\}$ are the optimal primal and dual variables, respectively.
For fixed $\bm\lambda$, the Lagrangian dual function $g(\bm{\lambda})$ can be obtained by solving
\begin{equation} \label{fix_dual}
\max_{\mathbf{Q}_k\succeq 0} \sum_{k\in\mathcal{K}}\log_2\det\left(\mathbf{I}_N+\frac{1}{\sigma^2}\mathbf{H}_{k}\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\mathbf{H}_{k}^{\dag}\right)-\sum_k\text{Tr}\left\{\bm{\Omega}\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\right\} ,
\end{equation}
where $\bm{\Omega}=\bm{\Psi}^{(t)}+\sum_{l}{\lambda_l\mathbf{B}_l}$. {Appendix \ref{app_2} shows that the optimal $\mathbf{{Q}}_k^*$ can be obtained as
\begin{equation}\label{Q_opt}
\mathbf{{Q}}_k^*=\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}\mathbf{\tilde{V}}_k\right)^{-1/2}\mathbf{\hat{V}}_k^{\dag}\bm{\tilde{\Lambda}}_k\mathbf{\hat{V}}_k\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}\mathbf{\tilde{V}}_k\right)^{-1/2},
\end{equation}
where $\mathbf{\hat{V}}_k$ is obtained from the following reduced SVD:
\begin{equation}\label{svd1}
\mathbf{H}_{k}\mathbf{\tilde{V}}_k\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}\mathbf{\tilde{V}}_k\right)^{-1/2}=\mathbf{\hat{U}}_k\bm{\Xi}_k\mathbf{\hat{V}}_k^\dag.
\end{equation}
$\bm{\tilde{\Lambda}}_k=\text{diag}\{\tilde{\lambda}_{k,1},\cdots,\tilde{\lambda}_{k,N}\}$, with
\begin{equation}
\tilde{\lambda}_{k,n}=\left(\frac{1}{\ln 2}-\frac{\sigma^2}{\xi_{k,n}^2}\right)^+,
\end{equation}
where $x^+=\max (x,0)$.}
The optimal $\mathbf{S}_k^*$ for given $\bm{\lambda}$ can be then obtained as
\begin{equation}\label{Covariance}
\mathbf{S}_k^*(\bm\lambda)=\mathbf{\tilde{V}}_k\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}\mathbf{\tilde{V}}_k\right)^{-1/2}\mathbf{\hat{V}}_k^{\dag}\bm{\tilde{\Lambda}}_k\mathbf{\hat{V}}_k\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}\mathbf{\tilde{V}}_k\right)^{-1/2}\mathbf{\tilde{V}}_k^\dag
\end{equation}
With the optimal $\mathbf{S}_k^*(\bm\lambda)$ achieved for given $\bm{\lambda}$, we can then find the Lagrangian dual variables $\bm\lambda$ by the projected subgradient method. Projected subgradient methods following, e.g., the square summable but not summable step size rules, have been proven to converge to the optimal values \cite{Bertsekas2003}. In particular, a subgradient with respect to $\lambda_l$ is $P_{l,\max}-\sum_{k\in\mathcal{K}}\text{Tr}\left\{\mathbf{B}_l\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\right\}$. With a step size $\delta_t$, the~dual variables can be updated as
\begin{equation}\label{subgradient}
\lambda_l^{(t+1)}=\max\left\{\lambda_l^{(t)}-\delta_t \left(P_{l,\max}-\sum_{k\in\mathcal{K}}\text{Tr}\left\{\mathbf{B}_l\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\right\}\right),0\right\},\;\forall l=1,\cdots,L.
\end{equation}
From the complementary slackness in (\ref{com_slack}), a stopping criterion for updating (\ref{subgradient}) can be
\begin{equation}\label{com_slack_sum}
\sum_{l\in\mathcal{L}}|\lambda_l\sum_{k\in\mathcal{K}}\text{Tr}\left\{\mathbf{B}_l\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\right\}|^2<\varepsilon.
\end{equation}
Once the optimal $\bm{\lambda}^*$ is obtained, the optimal precoding matrices $\{\mathbf{T}_k^*\}$ can be achieved by using the fact that $\mathbf{S}_k=\mathbf{T}_k\mathbf{T}_k^{\dag}$ as
\begin{equation}
\mathbf{T}_k^*=\mathbf{\tilde{V}}_k\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}^*\mathbf{\tilde{V}}_k\right)^{-1/2}\mathbf{\hat{V}}_k^{\dag}\bm{\Lambda}_k^{1/2}.
\end{equation}
The optimal set $\mathcal{A}$ and the corresponding precoding matrices $\{\mathbf{T}_{k,\mathcal{A}}\}$ can be obtained from $\{\mathbf{T}_k^*\}$. The~algorithm is summarized as Algorithm \ref{Al1}.
\begin{algorithm}[H]
\caption{Reweighted $\ell_1$ Norm Based Sparse Precoding Design.}\label{Al1}
\textbf{Initilization:} Set iteration counter $t=1$, Lagrangian dual variable $\bm{\lambda}^{(0)}>0$, $l=1,\cdots,L$. \\
\textbf{Repeat:}
\begin{enumerate}
\item Calculate $\bm{\Psi}^{(t)}$ and $\mathbf{S}_k^{(t)}$, $k=1,\cdots, K$, according to (\ref{Psi}) and (\ref{Covariance}), respectively.
\item Update $\{\lambda_l\}$ according to (\ref{subgradient}).
\item Update the iteration counter {$t\leftarrow t+1$} and
\[
r=\sum_{l\in\mathcal{L}}|\lambda_l\sum_{k\in\mathcal{K}}\text{Tr}\left\{\mathbf{B}_l\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\right\}|^2.
\]
\end{enumerate}
\textbf{Stop} if $r<\varepsilon$, where $\varepsilon$ is a pre-defined tolerance threshold.
\label{alg_1}
\end{algorithm}
\section{Complexity Analysis}\label{s4}
{In this section, we provide our complexity analysis of Algorithm \ref{alg_1}. Note that $\mathbf{\tilde{V}}_k$ can be calculated before the iterations. The main complexity of the proposed algorithm lies in step 1 and step 2.}
{Let us first focus on step 1. According to \cite{Coppersmith1987}, the calculations of matrix multiplication $\mathbf{XY}$ and matrix inversion $\mathbf{Z}^{-1}$ have complexities on the orders of $O(mnp)$ and $O(m^{2.736})$, respectively, where~$\mathbf{X}\in\mathbb{C}^{m\times n}$, $\mathbf{Y}\in\mathbb{C}^{n\times p}$ and $\mathbf{Z}\in\mathbb{C}^{m\times m}$. Therefore, the complexity to calculate $\mathbf{H}_{k}\mathbf{\tilde{V}}_k\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}\mathbf{\tilde{V}}_k\right)^{-1/2}$ is on the order of $O\left((M-N(K-1))^{2.736}\right)$. On the other hand, as the complexity of the SVD in (\ref{svd1}) is on the order of $O\left(M(M-N(K-1))^2\right)$ \cite{Coppersmith1987}, the complexity to calculate $\mathbf{\hat{V}}_k$ is on the order of $O\left(M(M-N(K-1))^2\right)$. By considering that the matrix calculation in (\ref{Covariance}) has a complexity on the order of $O\left(M(M-N(K-1))^2\right)$, we can then conclude that the complexity of step 1 is on the order of $O\left(KM(M-N(K-1))^2\right)$.}
{In step 2, as $\sum_{k\in\mathcal{K}}\text{Tr}\left\{\mathbf{B}_l\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\right\}=\text{Tr}\left\{\mathbf{B}_l\sum_{k\in\mathcal{K}}\mathbf{S}_k\right\}$ and $\sum_{k\in\mathcal{K}}\mathbf{S}_k$ can be calculated before updating $\lambda_l$, step 2 has a complexity on the order of $O\left(LM^3\right)$. By noting that the number of RAPs is typically larger than the number of users, i.e., $L>K$, and that the total number of BS antennas $M=N_c L$, the overall complexity of the proposed algorithm is on the order of $O(t_{avg}N_c^3L^4)$, where $t_{avg}$ is the average number of iterations. As we will show in the following section, the algorithm is able to converge within 15 iterations for a properly selected step size and tolerance threshold.}
\section{Simulation Results}\label{s5}
In this section, simulation results are presented to illustrate the results in this paper. We assume that the channel gain matrices $\{\mathbf{H}_{k,l}\}$ from RAP $l$ to user $k$ are independent over $k$ and $l$ for all $l\in\mathcal{L}$ and $k\in\mathcal{K}$, and all entries of $\mathbf{H}_{k,l}$ are independent and identically distributed (iid) complex Gaussian random variables with zero mean and variance $\gamma_{k,l}^2$. The path-loss model from RAP $l$ to the user $k$ is
\begin{equation}
\text{PL}_{k,l}\text{(dB)}=128+37.6\log_{10}D_{k,l},
\end{equation}
$\forall l\in\mathcal{L}$ and $\forall k\in\mathcal{K}$, where $D_{k,l}$ is the distance between user $k$ and RAP $l$ in the unit of kilometer. The~large-scale fading coefficient from RAP $l$ to user $k$ can be then obtained as
\begin{equation}
\gamma_{k,l}^2=10^{-\text{PL}_{k,l}\text{(dB)}/10}.
\end{equation}
The transmit power constraint at each RAP are assumed to be identical, which is set to be $P_{l,\max}=-40$ dBm/Hz, $\forall l\in\mathcal{L}$, and the noise variance is set to be $\sigma^2=-162$ dBm/Hz.
We consider the case that $L=10$ RAPs with $N_c=2$ antennas each and $K=2$ users with $N=3$ antennas each. {The positions of users and RAPs are generated in a circular area with radius 1,000~km
following uniform distribution. An example of the randomly generated antenna and user layout is plotted in Figure~\ref{Fig_layout}. Figure~\ref{Fig_converge} shows the convergence behavior of the proposed algorithm under the layout given in Figure~\ref{Fig_layout} under different step size $\delta_t=0.5$, $0.1$ and $0.05$. As we can see from Figure~\ref{Fig_converge}, the~value of (\ref{com_slack_sum}) rapidly decreases with the number of iterations. When the step size is large, i.e., $\delta_t=0.5$, despite that the algorithm converges in general, the value increases after several iterations. Such observation comes from the fact that we use the reweighted $\ell_1$ norm to approximate the non-convex $\ell_0$ norm, and a large step in $\bm\lambda$ will generally leading to a significant change of $\bm\Psi$ in~(\ref{P_l0_approx1}). When the step size is smaller, $\bm\Psi$ changes moderately, and a monotonic decrease can be observed in Figure~\ref{Fig_converge} when $\delta_t=0.1$ and $0.05$.}
\begin{figure}[H]
\begin{center}
\includegraphics[width=.65\textwidth]{layout.pdf}
\vspace{-1\baselineskip}
\caption{{An example of a randomly generated} system configuration. The active RAPs at the converged state with $\eta=0.5$ are highlighted in red. }\label{Fig_layout}
\end{center}
\end{figure}
\begin{figure}[H]
\begin{center}
\includegraphics[width=.6\textwidth]{convergence1.pdf}
\vspace{-1\baselineskip}
\caption{{Convergence behavior of the proposed algorithm} under the antenna and user layout shown in Figure~\ref{Fig_layout} with randomly generated small-scale fading coefficients. $L=10$. $N_c=2$. $K=2$. $N=3$. $\eta=0.5$. }\label{Fig_converge}
\end{center}
\end{figure}
{Figure~\ref{Fig_active} shows how the number of active RAPs varies with iterations in the layout shown in Figure~\ref{Fig_converge} with step size $\delta_t=0.1$ and the tolerance threshold $\varepsilon=10^{-4}$, {where a RAP is said to be active if its transmit power $P_l\geq 10^{-5}P_{l,\max}$}. The tradeoff constant $\eta$ is set to be $0$, $0.1$ and $0.5$.} Figure~\ref{Fig_active} shows that the number of active RAPs $|\mathcal{A}|$ decreases with $\eta$. Specifically, with~$\eta=0$, the problem reduces to a BD precoder design with per-RAP constraint, and all RAPs are active. With $\eta=0.5$, the sparsest solution can be achieved, i.e., $|\mathcal{A}|=A_{\min}=\lceil\frac{KN}{N_c}\rceil=3$. We~should mention that the value of $\eta$ that corresponds to the sparsest solution varies with the system~configuration.
\begin{figure}[H]
\begin{center}
\includegraphics[width=.6\textwidth]{Fig2.eps}
\vspace{-1\baselineskip}
\caption{Number of active RAPs under the antenna and user layout shown in Figure~\ref{Fig_layout} with randomly generated small-scale fading coefficients. $L=10$. $N_c=2$. $K=2$. $N=3$. }\label{Fig_active}
\end{center}
\end{figure}
As Figure~\ref{Fig_active} shows, the first several iterations lead to the biggest improvement. As iterations go on, there is no further improvement after the 15th iteration. Compared to the full cooperation case, i.e., $\eta=0$, as $L-A_{\min}=7$ RAPs are switched off, 70\% of the circuit power consumption can be saved with, however, limited rate performance loss, which will be illustrated later in this section. Figure~\ref{Fig_bs}~plots the transmit power distribution over all 10 RAPs. {Intuitively, the RAPs that have the smaller access distances contribute most to the sum rate. As shown in Figures~\ref{Fig_layout} and \ref{Fig_bs}, RAP 1 and RAP 9, which are close to User 1, and RAP 7, which is close to User 2, are selected to be active, while all the other RAP's transmit power eventrally goes to zero after 15 iterations.}
\begin{figure}[H]
\begin{center}
\includegraphics[width=.7\textwidth]{BS_POWER.pdf}
\vspace{-1\baselineskip}
\caption{{Transmit power of the RAPs under the antenna} and user layout shown in Figure~\ref{Fig_layout} with randomly generated small-scale fading coefficients. $L=10$. $N_c=2$. $K=2$. $N=3$. $\eta=0.5$.}\label{Fig_bs}
\end{center}
\end{figure}
\begin{figure}[H]
\begin{center}
\includegraphics[width=.6\textwidth]{Fig4.eps}
\vspace{-1\baselineskip}
\caption{{Tradeoff between average sum rate and the number} of active RAPs. $L=10$. $K=2$. $N=3$.}\label{Fig_tradeoff}
\end{center}
\end{figure}
Figure~\ref{Fig_tradeoff} plots how the average sum rate varies with the number of active RAPs. The average sum rate is obtained by averaging over 20 realizations of small-scale fading and 30 realizations of the positions of RAPs and users. The results of the exhaustive search is also presented for comparison, which~is obtained by searching over all possible combinations of active RAPs, and computing its achievable sum rate by the algorithm given in \cite{Zhang2010}. For the proposed algorithm, we simulate a series of different $\eta$'s to get different points along the curve. As we can see from Figure~\ref{Fig_tradeoff}, our proposed algorithm achieves almost the same average sum rate as the exhaustive search, which verifies the optimality of our proposed algorithm. Figure~\ref{Fig_tradeoff} further plots the average sum rate with a fixed number of $|\mathcal{A}|$ instead of $L$ uniformly distributed antennas are deployed for comparison, which is denoted as ``Fixed $L$'' in Figure~\ref{Fig_tradeoff}. We can clearly see that the proposed algorithm can achieve much better rate performance over that with the same amount of transmit RAP. With six selected antennas, for instance, the group sparse precoder reduces the average sum rate for only 3 bit/s/Hz, whereas if only $6$ antennas were installed instead of $L=10$, an additional 9 bit/s/Hz rate loss can be observed compared to the proposed algorithm. Moreover, the rate gap between the proposed algorithm and that with a fixed number of $L=|\mathcal{A}|$ full cooperative RAPs further increases as the number of selected antennas $|\mathcal{A}|$ decreases. This highlights the importance of group sparse precoder design in C-RAN with a large number of distributed RAPs.
\section{Conclusions}\label{s6}
In this paper, we study the group sparse precoder design that maximizes the sum rate in a C-RAN. We show that the joint antenna selection and precoder design problem can be formulated into an $\ell_0$ norm problem, which is, however, combinatorial and NP-hard. Inspired by the theory of compressive sensing, we propose an approach that solves the problem via reweighted $\ell_1$ norm. Simulation results verify the optimality of our proposed algorithm in that it achieves almost the same performance as that obtained from the exhaustive search. Compared to full cooperation, the group sparse precoding can achieve a significant proportion of the maximum sum rate that was achieved from full cooperation with, however, much fewer active RAPs, which highlights the importance of employing group sparse precoding in C-RAN with ultra-dense RAPs.
Note that in practical system, the imperfect fronthaul links between the BBU pool and the RAPs further limits the performance. It is desirable to extend our approach to a practical scenario by including the fronthaul link capacity constraint. Moreover, inspired by \cite{Vu2016} which implemented the zero-forcing precoding {in a distributed manner, we would like to further extend our algorithm in a distributed way in our future work, as it enables the application of group sparse precoding in a large-scale C-RAN system.}
\appendices
\section{Proof of Lemma \ref{Lemma1}}\label{app_1}
Define the channel gain matrix and the precoding matrix between user $k$ and the antennas of RAP $l$ as $\mathbf{H}_{k,l}$ and $\mathbf{T}_{k,l}$, respectively, $\forall k\in\mathcal{K}$ and $\forall l\in\mathcal{L}$. Let us reorder the channel gain matrices $\mathbf{H}_k$ and the precoding matrices $\mathbf{T}_k$ as
\begin{equation}
\mathbf{\tilde{H}}_k=\left[[\mathbf{H}_{k,l}]_{l\in\mathcal{A}},[\mathbf{H}_{k,l}]_{l\not\in\mathcal{A}}\right],
\end{equation}
and
\begin{equation}
\mathbf{\tilde{T}}_k=\left[[\mathbf{T}_{k,l}^T]_{l\in\mathcal{A}},[\mathbf{T}_{k,l}^T]_{l\not\in\mathcal{A}}\right]^T,
\end{equation}
respectively. We have
\begin{align}\label{app hsh}
\mathbf{H}_j\mathbf{S}_k\mathbf{H}_j&=\mathbf{\tilde{H}}_k\mathbf{\tilde{T}}_k\mathbf{\tilde{T}}_k^\dag\mathbf{\tilde{H}}_k^\dag\nonumber \\
&\mathop{=}\limits^{(a)}\left(\sum_{l\in\mathcal{A}}\mathbf{H}_{k,l}\mathbf{T}_{k,l}\right)\left(\sum_{l\in\mathcal{A}}\mathbf{H}_{k,l}\mathbf{T}_{k,l}\right)^\dag \\
&=\mathbf{H}_{j,\mathcal{A}}\mathbf{S}_{k,\mathcal{A}}\mathbf{H}_{j,\mathcal{A}}^\dag, \nonumber
\end{align}
for all $j,k\in\mathcal{K}$, where (a) follows from the fact that $\mathbf{T}_{k,l}=\mathbf{0}$ if RAP $l$ is not active, i.e., $l\not\in \mathcal{A}$.
Let us then prove the positive semidefinite constraint. The reordered covariance matrix $\mathbf{S}_k$ can be written as
\begin{align}\label{app psd}
\mathbf{\hat{S}}_k&=\mathbf{\hat{T}}_k\mathbf{\hat{T}}_k^{\dag} \nonumber \\
&=\begin{bmatrix}
\mathbf{T}_{k,\mathcal{A}}\mathbf{T}_{k,\mathcal{A}}^\dag & \mathbf{T}_{k,\mathcal{A}}[\mathbf{T}_{k,l}]^\dag_{l\not\in\mathcal{A}} \\
[\mathbf{T}_{k,l}]_{l\not\in\mathcal{A}}\mathbf{T}_{k,\mathcal{A}}^\dag & [\mathbf{T}_{k,l}]_{l\not\in\mathcal{A}}[\mathbf{T}_{k,l}]^\dag_{l\not\in\mathcal{A}}\\
\end{bmatrix}
\\
&\mathop{=}\limits^{(b)}\begin{bmatrix}
\mathbf{T}_{k,\mathcal{A}}\mathbf{T}_{k,\mathcal{A}}^\dag & \mathbf{0} \\
\mathbf{0} & \mathbf{0} \\
\end{bmatrix},\nonumber
\end{align}
where (b) holds as $\mathbf{T}_{k,l}=\mathbf{0}$ for all $l\not\in\mathcal{A}$. By noting that $\mathbf{T}_{k,\mathcal{A}}\mathbf{T}_{k,\mathcal{A}}^\dag=\mathbf{S}_{k,\mathcal{A}}\succeq \mathbf{0}$, we immediately have $\mathbf{S}_k\succeq 0$. (\ref{P_l0}) can be then proved by combining (\ref{app hsh})--(\ref{app psd}) and (\ref{Primal Constraint 1})--(\ref{Primal Constraint 4}).
\section{Derivation of (\ref{Q_opt})}\label{app_2}
{
We can observe from (\ref{fix_dual}) that the problem is equivalent to solve $K$ uncoupled subproblems given~as
\begin{equation}\label{app_subproblem}
\max_{\mathbf{Q}_k\succeq 0} \log_2\det\left(\mathbf{I}_N+\frac{1}{\sigma^2}\mathbf{H}_{k}\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\mathbf{H}_{k}^{\dag}\right)-\text{Tr}\left\{\bm{\Omega}\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\right\} ,
\end{equation}
By noting that $\text{Tr}\{\mathbf{X}\mathbf{Y}\}=\text{Tr}\{\mathbf{Y}\mathbf{X}\}$, we have
\begin{equation}
\text{Tr}\left\{\bm{\Omega}\mathbf{\tilde{V}}_k\mathbf{Q}_k\mathbf{\tilde{V}}_k^\dag\right\}=\text{Tr}\left\{\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}\mathbf{\tilde{V}}_k\right)^{1/2}\mathbf{Q}_k\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}\mathbf{\tilde{V}}_k\right)^{1/2}\right\}.
\end{equation}
Let us define
\begin{equation}\label{app_qtilde_def}
\mathbf{\tilde{Q}}_k=\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}\mathbf{\tilde{V}}_k\right)^{1/2}\mathbf{Q}_k\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}\mathbf{\tilde{V}}_k\right)^{1/2}.
\end{equation}
(\ref{app_subproblem}) can be written as
\begin{equation}\label{fix_dual 1}
\max_{\mathbf{\tilde{Q}}_k\succeq 0} \log_2\det\left(\mathbf{I}_N+\frac{1}{\sigma^2}\mathbf{H}_{k}\mathbf{\tilde{V}}_k\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}\mathbf{\tilde{V}}_k\right)^{-1/2}\mathbf{\tilde{Q}}_k\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}\mathbf{\tilde{V}}_k\right)^{-1/2}\mathbf{\tilde{V}}_k^\dag\mathbf{H}_{k}^{\dag}\right)
-\text{Tr}\left\{\mathbf{\tilde{Q}}_k\right\}.
\end{equation}
(\ref{fix_dual 1}) can be solved from standard waterfilling algorithm \cite{Cover2006}. In particular, by introducing the (reduced) SVD:
\begin{equation}
\mathbf{H}_{k}\mathbf{\tilde{V}}_k\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}\mathbf{\tilde{V}}_k\right)^{-1/2}=\mathbf{\hat{U}}_k\bm{\Xi}_k\mathbf{\hat{V}}_k^\dag,
\end{equation}
where $\mathbf{\hat{U}}_k\in\mathbb{C}^{N\times N}$ and $\mathbf{\hat{V}}_k\in\mathbb{C}^{N\times N}$ are unitary matrices. $\bm{\Xi}_k=\text{diag}\{\xi_{k,1},\dots,\xi_{k,N}\}$, with $\xi_{k,n}$ denoting the $n$-th singular value of $\mathbf{H}_{k}\mathbf{\tilde{V}}_k\left(\mathbf{\tilde{V}}_k^\dag\bm{\Omega}\mathbf{\tilde{V}}_k\right)^{-1/2}$.
The optimal $\mathbf{\tilde{Q}}_k$ can be then obtained as:
\begin{equation}\label{Qtilde}
\mathbf{\tilde{Q}}_k^*=\mathbf{\hat{V}}_k^{\dag}\bm{\tilde{\Lambda}}_k\mathbf{\hat{V}}_k,
\end{equation}
where $\bm{\tilde{\Lambda}}_k=\text{diag}\{\tilde{\lambda}_{k,1},\cdots,\tilde{\lambda}_{k,N}\}$, with
\begin{equation}
\tilde{\lambda}_{k,n}=\left(\frac{1}{\ln 2}-\frac{\sigma^2}{\xi_{k,n}^2}\right)^+,
\end{equation}
where $x^+=\max(x,0)$.
}
{(\ref{Q_opt}) can be then obtained by combining (\ref{Qtilde}) and (\ref{app_qtilde_def}).}
| {'timestamp': '2018-02-27T02:04:03', 'yymm': '1706', 'arxiv_id': '1706.01642', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01642'} | arxiv |
\section{Introduction}
\label{sec1}
Last few years have witnessed a massive growth in consumer interest in smart devices [1]. These include smartphones, smart TVs, and recently smartwatches. Because of their increased penetration, smartwatches have claimed a handsome market share. A typical smartwatch contains a heart rate monitor, GPS, thermometer, camera and accelerometer. Thus, it can provide a variety of services. These services include temperature and pulse measurements and the number of calories consumed when performing a physical activity, such as walking, running, cycling and so forth [2].
Recently, smartwatches have emerged in our daily lives and like their smartphone counterparts, smartwatches do contain a gyroscope, magnetometer and accelerometer sensors to support similar capabilities and applications. These applications include health applications i.e. calories consumption that require sensor based physical activity recognition. A number of calories consumed during physical activities vary from one activity to another. Therefore, the first thing to do when estimating the number of calories consumed, is to first recognize which activity have been performed [3].
This work explores the idea of physical activity recognition on smartwatches using the embedded gyroscope, magnetometer and accelerometer sensors. The gyroscope, magnetometer and accelerometer sensors are ideal for physical activity recognition. We further discussed the detailed analysis of various feature banks and classification methods to seek the best settings for optimum performance on two different types of models such as impersonal and personal model over the smartwatch. Personal models referred as the classifier is built using the data only form one specific user whereas the impersonal model referred as the classifier is built using the data form every user except the one under study. To summarize, the main contributions of this work is towards answering the following questions:
\begin{enumerate}
\item Existing smartphone-based physical activity recognition studies have a number of features that were utilized for smartphone-based physical activity recognition; can they be used for smartwatch-based physical activity recognition as well?
\item Which of the most commonly used classifiers from the reference field provides the best recognition accuracy?
\item Does features permutation help to improve the accuracy?
\item Does features normalization help to improve the performance of the classifier?
\item Which model (Personal or Impersonal) works better for smartwatch-based physical activity recognition?
\item Does changing the window size affect the recognition accuracy?
\end{enumerate}
Physical activity recognition in general using motion sensors especially using smartphones has been studied in recent years [4-6] and currently being studied extensively [7-8] but there are a few studies on physical activity recognition using smartwatches [9-18] in which the authors studied the role of the smartwatch in physical activity recognition system for health recommendation purposes.
For instance, Guiry et al. [9] proposed physical activity recognition system to recognize nine different activities using five different classifiers. These activities include walking, standing, cycling, running, stair ascent, stair descent, elevator ascent and descent. However, the authors studied smartphone and smartwatch based activity recognition separately and did not combine the data from both devices. Furthermore, for real-time data collection, the author's used magnetometer, accelerometer and gyroscope sensors for smartphone and accelerometer for a smartwatch. Trost et al. [10] used sensors on hip and wrist to detect physical activities using logistic regression based classification method. In [10], Trost et al. just focused on showing the potential of using the wrist position for physical activity recognition for health recommendation system. Chernbumroong et al. [11] used a single wrist-worn accelerometer to detect five different physical activities for recommendation system. These activities include standing, sitting, lying, running and walking. However, Da-Silva et al. [12] used the same sensor to detect the eight different physical activities for recommendation system. In addition to the activities identified in [11] Da-Silva et al. include the activity of working on a computer too. The works [13] and [14] detect the eating activity using a Hidden Markov Model (HMM) with a wrist-worn accelerometer and gyroscope sensors. Ramos-Garcia identifies the eating activity by dividing it into further sub-activities in [13] which includes resting, drinking, eating, using utensil and others. Meanwhile, Dong et al. [14] proposed to differentiate eating periods from non-eating periods to identify the eating and not-eating activity. Sen et al. [15] used both accelerometer and gyroscope sensor data to recognize the eating and non-eating activities. Furthermore, the authors used smartwatch camera to take images of the food being consumed to analyze what a user is eating.
School et al. [16] presented a feasibility study to detect and identify the smoking activity using accelerometer sensor where School et al. only reported a user-specific accuracy for smoking activity. Whereas, A. Parade et al. [17] used both accelerometer, magnetometer and gyroscope sensors to recognize smoking puffs where they just try to distinguished smoking activity from other activities. A similar work has been reported in [18] where the the authors used support vector machine (SVM) to recognize six different physical activities. These activities include standing, walking, writing, jacks, smoking and jogging. Kim et al. [19] proposed the collaborative classification approach for recognizing daily activities using smartwatches. The authors exploit a single off-the-shelf smartwatch to recognize five daily activities; namely eating, watching TV, sleeping, vacuuming and showering. For fair comparisons Kim et al. suggested using single and multiple sensors-based approaches to compare with their proposed approach with the overall accuracy of 91.5\% with the improved recall rate up to 21.5\% for each activity. Weiss et al. showed that accelerometers and gyroscopes sensors that sense user's movements and can help identify the user activity [20]. Weiss et al. propose to compare the smartphone and smartwatch-based user activity recognition in which smartwatch have the ability to recognize hand-based activities namely eating which is not possible through a smartphone. They showed that the smartwatch is able to recognize the drinking activity with 93.3\% accuracy while smartphones achieve only 77.3\%.
Nurwanto et al. [21] proposed a daily life light sport exercise activities. These activities include squat jump, push up, sit up and walking. Nurwanto et al. focuses only on accelerometer-based signal captured by left-handed persons and the obtained signals were processed through sliding window approach with the k-nearest neighbor method and dynamic time warping as the main classifier. Furthermore, Nurwanto et al. proved that k-NN together with dynamic time warping method is an efficient method for daily exercise recognition with the accuracy of 76.67\% for push up 96.69\% for squat jump and 80\% for sit up activity. They intentionally exclude the walking activity for their experimental process because of the random patterns. Al-Naffakh et al. [22] proposed the usefulness of using smartwatch motion sensor namely gyroscope and accelerometer to perform user activity recognition. Al-Naffakh et al. proved the natures of the signals captured are sufficiently discriminative to be useful in performing activity recognition.
Different activities can be recognized using motion sensors at the wrist position i.e. drinking, eating, smoking, walking, walking down stairs, walking up stairs, running, jogging, elevator up, elevator down, doing regular exercises, writing etc. However there is no study that discusses these activities all together with the recommendations of optimum system settings. Therefore, to extend the existing works, we evaluate the combination of different feature banks and classification techniques for the reliable recognition of various activities. We also evaluate three different built-in motion sensors. Moreover, unlike the current trends, we also evaluate the effect of window size on each activity performed by the individual user and its impact on the recognition performance of simple and complex activities. Although the effect of window size on physical activity recognition has been studied by Huynh et al. in [23] but the windowing effect on complex activities is yet not fully explored. Moreover, unlike the recent works, we explore the use of both \textit{Personal} and \textit{Impersonal} models individually for each activity.
\begin{enumerate}
\item Personal model means the classifier is trained using the data only from one specific individual whereas, the Impersonal model means the classifier is built using the data from every user except the one under study.
\item For both models, one subject cross-validation process is adopted.
\item Finally, our study suggests the optimum system settings for any activity recognition system based on smartwatches.
\end{enumerate}
This work analyzes the effects of combining gyroscope, magnetometer and accelerometer sensors data for physical activity recognition for different size of windows varying from one second to 12 seconds long window. We further analyze the effect of various sampling rates on the recognition performance in different scenarios. However, in our current study, we still have room for further improvement. For example, our current dataset is not balanced (as shown in Fig. 1) for all performed activities which might lead to the biased results towards majority classes. To handle the said problem to some extent, we used one subject cross-validation process for different models (personal and impersonal) which somehow overcome the class imbalance issue. This study also overcomes the limitations of overlapping while segmenting the raw data which forcefully improve the recognition performance because this overlap cause using some part of data in both training and testing which limiting the use of such techniques in a real-time environment. Moreover, we proposed and suggest some methods which helps to improve the recognition performance for those activities that have low recognition performance.
\begin{figure}[!ht]
\centering
\includegraphics[scale=0.22]{Fig1.eps}
\includegraphics[scale=0.22]{Fig2.eps}
\includegraphics[scale=0.22]{Fig3.eps} \linebreak
\includegraphics[scale=0.22]{Fig4.eps}
\includegraphics[scale=0.22]{Fig5.eps}
\caption{Raw Signal for individual activity.}
\end{figure}
The rest of the paper has the following organization. Section 2 describes the material and methods. Section 3 contains experimental settings. Section 4 presents the experimental results and discussion and finally section 5 concludes the paper with possible future directions.
\section{Materials and Methods}
\label{sec2}
Today's smartwatches are equipped with a variety of motion sensors that are useful for monitoring device movements like tilt, rotate and shake. Some of these sensors are the ambient light sensor, accelerometer, compass, gyroscope and GPS sensors. For experimental study we only collected the raw signals using three different sensors such as accelerometer, magnetometer and gyroscope sensor.
\subsection{Data Collection}
\label{sec3}
We collected the raw signals for five different activities from six users (three female and three male) having a mean age of twenty-five years old. The criterion for selecting the subjects is based on the gender because different genders exhibit different patterns when performing the same activity. These activities include walking, walking upstairs, walking downstairs, running and jogging. All subjects performed these activities twice on each day for more than a month. Therefore we collected raw data from the same user for same activity but performed on different days.
The participants enrolled in our study are approved by the laboratory head because this is a formal prerequisite because our experiments involved human subjects and there is a negligible risk of injury. The involved subjects then asked to answer few nontechnical questions like gender, age, height, weight, left or right handed etc, which we used to characterize our study. Then the subjects were asked to fastens the smartwatch on their wrist and places a Bluetooth paired smartphone in their pocket. Both devices run a simple custom designed application that controls the data collection process and instructs the participant to first add their name and then select the activity from the list of five different activities and the sensor from three different sensors. Once the initial instructions were done, turn the smartphone screen off and place the smartphone into the pants pocket. The smartphone instructs the smartwatch running our paired data collection application to collect the raw signal at the 20Hz rate. Each of these sensors generates 3-dimensional signals and appends a time-stamp to the values. Every after five minutes the smartwatch sends the data to the smartphone and after a successful transmission, the smartphone vibrate to notify the user that the data collection process is successfully completed and they can stop the current activity.
\subsection{Feature Extraction}
\label{sec4}
The embedded sensor generates three-dimensional time series signals which are highly fluctuating and oscillatory in nature. The oscillation and fluctuations make the physical activity recognition more difficult than other applications in nature. These raw signals are shown in Fig. 1 for individual activity performed by the single user. Therefore, it is compulsory to gather the nontrivial signals from raw data through a feature extraction process. The raw signals are divided into several equal sized windows to control the flow rate and pass fewer data to the system to extract the meaningful information. In [24] Khan et al. have presented a detailed analysis of using different kinds of features with a different number of samples per windows for smartphone-based physical activity recognition.
From these raw signals, the extracted features are divided into two different feature banks. First feature bank include the features obtained by taking; average, median, variance, standard deviation, interquartile, autocorrelation, partial autocorrelation, coefficients of autoregressive model, coefficients of moving average model, coefficients of autoregressive moving average model and wavelet coefficients. Second feature bank includes the features obtained by taking; average acceleration, average absolute difference, standard deviation, average resultant acceleration and the average difference between peaks. We also calculate the binned distribution in which we determine what fraction of reading fall in a 10 equal-sized bins. This function generates 10 features. Every feature except average resultant acceleration is extracted for each axis.
These features are extracted from each axis of the three-dimensional acceleration signal and in total for each window of acceleration data 43 (first-feature-bank) and 70 (second-feature-bank) features are extracted respectively. Prior to the feature extraction process moving average filter of order three is used for noise reduction.
\subsection{Classifiers}
\label{sec5}
Khan et al. and Saputri et al. showed that support vector machines (SVM) and artificial neural networks (ANN) are superior to other traditional classification methods for user-independent physical activity recognition system in [24-26]. K-nearest neighbor (KNN) is also one of the most popular classification method used for smartphone-based physical activity recognition and user identification [27]. ELM [28], Naive Bayes [29], Adaptive learning/Ensemble learning (BAG) [30] and Decision tree [31] classifiers are also famous for smartphone-based physical activity recognition system. All these classification methods have shown several advantages in several fields most probably in their respective domains. Once again, given that ours is an exploratory study and the fact that each of these classifiers has shown a good performance in their respective studies. Instead of choosing one we decided to explore the use of all of these classifiers except neural networks in this work.
\section{Experimental Settings}
\label{sec6}
The following experimental studies are performed using all the data to create both personal and impersonal models. In our first study, using a fixed size of 75 samples per window the performance of five classifiers are compared to the following three cases on both feature banks and for both personal and impersonal models:
\begin{itemize}
\item Randomly permuted features with normalization.
\item Without random permutation and normalization.
\item Randomly permuted features without normalization.
\end{itemize}
In the second study, the best setting for each classifier is chosen and tested multiple times while changing the number of samples in a window \textit{i.e. \{25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300\}} samples. The goal is to measure the effect of changing the window size on the performance of each classifier for both personal and impersonal model respectively. In our both studies, the training and testing data is randomly divided and classification results are obtained using 10-fold cross-validation process. The values used for different parameters of classifiers are as follows where all these parameters are carefully tuned and optimized.
\begin{itemize}
\item SVM with quadratic kernel function is used.
\item KNN with Euclidean distance is used and K is set to 10.
\item Adaptive Learning: Ensemble model (BAG) with tree model and the number of weak classifiers are set to 50.
\item Decision Tree: The numbers of trees are set to 85.
\end{itemize}
\section{Experimental Results and Discussion}
\label{sec7}
This section contains the obtained results for smartwatch-based physical activity recognition system. To validate our system we conduct different experiments. Our first experiment is for both personal and impersonal model-based physical activity recognition analyses. In this experiment, we conduct a detailed comparison of two different feature banks and five classifiers for both personal and impersonal models. Our second experiment explains the physical activity recognition process behavior with a different number of samples per window within the best settings obtained in our first experiment. Finally, the third experiment presents the single subject cross-validation recognition for each activity for both personal and impersonal models individually. All these experiments are based on 10-fold cross-validation process and all these experiments are carried out using Matlab R2014b installed on core i5 and 8GB of RAM machine.
In the introduction section; we stated some important research questions which our explanatory study seeks to provide the basis of answers. The answers to those questions based on the obtained results are as follows: Based on our findings, yes the features used in existing smartphone-based physical activity recognition studies can also be used for the smartwatch-based physical activity recognition. If we consider normalized and random permutation feature space, classifiers perform much better opposed to the case of without normalization and random permutation in several cases. Table I-IV present the 98\% confidence intervals about overall physical activity recognition rate. Using pairwise T-tests between groups of normalized/randomly permuted and unnormalized/non-permuted data at the 98\% confidence level.
\begin{table*}[!ht]
\caption{Overall Classification Accuracy and Confidence Interval for \textbf{Impersonal Model} with \textbf{43 Features} extracted using \textbf{75 samples per window}. Where \textit{NR = Normalized, UNR = Unnormalized, RP = Randomly~Permuted, and NRP = Non~Randomly~Permuted}.}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c| c c c| c c c| c c c| c c c l}
\hline \hline
\multicolumn{1}{c}{\bf Classifiers} & \multicolumn{3}{c}{\bf Walking} & \multicolumn{3}{c}{\bf Walking Up-Stairs} & \multicolumn{3}{c}{\bf Walking Down-Stairs} & \multicolumn{3}{c}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline
\bf Decision \\ \bf Tree & \bf 0.90\(\pm\)0.08 &0.89\(\pm\)0.09 &0.41\(\pm\)0.26 & \bf 0.90\(\pm\)0.07 & \bf 0.90\(\pm\)0.09 &0.46\(\pm\)0.20 &0.87\(\pm\)0.12 &0.87\(\pm\)0.12 &0.60\(\pm\)0.13 &0.82\(\pm\)0.18 &0.82\(\pm\)0.18 &0.61\(\pm\)0.15 & \bf 0.93\(\pm\)0.06 & \bf 0.94\(\pm\)0.06 &0.85\(\pm\)0.10 \\ \hline
\bf Naive \\ \bf Bayes & \bf 0.86\(\pm\)0.06 & \bf 0.86\(\pm\)0.06& 0.63\(\pm\)0.18& 0.78\(\pm\)0.12& 0.78\(\pm\)0.12& 0.36\(\pm\)0.15& 0.76\(\pm\)0.16& 0.76\(\pm\)0.16& 0.42\(\pm\)0.11& 0.55\(\pm\)0.18& 0.55\(\pm\)0.18& 0.59\(\pm\)0.17& \bf 0.86\(\pm\)0.02& \bf 0.86\(\pm\)0.02& \bf 0.86\(\pm\)0.04 \\ \hline \\
\bf KNN & \bf 0.86\(\pm\)0.08& \bf 0.86\(\pm\)0.08& 0.71\(\pm\)0.08& 0.62\(\pm\)0.07& 0.62\(\pm\)0.07 &0.18\(\pm\)0.07& 0.70\(\pm\)0.13& 0.70\(\pm\)0.13& 0.38\(\pm\)0.12& 0.61\(\pm\)0.17& 0.61\(\pm\)0.17& 0.56\(\pm\)0.13& \bf 0.91\(\pm\)0.06& \bf 0.91\(\pm\)0.06& \bf 0.88\(\pm\)0.04 \\ \hline \\
\bf SVM &\bf 0.94\(\pm\)0.07& \bf 0.94\(\pm\)0.06& 0.65\(\pm\)0.32& \bf 0.91\(\pm\)0.04& \bf 0.91\(\pm\)0.04& 0.25\(\pm\)0.27& 0.81\(\pm\)0.10& 0.81\(\pm\)0.10& 0.43\(\pm\)0.20& 0.76\(\pm\)0.13& 0.76\(\pm\)0.13& 0.55\(\pm\)0.16& \bf 0.92\(\pm\)0.03& \bf 0.92\(\pm\)0.03& \bf 0.88\(\pm\)0.05 \\ \hline \\
\bf BAG &\bf 0.91\(\pm\)0.08& \bf 0.90\(\pm\)0.08& 0.43\(\pm\)0.24& \bf 0.89\(\pm\)0.09& \bf 0.89\(\pm\)0.09 & 0.42\(\pm\)0.19 & \bf 0.87\(\pm\)0.12& \bf 0.87\(\pm\)0.12 & 0.60\(\pm\)0.13& 0.81\(\pm\)0.18 & 0.81\(\pm\)0.18 & 0.60\(\pm\)0.16 & \bf 0.94\(\pm\)0.05 & \bf 0.93\(\pm\)0.06 & \bf 0.85\(\pm\)0.09 \\ \hline
\end{tabular}}
\end{table*}
\begin{table*}[!ht]
\caption{Overall Classification Accuracy and Confidence Interval for \textbf{Personal Model} with \textbf{43 Features} extracted using \textbf{75 samples per window}}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c| c c c| c c c| c c c| c c c l}
\hline \hline
\multicolumn{1}{c}{\bf Classifiers} & \multicolumn{3}{c}{\bf Walking} & \multicolumn{3}{c}{\bf Walking Up-Stairs} & \multicolumn{3}{c}{\bf Walking Down-Stairs} & \multicolumn{3}{c}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline
\bf Decision \\ \bf Tree & \bf 0.98\(\pm\)0.01& 0.88\(\pm\)0.09& \bf 0.94\(\pm\)0.01& \bf 0.93\(\pm\)0.02& 0.78\(\pm\)0.06& 0.69\(\pm\)0.10& \bf 0.98\(\pm\)0.05& 0.75\(\pm\)0.03& 0.75\(\pm\)0.07& \bf 0.95\(\pm\)0.01& 0.95\(\pm\)0.01& 0.78\(\pm\)0.09& \bf 0.98\(\pm\)0.01& \bf 0.95\(\pm\)0.06& \bf 0.94\(\pm\)0.01 \\ \hline \\
\bf Naive & \bf 0.91\(\pm\)0.02& 0.72\(\pm\)0.02& \bf 0.87\(\pm\)0.08& 0.77\(\pm\)0.11& 0.61\(\pm\)0.09& 0.55\(\pm\)0.07& 0.81\(\pm\)0.07& 0.60\(\pm\)0.08& 0.64\(\pm\)0.12& 0.61\(\pm\)0.19& 0.67\(\pm\)0.13& 0.65\(\pm\)0.07& \bf 0.87\(\pm\)0.08& 0.73\(\pm\)0.07& \bf 0.87\(\pm\)0.06 \\ \hline \\
\bf KNN & \bf 0.92\(\pm\)0.07& 0.79\(\pm\)0.07& 0.87\(\pm\)0.07& 0.64\(\pm\)0.09& 0.45\(\pm\)0.11& 0.22\(\pm\)0.05& 0.62\(\pm\)0.12& 0.53\(\pm\)0.10& 0.44\(\pm\)0.10& 0.77\(\pm\)0.07& 0.72\(\pm\)0.12& 0.71\(\pm\)0.08& \bf 0.91\(\pm\)0.08& \bf 0.88\(\pm\)0.09& \bf 0.92\(\pm\)0.03 \\ \hline \\
\bf SVM & \bf 0.93\(\pm\)0.07& 0.76\(\pm\)0.01& \bf 0.93\(\pm\)0.01& 0.79\(\pm\)0.09& 0.74\(\pm\)0.07& 0.56\(\pm\)0.16& \bf 0.90\(\pm\)0.03& 0.68\(\pm\)0.04& 0.6\(\pm\)0.10& \bf 0.87\(\pm\)0.06& \bf 0.83\(\pm\)0.09& 0.74\(\pm\)0.07& \bf 0.97\(\pm\)0.01& \bf 0.94\(\pm\)0.06& \bf 0.94\(\pm\)0.01\\ \hline \\
\bf BAG & \bf 0.98\(\pm\)0.01& \bf 0.88\(\pm\)0.09& \bf 0.87\(\pm\)0.09& 0.85\(\pm\)0.09& 0.80\(\pm\)0.08& 0.66\(\pm\)0.06& \bf 0.89\(\pm\)0.07& 0.75\(\pm\)0.04& 0.72\(\pm\)0.09& \bf 0.95\(\pm\)0.02& \bf 0.95\(\pm\)0.02& 0.72\(\pm\)0.10& \bf 0.99\(\pm\)0.01& \bf 0.92\(\pm\)0.08& \bf 0.94\(\pm\)0.01 \\ \hline \end{tabular}}
\end{table*}
\begin{table*}[!ht]
\caption{Overall Classification Accuracy and Confidence Interval for \textbf{Personal Model} with \textbf{70 Features} extracted using \textbf{75 samples per window}}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c| c c c| c c c| c c c| c c c l}
\hline \hline
\multicolumn{1}{c}{\bf Classifiers} & \multicolumn{3}{c}{\bf Walking} & \multicolumn{3}{c}{\bf Walking Up-Stairs} & \multicolumn{3}{c}{\bf Walking Down-Stairs} & \multicolumn{3}{c}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline
\bf Decision \\ \bf Tree &\bf 0.98\(\pm\)0.01& \bf 0.87\(\pm\)0.09& \bf 0.90\(\pm\)0.08& 0.84\(\pm\)0.09& 0.67\(\pm\)0.04& 0.62\(\pm\)0.13& 0.79\(\pm\)0.11& 0.74\(\pm\)0.12& 0.74\(\pm\)0.04& \bf 0.86\(\pm\)0.07& \bf 0.87\(\pm\)0.06& 0.72\(\pm\)0.07& \bf 0.97\(\pm\)0.01& \bf 0.94\(\pm\)0.07& \bf 0.93\(\pm\)0.01 \\ \hline \\
\bf Naive & \bf 0.88\(\pm\)0.02& 0.75\(\pm\)0.08& 0.77\(\pm\)0.09& 0.65\(\pm\)0.16& 0.51\(\pm\)0.10& 0.53\(\pm\)0.12& 0.62\(\pm\)0.15& 0.47\(\pm\)0.09& 0.60\(\pm\)0.08& 0.58\(\pm\)0.12& 0.55\(\pm\)0.06&
0.65\(\pm\)0.14& \bf 0.88\(\pm\)0.02& 0.68\(\pm\)0.02& 0.83\(\pm\)0.07 \\ \hline \\
\bf KNN &\bf 0.96\(\pm\) 0.01& \bf 0.93\(\pm\) 0.07& 0.79\(\pm\) 0.09& 0.60\(\pm\) 0.10& 0.46\(\pm\) 0.08& 0.19\(\pm\) 0.11& 0.49\(\pm\) 0.16& 0.46\(\pm\) 0.10& 0.17\(\pm\) 0.06& 0.58±\(\pm\) 0.14& 0.59\(\pm\) 0.16& 0.26\(\pm\) 0.14& \bf 0.95\(\pm\) 0.02& \bf 0.95\(\pm\) 0.02& \bf 0.90\(\pm\) 0.02 \\ \hline \\
\bf SVM &0.98\(\pm\)0.01&0.91\(\pm\)0.08&0.87\(\pm\)0.07&0.89\(\pm\)0.08&0.77\(\pm\)0.08&0.52\(\pm\)0.07&0.86\(\pm\)0.08&0.76\(\pm\)0.08&0.54\(\pm\)0.08&0.91\(\pm\)0.02&0.85\(\pm\)0.09&
0.66\(\pm\)0.09&0.97\(\pm\)0.01&0.90\(\pm\)0.10&0.92\(\pm\)0.01\\ \hline \\
\bf BAG &\bf 0.97\(\pm\)0.01& \bf 0.87\(\pm\)0.09& \bf 0.90\(\pm\)0.07& \bf0.86\(\pm\)0.07& 0.69\(\pm\)0.04& 0.68\(\pm\)0.10& 0.84\(\pm\)0.05& 0.65\(\pm\)0.09& 0.65\(\pm\)0.06& \bf 0.90\(\pm\)0.03& \bf 0.86\(\pm\)0.05& 0.72\(\pm\)0.08& \bf 0.97\(\pm\)0.01& \bf 0.87\(\pm\)0.10& \bf 0.91\(\pm\)0.07 \\ \hline
\end{tabular}}
\end{table*}
\begin{table*}[!ht]
\caption{Overall Classification Accuracy and Confidence Interval for \textbf{Impersonal Model} with \textbf{70 Features} extracted using \textbf{75 samples per window}.}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c| c c c| c c c| c c c| c c c l}
\hline \hline
\multicolumn{1}{c}{\bf Classifiers} & \multicolumn{3}{c}{\bf Walking} & \multicolumn{3}{c}{\bf Walking Up-Stairs} & \multicolumn{3}{c}{\bf Walking Down-Stairs} & \multicolumn{3}{c}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline
\bf Decision \\ \bf Tree &\bf 0.91\(\pm\)0.07&\bf 0.91\(\pm\)0.07& 0.50\(\pm\)0.21& 0.82\(\pm\)0.09& 0.81\(\pm\)0.09& 0.45\(\pm\)0.19& 0.64\(\pm\)0.12& 0.64\(\pm\)0.12& 0.57\(\pm\)0.10& 0.62\(\pm\)0.21& 0.63\(\pm\)0.21& 0.54\(\pm\)0.18& \bf 0.86\(\pm\)0.07& \bf 0.86\(\pm\)0.07& \bf 0.85\(\pm\)0.094 \\ \hline \\
\bf Naive &0.76\(\pm\)0.09& 0.73\(\pm\)0.08& 0.39\(\pm\)0.11& 0.54\(\pm\)0.08& 0.14\(\pm\)0.03& 0.50\(\pm\)0.07& 0.53\(\pm\)0.11& 0.13\(\pm\)0.03& 0.46\(\pm\)0.07& 0.42\(\pm\)0.10& 0.16\(\pm\)0.07& 0.54\(\pm\)0.17& 0.81\(\pm\)0.05& 0.80\(\pm\)0.11& 0.80\(\pm\)0.08 \\ \hline \\
\bf KNN &\bf 0.89\(\pm\)0.05& \bf 0.89\(\pm\)0.05& 0.73\(\pm\)0.08& 0.54\(\pm\)0.08& 0.54\(\pm\)0.08& 0.14\(\pm\)0.03& 0.42\(\pm\)0.13& 0.42\(\pm\)0.13& 0.13\(\pm\)0.03& 0.31\(\pm\)0.11& 0.31\(\pm\)0.11& 0.16\(\pm\)0.07& \bf 0.86\(\pm\)0.06& \bf 0.88\(\pm\)0.09& 0.80\(\pm\)0.11 \\ \hline \\
\bf SVM &\bf 0.97\(\pm\)0.02& \bf 0.97\(\pm\)0.02& 0.84\(\pm\)0.12& \bf 0.90\(\pm\)0.04& \bf 0.90\(\pm\)0.04& 0.12\(\pm\)0.07& 0.82\(\pm\)0.06& 0.82\(\pm\)0.06& 0.50\(\pm\)0.1& 0.80\(\pm\)0.09& 0.80\(\pm\)0.09& 0.60\(\pm\)0.06& \bf 0.94\(\pm\)0.03& \bf 0.94\(\pm\)0.03& \bf 0.87\(\pm\)0.06 \\ \hline \\
\bf BAG &\bf 0.90\(\pm\)0.07& \bf 0.90\(\pm\)0.08& 0.51\(\pm\)0.20& 0.80\(\pm\)0.09& 0.80\(\pm\)0.10& 0.44\(\pm\)0.18& 0.63\(\pm\)0.12& 0.63\(\pm\)0.12& 0.57\(\pm\)0.09& 0.61\(\pm\)0.21& 0.61\(\pm\)0.21& 0.54\(\pm\)0.18& 0\bf 0.86\(\pm\).07& \bf 0.86\(\pm\)0.07& \bf 0.85\(\pm\)0.09 \\ \hline
\end{tabular}}
\end{table*}
Statistically significant results are in boldface, shows decision trees and SVM classifiers are statistically better when normalized and randomly permuted features are used. This increase was as much as almost 50\% (from 40\% to 90\% for the impersonal model and 94\% to 98\% for the personal model) looking at Table I and Table II with 43 features. Other classifiers are also statistically better using normalized features in a number of cases. For 70 number of feature-bank we again used pairwise T-tests between groups of normalized/randomly permuted and unnormalized/non-permuted data at 97\% - 98\% confidence level.
Statistically significant results are in boldface shows in all cases again decision trees and SVM classifiers are statistically better when normalized features are used. This increase was as much as almost 10\% (from 87\% to 97\% for the personal model) looking at Table III-IV. Table V-VIII shows single subject cross-validation process for each activity recognition.
\begin{figure}[!ht]
\centering{\includegraphics[scale=0.25]{Fig6.eps}}
\centering{\includegraphics[scale=0.25]{Fig7.eps}}
\centering{\includegraphics[scale=0.25]{Fig8.eps}} \linebreak
\centering{\includegraphics[scale=0.25]{Fig9.eps}}
\centering{\includegraphics[scale=0.25]{Fig10.eps}}
\caption{Overall Recognition Accuracy for different Activities with different number of samples per window.}
\end{figure}
Examining the overall and single subject cross-validation accuracy of all classifiers, each personal and the impersonal model becomes statistically significant in a number of cases. This leads us to prefer the use of normalization and random permutation in future applications of this method and in practical implementations. All of our chosen classifiers provide acceptable performance but decision tree and SVM are found to be better than other classifiers and have a number of other attractive features to their applicability.
In terms of the applicability of the smartwatch system, decision tree and SVM have smaller confidence intervals implying that they have more reliability in their training than other classification models. In terms of the applicability of the smartwatch system, the personal model has smaller confidence intervals implying that personal model has more reliability overall accuracies for both numbers of feature banks.
\begin{table}[!ht]
\tiny
\caption{Single Subject cross-validation-based accuracy analysis for \textbf{Impersonal Model with 43 Features extracted using 75 samples per window}.}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c c c c c c c c c c c c c c}
\hline \hline
\multicolumn{1}{c}{\bf Users} & \multicolumn{3}{|c|}{\bf Walking} & \multicolumn{3}{c|}{\bf Walking Up-Stairs} & \multicolumn{3}{c|}{\bf Walking Down-Stairs} & \multicolumn{3}{c|}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{|c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline \hline
\multicolumn{16}{c}{\bf Decision Trees Classifier} \\ \hline \hline
\bf User 1 &0.8706&0.8617&0.0595&0.9714&0.9689&0.4646& 0.7909&0.7942&0.8123& 0.6807&0.6922 &0.5766 &0.9759& 0.9765& 0.9175 \\ \hline
\bf User 2 &0.7145&0.6961&0.0839&0.9768&0.9794&0.7112&0.9944& 0.9940&0.7330& 0.9724& 0.9688& 0.7371& 0.9844& 0.9871&0.8945 \\ \hline
\bf User 3 &0.9757&0.9761&0.3730&0.7431&0.7000&0.7931&0.9497&0.9492&0.4230&0.9274& 0.9259& 0.7513&0.8691&0.8864&0.6500 \\ \hline
\bf User 4 &0.9935 &0.9894 &0.5847&0.9380&0.9390&0.2432&0.9277&0.9312&0.4050&0.4287&0.4201&0.2616&0.9911&0.9941&0.9410 \\ \hline
\bf User 5 &0.8998&0.8825&0.8987&0.9500&0.9442&0.2238&0.9690&0.9665&0.6171&0.9164&0.9126&0.7327&0.9687&0.9646&0.9400 \\ \hline
\bf User 6 & 0.9563&0.9518&0.4594&0.8450&0.8462&0.2972&0.6004&0.6025&0.6017&0.9804&0.9812&0.5938&0.8039&0.7993&0.7626 \\ \hline \hline
\multicolumn{16}{c}{\bf Naive Bayes Classifier} \\ \hline \hline
\bf User 1 &0.7597& 0.7597& 0.2070& 0.8883& 0.8883& 0.3495& 0.6883& 0.6883& 0.5390& 0.2448& 0.2448& 0.4323& 0.8522& 0.8522& 0.8595 \\ \hline
\bf User 2 &0.7979& 0.7979 & 0.6905& 0.9270& 0.9270& 0.3863& 0.9742 &0.9742 &0.6137 &0.7647 &0.7647& 0.7235 &0.8855 &0.8855 &0.8909 \\ \hline
\bf User 3 &0.9179 &0.9179 &0.6589 &0.6373 &0.6373& 0.6961 &0.8907 &0.8907 &0.3060 &0.7411& 0.7411& 0.7614& 0.8287& 0.8287 &0.7832 \\ \hline
\bf User 4 &0.9369 &0.9369 &0.8342 &0.8545& 0.8545& 0.2723 &0.7525 &0.7525 &0.2624 &0.3171& 0.3171& 0.2317& 0.8614& 0.8614 &0.9242 \\ \hline
\bf User 5 &0.8667 &0.8667 &0.5657&0.7791 &0.7791 &0.2500& 0.8734 &0.8734 &0.4430 &0.6918 &0.6918 &0.7673& 0.9038& 0.9038& 0.8308 \\ \hline
\bf User 6 & 0.8847& 0.8847& 0.8176& 0.5663& 0.5663& 0.1847& 0.4017& 0.4017& 0.3473 &0.5134 &0.5134 &0.6205& 0.8256& 0.8256& 0.8479 \\ \hline \hline
\multicolumn{16}{c}{\bf KNN Classifier} \\ \hline \hline
\bf User 1 &0.7523 &0.7523& 0.6728 &0.5680& 0.5680& 0.1359 &0.6299 &0.6299 &0.4416 &0.4688 &0.4688 &0.5365& 0.9179 &0.9179 &0.8942 \\ \hline
\bf User 2 &0.7370& 0.7370& 0.6279& 0.7854& 0.7854& 0.2017& 0.8970& 0.8970 &0.3605 &0.7765 &0.7765 &0.6882& 0.9655 &0.9655& 0.9091 \\ \hline
\bf User 3 &0.9661 &0.9661 &0.8268 &0.6618 &0.6618 &0.3235 &0.7814 &0.7814 &0.1913 &0.7310 &0.7310 &0.6853& 0.8759& 0.8759& 0.8444 \\ \hline
\bf User 4 &0.8901 &0.8901 &0.6811 &0.6150 &0.6150 &0.1878& 0.7030 &0.7030 &0.2327 &0.2317 &0.2317 &0.2378& 0.9778& 0.9778& 0.9298 \\ \hline
\bf User 5 &0.9371 &0.9371 &0.8495 &0.5698 &0.5698 &0.0698 &0.7848 &0.7848 &0.5190 &0.6667 &0.6667& 0.5723 & 0.9615 &0.9615& 0.9269 \\ \hline
\bf User 6 &0.8985 &0.8985& 0.6127& 0.5422 &0.5422 &0.1606 &0.4184& 0.4184 &0.5565& 0.7813& 0.7813& 0.6339& 0.7658 &0.7658& 0.8051 \\ \hline \hline
\multicolumn{16}{c}{\bf SVM Classifier} \\ \hline \hline
\bf User 1 &0.9760 &0.9760 &0.1257 &0.9223 &0.9223 &0.3204& 0.8377 &0.9657 &0.6883 &0.4740 &0.4740 &0.4792& 0.9398& 0.9380& 0.9033 \\ \hline
\bf User 2 &0.7710 &0.7710 &0.8497 &0.9742 &0.9742& 0.0172 &0.9657 &0.8361 &0.6695& 0.8706& 0.8706& 0.7059& 0.9164& 0.9164 &0.9073 \\ \hline
\bf User 3 &0.9679 &0.9679 &0.1304 &0.8137 &0.8137 &0.8971 &0.8361 &0.7277 &0.2787& 0.8985& 0.8985& 0.6954& 0.8654& 0.8654& 0.7815 \\ \hline
\bf User 4 &0.9874 &0.9874& 0.9550& 0.9061& 0.9061& 0.0329& 0.7277& 0.8608& 0.2772& 0.7378& 0.7378& 0.1707& 0.9464& 0.9464& 0.9575 \\ \hline
\bf User 5 &0.9600 &0.9600 & 0.9448 &0.9302 &0.9302 &0.0814 &0.8608 &0.6109 &0.5823& 0.6792& 0.6792 &0.6604& 0.9788 &0.9788& 0.9192 \\ \hline
\bf User 6 &0.9776 &0.9776& 0.8864& 0.9197& 0.9197& 0.1365& 0.6109 &0.9657 &0.0669 &0.8839 &0.8839 &0.5848& 0.8991 &0.8974 &0.8308 \\ \hline \hline
\multicolumn{16}{c}{\bf Ensemble Learning-BAG Classifier} \\ \hline \hline
\bf User 1 &0.8784 &0.8656 &0.0980& 0.9694& 0.9670& 0.3529 &0.7805& 0.7864& 0.7968& 0.6734& 0.6786 &0.5661& 0.9763 &0.9748& 0.9224 \\ \hline
\bf User 2 &0.7086& 0.7038 &0.1243 & 0.9712& 0.9721 &0.6236 &0.9944 &0.9953 &0.7416 &0.9641 &0.9647 &0.7429& 0.9827& 0.9811& 0.8982 \\ \hline
\bf User 3 &0.9757& 0.9759 &0.3900 &0.6730& 0.6985& 0.7902& 0.9475 &0.9497 &0.4240 &0.9279& 0.9228& 0.7472& 0.8692 &0.8764 &0.6458 \\ \hline
\bf User 4 &0.9894 &0.9874 & 0.5782 &0.9376 &0.9366 &0.2531 &0.9292 &0.9233 &0.4183& 0.3988 &0.4073& 0.2317& 0.9930 &0.9904& 0.9442 \\ \hline
\bf User 5 &0.8989 &0.8970 &0.9006 &0.9517& 0.9448& 0.2017& 0.9614& 0.9608& 0.6253& 0.8994 &0.9031& 0.7409& 0.9677 &0.9662 &0.9448 \\ \hline
\bf User 6 &0.9546& 0.9497& 0.4305& 0.8454 &0.8426 &0.2924 &0.6167& 0.6079 &0.6004& 0.9772& 0.9777& 0.5960& 0.8373& 0.8113& 0.7576 \\ \hline \hline
\end{tabular}}
\end{table}
\begin{table}[!ht]
\tiny
\caption{Single Subject cross-validation-based accuracy analysis for \textbf{Personal Model with 43 Features extracted using 75 samples per window}.}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c c c c c c c c c c c c c c}
\hline \hline
\multicolumn{1}{c}{\bf Users} & \multicolumn{3}{|c|}{\bf Walking} & \multicolumn{3}{c|}{\bf Walking Up-Stairs} & \multicolumn{3}{c|}{\bf Walking Down-Stairs} & \multicolumn{3}{c|}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{|c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline \hline
\multicolumn{16}{c}{\bf Decision Trees Classifier} \\ \hline \hline
\bf User 1 &0.9815 &0.7889 &0.9500 &0.9073 &0.7366 &0.8000 &0.9067 &0.7067 &0.5867 &0.9632 &0.9368 &0.7895& 0.9908& 0.9945& 0.9633 \\ \hline
\bf User 2 &0.9820 &0.9802 &0.9604 &0.8957 &0.7348 &0.8217 &0.7870& 0.7826& 0.8043& 0.9471& 0.9647 &0.8765 & 0.9836& 0.9873& 0.9382 \\ \hline
\bf User 3 &0.9786 &0.7768 &0.9214& 0.9450& 0.7500& 0.6750 &0.9278 &0.7167 &0.7611& 0.9333& 0.9128& 0.5487& 0.9772 &0.9579 &0.9193 \\ \hline
\bf User 4 &0.9874 &0.9946 &0.9568 &0.9714& 0.7619& 0.5000& 0.9600& 0.7400& 0.8100& 0.9500& 0.9625 &0.7875& 0.9833 &0.9815 &0.9500 \\ \hline
\bf User 5 &0.9867 &0.9905& 0.9314& 0.9235& 0.7412& 0.7176& 0.9226& 0.7290& 0.8129& 0.9548& 0.9484& 0.8581& 0.9865 &0.7885 &0.9519 \\ \hline
\bf User 6 &0.9741 &0.7741& 0.9397& 0.9102& 0.9306 &0.5959& 0.8894& 0.8000& 0.6979& 0.9636& 0.9682 &0.7955& 0.9829 &0.9846 &0.9282 \\ \hline \hline
\multicolumn{16}{c}{\bf Naive Bayes Classifier} \\ \hline \hline
\bf User 1 &0.9019 &0.6981 &0.9000& 0.8049 &0.6146& 0.4732& 0.6800& 0.4467 &0.3467 &0.5000 &0.6474& 0.5421 & 0.8789& 0.7046& 0.8844 \\ \hline
\bf User 2 &0.9099 &0.7171 &0.9027 &0.7087 &0.5087 &0.5000 &0.8174& 0.6478& 0.7391& 0.8412& 0.8412& 0.6118& 0.9109& 0.9036& 0.8982 \\ \hline
\bf User 3 &0.9518 &0.7571 &0.6589 &0.9250 &0.7300 &0.6950 &0.8889 &0.6778 &0.7500 &0.7846 &0.5949 &0.7897& 0.8912& 0.6421& 0.8930 \\ \hline
\bf User 4 &0.9279 &0.7423 &0.9261& 0.9429 &0.7381& 0.4952 &0.8750 &0.6600 &0.6050 &0.7500 &0.7312 &0.7250& 0.9296 &0.7315 &0.7278
\\ \hline
\bf User 5 &0.9219& 0.7200& 0.9105 &0.6176 &0.6176& 0.6294& 0.8903& 0.6710& 0.7355& 0.6194& 0.8194& 0.6258& 0.9308 &0.7231& 0.9269 \\ \hline
\bf User 6 & 0.8741 &0.6862& 0.8931& 0.6490& 0.4735& 0.4776& 0.7319& 0.4809& 0.6723& 0.1955& 0.3955& 0.6273& 0.6735 &0.6803 &0.8906 \\ \hline \hline
\multicolumn{16}{c}{\bf KNN Classifier} \\ \hline \hline
\bf User 1 &0.7333& 0.7389& 0.6852& 0.7122& 0.4732& 0.2585& 0.5800& 0.3467& 0.3667& 0.8316 &0.8211& 0.6895& 0.9450 &0.9541 &0.9376 \\ \hline
\bf User 2 &0.9604& 0.7477 &0.9045& 0.5217& 0.2783 &0.1826 &0.8391& 0.6087 &0.4435 &0.8059 &0.8412 &0.8059& 0.9691 &0.9691 &0.9164 \\ \hline
\bf User 3 &0.9643 &0.7571 &0.9054 &0.5400 &0.5900 &0.2050& 0.7222 &0.5222 &0.3389 &0.8051 &0.6103 &0.7436& 0.9561 &0.9491 &0.9316 \\ \hline
\bf User 4 &0.9568 &0.9658 &0.9351& 0.8333& 0.6333& 0.1333& 0.4450& 0.6250 &0.6350& 0.6813 &0.4813& 0.7688& 0.8741 &0.6889 &0.8481 \\ \hline
\bf User 5 &0.9638 &0.7600 & 0.9219 &0.6765& 0.4118& 0.3000& 0.6452 &0.6581 &0.5032 &0.6387 &0.6645& 0.7355& 0.9769 &0.7769& 0.9558 \\ \hline
\bf User 6 &0.9397 &0.7466 &0.8759& 0.5673& 0.3143& 0.2408 &0.5064& 0.4340& 0.3234 &0.8773 &0.8773& 0.5318& 0.7316& 0.9350 &0.9009 \\ \hline \hline
\multicolumn{16}{c}{\bf SVM Classifier} \\ \hline \hline
\bf User 1 &0.7481& 0.7370& 0.9315& 0.8049& 0.6732& 0.6000& 0.8400& 0.6200& 0.7333& 0.7263& 0.9158& 0.7474& 0.9688& 0.9761 &0.9431 \\ \hline
\bf User 2 &0.9622 &0.7658& 0.9279 &0.6522 &0.6609 &0.8261 &0.9435& 0.7565 & 0.7696 &0.8824& 0.6882 &0.8059& 0.9855& 0.9855& 0.9327 \\ \hline
\bf User 3 &0.9714 &0.7679 & 0.9089 &0.7500 &0.7250 &0.7450 &0.8556 & 0.6333& 0.6889& 0.8974& 0.6769& 0.7538& 0.9719 &0.9579 &0.9246 \\ \hline
\bf User 4 &0.9838& 0.7892& 0.9640& 0.9238 &0.7286& 0.3095& 0.9350& 0.7150 &0.7500& 0.8500& 0.8375& 0.5938& 0.9685 &0.9685 &0.9537 \\ \hline
\bf User 5 &0.9581 &0.7562& 0.9067 &0.9353& 0.7235& 0.5000& 0.9226& 0.6968& 0.7484 &0.8968 &0.9161 &0.8194& 0.9673 &0.7769 &0.9596 \\ \hline
\bf User 6 &0.9552 &0.7638 &0.9414 &0.6939 &0.9020 &0.4082& 0.8851 &0.6638 &0.4511 &0.9636 &0.9364 &0.7045& 0.9573 &0.9607& 0.9162 \\ \hline \hline
\multicolumn{16}{c}{\bf Ensemble Learning-BAG Classifier} \\ \hline \hline
\bf User 1 &0.9870 &0.7852 &0.9481 &0.7122 &0.7317 &0.7707 &0.9133 &0.7067& 0.5933 &0.9632 &0.9421 &0.7842& 0.9872 &0.7963 &0.9486 \\ \hline
\bf User 2 &0.9838 &0.9874& 0.9604& 0.8870& 0.7261& 0.5652 &0.9783 &0.7826 &0.8174 &0.9588 &0.9647 &0.8706& 0.9873 &0.9909& 0.9491 \\ \hline
\bf User 3 & 0.9786& 0.7732 &0.9179 &0.9450 &0.9500 &0.6400 &0.9278& 0.7111& 0.5556& 0.9077& 0.9026 &0.8154& 0.9807 & 0.9561& 0.9105 \\ \hline
\bf User 4 &0.9874 & 0.9964 &0.9495 &0.9619 &0.7714 &0.6762 &0.9650& 0.7400& 0.8350& 0.9375& 0.9563 &0.6000& 0.9778 &0.9778& 0.9444 \\ \hline
\bf User 5 &0.9867 &0.9886 &0.7276& 0.9059 &0.7235 &0.7118 &0.7290& 0.7161 &0.7871 &0.9677 &0.9548 &0.6452& 0.9942 &0.7846 &0.9462 \\ \hline
\bf User 6 &0.9741 &0.7724 &0.7138 &0.6980 &0.9224& 0.5918 &0.8553 &0.8255& 0.7064 &0.9727& 0.9591 &0.5955& 0.9846 &0.9897 &0.9197 \\ \hline \hline
\end{tabular}}
\end{table}
Looking at Table I-IV, KNN, Decision trees and SVM perform much better in the personal model for both number of features with normalization and for overall accuracy prospect; decision trees outperformed then KNN and SVM. The highest obtained accuracies are in boldface. For further analysis the best-recommended system settings are 70 features normalized and randomly permuted used by Decision tree and SVM classifier to recognize the individual's activity on a smartwatch. Given a fixed amount of data, the performance of KNN and SVM decreases significantly when the window size is increased as it reduces the number of training samples but this does not affect decision tree classifier. Since decision tree, KNN and SVM classifiers trained using 70 normalized and randomly permuted features happens to be the best setting for smartwatch based PAR system.
Results are summarized in Fig. 2 which presents the overall classification accuracy with 98\% confidence interval. According to these results, decision tree classifier shows higher accuracy for every size of the window. The performance of SVM and KNN through good but is relatively less than that of the decision tree in all cases. Overall, decision trees performance happens to be best followed by SVM as their performance did not much degraded when changing the size of samples per window. On the other hand, the performance of KNN reduced significantly as the window size is increased. We think that it is because we have a fixed amount of data. So a bigger window size results in a smaller number of training samples. To confirm this, we repeated the same experiment for each activity individually. The entire results are summarized in Table I-IV which confirms our hypothesis. The additional experiments on single subject cross-validations are presented in Table V-VIII for both feature banks and personal and impersonal models respectively.
\begin{table*}[!ht]
\tiny
\caption{Single Subject cross-validation-based accuracy analysis for \textbf{Personal Model with 70 Features extracted using 75 samples per window}.}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c c c c c c c c c c c c c c}
\hline \hline
\multicolumn{1}{c}{\bf Users} & \multicolumn{3}{|c|}{\bf Walking} & \multicolumn{3}{c|}{\bf Walking Up-Stairs} & \multicolumn{3}{c|}{\bf Walking Down-Stairs} & \multicolumn{3}{c|}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{|c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline \hline
\multicolumn{16}{c}{\bf Decision Trees Classifier} \\ \hline \hline
\bf User 1 &0.9593& 0.9574 &0.7074 &0.6780& 0.6780& 0.7171& 0.5800& 0.5467& 0.7000 &0.6947 &0.9053 &0.7632& 0.9908 &0.9908 &0.9541 \\ \hline
\bf User 2 &0.9748 &0.7640 &0.9405 &0.8913 &0.7217 &0.6130 &0.9217& 0.9522 &0.7739 &0.9235 &0.7235 &0.8176& 0.9909& 0.9873& 0.9218 \\ \hline
\bf User 3 &0.9821 &0.7821 &0.9357 &0.9550 &0.7500 &0.4950 &0.9389 &0.7111 &0.7167& 0.8769 &0.8872& 0.7487& 0.9421 &0.9246& 0.9105 \\ \hline
\bf User 4 &0.9820 &0.9856 &0.9586 &0.9286 &0.7143 &0.6762 &0.8200 &0.5950 &0.8100 &0.8562 &0.9000 &0.6062& 0.9778 &0.7741& 0.9389 \\ \hline
\bf User 5 &0.9790& 0.7733 &0.9257& 0.8412& 0.6235& 0.8294 &0.6903& 0.8710& 0.7548& 0.9290& 0.9419 &0.6129& 0.9750 &0.9731 &0.9462 \\ \hline
\bf User 6 & 0.9741& 0.9810 &0.9172 &0.7265 &0.7102 &0.3673 &0.7830 &0.7489& 0.6894& 0.8727 & 0.8773 &0.7773& 0.9641 &0.9675 &0.9248\\ \hline \hline
\multicolumn{16}{c}{\bf Naive Bayes Classifier} \\ \hline \hline
\bf User 1 &0.8593& 0.6333& 0.7870 &0.5073 &0.4634 &0.6537 &0.5467& 0.3733& 0.6200& 0.5368 &0.5632& 0.7211& 0.8789 &0.6642 &0.8917 \\ \hline
\bf User 2 &0.8757 &0.8793 & 0.6505 &0.3609 &0.3826 &0.5696& 0.7478 &0.5739& 0.7739 &0.7176 &0.5529 &0.7941& 0.8636& 0.6727& 0.7000 \\ \hline
\bf User 3 &0.9161& 0.7179 &0.6071 &0.8750& 0.6650 &0.6300 &0.7889& 0.5722 &0.4667 &0.5333 &0.6462& 0.7590& 0.8561& 0.6614 &0.8842 \\ \hline
\bf User 4 &0.8955 &0.6991 &0.8541& 0.8381 &0.6524& 0.6000& 0.5050 &0.4550 &0.5400 &0.6000& 0.4063 &0.4625& 0.9130& 0.7148& 0.7333 \\ \hline
\bf User 5 &0.8857 &0.8800 &0.8781 &0.5765 &0.3647& 0.2588& 0.8065& 0.5613& 0.6065& 0.7613 &0.5871 &0.7677& 0.9096& 0.7135 &0.9154 \\ \hline
\bf User 6 &0.8638 &0.6879 &0.8448& 0.7224& 0.5429 &0.4612 &0.3362 &0.3064& 0.5745& 0.3273 &0.5318& 0.3955 & 0.8598& 0.6547 &0.8838
\\ \hline \hline
\multicolumn{16}{c}{\bf KNN Classifier} \\ \hline \hline
\bf User 1 &0.9648 &0.9426 &0.8944 &0.4390& 0.3951 &0.1268 &0.4267& 0.4667& 0.1600& 0.7053 &0.7158& 0.1842& 0.9835 &0.9725 &0.9138\\ \hline
\bf User 2 &0.9532 &0.9532& 0.8685& 0.6565& 0.5087& 0.1391& 0.5174& 0.5174 &0.2217 &0.5118 &0.7118& 0.2000& 0.9545 & 0.9600 &0.8927 \\ \hline
\bf User 3 &0.9625 &0.9732& 0.8536& 0.7700 &0.5950 &0.4650 &0.7389 &0.5278& 0.1444& 0.4718& 0.5795& 0.2974 &0.9263& 0.9070 &0.8526 \\ \hline
\bf User 4 &0.9550 &0.9568 &0.7964& 0.5048 &0.4810& 0.2048& 0.3450 &0.5200 &0.2700 &0.3250 &0.2562& 0.0938& 0.9481& 0.9574& 0.9204 \\ \hline
\bf User 5 & 0.9771 &0.7638 &0.7048 &0.5471 &0.3176& 0.1353& 0.7161 &0.5484 &0.1613 &0.7742& 0.7935& 0.5935 &0.9635 &0.9654 &0.9058 \\ \hline
\bf User 6 &0.9603 &0.9759 &0.6190 &0.6898 &0.4612 &0.0980 &0.2213 &0.2043 &0.0596 &0.6955& 0.4727& 0.2182 &0.9675& 0.9556& 0.8940 \\ \hline \hline
\multicolumn{16}{c}{\bf SVM Classifier} \\ \hline \hline
\bf User 1 &0.9778 &0.7759& 0.8852& 0.8634 &0.7317 &0.4000 &0.8067 &0.8067 &0.5600 &0.9000& 0.9263& 0.5105 & 0.9706 &0.9725 &0.9193 \\ \hline
\bf User 2 &0.9946 &0.9910 & 0.9297 &0.9522 &0.7652 &0.4826 &0.9348 &0.7435 &0.4870 &0.9000 &0.7294 &0.5353& 0.9909& 0.9855& 0.9200 \\ \hline
\bf User 3 &0.9804 &0.9839 &0.8732 &0.9150 &0.7200& 0.6150& 0.9333 &0.9389& 0.4333& 0.8718 &0.8769 &0.7231& 0.9439 &0.7175 &0.9123 \\ \hline
\bf User 4 &0.9820 &0.9748 &0.9063 &0.9667 &0.7619 &0.6048 &0.9100& 0.7000& 0.7100& 0.9313& 0.9437 &0.7375& 0.9667 &0.7778& 0.9241 \\ \hline
\bf User 5 &0.9829 &0.9752 &0.6990& 0.6882& 0.6588& 0.4765& 0.8968& 0.7032 &0.4516 &0.9097 &0.6968& 0.7677& 0.9827 &0.9808 &0.9346 \\ \hline
\bf User 6 &0.9759 &0.7862 & 0.8983 &0.9510 &0.9633 &0.5673 &0.6851& 0.6638 &0.5872& 0.9273& 0.9545 &0.7091& 0.9675 &0.9641 &0.8872 \\ \hline \hline
\multicolumn{16}{c}{\bf Ensemble Learning-BAG Classifier} \\ \hline \hline
\bf User 1 &0.9556 &0.9500 &0.9241 &0.8780 &0.6829 &0.7317 &0.7333 &0.5133 &0.6467& 0.8947 &0.8842 &0.8000& 0.9908 &0.9890& 0.9596 \\ \hline
\bf User 2 &0.9658 &0.7730& 0.9405& 0.8826& 0.7087& 0.8261& 0.9087 &0.7174 &0.5696 &0.9353& 0.7529 &0.8000& 0.9873& 0.9873& 0.9364 \\ \hline
\bf User 3 &0.9821 &0.7804 &0.9268 &0.9500& 0.7400& 0.4700& 0.8944& 0.7056& 0.5500 &0.8667 &0.8564 &0.7487 & 0.9386& 0.7228& 0.9211 \\ \hline
\bf User 4 &0.9874& 0.9802 &0.9532 &0.6905 &0.6952 &0.6333 &0.8250 &0.5150 &0.6650 &0.8625 &0.9000 &0.6000& 0.9741 & 0.7741& 0.9444 \\ \hline
\bf User 5 & 0.9619 &0.7695 &0.9390& 0.8235& 0.6000 & 0.7941& 0.8645& 0.6903& 0.7613 &0.9032 &0.9226 &0.8065 & 0.9750 &0.7750& 0.9519 \\ \hline
\bf User 6 &0.9741 &0.9724 &0.7241 &0.9061 &0.6939 &0.6367 &0.8170& 0.7872& 0.6936& 0.9500 &0.8409 &0.5864& 0.9761 &0.9658 &0.7231 \\ \hline \hline
\end{tabular}}
\end{table*}
\begin{table*}[!ht]
\tiny
\caption{Single Subject cross-validation-based accuracy analysis for \textbf{Impersonal Model with 70 Features extracted using 75 samples per window}.}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c c c c c c c c c c c c c c}
\hline \hline
\multicolumn{1}{c}{\bf Users} & \multicolumn{3}{|c|}{\bf Walking} & \multicolumn{3}{c|}{\bf Walking Up-Stairs} & \multicolumn{3}{c|}{\bf Walking Down-Stairs} & \multicolumn{3}{c|}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{|c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline \hline
\multicolumn{16}{c}{\bf Decision Trees Classifier} \\ \hline \hline
\bf User 1 &0.7455 &0.7412 &0.3338 &0.9296 &0.9286 &0.3888 &0.7896 &0.7896 &0.7383 &0.3563 &0.3677 &0.3885& 0.8648 &0.8739 &0.9086 \\ \hline
\bf User 2 &0.9370 &0.9458 &0.1308 &0.9682 &0.9665 &0.8129 &0.7210 &0.7223 &0.6605 &0.8600& 0.8524 &0.7094& 0.8445& 0.8320& 0.8367 \\ \hline
\bf User 3 &0.9846 &0.9832 &0.5609 &0.7505 &0.7471 &0.6240 &0.6268 &0.6311& 0.5557& 0.8437& 0.8508& 0.7061& 0.7346& 0.7392 &0.6330 \\ \hline
\bf User 4 &0.9524 &0.9532 & 0.6688 &0.7906 &0.7850 &0.4028 &0.6485 &0.6470 &0.3876 &0.2348& 0.2274 &0.1835& 0.9762 &0.9773 &0.9486 \\ \hline
\bf User 5 &0.9617& 0.9636& 0.8874& 0.8023& 0.7849 &0.1552 &0.6791& 0.6747& 0.5766 &0.7264& 0.7157 &0.7535& 0.9442& 0.9456 &0.9133 \\ \hline
\bf User 6 &0.8523& 0.8491 &0.4219 &0.6711 &0.6643 &0.3040& 0.3448 & 0.3552 &0.5130 &0.7254 &0.7513 &0.4955& 0.7814& 0.7879& 0.8374 \\ \hline \hline
\multicolumn{16}{c}{\bf Naive Bayes Classifier} \\ \hline \hline
\bf User 1 &0.6192 &0.8429& 0.4455& 0.7087& 0.1408& 0.3883& 0.5649& 0.1039& 0.5649& 0.2396 &0.1719 &0.3646& 0.7646 &0.8102& 0.8266 \\ \hline
\bf User 2 &0.9123& 0.7728& 0.3953 &0.5536 &0.1330 &0.5880 &0.6609 &0.1116 &0.5536 &0.5118 &0.1294 &0.7118& 0.8582 &0.8873& 0.8273 \\ \hline
\bf User 3 &0.8286 &0.6982 &0.5643 &0.4216 &0.1961 &0.5392 &0.5683 &0.2022 &0.4481 &0.5736 &0.2792& 0.6954& 0.7902 &0.7115 &0.7413 \\ \hline
\bf User 4 &0.8342 &0.5802 &0.4432 &0.5164 &0.0845 &0.5164& 0.5149 &0.1535& 0.3960& 0.3415 &0.0183 &0.2378 & 0.8965 &0.9279 &0.9205 \\ \hline
\bf User 5 &0.6724 &0.8114 &0.1410& 0.5291& 0.1279& 0.5756 &0.6076 &0.1266 &0.4873& 0.4969 &0.1698 &0.7610& 0.7404& 0.8769& 0.6308 \\ \hline
\bf User 6 &0.7126& 0.6713 &0.3270 &0.4859 &0.1767 &0.3735 &0.2594 &0.0879& 0.3347& 0.3527 &0.2188 &0.4955& 0.8222 &0.5573& 0.8393 \\ \hline \hline
\multicolumn{16}{c}{\bf KNN Classifier} \\ \hline \hline
\bf User 1 &0.8096 &0.8096& 0.8429& 0.6408 &0.6408& 0.1408& 0.4026& 0.4026& 0.1039& 0.2448& 0.2448 &0.1719& 0.8029& 0.8029 &0.8102\\ \hline
\bf User 2 &0.9141 &0.9141& 0.7728& 0.6438& 0.6438& 0.1330& 0.5794 &0.5794 &0.1116 &0.3235 &0.3235& 0.1294& 0.9182 &0.9182& 0.8873 \\ \hline
\bf User 3 &0.9143 &0.9143& 0.6982& 0.5931 &0.5931 &0.1961 &0.5683 &0.5683& 0.2022 &0.5381 &0.5381 &0.2792& 0.8759 &0.8759& 0.7115 \\ \hline
\bf User 4 & 0.9387 &0.9387 &0.5802& 0.4131 & 0.4131 &0.0845& 0.2574 &0.2574 &0.1535 &0.1037 &0.1037 &0.0183& 0.9593& 0.9593& 0.9279 \\ \hline
\bf User 5 &0.9733 &0.9733 &0.8114 &0.4767 &0.4767 &0.1279 &0.5380& 0.5380 &0.1266 &0.3019 &0.3019 &0.1698& 0.9231 &0.9231 &0.8769 \\ \hline
\bf User 6 &0.8176 &0.8176 &0.6713& 0.4618 &0.4618 &0.1767& 0.2008 &0.2008 &0.0879 &0.3705 &0.3705 &0.2188& 0.7726& 0.7726 &0.5573 \\ \hline \hline
\multicolumn{16}{c}{\bf SVM Classifier} \\ \hline \hline
\bf User 1 &0.9372 &0.9372& 0.6007 &0.9417& 0.9417 &0.2233 &0.7857 &0.7857& 0.5909& 0.6146& 0.6146& 0.5313& 0.9197 &0.9197 &0.8832 \\ \hline
\bf User 2 &0.9517 &0.9517& 0.9660& 0.9828 &0.9828& 0.0258 &0.8712 &0.8712 & 0.6266& 0.9059 &0.9059 &0.6882& 0.9655 &0.9655 &0.8909 \\ \hline
\bf User 3 & 0.9875 &0.9875 &0.8750& 0.8578& 0.8578& 0.1716 &0.8852 &0.8852 &0.5355& 0.9137& 0.9137& 0.6802& 0.8776 &0.8776 &0.7483
\\ \hline
\bf User 4 &0.9928 &0.9928 & 0.6883& 0.8685 &0.8685 &0.2066 &0.8861 &0.8861& 0.4208& 0.8049 &0.8049 &0.5183& 0.9778 &0.9778 &0.9482 \\ \hline
\bf User 5 &0.9867 &0.9867& 0.9543& 0.8663& 0.8663 &0.0291 &0.8291& 0.8291 &0.5886 &0.7358& 0.7358 &0.5849& 0.9654& 0.9654& 0.9000 \\ \hline
\bf User 6 &0.9639 &0.9639 &0.9466& 0.8996 &0.8996 &0.0723 &0.6820 &0.6820 &0.2176 &0.8527 &0.8527 &0.5670& 0.9573& 0.9573& 0.8256 \\ \hline \hline
\multicolumn{16}{c}{\bf Ensemble Learning-BAG Classifier} \\ \hline \hline
\bf User 1 &0.7423 &0.7240& 0.3532 &0.9194 &0.9301& 0.3888 &0.7721& 0.7825& 0.7123& 0.3219& 0.3255& 0.3906& 0.8746 &0.8611 &0.9111 \\ \hline
\bf User 2 & 0.9331 &0.9392 &0.1644 &0.9665& 0.9597& 0.7931& 0.7120 &0.7206 &0.6652 &0.8288 &0.8253 &0.7141& 0.8393 &0.8480 &0.8349 \\ \hline
\bf User 3 &0.9832& 0.9852& 0.5695& 0.7333& 0.7216 &0.6039& 0.6186& 0.6235& 0.5322& 0.8376& 0.8365& 0.7015& 0.7362 &0.7392 &0.6451 \\ \hline
\bf User 4 &0.9450 &0.9505& 0.6701 &0.7690 &0.7643 &0.3911 &0.6416 &0.6391 &0.3856 &0.2305 &0.2329 &0.1951& 0.9758& 0.9747& 0.9444 \\ \hline
\bf User 5 &0.9598 &0.9577 &0.8851& 0.7628& 0.7756 &0.1651 &0.6918 &0.6842 &0.5766 &0.7182 &0.7170 &0.7440& 0.9415 &0.9463 &0.9137 \\ \hline
\bf User 6 &0.8522 &0.8515& 0.4389& 0.6627 &0.6514 &0.2892& 0.3477 &0.3485 &0.5188 &0.7201 &0.7076 &0.4906& 0.7805 & 0.7701 &0.8487 \\ \hline \hline
\end{tabular}}
\end{table*}
\section{Conclusion}
\label{sec8}
Feature banks created by different smartphone-based physical activity recognition studies can be used for physical activity recognition on smartwatches because smartphone also uses accelerometer, gyroscope and magnetometer sensors and hence the same set of features is acceptable for a smartwatch. Decision trees, SVM and KNN showed the best results with a minor difference. Additionally, Naive Bayes and ensemble learning with Bag classifiers also produce a good performance. Furthermore, feature normalization and random permutation processes significantly improve the classification performance in several cases. In addition to above, without any doubt, changing window size affects the recognition accuracy.
From results, we observed that every activity and each classifier's results of recognition is highly correlated with window size. In general, each classifier performs well when features are extracted using 25-125 samples per window. Personal models perform better for smartwatch based physical activity recognition providing an average accuracy of 98\%. Furthermore, the impersonal model produces 94\% and 90\% accuracy respectively with the same settings of the personal model. Finally, the recommended combination for smartwatch based physical activity recognition system is decision tree classifier trained using 25-125 samples per window of normalized and randomly permuted features. In our future work, we will investigate the effects of several linear/non-linear supervised and unsupervised feature selection methods.
\section{Introduction}
\label{sec1}
Last few years have witnessed a massive growth in consumer interest in smart devices [1]. These include smartphones, smart TVs, and recently smartwatches. Because of their increased penetration, smartwatches have claimed a handsome market share. A typical smartwatch contains a heart rate monitor, GPS, thermometer, camera and accelerometer. Thus, it can provide a variety of services. These services include temperature and pulse measurements and the number of calories consumed when performing a physical activity, such as walking, running, cycling and so forth [2].
Recently, smartwatches have emerged in our daily lives and like their smartphone counterparts, smartwatches do contain a gyroscope, magnetometer and accelerometer sensors to support similar capabilities and applications. These applications include health applications i.e. calories consumption that require sensor based physical activity recognition. A number of calories consumed during physical activities vary from one activity to another. Therefore, the first thing to do when estimating the number of calories consumed, is to first recognize which activity have been performed [3].
This work explores the idea of physical activity recognition on smartwatches using the embedded gyroscope, magnetometer and accelerometer sensors. The gyroscope, magnetometer and accelerometer sensors are ideal for physical activity recognition. We further discussed the detailed analysis of various feature banks and classification methods to seek the best settings for optimum performance on two different types of models such as impersonal and personal model over the smartwatch. Personal models referred as the classifier is built using the data only form one specific user whereas the impersonal model referred as the classifier is built using the data form every user except the one under study. To summarize, the main contributions of this work is towards answering the following questions: 1): Existing smartphone-based physical activity recognition studies have a number of features that were utilized for smartphone-based physical activity recognition; can they be used for smartwatch-based physical activity recognition as well. 2): Which of the most commonly used classifiers from the reference field provides the best recognition accuracy. 3): Does features permutation help to improve the accuracy. 4): Does features normalization help to improve the performance of the classifier. 5): Which model (Personal or Impersonal) works better for smartwatch-based physical activity recognition. 6): Does changing the window size affect the recognition accuracy.
Physical activity recognition in general using motion sensors especially using smartphones has been studied in recent years [4-6] and currently being studied extensively [7-8] but there are a few studies on physical activity recognition using smartwatches [9-18] in which the authors studied the role of the smartwatch in physical activity recognition system for health recommendation purposes.
For instance, Guiry et al. [9] proposed physical activity recognition system to recognize nine different activities using five different classifiers. These activities include walking, standing, cycling, running, stair ascent, stair descent, elevator ascent and descent. However, the authors studied smartphone and smartwatch based activity recognition separately and did not combine the data from both devices. Furthermore, for real-time data collection, the author's used magnetometer, accelerometer and gyroscope sensors for smartphone and accelerometer for a smartwatch. Trost et al. [10] used sensors on hip and wrist to detect physical activities using logistic regression based classification method. In [10], Trost et al. just focused on showing the potential of using the wrist position for physical activity recognition for health recommendation system. Chernbumroong et al. [11] used a single wrist-worn accelerometer to detect five different physical activities for recommendation system. These activities include standing, sitting, lying, running and walking. However, Da-Silva et al. [12] used the same sensor to detect the eight different physical activities for recommendation system. In addition to the activities identified in [11] Da-Silva et al. include the activity of working on a computer too. The works [13] and [14] detect the eating activity using a Hidden Markov Model (HMM) with a wrist-worn accelerometer and gyroscope sensors. Ramos-Garcia identifies the eating activity by dividing it into further sub-activities in [13] which includes resting, drinking, eating, using utensil and others. Meanwhile, Dong et al. [14] proposed to differentiate eating periods from non-eating periods to identify the eating and not-eating activity. Sen et al. [15] used both accelerometer and gyroscope sensor data to recognize the eating and non-eating activities. Furthermore, the authors used smartwatch camera to take images of the food being consumed to analyze what a user is eating.
School et al. [16] presented a feasibility study to detect and identify the smoking activity using accelerometer sensor where School et al. only reported a user-specific accuracy for smoking activity. Whereas, A. Parade et al. [17] used both accelerometer, magnetometer and gyroscope sensors to recognize smoking puffs where they just try to distinguished smoking activity from other activities. A similar work has been reported in [18] where the the authors used support vector machine (SVM) to recognize six different physical activities. These activities include standing, walking, writing, jacks, smoking and jogging. Kim et al. [19] proposed the collaborative classification approach for recognizing daily activities using smartwatches. The authors exploit a single off-the-shelf smartwatch to recognize five daily activities; namely eating, watching TV, sleeping, vacuuming and showering. For fair comparisons Kim et al. suggested using single and multiple sensors-based approaches to compare with their proposed approach with the overall accuracy of 91.5\% with the improved recall rate up to 21.5\% for each activity. Weiss et al. showed that accelerometers and gyroscopes sensors that sense user's movements and can help identify the user activity [20]. Weiss et al. propose to compare the smartphone and smartwatch-based user activity recognition in which smartwatch have the ability to recognize hand-based activities namely eating which is not possible through a smartphone. They showed that the smartwatch is able to recognize the drinking activity with 93.3\% accuracy while smartphones achieve only 77.3\%.
Nurwanto et al. [21] proposed a daily life light sport exercise activities. These activities include squat jump, push up, sit up and walking. Nurwanto et al. focuses only on accelerometer-based signal captured by left-handed persons and the obtained signals were processed through sliding window approach with the k-nearest neighbor method and dynamic time warping as the main classifier. Furthermore, Nurwanto et al. proved that k-NN together with dynamic time warping method is an efficient method for daily exercise recognition with the accuracy of 76.67\% for push up 96.69\% for squat jump and 80\% for sit up activity. They intentionally exclude the walking activity for their experimental process because of the random patterns. Al-Naffakh et al. [22] proposed the usefulness of using smartwatch motion sensor namely gyroscope and accelerometer to perform user activity recognition. Al-Naffakh et al. proved the natures of the signals captured are sufficiently discriminative to be useful in performing activity recognition.
Different activities can be recognized using motion sensors at the wrist position i.e. drinking, eating, smoking, walking, walking down stairs, walking up stairs, running, jogging, elevator up, elevator down, doing regular exercises, writing etc. However there is no study that discusses these activities all together with the recommendations of optimum system settings. Therefore, to extend the existing works, we evaluate the combination of different feature banks and classification techniques for the reliable recognition of various activities. We also evaluate three different built-in motion sensors. Moreover, unlike the current trends, we also evaluate the effect of window size on each activity performed by the individual user and its impact on the recognition performance of simple and complex activities. Although the effect of window size on physical activity recognition has been studied by Huynh et al. in [23] but the windowing effect on complex activities is yet not fully explored. Moreover, unlike the recent works, we explore the use of both \textit{Personal} and \textit{Impersonal} models individually for each activity as explained; 1): Personal model means the classifier is trained using the data only from one specific individual whereas, the Impersonal model means the classifier is built using the data from every user except the one under study. 2): For both models, one subject cross-validation process is adopted. 3): Finally, our study suggests the optimum system settings for any activity recognition system based on smartwatches.
This work analyzes the effects of combining gyroscope, magnetometer and accelerometer sensors data for physical activity recognition for different size of windows varying from one second to 12 seconds long window. We further analyze the effect of various sampling rates on the recognition performance in different scenarios. However, in our current study, we still have room for further improvement. For example, our current dataset is not balanced (as shown in Fig. 1) for all performed activities which might lead to the biased results towards majority classes. To handle the said problem to some extent, we used one subject cross-validation process for different models (personal and impersonal) which somehow overcome the class imbalance issue. This study also overcomes the limitations of overlapping while segmenting the raw data which forcefully improve the recognition performance because this overlap cause using some part of data in both training and testing which limiting the use of such techniques in a real-time environment. Moreover, we proposed and suggest some methods which helps to improve the recognition performance for those activities that have low recognition performance.
\begin{figure}[!ht]
\centering
\includegraphics[scale=0.16]{Fig1.eps}
\includegraphics[scale=0.16]{Fig2.eps}
\includegraphics[scale=0.16]{Fig3.eps} \linebreak
\includegraphics[scale=0.16]{Fig4.eps}
\includegraphics[scale=0.16]{Fig5.eps}
\caption{Raw Signal for individual activity.}
\end{figure}
The rest of the paper has the following organization. Section 2 describes the material and methods. Section 3 contains experimental settings. Section 4 presents the experimental results and discussion and finally section 5 concludes the paper with possible future directions.
\section{Materials and Methods}
\label{sec2}
Today's smartwatches are equipped with a variety of motion sensors that are useful for monitoring device movements like tilt, rotate and shake. Some of these sensors are the ambient light sensor, accelerometer, compass, gyroscope and GPS sensors. For experimental study we only collected the raw signals using three different sensors such as accelerometer, magnetometer and gyroscope sensor.
\subsection{Data Collection}
\label{sec3}
We collected the raw signals for five different activities from six users (three female and three male) having a mean age of twenty-five years old. The criterion for selecting the subjects is based on the gender because different genders exhibit different patterns when performing the same activity. These activities include walking, walking upstairs, walking downstairs, running and jogging. All subjects performed these activities twice on each day for more than a month. Therefore we collected raw data from the same user for same activity but performed on different days.
The participants enrolled in our study are approved by the laboratory head because this is a formal prerequisite because our experiments involved human subjects and there is a negligible risk of injury. The involved subjects then asked to answer few nontechnical questions like gender, age, height, weight, left or right handed etc, which we used to characterize our study. Then the subjects were asked to fastens the smartwatch on their wrist and places a Bluetooth paired smartphone in their pocket. Both devices run a simple custom designed application that controls the data collection process and instructs the participant to first add their name and then select the activity from the list of five different activities and the sensor from three different sensors. Once the initial instructions were done, turn the smartphone screen off and place the smartphone into the pants pocket. The smartphone instructs the smartwatch running our paired data collection application to collect the raw signal at the 20Hz rate. Each of these sensors generates 3-dimensional signals and appends a time-stamp to the values. Every after five minutes the smartwatch sends the data to the smartphone and after a successful transmission, the smartphone vibrate to notify the user that the data collection process is successfully completed and they can stop the current activity.
\subsection{Feature Extraction}
\label{sec4}
The embedded sensor generates three-dimensional time series signals which are highly fluctuating and oscillatory in nature. The oscillation and fluctuations make the physical activity recognition more difficult than other applications in nature. These raw signals are shown in Fig. 1 for individual activity performed by the single user. Therefore, it is compulsory to gather the nontrivial signals from raw data through a feature extraction process. The raw signals are divided into several equal sized windows to control the flow rate and pass fewer data to the system to extract the meaningful information. In [24] Khan et al. have presented a detailed analysis of using different kinds of features with a different number of samples per windows for smartphone-based physical activity recognition.
From these raw signals, the extracted features are divided into two different feature banks. First feature bank include the features obtained by taking; average, median, variance, standard deviation, interquartile, autocorrelation, partial autocorrelation, coefficients of autoregressive model, coefficients of moving average model, coefficients of autoregressive moving average model and wavelet coefficients. Second feature bank includes the features obtained by taking; average acceleration, average absolute difference, standard deviation, average resultant acceleration and the average difference between peaks. We also calculate the binned distribution in which we determine what fraction of reading fall in a 10 equal-sized bins. This function generates 10 features. Every feature except average resultant acceleration is extracted for each axis.
These features are extracted from each axis of the three-dimensional acceleration signal and in total for each window of acceleration data 43 (first-feature-bank) and 70 (second-feature-bank) features are extracted respectively. Prior to the feature extraction process moving average filter of order three is used for noise reduction.
\subsection{Classifiers}
\label{sec5}
Khan et al. and Saputri et al. showed that support vector machines (SVM) and artificial neural networks (ANN) are superior to other traditional classification methods for user-independent physical activity recognition system in [24-26]. K-nearest neighbor (KNN) is also one of the most popular classification method used for smartphone-based physical activity recognition and user identification [27]. ELM [28], Naive Bayes [29], Adaptive learning/Ensemble learning (BAG) [30] and Decision tree [31] classifiers are also famous for smartphone-based physical activity recognition system. All these classification methods have shown several advantages in several fields most probably in their respective domains. Once again, given that ours is an exploratory study and the fact that each of these classifiers has shown a good performance in their respective studies. Instead of choosing one we decided to explore the use of all of these classifiers except neural networks in this work.
\section{Experimental Settings}
\label{sec6}
The following experimental studies are performed using all the data to create both personal and impersonal models. In our first study, using a fixed size of 75 samples per window the performance of five classifiers are compared to the following three cases on both feature banks and for both personal and impersonal models: 1): Randomly permuted features with normalization. 2): Without random permutation and normalization. 3): Randomly permuted features without normalization.
In the second study, the best setting for each classifier is chosen and tested multiple times while changing the number of samples in a window \textit{i.e. \{25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300\}} samples. The goal is to measure the effect of changing the window size on the performance of each classifier for both personal and impersonal model respectively. In our both studies, the training and testing data is randomly divided and classification results are obtained using 10-fold cross-validation process. The values used for different parameters of classifiers are as follows where all these parameters are carefully tuned and optimized. SVM is trained with quadratic kernel function is used, KNN with Euclidean distance is used and K is set to 10, Ensemble model (BAG) with tree model and the number of weak classifiers are set to 50 and the numbers of decision tree are set to 85.
\section{Experimental Results and Discussion}
\label{sec7}
This section contains the obtained results for smartwatch-based physical activity recognition system. To validate our system we conduct different experiments. Our first experiment is for both personal and impersonal model-based physical activity recognition analyses. In this experiment, we conduct a detailed comparison of two different feature banks and five classifiers for both personal and impersonal models. Our second experiment explains the physical activity recognition process behavior with a different number of samples per window within the best settings obtained in our first experiment. Finally, the third experiment presents the single subject cross-validation recognition for each activity for both personal and impersonal models individually. All these experiments are based on 10-fold cross-validation process and all these experiments are carried out using Matlab R2014b installed on core i5 and 8GB of RAM machine.
In the introduction section; we stated some important research questions which our explanatory study seeks to provide the basis of answers. The answers to those questions based on the obtained results are as follows: Based on our findings, yes the features used in existing smartphone-based physical activity recognition studies can also be used for the smartwatch-based physical activity recognition. If we consider normalized and random permutation feature space, classifiers perform much better opposed to the case of without normalization and random permutation in several cases. Table I-IV present the 98\% confidence intervals about overall physical activity recognition rate. Using pairwise T-tests between groups of normalized/randomly permuted and unnormalized/non-permuted data at the 98\% confidence level.
\begin{table*}[!ht]
\caption{Overall Classification Accuracy and Confidence Interval for \textbf{Impersonal Model} with \textbf{43 Features} extracted using \textbf{75 samples per window}. Where \textit{NR = Normalized, UNR = Unnormalized, RP = Randomly~Permuted, and NRP = Non~Randomly~Permuted}.}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c| c c c| c c c| c c c| c c c l}
\hline \hline
\multicolumn{1}{c}{\bf Classifiers} & \multicolumn{3}{c}{\bf Walking} & \multicolumn{3}{c}{\bf Walking Up-Stairs} & \multicolumn{3}{c}{\bf Walking Down-Stairs} & \multicolumn{3}{c}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline
\bf Decision \\ \bf Tree & \bf 0.90\(\pm\)0.08 &0.89\(\pm\)0.09 &0.41\(\pm\)0.26 & \bf 0.90\(\pm\)0.07 & \bf 0.90\(\pm\)0.09 &0.46\(\pm\)0.20 &0.87\(\pm\)0.12 &0.87\(\pm\)0.12 &0.60\(\pm\)0.13 &0.82\(\pm\)0.18 &0.82\(\pm\)0.18 &0.61\(\pm\)0.15 & \bf 0.93\(\pm\)0.06 & \bf 0.94\(\pm\)0.06 &0.85\(\pm\)0.10 \\ \hline
\bf Naive \\ \bf Bayes & \bf 0.86\(\pm\)0.06 & \bf 0.86\(\pm\)0.06& 0.63\(\pm\)0.18& 0.78\(\pm\)0.12& 0.78\(\pm\)0.12& 0.36\(\pm\)0.15& 0.76\(\pm\)0.16& 0.76\(\pm\)0.16& 0.42\(\pm\)0.11& 0.55\(\pm\)0.18& 0.55\(\pm\)0.18& 0.59\(\pm\)0.17& \bf 0.86\(\pm\)0.02& \bf 0.86\(\pm\)0.02& \bf 0.86\(\pm\)0.04 \\ \hline \\
\bf KNN & \bf 0.86\(\pm\)0.08& \bf 0.86\(\pm\)0.08& 0.71\(\pm\)0.08& 0.62\(\pm\)0.07& 0.62\(\pm\)0.07 &0.18\(\pm\)0.07& 0.70\(\pm\)0.13& 0.70\(\pm\)0.13& 0.38\(\pm\)0.12& 0.61\(\pm\)0.17& 0.61\(\pm\)0.17& 0.56\(\pm\)0.13& \bf 0.91\(\pm\)0.06& \bf 0.91\(\pm\)0.06& \bf 0.88\(\pm\)0.04 \\ \hline \\
\bf SVM &\bf 0.94\(\pm\)0.07& \bf 0.94\(\pm\)0.06& 0.65\(\pm\)0.32& \bf 0.91\(\pm\)0.04& \bf 0.91\(\pm\)0.04& 0.25\(\pm\)0.27& 0.81\(\pm\)0.10& 0.81\(\pm\)0.10& 0.43\(\pm\)0.20& 0.76\(\pm\)0.13& 0.76\(\pm\)0.13& 0.55\(\pm\)0.16& \bf 0.92\(\pm\)0.03& \bf 0.92\(\pm\)0.03& \bf 0.88\(\pm\)0.05 \\ \hline \\
\bf BAG &\bf 0.91\(\pm\)0.08& \bf 0.90\(\pm\)0.08& 0.43\(\pm\)0.24& \bf 0.89\(\pm\)0.09& \bf 0.89\(\pm\)0.09 & 0.42\(\pm\)0.19 & \bf 0.87\(\pm\)0.12& \bf 0.87\(\pm\)0.12 & 0.60\(\pm\)0.13& 0.81\(\pm\)0.18 & 0.81\(\pm\)0.18 & 0.60\(\pm\)0.16 & \bf 0.94\(\pm\)0.05 & \bf 0.93\(\pm\)0.06 & \bf 0.85\(\pm\)0.09 \\ \hline
\end{tabular}}
\end{table*}
\begin{table*}[!ht]
\caption{Overall Classification Accuracy and Confidence Interval for \textbf{Personal Model} with \textbf{43 Features} extracted using \textbf{75 samples per window}}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c| c c c| c c c| c c c| c c c l}
\hline \hline
\multicolumn{1}{c}{\bf Classifiers} & \multicolumn{3}{c}{\bf Walking} & \multicolumn{3}{c}{\bf Walking Up-Stairs} & \multicolumn{3}{c}{\bf Walking Down-Stairs} & \multicolumn{3}{c}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline
\bf Decision \\ \bf Tree & \bf 0.98\(\pm\)0.01& 0.88\(\pm\)0.09& \bf 0.94\(\pm\)0.01& \bf 0.93\(\pm\)0.02& 0.78\(\pm\)0.06& 0.69\(\pm\)0.10& \bf 0.98\(\pm\)0.05& 0.75\(\pm\)0.03& 0.75\(\pm\)0.07& \bf 0.95\(\pm\)0.01& 0.95\(\pm\)0.01& 0.78\(\pm\)0.09& \bf 0.98\(\pm\)0.01& \bf 0.95\(\pm\)0.06& \bf 0.94\(\pm\)0.01 \\ \hline \\
\bf Naive & \bf 0.91\(\pm\)0.02& 0.72\(\pm\)0.02& \bf 0.87\(\pm\)0.08& 0.77\(\pm\)0.11& 0.61\(\pm\)0.09& 0.55\(\pm\)0.07& 0.81\(\pm\)0.07& 0.60\(\pm\)0.08& 0.64\(\pm\)0.12& 0.61\(\pm\)0.19& 0.67\(\pm\)0.13& 0.65\(\pm\)0.07& \bf 0.87\(\pm\)0.08& 0.73\(\pm\)0.07& \bf 0.87\(\pm\)0.06 \\ \hline \\
\bf KNN & \bf 0.92\(\pm\)0.07& 0.79\(\pm\)0.07& 0.87\(\pm\)0.07& 0.64\(\pm\)0.09& 0.45\(\pm\)0.11& 0.22\(\pm\)0.05& 0.62\(\pm\)0.12& 0.53\(\pm\)0.10& 0.44\(\pm\)0.10& 0.77\(\pm\)0.07& 0.72\(\pm\)0.12& 0.71\(\pm\)0.08& \bf 0.91\(\pm\)0.08& \bf 0.88\(\pm\)0.09& \bf 0.92\(\pm\)0.03 \\ \hline \\
\bf SVM & \bf 0.93\(\pm\)0.07& 0.76\(\pm\)0.01& \bf 0.93\(\pm\)0.01& 0.79\(\pm\)0.09& 0.74\(\pm\)0.07& 0.56\(\pm\)0.16& \bf 0.90\(\pm\)0.03& 0.68\(\pm\)0.04& 0.6\(\pm\)0.10& \bf 0.87\(\pm\)0.06& \bf 0.83\(\pm\)0.09& 0.74\(\pm\)0.07& \bf 0.97\(\pm\)0.01& \bf 0.94\(\pm\)0.06& \bf 0.94\(\pm\)0.01\\ \hline \\
\bf BAG & \bf 0.98\(\pm\)0.01& \bf 0.88\(\pm\)0.09& \bf 0.87\(\pm\)0.09& 0.85\(\pm\)0.09& 0.80\(\pm\)0.08& 0.66\(\pm\)0.06& \bf 0.89\(\pm\)0.07& 0.75\(\pm\)0.04& 0.72\(\pm\)0.09& \bf 0.95\(\pm\)0.02& \bf 0.95\(\pm\)0.02& 0.72\(\pm\)0.10& \bf 0.99\(\pm\)0.01& \bf 0.92\(\pm\)0.08& \bf 0.94\(\pm\)0.01 \\ \hline \end{tabular}}
\end{table*}
\begin{table*}[!ht]
\caption{Overall Classification Accuracy and Confidence Interval for \textbf{Personal Model} with \textbf{70 Features} extracted using \textbf{75 samples per window}}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c| c c c| c c c| c c c| c c c l}
\hline \hline
\multicolumn{1}{c}{\bf Classifiers} & \multicolumn{3}{c}{\bf Walking} & \multicolumn{3}{c}{\bf Walking Up-Stairs} & \multicolumn{3}{c}{\bf Walking Down-Stairs} & \multicolumn{3}{c}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline
\bf Decision \\ \bf Tree &\bf 0.98\(\pm\)0.01& \bf 0.87\(\pm\)0.09& \bf 0.90\(\pm\)0.08& 0.84\(\pm\)0.09& 0.67\(\pm\)0.04& 0.62\(\pm\)0.13& 0.79\(\pm\)0.11& 0.74\(\pm\)0.12& 0.74\(\pm\)0.04& \bf 0.86\(\pm\)0.07& \bf 0.87\(\pm\)0.06& 0.72\(\pm\)0.07& \bf 0.97\(\pm\)0.01& \bf 0.94\(\pm\)0.07& \bf 0.93\(\pm\)0.01 \\ \hline \\
\bf Naive & \bf 0.88\(\pm\)0.02& 0.75\(\pm\)0.08& 0.77\(\pm\)0.09& 0.65\(\pm\)0.16& 0.51\(\pm\)0.10& 0.53\(\pm\)0.12& 0.62\(\pm\)0.15& 0.47\(\pm\)0.09& 0.60\(\pm\)0.08& 0.58\(\pm\)0.12& 0.55\(\pm\)0.06&
0.65\(\pm\)0.14& \bf 0.88\(\pm\)0.02& 0.68\(\pm\)0.02& 0.83\(\pm\)0.07 \\ \hline \\
\bf KNN &\bf 0.96\(\pm\) 0.01& \bf 0.93\(\pm\) 0.07& 0.79\(\pm\) 0.09& 0.60\(\pm\) 0.10& 0.46\(\pm\) 0.08& 0.19\(\pm\) 0.11& 0.49\(\pm\) 0.16& 0.46\(\pm\) 0.10& 0.17\(\pm\) 0.06& 0.58±\(\pm\) 0.14& 0.59\(\pm\) 0.16& 0.26\(\pm\) 0.14& \bf 0.95\(\pm\) 0.02& \bf 0.95\(\pm\) 0.02& \bf 0.90\(\pm\) 0.02 \\ \hline \\
\bf SVM &0.98\(\pm\)0.01&0.91\(\pm\)0.08&0.87\(\pm\)0.07&0.89\(\pm\)0.08&0.77\(\pm\)0.08&0.52\(\pm\)0.07&0.86\(\pm\)0.08&0.76\(\pm\)0.08&0.54\(\pm\)0.08&0.91\(\pm\)0.02&0.85\(\pm\)0.09&
0.66\(\pm\)0.09&0.97\(\pm\)0.01&0.90\(\pm\)0.10&0.92\(\pm\)0.01\\ \hline \\
\bf BAG &\bf 0.97\(\pm\)0.01& \bf 0.87\(\pm\)0.09& \bf 0.90\(\pm\)0.07& \bf0.86\(\pm\)0.07& 0.69\(\pm\)0.04& 0.68\(\pm\)0.10& 0.84\(\pm\)0.05& 0.65\(\pm\)0.09& 0.65\(\pm\)0.06& \bf 0.90\(\pm\)0.03& \bf 0.86\(\pm\)0.05& 0.72\(\pm\)0.08& \bf 0.97\(\pm\)0.01& \bf 0.87\(\pm\)0.10& \bf 0.91\(\pm\)0.07 \\ \hline
\end{tabular}}
\end{table*}
\begin{table*}[!ht]
\caption{Overall Classification Accuracy and Confidence Interval for \textbf{Impersonal Model} with \textbf{70 Features} extracted using \textbf{75 samples per window}.}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c| c c c| c c c| c c c| c c c l}
\hline \hline
\multicolumn{1}{c}{\bf Classifiers} & \multicolumn{3}{c}{\bf Walking} & \multicolumn{3}{c}{\bf Walking Up-Stairs} & \multicolumn{3}{c}{\bf Walking Down-Stairs} & \multicolumn{3}{c}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline
\bf Decision \\ \bf Tree &\bf 0.91\(\pm\)0.07&\bf 0.91\(\pm\)0.07& 0.50\(\pm\)0.21& 0.82\(\pm\)0.09& 0.81\(\pm\)0.09& 0.45\(\pm\)0.19& 0.64\(\pm\)0.12& 0.64\(\pm\)0.12& 0.57\(\pm\)0.10& 0.62\(\pm\)0.21& 0.63\(\pm\)0.21& 0.54\(\pm\)0.18& \bf 0.86\(\pm\)0.07& \bf 0.86\(\pm\)0.07& \bf 0.85\(\pm\)0.094 \\ \hline \\
\bf Naive &0.76\(\pm\)0.09& 0.73\(\pm\)0.08& 0.39\(\pm\)0.11& 0.54\(\pm\)0.08& 0.14\(\pm\)0.03& 0.50\(\pm\)0.07& 0.53\(\pm\)0.11& 0.13\(\pm\)0.03& 0.46\(\pm\)0.07& 0.42\(\pm\)0.10& 0.16\(\pm\)0.07& 0.54\(\pm\)0.17& 0.81\(\pm\)0.05& 0.80\(\pm\)0.11& 0.80\(\pm\)0.08 \\ \hline \\
\bf KNN &\bf 0.89\(\pm\)0.05& \bf 0.89\(\pm\)0.05& 0.73\(\pm\)0.08& 0.54\(\pm\)0.08& 0.54\(\pm\)0.08& 0.14\(\pm\)0.03& 0.42\(\pm\)0.13& 0.42\(\pm\)0.13& 0.13\(\pm\)0.03& 0.31\(\pm\)0.11& 0.31\(\pm\)0.11& 0.16\(\pm\)0.07& \bf 0.86\(\pm\)0.06& \bf 0.88\(\pm\)0.09& 0.80\(\pm\)0.11 \\ \hline \\
\bf SVM &\bf 0.97\(\pm\)0.02& \bf 0.97\(\pm\)0.02& 0.84\(\pm\)0.12& \bf 0.90\(\pm\)0.04& \bf 0.90\(\pm\)0.04& 0.12\(\pm\)0.07& 0.82\(\pm\)0.06& 0.82\(\pm\)0.06& 0.50\(\pm\)0.1& 0.80\(\pm\)0.09& 0.80\(\pm\)0.09& 0.60\(\pm\)0.06& \bf 0.94\(\pm\)0.03& \bf 0.94\(\pm\)0.03& \bf 0.87\(\pm\)0.06 \\ \hline \\
\bf BAG &\bf 0.90\(\pm\)0.07& \bf 0.90\(\pm\)0.08& 0.51\(\pm\)0.20& 0.80\(\pm\)0.09& 0.80\(\pm\)0.10& 0.44\(\pm\)0.18& 0.63\(\pm\)0.12& 0.63\(\pm\)0.12& 0.57\(\pm\)0.09& 0.61\(\pm\)0.21& 0.61\(\pm\)0.21& 0.54\(\pm\)0.18& 0\bf 0.86\(\pm\).07& \bf 0.86\(\pm\)0.07& \bf 0.85\(\pm\)0.09 \\ \hline
\end{tabular}}
\end{table*}
Statistically significant results are in boldface, shows decision trees and SVM classifiers are statistically better when normalized and randomly permuted features are used. This increase was as much as almost 50\% (from 40\% to 90\% for the impersonal model and 94\% to 98\% for the personal model) looking at Table I and Table II with 43 features. Other classifiers are also statistically better using normalized features in a number of cases. For 70 number of feature-bank we again used pairwise T-tests between groups of normalized/randomly permuted and unnormalized/non-permuted data at 97\% - 98\% confidence level.
Statistically significant results are in boldface shows in all cases again decision trees and SVM classifiers are statistically better when normalized features are used. This increase was as much as almost 10\% (from 87\% to 97\% for the personal model) looking at Table III-IV. Table V-VIII shows single subject cross-validation process for each activity recognition.
\begin{figure}[!ht]
\centering{\includegraphics[scale=0.18]{Fig6.eps}}
\centering{\includegraphics[scale=0.18]{Fig7.eps}}
\centering{\includegraphics[scale=0.18]{Fig8.eps}} \linebreak
\centering{\includegraphics[scale=0.18]{Fig9.eps}}
\centering{\includegraphics[scale=0.18]{Fig10.eps}}
\caption{Overall Recognition Accuracy for different Activities with different number of samples per window.}
\end{figure}
Examining the overall and single subject cross-validation accuracy of all classifiers, each personal and the impersonal model becomes statistically significant in a number of cases. This leads us to prefer the use of normalization and random permutation in future applications of this method and in practical implementations. All of our chosen classifiers provide acceptable performance but decision tree and SVM are found to be better than other classifiers and have a number of other attractive features to their applicability.
In terms of the applicability of the smartwatch system, decision tree and SVM have smaller confidence intervals implying that they have more reliability in their training than other classification models. In terms of the applicability of the smartwatch system, the personal model has smaller confidence intervals implying that personal model has more reliability overall accuracies for both numbers of feature banks.
\begin{table}[!ht]
\tiny
\caption{Single Subject cross-validation-based accuracy analysis for \textbf{Impersonal Model with 43 Features extracted using 75 samples per window}.}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c c c c c c c c c c c c c c}
\hline \hline
\multicolumn{1}{c}{\bf Users} & \multicolumn{3}{|c|}{\bf Walking} & \multicolumn{3}{c|}{\bf Walking Up-Stairs} & \multicolumn{3}{c|}{\bf Walking Down-Stairs} & \multicolumn{3}{c|}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{|c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline \hline
\multicolumn{16}{c}{\bf Decision Trees Classifier} \\ \hline \hline
\bf User 1 &0.8706&0.8617&0.0595&0.9714&0.9689&0.4646& 0.7909&0.7942&0.8123& 0.6807&0.6922 &0.5766 &0.9759& 0.9765& 0.9175 \\ \hline
\bf User 2 &0.7145&0.6961&0.0839&0.9768&0.9794&0.7112&0.9944& 0.9940&0.7330& 0.9724& 0.9688& 0.7371& 0.9844& 0.9871&0.8945 \\ \hline
\bf User 3 &0.9757&0.9761&0.3730&0.7431&0.7000&0.7931&0.9497&0.9492&0.4230&0.9274& 0.9259& 0.7513&0.8691&0.8864&0.6500 \\ \hline
\bf User 4 &0.9935 &0.9894 &0.5847&0.9380&0.9390&0.2432&0.9277&0.9312&0.4050&0.4287&0.4201&0.2616&0.9911&0.9941&0.9410 \\ \hline
\bf User 5 &0.8998&0.8825&0.8987&0.9500&0.9442&0.2238&0.9690&0.9665&0.6171&0.9164&0.9126&0.7327&0.9687&0.9646&0.9400 \\ \hline
\bf User 6 & 0.9563&0.9518&0.4594&0.8450&0.8462&0.2972&0.6004&0.6025&0.6017&0.9804&0.9812&0.5938&0.8039&0.7993&0.7626 \\ \hline \hline
\multicolumn{16}{c}{\bf Naive Bayes Classifier} \\ \hline \hline
\bf User 1 &0.7597& 0.7597& 0.2070& 0.8883& 0.8883& 0.3495& 0.6883& 0.6883& 0.5390& 0.2448& 0.2448& 0.4323& 0.8522& 0.8522& 0.8595 \\ \hline
\bf User 2 &0.7979& 0.7979 & 0.6905& 0.9270& 0.9270& 0.3863& 0.9742 &0.9742 &0.6137 &0.7647 &0.7647& 0.7235 &0.8855 &0.8855 &0.8909 \\ \hline
\bf User 3 &0.9179 &0.9179 &0.6589 &0.6373 &0.6373& 0.6961 &0.8907 &0.8907 &0.3060 &0.7411& 0.7411& 0.7614& 0.8287& 0.8287 &0.7832 \\ \hline
\bf User 4 &0.9369 &0.9369 &0.8342 &0.8545& 0.8545& 0.2723 &0.7525 &0.7525 &0.2624 &0.3171& 0.3171& 0.2317& 0.8614& 0.8614 &0.9242 \\ \hline
\bf User 5 &0.8667 &0.8667 &0.5657&0.7791 &0.7791 &0.2500& 0.8734 &0.8734 &0.4430 &0.6918 &0.6918 &0.7673& 0.9038& 0.9038& 0.8308 \\ \hline
\bf User 6 & 0.8847& 0.8847& 0.8176& 0.5663& 0.5663& 0.1847& 0.4017& 0.4017& 0.3473 &0.5134 &0.5134 &0.6205& 0.8256& 0.8256& 0.8479 \\ \hline \hline
\multicolumn{16}{c}{\bf KNN Classifier} \\ \hline \hline
\bf User 1 &0.7523 &0.7523& 0.6728 &0.5680& 0.5680& 0.1359 &0.6299 &0.6299 &0.4416 &0.4688 &0.4688 &0.5365& 0.9179 &0.9179 &0.8942 \\ \hline
\bf User 2 &0.7370& 0.7370& 0.6279& 0.7854& 0.7854& 0.2017& 0.8970& 0.8970 &0.3605 &0.7765 &0.7765 &0.6882& 0.9655 &0.9655& 0.9091 \\ \hline
\bf User 3 &0.9661 &0.9661 &0.8268 &0.6618 &0.6618 &0.3235 &0.7814 &0.7814 &0.1913 &0.7310 &0.7310 &0.6853& 0.8759& 0.8759& 0.8444 \\ \hline
\bf User 4 &0.8901 &0.8901 &0.6811 &0.6150 &0.6150 &0.1878& 0.7030 &0.7030 &0.2327 &0.2317 &0.2317 &0.2378& 0.9778& 0.9778& 0.9298 \\ \hline
\bf User 5 &0.9371 &0.9371 &0.8495 &0.5698 &0.5698 &0.0698 &0.7848 &0.7848 &0.5190 &0.6667 &0.6667& 0.5723 & 0.9615 &0.9615& 0.9269 \\ \hline
\bf User 6 &0.8985 &0.8985& 0.6127& 0.5422 &0.5422 &0.1606 &0.4184& 0.4184 &0.5565& 0.7813& 0.7813& 0.6339& 0.7658 &0.7658& 0.8051 \\ \hline \hline
\multicolumn{16}{c}{\bf SVM Classifier} \\ \hline \hline
\bf User 1 &0.9760 &0.9760 &0.1257 &0.9223 &0.9223 &0.3204& 0.8377 &0.9657 &0.6883 &0.4740 &0.4740 &0.4792& 0.9398& 0.9380& 0.9033 \\ \hline
\bf User 2 &0.7710 &0.7710 &0.8497 &0.9742 &0.9742& 0.0172 &0.9657 &0.8361 &0.6695& 0.8706& 0.8706& 0.7059& 0.9164& 0.9164 &0.9073 \\ \hline
\bf User 3 &0.9679 &0.9679 &0.1304 &0.8137 &0.8137 &0.8971 &0.8361 &0.7277 &0.2787& 0.8985& 0.8985& 0.6954& 0.8654& 0.8654& 0.7815 \\ \hline
\bf User 4 &0.9874 &0.9874& 0.9550& 0.9061& 0.9061& 0.0329& 0.7277& 0.8608& 0.2772& 0.7378& 0.7378& 0.1707& 0.9464& 0.9464& 0.9575 \\ \hline
\bf User 5 &0.9600 &0.9600 & 0.9448 &0.9302 &0.9302 &0.0814 &0.8608 &0.6109 &0.5823& 0.6792& 0.6792 &0.6604& 0.9788 &0.9788& 0.9192 \\ \hline
\bf User 6 &0.9776 &0.9776& 0.8864& 0.9197& 0.9197& 0.1365& 0.6109 &0.9657 &0.0669 &0.8839 &0.8839 &0.5848& 0.8991 &0.8974 &0.8308 \\ \hline \hline
\multicolumn{16}{c}{\bf Ensemble Learning-BAG Classifier} \\ \hline \hline
\bf User 1 &0.8784 &0.8656 &0.0980& 0.9694& 0.9670& 0.3529 &0.7805& 0.7864& 0.7968& 0.6734& 0.6786 &0.5661& 0.9763 &0.9748& 0.9224 \\ \hline
\bf User 2 &0.7086& 0.7038 &0.1243 & 0.9712& 0.9721 &0.6236 &0.9944 &0.9953 &0.7416 &0.9641 &0.9647 &0.7429& 0.9827& 0.9811& 0.8982 \\ \hline
\bf User 3 &0.9757& 0.9759 &0.3900 &0.6730& 0.6985& 0.7902& 0.9475 &0.9497 &0.4240 &0.9279& 0.9228& 0.7472& 0.8692 &0.8764 &0.6458 \\ \hline
\bf User 4 &0.9894 &0.9874 & 0.5782 &0.9376 &0.9366 &0.2531 &0.9292 &0.9233 &0.4183& 0.3988 &0.4073& 0.2317& 0.9930 &0.9904& 0.9442 \\ \hline
\bf User 5 &0.8989 &0.8970 &0.9006 &0.9517& 0.9448& 0.2017& 0.9614& 0.9608& 0.6253& 0.8994 &0.9031& 0.7409& 0.9677 &0.9662 &0.9448 \\ \hline
\bf User 6 &0.9546& 0.9497& 0.4305& 0.8454 &0.8426 &0.2924 &0.6167& 0.6079 &0.6004& 0.9772& 0.9777& 0.5960& 0.8373& 0.8113& 0.7576 \\ \hline \hline
\end{tabular}}
\end{table}
\begin{table}[!ht]
\tiny
\caption{Single Subject cross-validation-based accuracy analysis for \textbf{Personal Model with 43 Features extracted using 75 samples per window}.}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c c c c c c c c c c c c c c}
\hline \hline
\multicolumn{1}{c}{\bf Users} & \multicolumn{3}{|c|}{\bf Walking} & \multicolumn{3}{c|}{\bf Walking Up-Stairs} & \multicolumn{3}{c|}{\bf Walking Down-Stairs} & \multicolumn{3}{c|}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{|c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline \hline
\multicolumn{16}{c}{\bf Decision Trees Classifier} \\ \hline \hline
\bf User 1 &0.9815 &0.7889 &0.9500 &0.9073 &0.7366 &0.8000 &0.9067 &0.7067 &0.5867 &0.9632 &0.9368 &0.7895& 0.9908& 0.9945& 0.9633 \\ \hline
\bf User 2 &0.9820 &0.9802 &0.9604 &0.8957 &0.7348 &0.8217 &0.7870& 0.7826& 0.8043& 0.9471& 0.9647 &0.8765 & 0.9836& 0.9873& 0.9382 \\ \hline
\bf User 3 &0.9786 &0.7768 &0.9214& 0.9450& 0.7500& 0.6750 &0.9278 &0.7167 &0.7611& 0.9333& 0.9128& 0.5487& 0.9772 &0.9579 &0.9193 \\ \hline
\bf User 4 &0.9874 &0.9946 &0.9568 &0.9714& 0.7619& 0.5000& 0.9600& 0.7400& 0.8100& 0.9500& 0.9625 &0.7875& 0.9833 &0.9815 &0.9500 \\ \hline
\bf User 5 &0.9867 &0.9905& 0.9314& 0.9235& 0.7412& 0.7176& 0.9226& 0.7290& 0.8129& 0.9548& 0.9484& 0.8581& 0.9865 &0.7885 &0.9519 \\ \hline
\bf User 6 &0.9741 &0.7741& 0.9397& 0.9102& 0.9306 &0.5959& 0.8894& 0.8000& 0.6979& 0.9636& 0.9682 &0.7955& 0.9829 &0.9846 &0.9282 \\ \hline \hline
\multicolumn{16}{c}{\bf Naive Bayes Classifier} \\ \hline \hline
\bf User 1 &0.9019 &0.6981 &0.9000& 0.8049 &0.6146& 0.4732& 0.6800& 0.4467 &0.3467 &0.5000 &0.6474& 0.5421 & 0.8789& 0.7046& 0.8844 \\ \hline
\bf User 2 &0.9099 &0.7171 &0.9027 &0.7087 &0.5087 &0.5000 &0.8174& 0.6478& 0.7391& 0.8412& 0.8412& 0.6118& 0.9109& 0.9036& 0.8982 \\ \hline
\bf User 3 &0.9518 &0.7571 &0.6589 &0.9250 &0.7300 &0.6950 &0.8889 &0.6778 &0.7500 &0.7846 &0.5949 &0.7897& 0.8912& 0.6421& 0.8930 \\ \hline
\bf User 4 &0.9279 &0.7423 &0.9261& 0.9429 &0.7381& 0.4952 &0.8750 &0.6600 &0.6050 &0.7500 &0.7312 &0.7250& 0.9296 &0.7315 &0.7278
\\ \hline
\bf User 5 &0.9219& 0.7200& 0.9105 &0.6176 &0.6176& 0.6294& 0.8903& 0.6710& 0.7355& 0.6194& 0.8194& 0.6258& 0.9308 &0.7231& 0.9269 \\ \hline
\bf User 6 & 0.8741 &0.6862& 0.8931& 0.6490& 0.4735& 0.4776& 0.7319& 0.4809& 0.6723& 0.1955& 0.3955& 0.6273& 0.6735 &0.6803 &0.8906 \\ \hline \hline
\multicolumn{16}{c}{\bf KNN Classifier} \\ \hline \hline
\bf User 1 &0.7333& 0.7389& 0.6852& 0.7122& 0.4732& 0.2585& 0.5800& 0.3467& 0.3667& 0.8316 &0.8211& 0.6895& 0.9450 &0.9541 &0.9376 \\ \hline
\bf User 2 &0.9604& 0.7477 &0.9045& 0.5217& 0.2783 &0.1826 &0.8391& 0.6087 &0.4435 &0.8059 &0.8412 &0.8059& 0.9691 &0.9691 &0.9164 \\ \hline
\bf User 3 &0.9643 &0.7571 &0.9054 &0.5400 &0.5900 &0.2050& 0.7222 &0.5222 &0.3389 &0.8051 &0.6103 &0.7436& 0.9561 &0.9491 &0.9316 \\ \hline
\bf User 4 &0.9568 &0.9658 &0.9351& 0.8333& 0.6333& 0.1333& 0.4450& 0.6250 &0.6350& 0.6813 &0.4813& 0.7688& 0.8741 &0.6889 &0.8481 \\ \hline
\bf User 5 &0.9638 &0.7600 & 0.9219 &0.6765& 0.4118& 0.3000& 0.6452 &0.6581 &0.5032 &0.6387 &0.6645& 0.7355& 0.9769 &0.7769& 0.9558 \\ \hline
\bf User 6 &0.9397 &0.7466 &0.8759& 0.5673& 0.3143& 0.2408 &0.5064& 0.4340& 0.3234 &0.8773 &0.8773& 0.5318& 0.7316& 0.9350 &0.9009 \\ \hline \hline
\multicolumn{16}{c}{\bf SVM Classifier} \\ \hline \hline
\bf User 1 &0.7481& 0.7370& 0.9315& 0.8049& 0.6732& 0.6000& 0.8400& 0.6200& 0.7333& 0.7263& 0.9158& 0.7474& 0.9688& 0.9761 &0.9431 \\ \hline
\bf User 2 &0.9622 &0.7658& 0.9279 &0.6522 &0.6609 &0.8261 &0.9435& 0.7565 & 0.7696 &0.8824& 0.6882 &0.8059& 0.9855& 0.9855& 0.9327 \\ \hline
\bf User 3 &0.9714 &0.7679 & 0.9089 &0.7500 &0.7250 &0.7450 &0.8556 & 0.6333& 0.6889& 0.8974& 0.6769& 0.7538& 0.9719 &0.9579 &0.9246 \\ \hline
\bf User 4 &0.9838& 0.7892& 0.9640& 0.9238 &0.7286& 0.3095& 0.9350& 0.7150 &0.7500& 0.8500& 0.8375& 0.5938& 0.9685 &0.9685 &0.9537 \\ \hline
\bf User 5 &0.9581 &0.7562& 0.9067 &0.9353& 0.7235& 0.5000& 0.9226& 0.6968& 0.7484 &0.8968 &0.9161 &0.8194& 0.9673 &0.7769 &0.9596 \\ \hline
\bf User 6 &0.9552 &0.7638 &0.9414 &0.6939 &0.9020 &0.4082& 0.8851 &0.6638 &0.4511 &0.9636 &0.9364 &0.7045& 0.9573 &0.9607& 0.9162 \\ \hline \hline
\multicolumn{16}{c}{\bf Ensemble Learning-BAG Classifier} \\ \hline \hline
\bf User 1 &0.9870 &0.7852 &0.9481 &0.7122 &0.7317 &0.7707 &0.9133 &0.7067& 0.5933 &0.9632 &0.9421 &0.7842& 0.9872 &0.7963 &0.9486 \\ \hline
\bf User 2 &0.9838 &0.9874& 0.9604& 0.8870& 0.7261& 0.5652 &0.9783 &0.7826 &0.8174 &0.9588 &0.9647 &0.8706& 0.9873 &0.9909& 0.9491 \\ \hline
\bf User 3 & 0.9786& 0.7732 &0.9179 &0.9450 &0.9500 &0.6400 &0.9278& 0.7111& 0.5556& 0.9077& 0.9026 &0.8154& 0.9807 & 0.9561& 0.9105 \\ \hline
\bf User 4 &0.9874 & 0.9964 &0.9495 &0.9619 &0.7714 &0.6762 &0.9650& 0.7400& 0.8350& 0.9375& 0.9563 &0.6000& 0.9778 &0.9778& 0.9444 \\ \hline
\bf User 5 &0.9867 &0.9886 &0.7276& 0.9059 &0.7235 &0.7118 &0.7290& 0.7161 &0.7871 &0.9677 &0.9548 &0.6452& 0.9942 &0.7846 &0.9462 \\ \hline
\bf User 6 &0.9741 &0.7724 &0.7138 &0.6980 &0.9224& 0.5918 &0.8553 &0.8255& 0.7064 &0.9727& 0.9591 &0.5955& 0.9846 &0.9897 &0.9197 \\ \hline \hline
\end{tabular}}
\end{table}
Looking at Table I-IV, KNN, Decision trees and SVM perform much better in the personal model for both number of features with normalization and for overall accuracy prospect; decision trees outperformed then KNN and SVM. The highest obtained accuracies are in boldface. For further analysis the best-recommended system settings are 70 features normalized and randomly permuted used by Decision tree and SVM classifier to recognize the individual's activity on a smartwatch. Given a fixed amount of data, the performance of KNN and SVM decreases significantly when the window size is increased as it reduces the number of training samples but this does not affect decision tree classifier. Since decision tree, KNN and SVM classifiers trained using 70 normalized and randomly permuted features happens to be the best setting for smartwatch based PAR system.
Results are summarized in Fig. 2 which presents the overall classification accuracy with 98\% confidence interval. According to these results, decision tree classifier shows higher accuracy for every size of the window. The performance of SVM and KNN through good but is relatively less than that of the decision tree in all cases. Overall, decision trees performance happens to be best followed by SVM as their performance did not much degraded when changing the size of samples per window. On the other hand, the performance of KNN reduced significantly as the window size is increased. We think that it is because we have a fixed amount of data. So a bigger window size results in a smaller number of training samples. To confirm this, we repeated the same experiment for each activity individually. The entire results are summarized in Table I-IV which confirms our hypothesis. The additional experiments on single subject cross-validations are presented in Table V-VIII for both feature banks and personal and impersonal models respectively.
\begin{table*}[!ht]
\tiny
\caption{Single Subject cross-validation-based accuracy analysis for \textbf{Personal Model with 70 Features extracted using 75 samples per window}.}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c c c c c c c c c c c c c c}
\hline \hline
\multicolumn{1}{c}{\bf Users} & \multicolumn{3}{|c|}{\bf Walking} & \multicolumn{3}{c|}{\bf Walking Up-Stairs} & \multicolumn{3}{c|}{\bf Walking Down-Stairs} & \multicolumn{3}{c|}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{|c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline \hline
\multicolumn{16}{c}{\bf Decision Trees Classifier} \\ \hline \hline
\bf User 1 &0.9593& 0.9574 &0.7074 &0.6780& 0.6780& 0.7171& 0.5800& 0.5467& 0.7000 &0.6947 &0.9053 &0.7632& 0.9908 &0.9908 &0.9541 \\ \hline
\bf User 2 &0.9748 &0.7640 &0.9405 &0.8913 &0.7217 &0.6130 &0.9217& 0.9522 &0.7739 &0.9235 &0.7235 &0.8176& 0.9909& 0.9873& 0.9218 \\ \hline
\bf User 3 &0.9821 &0.7821 &0.9357 &0.9550 &0.7500 &0.4950 &0.9389 &0.7111 &0.7167& 0.8769 &0.8872& 0.7487& 0.9421 &0.9246& 0.9105 \\ \hline
\bf User 4 &0.9820 &0.9856 &0.9586 &0.9286 &0.7143 &0.6762 &0.8200 &0.5950 &0.8100 &0.8562 &0.9000 &0.6062& 0.9778 &0.7741& 0.9389 \\ \hline
\bf User 5 &0.9790& 0.7733 &0.9257& 0.8412& 0.6235& 0.8294 &0.6903& 0.8710& 0.7548& 0.9290& 0.9419 &0.6129& 0.9750 &0.9731 &0.9462 \\ \hline
\bf User 6 & 0.9741& 0.9810 &0.9172 &0.7265 &0.7102 &0.3673 &0.7830 &0.7489& 0.6894& 0.8727 & 0.8773 &0.7773& 0.9641 &0.9675 &0.9248\\ \hline \hline
\multicolumn{16}{c}{\bf Naive Bayes Classifier} \\ \hline \hline
\bf User 1 &0.8593& 0.6333& 0.7870 &0.5073 &0.4634 &0.6537 &0.5467& 0.3733& 0.6200& 0.5368 &0.5632& 0.7211& 0.8789 &0.6642 &0.8917 \\ \hline
\bf User 2 &0.8757 &0.8793 & 0.6505 &0.3609 &0.3826 &0.5696& 0.7478 &0.5739& 0.7739 &0.7176 &0.5529 &0.7941& 0.8636& 0.6727& 0.7000 \\ \hline
\bf User 3 &0.9161& 0.7179 &0.6071 &0.8750& 0.6650 &0.6300 &0.7889& 0.5722 &0.4667 &0.5333 &0.6462& 0.7590& 0.8561& 0.6614 &0.8842 \\ \hline
\bf User 4 &0.8955 &0.6991 &0.8541& 0.8381 &0.6524& 0.6000& 0.5050 &0.4550 &0.5400 &0.6000& 0.4063 &0.4625& 0.9130& 0.7148& 0.7333 \\ \hline
\bf User 5 &0.8857 &0.8800 &0.8781 &0.5765 &0.3647& 0.2588& 0.8065& 0.5613& 0.6065& 0.7613 &0.5871 &0.7677& 0.9096& 0.7135 &0.9154 \\ \hline
\bf User 6 &0.8638 &0.6879 &0.8448& 0.7224& 0.5429 &0.4612 &0.3362 &0.3064& 0.5745& 0.3273 &0.5318& 0.3955 & 0.8598& 0.6547 &0.8838
\\ \hline \hline
\multicolumn{16}{c}{\bf KNN Classifier} \\ \hline \hline
\bf User 1 &0.9648 &0.9426 &0.8944 &0.4390& 0.3951 &0.1268 &0.4267& 0.4667& 0.1600& 0.7053 &0.7158& 0.1842& 0.9835 &0.9725 &0.9138\\ \hline
\bf User 2 &0.9532 &0.9532& 0.8685& 0.6565& 0.5087& 0.1391& 0.5174& 0.5174 &0.2217 &0.5118 &0.7118& 0.2000& 0.9545 & 0.9600 &0.8927 \\ \hline
\bf User 3 &0.9625 &0.9732& 0.8536& 0.7700 &0.5950 &0.4650 &0.7389 &0.5278& 0.1444& 0.4718& 0.5795& 0.2974 &0.9263& 0.9070 &0.8526 \\ \hline
\bf User 4 &0.9550 &0.9568 &0.7964& 0.5048 &0.4810& 0.2048& 0.3450 &0.5200 &0.2700 &0.3250 &0.2562& 0.0938& 0.9481& 0.9574& 0.9204 \\ \hline
\bf User 5 & 0.9771 &0.7638 &0.7048 &0.5471 &0.3176& 0.1353& 0.7161 &0.5484 &0.1613 &0.7742& 0.7935& 0.5935 &0.9635 &0.9654 &0.9058 \\ \hline
\bf User 6 &0.9603 &0.9759 &0.6190 &0.6898 &0.4612 &0.0980 &0.2213 &0.2043 &0.0596 &0.6955& 0.4727& 0.2182 &0.9675& 0.9556& 0.8940 \\ \hline \hline
\multicolumn{16}{c}{\bf SVM Classifier} \\ \hline \hline
\bf User 1 &0.9778 &0.7759& 0.8852& 0.8634 &0.7317 &0.4000 &0.8067 &0.8067 &0.5600 &0.9000& 0.9263& 0.5105 & 0.9706 &0.9725 &0.9193 \\ \hline
\bf User 2 &0.9946 &0.9910 & 0.9297 &0.9522 &0.7652 &0.4826 &0.9348 &0.7435 &0.4870 &0.9000 &0.7294 &0.5353& 0.9909& 0.9855& 0.9200 \\ \hline
\bf User 3 &0.9804 &0.9839 &0.8732 &0.9150 &0.7200& 0.6150& 0.9333 &0.9389& 0.4333& 0.8718 &0.8769 &0.7231& 0.9439 &0.7175 &0.9123 \\ \hline
\bf User 4 &0.9820 &0.9748 &0.9063 &0.9667 &0.7619 &0.6048 &0.9100& 0.7000& 0.7100& 0.9313& 0.9437 &0.7375& 0.9667 &0.7778& 0.9241 \\ \hline
\bf User 5 &0.9829 &0.9752 &0.6990& 0.6882& 0.6588& 0.4765& 0.8968& 0.7032 &0.4516 &0.9097 &0.6968& 0.7677& 0.9827 &0.9808 &0.9346 \\ \hline
\bf User 6 &0.9759 &0.7862 & 0.8983 &0.9510 &0.9633 &0.5673 &0.6851& 0.6638 &0.5872& 0.9273& 0.9545 &0.7091& 0.9675 &0.9641 &0.8872 \\ \hline \hline
\multicolumn{16}{c}{\bf Ensemble Learning-BAG Classifier} \\ \hline \hline
\bf User 1 &0.9556 &0.9500 &0.9241 &0.8780 &0.6829 &0.7317 &0.7333 &0.5133 &0.6467& 0.8947 &0.8842 &0.8000& 0.9908 &0.9890& 0.9596 \\ \hline
\bf User 2 &0.9658 &0.7730& 0.9405& 0.8826& 0.7087& 0.8261& 0.9087 &0.7174 &0.5696 &0.9353& 0.7529 &0.8000& 0.9873& 0.9873& 0.9364 \\ \hline
\bf User 3 &0.9821 &0.7804 &0.9268 &0.9500& 0.7400& 0.4700& 0.8944& 0.7056& 0.5500 &0.8667 &0.8564 &0.7487 & 0.9386& 0.7228& 0.9211 \\ \hline
\bf User 4 &0.9874& 0.9802 &0.9532 &0.6905 &0.6952 &0.6333 &0.8250 &0.5150 &0.6650 &0.8625 &0.9000 &0.6000& 0.9741 & 0.7741& 0.9444 \\ \hline
\bf User 5 & 0.9619 &0.7695 &0.9390& 0.8235& 0.6000 & 0.7941& 0.8645& 0.6903& 0.7613 &0.9032 &0.9226 &0.8065 & 0.9750 &0.7750& 0.9519 \\ \hline
\bf User 6 &0.9741 &0.9724 &0.7241 &0.9061 &0.6939 &0.6367 &0.8170& 0.7872& 0.6936& 0.9500 &0.8409 &0.5864& 0.9761 &0.9658 &0.7231 \\ \hline \hline
\end{tabular}}
\end{table*}
\begin{table*}[!ht]
\tiny
\caption{Single Subject cross-validation-based accuracy analysis for \textbf{Impersonal Model with 70 Features extracted using 75 samples per window}.}
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c c c c c c c c c c c c c c}
\hline \hline
\multicolumn{1}{c}{\bf Users} & \multicolumn{3}{|c|}{\bf Walking} & \multicolumn{3}{c|}{\bf Walking Up-Stairs} & \multicolumn{3}{c|}{\bf Walking Down-Stairs} & \multicolumn{3}{c|}{\bf Running}& \multicolumn{3}{c}{\bf Jogging}\\ \hline
& \multicolumn{1}{|c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP} & \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c|}{\bf UNR-RP}& \multicolumn{1}{c}{\bf NR-RP} & \multicolumn{1}{c}{\bf NR-NRP}& \multicolumn{1}{c}{\bf UNR-RP}\\ \hline \hline
\multicolumn{16}{c}{\bf Decision Trees Classifier} \\ \hline \hline
\bf User 1 &0.7455 &0.7412 &0.3338 &0.9296 &0.9286 &0.3888 &0.7896 &0.7896 &0.7383 &0.3563 &0.3677 &0.3885& 0.8648 &0.8739 &0.9086 \\ \hline
\bf User 2 &0.9370 &0.9458 &0.1308 &0.9682 &0.9665 &0.8129 &0.7210 &0.7223 &0.6605 &0.8600& 0.8524 &0.7094& 0.8445& 0.8320& 0.8367 \\ \hline
\bf User 3 &0.9846 &0.9832 &0.5609 &0.7505 &0.7471 &0.6240 &0.6268 &0.6311& 0.5557& 0.8437& 0.8508& 0.7061& 0.7346& 0.7392 &0.6330 \\ \hline
\bf User 4 &0.9524 &0.9532 & 0.6688 &0.7906 &0.7850 &0.4028 &0.6485 &0.6470 &0.3876 &0.2348& 0.2274 &0.1835& 0.9762 &0.9773 &0.9486 \\ \hline
\bf User 5 &0.9617& 0.9636& 0.8874& 0.8023& 0.7849 &0.1552 &0.6791& 0.6747& 0.5766 &0.7264& 0.7157 &0.7535& 0.9442& 0.9456 &0.9133 \\ \hline
\bf User 6 &0.8523& 0.8491 &0.4219 &0.6711 &0.6643 &0.3040& 0.3448 & 0.3552 &0.5130 &0.7254 &0.7513 &0.4955& 0.7814& 0.7879& 0.8374 \\ \hline \hline
\multicolumn{16}{c}{\bf Naive Bayes Classifier} \\ \hline \hline
\bf User 1 &0.6192 &0.8429& 0.4455& 0.7087& 0.1408& 0.3883& 0.5649& 0.1039& 0.5649& 0.2396 &0.1719 &0.3646& 0.7646 &0.8102& 0.8266 \\ \hline
\bf User 2 &0.9123& 0.7728& 0.3953 &0.5536 &0.1330 &0.5880 &0.6609 &0.1116 &0.5536 &0.5118 &0.1294 &0.7118& 0.8582 &0.8873& 0.8273 \\ \hline
\bf User 3 &0.8286 &0.6982 &0.5643 &0.4216 &0.1961 &0.5392 &0.5683 &0.2022 &0.4481 &0.5736 &0.2792& 0.6954& 0.7902 &0.7115 &0.7413 \\ \hline
\bf User 4 &0.8342 &0.5802 &0.4432 &0.5164 &0.0845 &0.5164& 0.5149 &0.1535& 0.3960& 0.3415 &0.0183 &0.2378 & 0.8965 &0.9279 &0.9205 \\ \hline
\bf User 5 &0.6724 &0.8114 &0.1410& 0.5291& 0.1279& 0.5756 &0.6076 &0.1266 &0.4873& 0.4969 &0.1698 &0.7610& 0.7404& 0.8769& 0.6308 \\ \hline
\bf User 6 &0.7126& 0.6713 &0.3270 &0.4859 &0.1767 &0.3735 &0.2594 &0.0879& 0.3347& 0.3527 &0.2188 &0.4955& 0.8222 &0.5573& 0.8393 \\ \hline \hline
\multicolumn{16}{c}{\bf KNN Classifier} \\ \hline \hline
\bf User 1 &0.8096 &0.8096& 0.8429& 0.6408 &0.6408& 0.1408& 0.4026& 0.4026& 0.1039& 0.2448& 0.2448 &0.1719& 0.8029& 0.8029 &0.8102\\ \hline
\bf User 2 &0.9141 &0.9141& 0.7728& 0.6438& 0.6438& 0.1330& 0.5794 &0.5794 &0.1116 &0.3235 &0.3235& 0.1294& 0.9182 &0.9182& 0.8873 \\ \hline
\bf User 3 &0.9143 &0.9143& 0.6982& 0.5931 &0.5931 &0.1961 &0.5683 &0.5683& 0.2022 &0.5381 &0.5381 &0.2792& 0.8759 &0.8759& 0.7115 \\ \hline
\bf User 4 & 0.9387 &0.9387 &0.5802& 0.4131 & 0.4131 &0.0845& 0.2574 &0.2574 &0.1535 &0.1037 &0.1037 &0.0183& 0.9593& 0.9593& 0.9279 \\ \hline
\bf User 5 &0.9733 &0.9733 &0.8114 &0.4767 &0.4767 &0.1279 &0.5380& 0.5380 &0.1266 &0.3019 &0.3019 &0.1698& 0.9231 &0.9231 &0.8769 \\ \hline
\bf User 6 &0.8176 &0.8176 &0.6713& 0.4618 &0.4618 &0.1767& 0.2008 &0.2008 &0.0879 &0.3705 &0.3705 &0.2188& 0.7726& 0.7726 &0.5573 \\ \hline \hline
\multicolumn{16}{c}{\bf SVM Classifier} \\ \hline \hline
\bf User 1 &0.9372 &0.9372& 0.6007 &0.9417& 0.9417 &0.2233 &0.7857 &0.7857& 0.5909& 0.6146& 0.6146& 0.5313& 0.9197 &0.9197 &0.8832 \\ \hline
\bf User 2 &0.9517 &0.9517& 0.9660& 0.9828 &0.9828& 0.0258 &0.8712 &0.8712 & 0.6266& 0.9059 &0.9059 &0.6882& 0.9655 &0.9655 &0.8909 \\ \hline
\bf User 3 & 0.9875 &0.9875 &0.8750& 0.8578& 0.8578& 0.1716 &0.8852 &0.8852 &0.5355& 0.9137& 0.9137& 0.6802& 0.8776 &0.8776 &0.7483
\\ \hline
\bf User 4 &0.9928 &0.9928 & 0.6883& 0.8685 &0.8685 &0.2066 &0.8861 &0.8861& 0.4208& 0.8049 &0.8049 &0.5183& 0.9778 &0.9778 &0.9482 \\ \hline
\bf User 5 &0.9867 &0.9867& 0.9543& 0.8663& 0.8663 &0.0291 &0.8291& 0.8291 &0.5886 &0.7358& 0.7358 &0.5849& 0.9654& 0.9654& 0.9000 \\ \hline
\bf User 6 &0.9639 &0.9639 &0.9466& 0.8996 &0.8996 &0.0723 &0.6820 &0.6820 &0.2176 &0.8527 &0.8527 &0.5670& 0.9573& 0.9573& 0.8256 \\ \hline \hline
\multicolumn{16}{c}{\bf Ensemble Learning-BAG Classifier} \\ \hline \hline
\bf User 1 &0.7423 &0.7240& 0.3532 &0.9194 &0.9301& 0.3888 &0.7721& 0.7825& 0.7123& 0.3219& 0.3255& 0.3906& 0.8746 &0.8611 &0.9111 \\ \hline
\bf User 2 & 0.9331 &0.9392 &0.1644 &0.9665& 0.9597& 0.7931& 0.7120 &0.7206 &0.6652 &0.8288 &0.8253 &0.7141& 0.8393 &0.8480 &0.8349 \\ \hline
\bf User 3 &0.9832& 0.9852& 0.5695& 0.7333& 0.7216 &0.6039& 0.6186& 0.6235& 0.5322& 0.8376& 0.8365& 0.7015& 0.7362 &0.7392 &0.6451 \\ \hline
\bf User 4 &0.9450 &0.9505& 0.6701 &0.7690 &0.7643 &0.3911 &0.6416 &0.6391 &0.3856 &0.2305 &0.2329 &0.1951& 0.9758& 0.9747& 0.9444 \\ \hline
\bf User 5 &0.9598 &0.9577 &0.8851& 0.7628& 0.7756 &0.1651 &0.6918 &0.6842 &0.5766 &0.7182 &0.7170 &0.7440& 0.9415 &0.9463 &0.9137 \\ \hline
\bf User 6 &0.8522 &0.8515& 0.4389& 0.6627 &0.6514 &0.2892& 0.3477 &0.3485 &0.5188 &0.7201 &0.7076 &0.4906& 0.7805 & 0.7701 &0.8487 \\ \hline \hline
\end{tabular}}
\end{table*}
\section{Conclusion}
\label{sec8}
Feature banks created by different smartphone-based physical activity recognition studies can be used for physical activity recognition on smartwatches because smartphone also uses accelerometer, gyroscope and magnetometer sensors and hence the same set of features is acceptable for a smartwatch. Decision trees, SVM and KNN showed the best results with a minor difference. Additionally, Naive Bayes and ensemble learning with Bag classifiers also produce a good performance. Furthermore, feature normalization and random permutation processes significantly improve the classification performance in several cases. In addition to above, without any doubt, changing window size affects the recognition accuracy.
From results, we observed that every activity and each classifier's results of recognition is highly correlated with window size. In general, each classifier performs well when features are extracted using 25-125 samples per window. Personal models perform better for smartwatch based physical activity recognition providing an average accuracy of 98\%. Furthermore, the impersonal model produces 94\% and 90\% accuracy respectively with the same settings of the personal model. Finally, the recommended combination for smartwatch based physical activity recognition system is decision tree classifier trained using 25-125 samples per window of normalized and randomly permuted features. In our future work, we will investigate the effects of several linear/non-linear supervised and unsupervised feature selection methods.
| {'timestamp': '2019-04-23T02:14:29', 'yymm': '1706', 'arxiv_id': '1706.01720', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01720'} | arxiv |
\section{Introduction}
\label{sec:intro}
Conversational agents can seamlessly integrate into our lives by offering a natural language interface for complex tasks.
However, the complexity of conversations with current slot-filling dialogue systems is limited.
One limitation is that the user usually cannot refer back to an earlier state in the dialogue, which is essential \textit{e.g.}, when comparing alternatives or researching a complex subject.
The recently published Frames dataset \citep{el_asri_frames_2017} provides 1369 goal-oriented human-human dialogues where the participants had to decide on a vacation package to purchase. The authors observed that in order to make up their minds, participants often compared different packages and referred to items that had been previously discussed during the dialogue. Current dialogue systems do not model the dialogue history in a way that a user can go back-and-forth between the different things that have been discussed. To address this shortcoming, \citet{el_asri_frames_2017} introduced a new task called \textit{frame tracking}. Frame tracking is an extension of the state tracking \citep{henderson_machine_2015,Williams:16b} task.
In a task-oriented dialogue system, the state tracker keeps track of the user goal. The user goal is often represented as the set of constraints that the user has (\textit{e.g.}, a budget) as well as the questions that the user has about the items presented to her by the dialogue system (\textit{e.g.}, the price of the vacation package). It is assumed that the dialogue system only needs to keep track of the last set of constraints given by the user. As a consequence, the user can change her goal during the dialogue but never come back to a previous goal. Frame tracking consists of recording all the different goals set by the user during the dialogue. This requires creating a new frame for each new user goal, which is the annotation provided with the Frames corpus.
A frame tracker needs to be able to assign each new user utterance to the frames it references. This requires understanding which frame the user is talking about and recognizing when the user changes her goal, which implies that a new frame is created. For \textit{e.g.} comparisons, multiple referenced frames need to be identified. This paper proposes a neural model that attempts to solve these tasks.
We show that the model significantly outperforms the baseline proposed by \citeauthor{el_asri_frames_2017} on all the tasks required to perform frame tracking except for when the user switches frames without specifying slots. We also provide an analysis of frame tracking. In particular, we show that our model knows what frame anaphora refer to almost 90\% of the time, and which hotel is being talked about 84.6\% of the time. On the other hand, it does not perform well on slots which tend to be repeated in many frames, such as \texttt{dst\_city} (destination city). It also has difficulties selecting the right frame among similar \texttt{offer}s introduced in the same dialogue turn.
\section{Frame Tracking: An Extension of State Tracking}
\label{sec:frametracking}
\begin{figure}
\centering
\includegraphics[width=\linewidth]{frames}
\caption{Illustration of the frame tracking task. The model must choose, for each slot, which frame it is referring to, given the set of available frames, the previous active frame (bold), and the potential new frame (marked ``(new)'').}
\label{fig:frametracking}
\end{figure}
In a goal-oriented dialogue system, the state tracker records the user goal in a semantic frame \citep{singh_optimizing_2002,raux_lets_2003,el_asri_nastia:_2014,laroche_final_2011}. The Dialogue State Tracking Challenge (DSTC) \citep{Williams:16b} defines this semantic frame with the following components:
\begin{itemize}[noitemsep]
\item User constraints: slots which have been set to a particular value by the user.
\item User requests: slots whose values the user wants to know.
\item User's search method: the user's way of searching the database (\textit{e.g.}, by constraints or alternatives).
\end{itemize}
In state tracking, when a new user constraint is set, it overwrites the previous one in the frame. In frame tracking, a new user constraint creates a new frame and thus, there are as many frames as user goals explored during the dialogue.
To deal with user goals, two components specific to this setting were added to a frame, namely:
\begin{itemize}[noitemsep]
\item User's comparison requests: user requests for this frame and one or more other frames.
\item User's binary questions: user questions with slot types and slot values for this frame and possibly one or more other frames.
\end{itemize}
The user's search method is not part of the semantic frame defined for frame tracking. In addition, a frame is also created when the wizard proposes a vacation package to the user. This type of frame contains the same components as the ones defining a user goal except that the constraints are set by the wizard and not the user. A new frame is created so that if the user wants to consider the package, it is possible to switch to this frame and consider it to be the current user goal.
An example of comparison request is ``\textit{Could you tell me which of these resorts offers free wifi?}'' and an example of binary question is ``\textit{Is this hotel in the downtown area of the city?}'' or ``\textit{Is the this trip cheaper than the previous one?}''. A user request only has a slot type, \textit{e.g.}, ``\textit{Where is this hotel?}'' whereas a binary question has a slot type and a slot value. In other words, a binary question amounts to a confirmation and a request, to an open question.
Frames was collected using a Wizard-of-Oz method (WOz, \citealp{kelley_iterative_1984,rieser_corpus_2005,wen_network-based_2016}): for each dialogue a user and a wizard were paired. The user had a set of constraints and was tasked with finding a good vacation package that fits these constraints. The wizard had access to a database of vacation packages and helped the user find a suitable package. The wizards were thus playing the role of the dialogue system.
Each dialogue turn in the dataset is annotated with the currently active frame, \textit{i.e.}, the frame that is being currently discussed. The corpus was annotated in such a way that both users and wizards could create new frames. On the wizard side, a new frame is created whenever the wizard proposes a new package to the user. However, only the user can switch the currently active frame, for instance, by asking questions about a package proposed by the wizard. The motivation is that the user should have control of the frame being discussed throughout the dialogue, the dialogue system being an assistant to the user.
\citet{el_asri_frames_2017} define the frame tracking task as follows:
\begin{example}
For each user turn $\tau$, the full dialogue history $H = \{F_1,...,F_{n_{\tau-1}}\}$ is available, where $F_i$ is a frame and $n_{\tau-1}$ is the number of frames created up to that turn. The following labels are known for the user utterance $u_\tau$ at time $\tau$: dialogue acts, slot types, and slot values. The task is to predict if a new frame is created and to predict the frame or frames that are referenced in each dialogue act. A referenced frame can be the currently active frame or a previous one.
\end{example}
This task is illustrated in \cref{fig:frametracking}. We propose a model that tries to solve this task and analyze this model's behavior on several sub-tasks.
\section{Related Work}
As discussed in the previous section, frame tracking extends state tracking from only tracking the current user goal to tracking all the user goals that occur during the dialogue.
Recently, several approaches to state tracking have attempted to model more complex behaviors than sequential slot-filling. The closest approach to ours is the Task Lineage-based Dialog State Tracking (TL-DST) setting proposed by \citet{Lee:16}. TL-DST is a framework that allows keeping track of multiple tasks across different domains. Similarly to frame tracking, \citeauthor{Lee:16} propose to learn a dynamic structure of the dialogue composed of several frames corresponding to different tasks. TL-DST encompasses several sub-tasks among which \textit{task frame parsing} which consists of assigning a set of new dialogue acts to frames. This relates to frame tracking except that they impose constraints on how a dialogue act can be assigned to a frame and a dialogue act can only reference one frame. \citet{Lee:16} trained their tracking model on datasets released for DSTC (DSTC2 and DSTC3, \citealp{Henderson:14,Henderson:14c}) because no appropriate data for the task was available at the time. With this data, they could artificially mix different tasks within one dialogue, \textit{e.g.}, looking for a restaurant and looking for a pub, but they could not study human behavior and how humans switch between tasks and frames. Besides, TL-DST allows switching between different tasks but does not allow comparisons which is an important aspect of frame tracking.
Another related approach was proposed by \citet{Perez:16}, who re-interpreted the state tracking task as a question-answering task. Their state tracker is based on a memory network \citep{weston:14} and can answer questions about the user goal at the end of the dialogue. They also propose adding other skills such as keeping a list of the constraints expressed by the user during the dialogue. This work did not attempt to formalize the different constraints as separate states to record.
Before describing our frame tracking model, we analyze the frame-switching and frame-creation behavior in Frames.
\section{Analysis of Frame References}
\label{sec:frames-analysis}
\subsection{Reasons for Referencing Other Frames}
\label{sec:frames-reasons}
The Frames dataset contains 19986 turns, among which 10407 are user turns. In 3785 (36\%) of these user turns, the active frame is changed. When the active frame is not changed, the user refers to one or more other frames in 7.5\% of the turns.
If we consider only \texttt{inform} acts\footnote{Utterances where the user informs the wizard of constraints.}, a dialogue system with a traditional
state tracker which tracks only a single semantic frame would be able to deal
with the subset of frame changes which correspond to overriding an already
established value (1684 turns or 44\% of the turns where frame changes occur).
The remaining 2102 (56\%) turns contain \texttt{switch\_frame} acts from the
user. The \texttt{switch\_frame} act indicates when a user switches from the
currently active frame to a previously-defined frame. A \texttt{switch\_frame}
act directly follows one or several vacation-package offers from the wizard in
1315 (38\%) of the frame-changing turns. In 428 turns, the user selects between
multiple offers made by the wizard and in 887 turns, she accepts a single offer
made by the wizard. A total of 787 (20\%) frame switches are made to a point in
the dialogue which is anterior to the directly preceding turn. Note that in this
work, we assume that we know the list of all previous frames at each turn of the
dialogue but a practical dialogue system should generate this list dynamically
during the dialogue. For this reason, it is crucial to also correctly interpret the
user's \texttt{inform} acts so that if a user appeals to an old frame, this
frame exists and is correctly identified.
Most of the turns where the user does not change the active frame but refers to other frames contain \texttt{request\_compare} (asking to compare different frames, 191), \texttt{negate} (98), \texttt{request} (28), and \texttt{request\_alts} (asking for another package, 17) acts.
\subsection{Examples}
\label{sec:examples}
In this section, we categorize instances of interesting frame-related user behavior and discuss the resulting requirements for a frame tracker.
\begin{itemize}[noitemsep]
\item \textbf{Switching to a frame by mentioning a slot value.} ``Oh, the Rome deal sounds much better!'', ``Can you tell me more about the Frankfurt package?'', ``I'll take the 13 day trip then!''.
For this case, we need to find which frames match the identified slot values, for instance, the destination city in the first example. Since there might be multiple matching frames, we have to incorporate recency information as well.
In addition, equivalences have to be taken into account (13 --
thirteen, September -- sept, NY -- Big Apple, etc.).
Furthermore, in some cases, we need to learn equivalences between slots. \textit{E.g.}, the user has a budget, but the wizard typically only mentions prices.
\item \textbf{Switching to a frame without referencing it directly, usually by accepting an offer explicitly or implicitly.} ``yeah tell me more!'', ``yes please'', ``Reasonable. any free wifi for the kids?''.
The difficult part here is to identify whether the user actually accepted an offer at all, which also modifies the frame if the user asks follow-up questions in the same turn like in the third example. Some users ignore irrelevant wizard offers completely.
\item \textbf{Switching to a frame using anaphora.}
``Yeah, how much does the second trip cost?'', ``When is this trip and what is the price?'', ``Give me the first option, thank you''.
This is a slightly more explicit version of the previous case, and requires additional logic to determine the referenced frame based on recency and other mentioned slot values.
\item \textbf{Implicit reference for comparisons.}
``Do these packages have different departure dates?''.
\item \textbf{Explicit reference for comparisons.}
``Can you compare the price of this and the one to the package in St. Luis?'' (sic)
\item \textbf{Creating a new frame by specifying a conflicting slot value.}
``okaaay, how about to Tijuana then?'', ``what's the cheapest you got?'', ``Can I get a longer package if I opt for economy first?''
Here, the mentioned slot values need to be explicitly compared with the ones in the current frame to identify contradicting values. The same similarities discussed in frame switching above must be considered.
The context in which the slot values occur may be crucial to decide whether this is a switch to an old frame or the creation of a new one.
\item \textbf{Creating a new frame with an explicit reference to a previous one.}
``Are there flights from Vancouver leaving around the same time from
another departure city?'', ``I'd like to also compare the prices for a trip to Kobe between the same dates.'', ``Is there a shorter trip to NY?''.
In these examples, the slots time, date, and duration depend on references to frames (the current frame and the NY frame, respectively).
\end{itemize}
\section{Frame Tracking Model}
\label{sec:methods}
In the previous section, we identified various ways employed by the users to reference past frames or create new ones. In the following sections, we describe a model for frame tracking, \textit{i.e.}, a model which takes as input the history of past frames as well as the current user utterance and the associated dialogue acts, and which outputs the frames references for each dialogue act.
\subsection{Input Encoding}
\label{sec:methods-in-enc}
Our model receives three kinds of inputs: the frames that were created before
the current turn, the current turn's user dialogue acts without frame
references, and the user's utterance. We encode these three inputs before
passing them to the network. The frames and the dialogue acts in particular are
complex data structures whose encodings are crucial for the model's performance.
\subsubsection{Text Encoding}
\label{sec:methods-text-enc}
We encode the user text as well as all the slot values by tokenizing the strings\footnote{using nltk's \texttt{TweetTokenizer}, \url{www.nltk.org}} and converting each token to letter trigrams\footnote{\textit{E.g.}, ``hello'' is converted to \#he, hel, ell, llo, lo\#}. Each trigram $t\in\mathcal T$ is represented as its index in a trainable trigram dictionary \(D_{\mathcal T}\).
\subsubsection{Frame Encoding}
\label{sec:methods-frame-enc}
We encode only the constraints stored in the set \(\mathcal F\) containing the frames created before the current turn.
In the Frames dataset, each frame \(F\in\mathcal F\) contains constraints composed of slot-value pairs, where for one slot \(s\in\mathcal S\) multiple equivalent values (\textit{e.g.}, NY and New York) and additional negated values (for instance if the user says that she does not want to go to a city proposed by the wizard) may be present. We encode a string representation of the most recent non-negated value \(v\) as described in \cref{sec:methods-text-enc}. The slot type is encoded as an index in a slot type dictionary \(D_{\mathcal S}\).
The final frame encoding is the concatenation of all slot-value pairs in the frame.
In addition to the encoded frames, we also provide two vectors to the model: a one-hot code \(f_{c}\) marking the frame that was active in the last turn (the bold frame in \cref{fig:frametracking}) and a one-hot code \(f_{n}\) marking the frame that will be added if a new frame is created by the user in this turn (the frame marked ``(new)'' in \cref{fig:frametracking}).
\subsubsection{Similarity Encoding}
\label{sec:methods-similarity-enc}
To simplify learning of plain value matching, we precompute a matrix $S_L\in \mathbb{R}^{N{\times}\mathcal F}$, which contains the normalized string edit distance of the slot values in the user act to the value of the same slot in each frame, if present.
\subsubsection{Recency Encoding}
We also provide the model with information about the history of the dialogue by
marking recently added as well as recently active frames, coded as \(h^\tau_{d}\)
and \(h^\tau_{c}\), respectively, at turn \(\tau\). For a frame \(f\) introduced or last active at turn $\tau_f$, we set
\begin{align*}
\label{eq:recent_discount}
h_\cdot^\tau(f) = \begin{cases}
0 & \text{~if~} \tau < \tau_f\\
1 & \text{~if~} \tau = \tau_f\\
\gamma h_\cdot^{\tau-1} & \textnormal{otherwise.}\\
\end{cases}
\end{align*}
\subsubsection{Act Encoding}
\label{sec:methods-act-enc}
A dialogue act in the current turn has an act name \(a\in\mathcal A\) and a number of arguments.
Each argument has a slot type \(s\in\mathcal S\) and an optional slot value \(v\).
We use a dictionary \(D_{\mathcal A}\) to assign a unique index to each act \(a\), and use the same method as described in \cref{sec:methods-frame-enc} to encode slot-value pairs.
In addition to the $N$ triples \((a,s,v)\), we encode every act
\(a\) separately, since an act may not have any arguments but still refer to a frame (cf. frame switching examples in \cref{sec:examples}).
\subsection{Output Encoding}
\label{sec:methods-out-enc}
For each triple \((a,s,v)\), our model outputs a multinomial distribution $p_{asv,F}$ over the frames \(F\in\mathcal F\).
Additionally, for each act \(a\in\mathcal A\) and frame \(F\in\mathcal F\), we determine the probability $p_{a,F}$ that $F$ is referenced by \(a\).
It can be difficult for the model to correctly predict the cases when the referenced frame is the currently active frame, especially in situations where (a) the slot values do not match and (b) the active frame was changed by an earlier act within the same turn.
To address this challenge, in the target, we replace all occurrences of the active frame with a special frame with index 0. In the example of \cref{fig:frametracking}, the value \texttt{flex=T} would point to this frame 0 since the active frame is changed by a previous value, in this case, the \texttt{budget}.
In the loss function, we do not penalize the model for confusing the active frame and the special frame except for \texttt{switch\_frame} and frame-creating \texttt{inform} acts, for which we want the model to predict the referenced frame.
During prediction, we distribute $p_{asv,0}$ over $\mathcal F$ according to the predicted active frame:
\begin{align*}
g_s & = \begin{cases}
1 & \text{if a \texttt{switch\_frame} act is present}\\
0 & \text{otherwise}
\end{cases}\\
p_{\text{new}} & = p_{asv,|\mathcal F|+1}\\
p_{asv,F} &:= p_{asv,F} +
p_{asv,0} \big(
(1-g_s) \times p_{\text{new}} \\
& +g_s \times p_{\text{switch},F}\big),
\end{align*}
where $p_{\text{switch},\cdot}$ is the distribution assigned by the model to the \texttt{switch\_frame} act.
If no new frame was predicted and no \texttt{switch\_frame} act is present, the remaining probability mass is assigned to the previously active frame.
\begin{table*}[!t]
\begin{tabu}to\linewidth{@{}X[3,l]X[2,l]X[2,l]X[1.5,l]X[l]X[l]X[l]X[l]X[l]X[l]@{}}\toprule
& \multicolumn{9}{c}{Accuracy (\%)}\\\cmidrule{2-10}
Lesion & Full Acts & Only Acts & Frames & Text & $h_c^\tau$ & $h_d^\tau$ & $f_n$ & $S_L$ & $f_c$\\\midrule
Slot-based & 58.3 & 66 & 63.7 & 74.5 & 65.4 & 78.8 & 79.5 & 64.4 & 82.7\\
Act-based & 98 & 98.3 & 93.9 & 94.2 & 89.8 & 85.8 & 90.2 & 97.1 & 92.8\\
\bottomrule
\end{tabu}
\caption{Accuracy when removing model inputs.}
\label{tbl:lesion}
\end{table*}
\begin{figure}[tbp]
\centering
\includegraphics[width=\linewidth]{schema.pdf}
\label{fig:schema}
\caption{Simplified overview of our model. $N$ triples of acts $a$ with slot-value arguments $s,v$ are matched to frames $F$ by computing a model similarity metric $S_M$. Frames are described by their constraints (slot-value pairs $s,v$). Together with the current and new frame indicators ($g_c$, $g_n$), $S_M$ represents a multinomial distribution $p_{asv,F}$ over the frames $F\in\mathcal F$. The same acts $a$ can refer to additional frames regardless of slot-value arguments, predicted in $p_{a,F}$ with the help of recency information $h^\tau$.}
\end{figure}
\subsection{Model Structure}
\label{sec:methods-model}
For each user turn, we first embed all dialogue acts \(a\), slot types \(s\), and letter trigrams \(t\) using the dictionaries \(D_{\mathcal A}\), \(D_{\mathcal S}\), and \(D_{\mathcal T}\), respectively.
We sum the letter trigram embeddings for every token to generate trigram hashes
\citep{huang_learning_2013}. A bidirectional GRU \citep{cho_properties_2014} $r_t$ over
the hashes of values and the utterance generates summary vectors for both.
The summary vector is the concatenation of the final hidden state of the forward
and backward computation.
A second bi-directional GRU \(r_{asv}\) computes a hidden activation for each of the (act, slot, value) triples in the current turn.
We compute a value summary vector $m_{asv}$ by appending each hidden state of $r_{asv}$ with the utterance embedding and projecting to a 256-dimensional space.
For the frames, we proceed in a similar manner, except that the frames do not contain dialogue acts nor an utterance, so we use a GRU $r_F$ to compute hidden states for all slot-value pairs
\begin{align}
\left(\begin{matrix}
D_{\mathcal S}[s_{1}], r_t(D_{\mathcal T}[v_{1}])\\ D_{\mathcal S}[s_{2}], r_t(D_{\mathcal T}[v_{2}])\\
\ldots\end{matrix}\right).
\end{align}
During training, the constraint order within frames is shuffled.
The final hidden of the state $r_F$ is projected to a 256-dimensional space, resulting in a frame summary vector $m_F$.
By comparing slot values $m_{asv}$ mentioned by the user to the frames $m_F$, and
taking into account the recently-active and recently-added information, we can
determine which frame the user is referencing. To this end, we compute the
dot-product between $m_{asv}$ and $m_F$, resulting in a model similarity matrix
$S_M\in\mathbb R^{N{\times}|\mathcal F|}$. It is important to have the user
utterance in the value summary vector because without it, the comparison with
the frames would only work if slot values were explicitly mentioned, which is
not true in general. Boolean values, for example, are usually only
present implicitly (\textit{cf.} \cref{sec:examples}).
We learn the weights of a linear combination of the model similarity matrix with the input $S_L$, yielding the final similarity matrix $S$.
Two special cases remain: (1) no match could be found and (2) a new frame should be created. To handle these cases, we extend $S$ with two columns corresponding to the active frame $g_c$ and the new frame $g_n$. Intuitively, $g_n$ is high if no frame matches the user turn and if there is a strong discrepancy with the active frame. On the other hand, $g_c$ is high only if no frame matches the user turn. Since again, the actual user utterance sometimes contains crucial information, we condition $g_n$ and $g_c$ on the maximum match with any frame, the match with the previously active frame, and the user utterance embedding.
For a user input triple \((a,s,v)\), the slot-based frame prediction is then computed as
\begin{align}
p_{asv} = \softmax(&g_c, S_{asv,1}, S_{asv,2}, \ldots,\\
&\nonumber S_{asv,|\mathcal F|}, g_n).
\end{align}
Finally, we determine the act-based probability of frame references $p_{a,F}$.
For every pair $(a, F)$, this probability is computed by a 2 layer densely connected network conditioned on the dialogue act, the recency information, and the user utterance embedding. We also set $p_{a, 0}$ to $1-\max_F p_{a,F}$ to produce an implicit reference to the active frame by default.
\section{Experiments}
\label{sec:exp}
\subsection{Learning Protocol and Metrics}
We train the model by splitting the dataset into 10 folds as described by \citet{el_asri_frames_2017}. For each fold, we further split the training corpus into training and validation sets by withholding a random selection of 20\% of the dialogues from training. We use the Adam \citep{kingma_adam:_2014} algorithm to minimize the sum of the loss for $p_{asv}$ and $p_{a,F}$, with a learning rate of $10^{-3}$. Learning is stopped when the minimum validation error has not changed for ten epochs. We compare our model to the simple rule-based baseline described by \citet{el_asri_frames_2017}.
For slot-based predictions ($p_{asv,F}$), we report mean accuracy over the ten folds of the Frames dataset. For act-based predictions ($p_{a,F}$), \textit{i.e.}, we determine for every act $a$ whether the ground truth set of referenced frames is equal to the predicted set of referenced frames (with a cutoff at $p_{a,F}=\frac12$), and again average accuracy scores over the ten folds.
Results are summarized in \cref{tbl:folds_perf}. Our model strongly outperforms the baseline both on references with and without slots. In particular, we observe that our model excels at predicting frame references based on acts alone, while the baseline struggles to solve this task.
\subsection{Comparison with the Baseline}
\begin{table}[!t]
\begin{tabu}to\linewidth{@{}X[1.1,l]X[l]X[l]@{}}\toprule
&\multicolumn{2}{c}{Accuracy (\%)}\\\cmidrule{2-3}
& \textbf{Ours} & \textbf{Baseline}\\\cmidrule{2-3}
Slot-based & \textbf{76.43}$\pm$4.49 & 61.32$\pm$2.19\\
Act-based & \textbf{95.66}$\pm$2.34 & 66.81$\pm$2.58\\
\bottomrule
\end{tabu}
\caption{Performance comparison between the baseline of \citet{el_asri_frames_2017} and our model.}
\label{tbl:folds_perf}
\vspace{-0.3cm}
\end{table}
\begin{table}[!t]
\begin{tabu}to\linewidth{@{}X[3.0,l]X[0.5,r]X[1.0,r]@{}}\toprule
&\multicolumn{2}{c}{Accuracy (\%)}\\\cmidrule{2-3}
&\textbf{Ours} & \textbf{Baseline}\\\cmidrule{2-3}
Frame change (new val) & 52.5 & 4.2\\
No frame change (new val) & 93.8 & 74.3\\
Frame change (no offer) & 36.4 & 22.7\\
Frame change (offer) & 67 & 62.2\\
request\_compare & 70.5 & 40.9\\
\bottomrule
\end{tabu}
\caption{Partial comparison table of performance for different dialogue settings (cf \cref{sec:frames-analysis}), including frame changes/lack of frame changes upon the introduction of new values, as well as when preceded by an offer or not, demonstrating our model's improvements over the baseline.}
\label{tbl:event_types}
\end{table}
\begin{table}[!t]
\begin{tabu}to\linewidth{@{}X[2.7,l]X[0.7,r]X[1.3,r]@{}}\toprule
&\multicolumn{2}{c}{Accuracy (\%)}\\\cmidrule{2-3}
&\textbf{Ours} & \textbf{Baseline}\\\cmidrule{2-3}
\texttt{switch\_frame(dst\_city)} & 66.1 & 21.4\\
\texttt{switch\_frame(duration)} & 52.6 & 26.3\\
\texttt{inform(seat)} & 60.0 & 36.0\\
\texttt{request(end\_date)} & 66.7 & 0.0\\
\bottomrule
\end{tabu}
\caption{Partial comparison table of act-slot combinations between our model and the baseline of \cite{el_asri_frames_2017}.}
\label{tbl:act_slot}
\end{table}
We further analyze the difference in performance between our frame tracking model and the rule-based baseline on classes of predictions on a single fold of the data. We organize the turns in the test set into 11 classes and measure performance by computing accuracy only on turns that fall into the respective class.
We first observe that the baseline model almost completely fails to identify frame changes when a new value is introduced by a user (4\% accuracy over 303 turns), frame changes associated with \texttt{switch\_frame} acts that do not have slot values, or when a \texttt{switch\_frame} act is present in a turn following one that does not contain an \texttt{offer} act. On the other hand, the baseline model predicts lacks of frame changes (74.3\% over 1111 instances) and frame changes after an \texttt{offer} (62.2\% over 312 instances) quite well.
Our model dominates the rule-based baseline on all classes except for the prediction of frame changes with \texttt{switch\_frame} acts that do not have slot values (4.2\% over 24 occurrences). Partial comparison results are presented in \cref{tbl:event_types}.
Perhaps surprisingly, our model correctly predicts 70.5\% of frames associated with \texttt{request\_compare} acts whereas the baseline only correctly identifies 40.9\% of them.
We then computed the accuracy on the set of unique act and slot combinations in
the dataset.
Here, our model outperforms the baseline on all act-slot pairs with more than 10 occurrences in the test set. We observe that the baseline performs quite poorly on \texttt{switch\_frame}s with \texttt{dst\_city} (destination city) slots, whereas our model does not have such a drawback. The same is true for a \texttt{switch\_frame} with a \texttt{duration} or for an \texttt{inform} with a \texttt{seat} (economy or business flight seat) or even a \texttt{request} with an \texttt{end\_date}. Results are presented in \cref{tbl:act_slot}. We note that our model performs worse on combinations that should express a match with a frame whose slot values use very different spellings (such as rich abbreviations and synonyms) whereas the baseline model is the weakest when slot values can be easily confused for values of other slots (\textit{e.g.} a rating of 5 (stars) vs. a duration of 5 (days)). Our model is also currently unable to distinguish between similar offers introduced in the same turn.
Code to generate the full set of metrics will be made available.
\subsection{Lesion Studies}
To assess which of the features are useful for the model, we remove the model's
inputs one at a time and measure the model's performance. Results are shown in
\cref{tbl:lesion}. We observe that the model stops learning (\textit{i.e.} its
performance does not exceed the baseline's) on the act-slot-value triples when any of
the input is removed except for the new frame history, new frame candidate, and
previous frame inputs. Similarly, the model performance suffers when the new
frame candidate, any historical data, or the frames are removed. We observe
that all the inputs are used by the model in its predictions either for
$p_{asv,F}$ or $p_{a},F$.
\section{Discussion}
\vspace*{-2mm}
Our model makes use of the text to correctly predict the frames
associated with acts. Dependence on input text means our method is
domain-dependent. The annotation process for the Frames dataset is costly, so it
would be beneficial if we could transfer learned frame switching behavior to
other domains, possibly with already existing NLU components. A possible
solution might be to standardize the text after NLU, and use anonymous
placeholders instead of domain-specific words.
Additionally, our current model assumes a perfect NLU to provide acts, slots,
and values as inputs. While this is helpful for researching the frame
referencing issues in isolation, both components should work together. For
example, currently, we assume that a \texttt{switch\_frame} act is correctly
identified, but we do not know the frame the user wants to switch to. In a more
realistic pipeline, these decisions are closely related and also need to take
more of the dialogue history into account.
\subsection{Conclusion}
In this paper, we provided a thorough analysis of user behavior concerning
switching between different user goals in the Frames dataset. Based on this
analysis, we have designed a frame tracking model that outperforms the baseline
of \citet{el_asri_frames_2017} by almost 20\% relative performance. This model
assigns the dialogue acts of a new user utterance to the semantic frames created
during the dialogue, each frame corresponding to a goal. We analyzed the
strengths and weaknesses of the rule-based baseline and of our model on
different subtasks of frame tracking. Our model outperforms the baseline on all
but one subtasks. We showed that further improvement is necessary for
matching slot values when they are present in many distinct frames. We
have demonstrated that the frame tracking task can be performed effectively by
learning from data (our model correctly identifies frame changes in about 3 out
of 4 cases). This represents a first step toward memory-enhanced dialogue
systems which understand when a user refers to an older topic in a conversation
and which provide more accurate advice by understanding the full context of a
request.
| {'timestamp': '2017-06-07T02:05:10', 'yymm': '1706', 'arxiv_id': '1706.01690', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01690'} | arxiv |
\section{Introduction}
\IEEEPARstart{T}{he} most noticeable developments foreseen in the near future in power systems involve Distribution Networks (DNs). Future DNs are expected to host a big percentage of Renewable Energy Sources (RES) and other Distributed Energy Resources (electric vehicles, flexible loads, fuel cells, batteries, etc.). Moreover, it is expected that DNs will be called upon to actively support the bulk Transmission Network (TN) participating in ancillary services with the help of Information and Communication Technologies (ICT) and advanced management and control techniques. For these reasons, the interaction between the Transmission and Distribution (T\&D) grids has become the focus in many research areas of power systems over the last years. It has drawn significant attention in the areas of voltage stability and support~\cite{Aristidou2015d, Lin2016, Ding2017}, combined system dynamic stability~\cite{TR22}, optimisation of power and reserves~\cite{Caramanis2016,Li2016}, dynamic simulations for security assessment \cite{Li2015,Aristidou2015}, and much more. This increased research interest has been coupled with an equally high number of national and international research projects, funded both by industry and governmental agencies, to define or analyse the interactions between Transmission System Operators (TSOs) and Distribution System Operators (DSOs), e.g.~\cite{TDI2,SmartNet,evolvdso}.
\subsection{Review of popular test system models}
Several test systems exist for separately studying TNs or DNs. For TN studies, the most widely used systems are the ones developed by IEEE, for power flow~\cite{dataieee, dataieee2} and transient stability studies~\cite{Ieee1992,Demetriou2015}. More specialised test system have also been proposed, for instance, the RTS-79 and RTS-96~\cite{rts96} for reliability studies, or the revised Nordic system for dynamic and voltage stability studies~\cite{PES-TR19}. Several variants of these models have been published over the years depending on the type of study and the phenomena tackled by the method being tested. Other research groups and organisations have also developed their own test systems; for example, the 150-bus synthetic system from the University of Illinois, Urbana-Champaign~\cite{uiuc150}, the 9-bus and 179-bus systems from the Western System Coordinating Council~\cite{wscc9}, used for transient stability studies~\cite{wscc9_bis,Singh2015}, and more~\cite{IEEJ,Semerow2015,CigreTFC6.04.02/TB5752014,Josz2016}.
Regarding distribution network models, a wide variety of distribution test systems have been proposed by IEEE and can be found in \cite{dn_systems}. In addition, the 33-bus and the 69-bus test systems \cite{baran1989network,baran1989optimal} have been used, among other things, to study the impact of distributed generation~\cite{Acharya2006} while the RBTS 6-bus test system has been used for reliability analysis~\cite{Wang1993}. Several other, isolated or collective, efforts have been made to prepare and make available generic DN test systems, e.g.~\cite{UKDGS,CigreTFC6.04.02/TB5752014}.
While there is an abundance of individual TN and DN systems, there is a lack of combined T\&D systems allowing to investigate the interplay between them. Such systems are required to examine the impact of active distribution networks on the TN, study various proposed methods for DNs to support the TN in steady-state or during fault dynamics, develop or validate DN equivalent models that can later be used in bulk TN stability studies, test T\&D co-optimization algorithms (for planning or operation), analyze the techniques for including DNs to power markets, and many more.
In the past, specific test systems, such as in~\cite{Aristidou2015d}, have been developed by individual researchers or groups to analyse the T\&D interactions. However, constructing such a system is a tedious task with many challenges and parameters to be selected. In addition, the data of these systems is rarely published and the customization performed to match the specific problem studied, makes them difficult to be used in other applications.
\subsection{Contributions}
In this paper, an open-source MATLAB toolbox named \emph{TDNetGen}\cite{TDNETGEN} is presented, that is able to generate large-scale T\&D network models (high and medium voltage) that can be used for a variety of studies. The generated model data can be freely modified and shared, allowing researchers to compare the performance of their algorithms against each other. \emph{TDNetGen}~allows to select several key characteristics of the generated system, such as the RES penetration, the scaling factors for loads and generators, etc. (some of these are detailed in \prettyref{sec:key_parameters}).
Based on these characteristics, \emph{TDNetGen}~generates the combined T\&D test system using the well-known Nordic TN model, detailed in~\cite{PES-TR19}, and systematically replacing the aggregated TN loads with a detailed DN model, derived from~\cite{UKDGS} and customised to accommodate increased distributed generators (DGs) penetration. The toolbox is powered by MATPOWER~\cite{Zimmerman2011}, a well-known, open-source, steady-state, planning and analysis tool. The generated models can be exported in the native MATPOWER format or custom exporters can be easily implemented to allow importing to other software.
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{nordic32}\caption{One-line diagram of the transmission network \cite{PES-TR19}}\label{fig:one_line_tn}
\end{figure}
\subsection{Paper Structure}
The remaining paper is organised as follows. In \prettyref{sec:systems}, the "template" TN and DN models that are used to generate the combined T\&D system are presented. Then, in \prettyref{sec:key_parameters}, the key parameters for selecting the characteristics of the generated system are explained and in \prettyref{sec:Methodology}, the procedure of generating the combined T\&D system is detailed. Finally, some example test cases are given in \prettyref{sec:Power-Flow-Test-Cases} followed by some concluding remarks in \prettyref{sec:conclusion}.
\section{Template test systems}\label{sec:systems}
In this section, we briefly present the TN and DN models that are combined to generate the resulting T\&D system.
The TN is based on the model documented in \cite{PES-TR19} and sketched in Fig.~\ref{fig:one_line_tn}. It is a variant of the well-known Nordic test system that has been recently revised by the IEEE Power System Dynamic Performance Committee. The system is separated into four zones: \textit{Equiv}, \textit{North}, \textit{Central}, and \textit{South}. Most of the generation is situated in the North and consists of hydropower plants. The rest of the generation, in the \textit{Central} and \textit{South} areas, consists of thermal power plants. Most of the consumption is located in the \textit{Central} and \textit{South} areas. \textit{Equiv} is an equivalent of an external system connected to the North area. In this model, the distribution networks are represented as aggregated loads (see Fig.~\ref{fig:split}, left-hand side). The TN model includes 74 buses: 32 at the transmission level, 20 are generator terminal buses, and 22 buses at the distribution level (medium voltage side of distribution transformers) where the aggregated loads are connected. It includes 102 branches, among which 22 are distribution and 20 step-up transformers.
The model used for the DNs was developed by the Centre for Sustainable Electricity and Distributed Generation (SEDG)~\cite{UKDGS}. It represents a radial 11kV urban network fed from a 33kV supply point and its one-line diagram is shown in Fig.~\ref{fig:one_line_dn}. The system has been modified to include two types of DGs and to accommodate higher loading levels. The feeders 1-4 are serving bigger consumers and the DGs connected there are considered to be controllable micro-turbines or small synchronous machines. The remaining feeders are serving residential consumers and the DGs consist of aggregate models of rooftop photovoltaic (PV) systems, thus uncontrolled and generating at their maximum power with unity power factor. Overall, the DN system includes 75 buses with 4 DGs on feeders 1-4 and 18 aggregate PV systems on the remaining feeders.
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{DN_topo}\caption{One-line diagram of the distribution network \cite{UKDGS}}\label{fig:one_line_dn}
\end{figure}
\section{Key parameters}\label{sec:key_parameters}
In this section, we present some key parameters that are used to generate the final test system. These user-defined parameters are located in the file \textit{parameters.m}, at the root of the toolbox.
\begin{itemize}
\item \emph{Penetration level}: This value defines the percentage of the active power demand to be generated by the DGs in each DN. It is defined as the ratio between the total active power injected by the DGs and the total power demand of the loads served by the DN, i.e.
\begin{equation}
PL = \frac{\sum_{i=1}^{N_{DG}} P_{DGi}}{\sum_{j=1}^{N_{Dj}} P_{D}}
\end{equation}
where $N_{DG}$ (resp. $N_{D}$) is the number of DGs (resp. loads) within the DN. It has to be noted that the penetration level is defined \textit{per DN} and not on the entire combined T\&D system. Due to the existence of loads connected at the TN level, the penetration of the combined system will be less than this value.
\item \emph{Generation Split}: This parameter defines the way of splitting the generation between the larger DGs (feeders 1-4 in Fig.~\ref{fig:one_line_dn}) and the smaller ones (feeders 5-8 in Fig.~\ref{fig:one_line_dn}). It allows assigning higher generation levels to the controllable units (feeders 1-4) or to the uncontrollable units (feeders 5-8).
\item \emph{Constant load}: This parameter defines which possible vision of the future power grid is considered for the generated T\&D system. The options are:
\begin{itemize}
\item Scenario 1 (\textit{constant load='false'}) assumes that the growth of distributed generation will outpace the growth of electricity demand in DNs. If we consider this from the TN point of view, it means that the net demand of the DNs will decrease. If the penetration level is very high, a reverse power flow can be observed from the DNs to the TN. This option modifies the TN power flows as given in~\cite{PES-TR19}.
\item Scenario 2 (\textit{constant load='true'}) assumes that the electricity demand will also increase (e.g., because of electric vehicles) alongside distributed generation. Thus, the excess demand will be covered by the DGs and the TN will see the same total demand from the DNs (hence 'constant load'). This option does not modify the TN power flows as defined in~\cite{PES-TR19}.
\end{itemize}
\item \emph{Random}: Since the same DN template is used to replace all of the TN aggregate loads, this can lead to artificial synchronisations between the various DNs. This setting allows for the parameters of the DNs (e.g., penetration level, generator split, etc.) to be slightly varied around the original values (maximum $\pm5\%$), thus introducing some diversity between DNs.
\item \emph{Large system}: In the default setting (\textit{Large system='true'}), all the loads of the original TN except the ones in the \textit{Equiv} area (on buses 71 and 72 in Fig.~\ref{fig:one_line_tn}) are systematically replaced by detailed DNs. This leads to a T\&D system of approximately 22000 buses. Alternatively, if the parameter is set to \textit{'false'}, then only the loads in the \textit{Central} area are replaced, thus leading to a T\&D system of approximately 15000 buses.
\item \emph{Oversize}: This option allows to oversize the power consumed by each DN, thus creating several security violations. This is useful when the user needs a severely congested test system to test management and operation techniques relying heavily on DGs. As a consequence of the overloading, the number of detailed DNs required to replace each TN load is decreased and consequently also the number of buses in the combined system.
\item \emph{Run OPF}: Determines if the user wants to optimise the operating point of the generated T\&D system before exporting the data. The optimisation procedure is further detailed in \prettyref{sec:OPF}.
\item \emph{Export format}: Defines the format in which the power flow data is exported (MATPOWER or a custom exporter). Two example custom exporters (one for power flow and one for time-domain dynamic simulations) are provided in \prettyref{sec:export}.
\end{itemize}
\section{Methodology}\label{sec:Methodology}
In this section, the general methodology of generating the combined T\&D system is presented. As mentioned earlier, \emph{TDNetGen}~systematically replaces the aggregated loads of the original TN system with detailed DNs, based on the template DN model presented in \prettyref{sec:systems}. The procedure is summarised here and detailed below:
\begin{enumerate}[label=\Alph*)]
\item Initialize the TN model. Compute the amount of load, per TN bus, that needs to be replaced by detailed DNs based on the \emph{Large system} parameter.
\item Initialize the template DN system and find the maximum DN capacity while avoiding voltage violations. Using the maximum DN capacity and the load per TN bus, calculate the minimum number of DNs required to replace the aggregated loads. Generate the corresponding DN models and compute their individual capacity.
\item Using the parameters \emph{Penetration level}, \emph{Generation split}, \emph{Constant load}, \emph{Random}, and \emph{Oversize}, and their capacity customize each DN operating point by scaling the load and the DGs.
\item Generate the combined T\&D system by interconnecting the models, treating the naming conventions, and ensuring continuity over the boundaries (distribution transformers).
\item \textbf{(Optional)} If the \emph{Run OPF} parameter is selected, optimise the combined T\&D system operating point to reduce generation cost and alleviate voltage problems.
\item Export the combined system data in MATPOWER format or one of the custom exporters, as selected by \emph{Export format}.
\end{enumerate}
\begin{figure}
\begin{flushleft}
\smartdiagramset{%
set color list={teal!60, teal!60, teal!60, teal!60, red!60, teal!60},
module x sep=3.0,
back arrow disabled=true,
text width=4.5cm,
additions={
additional item offset=0.5cm,
additional item border color=gray,
additional item font=\small,
additional arrow color=teal!60,
additional item text width=2.5cm,
additional item bottom color=teal!60,
additional item shadow=drop shadow,
}
}
\smartdiagramadd[flow diagram:vertical]{%
Solve the TN power flow (master), {According to the user parameters, solve the DN power flows separately (slaves)}, Replace the TN aggregated loads by DNs in parallel, Solve power flow for the entire T\&D system, Voltages within limits?, Run OPF or export results%
}{right of module4/Update turns ratio of the OLTCs}
\smartdiagramconnect{->}{additional-module1/module4}
\begin{tikzpicture}[remember picture,overlay]
\draw[additional item arrow type] (module5.east) |- ([yshift=-11mm]additional-module1.south) -- (additional-module1);
\end{tikzpicture}
\end{flushleft}
\caption{Master-slave approach for the power flow solution}
\label{fig:master_slave}
\end{figure}
\subsection{Transmission network initialization}
To decrease the complexity of the T\&D model generation, a master-slave approach is followed, illustrated in Fig. \ref{fig:master_slave}. This approach is only used for the construction of the T\&D model. Once the model is exported, the user can analyse it using standard integrated approaches (e.g., MATPOWER's standard power-flow solvers).
First, the TN model (located under \textit{input\_data/tn\_template.mat}) is loaded in MATPOWER and a power-flow solution is performed to compute the voltages at the TN load buses. Then, depending on the \textit{Large system} parameter, it is selected which TN loads will be replaced by detailed DNs. That is, either all the loads in the system will be replaced or only the ones in the Central area.
This approach allows the user to modify the TN operating point before calling \emph{TDNetGen}~in order to test different operating conditions. For instance, the parameters of the large TN generators could be modified and the TN load consumption changed to create different scenarios. However, the TN load buses and names should remain unchanged as the following procedure depends on these.
\subsection{Distribution network initialization}
In a second step, the DN template model (located in \textit{input\_data/dn\_template.mat}) is loaded into MATPOWER. The maximum capacity of the DN is calculated by gradually scaling the DN loads under constant power factor while keeping the output of the DGs to zero and making sure that the voltage constraints are not violated. Finally, if the parameter \textit{oversize} is larger than $1.0$, all the DN loads are scaled by this factor, ignoring the voltage violations.
Then, the number of DNs needed to replace each aggregated TN load (as shown in Fig.~\ref{fig:split}) is computed by dividing the TN load consumed power with the DN maximum capacity and rounding up to the nearest integer. The implicit assumptions made in this step are that i) the original TN loads are pure loads without any aggregated distributed generation, and ii) the DNs used to replace the TN loads are operating close to their maximum capacity (or oversized). Finally, using the number of DNs per TN bus, the individual DN models are generated and their load consumption is calculated.
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{aggr_load_to_DN}\caption{Aggregated TN loads replaced by detailed DNs connected in parallel on the same TN bus}\label{fig:split}
\end{figure}
Similarly to the TN model, this approach allows the user to modify the DN parameters before executing \emph{TDNetGen}. However, much of the scaling and optimisation procedure that follows relies on the exact naming conventions and topology of the DN (location of DGs), thus these should be kept for the modified system.
\subsection{Customization of distribution networks}\label{sec:DN_custom}
In this step, the created DN models are customised according to the parameters defined by the user. The amount of renewable generation is defined by the \textit{penetration level} and the DN consumption; its allocation is determined by the generation splitting parameter, which allows the user to assign more or less power to the controllable DGs in feeders 1-4. Then, if the \textit{Random} flag has been set by the user, a randomization of the DN parameters is performed to make sure that the DN models are not identical. In addition, if the \textit{constant load} parameter is set to true, the active power demand of the DN models is increased to match the introduced DGs, so that the total demand seen by the TN remains the same before and after the replacement of the TN loads by the DN models. At the end of this step, a set of DN models with the user defined characteristics is available to be integrated into the TN.
\subsection{Combined system generation}\label{sec:combined}
As mentioned previously, the integration of the DNs is achieved by replacing the aggregated TN loads by several DNs in parallel (see Fig.~\ref{fig:split}).
Before connecting the DN models to the TN, the conditions over the boundary elements (distribution transformers) need to be consistent. That is, the magnitude and angle of the high voltage bus to which the DN will be attached (shown in Fig.~\ref{fig:one_line_dn}) needs to match the voltage used for computing the DN power flows in \prettyref{sec:DN_custom}. Consequently, the angles of the other DN buses need to be adjusted accordingly.
Moreover, the distribution transformers between the TN and the DNs (see Fig.~\ref{fig:one_line_dn}) are considered to be equipped with On-Load Tap-Changing (OLTC) controllers and used to regulate the voltage of the DNs. Basically, the transformer ratio is modified in discrete steps to maintain the voltage at the low-voltage side of the transformer within some deadband as follows for the $i$-th transformer:
\begin{equation}\label{eq:OLTC}
\begin{cases}
\mbox{if } V^C_i > V^{set}_i+\frac{DB_i}{2} & r_i=r_i+1 \\
\mbox{if } V^C_i < V^{set}_i-\frac{DB_i}{2} & r_i=r_i-1
\end{cases}
\end{equation}
where $V^{set}_i$ and $DB_i$ are the controller setpoint and deadband, respectively; $V^C_i$ is the controlled voltage; and, $r_i$ is the discrete tap defining the transformer ratio.
After the customization of the DNs in \prettyref{sec:DN_custom}, the DN voltage controlled by the OLTC ($V^C_i$) might be out of the deadband and require adjusting the transformer ratio. Unfortunately, MATPOWER does not support OLTC transformers. Thus, their functionality was implemented externally with an iterative procedure: a combined T\&D power flow solution is performed, then the voltages of the DN substations are checked and the OLTC ratios adjusted accordingly. This is followed by another combined system power flow solution to update the values. This sequence is repeated until the DN voltage set-points (which can be changed by the user in \textit{parameters.m}) are reached. Some safeguards in the form of a maximum allowed changes have been implemented to avoid infinite cycling of the OLTCs.
Finally, the combined T\&D network model is generated. In the case of \textit{constant load} set to true, the TN power flows and voltages will be unchanged. Alternatively, the TN power flows will be different and at high penetration levels even reversed. Moreover, due to the integration of the DGs, there might be some voltage violations both in the DNs as well as in the TN. The latter only if \textit{constant load} is set to false.
\subsection{Operating point optimization}\label{sec:OPF}
The resulting T\&D system from the previously described procedure might lead to increased generation costs as well as voltage violations. \emph{TDNetGen}~provides the option to run an AC OPF to optimise the combined system operation and alleviate any voltage problems before exporting the data. Unlike the previous steps, this is an optional step (controlled by the \emph{Run OPF} parameter) as the users might want to implement their own OPF algorithm or test some operational schemes for alleviating voltage problems.
To optimise the operating point, the following OPF problem needs to be solved:
\begin{mini!}[2]
{\bm x,\bm c,\bm r}{f(\bm x,\bm c,\bm r)\label{eq:OPF-obj}}{\label{eq:OPF-opti}}{}
\addConstraint{\bm g(\bm x,\bm c,\bm r)=\bm 0\label{eq:OPF-Eq}}{}
\addConstraint{\bm h(\bm x,\bm c,\bm r)\leq\bm 0\label{eq:OPF-Ineq}}{}
\addConstraint{\underline{\bm c}\leq\bm c \leq \overline{\bm c}\label{eq:OPF-Ineq2}}{}
\addConstraint{\bm r=[r_1 \ldots r_i \ldots r_{nd}]\label{eq:OPF-disc}}{}
\addConstraint{r_i \in \{r_i^1 \ldots r_i^j \ldots r_i^{max}\},\,\, \forall i=1,\ldots,r_{nd}\label{eq:OPF-disc2}}{}
\end{mini!}
where $\bm x$ is the vector of state variables (i.e., voltage magnitudes and phases at all buses), $\bm c$ is an $n_c$ dimensional vector of continuous control variables (i.e., active and reactive powers of generators) and $\underline{\bm c}$ (resp. $\overline{\bm c}$) is its corresponding vector of lower (resp. upper) bounds, $r$ is an $n_d$ dimensional vector of discrete control variables (i.e., the OLTC transformer ratios), $r_i^j$ is the $j$-th discrete value of discrete variable $r_i$, $r_i^{max}$ is the number of discrete positions of the OLTC, $\bm f(\cdot)$ is the objective function, $\bm g(\cdot)$ and $\bm h(\cdot)$ are vectors of functions which model equality and inequality constraints.
\begin{figure}
\begin{flushright}
\smartdiagramset{%
uniform color list=teal!60 for 3 items,
module x sep=3.0,
back arrow distance=0.75,
text width=4cm,
additions={
additional item offset=0.5cm,
additional item border color=red,
additional arrow color=red,
additional item text width=2cm,
additional item bottom color=red!50,
additional item shadow=drop shadow,
}
}
\smartdiagramadd[flow diagram:vertical]{%
{With the OLTC setpoints ($\bm r$) frozen, solve the AC OPF problem for $\bm c$}, Update the OLTC setpoints ($\bm r$) based on \eqref{eq:OLTC}, Tighten the security constraints \eqref{eq:OPF-Ineq2}%
}{left of module1/Start: Relax security constraints,%
left of module3/Stop: Solved with final security constraints}
\smartdiagramconnect{<-}{additional-module2/module3}
\smartdiagramconnect{<-}{module1/additional-module1}
\end{flushright}
\caption{Iterative relaxation technique for the OPF solution}\label{fig:OPF-SOl}
\end{figure}
The objective function \eqref{eq:OPF-obj} is to minimise the cost of supplying the load. Only the large TN generators and the DGs located in feeders 1-4 of each DN are dispatched. That is, the PV systems in feeders 5-8 do not participate and are assumed to always operate at maximum power and unity power factor. The generator quadratic cost functions were taken from \cite{Gao2015} and \cite{Feng2014}, for the TN and DN generators respectively. Their values are defined in \textit{functions/add\_gen\_costs\_for\_OPF.m} and can be modified by the user.
The equality constraints \eqref{eq:OPF-Eq} are the AC bus power flow equations, the inequality constraints \eqref{eq:OPF-Ineq} refer to operational limits (i.e., the voltage magnitudes security constraints), the inequality constraints \eqref{eq:OPF-Ineq2} refer to physical limits of equipment (i.e., bounds on generators active/reactive powers), and the constraints \eqref{eq:OPF-disc} describe the discrete variable values of the OLTC controllers.
Efficiently solving a large-scale, mixed-integer, optimisation problem as described by \eqref{eq:OPF-opti} can be challenging. Several methods have been proposed in the literature based on the round-off strategy, using penalty terms, or several other heuristic methods (several examples can be found in \cite{Capitanescu2010,Platbrood2014} and their references). However, the focus of this paper is on providing a parametrizable, large-scale, test-system and not on developing solution techniques for OPF problems with discrete decision variables. Thus, a simple, heuristic, iterative relaxation method is employed in this work.
The procedure used in \emph{TDNetGen}~is summarised in Fig.~\ref{fig:OPF-SOl}. First, the voltage constraints \eqref{eq:OPF-Ineq} are relaxed and the discrete variables \eqref{eq:OPF-disc} are fixed constant. The latter transforms the mixed-integer OPF into a "standard AC OPF problem" that is solved with the included MATPOWER algorithm to compute an estimate of the continuous control variables $\bm c$. Based on this estimate, the discrete variables $\bm r$ are updated using the control rules of \eqref{eq:OLTC}. Finally, the security constraints are tightened and the procedure is repeated until the problem is solved with the final constraints, selected by the user, and the OLTC control rules \eqref{eq:OLTC} are satisfied.
Starting from MATPOWER version 6.0, a new tool called MOST~\cite{Sanchez2013} is also provided for optimal scheduling including uncertainty in demand and RES generation. However, this has not been tested in this work.
\subsection{Data exporters}\label{sec:export}
The final step is to export the combined system into the \textit{output\_data} folder. In the default format, \emph{TDNetGen}~exports a MATPOWER case file that can be loaded, modified, and analysed, without the need of the \emph{TDNetGen}~being present.
In addition, the toolbox allows the user to build a custom exporter to any format, depending on the simulation software used. \emph{TDNetGen}~provides two examples of custom exporters, provided in the \textit{custom\_data} folder. The first is the power flow program ARTERE developed at the University of Liege and available at \cite{ARTERE}. Compared to MATPOWER, this software includes the modelling and treatment of OLTC transformers and is computationally more efficient.
The second custom exporter is for the academic time-domain, dynamic simulation software RAMSES~\cite{Aristidou2015f}. In order to execute a dynamic simulation, the dynamic data for both the TN generators and controllers as well as the DGs, are required. For the TN, the dynamic data are taken from~\cite{PES-TR19}. For the DNs, the DGs in feeders 1-4 are modelled as small synchronous machines following~\cite{VVC13a}, while the DGs in feeders 5-8 use the distributed PV system model (PVD)~\cite{Elliott2015}. The initialization of the dynamic models takes place in RAMSES based on the operating point provided by \emph{TDNetGen}.
Using the above two examples, users can create their own exporters to a variety of software packages. One of the future developments will be the implementation of an exporter to CIM format~\cite{CIMPrimer}, to facilitate the integration of the models to other software.
\section{Example Test Cases}\label{sec:Power-Flow-Test-Cases}
In this section, we present some combined T\&D test systems generated by \emph{TDNetGen}~focusing on producing some operationally challenging test cases.
\subsection{Power-flow scenarios}
\begin{figure}
\centering
\includegraphics[trim=30 10 40 30, clip, width=1\columnwidth]{over}\caption{Over-voltages above 1.15~pu in the TN for different \textit{Penetration level} values [\textit{Constant load='false'}, \textit{Large system='true'}, \textit{Run OPF='false'}]}\label{fig:over}
\end{figure}
One of the main problems associated with increased penetration of DGs and in particular RES are possible over-voltage problems arising at high generation levels. \emph{TDNetGen}~is able to generate such scenarios by increasing the penetration level. As the penetration level increases, more buses experience over-voltages, in the DNs but also in the TN. Figure~\ref{fig:over}, shows the number of TN buses with over-voltages (above 1.15 pu) as the penetration level increases. In these scenarios, the operating point produced by \emph{TDNetGen}~is not optimised (\textit{Run OPF='false'}). If an OPF solution is selected, then the operating point can be corrected by re-dispatching the TN generators and the DGs in feeders 1-4 of each DN.
Figures~\ref{fig:pl0_20} and \ref{fig:pl25_75} show the voltage profiles at all the buses located in a specific DN for different penetration levels. In these figures, the 75 DN buses are numbered consecutively starting from feeder 1 up to 8 and from the bus closest to the DN substation to the one furthest (see Fig.~\ref{fig:one_line_dn}). The continuous curve represents the voltage profile of the DN without any DG and where the voltage set-point of the OLTC is at 1.03~pu\footnote{There is a slight variation of the actual voltage controlled by the OLTC over the different scenarios due to the effect of the deadband.}. It can be seen that as the penetration level increases, the voltage profile of the feeder is changing.
\begin{figure}
\centering
\includegraphics[trim=30 10 60 30, clip, width=1\columnwidth]{pl0_20}\caption{Voltage profile of DN for low penetration levels [\textit{Constant load='false'}, \textit{Large system='true'}, \textit{Run OPF='false'}]}\label{fig:pl0_20}
\end{figure}
\begin{figure}
\centering
\includegraphics[trim=30 10 60 30, clip, width=1\columnwidth]{pl0_150}\caption{Voltage profile of DN for high penetration levels [\textit{Constant load='false'}, \textit{Large system='true'}, \textit{Run OPF='false'}]}\label{fig:pl25_75}
\end{figure}
As the penetration level increases, the total power demand of the DNs from the TN decreases. In cases of higher than 100\% penetration, when the DGs cover the local load consumption as well as the DN losses, then a reverse power flow arises. In these extreme cases, the power flows from the DNs to the TN and it can cause voltage violations and challenge the effectiveness of existing management, control, and protection schemes. Figure~\ref{fig:rev_pf} shows the total power transferred from the TN to all the DNs for different penetration levels. It can be seen that at about 115\%, the DNs cover their own local consumption and losses and there is no power exchange with the TN. It should be noted that individual DNs might reach a reverse power flow condition at lower or higher penetration levels due to their different operating points.
\begin{figure}
\centering
\includegraphics[trim=30 80 30 10, clip, width=1\columnwidth]{reverse_PF}\caption{Power flow from the transmission to the distribution network [\textit{Constant load='false'}, \textit{Large system='true'}, \textit{Run OPF='false'}]}\label{fig:rev_pf}
\end{figure}
\subsection{A dynamic simulation scenario using RAMSES}
As explained in \prettyref{sec:export}, custom exporters can be used to translate the data into other formats used in other software than MATPOWER. One of the example exporters with the toolbox produces the data to be used in RAMSES, an academic, time-domain, dynamic simulation software~\cite{Aristidou2015f}. This simulator uses a topologically-based, domain decomposition method to partition the system into the TN and the multiple DNs. Then, it solves the sub-problems defined over each sub-domain at each discrete time instance, while treating the interface variables with a Schur-complement approach. Parallel computing techniques are employed to accelerate the system simulation.
A T\&D model was generated with the parameters \textit{Constant load='true'}, \textit{Large system='false'}, \textit{Run OPF='false'}, \textit{Penetration level=50\%}, \textit{Oversize=2.0}. The data was exported into RAMSES format, leading to a system with 141 DNs in the Central area, with a total of 10782 buses, 20 large (connected to the TN) and 564 small synchronous generators (connected to the DN feeders 1-4), 2538 distributed PV systems (connected to the DN feeders 5-8), and 10595 voltage-dependent loads. The considered disturbance is a 5-cycle (100~ms) short-circuit near bus 4032, cleared by opening line 4032-4042. The response is simulated over a horizon of 250~s with a time-step of 1 cycle (20~ms).
This scenario leads to a long-term voltage collapse driven by the load-power restoration caused by the OLTCs restoring the DN voltages. Figure~\ref{fig:ramsesTN} shows the evolution of the TN voltages while Fig.~\ref{fig:ramsesDN} shows the DN voltages at the buses in a DN attached to the TN bus 1041. More information on the analysis, instability detection and corrective control of such unstable scenarios in combined T\&D systems is given in \cite{Aristidou2015d}.
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{TNbusvolt2}\caption{Voltages at various TN buses during the dynamic simulation}\label{fig:ramsesTN}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{DNbusvolt01a2}\caption{Voltages at various DN buses within the same DN during the dynamic simulation}\label{fig:ramsesDN}
\end{figure}
\subsection{Computational cost of \emph{TDNetGen}}
Depending on the choice of parameters, the run-time to generate the T\&D system can vary significantly. However, this is a cost occurred only once to generate the test system, which can then be used independently of \emph{TDNetGen}. The most computationally intensive task is the OPF solution of the system to optimise the operating point (if selected). Table~\ref{tab:cpu} shows the average execution times to generate a T\&D system\footnote{Acquired on a MacBook Pro laptop with 2.2GHz Intel Core i7, 16GB of RAM, using MATLAB 2015a and MATPOWER 6.0} as well as the average number of times the OLTC setpoints are updated during an execution. The overall execution time does not exceed 4 minutes, using a standard laptop computer.
\begin{table}
\caption{Average computational cost of different \emph{TDNetGen} ~operations}\label{tab:cpu}
\begin{center}
\begin{tabular}{l l l}
\hline
Operation & Run-time & OLTC updates\\
\hline
Power Flow & 30 seconds & 22\\
Optimal Power Flow & 200 seconds & 3\\
Export data & 15 seconds & -\\
\hline
\end{tabular}
\end{center}
\end{table}
\section{Conclusion}\label{sec:conclusion}
In this paper, an open-source MATLAB toolbox was presented, that is able to generate synthetic large-scale T\&D network test cases. These models can be used to develop or test solutions targeting problems specific to combined T\&D systems (optimisation, market clearing, system security, ancillary services by DNs, etc.). The toolbox is based on the widely used MATPOWER software and uses the well-known Nordic system as the TN upon which the combined T\&D system is built. \emph{TDNetGen}~is highly parametrizable, allowing to generate models with a variety of characteristics, replicating common problems in systems with high penetration of RES. In addition, medium- ($\sim 10000$ buses) to large-scale ($\sim 22000$ buses) test-system models can be produced, allowing to test the scalability of algorithms proposed by the users. Moreover, the model data can be shared among researchers to provide a common testing platform.
Finally, the open-source nature of the toolbox allows the users to expand the code, adding new functionality, or building custom export functions to import the generated models into their own software. The latest version of the toolbox can be found at \cite{TDNETGEN}.
\section*{Acknowledgment}
\addcontentsline{toc}{section}{Acknowledgment}
The authors would like to thank Prof Thierry Van Cutsem for the valuable input in the development of the toolbox and Gilles Chaspierre for being the first user of the toolbox and identifying several bugs.
\bibliographystyle{IEEEtran}
| {'timestamp': '2017-11-15T02:08:08', 'yymm': '1706', 'arxiv_id': '1706.01656', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01656'} | arxiv |
\section{Introduction}
\label{seq1}
Nowadays, Cloud computing allows data owners to use massive data storage and large computation capabilities at a very low costs. Despite these benefits, such a data outsourcing induces important security challenges. Indeed, data owners lose the control over the pieces of information they outsource. To protect data in terms of confidentiality and privacy from unauthorized users as well as from the cloud, one common solution consists in encrypting data. However, if using encryption achieves data confidentiality, it may limit the possible reuse or processing of outsourced data as well as the sharing of data. In this work, we are interested in the sharing of data between different users who have outsourced their data encrypted with their own public keys, i.e. using some asymmetric cryptosystem. Such a kind of problem is referred as proxy re-encryption (PRE) \cite{blaze1998divertible}, where Alice (the delegator or the emitter) wants to share with Bob (the delegate or recipient) some data she previously outsourced encrypted into the cloud (the proxy). When working with asymmetric encryption, the objective of PRE is to securely enable the proxy to re-encrypt Alice's cipher-text, encrypted with her public key, into a cipher-text that can be decrypted with Bob's private key. To do so, one simple PRE solution consists in asking Alice to provide her private key to the proxy. However, this strategy imposes the proxy to be completely trusted and does not work in the case the cloud is considered as semi-honest (i.e., it will not disclose the data but will be curious). Blaze \textit{et al}. \cite{blaze1998divertible} proposed the first PRE scheme in such a semi-honest framework. This one is based on the ElGamal cryptosystem and on a set of secret pieces of information, referred as secret re-encryption key, Alice has to send to the proxy so as to make possible the change of the public key encryption (i.e., re-encrypt data with Bob's public key). One main issue of this proposal, remarked by Ateniese \textit{et al}. \cite{ateniese2006improved}, is that Blaze \textit{et al}.'s scheme is inherently bidirectional, that is to say that the re-encryption key which allows transferring cipher-texts from Alice to Bob, enables the proxy to convert all Bob's cipher-texts under Alice's public key. This is not acceptable for Bob. The main reason of this is that the re-encryption key depends on the delegate (Bob) private key. In order to solve this problem and achieve a unidirectional PRE different approaches have been proposed. The first class of methods relies on classical asymmetric encryption cryptosystems. For instance, \cite{jakobsson1999quorum} take advantage of a quorum-based protocol which stands on distributed proxies, each of them possesses a part of the data of Alice but receive a different re-encryption key independent of Bob private key. However, with this approach, the security of Alice private key is safe as long as some proxies are honest. An alternative, proposed in \cite{dodis2003proxy}, works with only one proxy where the re-encryption key provided by Alice is split into two parts, one for the proxy and the other for Bob. Unfortunately, with \cite{dodis2003proxy}, the data of Alice, she encrypted with her public-key are turned into symmetrically encrypted data and not asymmetrically with the public key of Bob. The second class regroups methods referred as identity-based proxy re-encryption (IBPRE) and was introduced by Green and Ateniese \cite{green2007identity}. Such a method mixes PRE with identity-based cryptography (IBC). In IBC, the public encryption key of one user is derived from his identity (e.g., his email address); by combining it with PRE, the emitter and the proxy just need to know the delegates' identities instead of verifying their certificates. Basically, the unidirectional propriety is achieves due to the fact the re-encryption key depends on the identity of the delegate. However, it must be known that IB-PRE suffers of the key-escrow issue (see \cite{dodis2003proxy} for more details). Most of these schemes also rely on cryptosystems which are based on bilinear pairing \cite{han2013identity, chu2007identity, matsuo2007proxy, liang2009attribute, xu2016conditional}, an application considered as a very expensive in terms of computation complexity compared to modular multiplication or exponentiation \cite{baek2005certificateless}. To overcome this issue, Deng \textit{et al}. \cite{deng2008chosen} proposed an asymmetric cross-cryptosystem re-encryption scheme instead of pairing.
Beyond, if the above approaches allow one user to share data with another one, they do not make possible the processing of encrypted data by the cloud or proxy. This capacity is usually achieved with the help of homomorphic cryptosystems. With these ones, one can perform operations onto encrypted data with the guarantee that the decrypted result equals the one carried out onto un-encrypted data \cite{rivest1978data}. The first homomorphic based PRE attempt has been proposed by Bresson \textit{et al}. in \cite{bresson2003simple}, using the Paillier cryptosystem \cite{paillier1999public}. However, even though their solution makes possible data sharing, it cannot be seen as a pure proxy re-encryption scheme. Indeed, data are not re-encrypted with the public key of the delegate. If this one wants to ask the cloud to process the data he receives from Alice, he has: i) first to download Alice data, ii) decrypt them based on some secret pieces of information provided by Alice; iii) re-encrypt them with his public key and send them back to the cloud. There is thus still a need for a homomorphic based PRE.
In this work, we propose the first homomorphic proxy re-encryption scheme which does not require the delegate to re-upload the data another user has shared with him. It is based on the Paillier cryptosystem. It can be roughly summarized as follows. Bob and Alice agree on a secret key; key Alice sends Paillier encrypted to the cloud. The cloud uses this key so as to generate a Paillier encrypted random sequence with the help of a secure linear congruential generator (SLCG) we propose and which works in the Paillier encrypted domain. All computations are conducted by the cloud server. This SLCG provides a sequence of Paillier encrypted random numbers. Based on a fast and new solution we propose so as to compute the difference in-between Paillier encrypted data, the cloud: i) computes in clear the difference between this encrypted random sequence and the encrypted data of Alice and, ii) encrypts this sequence of differences with the public key of Bob. Then, Bob just has to ask the cloud to remove the noise from the encrypted data in order to get access to the data Alice wants to share with him and process them in an outsourced manner if he wants.
The rest of the paper is organized as follow. In Section \ref{seq2}, we come back on the definition of Paillier cryptosystem and show how to use it in order to: i) quickly compute the difference between Paillier encrypted data; and ii) implement a secure linear congruential generator so as to generate an encrypted random sequence. Section \ref{seq3} describes the overall architecture of our Homomorphic PRE solution (HPRE) in the case of the sharing of images. Performance of the proposed solution is given in Section \ref{seq4}. Conclusions are given in Section \ref{seq6}.
\section{Processing Paillier Encrypted Data}
\label{seq2}
In this section, we first introduce the Paillier cryptosystem as well as a new way to compute the difference between Paillier encrypted data before presenting a secure linear congruential generator (LCG) implemented in the Paillier encrypted domain so as to generate an encrypted pseudo random sequence of integers.
\subsection{Paillier cryptosystem}
\label{sseq2:1}
We opted for the asymmetric Paillier cryptosystem because of its additive homomorphic property \cite{paillier1999public}. In this work, we use a fast version of it defined as follows. Let $((g,K_p), K_s)$ be the public/private key pair, such as:
\begin{equation}
K_p = pq \quad and \quad K_s= (p-1)(q-1)
\label{eq1}
\end{equation}
where $p$ and $q$ are two large prime integers. $\mathbb{Z}_{K_p}= \{0, 1,..., K_p-1\}$ and $\mathbb{Z}_{K_p}^*$ denotes the integers that have multiplicative inverses modulo $K_p$. We select $g\in\mathbb{Z}_{K_p^2}^*$ such as:
\begin{equation}
\frac{g^{K_s}-1 \, mod\, K_p^2}{K_p} \in \mathbb{Z}_{K_p}^*
\label{eq2}
\end{equation}
The Paillier encryption of a plain-text $m\in\mathbb{Z}_{K_p}$ into the cipher-text $c\in\mathbb{Z}_{K_p^2}^*$ using the public key $K_p$ is given by
\begin{equation}
c= E[m,r]= g^m r^{K_p} \mod K_p^2
\label{eq3}
\end{equation}
where $r \in \mathbb{Z}_{K_p}^*$ is a random integer associated to $m$ making the Paillier cryptosystem probabilistic or semantically secure. More clearly, depending on the value of $r$, the encryption of the same plain-text message will yield to different cipher-texts even though the public encryption key is the same. Notice that it is possible to get a fast version of~\eqref{eq3} by fixing $g=1+K_p$ without reducing the algorithm security. By doing so, the encryption of $m$ into $c$ requires only one modular exponentiation and two modular multiplications
\begin{equation}
c=E[m,r]=(1+mK_p)r^{K_p} \mod K_p^2
\label{eq4}
\end{equation}
As we will see in section \ref{sseq2:2}, this property will be of importance for the computation of the difference between Paillier encrypted data.\\
Based on the assumption $g=1+K_p$, the decryption of $c$ using the private Key $K_s$ is such as
\begin{equation}
m=\frac{(c^{K_s}-1)K_s^{-1} \mod K_p^2}{K_p} \mod K_p
\label{eq5}
\end{equation}
If we consider two plain-texts $m_1$ and $m_2$, the additive homomorphic property of the Paillier cryptosystem allows linear operations on encrypted data like addition and multiplication, ensuring that
\begin{equation}
E[m_1,r_1]E[m_2,r_2] = E[m_1+m_2, r_1r_2]
\label{eq6}
\end{equation}
\begin{equation}
E[m_1,r_1]^{m_2} = E[m_1 m_2, r_1^{m_2}]
\label{eq7}
\end{equation}
\subsection{Computing the difference in-between encrypted data}
\label{sseq2:2}
In this work, we propose a solution that allows the calculation by one server of the difference between two Paillier encrypted data. More clearly if $a$ and $b$ are two integers, we want to compute their difference $a-b$ from their encrypted versions.
Let us consider a user-server relationship where the server has two cipher-texts $E_{K_p}[a,r]$ and $E_{K_p}[b,r]$ encrypted by the user. It is important to notice that to make such computation possible; the two cipher-texts have to be encrypted with the same random value $r$. Under this constraint, one can directly derive the difference $d$ between $a$ and $b$ from $E_{K_p}[a,r]$ and $E_{K_p}[b,r]$ by taking advantage of the fast Paillier cryptosystem assumption, i.e. $g=1+K_p$, as follows
$$\begin{array}{ccc}
d & = & D(a,b) =D^e(E_{K_p}[a, r], E_{K_p}[b, r]) \\[.3cm]
& = & \frac{E_{K_p}[a,r]E_{K_p}[b,r]^{-1}-1 \mod K_p^2}{K_p} \mod K_p \\[.3cm]
& = & \frac{g^a r g^{-b}r^{-1}-1 \mod K_p^2}{K_p} \mod K_p \\[.3cm]
& = & \frac{g^{a-b} -1 \mod K_p^2}{K_p} \mod K_p \\[.3cm]
d & = & a- b \mod K_p
\end{array}$$
\begin{equation}
\label{eq8}
\end{equation}
where $D$ and $D^e$ denote the two functions that allows computing the difference $d$ in the clear and Paillier encrypted domain, respectively. Notice that knowing the difference $d$ between $a$ and $b$ gives no clues about the values of $a$ and $b$, respectively.
\subsection{Secure Linear Congruential Generator}
\label{sseq2:3}
As stated in the introduction, our HPRE scheme will require the cloud to securely generate a pseudo random sequence that is to say a Paillier encrypted random sequence of integers.
The generator we propose to secure is LCG \cite{l1999tables} (Linear Congruential Generator). This one is based on congruence and a linear functions; functions that can be easily implemented in the Paillier encrypted domain.
In the clear domain, LCG works as follows
\begin{equation}
X_{n+1} = a X_n + c \mod m
\label{eq9}
\end{equation}
where: $X_n$ is the $n^{th}$ random integer value of the LCG sequence; $a$ is a multiplier; $c$ is an increment; $m$ is the modulo; and, $X_0$ the initial term, also called the seed or the secret LCG key, one needs to know so as to re-generate a random sequence. The security of the LCG is based on the seed $X_0$. The knowledge of the parameters $a$, $c$ and $m$ does not endanger its security \cite{l1999tables}.
This random generator can be implemented into the Paillier encrypted domain, i.e. turned into a Secure LCG (SLCG), so as to generate an encrypted random sequence of integers (i.e. $\{E[X_n,r_n ]\}_{n=0...N-1}$) in the following way :
\begin{equation}
E[X_{n+1},r_{n+1}]=E[X_n,r_n ]^a E[c,r_c] =E[a X_n+c,r_n^ar_c]
\label{eq10}
\end{equation}
under the constraint however that $m$ equals the user Paillier public key $K_p$, (i.e., $m = K_p$, see ~\eqref{eq1}).
If the increment as well as all terms of the sequence are encrypted (including the LCG seed) that is not the case of the multiplier $a$. However, this does not reduce the security of our system as the parameter $a$ is not supposed to be secret \cite{l1999tables}.
It is important to notice that, in our SLCG, a recursive relation exists between the random integers $r_n$ which ensure the semantic security of the Paillier cryptosystem. Derived from ~\eqref{eq10}, this one is such as:
\begin{equation}
r_{n+1}= r_n^a r_c
\label{eq11}
\end{equation}
where $r_c$ is the random variable used to encrypt the increment. $r_0$ is the random value associated to the seed $X_0$. This recursive relationship will be considered in Section \ref{sseq3:2} so as to allow data exchange between two different users.
\begin{figure}[!t]
\centering
\includegraphics[scale=.5]{image/sharing.png}
\caption{General framework for data sharing through public-cloud}
\label{fig1}
\end{figure}
\begin{figure*}[t]
\begin{center}
\includegraphics[width=0.9\textwidth]{image/diagram3.png}
\end{center}
\caption{Main steps of our HPRE for an image sharing}
\label{fig2}
\end{figure*}
\section{Sharing outsourced encrypted data}
\label{seq3}
In this Section, we first refine the data exchange framework we consider and its basic security assumptions. We then present our Homomorphic based Proxy Re-Encryption scheme (HPRE).
\subsection{Data exchange scenario in outsourced environment}
\label{sseq3:1}
Fig. \ref{fig1} illustrates the general data exchange framework we consider where a data owner (the emitter or the delegator) has \textit{a priori} stored his data into a public cloud in an asymmetrically encrypted form; data he wants to share with another user (the recipient or the delegate). We further assume a semi-honest cloud server. This one honestly stores encrypted data uploaded by the users and responds to their requests. If the server does not disclose data to any parties who fail to prove ownership or access rights, it is however curious and may try to infer information about the content of users' data or about their private keys. One last assumption is that all communications between the server and the users are protected with the help of the Paillier cryptosystem. Eavesdroppers cannot infer messages being transmitted.
As stated previously, our objective is to allow them to share some data under the constraint the delegator does not have to download his data, re-encrypt them with the public key of the delegate and upload them into the cloud. We also want this process conducted by the cloud (proxy) without giving the delegator private key as well as with very few communications in-between the delegator, the proxy and the delegate. In our idea, if one user wants to share data with several users at once, all of them will have to agree on a single secret with the delegator.
\subsection{Secure data exchange between users}
\label{sseq3:2}
Let us thus consider that Alice (the delegator) wants to share with Bob (the delegate) a set of data she is the owner of. These data could be a set of integer values like for instance a gray-scale image $I$, the $N$ pixels of which $I=\{I_i\}_{i=0..N-1}$ are encoded on $b$ bits.
As stated previously, it is assumed that Alice has already outsourced an image into the cloud by Paillier encrypting its pixels independently with her public key $K_{p1}$, such as (see in Fig. \ref{fig2} – Data outsourcing step)
\begin{equation}
I_i^e=E_{K_{p1}}[I_i,r_i]
\label{eq12}
\end{equation}
where $r_i$ is the random value associated to the $i^{th}$ pixel $I_i$ of $I$, $I_i^e$ is the encrypted version of $I_i$. As we will see in the sequel, our HPRE procedure imposes a constraint on the way Alice generates the random values $\{r_i\}_{i=0..N-1}$. These ones should satisfy ~\eqref{eq11}, that is to say that for one file Alice stores into the cloud, she has to memorize the first random value $r_c$ and $r_0$ she used when she encrypted the first pixel of her image (or of any files she stored), $I_0^e=E_{K_{p1}}[I_0,r_0]$.
In order to share this encrypted image with Bob, the public Paillier encryption key of whom is $K_{p2}$, we propose the following HPRE procedure also depicted in Fig. \ref{fig2}
\begin{enumerate}
\item \textbf{User agreement for data exchange} - In this first tsep, Bob and Alice have to agree on the exchange by defining the LCG parameters, in other words: the secret key $X_0$, the multiplier $a$ and the increment $c$. Let us recall that knowing $c$ and $a$ is not critical from a security point of view (see Section \ref{sseq2:3}).
\item \textbf{Secret random sequence generation} - Alice encrypts $X_0$ and $c$ under her public key $K_{p1}$: $E_{K_{p1}}[X_0,r_0]$ $E_{K_{p1}}[c,r_c]$, and sends them to the cloud. Notice that $X_0$ is encrypted with the same random integer $r_0$ Alice used to encrypt the first pixel of her image (see above). She also sends the multiplier $a$. Based on these pieces of information, the cloud generates the secret random sequence $X^e=\{X_i^e=E_{K_{p1}}[X_i,r_i]\}_{i=0..N-1}$ using ~\eqref{eq10}.
\item \textbf{Data encryption for the delegator} - This procedure relies on different stages: i) the computation of differences between the encrypted data of Alice $(I^e)$ and the secret random sequence $(X^e)$; ii) the encryption of this differences with the public key of Bob $K_{p2}$.
\begin{enumerate}
\item \textit{Difference computation} - since $X_i^e$ and $I_i^e$ have been encrypted with the same public key $K_{p1}$ and the same random values $r_i$ (see above), the cloud computes their difference $D_i$ as exposed in see Section \ref{sseq2:2}, that is to say
\begin{equation}
\begin{small}
\begin{array}{ccc}
D_i & = &D(X_i,I_i )=D^e(E_{K_{p1}}[X_i,r_i],E_{K_{p1}}[I_i,r_i ]) \\
• & = & X_i-I_i \mod K_{p1}
\end{array}
\end{small}
\label{eq13}
\end{equation}
Even though the cloud knows $D=\{D_i\}_{i=0...N-1}$, it cannot deduce the value of $I_i$ and $X_i$.
\item \textit{Data encryption for the delegator} - From this stand point, one may think the cloud just has to encrypt $D$ with the public key of Bob, $K_{p2}$, and then remove the noise so as so to give him access to the data. This is possible under the constraint $D_i \mod K_{p1} = D_i \mod K_{p2}$ which is achieved when $0<D_i<min(K_{p1}, K_{p2})$. Unfortunately, this constraint is hard to satisfy because of the SLCG the output amplitude of which can not be controlled simply. To overcome this issue, our HPRE includes a "noise refreshment procedure" (see Fig. \ref{fig2}) before encrypting the data with the public key of Bob.
\begin{itemize}
\item Noise refreshment
\end{itemize}
To refresh the noise, Bob first generates on his side the sequence $\{X_i\}_{i=0..N-1}$, using an LCG parameterized as the SLGC of the cloud.
He also produces a second noise $\{\beta_i\}_{i=0..N-1}$ such as:
\begin{equation}
2^b-1<\beta_i<\min(K_{p1},K_{p2})
\label{eq14}
\end{equation}
where $b$ is the number of bits on which is encoded the pixel values of the image of Alice. Under such a constraint: we ensure: $\beta_i \mod K_{p1}= \beta_i \mod K_{p2}$ and $\beta_i-I_i \mod K_{p1}= \beta_i-I_i \mod K_{p2}$.
Then Bob sends to the cloud $\{E_{K_{p2}}[\beta_i,r_i']\}_{i=0...N-1}$ and $\{\alpha_i=\beta_i-X_i \mod K_{p1}\}_{i=0..N-1}$. Where $r_i'$ is a random value defined by Bob.
On its side, in order to remove the noise $\{X_i\}_{i=0...N-1 }$, the cloud computes
\begin{equation}
G_i=\alpha_i+D_i \mod K_{p1}=\beta_i-I_i \mod K_{p1}
\label{eq15}
\end{equation}
Then it encrypts $\{G_i\}_{i=0..N-1}$ with the public key of Bob
\begin{equation}
\{E_{K_{p2}}[G_i,r_i'']=E_{K_{p2}}[\beta_i-I_i,r_i'']\}_{i=0..N-1}
\label{eq16}
\end{equation}
Finally, in order to remove the noise $\beta_i$ from of the data of Bob, the server computes
\begin{equation}
E_{K_{p2}}[I_i,r_i' r_{i}^{''-1}]=E_{K_{p2}}[\beta_i,r_i']E_{K_{p2}}[\beta_i-I_i,r_i'']^{-1}
\label{eq17}
\end{equation}
\end{enumerate}
At the end of this procedure, Bob has on the cloud the image of Alice encrypted with his own public key.
\end{enumerate}
As depicted, this system allows the data exchange between Alice and Bob, without extra-communication between the cloud and Alice, and the downloading of data by Bob. It is also possible to notice that the access to the shared data is based on the knowledge of the secret SLCG key $X_0$ generated by Alice in agreement with Bob. Because our scheme is based on homormophic encryption, data can be by next processed by the cloud without endangering data confidentiality.
\begin{table*}[t]
\renewcommand{\arraystretch}{1.5}
\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline
Entities & Delegator (Alice) & Proxy (Cloud) & Delegate (Bob) \\
\hline
Time computation (sec) & 0.002 & 90 & 30\\
\hline
Encrypted data volume of & 0 & 22986753 & 2048 \\
\hline
\end{tabular}
\end{center}
\caption{Amount of information stored (in bits) as well as the corresponding computation time that each entity needs (Alice, Bob and the cloud) for sharing an image of $92\times 122$ pixels}
\label{tab1}
\end{table*}
\begin{figure}[!t]
\centering
\includegraphics[scale=.5]{image/face.PNG}
\caption{Samples of face database}
\label{fig3}
\end{figure}
\section{Experimental results}
\label{seq4}
The previous solution was experimented in the case of the sharing of uncompressed images between two users. These images are issued from the Olivetti Research Laboratory of Cambridge, UK. It contains $400$ images of $8$ bit encoded of $92\times 122$ pixels. Some samples of our image test set are given Fig. \ref{fig3}. These images were encrypted with Paillier public keys of more than $1024$ bits in order to provide a high level of security.
Performance of our scheme are evaluated in terms of storage and computation complexity. Our HPRE was implemented in C/C++ with GMP library and all experiments were conducted using a machine equipped with $23$GB RAM running on Ubuntu $14.04$ LTS.
\begin{itemize}
\item Storage complexity:
\end{itemize}
Assuming that images are Paillier encrypted with a key of $1024$ bits, one encrypted image needs $2,7Mo$ so as to be stored into the cloud.
For one image the delegator (Alice) outsources, she only has to store on her side the random values $r_0$ and $r_c$. However this is not obligation. Indeed, based on the fact she knows both her public and private keys, she just has to download the encrypted seed $E_{K_{p1}}[X_0,r_0]$ and the encrypted increment $E_{K_{p1}}[c,r_c]$, to get access to these random values (i.e. $r_c$ and $r_0$).
During an image exchange, the delegator sends the encrypted seed $E_{K_{p1}} [X_0,r_0]$, the encrypted increment $E_{K_{p1}}[c,r_c]$ and the multiplier $a$. This amount of data is bounded by $O(log_2(K_{p1}^2))$. For a key of $1024$ bits, it is closed to $2048$ bits. On its side, the delegate (Bob) has to store $X_0$, the secret key of the LCG, but only for one session of data exchange.
\begin{itemize}
\item Computation complexity:
\end{itemize}
On the delegator side, the computation complexity is limited to the encryption of the SLCG parameters (i.e. $X_0$, $c$). Such a complexity is independent of the image's size.
Regarding the cloud, this one has to compute: the secret random sequence, compute the difference between the encrypted date of Alice with this random sequence, refresh the noise based on the inputs of Bob, encrypt the result with the public key of Bob and finally remove the noise. For an image of $N$ pixels, the secret random sequence generation is equivalent to $N$ encryptions. It is the same for the computation of the differences $\{D_i\}_{i=0...N-1}$. As described above, the noise refreshment procedure consists in modular additions. We consider its complexity negligible compared to encryption operations. The last step, the encryption of the differences $\{G_i\}_{i=0...N-1}$ is made of $N$ encryptions. As a consequence, the computation complexity for the cloud is bounded by $O(3\times N)$ encryptions.
The delegate computation complexity is attached to the noise refreshment procedure. He has to generate a LCG noise (i.e. $\{X_i\}_{i=0...N-1}$), a task the complexity of which is negligible compared to the $N$ encryptions of the second noise (i.e. $\{\beta_i\}_{i=0...N-1}$) he also produces and that he next sends to the cloud. The computation complexity of the delegate is thus of $N$ encryptions.
We provide in Table \ref{tab1} the amount of data that each entities has to store as well as the computation time required in the case of sharing images of our data set. Our HPRE scheme takes about $1'30$ minutes so as to share an image with a standard computer.
\section{Conclusion}
\label{seq6}
In this paper, we proposed the first homomorphic proxy re-encryption scheme. Its originality stands on a solution we propose so as to compute the difference of data encrypted with the fast version of the Paillier cryptosystem. It takes also advantage of a secure linear congruential generator we implemented in the Paillier encrypted domain. This one drastically reduces the computation complexity of the cloud and delegator. Furthermore, this solution doesn't need extra communication between the cloud and the delegator, i.e. the data owner. Moreover, since the data are homomorphically encrypted, it is possible to process outsourced data while ensuring their confidentiality. Our HPRE was implemented in the case of the sharing of uncompressed images stored in the cloud showing good time computation performance. Our scheme is not limited to images and can be used with any kinds of data.
\bibliographystyle{IEEEtran}
| {'timestamp': '2017-06-07T02:06:39', 'yymm': '1706', 'arxiv_id': '1706.01756', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01756'} | arxiv |
\section*{Abstract (Not appropriate in this style!)}%
\else \small
\begin{center}{\bf Abstract\vspace{-.5em}\vspace{\z@}}\end{center}%
\quotation
\fi
}%
}{%
}%
\@ifundefined{endabstract}{\def\endabstract
{\if@twocolumn\else\endquotation\fi}}{}%
\@ifundefined{maketitle}{\def\maketitle#1{}}{}%
\@ifundefined{affiliation}{\def\affiliation#1{}}{}%
\@ifundefined{proof}{\def\proof{\noindent{\bfseries Proof. }}}{}%
\@ifundefined{endproof}{\def\endproof{\mbox{\ \rule{.1in}{.1in}}}}{}%
\@ifundefined{newfield}{\def\newfield#1#2{}}{}%
\@ifundefined{chapter}{\def\chapter#1{\par(Chapter head:)#1\par }%
\newcount\c@chapter}{}%
\@ifundefined{part}{\def\part#1{\par(Part head:)#1\par }}{}%
\@ifundefined{section}{\def\section#1{\par(Section head:)#1\par }}{}%
\@ifundefined{subsection}{\def\subsection#1%
{\par(Subsection head:)#1\par }}{}%
\@ifundefined{subsubsection}{\def\subsubsection#1%
{\par(Subsubsection head:)#1\par }}{}%
\@ifundefined{paragraph}{\def\paragraph#1%
{\par(Subsubsubsection head:)#1\par }}{}%
\@ifundefined{subparagraph}{\def\subparagraph#1%
{\par(Subsubsubsubsection head:)#1\par }}{}%
\@ifundefined{therefore}{\def\therefore{}}{}%
\@ifundefined{backepsilon}{\def\backepsilon{}}{}%
\@ifundefined{yen}{\def\yen{\hbox{\rm\rlap=Y}}}{}%
\@ifundefined{registered}{%
\def\registered{\relax\ifmmode{}\r@gistered
\else$\m@th\r@gistered$\fi}%
\def\r@gistered{^{\ooalign
{\hfil\raise.07ex\hbox{$\scriptstyle\rm\RIfM@\expandafter\text@\else\expandafter\mbox\fi{R}$}\hfil\crcr
\mathhexbox20D}}}}{}%
\@ifundefined{Eth}{\def\Eth{}}{}%
\@ifundefined{eth}{\def\eth{}}{}%
\@ifundefined{Thorn}{\def\Thorn{}}{}%
\@ifundefined{thorn}{\def\thorn{}}{}%
\def\TEXTsymbol#1{\mbox{$#1$}}%
\@ifundefined{degree}{\def\degree{{}^{\circ}}}{}%
\newdimen\theight
\@ifundefined{Column}{\def\Column{%
\vadjust{\setbox\z@=\hbox{\scriptsize\quad\quad tcol}%
\theight=\ht\z@\advance\theight by \dp\z@\advance\theight by \lineskip
\kern -\theight \vbox to \theight{%
\rightline{\rlap{\box\z@}}%
\vss
}%
}%
}}{}%
\@ifundefined{qed}{\def\qed{%
\ifhmode\unskip\nobreak\fi\ifmmode\ifinner\else\hskip5\p@\fi\fi
\hbox{\hskip5\p@\vrule width4\p@ height6\p@ depth1.5\p@\hskip\p@}%
}}{}%
\@ifundefined{cents}{\def\cents{\hbox{\rm\rlap c/}}}{}%
\@ifundefined{tciLaplace}{\def\tciLaplace{\ensuremath{\mathcal{L}}}}{}%
\@ifundefined{tciFourier}{\def\tciFourier{\ensuremath{\mathcal{F}}}}{}%
\@ifundefined{textcurrency}{\def\textcurrency{\hbox{\rm\rlap xo}}}{}%
\@ifundefined{texteuro}{\def\texteuro{\hbox{\rm\rlap C=}}}{}%
\@ifundefined{euro}{\def\euro{\hbox{\rm\rlap C=}}}{}%
\@ifundefined{textfranc}{\def\textfranc{\hbox{\rm\rlap-F}}}{}%
\@ifundefined{textlira}{\def\textlira{\hbox{\rm\rlap L=}}}{}%
\@ifundefined{textpeseta}{\def\textpeseta{\hbox{\rm P\negthinspace s}}}{}%
\@ifundefined{miss}{\def\miss{\hbox{\vrule height2\p@ width 2\p@ depth\z@}}}{}%
\@ifundefined{vvert}{\def\vvert{\Vert}}{
\@ifundefined{tcol}{\def\tcol#1{{\baselineskip=6\p@ \vcenter{#1}} \Column}}{}%
\@ifundefined{dB}{\def\dB{\hbox{{}}}}{
\@ifundefined{mB}{\def\mB#1{\hbox{$#1$}}}{
\@ifundefined{nB}{\def\nB#1{\hbox{#1}}}{
\@ifundefined{note}{\def\note{$^{\dag}}}{}%
\defLaTeX2e{LaTeX2e}
\ifx\fmtnameLaTeX2e
\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
\DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf}
\DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}
\DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit}
\DeclareOldFontCommand{\sl}{\normalfont\slshape}{\@nomath\sl}
\DeclareOldFontCommand{\sc}{\normalfont\scshape}{\@nomath\sc}
\fi
\def\alpha{{\Greekmath 010B}}%
\def\beta{{\Greekmath 010C}}%
\def\gamma{{\Greekmath 010D}}%
\def\delta{{\Greekmath 010E}}%
\def\epsilon{{\Greekmath 010F}}%
\def\zeta{{\Greekmath 0110}}%
\def\eta{{\Greekmath 0111}}%
\def\theta{{\Greekmath 0112}}%
\def\iota{{\Greekmath 0113}}%
\def\kappa{{\Greekmath 0114}}%
\def\lambda{{\Greekmath 0115}}%
\def\mu{{\Greekmath 0116}}%
\def\nu{{\Greekmath 0117}}%
\def\xi{{\Greekmath 0118}}%
\def\pi{{\Greekmath 0119}}%
\def\rho{{\Greekmath 011A}}%
\def\sigma{{\Greekmath 011B}}%
\def\tau{{\Greekmath 011C}}%
\def\upsilon{{\Greekmath 011D}}%
\def\phi{{\Greekmath 011E}}%
\def\chi{{\Greekmath 011F}}%
\def\psi{{\Greekmath 0120}}%
\def\omega{{\Greekmath 0121}}%
\def\varepsilon{{\Greekmath 0122}}%
\def\vartheta{{\Greekmath 0123}}%
\def\varpi{{\Greekmath 0124}}%
\def\varrho{{\Greekmath 0125}}%
\def\varsigma{{\Greekmath 0126}}%
\def\varphi{{\Greekmath 0127}}%
\def{\Greekmath 0272}{{\Greekmath 0272}}
\def\FindBoldGroup{%
{\setbox0=\hbox{$\mathbf{x\global\edef\theboldgroup{\the\mathgroup}}$}}%
}
\def\Greekmath#1#2#3#4{%
\if@compatibility
\ifnum\mathgroup=\symbold
\mathchoice{\mbox{\boldmath$\displaystyle\mathchar"#1#2#3#4$}}%
{\mbox{\boldmath$\textstyle\mathchar"#1#2#3#4$}}%
{\mbox{\boldmath$\scriptstyle\mathchar"#1#2#3#4$}}%
{\mbox{\boldmath$\scriptscriptstyle\mathchar"#1#2#3#4$}}%
\else
\mathchar"#1#2#3#
\fi
\else
\FindBoldGroup
\ifnum\mathgroup=\theboldgroup
\mathchoice{\mbox{\boldmath$\displaystyle\mathchar"#1#2#3#4$}}%
{\mbox{\boldmath$\textstyle\mathchar"#1#2#3#4$}}%
{\mbox{\boldmath$\scriptstyle\mathchar"#1#2#3#4$}}%
{\mbox{\boldmath$\scriptscriptstyle\mathchar"#1#2#3#4$}}%
\else
\mathchar"#1#2#3#
\fi
\fi}
\newif\ifGreekBold \GreekBoldfalse
\let\SAVEPBF=\pbf
\def\pbf{\GreekBoldtrue\SAVEPBF}%
\@ifundefined{theorem}{\newtheorem{theorem}{Theorem}}{}
\@ifundefined{lemma}{\newtheorem{lemma}[theorem]{Lemma}}{}
\@ifundefined{corollary}{\newtheorem{corollary}[theorem]{Corollary}}{}
\@ifundefined{conjecture}{\newtheorem{conjecture}[theorem]{Conjecture}}{}
\@ifundefined{proposition}{\newtheorem{proposition}[theorem]{Proposition}}{}
\@ifundefined{axiom}{\newtheorem{axiom}{Axiom}}{}
\@ifundefined{remark}{\newtheorem{remark}{Remark}}{}
\@ifundefined{example}{\newtheorem{example}{Example}}{}
\@ifundefined{exercise}{\newtheorem{exercise}{Exercise}}{}
\@ifundefined{definition}{\newtheorem{definition}{Definition}}{}
\@ifundefined{mathletters}{%
\newcounter{equationnumber}
\def\mathletters{%
\addtocounter{equation}{1}
\edef\@currentlabel{\arabic{equation}}%
\setcounter{equationnumber}{\c@equation}
\setcounter{equation}{0}%
\edef\arabic{equation}{\@currentlabel\noexpand\alph{equation}}%
}
\def\endmathletters{%
\setcounter{equation}{\value{equationnumber}}%
}
}{}
\@ifundefined{BibTeX}{%
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}}{}%
\@ifundefined{AmS}%
{\def\AmS{{\protect\usefont{OMS}{cmsy}{m}{n}%
A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}}}{}%
\@ifundefined{AmSTeX}{\def\AmSTeX{\protect\AmS-\protect\TeX\@}}{}%
\def\@@eqncr{\let\@tempa\relax
\ifcase\@eqcnt \def\@tempa{& & &}\or \def\@tempa{& &}%
\else \def\@tempa{&}\fi
\@tempa
\if@eqnsw
\iftag@
\@taggnum
\else
\@eqnnum\stepcounter{equation}%
\fi
\fi
\global\@ifnextchar*{\@tagstar}{\@tag}@false
\global\@eqnswtrue
\global\@eqcnt\z@\cr}
\def\@ifnextchar*{\@TCItagstar}{\@TCItag}{\@ifnextchar*{\@TCItagstar}{\@TCItag}}
\def\@TCItag#1{%
\global\@ifnextchar*{\@tagstar}{\@tag}@true
\global\def\@taggnum{(#1)}%
\global\def\@currentlabel{#1}}
\def\@TCItagstar*#1{%
\global\@ifnextchar*{\@tagstar}{\@tag}@true
\global\def\@taggnum{#1}%
\global\def\@currentlabel{#1}}
\def\QATOP#1#2{{#1 \atop #2}}%
\def\QTATOP#1#2{{\textstyle {#1 \atop #2}}}%
\def\QDATOP#1#2{{\displaystyle {#1 \atop #2}}}%
\def\QABOVE#1#2#3{{#2 \above#1 #3}}%
\def\QTABOVE#1#2#3{{\textstyle {#2 \above#1 #3}}}%
\def\QDABOVE#1#2#3{{\displaystyle {#2 \above#1 #3}}}%
\def\QOVERD#1#2#3#4{{#3 \overwithdelims#1#2 #4}}%
\def\QTOVERD#1#2#3#4{{\textstyle {#3 \overwithdelims#1#2 #4}}}%
\def\QDOVERD#1#2#3#4{{\displaystyle {#3 \overwithdelims#1#2 #4}}}%
\def\QATOPD#1#2#3#4{{#3 \atopwithdelims#1#2 #4}}%
\def\QTATOPD#1#2#3#4{{\textstyle {#3 \atopwithdelims#1#2 #4}}}%
\def\QDATOPD#1#2#3#4{{\displaystyle {#3 \atopwithdelims#1#2 #4}}}%
\def\QABOVED#1#2#3#4#5{{#4 \abovewithdelims#1#2#3 #5}}%
\def\QTABOVED#1#2#3#4#5{{\textstyle
{#4 \abovewithdelims#1#2#3 #5}}}%
\def\QDABOVED#1#2#3#4#5{{\displaystyle
{#4 \abovewithdelims#1#2#3 #5}}}%
\def\tint{\msi@int\textstyle\int}%
\def\tiint{\msi@int\textstyle\iint}%
\def\tiiint{\msi@int\textstyle\iiint}%
\def\tiiiint{\msi@int\textstyle\iiiint}%
\def\tidotsint{\msi@int\textstyle\idotsint}%
\def\toint{\msi@int\textstyle\oint}%
\def\tsum{\mathop{\textstyle \sum }}%
\def\tprod{\mathop{\textstyle \prod }}%
\def\tbigcap{\mathop{\textstyle \bigcap }}%
\def\tbigwedge{\mathop{\textstyle \bigwedge }}%
\def\tbigoplus{\mathop{\textstyle \bigoplus }}%
\def\tbigodot{\mathop{\textstyle \bigodot }}%
\def\tbigsqcup{\mathop{\textstyle \bigsqcup }}%
\def\tcoprod{\mathop{\textstyle \coprod }}%
\def\tbigcup{\mathop{\textstyle \bigcup }}%
\def\tbigvee{\mathop{\textstyle \bigvee }}%
\def\tbigotimes{\mathop{\textstyle \bigotimes }}%
\def\tbiguplus{\mathop{\textstyle \biguplus }}%
\newtoks\temptoksa
\newtoks\temptoksb
\newtoks\temptoksc
\def\msi@int#1#2{%
\def\@temp{{#1#2\the\temptoksc_{\the\temptoksa}^{\the\temptoksb}}
\futurelet\@nextcs
\@int
}
\def\@int{%
\ifx\@nextcs\limits
\typeout{Found limits}%
\temptoksc={\limits}%
\let\@next\@intgobble%
\else\ifx\@nextcs\nolimits
\typeout{Found nolimits}%
\temptoksc={\nolimits}%
\let\@next\@intgobble%
\else
\typeout{Did not find limits or no limits}%
\temptoksc={}%
\let\@next\msi@limits%
\fi\fi
\@next
}%
\def\@intgobble#1{%
\typeout{arg is #1}%
\msi@limits
}
\def\msi@limits{%
\temptoksa={}%
\temptoksb={}%
\@ifnextchar_{\@limitsa}{\@limitsb}%
}
\def\@limitsa_#1{%
\temptoksa={#1}%
\@ifnextchar^{\@limitsc}{\@temp}%
}
\def\@limitsb{%
\@ifnextchar^{\@limitsc}{\@temp}%
}
\def\@limitsc^#1{%
\temptoksb={#1}%
\@ifnextchar_{\@limitsd}{\@temp
}
\def\@limitsd_#1{%
\temptoksa={#1}%
\@temp
}
\def\dint{\msi@int\displaystyle\int}%
\def\diint{\msi@int\displaystyle\iint}%
\def\diiint{\msi@int\displaystyle\iiint}%
\def\diiiint{\msi@int\displaystyle\iiiint}%
\def\didotsint{\msi@int\displaystyle\idotsint}%
\def\doint{\msi@int\displaystyle\oint}%
\def\dsum{\mathop{\displaystyle \sum }}%
\def\dprod{\mathop{\displaystyle \prod }}%
\def\dbigcap{\mathop{\displaystyle \bigcap }}%
\def\dbigwedge{\mathop{\displaystyle \bigwedge }}%
\def\dbigoplus{\mathop{\displaystyle \bigoplus }}%
\def\dbigodot{\mathop{\displaystyle \bigodot }}%
\def\dbigsqcup{\mathop{\displaystyle \bigsqcup }}%
\def\dcoprod{\mathop{\displaystyle \coprod }}%
\def\dbigcup{\mathop{\displaystyle \bigcup }}%
\def\dbigvee{\mathop{\displaystyle \bigvee }}%
\def\dbigotimes{\mathop{\displaystyle \bigotimes }}%
\def\dbiguplus{\mathop{\displaystyle \biguplus }}%
\if@compatibility\else
\RequirePackage{amsmath}
\fi
\def\makeatother\endinput{\makeatother\endinput}
\bgroup
\ifx\ds@amstex\relax
\message{amstex already loaded}\aftergroup\makeatother\endinput
\else
\@ifpackageloaded{amsmath}%
{\if@compatibility\message{amsmath already loaded}\fi\aftergroup\makeatother\endinput}
{}
\@ifpackageloaded{amstex}%
{\if@compatibility\message{amstex already loaded}\fi\aftergroup\makeatother\endinput}
{}
\@ifpackageloaded{amsgen}%
{\if@compatibility\message{amsgen already loaded}\fi\aftergroup\makeatother\endinput}
{}
\fi
\egroup
\typeout{TCILATEX defining AMS-like constructs in LaTeX 2.09 COMPATIBILITY MODE}
\let\DOTSI\relax
\def\RIfM@{\relax\ifmmode}%
\def\FN@{\futurelet\next}%
\newcount\intno@
\def\iint{\DOTSI\intno@\tw@\FN@\ints@}%
\def\iiint{\DOTSI\intno@\thr@@\FN@\ints@}%
\def\iiiint{\DOTSI\intno@4 \FN@\ints@}%
\def\idotsint{\DOTSI\intno@\z@\FN@\ints@}%
\def\ints@{\findlimits@\ints@@}%
\newif\iflimtoken@
\newif\iflimits@
\def\findlimits@{\limtoken@true\ifx\next\limits\limits@true
\else\ifx\next\nolimits\limits@false\else
\limtoken@false\ifx\ilimits@\nolimits\limits@false\else
\ifinner\limits@false\else\limits@true\fi\fi\fi\fi}%
\def\multint@{\int\ifnum\intno@=\z@\intdots@
\else\intkern@\fi
\ifnum\intno@>\tw@\int\intkern@\fi
\ifnum\intno@>\thr@@\int\intkern@\fi
\int
\def\multintlimits@{\intop\ifnum\intno@=\z@\intdots@\else\intkern@\fi
\ifnum\intno@>\tw@\intop\intkern@\fi
\ifnum\intno@>\thr@@\intop\intkern@\fi\intop}%
\def\intic@{%
\mathchoice{\hskip.5em}{\hskip.4em}{\hskip.4em}{\hskip.4em}}%
\def\negintic@{\mathchoice
{\hskip-.5em}{\hskip-.4em}{\hskip-.4em}{\hskip-.4em}}%
\def\ints@@{\iflimtoken@
\def\ints@@@{\iflimits@\negintic@
\mathop{\intic@\multintlimits@}\limits
\else\multint@\nolimits\fi
\eat@
\else
\def\ints@@@{\iflimits@\negintic@
\mathop{\intic@\multintlimits@}\limits\else
\multint@\nolimits\fi}\fi\ints@@@}%
\def\intkern@{\mathchoice{\!\!\!}{\!\!}{\!\!}{\!\!}}%
\def\plaincdots@{\mathinner{\cdotp\cdotp\cdotp}}%
\def\intdots@{\mathchoice{\plaincdots@}%
{{\cdotp}\mkern1.5mu{\cdotp}\mkern1.5mu{\cdotp}}%
{{\cdotp}\mkern1mu{\cdotp}\mkern1mu{\cdotp}}%
{{\cdotp}\mkern1mu{\cdotp}\mkern1mu{\cdotp}}}%
\def\RIfM@{\relax\protect\ifmmode}
\def\RIfM@\expandafter\text@\else\expandafter\mbox\fi{\RIfM@\expandafter\RIfM@\expandafter\text@\else\expandafter\mbox\fi@\else\expandafter\mbox\fi}
\let\nfss@text\RIfM@\expandafter\text@\else\expandafter\mbox\fi
\def\RIfM@\expandafter\text@\else\expandafter\mbox\fi@#1{\mathchoice
{\textdef@\displaystyle\f@size{#1}}%
{\textdef@\textstyle\tf@size{\firstchoice@false #1}}%
{\textdef@\textstyle\sf@size{\firstchoice@false #1}}%
{\textdef@\textstyle \ssf@size{\firstchoice@false #1}}%
\glb@settings}
\def\textdef@#1#2#3{\hbox{{%
\everymath{#1}%
\let\f@size#2\selectfont
#3}}}
\newif\iffirstchoice@
\firstchoice@true
\def\Let@{\relax\iffalse{\fi\let\\=\cr\iffalse}\fi}%
\def\vspace@{\def\vspace##1{\crcr\noalign{\vskip##1\relax}}}%
\def\multilimits@{\bgroup\vspace@\Let@
\baselineskip\fontdimen10 \scriptfont\tw@
\advance\baselineskip\fontdimen12 \scriptfont\tw@
\lineskip\thr@@\fontdimen8 \scriptfont\thr@@
\lineskiplimit\lineskip
\vbox\bgroup\ialign\bgroup\hfil$\m@th\scriptstyle{##}$\hfil\crcr}%
\def\Sb{_\multilimits@}%
\def\endSb{\crcr\egroup\egroup\egroup}%
\def\Sp{^\multilimits@}%
\let\endSp\endSb
\newdimen\ex@
\ex@.2326ex
\def\rightarrowfill@#1{$#1\m@th\mathord-\mkern-6mu\cleaders
\hbox{$#1\mkern-2mu\mathord-\mkern-2mu$}\hfill
\mkern-6mu\mathord\rightarrow$}%
\def\leftarrowfill@#1{$#1\m@th\mathord\leftarrow\mkern-6mu\cleaders
\hbox{$#1\mkern-2mu\mathord-\mkern-2mu$}\hfill\mkern-6mu\mathord-$}%
\def\leftrightarrowfill@#1{$#1\m@th\mathord\leftarrow
\mkern-6mu\cleaders
\hbox{$#1\mkern-2mu\mathord-\mkern-2mu$}\hfill
\mkern-6mu\mathord\rightarrow$}%
\def\overrightarrow{\mathpalette\overrightarrow@}%
\def\overrightarrow@#1#2{\vbox{\ialign{##\crcr\rightarrowfill@#1\crcr
\noalign{\kern-\ex@\nointerlineskip}$\m@th\hfil#1#2\hfil$\crcr}}}%
\let\overarrow\overrightarrow
\def\overleftarrow{\mathpalette\overleftarrow@}%
\def\overleftarrow@#1#2{\vbox{\ialign{##\crcr\leftarrowfill@#1\crcr
\noalign{\kern-\ex@\nointerlineskip}$\m@th\hfil#1#2\hfil$\crcr}}}%
\def\overleftrightarrow{\mathpalette\overleftrightarrow@}%
\def\overleftrightarrow@#1#2{\vbox{\ialign{##\crcr
\leftrightarrowfill@#1\crcr
\noalign{\kern-\ex@\nointerlineskip}$\m@th\hfil#1#2\hfil$\crcr}}}%
\def\underrightarrow{\mathpalette\underrightarrow@}%
\def\underrightarrow@#1#2{\vtop{\ialign{##\crcr$\m@th\hfil#1#2\hfil
$\crcr\noalign{\nointerlineskip}\rightarrowfill@#1\crcr}}}%
\let\underarrow\underrightarrow
\def\underleftarrow{\mathpalette\underleftarrow@}%
\def\underleftarrow@#1#2{\vtop{\ialign{##\crcr$\m@th\hfil#1#2\hfil
$\crcr\noalign{\nointerlineskip}\leftarrowfill@#1\crcr}}}%
\def\underleftrightarrow{\mathpalette\underleftrightarrow@}%
\def\underleftrightarrow@#1#2{\vtop{\ialign{##\crcr$\m@th
\hfil#1#2\hfil$\crcr
\noalign{\nointerlineskip}\leftrightarrowfill@#1\crcr}}}%
\def\qopnamewl@#1{\mathop{\operator@font#1}\nlimits@}
\let\nlimits@\displaylimits
\def\setboxz@h{\setbox\z@\hbox}
\def\varlim@#1#2{\mathop{\vtop{\ialign{##\crcr
\hfil$#1\m@th\operator@font lim$\hfil\crcr
\noalign{\nointerlineskip}#2#1\crcr
\noalign{\nointerlineskip\kern-\ex@}\crcr}}}}
\def\rightarrowfill@#1{\m@th\setboxz@h{$#1-$}\ht\z@\z@
$#1\copy\z@\mkern-6mu\cleaders
\hbox{$#1\mkern-2mu\box\z@\mkern-2mu$}\hfill
\mkern-6mu\mathord\rightarrow$}
\def\leftarrowfill@#1{\m@th\setboxz@h{$#1-$}\ht\z@\z@
$#1\mathord\leftarrow\mkern-6mu\cleaders
\hbox{$#1\mkern-2mu\copy\z@\mkern-2mu$}\hfill
\mkern-6mu\box\z@$}
\def\qopnamewl@{proj\,lim}{\qopnamewl@{proj\,lim}}
\def\qopnamewl@{inj\,lim}{\qopnamewl@{inj\,lim}}
\def\mathpalette\varlim@\rightarrowfill@{\mathpalette\varlim@\rightarrowfill@}
\def\mathpalette\varlim@\leftarrowfill@{\mathpalette\varlim@\leftarrowfill@}
\def\mathpalette\varliminf@{}{\mathpalette\mathpalette\varliminf@{}@{}}
\def\mathpalette\varliminf@{}@#1{\mathop{\underline{\vrule\@depth.2\ex@\@width\z@
\hbox{$#1\m@th\operator@font lim$}}}}
\def\mathpalette\varlimsup@{}{\mathpalette\mathpalette\varlimsup@{}@{}}
\def\mathpalette\varlimsup@{}@#1{\mathop{\overline
{\hbox{$#1\m@th\operator@font lim$}}}}
\def\stackunder#1#2{\mathrel{\mathop{#2}\limits_{#1}}}%
\begingroup \catcode `|=0 \catcode `[= 1
\catcode`]=2 \catcode `\{=12 \catcode `\}=12
\catcode`\\=12
|gdef|@alignverbatim#1\end{align}[#1|end[align]]
|gdef|@salignverbatim#1\end{align*}[#1|end[align*]]
|gdef|@alignatverbatim#1\end{alignat}[#1|end[alignat]]
|gdef|@salignatverbatim#1\end{alignat*}[#1|end[alignat*]]
|gdef|@xalignatverbatim#1\end{xalignat}[#1|end[xalignat]]
|gdef|@sxalignatverbatim#1\end{xalignat*}[#1|end[xalignat*]]
|gdef|@gatherverbatim#1\end{gather}[#1|end[gather]]
|gdef|@sgatherverbatim#1\end{gather*}[#1|end[gather*]]
|gdef|@gatherverbatim#1\end{gather}[#1|end[gather]]
|gdef|@sgatherverbatim#1\end{gather*}[#1|end[gather*]]
|gdef|@multilineverbatim#1\end{multiline}[#1|end[multiline]]
|gdef|@smultilineverbatim#1\end{multiline*}[#1|end[multiline*]]
|gdef|@arraxverbatim#1\end{arrax}[#1|end[arrax]]
|gdef|@sarraxverbatim#1\end{arrax*}[#1|end[arrax*]]
|gdef|@tabulaxverbatim#1\end{tabulax}[#1|end[tabulax]]
|gdef|@stabulaxverbatim#1\end{tabulax*}[#1|end[tabulax*]]
|endgroup
\def\align{\@verbatim \frenchspacing\@vobeyspaces \@alignverbatim
You are using the "align" environment in a style in which it is not defined.}
\let\endalign=\endtrivlist
\@namedef{align*}{\@verbatim\@salignverbatim
You are using the "align*" environment in a style in which it is not defined.}
\expandafter\let\csname endalign*\endcsname =\endtrivlist
\def\alignat{\@verbatim \frenchspacing\@vobeyspaces \@alignatverbatim
You are using the "alignat" environment in a style in which it is not defined.}
\let\endalignat=\endtrivlist
\@namedef{alignat*}{\@verbatim\@salignatverbatim
You are using the "alignat*" environment in a style in which it is not defined.}
\expandafter\let\csname endalignat*\endcsname =\endtrivlist
\def\xalignat{\@verbatim \frenchspacing\@vobeyspaces \@xalignatverbatim
You are using the "xalignat" environment in a style in which it is not defined.}
\let\endxalignat=\endtrivlist
\@namedef{xalignat*}{\@verbatim\@sxalignatverbatim
You are using the "xalignat*" environment in a style in which it is not defined.}
\expandafter\let\csname endxalignat*\endcsname =\endtrivlist
\def\gather{\@verbatim \frenchspacing\@vobeyspaces \@gatherverbatim
You are using the "gather" environment in a style in which it is not defined.}
\let\endgather=\endtrivlist
\@namedef{gather*}{\@verbatim\@sgatherverbatim
You are using the "gather*" environment in a style in which it is not defined.}
\expandafter\let\csname endgather*\endcsname =\endtrivlist
\def\multiline{\@verbatim \frenchspacing\@vobeyspaces \@multilineverbatim
You are using the "multiline" environment in a style in which it is not defined.}
\let\endmultiline=\endtrivlist
\@namedef{multiline*}{\@verbatim\@smultilineverbatim
You are using the "multiline*" environment in a style in which it is not defined.}
\expandafter\let\csname endmultiline*\endcsname =\endtrivlist
\def\arrax{\@verbatim \frenchspacing\@vobeyspaces \@arraxverbatim
You are using a type of "array" construct that is only allowed in AmS-LaTeX.}
\let\endarrax=\endtrivlist
\def\tabulax{\@verbatim \frenchspacing\@vobeyspaces \@tabulaxverbatim
You are using a type of "tabular" construct that is only allowed in AmS-LaTeX.}
\let\endtabulax=\endtrivlist
\@namedef{arrax*}{\@verbatim\@sarraxverbatim
You are using a type of "array*" construct that is only allowed in AmS-LaTeX.}
\expandafter\let\csname endarrax*\endcsname =\endtrivlist
\@namedef{tabulax*}{\@verbatim\@stabulaxverbatim
You are using a type of "tabular*" construct that is only allowed in AmS-LaTeX.}
\expandafter\let\csname endtabulax*\endcsname =\endtrivlist
\def\endequation{%
\ifmmode\ifinner
\iftag@
\addtocounter{equation}{-1}
$\hfil
\displaywidth\linewidth\@taggnum\egroup \endtrivlist
\global\@ifnextchar*{\@tagstar}{\@tag}@false
\global\@ignoretrue
\else
$\hfil
\displaywidth\linewidth\@eqnnum\egroup \endtrivlist
\global\@ifnextchar*{\@tagstar}{\@tag}@false
\global\@ignoretrue
\fi
\else
\iftag@
\addtocounter{equation}{-1}
\eqno \hbox{\@taggnum}
\global\@ifnextchar*{\@tagstar}{\@tag}@false%
$$\global\@ignoretrue
\else
\eqno \hbox{\@eqnnum
$$\global\@ignoretrue
\fi
\fi\fi
}
\newif\iftag@ \@ifnextchar*{\@tagstar}{\@tag}@false
\def\@ifnextchar*{\@TCItagstar}{\@TCItag}{\@ifnextchar*{\@TCItagstar}{\@TCItag}}
\def\@TCItag#1{%
\global\@ifnextchar*{\@tagstar}{\@tag}@true
\global\def\@taggnum{(#1)}%
\global\def\@currentlabel{#1}}
\def\@TCItagstar*#1{%
\global\@ifnextchar*{\@tagstar}{\@tag}@true
\global\def\@taggnum{#1}%
\global\def\@currentlabel{#1}}
\@ifundefined{tag}{
\def\@ifnextchar*{\@tagstar}{\@tag}{\@ifnextchar*{\@tagstar}{\@tag}}
\def\@tag#1{%
\global\@ifnextchar*{\@tagstar}{\@tag}@true
\global\def\@taggnum{(#1)}}
\def\@tagstar*#1{%
\global\@ifnextchar*{\@tagstar}{\@tag}@true
\global\def\@taggnum{#1}}
}{}
\def\tfrac#1#2{{\textstyle {#1 \over #2}}}%
\def\dfrac#1#2{{\displaystyle {#1 \over #2}}}%
\def\binom#1#2{{#1 \choose #2}}%
\def\tbinom#1#2{{\textstyle {#1 \choose #2}}}%
\def\dbinom#1#2{{\displaystyle {#1 \choose #2}}}%
\makeatother
\endinput
\section{Introduction}
In a multi-object scenario the number of objects and their individual states
evolve in time, compounded by false detections, misdetections and
measurement origin uncertainty \cite{BSF88, BP99, Mah07, mahler2014advances}%
. For example, in the video dataset KITTI-17 from KITTI datasets \cite{Geiger2012CVPR}, see
Fig. \ref{fig:videosam2}, the number of objects varies with time due to
objects coming in and out of the scene, and the detector (e.g. background
subtraction, foreground modelling \cite{Elgammaletal02}) used to convert
each image into point measurements, invariably misses objects in the scene
as well as generating false measurements or clutter.
Knowledge of parameters for uncertainty sources such as clutter and
detection profile are of critical importance in Bayesian multi-object
filtering, arguably, more so than the measurement noise model. Most
multi-object tracking techniques are built on the assumption that
multi-object system model parameters are known a priori, which is generally
not the case in practice \cite{BSF88, BP99, Mah07, mahler2014advances}.
Significant mismatches in clutter and detection model parameters inevitably
result in erroneous estimates. For the video tracking example in Fig. \ref%
{fig:videosam2} the clutter rate and detection profile are not known and
have to be guessed before a multi-object tracker can be applied. The
tracking performance of the Bayes optimal multi-object tracking filter \cite%
{VoGLMB13,VVP_GLMB13}, for the guessed clutter rate and 'true' clutter rate (that
varies with time as shown in Fig. \ref{fig:frame_clutter}), demonstrates
significant performance degradation.
\begin{figure*}[h]
\centering
\subfigure{
\label{fig:subfig1}
\includegraphics[scale=0.28, trim= 20 0 20 0]{sam2_fig_16_60.png}}%
\subfigure{
\label{fig:subfig1}
\includegraphics[scale=0.28, trim= 20 0 20 0]{sam2_fig_16_rigged.png}
}
\subfigure{
\label{fig:subfig1}
\includegraphics[scale=0.28, trim= 20 0 20 0]{sam2_fig_48_60.png}}%
\subfigure{
\label{fig:subfig1}
\includegraphics[scale=0.28, trim= 20 0 20 0]{sam2_fig_48_rigged.png}
}
\caption[Optional caption for list of figures]{Frames 16, 48 of the image
sequence from \protect\cite{Geiger2012CVPR} and object detections obtained
using the detector in \protect\cite{DOLLAR2014}. The number of objects
varies with time due to objects coming in and out of the scene. Object
estimates (marked by blue boxes) using the standard GLMB filter for guessed
clutter rate of 60 (left column) and 'true' clutter rate (right column).
Tracking using 'true' clutter rate accurately estimated several objects
that were missed in the frames on the left.}
\label{fig:videosam2}
\end{figure*}
Except for a few applications, the clutter rate and detection profile of the
sensor are not available. Usually these parameters are either estimated from
training data or manually tuned. However, a major problem in many
applications is the time-varying nature of the misdetection and clutter
processes, see Fig. \ref{fig:frame_clutter} for example. Consequently,
there is no guarantee that the model parameters chosen from training data
will be sufficient for the multi-object filter at subsequent frames. Thus,
current multi-object tracking algorithms are far from being a
'plug-and-play' technology, since their application still requires
cumbersome and error-prone user configuration.
\begin{figure}[h]
\centering
\includegraphics[trim=20 0 20 0,clip,width=0.5 \textwidth]{frame_clutter.png}
\caption{'True' clutter rate for the first 60 frames of the dataset\cite{Geiger2012CVPR}. Note
that it is not possible to know the true clutter rate for real video data.
For illustration we assume that the clutter rate varies slowly and
use the average clutter count over a moving 10-frame window as the 'true'
clutter rate.}
\label{fig:frame_clutter}
\end{figure}
This paper proposes an online multi-object tracker that learns the clutter
and detection model parameters while tracking. Such capability is essential
for applications where the clutter rate and detection profile vary with
time. Specifically, we detail a GLMB filter for Jump Markov system (JMS),
which is applicable to tracking multiple manuevering objects as well as
joint tracking and classification of multiple objects. Using the JMS-GLMB
filter, we develop a multi-object tracker that can adaptively learn clutter
rate and detection profile while tracking, provided that the detection
profile and clutter background do not change too rapidly compared to the
measurement-update rate. An efficient implementation of the proposed filter and
experiments confirm markedly improved performance over existing multi-object
filters for unknown background such as the $\lambda $-CPHD filter \cite%
{MVV10}. Preliminary results have been reported in \cite{PVV16}, which
outlines a GLMB filter for jump-Markov system model.
We remark that robust Bayesian approaches to problems with model mismatch in
the literature such as \cite{Cozman, Noacketal08, Wally, Basu, Berger,
Berliner} are too computationally intensive for an on-line multi-object
tracker. A Sequential Monte Carlo technique for calibration of
time-invariant multi-object model parameters was proposed in \cite{Singhetal}%
. While this approach is quite general it is not directly applicable to
time-varying clutter rate and detection profile, and is also too
computationally intensive for an on-line tracker. Previous work on CPHD/PHD,
multi-Bernoulli and multi-target Bayes filters for unknown clutter rate and
detection profile \cite{MVV10}, \cite{Mahler10a, Mahler10b, VVHM13,
MahlerVo14, Corea16, Rez_TMI15} do not output object tracks. Further, the
CPHD/PHD, multi-Bernoulli filters require more drastic approximations than
the GLMB filter.
The remainder of paper is organized as follows. Section II provides
background material on multi-object tracking and the GLMB filter. Section
III details two versions of the GLMB filter for a general multi-object JMS
model and a non-interacting multi-object JMS model. Section IV presents an
efficient implementation of the non-interacting JMS-GLMB filter for tracking
in unknown clutter rate and detection profile. Numerical studies are
presented in Section V and concluding remarks are given in Section VI.
\section{Background}
\indent This section reviews relevant background on the random finite set
(RFS) formulation of multi-object tracking and the GLMB filter. Throughout
the article, we adopt the following notations. For a given set $S$, $|S|$
denotes its cardinality (number of elements), $1_{S}(\cdot )$ denotes the
indicator function of $S$, and $\mathcal{F}(S)$ denotes the class of finite
subsets of $S$. We denote the inner product $\int f(x)g(x)dx$ by $%
\left\langle f,g\right\rangle $, the list of variables $%
X_{m},X_{m+1},...,X_{n}$ by $X_{m:n}$, the product $\tprod_{x\in X}f(x)$
(with $f^{\emptyset }=1$) by $f^{X}$, and a generalization of the Kroneker
delta that takes arbitrary arguments such as sets, vectors, integers etc.,
by
\begin{equation*}
\delta _{Y}[X]\triangleq \left\{
\begin{array}{l}
1,\RIfM@\expandafter\text@\else\expandafter\mbox\fi{ if }X=Y \\
0,\RIfM@\expandafter\text@\else\expandafter\mbox\fi{ otherwise}%
\end{array}%
\right. .
\end{equation*}
\subsection{Multi-object State}
\indent At time $k$, an existing object is described by a vector $x_{k}\in
\mathbb{X}$. To distinguish different object trajectories, each object is
identified by a unique label $\ell _{k}$ that consists of an ordered pair $%
(t,i)$, where $t$ is the time of birth and $i$ is the index of individual
objects born at time $t$ \cite{VoGLMB13}. The trajectory of an object is
given by the sequence of states with the same label.
Formally, the state of an object at time $k$ is a vector $\mathbf{x}%
_{k}=(x_{k},\ell _{k})\in \mathbb{X\times L}_{k}$, where $\mathbb{L}_{k}$
denotes the label space for objects at time $k$ (including those born prior
to $k$). Note that $\mathbb{L}_{k}$ is given by $\mathbb{B}_{k}\cup \mathbb{L%
}_{k-1}$, where $\mathbb{B}_{k}$ denotes the label space for objects born at
time $k$ (and is disjoint from $\mathbb{L}_{k-1}$).
In the RFS approach to multi-object tracking \cite{Mah07, mahler2014advances}%
. the collection of object states, referred to as the \emph{multi-object
state}, is naturally represented as a finite set \cite{VVPS10}. Suppose that
there are $N_{k}$ objects at time $k$, with states $\mathbf{x}_{k,1},...,%
\mathbf{x}_{k,N_{k}}$, then the \emph{multi-object state} is defined by the
finite set
\begin{equation*}
\mathbf{X}_{k}=\{\mathbf{x}_{k,1},...,\mathbf{x}_{k,N_{k}}\}\in \mathcal{F}(%
\mathbb{X\times L}_{k}),
\end{equation*}%
We denote the set $\{\ell :(x,\ell )\in \mathbf{X}\}$ of labels of $\mathbf{X%
}$ by $\mathcal{L}(\mathbf{X})$. Note that since the label is unique, no two
objects have the same label, i.e. $\delta _{|\mathbf{X}|}[|\mathcal{L}(%
\mathbf{X})|]=1$. Hence $\Delta (\mathbf{X})\triangleq $ $\delta _{|\mathbf{X%
}|}[|\mathcal{L}_{\mathbf{X}}|]$ is called the \emph{distinct label indicator%
}.
A \emph{labeled RFS} is a random variable on $\mathcal{F}(\mathbb{X}\mathcal{%
\times }\mathbb{L})$ such that each realization has distinct labels. The
distinct label property ensures that at any time no two tracks can share any
common points. For the rest of the paper, we follow the convention that
single-object states are represented by lower-case letters (e.g. $x$, $%
\mathbf{x}$), while multi-object states are represented by upper-case
letters (e.g. $X$, $\mathbf{X}$), symbols for labeled states and their
distributions are bold-faced (e.g. $\mathbf{x}$, $\mathbf{X}$, $\mathbf{\pi }
$, etc.), and spaces are represented by blackboard bold (e.g. $\mathbb{X}$, $%
\mathbb{Z}$, $\mathbb{L}$, etc.). For notational compactness, we drop the
time subscript $k$, and use the subscript `$+$' for time $k+1$.
\subsection{Standard multi-object system model}
Given the multi-object state $\mathbf{X}$ at time $k$, each state $(x,\ell
)\in \mathbf{X}$ either survives with probability $P_{S}(x,\ell )$ and
evolves to a new state $(x_{+},\ell _{+})$ at time $k+1$ with probability
density $f_{+}(x_{+}|x,\ell )\delta _{\ell }[\ell _{+}]$ or dies with
probability $1-P_{S}(x,\ell )$. The set $\mathbf{B}_{+}$ of new objects born
at time $k+1$ is distributed according to the labeled multi-Bernoulli (LMB)
density
\begin{equation}
\Delta (\mathbf{B}_{+})\left[ 1_{\mathbb{B}_{\,+}}\,r_{B,+}\right] ^{%
\mathcal{L(}\mathbf{B}_{+})}\left[ 1-r_{B,+}\right] ^{\mathbb{B}_{+}-%
\mathcal{L(}\mathbf{B}_{+})}p_{B,+}^{\mathbf{B}_{+}}, \label{eq:LMB_birth}
\end{equation}%
where $r_{B,+}(\ell )$ is the probability that a new object with label $\ell
$ is born, $p_{B,+}(\cdot ,\ell )$\ is the distribution of its kinematic
state, and $\mathbb{B}_{\,+}$ is the label space of new born objects \cite%
{VoGLMB13}. The multi-object state $\mathbf{X}_{+}$ (at time $k+1$) is the
superposition of surviving objects and new born objects. Note that the label
space of all objects at time $k+1$ is the disjoint union $\mathbb{L}_{+}=%
\mathbb{L}\uplus \mathbb{B}_{+}$. It is assumed that, conditional on $%
\mathbf{X}$, objects move, appear and die independently of each other.
For a given multi-object state $\mathbf{X}$, each $(x,\ell )\in \mathbf{X}$
is either detected with probability $P_{D}(x,\ell )$ and generates a
detection $z\in Z$ with likelihood $g(z|x,\ell )$ or missed with probability
$1-P_{D}(x,\ell )$. The \emph{multi-object observation} is the superposition
of the observations from detected objects and Poisson clutter with
(positive) intensity $\kappa $. Assuming that, conditional on $\mathbf{X}$,
detections are independent of each other and clutter, the multi-object
likelihood function is given by \cite{VoGLMB13}, \cite{VVP_GLMB13}
\begin{equation}
g(Z|\mathbf{X})\propto \sum_{\theta \in \Theta }1_{\Theta (\mathcal{L(}%
\mathbf{X}))}(\theta )\prod\limits_{(x,\ell )\in \mathbf{X}}\psi
_{Z_{_{\!}}}^{(\theta (\ell ))}(x,\ell ) \label{eq:RFSmeaslikelihood0}
\end{equation}%
where: $\Theta $ is the set of \emph{positive 1-1} maps $\theta :\mathbb{L}%
\rightarrow \{0$:$|Z|\}$, i.e. maps such that \emph{no two distinct
arguments are mapped to the same positive value}, $\Theta (I)$ is the set of
\emph{positive 1-1} maps with domain $I$; and
\begin{equation}
\psi _{\!\{z_{1:M}\}\!}^{(j)}(x,\ell )=\left\{ \!\!%
\begin{array}{ll}
\frac{P_{\!D}(x,\ell )g(z_{j}|x,\ell )}{\kappa (z)}, & \!\!\RIfM@\expandafter\text@\else\expandafter\mbox\fi{if }j=1%
\RIfM@\expandafter\text@\else\expandafter\mbox\fi{:}M \\
1-P_{\!D}(x,\ell ), & \!\!\RIfM@\expandafter\text@\else\expandafter\mbox\fi{if }j=0%
\end{array}%
\right. \!\!. \label{eq:PropConj5}
\end{equation}%
The map $\theta $ specifies which objects generated which detections, i.e.
object $\ell $ generates detection $z_{\theta (\ell )}\in Z$, with
undetected objects assigned to $0$. The positive 1-1 property means that $%
\theta $ is 1-1 on $\{\ell :\theta (\ell )>0\}$, the set of labels that are
assigned positive values, and ensures that any detection in $Z$ is assigned
to at most one object.
For the special case with zero-clutter, i.e. $\kappa $ is identically zero,
the multi-object likelihood function still takes the same form, but with $%
P_{\!D}(x,\ell )g(z_{j}|x,\ell )/\kappa (z)$ replaced by $P_{\!D}(x,\ell
)g(z_{j}|x,\ell )$, see \cite{Mah07, mahler2014advances}. To cover both
positive and identically-zero clutter intensities we write%
\begin{equation}
\psi _{\!\{z_{1:M}\}\!}^{(j)}(x,\ell )=\left\{ \!\!%
\begin{array}{ll}
\frac{P_{\!D}(x,\ell )g(z_{j}|x,\ell )}{\kappa (z)+\delta _{0}[\kappa (z)]},
& \!\!\RIfM@\expandafter\text@\else\expandafter\mbox\fi{if }j=1\RIfM@\expandafter\text@\else\expandafter\mbox\fi{:}M \\
1-P_{\!D}(x,\ell ), & \!\!\RIfM@\expandafter\text@\else\expandafter\mbox\fi{if }j=0%
\end{array}%
\right. \!\!.
\end{equation}
\subsection{Generalized Labeled Multi-Bernoulli}
A Generalized Labeled Multi-Bernoulli (GLMB) filtering density, at time $k$,
is a multi-object density that can be written in the form
\begin{equation}
\mathbf{\pi }(\mathbf{X})=\Delta (\mathbf{X})\sum_{\xi \in \Xi ,I\subseteq
\mathbb{L}}\omega ^{(I,\xi )}\delta _{I}[\mathcal{L(}\mathbf{X})]\left[
p^{(\xi )}\right] ^{\mathbf{X}}. \label{eq:GLMB}
\end{equation}%
where each $\xi \in \Xi \triangleq \Theta _{0}\times ...\times \Theta _{k}$
represents a history of association maps $\xi =(\theta _{1:k})$, each $%
p^{(\xi )}(\cdot ,\ell )$ is a probability density on $\mathbb{X}$, and each
$\omega ^{(I,\xi )}$ is non-negative with $\sum_{\xi \in \Xi
}\sum_{I\subseteq \mathbb{L}}\omega ^{(I,\xi )}=1$. The cardinality
distribution of a GLMB is given by%
\begin{equation}
\Pr (\left\vert \mathbf{X}\right\vert \RIfM@\expandafter\text@\else\expandafter\mbox\fi{=}n)=\sum_{\xi \in \Xi
,I\subseteq \mathbb{L}}\delta _{n}\left[ \left\vert I\right\vert \right]
\omega ^{(I,\xi )}, \label{eq:GLMBCard}
\end{equation}%
while, the existence probability and probability density of track $\ell \in
\mathbb{L}$ are respectively\allowdisplaybreaks%
\begin{align}
r(\ell )& =\sum_{\xi \in \Xi ,I\subseteq \mathbb{L}}1_{I}(\ell )\omega
^{(I,\xi )}, \\
p(x,\ell )& =\frac{1}{r(\ell )}\sum_{\xi \in \Xi ,I\subseteq \mathbb{L}%
}1_{I}(\ell )\omega ^{(I,\xi )}p^{(\xi )}(x,\ell ).
\end{align}
Given the GLMB density (\ref{eq:GLMB}), an intuitive multi-object estimator
is the \emph{multi-Bernoulli estimator}, which first determines the set of
labels $L\subseteq $ $\mathbb{L}$ with existence probabilities above a
prescribed threshold, and second the mode/mean estimates from the densities $%
p(\cdot ,\ell ),\ell \in L$, for the states of the objects. A popular
estimator is a suboptimal version of the Marginal Multi-object Estimator
\cite{Mah07}, which first determines the pair $(L,\xi )$ with the highest
weight $\omega ^{(L,\xi )}$ such that $\left\vert L\right\vert $ coincides
with the mode cardinality estimate, and second the mode/mean estimates from $%
p^{(\xi )}(\cdot ,\ell ),\ell \in L$, for the states of the objects.
For the standard multi-object system model the GLMB density is a conjugate
prior, and is also closed under the Chapman-Kolmogorov equation \cite%
{VoGLMB13}. Moreover, the GLMB posterior can be tractably computed to any
desired accuracy in the sense that, given any $\epsilon >0$, an approximate
GLMB within $\epsilon $ from the actual GLMB in $L_{1}$ distance, can be
computed (in polynomial time) \cite{VVP_GLMB13}. The GLMB filtering density
can be propagated forward in time via a prediction step and an update step
as in\cite{VVP_GLMB13} or in one single step as in \cite{VVH_GLMB17}. Since
the number of components grow exponentially in the predicted/filtered
densities during prediction/update stages, truncation of hypotheses with low
weights is essential during implementation. Polynomial complexity schemes
for truncation of insignificant weights were given in \cite{VVP_GLMB13} and
\cite{VVH_GLMB17}, via Murty's algorithm with a quartic (or at best cubic)
complexity, or via Gibbs sampling with a linear complexity, where the
complexity is given in the number of measurements.
\section{Jump Markov System\ GLMB\ Filtering}
We first derive from the GLMB recursion a multi-object filter for Jump
Markov system (JMS) in subsection \ref{subsec_JMSGLMB}, which is applicable
to tracking multiple manuevering objects as well as joint tracking and
classification of multiple objects. When the modes of the multi-object JMS
do not interact, the JMS-GLMB recursion reduces to a more tractable form,
which is presented in subsection \ref{subsec_MultiClassGLMB}. This special
case is then used to develop a multi-object tracker that can operate in
unknown background in section \ref{sec_UBGLMB}.
\subsection{GLMB filter for Jump Markov Systems}
\label{subsec_JMSGLMB}
A \emph{Jump Markov System} (JMS) consists of a set of parameterised state
space models, whose parameters evolve with time according to a finite state
Markov chain. A JMS can be specified in terms of the standard system
parameters for each mode or class as follows.
Let $\mathbb{M}$ be the (discrete) index set of modes in the system. Suppose
that mode $m$ is in effect at time $k$, then the state transition density
from $\zeta $, at time $k$, to $\zeta _{+}$, at time $k+1$, is denoted by $%
f_{+}^{(m)}(\zeta _{+}|\zeta )$, and the likelihood of $\zeta $ generating
the measurement $z$ is denoted by $g^{(m)}(z|\zeta )$ \cite{LiVSMM00}, \cite%
{LiJilkovMM05}, \cite{Ristic04}. Moreover, the joint transition of the state
and mode assumes the form:%
\begin{equation}
f_{+}(\zeta _{+},m_{+}|\zeta ,m)=f_{+}^{(m_{+})}(\zeta _{+}|\zeta )\vartheta
_{+}(m_{+}|m), \label{eq:JMS_trans}
\end{equation}%
where $\vartheta _{+}(m_{+}|m)$ denotes the probability of switching from
mode $m$ to $m_{+}$ (and satisfies $\sum_{m_{+}\in \mathbb{M}}\vartheta
_{+}(m_{+}|m)=1$). Note that by defining the \emph{augmented state} as $%
x=(\zeta ,m\mathbf{)}\in \mathbb{X}\times \mathbb{M}$, a JMS model can be
expressed as a standard state space model with transition density (\ref%
{eq:JMS_trans}) and measurement likelihood function $g(z|\zeta
,m)=g^{(m)}(z|\zeta )$.
In a multi-object system, each object is identified by a label $\ell $ that
remains unchanged throughout its life, hence the JMS state equation for such
an object is written as
\begin{eqnarray}
\!\!\!\!f_{+}(\zeta _{+},m_{+}|\zeta ,m,\ell )\!\!\!
&=&\!\!\!f_{+}^{(m_{+})}(\zeta _{+}|\zeta ,\ell )\vartheta _{+}(m_{+}|m)
\label{eq:JMS-GLMB} \\
\!\!\!\!g(z|\zeta ,m,\ell )\!\!\! &=&\!\!\!g^{(m)}(z|\zeta ,\ell )
\label{eq:JMS-GLMB1}
\end{eqnarray}%
Additionally, to emphasize the dependence on the mode, the survival, birth
and detection parameters are, respectively, denoted as
\begin{eqnarray*}
p_{B,+}^{(m_{+})}(\zeta _{+},\ell _{+}) &\triangleq &p_{B,+}(\zeta
_{+},m_{+},\ell _{+}), \\
P_{S}^{(m)}(\zeta ,\ell ) &\triangleq &P_{S}(\zeta ,m,\ell ), \\
P_{D}^{(m)}(\zeta ,\ell ) &\triangleq &P_{D}(\zeta ,m,\ell ).
\end{eqnarray*}%
Substituting these parameters and the JMS state equations (\ref{eq:JMS-GLMB}%
)-(\ref{eq:JMS-GLMB1}) into the GLMB recursion in \cite{VVH_GLMB17} yields
the so-called JMS-GLMB recursion.
\begin{proposition}
If the filtering density at time $k$ is the GLMB (\ref{eq:GLMB}), then the
filtering density at time $k+1$ is the GLMB%
\begin{equation}
\mathbf{\pi }_{\!}(\mathbf{X_{+\!}}|Z_{+\!})\!\propto \!\Delta _{\!}(_{\!}%
\mathbf{X_{\!+}}_{\!})\!\!\!\!\sum\limits_{I\!,\xi ,I_{\!+},\theta
_{\!+\!}}\!\!\!\!\omega ^{(I,\xi )}\omega _{Z_{_{\!}+}}^{(_{\!}I_{\!},\xi
,I_{\!+\!},\theta _{\!+\!})}\delta _{_{\!}I_{+\!}}[\mathcal{L}(_{\!}\mathbf{%
X_{\!+}}_{\!})]\!\left[ p_{Z_{_{\!}+_{\!}}}^{(_{\!}\xi ,\theta
_{\!+\!})}{}_{\!}\right] ^{\!\mathbf{X_{\!+}}}\! \label{eq:JMSGLMB}
\end{equation}%
where $I\in \mathcal{F}(\mathbb{L})$,$\;\xi \in \Xi $,$\;I_{+}\in \mathcal{F}%
(\mathbb{L}_{+})$,$\;\theta _{+}\in \Theta _{+}$, \allowdisplaybreaks%
\begin{align}
\omega _{Z_{_{\!}+}}^{(_{\!}I_{\!},\xi ,I_{\!+\!},\theta _{\!+\!})}=& 1_{{%
\Theta }_{\!+\!}(I_{+})}(\theta _{\!+\!})\left[ 1-\bar{P}_{S}^{(\xi )}\right]
^{\!I\!-I_{\!+}}\!\left[ \bar{P}_{S\!}^{(\xi )}\right] ^{\!I\cap
I_{+\!}}\times \notag \\
& \left[ 1-r_{B\!,+}\right] ^{\mathbb{B}_{\!+\!}-I_{\!+}\!}\;r_{B\!,+}^{%
\mathbb{B}_{\!{+}}\cap I_{+\!}}\!\left[ \bar{\psi}_{_{\!}Z_{_{\!}+}}^{(_{\!}%
\xi ,\theta _{_{\!}+\!})}\right] ^{I_{+}} \label{eq:JMSGLMB1} \\
\bar{P}_{S\!}^{(\xi )}(\ell )=& \sum_{m\in \mathbb{M}}\bar{P}_{S\!}^{(\xi
)}(m,\ell ), \label{eq:JMSGLMB2} \\
\bar{P}_{S\!}^{(\xi )}(m,\ell )=& \left\langle p^{(\xi )\!}(\cdot ,m,\ell
),P_{S}^{(m)}(\cdot ,\ell )\right\rangle , \label{eq:JMSGLMB3} \\
\bar{\psi}_{_{\!}Z_{_{\!}+}}^{(\xi ,\theta _{+\!})}(\ell )=& \sum_{m_{+}\in
\mathbb{M}}\bar{\psi}_{_{\!}Z_{_{\!}+}}^{(\xi ,\theta _{+\!})}(m_{+},\ell ),
\label{eq:JMSGLMB4} \\
\bar{\psi}_{_{\!}Z_{_{\!}+}}^{(\xi ,\theta _{+\!})}(m_{+},\ell )=&
\left\langle \bar{p}_{+}^{(\xi )}(\cdot ,m_{+},\ell _{_{\!}}),\psi
_{_{\!}Z_{_{\!}+}\!}^{(\theta _{_{\!}+}(\ell ))}(\cdot ,m_{+},\ell
_{_{\!}})\right\rangle \label{eq:JMSGLMB5}
\end{align}%
\begin{gather}
\!\bar{p}_{+}^{(\xi )\!}(\zeta _{+},m_{+},\ell )=1_{\mathbb{B}_{+}}\!(\ell
)p_{B}^{(m_{+})}(\zeta _{+},\ell )\;+\RIfM@\expandafter\text@\else\expandafter\mbox\fi{ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ \ \ \ \ \ } \notag \\
1_{\mathbb{L}}(\ell )\frac{\sum\limits_{m\in \mathbb{M}}{\tiny \!}%
\!\left\langle \!{\small P}_{S}^{(m)}{\small (\cdot ,\ell )f}_{+}^{(m_{+})}%
{\small (\zeta }_{+}{\small |\cdot ,\ell ),p}^{(\xi )}{\small (\cdot ,m,\ell
)}\!\right\rangle \!{\small \vartheta (m}_{+}{\small |m)}}{{\small \bar{P}}%
_{S}^{(\xi )}{\small (\ell )}} \label{eq:JMSGLMB6}
\end{gather}%
\begin{align}
p_{Z_{_{\!}+}}^{(\xi _{\!},\theta _{\!+\!})\!}(\zeta _{+},m_{+},\ell )=&
\frac{\bar{p}_{+}^{(\xi )\!}(\zeta _{+},m_{+},\ell )\psi _{Z_{+}}^{(\theta
_{_{\!}+\!}(\ell ))\!}(\zeta _{+},m_{+},\ell )}{\bar{\psi}_{Z_{+}}^{(\xi
,\theta _{_{\!}+})}(m_{+},\ell _{_{\!}})} \label{eq:JMSGLMB7} \\
\psi _{\!\{z_{1:|Z|}\}\!}^{(j)}(\zeta ,m,\ell )=& \left\{ \!\!%
\begin{array}{ll}
\!\frac{P_{D}^{(m)}(\zeta ,\ell )g^{(m)}(z_{j\!}|_{_{\!}}\zeta ,\ell )}{%
\kappa (z_{j})+\delta _{0}[\kappa (z_{j})]}, & \!\!\!\RIfM@\expandafter\text@\else\expandafter\mbox\fi{if }j\in \left\{
1,...,|Z|\right\} \\
\!1-P_{D}^{(m)}(\zeta ,\ell ), & \!\!\!\RIfM@\expandafter\text@\else\expandafter\mbox\fi{if }j=0%
\end{array}%
\right. \!\! \label{eq:JMSGLMB8}
\end{align}
\end{proposition}
Notice that the above expression is in $\delta $-GLMB form since it can be
written as a sum over $I_{\!+},\xi ,\theta _{+}$ with weights%
\begin{equation*}
\omega _{Z_{+}}^{(I_{+},\xi ,\theta _{+})}\propto \sum\limits_{I}\omega
^{(I,\xi )}\omega _{Z_{+}}^{(I,\xi ,I_{+},\theta _{+})}.
\end{equation*}
This special case of the GLMB recursion is particularly useful for tracking
multiple manuevering objects and joint multi-object tracking and
classification. Indeed the application of the JMS-GLMB recursion to multiple
manuevering object tracking has been reported our preliminary work \cite%
{PVV16}, where separate prediction and update steps was introduced. The same
result was independently reported in \cite{RezaFusion16}.
\subsection{Multi-Class GLMB}
\label{subsec_MultiClassGLMB}
The JMS-GLMB recursion can be applied to the joint multi-object tracking and
classification problem by using the mode as the class label (not to be
confused to object label). What distinguishes this problem from generic
JMS-GLMB filtering is that the modes do not interact with each other in the
following sense:
\begin{enumerate}
\item All possible states of a new object with the same object label share\
a common mode (class label);
\item An object cannot switch between different modes from one time step to
the next.
\end{enumerate}
Let $\mathbb{B}^{(m)}$ denote the set of labels of all elements in $\mathbb{%
X\times M}\times \mathbb{B}$ with mode $m$. Then condition 1 implies that
the label sets $\mathbb{B}^{(m)}$ and $\mathbb{B}^{(m^{\prime })}$ for
different modes $m$ and $m^{\prime }$ are disjoint (otherwise there exist a
label $\ell $ in both $\mathbb{B}^{(m)}$ and $\mathbb{B}^{(m^{\prime })}$,
which means there are states in $\mathbb{X\times M}\times \mathbb{B}$ with
different modes $m$ and $m^{\prime }$ but share a common label $\ell $).
Furthermore, the sets $\mathbb{B}^{(m)}$, $m\in \mathbb{M}$ cover $\mathbb{B}
$, i.e. $\mathbb{B}=\bigcup_{m\in \mathbb{M}}\mathbb{B}^{(m)}$, and thus
form a partition of the space $\mathbb{B}$. A new object is classified as
class $m$ (and has mode $m$) if and only if its label falls into $\mathbb{B}%
^{(m)}$. Thus for an LMB birth\ model, condition 1 means%
\begin{eqnarray}
r_{B,+}(\ell _{+}) &=&\sum_{m_{+}\in \mathbb{M}}r_{B,+}^{(m_{+})}1_{\mathbf{%
\mathbb{B}}_{+}^{(m_{+})}}(\ell _{+}), \label{eq:class_birthr} \\
p_{B,+}^{(m_{+})}(\zeta _{+},\ell _{+}) &=&p_{B,+}^{(m_{+})}(\zeta _{+})1_{%
\mathbf{\mathbb{B}}_{+}^{(m_{+})}}(\ell _{+}). \label{eq:class_birthp}
\end{eqnarray}%
Note that $r_{B,+}^{(m_{+})}$ and $p_{B,+}^{(m_{+})}(\zeta _{+})$ are
respectively the existence probability and probability density of the
kinematics $\zeta _{+}$ of a new object given mode $m_{+}$, while $1_{%
\mathbf{\mathbb{B}}_{+}^{(m_{+})}}(\ell _{+})$ is the probability of mode $%
m_{+}$ given label $\ell _{+}$.
Condition 2 means that the mode transition probability
\begin{equation}
\vartheta (m_{+}|m)=\delta _{m}[m_{+}], \label{eq:class_trans}
\end{equation}%
which implies that each object belongs to exactly one of the classes in $%
\mathbb{M}$ for its entire life. Consequently, the non-interacting mode
condition means that at time $k$, the label space for all class $m$ objects
is $\mathbb{L}^{(m)}=\biguplus\nolimits_{t=0}^{k}\mathbb{B}_{t}^{(m)}$, and
the set of all possible labels is given by the disjoint union $\mathbb{L}%
=\biguplus\nolimits_{m\in \mathbb{M}}\mathbb{L}^{(m)}$.
For a multi-object JMS system with non-interacting modes, the JMS-GLMB
recursion reduces to a form where the weights and multi-object exponentials
can be separated according to classes. We call this form the multi-class
GLMB.
\begin{proposition}
Let $\mathbf{X}_{\!\!}^{(m)}$ denote the subset of $\mathbf{X}$ with mode $m$%
, and hence $\mathbf{X}=\biguplus\nolimits_{m\in \mathbb{M}}\mathbf{X}^{(m)}$%
. Suppose that the hybrid multi-object density at time $k$ is a GLMB of the
form%
\begin{equation}
\mathbf{\pi }(\mathbf{X})=\sum_{\xi ,I}1_{{\Theta }(I)}(\xi \perp {\Theta }%
)\prod\limits_{m\in \mathbb{M}}\mathbf{\pi }^{(I^{(m)},\xi ^{(m)})}(\mathbf{X%
}_{\!\!}^{(m)}) \label{eq:deltaglmb_class12}
\end{equation}%
where $\xi \in \Xi $, $I\subseteq \mathbb{L}$, $\xi \perp {\Theta }$ denotes
the projection $\xi $ into the space ${\Theta }$, $I^{(m)}\triangleq I\cap
\mathbb{L}^{(m)}$, $\xi ^{(m)}=\xi |_{\mathbb{L}_{0}^{(m)}\times ...\times
\mathbb{L}_{k}^{(m)}}$ (i.e. the map $\xi $ restricted to $\mathbb{L}%
_{0}^{(m)}\times ...\times \mathbb{L}_{k}^{(m)}$), and
\begin{equation}
\mathbf{\pi }^{(I,\xi )}(\mathbf{X})\triangleq \Delta (\mathbf{X})w^{(I,\xi
)}\delta _{_{\!}I}[\mathcal{L}(\mathbf{X}_{\!})]\left[ p^{(\xi )}\right] ^{%
\mathbf{X}}
\end{equation}%
Then the hybrid multi-object filtering density at time $k+1$ is the GLMB
\begin{equation}
\mathbf{\pi }_{\!Z_{+}\!}(\mathbf{X_{+}})\!\propto \!\!\!\!\sum_{\xi
,I,_{\!}\theta _{\!+\!},I_{+\!}}\!\!\!\!1_{{\Theta }_{\!+\!}(I_{+\!})}(%
\theta _{\!+\!})\!\!\!\prod\limits_{m\in \mathbb{M}}\!\!\mathbf{\pi }%
_{Z_{+}\!}^{\!(m,I_{\!}^{(m)},\xi ^{(m)},I_{\!+\!}^{(m)},\theta
_{\!+\!}^{\!(m)})\!}(\mathbf{X}_{+\!}^{(m)\!}) \label{eq:GLMBactualvirtual}
\end{equation}%
where $I_{\!+\!}\in \!\mathcal{F}(\mathbb{L}_{\!+})$,$\;\theta _{\!+\!}\in
\!\Theta _{+}$, $I_{\!+}^{(m)}=I_{\!+}\!\cap \!\mathbb{L}_{+}^{(m)}$, $%
\theta _{+}^{(m)}=\theta _{+}|_{\mathbb{L}_{+}^{(m)}}$\ \allowdisplaybreaks%
\begin{eqnarray}
&&\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\mathbf{\pi }%
_{Z_{+}\!}^{(m,I_{\!},\xi ,I_{\!+\!},\theta _{\!+\!})}(\mathbf{X}_{+\!})=
\notag \\
&&\!\!\!\!\Delta _{\!}(\mathbf{X}_{+})w_{Z_{_{\!}+}}^{(m,I_{\!},\xi
,I_{\!+\!},\theta _{\!+\!})}w^{(I,\xi )}\delta _{_{\!}I_{+}}[\mathcal{L}(%
\mathbf{X}_{+\!})]\left[ p_{Z_{_{\!}+_{\!}}}^{(_{\!}\xi ,\theta
_{\!+\!})}{}_{\!}\right] ^{\mathbf{X}_{+}}
\end{eqnarray}%
\begin{align}
w_{Z_{_{\!}+}}^{(_{\!}m,I_{\!},\xi ,I_{\!+\!},\theta _{\!+\!})}& =\left[
\bar{\psi}_{_{\!}Z_{_{\!}+}}^{(_{\!}\xi ,\theta _{_{\!}+\!})}(m,\cdot )%
\right] ^{I_{+}}\left[ 1-r_{B\!,+}\right] ^{\mathbb{B}_{\!+\!}^{(m)}-I_{\!+}%
\!}r_{B\!,+}^{\mathbb{B}_{\!{+}}^{(m)}\cap I_{+\!}} \notag \\
& \times \left[ 1-\bar{P}_{S}^{(\xi )}(m,\cdot )\right] ^{\!I\!-I_{\!+}}\!%
\left[ \bar{P}_{S\!}^{(\xi )}(m,\cdot )\right] ^{\!I\cap I_{+\!}}
\label{eq:mclassGLMB2} \\
\bar{P}_{S}^{(\xi )}(m,\ell )& =\left\langle p^{(\xi )\!}(\cdot ,m,\ell
),P_{S}^{(m)}(\cdot ,\ell )\right\rangle , \label{eq:mclassGLMB3} \\
\bar{\psi}_{_{\!}Z_{_{\!}+}}^{(\xi ,\theta _{+\!})}(m,\ell )& =\left\langle
\bar{p}_{+}^{(\xi )}(\cdot ,m,\ell _{_{\!}}),\psi
_{_{\!}Z_{_{\!}+}\!}^{(\theta _{_{\!}+}(\ell ))}(\cdot ,m,\ell
_{_{\!}})\right\rangle , \label{eq:mclassGLMB4}
\end{align}%
\begin{align}
\bar{p}_{+}^{(\xi )_{\!}}(\zeta ,m,\ell )=& 1_{\mathbb{L}_{\!}^{(m)}}(\ell )%
\frac{\!\left\langle P_{S}^{(m)}(\cdot ,\ell )f_{+}^{(m)}(\zeta |\cdot ,\ell
)),p^{(\xi )}(\cdot ,m,\ell )\right\rangle }{\bar{P}_{S}^{(\xi )}(m,\ell )}
\notag \\
+& 1_{\mathbb{B}_{+}^{(m)}}\!(\ell )p_{B}^{(m)}(\zeta ,\ell )
\label{eq:mclassGLMB5} \\
p_{Z_{_{\!}+}}^{(\xi _{\!},\theta _{\!+\!})\!}(\zeta ,m,\ell )& =\frac{\bar{p%
}_{+}^{(\xi )}(\zeta ,m,\ell )\psi _{Z_{+}}^{(\theta _{_{\!}+}(\ell
))}(\zeta ,m,\ell )}{\bar{\psi}_{Z_{+}}^{(\xi ,\theta _{_{\!}+})}(m,\ell )}
\label{eq:mclassGLMB6}
\end{align}
\begin{equation}
\psi _{\!\{z_{1:|Z|}\}\!}^{(j)}(\zeta ,m,\ell )= \Big{\{}
\begin{array}{ll}
\!\frac{P_{D}^{(m)}(\zeta ,\ell )g^{(m)}(z_{j\!}|_{_{\!}}\zeta ,\ell )}{%
\kappa (z_{j})+\delta _{0}[\kappa (z_{j})]}, \!\RIfM@\expandafter\text@\else\expandafter\mbox\fi{if }j\in \left\{
1,...,|Z|\right\} & \\
\!1-P_{D}^{(m)}(\zeta ,\ell ), \;\;\;\;\;\; \RIfM@\expandafter\text@\else\expandafter\mbox\fi{if }j=0 &
\end{array}%
\end{equation}
\end{proposition}
\begin{proof}
Note that the $\mathbb{L}_{0}^{(m)}\times ...\times \mathbb{L}%
_{k}^{(m)},m\in \mathbb{M}$ form a partition of $\mathbb{L}_{0}\times
...\times \mathbb{L}_{k}$ , and since each $\xi ^{(m)}$ was defined as a
restrictions of\ $\xi $ over $\mathbb{L}_{0}^{(m)}\times ...\times \mathbb{L}%
_{k}^{(m)}$, $\xi $ is completely characterized by the $\xi ^{(m)},m\in
\mathbb{M}$. By defining%
\begin{eqnarray}
\omega ^{(I,\xi )} &=&1_{{\Theta }(I)}(\xi \perp {\Theta }%
)\prod\limits_{m\in \mathbb{M}}w^{(I^{(m)},\xi ^{(m)})} \label{eq:proof_1}
\\
p^{(\xi )}(\zeta ,m,\ell ) &=&\left[ p^{(\xi ^{(m)})}(\zeta ,m,\ell )\right]
^{1_{\mathbb{L}^{(m)}}(\ell )} \label{eq:proof_3}
\end{eqnarray}%
it can be seen that (\ref{eq:deltaglmb_class12}) is a GLMB of the form (\ref%
{eq:GLMB}) since
\begin{eqnarray*}
\delta _{_{\!}I}[\mathcal{L}(\mathbf{X}_{\!})] &=&\prod\limits_{m\in \mathbb{%
M}}\delta _{_{\!}I^{(m)}}[\mathcal{L}(\mathbf{X}_{\!}^{(m)})] \\
\left[ p^{(\xi )}\right] ^{\mathbf{X}} &=&\left[ p^{(\xi )}\right]
^{\biguplus\nolimits_{m\in \mathbb{M}}\mathbf{X}^{(m)}}=\prod\limits_{m\in
\mathbb{M}}\left[ p^{(\xi ^{(m)})}{}_{\!}\right] ^{\mathbf{X}^{(m)}}.
\end{eqnarray*}%
Thus by applying Proposition 1, the hybrid multi-object filtering density at
time $k+1$ is given by (\ref{eq:JMSGLMB}-\ref{eq:JMSGLMB8}). Substituting (%
\ref{eq:proof_1}), (\ref{eq:proof_3}), (\ref{eq:class_birthr}-\ref%
{eq:class_trans}) into (\ref{eq:JMSGLMB}-\ref{eq:JMSGLMB8}), decomposing%
\begin{eqnarray}
\mathbf{X}_{+} &=&\biguplus\nolimits_{m\in \mathbb{M}}\mathbf{X}_{+}^{(m)}
\label{eq:proof1} \\
\omega _{Z_{_{\!}+}}^{(_{\!}I_{\!},\xi ,I_{\!+\!},\theta _{\!+\!})} &=&1_{{%
\Theta }_{\!+\!}(I_{+})}(\theta _{\!+\!})\prod\limits_{m\in \mathbb{M}%
}w_{Z_{_{\!}+}}^{(m,I_{\!}^{(m)},\xi ^{(m)},I_{\!+\!}^{(m)},\theta
_{\!+\!}^{(m)})} \label{eq:proof2} \\
p_{Z_{_{\!}+_{\!}}}^{(_{\!}\xi ,\theta _{\!+\!})}{} &=&\left(
p_{Z_{_{\!}+_{\!}}}^{(_{\!}\xi ^{(m)},\theta _{\!+\!}^{(m)})}{}_{\!}\right)
^{1_{\mathbb{L}_{+}^{(m)}}(\ell )} \label{eq:proof3}
\end{eqnarray}%
and rearranging yields (\ref{eq:GLMBactualvirtual}). Note that (\ref%
{eq:class_trans}) ensures that $m_{+}=m$.
\end{proof}
Given a GLMB filtering density of the multi-class form (\ref%
{eq:deltaglmb_class12}), the GLMB filtering density for class $c\in \mathbb{M%
}$, can be obtained by marginalizing the other classes according to the
following proposition.
\begin{proposition}
For the multi-class GLMB (\ref{eq:deltaglmb_class12}), the marginal GLMB for
class $c$ is given by
\begin{equation*}
\mathbf{\pi }\left( \mathbf{X}^{(c)}\right) =\Delta (\mathbf{X}%
^{(c)})\sum_{\xi ,I}\omega ^{(I,\xi )}\delta _{_{\!}I^{(c)}}[\mathcal{L}(%
\mathbf{X}_{\!}^{(c)})]\left[ p^{(\xi ^{(c)})}\right] ^{\mathbf{X}^{(c)}}
\end{equation*}
\end{proposition}
\begin{proof}
Note that%
\begin{eqnarray*}
&&\!\!\!\!\!\!\!\!\!\!\!\!\!\!\int \mathbf{\pi }^{(I^{(m)},\xi ^{(m)})}(%
\mathbf{X}_{\!\!}^{(m)})\delta \mathbf{X}^{(m)} \\
&=&\!\int \!\Delta (\mathbf{X}^{(m)\!})w^{(I^{(m)\!},\xi ^{(m)})}\delta
_{_{\!}I^{(m)\!}}[\mathcal{L}(\mathbf{X}_{\!}^{(m)})]\!\left[ p^{(\xi )}%
\right] ^{\!\mathbf{X}^{\!(m)}}\!\delta \mathbf{X}^{(m)} \\
&=&\!w^{(I^{(m)},\xi ^{(m)})}.
\end{eqnarray*}%
Since, the $\mathbf{X}^{(m)}$, $m\in \mathbb{M}$ are disjoint,
\begin{eqnarray*}
\mathbf{\pi }(\mathbf{X}^{(c)})\!\! &=&\!\!\int \mathbf{\pi }\left(
\tbiguplus\limits_{m\in \mathbb{M}}\mathbf{X}^{(m)}\right) \delta \left(
\tbiguplus\limits_{m\in \mathbb{M}-\{c\}}\mathbf{X}^{(m)}\right) \\
\!\! &=&\!\!\int \sum_{\xi ,I}\!1_{{\Theta }(I)}(\xi \!\perp \!{\Theta }%
)\times \\
&&\!\!\prod\limits_{m\in \mathbb{M}}\mathbf{\pi }^{(I^{(m)},\xi ^{(m)})}(%
\mathbf{X}_{\!\!}^{(m)})\delta \left( \tbiguplus\limits_{m\in \mathbb{M}%
-\{c\}}\mathbf{X}^{(m)}\right) \\
\!\! &=&\!\!\sum_{\xi ,I}\!1_{{\Theta }(I)}(\xi \!\perp \!{\Theta })\mathbf{%
\pi }^{(I^{(c)},\xi ^{(c)})}(\mathbf{X}_{\!\!}^{(c)})\times \\
&&\!\!\prod\limits_{m\in \mathbb{M}-\{c\}}\int \mathbf{\pi }^{(I^{(m)},\xi
^{(m)})}(\mathbf{X}_{\!\!}^{(m)})\delta \mathbf{X}^{(m)} \\
\!\! &=&\!\!\sum_{\xi ,I}\!1_{{\Theta }(I)}(\xi \!\perp \!{\Theta })\mathbf{%
\pi }^{(I^{(c)},\xi ^{(c)})}(\mathbf{X}_{\!\!}^{(c)})\times \\
&&\!\!\prod\limits_{m\in \mathbb{M}-\{c\}}\!\!\!\!w^{(I^{(m)},\xi ^{(m)})}.
\\
\!\! &=&\!\!\Delta (\mathbf{X}^{(c)})\sum_{\xi ,I}\omega ^{(I,\xi )}\delta
_{_{\!}I^{(c)}}[\mathcal{L}(\mathbf{X}_{\!}^{(c)})]\left[ p^{(\xi ^{(c)})}%
\right] ^{\mathbf{X}^{(c)}}.
\end{eqnarray*}
\end{proof}
\section{GLMB\ Filtering with Unknown Background} \label{sec_UBGLMB}
Clutter or false detections are generally understood as detections that do
not correspond to any object \cite{BSF88, BP99, Mah07, mahler2014advances}.
Since the number false detections and their values are random, clutter is
usually modelled by RFSs in the literature \cite{MahlerPHD,Mah07,
mahler2014advances}. The simplest and the most commonly used clutter model
is the Poisson RFS \cite{MahlerPHD}, in most cases, with a uniform intensity
over the surveillance region. Alternatively clutter can be treated as
detections originating from \emph{clutter generators}--objects that are not
of interest to the tracker \cite{MVV10}, \cite{Mahler10a, Mahler10b, VVHM13}.
In \cite{MVV10} a CPHD recursion was derived to propagate separate intensity
functions for clutter generators and objects of interest, and their
collective cardinality distribution of the hybrid multi-object state.
Similarly, in\ \cite{VVHM13} analogous multi-Bernoulli recursions were
derived to propagate the disjoint union of objects of interest and clutter
generators. In this work we show that the multi-class GLMB filter is an
effective multi-object object tracker that can operate under unknown
background by learning the clutter and detection model on-the-fly.
This section details an on-line multi-object tracker that operates in
unknown clutter rate and detection profile. In particular we propose a GLMB
clutter model in subsection \ref{subsec_hybridmodel} by treating clutter as
a special class of objects with completely uncertain dynamics, and describe
a dedicated GLMB recursion for propagating the joint filtering density of
clutter generators and objects of interest. Implementation details are given
in subsection \ref{subsec_implementation}. Extension of the proposed
algorithm to accommodate unknown detection profile is described in
subsection \ref{subsec_UPD}.
\vspace{-3mm}
\subsection{GLMB Joint Object-Clutter Model} \label{subsec_hybridmodel}
We propose to model the finite set of \emph{clutter generators} and \emph{%
objects of interest} as two non-interacting classes of objects, and
propagate this so-called \emph{hybrid multi-object} filtering density
forward in time via the multi-class GLMB recursion. The GLMB filtering
density of the hybrid multi-object state captures all relevant statistical
information on the objects of interest as well as the clutter generators.
What distinguishes the objects of interest from clutter generators is that
the former have relatively predictable dynamics whereas the latter have
completely random dynamics.
In the hybrid multi-object model, the Poisson clutter intensity $\kappa $ is
identically 0 and each detection is generated from either a clutter
generator or an object of interest, which constitute, respectively, the two
modes (or classes) 0 and 1 of the mode space $\mathbb{M}=\{0,1\}$. Since the
classes are non-interacting, there are no switchings between objects of
interest and clutter generators. Moreover, the label space for new born
clutter generators $\mathbf{\mathbb{B}}^{(0)}$ and the label space for new
born objects of interest $\mathbf{\mathbb{B}}^{(1)}$ are disjoint and the
LMB birth parameters are given by
\begin{eqnarray*}
r_{B,+}(\ell _{+}) &=&r_{B,+}^{(0)}1_{\mathbf{\mathbb{B}}_{+}^{(0)}}(\ell
_{+})+r_{B,+}^{(1)}1_{\mathbf{\mathbb{B}}_{+}^{(1)}}(\ell _{+}), \\
p_{B,+}^{(m_{+})}(\zeta _{+},\ell _{+}) &=&p_{B,+}^{(m_{+})}(\zeta _{+})1_{%
\mathbf{\mathbb{B}}_{+}^{(m_{+})}}(\ell _{+})
\end{eqnarray*}%
Since clutter are distinguishable from targets by their completely random
dynamics, each clutter generator has a transition density independent of the
previous state and a uniform measurememt likelihood in the observation
region with volume $V$%
\begin{eqnarray*}
f_{+}^{(0)}(\zeta _{+}|\zeta ,\ell ) &=&s(\zeta _{+}) \\
g^{(0)}(z|\zeta ,\ell ) &=&u(z)V^{-1}
\end{eqnarray*}%
Note that the labels of clutter generators can effectively be ignored since
it is implicit that their labels are distinct but are otherwise
uninformative. Further, for Gaussian implementations it is assumed that the
survival and detection probabilities for clutter generators are state
independent%
\begin{eqnarray*}
P_{S}^{(0)}(\zeta ,\ell ) &=&P_{S}^{(0)} \\
P_{D}^{(0)}(\zeta ,\ell ) &=&P_{D}^{(0)}
\end{eqnarray*}
Applying the multi-class GLMB recursion to this model, it can be easily seen
that all clutter generators are functionally identical (from birth through
prediction and update)%
\begin{equation*}
p_{B}^{(0)}(\zeta ,\ell )=\bar{p}_{+}^{(\xi ^{(0)})}(\zeta ,0,\ell
)=p_{Z_{+}}^{(\xi ^{(0)},\theta _{+}^{(0)})}(\zeta ,0,\ell )=s(\zeta )
\end{equation*}%
and that the weight update for clutter generators reduces to%
\begin{align}
& \!\!\!\!\!\!w_{Z_{_{\!}+}}^{(0,_{\!}I_{\!}^{(0)},\xi
^{(0)},I_{\!+\!}^{(0)},\theta _{\!+\!}^{(0)})} \notag \\
=& \left[ 1-P_{S}^{(0)}\right] ^{|I^{(0)}-I_{+}^{(0)}|}\left[ P_{S}^{(0)}%
\right] ^{|I^{(0)}\cap I_{+}^{(0)}|}\times \notag \\
& \left[ 1-r_{B,+}^{(0)}\right] ^{|\mathbb{B}_{+}^{(0)}-I_{+}^{(0)}|}\left[
r_{B,+}^{(0)}\right] ^{|\mathbb{B}_{{+}}^{(0)}\cap I_{+}^{(0)}|}\times
\notag \\
& \left[ 1-P_{D,+}^{(0)}\right] ^{|\{\ell \in I_{+}^{(0)}:\theta
_{+}^{(0)}(\ell )=0\}|}\left[ P_{D,+}^{(0)}V^{-1}\right] ^{|\{\ell \in
I_{+}^{(0)}:\theta _{+}^{(0)}(\ell )>0\}|} \label{eq:CGprop}
\end{align}%
Thus propagation of clutter generators within each GLMB\ component reduces
to propagation of their weights
\begin{equation*}
w_{Z_{+}}^{(0,I_{+}^{(0)},\xi ^{(0)},\theta
_{+}^{(0)})}=\tsum\nolimits_{I^{(0)}}w^{(I^{(0)},\xi
^{(0)})}w_{Z_{+}}^{(0,I^{(0)},\xi ^{(0)},I_{+}^{(0)},\theta _{+}^{(0)})}.
\end{equation*}
\vspace{-3mm}
\subsection{Implementation} \label{subsec_implementation}
The key challenge in the implemention of the multi-class GLMB filter is the
propagation of the GLMB components, which involves, for each parent GLMB
component $(I,\xi )$, searching the space $\mathcal{F}(\mathbb{L}%
_{\!+})\times \Theta _{+}$ to find a set of $(I_{\!+},\theta _{\!+\!})$ such
that the children components $(I_{\!},\xi ,I_{\!+\!},\theta _{\!+\!})$ have
significant weights $\omega _{Z_{_{\!}+}}^{(_{\!}I_{\!},\xi
,I_{\!+\!},\theta _{\!+\!})}$. In \cite{VVH_GLMB17}, the set of $%
(I_{\!+},\theta _{\!+\!})$ is generated from a Gibbs sampler with stationary
distribution is constructed so that only valid children components have
positive probabilities, and those with high weights are more likely to be
sampled than those with low weights. A direct application of this approach
to generate new children would, however, be expensive, for the following
reasons.
Let $P=|I|$, $P^{(0)}=|I^{(0)}|$, $P^{(1)}=|I^{(1)}|$ and $M=|Z_{+}|$.
According to \cite{VVH_GLMB17} the complexity of the joint prediction and
update via Gibbs sampling with $T$ iterations is $\mathcal{O}(TP^{2}M)$.
Since the present formulation treat clutter as objects, the total number of
hypothesized objects $P\geq P^{(0)}\geq M$, and hence the complexity is at
least $\mathcal{O}(TM^{3})$, which is cubic in the number of measurements
and results in a relatively inefficient implementation. This occurs because
the majority of the computational effort is spent on clutter generators even
though they are not of interest. This problem is exacerbated as the clutter
rate increases.
In the following we propose a more efficient implementation by focusing on
the filtering density of the objects of interest instead of the hybrid
multi-object filtering density. Observe that given any $(I_{+}^{(1)},\theta
_{\!+\!}^{(1)})\in \mathcal{F}(\mathbb{L}_{\!+}^{(1)})\times \Theta
_{+}^{(1)}$, and $(I_{+}^{(0)},\theta _{\!+\!}^{(0)})\in \mathcal{F}(\mathbb{%
L}_{\!+}^{(0)})\times \Theta _{+}^{(0)}$, where $\Theta _{+}^{(m)}$\ denotes
the space of positive 1-1 maps from $\mathbb{L}_{+}^{(m)}$ to $\{0,1,...,M\}$%
, we can uniquely define%
\begin{equation}
(I_{\!+},\theta _{\!+\!})\triangleq (I_{+}^{(1)}\uplus I_{+}^{(0)},1_{%
\mathbb{L}_{\!+}^{(1)}}\theta _{\!+\!}^{(1)}+1_{\mathbb{L}%
_{\!+}^{(0)}}\theta _{\!+\!}^{(0)}). \label{eq:composition}
\end{equation}%
Further, the weight of the resulting component $(I_{\!},\xi
,I_{\!+\!},\theta _{\!+\!})$ is
\begin{equation}
\omega _{Z_{_{\!}+}}^{(_{\!}I_{\!},\xi ,I_{\!+\!},\theta _{\!+\!})}=1_{{%
\Theta }(I_{\!+\!})}(\theta _{\!+\!})w_{Z_{+}\!}^{\!(0,I_{\!}^{(0)},\xi
^{(0)},I_{\!+\!}^{(0)},\theta
_{\!+\!}^{\!(0)})\!}w_{Z_{+}\!}^{\!(1,I_{\!}^{(1)},\xi
^{(1)},I_{\!+\!}^{(1)},\theta _{\!+\!}^{\!(1)})\!}
\label{eq:componentweight}
\end{equation}%
see Proposition 2 (\ref{eq:proof2}). Note that if $\theta _{\!+\!}$ is not a
valid association map then $1_{{\Theta }(I_{\!+\!})}(\theta _{\!+\!})=0$,
and hence the weight is zero.
For each parent GLMB component $(I,\xi )$, rather than searching for $%
(I_{\!+},\theta _{\!+\!})$ with significant $\omega
_{Z_{_{\!}+}}^{(_{\!}I_{\!},\xi ,I_{\!+\!},\theta _{\!+\!})}$ in the space $%
\mathcal{F}(\mathbb{L}_{\!+})\times \Theta _{+}$, we:
\begin{enumerate}
\item seek $(I_{+}^{(1)},\theta _{\!+\!}^{(1)})$\ with significant $%
w_{Z_{_{\!}+}}^{(_{\!}1,I_{\!}^{(1)},\xi ^{(1)},I_{\!+\!}^{(1)},\theta
_{\!+\!}^{(1)})}$\ from the smaller space $\mathcal{F}(\mathbb{L}%
_{\!+}^{(1)})\times \Theta _{+}^{(1)}$;
\item for each such $(I_{+}^{(1)},\theta _{\!+\!}^{(1)})$ find the $%
(I_{+}^{(0)},\theta _{\!+\!}^{(0)})$ with the best $w_{Z_{_{\!}+}}^{(_{%
\!}0,I_{\!}^{(0)},\xi ^{(0)},I_{\!+\!}^{(0)},\theta _{\!+\!}^{(0)})}$,
subject to the constraint
\begin{equation}
1_{\mathbb{L}_{\!+}^{(1)}}\theta _{\!+\!}^{(1)}+1_{\mathbb{L}%
_{\!+}^{(0)}}\theta _{\!+\!}^{(0)}\in {\Theta }(I_{+}^{(1)}\uplus
I_{+}^{(0)}); \label{eq:constraint}
\end{equation}
\item construct $(I_{\!+},\theta _{\!+\!})$ from $(I_{+}^{(1)},\theta
_{\!+\!}^{(1)})$ and $(I_{+}^{(0)},\theta _{\!+\!}^{(0)})$ via (\ref%
{eq:composition}) and compute the corresponding weight via (\ref%
{eq:componentweight}).
\end{enumerate}
Due to the constraint \ref{eq:constraint}, $1_{{\Theta }(I_{\!+\!})}(\theta _{\!+\!})=1$, and
hence, it follows from (\ref{eq:componentweight}) that the resulting GLMB
component $(I_{\!},\xi ,I_{\!+\!},\theta _{\!+\!})$ also has significant
weight.
The advantage of this strategy is two fold:
\begin{itemize}
\item searching over a much smaller space $\mathcal{F}(\mathbb{L}%
_{\!+}^{(1)})\times \Theta _{+}^{(1)}$ results in a linear complexity in the
measurements $\mathcal{O}(T(P^{(1)})^{2}M)$ since typically $P^{(1)}<<M$;
\item finding $(I_{+}^{(0)},\theta _{\!+\!}^{(0)})$ with the best weight
subject to the constraint $\theta _{\!+\!}\in {\Theta }(I_{\!+\!})$ is
straight forward and requires miminal computation.
\end{itemize}
\vspace{-3mm}
\subsection{Propagating Objects of Interest}
One way to generate significant $(I_{+}^{(1)},\theta _{\!+\!}^{(1)})$\ is to
design a Gibbs sampler with stationary distribution $w_{Z_{_{\!}+}}^{(_{%
\!}1,I_{\!}^{(1)},\xi ^{(1)},I_{\!+\!}^{(1)},\theta _{\!+\!}^{(1)})}$.
However, this approach requires computing the hybrid multi-object density,
which we try to avoid in the first place.
A much more efficient alternative is to treat the multi-Bernoulli clutter as
Poisson with matching intensity, and apply the standard GLMB filter (the
JMS-GLMB filter (\ref{eq:JMSGLMB}) with a single-mode), where the Gibbs
sampler \cite{Murty68} (or Murty's algorithm \cite{Cassella_Gibbs92}) can be
used to obtain significant $(I_{+}^{(1)},\theta _{\!+\!}^{(1)})$ \cite%
{VVH_GLMB17}. Since there are $|I^{(0)}| $ clutter generators from the
previous time with survival probability $P_{S}^{(0)}$, and $|\mathbf{\mathbb{%
B}}_{+}^{(0)}|$ clutter birth with probability $r_{B,+}^{(0)}$, the
predicted clutter intensity is given by $\hat{\kappa}%
_{+}=(P_{S}^{(0)}|I^{(0)}|+r_{B,+}^{(0)}|\mathbf{\mathbb{B}}%
_{+}^{(0)}|)P_{D,+}^{(0)}V^{-1}$. Note that a Poisson RFS has larger
variance on the number of clutter points than a multi-Bernoulli with
matching intensity. Hence, in treating clutter as a Poisson RFS, we are
effectively tempering with the clutter model to induce the Gibbs sampler (or
Murty's algorithm) to generate more diverse components \cite{VVH_GLMB17}.
Following \cite{VVH_GLMB17}, let us enumerate $Z_{+}=\{z_{1:M}\}$, $%
I^{(1)}=\{\ell _{1:R}\}$, and $\mathbb{B}_{+}^{(1)}=\{\ell _{R+1:P}\}$. The $%
(I_{\!+}^{(1)},\theta _{\!+\!}^{(1)})\in $ $\mathcal{F}(\mathbb{L}%
_{+}^{(1)})\times \Theta (I_{+}^{(1)})$ at time $k+1$ with significant
weights are determined by solving a ranked assignment problem with cost
matrix $[\eta _{i}^{(\xi ^{(1)})}(j)]$, $i=1:P$,$~j=-1:M$, where%
\begin{equation*}
\eta _{i}^{(\xi ^{(1)})\!}(j)\!=\!\left\{ \!\!%
\begin{array}{ll}
1-\bar{P}_{S\!}^{(\xi ^{(1)})}(1,\ell _{i}) & \!\!\ell _{i}\in I^{(1)},~j<0
\\
\bar{P}_{S}^{(\xi ^{(1)})}(1,\ell _{i})\bar{\psi}_{Z_{+}}^{(\xi
^{(1)},\theta _{+}^{(1)})\!}(1,\ell _{i}) & \!\!\ell _{i}\in I^{(1)},~j\geq 0
\\
1-r_{B,+}(\ell _{i}) & \!\!\ell _{i}\in \mathbb{B}_{+}^{(1)},~j<0 \\
r_{B,+}(\ell _{i})\bar{\psi}_{Z_{+}}^{(\xi ^{(1)},\theta
_{+}^{(1)})\!}(1,\ell _{i}) & \!\!\ell _{i}\in \mathbb{B}_{+}^{(1)},~j\geq 0%
\end{array}%
\right.
\end{equation*}%
\begin{eqnarray*}
\bar{\psi}_{Z_{+}}^{(\xi ^{(1)},\theta _{+}^{(1)})}(1,\ell )\!\!
&=&\!\!\left\langle \bar{p}_{+}^{(\xi ^{(1)})}(\cdot ,1,\ell ),\psi
_{Z_{+}}^{(\theta _{+}^{(1)}(\ell ))}(\cdot ,1,\ell )\right\rangle \\
\psi _{Z_{+}}^{(j)}(\zeta ,1,\ell )\!\! &=&\!\!\left\{ \!%
\begin{array}{ll}
\frac{P_{D,+}^{(1)}(\zeta ,\ell )g_{+}^{(1)}(z_{j}|\zeta ,\ell )\!}{\hat{%
\kappa}_{+}}, & \!\!\RIfM@\expandafter\text@\else\expandafter\mbox\fi{if }j\in \left\{ 1,...,M\right\} \\
1-P_{D,+}^{(1)}(\zeta ,\ell ), & \!\!\RIfM@\expandafter\text@\else\expandafter\mbox\fi{if }j=0%
\end{array}%
\right.
\end{eqnarray*}%
Such a ranked assignment problem can be solved by Murty's algorithm or the
Gibbs sampler given in Section III-D \cite{VVH_GLMB17}.
\vspace{-3mm}
\subsection{Propagating Clutter Generators}
Given $(I_{\!+}^{(1)},\theta _{\!+\!}^{(1)})$ pertaining to the objects of
interest, we proceed to determine $(I_{\!+}^{(0)},\theta _{\!+\!}^{(0)})$
pertaining to clutter generators, which maximizes $\omega
_{Z_{_{\!}+}}^{(_{\!}0,I_{\!}^{(0)},\xi ^{(0)},I_{\!+\!}^{(0)},\theta
_{\!+\!}^{(0)})}$ where $I_{\!+\!}^{(0)}\subseteq $ $_{\!}I_{\!}^{(0)}\cup
\mathbb{B}_{+}^{(0)}$ and $\theta _{\!+\!}^{(0)}:I_{\!+\!}^{(0)}\rightarrow
\{0:M\}$ subject to constraint (\ref{eq:constraint}).
Denote by $Z_{+}^{(1)}\subseteq Z_{+}$ the set of measurements assigned to $%
I_{\!+}^{(1)}$ by $\theta _{\!+\!}^{(1)}$ and the remaining set of
measurements $Z_{+}-$ $Z_{+}^{(1)}$, due to clutter generators, by $%
Z_{+}^{(0)}$. Recall that clutter generators are functionally identical
except in label and that their propagation reduces to calculating their
corresponding weights (\ref{eq:CGprop}). Let $N_{S}^{(0)}=|I^{(0)}\cap
I_{+}^{(0)}|$ and $N_{B,+}^{(0)}=|\mathbb{B}_{{+}}^{(0)}\cap I_{+}^{(0)}|$
denote the counts of surviving and new born clutter generators respectively.
Then $|I^{(0)}-I_{+}^{(0)}|=|I^{(0)}|-N_{S}^{(0)}$ and $|\mathbb{B}%
_{+}^{(0)}-I_{+}^{(0)}|=|\mathbb{B}_{+}^{(0)}|-N_{B,+}^{(0)}$. Observe that
the count $|Z_{+}^{(0)}|$ of clutter must equal the number of detections of
clutter generators according to $(I_{\!+}^{(0)},\theta _{\!+\!}^{(0)})$,
i.e. $|Z_{+}^{(0)}|=|\{\ell \in I_{+}^{(0)}:\theta _{+}^{(0)}(\ell )>0\}|$
and hence the count of misdetections of clutter generators according to $%
(I_{\!+}^{(0)},\theta _{\!+\!}^{(0)})$ is $%
N_{S}^{(0)}+N_{B,+}^{(0)}-|Z_{+}^{(0)}|=|\{\ell \in I_{+}^{(0)}:\theta
_{+}^{(0)}(\ell )=0\}|$. Consequently the weight (\ref{eq:CGprop}) can be
rewritten as
\begin{align*}
& \!\!\!\!\!\!\!\!\omega _{Z_{_{\!}+}}^{(0,I_{\!}^{(0)},\xi
^{(0)},I_{\!+\!}^{(0)},\theta _{\!+\!}^{(0)})}\! \\
=& \left[ 1-P_{S}^{(0)\!}\right] ^{\!|I^{(0)\!}|-N_{S}^{(0)}}\!\!\!\left[
P_{S}^{(0)\!}\right] ^{\!N_{S}^{(0)}}\!\!\!\left[ 1-r_{B,+\!}^{(0)}\right]
^{\!|\mathbb{B}_{+}^{(0)}|-N_{B,+}^{(0)}}\times \\
& \left[ r_{B,+\!}^{(0)}\right] ^{\!N_{B,+}^{(0)}}\left[ 1-P_{D,+}^{(0)\!}%
\right] ^{\!N_{S}^{(0)}+N_{B,+}^{(0)}-|Z_{+}^{(0)\!}|}\!\left[
P_{D,+}^{(0)\!}V^{-1}\right] ^{\!|Z_{+}^{(0)}|} \\
\propto & \left[ \!\frac{P_{S}^{(0)}(1-P_{D,+}^{(0)})}{1-P_{S}^{(0)}}\!%
\right] ^{\!N_{S}^{(0)}}\!\left[ \!\frac{r_{B,+}^{(0)}(1-P_{D,+}^{(0)})}{%
1-r_{B,+}^{(0)}}\!\right] ^{\!N_{B,+}^{(0)}}
\end{align*}%
Thus seeking the best $(I_{\!+}^{(0)},\theta _{\!+\!}^{(0)})$ subject to
constraint (\ref{eq:constraint}) reduces to seeking the best $%
(N_{S}^{(0)},N_{B,+}^{(0)})$ subject to the constraints $0\leq
N_{S}^{(0)}\leq $ $|I^{(0)}|$, $0\leq N_{B,+}^{(0)}\leq $ $|\mathbb{B}%
_{+}^{(0)}|$ and $N_{S}^{(0)}+N_{B,+}^{(0)}\leq |Z_{+}^{(0)}|$.
\vspace{-3mm}
\subsection{Linear Gaussian Update Parameters}
Let $\mathcal{N}(\cdot ;\bar{\zeta},P)$ denotes a Gaussian density with mean
$\bar{\zeta}$ and covariance $P$. Then for a linear Gaussian multi-object
model of the objects of interest $P_{S}^{(1)}(\zeta ,\ell )=P_{S}^{(1)}$, $%
P_{D}^{(1)}(\zeta ,\ell )=P_{D}^{(1)}$, $f_{+}^{(1)}(\zeta _{+}|\zeta ,\ell
)=\mathcal{N}(\zeta _{+};F\zeta ,Q)$, $g^{(1)}(z|\zeta ,\ell )=\mathcal{N}%
(z;H\zeta ,R)$, and $p_{B,+}^{(1)}(\zeta _{+})=\mathcal{N}(\zeta _{+};\bar{%
\zeta}_{+}^{(1)},P_{+}^{(1)})$, where $F$ is the transition matrix, $Q$ is
the process noise covariance, $H$ is the observation matrix, $R$ is the
observation noise covariance, $\bar{\zeta}_{+}^{(1)}$ and $P_{+}^{(1)}$ are
the mean and covariance of the kinematic state of a new object of interest.
If each current density of an object of interest is a Gaussian of the form%
\begin{equation}
p^{(\xi ^{(1)})_{\!}}(\zeta ,1,\ell )=\mathcal{N}(\zeta ;\bar{\zeta}^{(\xi
^{(1)})}(\ell ),P^{(\xi ^{(1)})}(\ell )) \label{eq:GM_single_pdf}
\end{equation}%
then the terms (\ref{eq:mclassGLMB4}), (\ref{eq:mclassGLMB5}), (\ref%
{eq:mclassGLMB6}) can be computed analytically using the following
identities:
\begin{equation*}
\int \mathcal{N}(\zeta ;\bar{\zeta},P)\mathcal{N}(\zeta _{+};F\zeta
,Q)d\zeta =\mathcal{N}(\zeta _{+};F\bar{\zeta},FPF^{T}+Q),
\end{equation*}%
\begin{eqnarray*}
&&\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\mathcal{N}%
(\zeta ;\bar{\zeta},P)\mathcal{N}(z;H\zeta ,R) \\
&=&q(z)\mathcal{N}(\zeta ;\bar{\zeta}+K(z-H\bar{\zeta}),[I-KH]P), \\
q(z) &=&\mathcal{N}(z;H\bar{\zeta},HPH^{T}+R), \\
K &=&PH^{T}\left[ HPH^{T}+R\right] ^{-1}.
\end{eqnarray*}
\vspace{-4mm}
\subsection{Extension to Unknown Detection Probability}
\label{subsec_UPD}
Following the approach in \cite{MVV10}, to jointly estimate an unknown
detection probability, we augment a variable $a\in \lbrack 0,1]$ to the
state, i.e. $\mathbf{x}=(\zeta ,m,a,\ell )$, so that
\begin{equation}
P_{D}^{(m)}(\zeta ,a,\ell )=a.
\end{equation}%
Additionally, in this model $g^{(m)}(z|\zeta ,a,\ell )=g^{(m)}(z|\zeta ,\ell
)$, $P_{S}^{(m)}(\zeta ,a,\ell )=P_{S}^{(m)}$, $p_{B,+}^{(1)}(\zeta
_{+},a_{+})=p_{B,+}^{(1)}(\zeta _{+})p_{B,+}^{(1)}(a_{+})$, and the
transition density is given by
\begin{equation}
f_{+}^{(m)}(\zeta _{+},a_{+}|\zeta ,a,\ell )=f_{+}^{(m)}(\zeta _{+},|\zeta
,\ell )f_{+}^{(\Delta )}(a_{+}|a).
\end{equation}%
The unknown detection probability is then modelled on a Beta distribution $%
\beta (\cdot ,s,t)$ where $s$ and $t$ are positive shape parameters and the
single-object state density is modelled by a Beta-Gaussian density:%
\begin{eqnarray*}
&&\!\!\!\!\!\!\!p^{(\xi ^{(1)})_{\!}}(\zeta ,1,a,\ell ) \\
&=&\beta (a;s^{(\xi ^{(1)})}(\ell ),t^{(\xi ^{(1)})}(\ell ))\mathcal{N}%
(\zeta ;m^{(\xi ^{(1)})}(\ell ),P^{(\xi ^{(1)})}(\ell )
\end{eqnarray*}
Note that in practice, we only use the Beta model for the unknown detection
probability of the objects of interest. For clutter generators, we use a
fixed detection probability between 0.5 and 1. Values close to 0.5 result in
a large variance on the clutter cardinality and faster reponse to changes in
clutter parameter, while the converse is true for values close to 1.
Analytic computation of the terms (\ref{eq:mclassGLMB4}), (\ref%
{eq:mclassGLMB5}), (\ref{eq:mclassGLMB6}) can be performed separately for
the Gaussian part (which has been given in the previous subsection) and the
Beta part using \cite{MVV10}:
\begin{equation*}
\beta (a_{+};s_{+},t_{+})=\int \beta (a;s,t)f_{+}^{(\Delta )}(a_{+}|a)da
\end{equation*}%
where
\begin{eqnarray*}
s_{+} &=&\left( \frac{\mu _{\beta }(1-\mu _{\beta })}{\sigma _{\beta }^{2}}%
-1\right) \mu _{\beta }, \\
t_{+} &=&\left( \frac{\mu _{\beta }(1-\mu _{\beta })}{\sigma _{\beta }^{2}}%
-1\right) \left( 1-\mu _{\beta }\right) . \\
\mu _{\beta } &=&\frac{s}{s+t}\;,\;\;\;\;\;\sigma _{\beta }^{2}=\frac{st}{%
(s+t)^{2}(s+t+1)}
\end{eqnarray*}%
(note that $\beta (\cdot ;s_{+},t_{+})$ has the same mean $\mu _{\beta }$ as
$\beta (\cdot ;s,t)$ but a larger variance than $\sigma _{\beta }$) and%
\begin{eqnarray*}
(1-a)\beta (a;s,t) &=&\frac{B(s,t+1)}{B(s,t)}\beta (a;s,t+1), \\
a\beta (a;s,t) &=&\frac{B(s+1,t)}{B(s,t)}\beta (a;s+1,t),
\end{eqnarray*}%
where $B(s,t)=\tint\nolimits_{0}^{1}a^{s-1}(1-a)^{t-1}da$.
\section{Numerical Studies}
\subsection{Simulations}
The following simulation scenario is used to test the proposed robust
multi-object filter. The target state vector $[x,y,\dot{x},\dot{y}]^{T}$
consists of cartesian coordinates and the velocities. Objects of interest
move according to a constant velocity model, with zero-mean Gaussian process
noise of covariance%
\begin{equation*}
Q_{f}={v_{f}}^{2}%
\begin{bmatrix}
T^{4}/4 & T^{3}/2 & 0 & 0 \\
T^{3}/2 & T^{2} & 0 & 0 \\
0 & 0 & T^{4}/4 & T^{3}/2 \\
0 & 0 & T^{3}/2 & T^{2}%
\end{bmatrix}%
\end{equation*}%
where $v_{f}=5ms^{-1}$ and $T=1s$. Objects of interest are born from a
labeled multi Bernoulli distribution with four components of 0.03 birth
probability, and birth densities
\begin{eqnarray*}
&&\mathcal{N}(\cdotp,[0,0,0,0]^{T},P_{\gamma }), \\
&&\mathcal{N}(\cdotp,[400,-600,0,0]^{T},P_{\gamma }), \\
&&\mathcal{N}(\cdotp,[-800,-200,0,0]^{T},P_{\gamma }), \\
&&\mathcal{N}(\cdotp,[-200,800,0,0]^{T},P_{\gamma }),
\end{eqnarray*}%
where $P_{\gamma }=\diag([50,50,50,50]).$ The probability of survival is set
at 0.99.
Objects of interest enter and leave the observation region $%
[-1000,1000]m\times \lbrack -1000,1000]m$ at different times reaching a maximum
of ten targets. The measurements are the object positions
obtained through a sensor located at coordinate $(0,0)$. Measurement noise
is assumed to be distributed Gaussian with zero-mean and covariance $Q_{r}
$ where $v_{r}=3ms^{-1}$.
\begin{equation*}
Q_{r}={v_{r}}^2%
\begin{bmatrix}
1 & 0 \\
0 & 1%
\end{bmatrix}%
\end{equation*}
The detection model parameters for all new born objects of interest are set
at $s= 9$ and $t=1$ resulting in a mean of 0.9 for the detection probability.
At the initial timestep, clutter generators are born from a (labeled)
multi-Bernoulli distribution with 120 components, each with 0.5 birth
probability and uniform birth density. At subsequent timesteps clutter
generators are born from a (labeled) multi-Bernoulli distribution with 30
components, each with 0.5 birth probability and uniform birth density.
Probability of survival and probability of detection of the clutter
generators are both set at 0.9.
Four scenarios corresponding to four different pairings of average
(unknown) clutter rate and detection probability (see Table 1) are studied.
\begin{table}[tbp]
\centering
\begin{tabular}{|c|c|c|}
\hline
\multirow{2}{*}{Scenario ID} & \multirow{2}{*}{Clutter Rate} & %
\multirow{2}{*}{Detection Probability} \\
& & \\
\hline
\multirow{2}{*}{1} & \multirow{2}{*}{10} & \multirow{2}{*}{0.97} \\ [2ex]
\hline
\multirow{2}{*}{2} & \multirow{2}{*}{10} & \multirow{2}{*}{0.85} \\ [2ex]
\hline
\multirow{2}{*}{3} & \multirow{2}{*}{70} & \multirow{2}{*}{0.97} \\ [2ex]
\hline
\multirow{2}{*}{4} & \multirow{2}{*}{varying between 25-35} & \multirow{2}{*}{0.95} \\ [2ex]
\hline
\end{tabular}
\vspace{\baselineskip}
\caption{Simulation Parameters unknown to the filter}
\label{my-label}
\end{table}
The Fig. \ref{fig:fig1subfig1} shows the OSPA\cite{SVV08} errors obtained from 100 Monte Carlo
runs (OSPA c = 300, p = 1) for the proposed GLMB filter in comparison with $%
\lambda $-CPHD\cite{MVV10} filter for scenario 1.
Estimated clutter rates and detection probabilites by the two filters are
shown in Fig. \ref{fig:fig1subfig2}, while estimated tracks for objects of interest taken from
a single run is shown in Fig. \ref{fig:fig1subfig3}. It can be seen that for the given
parameters, the GLMB filter performs far better than the $\lambda $-CPHD
in terms of clutter rate, detection probability and track
estimation for objects of interest.
We further investigate the performance of the proposed algorithm by varying
the background parameters in scenarios 2 and 3. The average detection
probability in scenario 2 is lower than that of scenario 1, while the
average clutter rate in scenario 3 is higher than that of scenario 1. Note from Figure \ref{fig:Scenario1} that
$\lambda $-CPHD filter begins to fail in scenario 1. The
OSPA errors for 100 Monte Carlo runs, estimates of the clutter
rate and detection probabilities for the more challenging scenarios 2 and 3 are given in Fig.
\ref{fig:Scenario2}, Fig. \ref{fig:Scenario3} at which $\lambda $-CPHD competely breaks down. On the other hand the proposed GLMB filter is capable of accurately tracking the objects of
interest as well as estimating the unknown clutter and detection parameters.
The fourth scenario comprises of a wavering clutter rate with comparison to the
$\lambda $-CPHD\ filter. Perceiving Fig. \ref{fig:Scenario4} it is clear that that the proposed filter outperforms $\lambda $-CPHD and is quite adept at converging swiftly to the shifted clutter rate.
\begin{figure}[ht]
\centering
\subfigure[OSPA Error]{
\label{fig:fig1subfig1}
\includegraphics[trim=20 0 30 0,clip,width=0.48\textwidth]{sim1_may31_ospatest.png}
}
\subfigure[estimated clutter and detection parameters]{
\label{fig:fig1subfig2}
\includegraphics[trim=30 0 20 0,clip,width=0.5\textwidth]{sim1_may31_params.png}
}
\subfigure[Track Estimations]{
\label{fig:fig1subfig3}
\includegraphics[trim=10 0 10 0,clip,width=0.5\textwidth]{sim1_may31_tracks.png}
}
\caption[Scenario 1]{Scenario 1. The bumps in the OSPA error for GLMB in \ref{fig:fig1subfig1} appear close to time steps where a new birth or a death of an object of interest occurs. }
\label{fig:Scenario1}
\end{figure}
\begin{figure}[ht]
\centering
\subfigure[OSPA Error]{
\label{fig:fig2subfig1}
\includegraphics[trim=15 0 30 0,clip,width=0.48\textwidth]{sim2_may31_ospatest.png}
}
\subfigure[estimated clutter and detection parameters]{
\label{fig:fig2subfig2}
\includegraphics[trim=10 0 20 0,clip,width=0.5\textwidth]{sim2_may31_params.png}
}
\caption[Scenario 2]{Scenario 2. Comparison with $\lambda $-CPHD not included as it completely fails at this juncture.}
\label{fig:Scenario2}
\end{figure}
\begin{figure}[ht]
\centering
\subfigure[OSPA Error]{
\label{fig:fig3subfig1}
\includegraphics[trim=15 0 30 0,clip,width=0.48\textwidth]{sim3_may31_ospatest.png}
}
\subfigure[estimated clutter and detection parameters]{
\label{fig:fig3subfig2}
\includegraphics[trim=10 0 20 0,clip,width=0.5\textwidth]{sim3_may31_params.png}
}
\caption[Scenario 3]{Scenario 3. Comparison with $\lambda $-CPHD not included as it completely fails at this juncture.}
\label{fig:Scenario3}
\end{figure}
\begin{figure}[ht]
\centering
\subfigure[OSPA Error]{
\label{fig:fig4subfig1}
\includegraphics[trim=20 0 30 0,clip,width=0.48\textwidth]{sim4_may31_ospatest.png}
}
\subfigure[estimated clutter and detection parameters]{
\label{fig:fig4subfig2}
\includegraphics[trim=20 10 20 0,clip,width=0.5\textwidth]{sim4_may31_params.png}
}
\caption[Scenario 4]{Scenario 4.}
\label{fig:Scenario4}
\end{figure}
\vspace{-4mm}
\subsection{Video Data}
The proposed filter for jointly unknown clutter rate and detection probability is tested on two image sequences: S2.L1 from PETS2009 datasets \cite{PETS} and KITTI-17 from KITTI datasets \cite{Geiger2012CVPR}. The detections are obtained using the detection algorithm in \cite{DOLLAR2014}.
\textit{Dataset 1:} The state vector consists of the target $x,y$ positions
and the velocities in each direction. The process noise is assumed to be
distributed from a zero-mean Gaussian with covariance $Q_{f}$ where $v_{f}=2$
pixels. Actual targets are assumed to be born from a labeled multi Bernoulli
distribution with seven components of 0.03 birth probability, and Gaussian
birth densities,
\vspace{-2mm}
\begin{eqnarray*}
&&\!\!\!\!\!\!\mathcal{N}(\cdotp,[260;260;0;0]^{T},P_{\gamma }),
\mathcal{N}(\cdotp,[740;370;0;0]^{T},P_{\gamma }), \\
&&\!\!\!\!\!\!\mathcal{N}(\cdotp,[10;200;0;0]^{T},P_{\gamma }),
\mathcal{N}(\cdotp,[280;80;0;0]^{T},P_{\gamma }), \\
&&\!\!\!\!\!\!\mathcal{N}(\cdotp,[750;130;0;0]^{T},P_{\gamma }),
\mathcal{N}(\cdotp,[650;270;0;0]^{T},P_{\gamma }), \\
&&\!\!\!\!\!\!\mathcal{N}(\cdotp,[500;200;0;0]^{T},P_{\gamma }), \RIfM@\expandafter\text@\else\expandafter\mbox\fi{ where } P_{\gamma }=\diag([10;10;3;3]).
\end{eqnarray*}%
The observation space is a $756\times 560$ pixel image frame. Actual target measurements contain the $x,y$
positions with measurement noise assumed to be distributed zero-mean Gaussian with covariance $Q_{r}$ with $v_{r}=3$ pixels. Clutter targets
are born from a multi Bernoulli distribution with 30 birth components in the
firstmost time step and 12 components in subsequent time steps each with 0.5
birth probability and uniform birth density. Probability of survival and
detection for clutter targets are both set at 0.9.
The Fig. \ref{fig:videotrack} shows tracking results at frames 20, 40 and 100
respectively. True and estimated clutter cardinality statistics are given in
Fig. \ref{fig:video1clrate}. From these figures it can be observed that the
filter successfully outputs object tracks and that the estimated clutter
rate nearly overlays the true clutter rate.
\textit{Dataset 2:} The detection results from this dataset (KITTI17) comprises of a higher number of false measurements than the PETS2009 S2.L1 dataset. The state vector consists of
the target $x,y$ positions and the velocities in each direction. The process
noise is assumed to be distributed from a zero-mean Gaussian with covariance
$Q_{f}$ where $v_{f}=2$ pixels. Actual targets are assumed to be born from a
labeled multi Bernoulli distribution with three components of 0.05 birth
probability, and birth densities
\begin{eqnarray*}
&&\!\!\!\!\!\!\mathcal{N}(\cdotp,[550;200;0;0]^{T},P_{\gamma }),
\mathcal{N}(\cdotp,[1200;250;0;0]^{T},P_{\gamma }), \\
&&\!\!\!\!\!\!\mathcal{N}(\cdotp,[500;250;0;0]^{T},P_{\gamma }) \RIfM@\expandafter\text@\else\expandafter\mbox\fi{where } P_{\gamma }=\diag([10;10;1;1]).
\end{eqnarray*}
\vspace{-2mm}
State transition function for actual targets are based on constant velocity
model with a 0.99 probability of survival. Process noise is assumed to be
distributed from a zero-mean Gaussian with covariance $Q_{f}$ with $v_{f}=2$
pixels per frame. The observation space is a 1220$\times $350 pixel image
frame. Actual target measurements contain the $x,y$ positions with
measurement noise assumed to be distributed zero-mean Gaussian with
covariance $Q_{r}$ with $v_{r}=3$ pixels. Clutter target are born from 60
identical and uniformly distributed birth regions in the firstmost time step
and 20 birth regions in the subsequent time steps each with a birth
probability of 0.5. Probability of survival and detection for clutter
targets are both set at 0.9.
\begin{figure}[H]
\centering
\subfigure{
\label{fig:subfig1}
\includegraphics[scale=0.4]{frame20_2.png}
}
\subfigure{
\label{fig:subfig2}
\includegraphics[scale=0.4]{frame40_2.png}
}
\subfigure{
\label{fig:subfig4}
\includegraphics[scale=0.4]{frame100_2.png}
}
\caption[Optional caption for list of figures]{Tracking results for frames
20, 40, 100 in dataset 1. }
\label{fig:videotrack}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[scale=0.55, trim= 35 0 20 20]{vid1_22.png}
\caption{Estimated clutter rate for dataset 1.}
\label{fig:video1clrate}
\end{figure}
The frames on the left of Fig. \ref{fig:videotrack2} shows tracking
results for frames 15, 35 and 50 obtained from the standard GLMB filter for
the guessed clutter rate of 60. The frames on the right of Fig. \ref%
{fig:videotrack2} shows tracking results for the same frames using the
proposed filter. When comparing each frame pair it can be noted that some
objects that were missed by the standard algorithm with the guessed clutter
rate has been picked up by the proposed algorithm. Comparison between true
and estimated clutter cardinality statistics given in Fig. \ref%
{fig:video2clrate} demonstrates that the estimated clutter rate is close
enough to the true clutter rate to achieve a similar performance if fed back to the standard algorithm\cite{VVP_GLMB13}.
\begin{figure*}[h]
\centering
\subfigure{
\label{fig:subfig1}
\includegraphics[scale=0.28, trim= 20 0 20 0]{sam2_fig_15_60.png}}%
\subfigure{
\label{fig:subfig1}
\includegraphics[scale=0.28, trim= 20 0 20 0]{sam2_fig_15_un.png}
}
\subfigure{
\label{fig:subfig1}
\includegraphics[scale=0.28, trim= 20 0 20 0]{sam2_fig_35_60.png}}%
\subfigure{
\label{fig:subfig1}
\includegraphics[scale=0.28, trim= 20 0 20 0]{sam2_fig_35_un.png}
}
\subfigure{
\label{fig:subfig5}
\includegraphics[scale=0.28, trim= 20 0 20 0]{sam2_fig_50_60.png}}%
\subfigure{
\label{fig:subfig6}
\includegraphics[scale=0.28, trim= 20 0 20 0]{sam2_fig_50_un.png}
}
\caption[Examples of tracking results for frames 15,35,50 with guessed
clutter rate 60 (on left) and the proposed filter (on right)]{Tracking results for frames 15,35,50 with guessed clutter rate 60 (left) and the proposed filter (right) for dataset 2.}
\label{fig:videotrack2}
\end{figure*}
\begin{figure}[tbp]
\centering
\includegraphics[scale=0.6, trim= 35 0 20 20]{vid2_22.png}
\caption{Estimated clutter rate for dataset 2.}
\label{fig:video2clrate}
\end{figure}
\vspace{-2mm}
\section{Conclusion}
In this paper we have proposed a tractable algorithm for tracking multiple
objects in environments with unknown model parameters, such as clutter rate
and detection probability, based on the GLMB filter. Specifically, objects
of interest and clutter objects are treated as non-interacting classes of
objects, and a GLMB recursion for propagating the joint filtering density of
these classes are derived, along with an efficient implementation.
Simulations and applications to video data demonstrate that the proposed
filter has good tracking performance in the presence of unknown background
and outperforms the $\lambda $-CPHD filter. Moreover, it can also estimate
the clutter rate and detection probability parameters while tracking.
\providecommand{\url}[1]{#1} \csname url@samestyle\endcsname%
\providecommand{\newblock}{\relax} \providecommand{\bibinfo}[2]{#2} %
\providecommand{\BIBentrySTDinterwordspacing}{\spaceskip=0pt\relax} %
\providecommand{\BIBentryALTinterwordstretchfactor}{4}
\providecommand{\BIBentryALTinterwordspacing}{\spaceskip=\fontdimen2\font plus
\BIBentryALTinterwordstretchfactor\fontdimen3\font minus
\fontdimen4\font\relax}
\providecommand{\BIBforeignlanguage}[2]{{\expandafter\ifx\csname l@#1\endcsname\relax
\typeout{** WARNING: IEEEtran.bst: No hyphenation pattern has been}\typeout{** loaded for the language `#1'. Using the pattern for}\typeout{** the default language instead.}\else
\language=\csname l@#1\endcsname
\fi
#2}} \providecommand{\BIBdecl}{\relax} \BIBdecl
\vspace{-4mm}
| {'timestamp': '2017-07-20T02:04:39', 'yymm': '1706', 'arxiv_id': '1706.01584', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01584'} | arxiv |
\section{Example: A Secure Cloud Server}
\label{sec:example}
\begin{figure}
\small
\[
\begin{array}{l}
Server \equiv \\\new{usage}{ \arrayType{\Int}_{\bot}}{\{0,0,0\}};\\
\new{blocked}{ \arrayType{\Int}_{\bot}}{\{0,0,0\}};\\
\new{nextID}{ \Int_{\bot}}{0};\\
RegisterUsers ~|~CheckUsag
\\[4mm]
RegisterUsers \equiv \\
!~\acceptPub{\mathit{newUsers}}{\chanTypePub{\arrayType{\pubKeyType}_{\bot}}};\\
~~\inputChanII{newUsers}{client1Client2};\\
~~\letk{client1}{client1Client2[0]} \\
~~\letk{client2}{client1Client2[1]} \\
~~\sync~\{ \\
~~~~\new{accountID}{\Int_\bot}{nextID}; \\
~~~~nextID = nextID+1;\}\\
~~\mathbf{if}~(accountID \leq 2)~\mathbf{then} \{\\
~~~~\new{data}{\Int_{\{\publicKey{Server},client1,client2\}}}{0};\\
~~~~ServeClient(client1,client2,client1)
\\~~|~~ServeClient(client1,client2,client2)~\}
\\[4mm]
CheckUsage \equiv !~\sync \{\\
~~\new{total}{\Int_\bot\!}{\!usage[0]+usage[1]+usage[2]+3};\\
~~\{~\condnb{usage[0]>total/2}{\\
~~~~\assign{blocked[0]}{1}}{\assign{blocked[0]}{0}};\\
~~|~\condnb{usage[1]>total/2}{\\
~~~~\assign{blocked[1]}{1}}{\assign{blocked[1]}{0}};\\
~~|~\condnb{usage[2]>total/2}{\\
~~~~\assign{blocked[2]}{1}}{\assign{blocked[2]}{0}};\}
\\[4mm]
ServeClient(c1,c2,c3) \equiv \\
!~\acceptCCert{upload}{\chanTypePub{\Int_{\{Server,c1,c2\}}}\\
~~~~}{c3}{Server};\\
~~\mathbf{if}~(blocked[accountID]=0)~\mathbf{then} \{\\
~~~~\inputChanII{upload}{z};\\
~~~~usage[accountID] = usage[accountID] + 1;\\
~~~~data=z;\}\\
|~ !~\acceptCCert{dowload}{\chanTypePub{\Int_{\{Server,c1,c2\}}}\\
~~~~}{c3}{Server};\\
~~\mathbf{if}~(blocked[accountID]=0)~\mathbf{then} \{\\
~~~~usage[accountID] = usage[accountID] + 1;\\
~~~~\outputChan{data}{download};\}\\
\end{array}
\]
\caption{An example server that monitors the clients usage but not their data}
\label{fig:example}
\end{figure}
\begin{figure}
\[\!
\begin{array}{l}
Sender \equiv \\
~~~ \acceptPub{\mathit{otherPrin}}{\chanTypePub{\pubKeyType_{\bot}}};\\
~~~ \inputChanII{otherPrin}{mobileKey};\\
~~~ \letk{mobile}{mobileKey}\\
~~~ \newPrin{Alice}{\{mobile\}};\\
~~~ \acceptPub{\mathit{releasedPrin}}{\chanTypePub{\privKeyType_{\bot}}};\\
~~~ \outputChan{\release{Alice}}{releasedPrin};\\
~~~ \acceptPub{\mathit{c}}{\chanTypePub{\pubKeyType_{\bot}}};\\
~~~ \inputChanII{c}{bobKey};\\
~~~ \outputChan{otherPrin}{bobKey};\\
~~~ \letk{bob}{bobKey}\\
~~~ \outputChan{\publicKey{Alice}}{c};\\
~~~ \connectPub{newUsers}{\chanTypePub{\arrayType{\pubKeyType}_{\bot}}};\\
~~~ \outputChan{\{\publicKey{Alice},bobKey\}}{newUsers};\\
~~~ Send(Alice,bob,42) \\
\\
Send(p,k,v) \equiv \\
~~~ \connectCCert{upload}{\chanTypePub{\Int_{\{srvKey,\publicKey{p},k\}}}\\~~~~~}{srvKey}{p};\\
~~~ \new{sharedSecret}{ \Int_{\{srvKey,\publicKey{p},k\}}}{v};\\
~~~ \outputChan{sharedSecret}{upload};\\
\\
Mobile \equiv \\
~~~ \newPrin{Mobile}{\{\}};\\
~~~ \connectPub{\mathit{keyChan}}{\chanTypePub{\pubKeyType_{\bot}}};\\
~~~ \outputChan{\publicKey{Mobile}}{keyChan};\\
~~~ \connectPub{\mathit{releaseChan}}{\chanTypePub{\privKeyType_{\bot}}};\\
~~~ \inputChanII{releaseChan}{encaps}\\
~~~ \registerII{Mobile}{encaps}{MyId}\\
~~~ \inputChanII{keyChan}{bobKey};\\
~~~ \letk{bob}{bobKey} Send(MyId,bob,24)\\
\\
Receiver \equiv\\
~~~ \newPrin{Bob}{\{\}};\\
~~~ \connectPub{fromBob}{\chanTypePub{\pubKeyType_{\bot}}};\\
~~~ \outputChan{\publicKey{Bob}}{fromBob};\\
~~~ \inputChanII{fromBob}{aliceKey};\\
~~~ \letk{alice}{aliceKey} \\
~~~ \connectCCert{download}{\chanTypePub{\Int_{\{srvKey,alice,\publicKey{Bob}\}}}\\~~~~~}{srvKey}{Bob};\\
~~~ \inputChanII{download}{data};\\
\end{array}\!
\]
\caption{Definitions of Sender, Receiver and Mobile Processes}
\label{fig:example-2-a}
\end{figure}
\begin{figure}[ht]
\[
\begin{array}{lcl}
SD & \equiv & \langle \{ srvKey \mapsto k^+_s\} \blacktriangleright Sender \rangle \\
MD & \equiv & \langle \{ srvKey \mapsto k^+_s\} \blacktriangleright Mobile \rangle\\
RD & \equiv & \langle \{ srvKey \mapsto k^+_s\} \blacktriangleright Receiver \rangle\\
Srv & \equiv & \langle \{Server \mapsto \prin{k^+_s}{k^-_s}{ \{ \}} \} \blacktriangleright Server \rangle \\
System & \equiv & SD \mid MD \mid RD \mid RD \mid Srv
\end{array}
\]
\caption{The server context with 4 devices: a sender with its mobile device and two concurrent receivers}
\label{fig:example-2-b}
\end{figure}
As an extended example we consider a cloud server that provides a data storage service.
The motivation of our work is to make it possible to type an open cloud service,
without the need for a global PKI neither the need to verify that
its users run typed programs,
so ensuring that it provides security guarantees to all of its users.
The server process in Figure~\ref{fig:example} defines an open service which users can connect to and register to store data.
This data can be shared with another principal, hence the server takes a pair of public keys,
representing the principals, when registering.
To keep the example simple this server accepts up to 3 accounts and denies further registrations.
The data for each accounts is stored in the data variable defined in the $RegisterUsers$ process;
the restriction set used to type this variable specifies that only the server and the two clients named at registration
can have knowledge of this data.
Additionally, the server keeps track of how often each account is used (in the $usage$ array)
and runs a process to monitor the usage (the $CheckUsage$ process).
If any account is found to have made more than 50\% of the total number of requests (plus $3$),
it is temporarily blocked (by setting the corresponding index in the $blocked$ array to 1).
The usage data and blocked status are public data.
This is an example of an open cloud service which writes to public variables after processing private data.
Our type system ensures that there is no leakage between the two.
An example configuration is given in \autoref{fig:example-2-b}, with the
definitions of the processes provided in
\autoref{fig:example-2-a}: this configuration consists of four devices $SD$, $MD$ and two identical $RD$ devices.
We assume that, in the physical world,
$SD$ and $MD$ are the laptop and respectively the mobile of Alice while the two other devices $RD$ are owned by Bob and Charlie.
In the system definition, Alice's and Bob's devices start off knowing the servers public key,
but the server has no knowledge of Alice's and Bob's principals.
The mobile device $MD$ first creates a new principal identity and shares the public key to $SD$.
Note that $RD$ could also send its private key to $SD$ at this point which is not the expected behavior.
To avoid honest users to establish unwanted connection, a port number mechanism should be added to the connections rules.
Once $SD$ receives the principal's public key from $MD$,
$SD$ creates a new principal identity to use with the cloud service which is known by the mobile's principal identity.
This allows $SD$ to release and to send the new principal $Alice$ to $MD$ which registers it.
Therefore both $SD$ and $MD$ can use the service with the same account.
Finally Bob's device $RD$ and $SD$ exchange their public keys,
and $SD$ sends to $MD$ the public key received from $RD$
then $SD$ registers for a shared account between $\pub(Alice)$ and $bobKey$ on the server.
Finally, $SD$ or $MD$ can upload a $sharedSecret$ value to the server.
Meanwhile $MD$ is able to recover the last uploaded value ($0$ if it downloads before an upload occurs).
The security type on the variable $sharedSecret$ means that its value can only have an effect on other variables
with the same or a more restrictive type.
Importantly, our correctness result limits knowledge of these values to just the Alice, Bob and Server devices,
no matter what well-typed code are run in these devices.
On the other hand, checking the authenticity of the Bob key (with a mechanism such as PGP, or out-of-band checks)
is Alice's responsibility.
These are exactly the guarantees that a user, or a organisation, would want before using the cloud service.
While many people trust their cloud services, and organisations enter into complex legal agreements,
leaks can still occur due to programming errors.
Type checking the code, as we outline in this paper can show that it is safe from such programming errors,
and help provide the users with the guarantees they need to use the system.
\section{Examples:}
\subsection{Simple Communication Over a Private Channel}
The exchange above can be simplified using encrypted and authenticated channels, in the style of TLS with client certificates:
\begin{figure}
\[
\begin{array}{crl}
&\langle \{ Alice \mapsto \prin{k^+_a}{k^-_a}{ \{ \}},bobPub \mapsto k_b^+ \}\} \blacktriangleright & \new{x}{\Int_{\{Alice,bobPub\}}}{7};\\
&&\connectCCert{c}{\chanType{\Int_{\{Alice,bobPub\}}}{\bot}}{bobPub}{Alice};\\
&&\outputChan{x}{c};\\
&&\inputChanII{c}{xInc};\\
&& \assign{x}{xInc};\\
|& \langle \{Bob \mapsto \prin{k^+_b}{k^-_b}{ \{ \}},alicePub \mapsto k_a^+ \} \blacktriangleright &
\acceptCCert{c}{\chanTypePub{\Int_{\{Alice,bobPub\}}}}{alicePub}{Bob};\\
&&\inputChanII{c}{z};\\
&&\outputChan{z+1}{c};\rangle\\
\end{array}
\]
\end{figure}
For the Alice device:
\begin{itemize}
\item After one step we get to:
$\{ Alice\!:\!\prinType, bobPub\!:\!\pubKeyType_{\bot},x\!:\!\Int_{\{Alice,bobPub\}} \},\bot,\{\}\\
\vdash\\
\connectCCert{c}{\chanTypePub{\Int_{\{Alice,bobPub\}}}}{bobPub}{Alice};\\
\outputChan{x}{c};\\
\inputChanII{c}{xInc};\\
\assign{x}{xInc};\\$
\item As the protection types in the connect match the keys used to open the channel this is well typed, and we get:\\
$\{ Alice\!:\!\prinType, bobPub\!:\!\pubKeyType_{\bot},x\!:\!\Int_{\{Alice,bobPub\}},$\\
$~~~~~~~~~~c\!:\!\chanTypePub{Int_{\{Alice,bobPub\}}}\},\{Alice,bobPub\},\{\}\\
\vdash\\
\outputChan{x}{c};\\
\inputChanII{c}{xInc};\\
\assign{x}{xInc};\\$
Connecting on the high level channel may leak data at the $\{Alice,bobPub\}$ lev el to the receiver, therefore the program counter is raised. The high level data can then be sent over the channel.
\end{itemize}
\subsection{Client gives its identity to the server}
\[
\begin{array}{crl}
&\langle \{ serverPub \mapsto k^+_s \}\} \blacktriangleright & \newPrin{Client}{\{\}};\\
&& \connectPub{c_1}{\pubKeyType_{\bot}};\\
&&\outputChan{\publicKey{Client}}{c_1};\\
&&\new{x}{\Int_{\{Client,serverPub\}}}{7};\\
&&\connectCCert{c_2}{\chanTypePub{\Int_{\{Client,serverPub\}}}}{serverPub}{Client};\\
&&\outputChan{x}{c_2};\\
&&\inputChanII{c_2}{xInc};\\
\\
|& \langle \{Server \mapsto \prin{k^+_s}{k^-_s}{ \{ \}} \} \blacktriangleright &\bang{~\acceptPub{c_1}{\pubKeyType_{\bot}}};\\
&&~~\inputChanII{c_1}{clientKey};\\
&&~~\bang{~\acceptCCert{c_2}{\chanTypePub{\Int_{\{Server,clientKey\}}}}{clientKey}{Bob}};\\
&&~~~~\inputChanII{c}{z};\\%\new{z}{\Int_\bot}{\inputExp{c}};\\
&&~~~~\outputChan{z+1}{c};\rangle\\
\end{array}
\]
\section{Additional Language Rules}
\label{app:other-rules}
\begin{figure}
\begin{gather}
\inferrule{ v\!:\!T \in \Gamma}{ \typeVar{v} : T} \tag{var\_T}\label{type:var}
\\
\inferrule{
}{ \typeVar{i} : \Int_\bot} \tag{int\_T}\label{type:int}
\\
\inferrule{ P \in \GammaPrin}{ \typeVar{\publicKey{P}} : \pubKeyType_{\bot}} \tag{pubKey\_T}\label{type:pubKey}
\\
\inferrule{ \GammaPrin;\GammaKey;\Gamma \vdash e_1\!:\!\Int_{R_1}
\\ \GammaPrin;\GammaKey;\Gamma \vdash e_2\!:\!\Int_{R_2}
}{\GammaPrin;\GammaKey;\Gamma \vdash e_1 + e_2 : \Int_{R_1 \cap R_2}}
\tag{Sum\_T}\label{type:sum}
\\
\inferrule{ \typeVar{v_1\!:\!S_R} \dots \typeVar{v_n\!:\!S_R}}{
\typeVar{ \{v_1, \dots v_n \} : \arrayType{S}_R}}
\tag{array\_T} \label{type:array}
\\
\inferrule{ \typeVar{x\!:\! \arrayType{S}_{R_1}} \\ \typeVar{e \!:\!Int_{R_2}}
}{
\typeVar{ x[e]\!:\!S_{R_1 \cap R_2}}}
\tag{element\_T} \label{type:element}
\\
\inferrule{
}{
\GammaPrin; \GammaKey \vdash \bot
\tag{public\_T}
}
\\
\inferrule{
pc;\GammaPrin;\GammaKey;\GammaChan; \Gamma \vdash C_1 \\
pc;\GammaPrin;\GammaKey;\GammaChan; \Gamma \vdash C_2
}{
pc;\GammaPrin;\GammaKey;\GammaChan; \Gamma \vdash ~C_1~|~C_2 }
\tag{para\_T} \label{type:para}
\\
\inferrule{
}{
pc;\GammaPrin;\GammaKey;\GammaChan; \Gamma \vdash \nop }
\tag{skip\_T} \label{type:skip}
\\
\inferrule{pc;\GammaPrin;\GammaKey;\GammaChan; \Gamma \vdash C
}{
pc;\GammaPrin;\GammaKey;\GammaChan; \Gamma \vdash ~\bang C }
\tag{bang\_T} \label{type:bang}
\\
\inferrule{
\typeVar{e_1:\Int_{R_1}} \\
\typeVar{e_2 : S_{R_2}} \\
\typeVar{x : \arrayType{S}_{R_3}} \\
\gamma \vdash R_3 \subseteq pc \cap R_1 \cap R_2 \\
pc;\GammaPrin;\GammaKey;\GammaChan; \Gamma \vdash C
}{
pc;\GammaPrin;\GammaKey;\GammaChan; \Gamma \vdash \assign{x[e_1]}{e_2}; ~C } \tag{assign\_array\_T}\label{type:assignArray}
\\
\inferrule{
pc = \bot \\
pc;\GammaPrin ;\GammaKey;\GammaChan \cup \{ c \!:\!\!\chanType{S_\bot}{\bot}\}; \Gamma \vdash C
}{
pc;\GammaPrin ;\GammaKey;\GammaChan; \Gamma \vdash \acceptPub{c}{\chanType{S_\bot}{\bot}}; ~C } \tag{accept\_1\_T} \label{type:acceptPub}
\\
\inferrule{
p \in \GammaPrin \\
k \in \GammaKey \\
\rightsComp{ \{\publicKey{p},k\} }{ R_1 \subseteq R_2 \subseteq pc} \\
R_2; \GammaPrin; \GammaKey; \GammaChan \cup \{ c : \chanType{S_{R_1}}{R_2} \}; \Gamma \vdash C
}{
pc;\GammaPrin; \GammaKey; \GammaChan; \Gamma \vdash \acceptCCert{c}{\chanType{S_{R_1}}{R_2}}{k}{p};~C }
\tag{accept\_2\_T} \label{type:open-cert-server}
\end{gather}
\caption{Other type rules for commands}
\label{fig:other-type-rules-a}
\end{figure}
\begin{figure}
\begin{gather}
\inferrule{
pc;\GammaPrin;\GammaKey;\GammaChan; \Gamma \vdash G \{C / \nop \}
}{
pc;\GammaPrin;\GammaKey;\GammaChan; \Gamma \vdash \sync\{G\};C }
\tag{sync\_T} \label{type:sync}
\end{gather}
Where
\[
\begin{array}{rcl}
G & ::= & \cond{e_1}{e_2}{G_1}{G_2} \\
& | & \new{x}{S_R}{e};~G \\
& | & \assign{x}{e};~G \\
& | & \assign{x[e_1]}{e_2};~G\\
& | & \decrypt{P}{e}{x}{S_R}{G_1}{G_2} \\
& | & \register{P_1}{e}{P_2}{G_1}{G_2} \\
& | & \paral{G_1}{G_2} \\
& | & \nop
\end{array}
\]
\caption{Other type rules for commands (continued)}
\label{fig:other-type-rules-b}
\end{figure}
\begin{figure}
\begin{gather}
\inferrule{
M(e) = i \\ i \in \{0,\ldots,n \}\\
M(x) = \{v_0,\ldots,v_i,\ldots,v_n\}
}{
M(x[e]) = v_i
} \tag{element\_E}\label{red:arrayelement}
\\
\inferrule{
M(e) = i \\ i \notin \{0,\ldots,n \} \\
M(x) = \{v_0,\ldots,v_i,\ldots,v_n\}
}{
M(x[e]) = \NotAValue
} \tag{element\_err\_E}\label{red:array_err}
\\
\inferrule{
M(P) = \prin{\pubKey}{\secKey}{R}
}{
M(\publicKey{P}) = \pubKey
} \tag{pub\_E}\label{red:pub}
\\
\inferrule{
\dev{M}{C_1} \rightarrow^* \dev{M'}{\nop}
}{
\dev{M}{ \sync\{C_1\};C_2 } \rightarrow \dev{M'}{C_2}
}
\tag{sync\_S} \label{red:sync}
\\
\inferrule{
M(e_1) = v \\
M(e_2) = v
}{
\dev{M}{\cond{e_1}{e_2}{C_1}{C_2}}
\rightarrow \dev{M}{C_1}
}\tag{if1\_S} \label{red:if1}
\\
\inferrule{
M(e_1) = v \\
M(e_2) = v' \\
v \neq v'
}{
\dev{M}{\cond{e_1}{e_2}{C_1}{C_2}}
\rightarrow \dev{M}{C_2}
}\tag{if2\_S} \label{red:if2}
\\
\inferrule{
}{
\dev{M}{~ \bang{C} }
\rightarrow \dev{M}{ C~|~\bang{C}}}\tag{bang\_S} \label{red:bang}
\\
\inferrule{
M(e_1) = i \\
M(e_2) = v
}{
\dev{M\cup\{x \mapsto \{v_1,\dots v_i, \dots v_n\}}{\assign{x[e_1]}{e_2}; ~C}
\\ \rightarrow \dev{M \cup \{x \mapsto \{v_1,\dots v, \dots v_n\}\}}{C}
}\tag{assignArray\_S} \label{red:assignArray}
\\
\inferrule{
M(p) = \prin{k^+}{k^-}{\LR_2} \\
M(e) = \enc{v}{n}{\LR} \\
k^+ \not\in M(RS_1) \lor M(RS_1) \not\subseteq \LR
}{
\dev{M}{\decrypt{p}{e}{x}{S_{RS_1}}{C_1}{C_2} }
\rightarrow
\dev{M }{C_2}
} \tag{dec\_false\_S}\label{red:decF}
\end{gather}
\caption{Other semantics rules}
\label{fig:other-semantics-rules}
\end{figure}
Reduction is defined modulo the standard equivalence rules, which may be applied in any context, e.g.\\
$D_1 ~|~ D_2 \equiv D_2 ~|~ D_1$ \\
$D_1 ~|~ (D_2 ~|~ D_2) \equiv (D_1 ~|~ D_2) ~|~ D_2$ \\
$\dev{M_1}{C_1~|~C_2} \equiv \dev{M_1}{C_2~|~C_1}$ \\
$\dev{M_1}{C_1~|~(C_2~|~C_3)} \equiv \dev{M_1}{(C_1~|~C_2)~|~C_2}$ \\
The rules not mentioned in \autoref{fig:semantics-rules} can be found in \autoref{fig:other-semantics-rules}
and the types rules not mentioned in \autoref{fig:types-rules-cmd} and
\autoref{fig:types-rules-expr} can be found in
\autoref{fig:other-type-rules-a} and \autoref{fig:other-type-rules-a}.
\begin{figure}
\[
\begin{array}{rcll}
\attExpr & ::= & m_1 & \text{a variable of $\attKnowledge$}
\\ & | & \mathrm{encr}_{\attExpr_2}(\attExpr_1) & \text{encrypt $\attExpr_1$ with rights $\attExpr_2$}
\\ & | & \mathrm{decr}_{\attExpr_1}(\attExpr_2) & \text{decrypt $\attExpr_1$ with the secret key $\attExpr_2$}
\\ & | & \mathrm{alter}(\attExpr_1,\attExpr_2) & \text{the principal $\attExpr_1$ where its rights are now $\attExpr_2$}
\\ & | & \mathrm{freshprin}(\attExpr) & \text{the $\attExpr$-th principal generated by the attacker}
\\ & | & \mathrm{pub}(\attExpr) & \text{the public key of a principal $\attExpr$}
\\ & | & \mathrm{sec}(\attExpr) & \text{the secret key of a principal $\attExpr$}
\\ & | & \mathrm{rights}(\attExpr) & \text{the rights of a principal $\attExpr$}
\\ & | & \{\attExpr_1, \dots \attExpr_n \} & \text{tuple}
\\ & | & \attExpr_1[\attExpr_2] & \text{element of a tuple}
\\ & | & \attExpr_1 \oplus \attExpr_2 & \text{where $\oplus$ is $+,-,\times,\dots$}
\\ & | & i & \text{an integer}
\end{array}
\]
\begin{gather}
\inferrule{
M(\attExpr_1) = v
\\ M(\attExpr_2) = \{ \pubKeyOf{k_1} ,\ldots ,\pubKeyOf{k_n}\}
\\ \fresh(n)
}{
M(\mathrm{encr}_{\attExpr_2}(\attExpr_1)) = \enc{v}{n}{\{ \pubKeyOf{k_1} ,\ldots ,\pubKeyOf{k_n}\}}
} \tag{attacker\_encryption}\label{eexpr:encr}
\\
\inferrule{
M(\attExpr_1) = \enc{v}{n}{\{ \pubKeyOf{k_1} ,\ldots ,\pubKeyOf{k_n}\}}
\\ M(\attExpr_2) = \secKeyOf{k_i} \quad i \in \{1,\ldots,n\}
}{
M(\mathrm{decr}_{\attExpr_2}(\attExpr_1)) = v
} \tag{attacker\_decryption}\label{eexpr:decr}
\\
\inferrule{
M(\attExpr_1) = \prinv{k}{r}
\\ M(\attExpr_2) = r'
}{
M(\mathrm{alter}({\attExpr_1},\attExpr_2)) = \prinv{k}{r}
} \tag{attacker\_alter}\label{eexpr:alter}
\\
\inferrule{
M(\attExpr) = i \in \mathbb{N}
}{
M(\mathrm{freshprin}({\attExpr})) = \prinv{k_i}{\{\}}
} \tag{attacker\_fresh}\label{eexpr:fresh}
\end{gather}
\caption{extended expressions of the attacker and some of their reduction rules.}\label{fig:extended-expressions}
\end{figure}
\section{Language: Semantics and Type System}
\label{sec:lang}
\input{types-fig-devices}
\subsection{Syntax}
The syntax of our language is given in Figures \ref{fig:syntax}, \ref{fig:types}, \ref{fig:commands} and \ref{fig:expressions}.
We let $x,y,z$ range over variable names $\VarNames$, $p,p_1,p_2,\ldots$ range over principal names $\PrinNames$,
$k_1,k_2,\ldots$ range over public key names $\KeyNames$
and $c,c_1,c_2,\ldots$ range over channel names $\ChanNames$.
A system $\nu\activechans.D_1 \mid \ldots \mid D_n$
is a set of \emph{devices} that run in parallel and that communicates through channels of $\activechans$.
The list $\activechans$ records which channel names correspond to establish channels (globally bound).
Channel also appear in connect and accept commands in the devices, and these are added to $\activechans$ once the channel is opened.
When there are no established channels, we omit the $\nu \{\}.$ prefix.
Note that to guarantee freshness of keys and nonce used in encryption,
we might also provide global binders $\bar{k}$ and $\bar{n}$ in addition to $\activechans$.
However this guarantee is straightforward to provide, using
``freshness'' predicates, so for readability reasons we omit explicit
binders for generated keys and nonces.
A device consists of a \emph{memory} $\mem$ and a \emph{command} $C$.
Memories associate variable names with \emph{values}, key names with keys and principal names with \emph{principals}.
Given a nonce $k$ from some assumed set of key nonces,
we define $(\pubof{k},\secof{k})$ as the public private key pair generated from $k$, where $\pubof{.}$ and $\secof{.}$ are two constructors.
A principal $\pvalue$ is a tuple $\prin{\secof{k}}{\pubof{k}}{\LR}$ which contains a key pair $(\secof{k},\pubof{k})$,
together with a (possibly empty) set of public key values $\LR$.
When a device has $\pvalue$ in its memory, it is allowed to act for $\pvalue$.
Devices that can act as a principal $\pvalue_0$, whose public key $\pubKeyOf{k_0}$ is one of the public keys in $\LR$,
are allowed to add $\pvalue$ to their memory.
Each variable $x$ in $\VarNames$
represents a reference to a value
i.e. variables are mutable.
At declaration time, a reference is associated with some rights $R$, which cannot be revoked or changed.
Making all variables mutable is convenient for our security analysis:
it allows us to define non interference as the property that a parallel process
that alters the value of a high-level variable cannot be detected by an attacker.
If variables were not mutable we would have to consider a much more complex security property and proof.
In addition, to avoid to consider scope of variables, we assume that a command never declares twice the same name
for variables, channels, keys and principals.
Types (\autoref{fig:types}) for these variables consists of a pure-type $S$
which indicates the base type for the value of the variable (e.g. integer, public key, cipher, etc.)
and a \emph{label} (or \emph{right}) $R$
which indicates the principals who are allowed to access to the variable.
A label can be either $\bot$ i.e. the variable is public
or a set which contains public key names: $k \in \KeyNames$ and $\publicKey{p}$
where $p \in \PrinNames$.
Key names are declared by a command $\letk{k}{x} C$.
This command copies the value of the reference $x$ into $k$ which represents
a public key (not a reference to a public key).
The type system \eqref{type:let} ensures that $x$ in this command is an unrestricted public key: $x : \pubKeyType_\bot$.
Channel types are declared when they are established, we have two kinds of channel: public and secure channels.
Their types have syntax $\Chan(S_{R_1})_{R_2}$ where $S_{R_1}$ is the type of values that are past over the channel
and $R_2$ expresses
which principals are allowed to know the existence of $c$ and when communication on this channel takes place.
\input{types-types}
\input{typeSyntax}
\subsection{Semantics}
The semantics of the system is defined as a small-step semantics for commands
and as a big-step semantics for expressions.
Devices run concurrently with synchronized communication between them.
Inside each device, all parallel threads run concurrently and communicate
through the shared memory of the device (since memory is mutable).
The main reduction rules are presented in \autoref{fig:commands-semantics}
for commands and in \autoref{fig:semantics-rules} for main expressions.
When a command that declares a new variable is reduced, the name is
replaced by a fresh name that represents a pointer to the location in the memory where the value has been stored.
The evaluation of expressions has the form $\evaluates{\mem}{e}{v}$:
the evaluation of $e$ with memory $\mem$ returns the value $v$.
We note that this is different from some other calculi, in which variables are not references, and are replaced with a value when declared. Our correctness statement below depends on the use of references and, since we have a memory mechanism, we prefer to store the key names and principal names in memory and instead of applying a substitution,
the names are evaluated when a command reduces
(cf the \eqref{red:rights} rules).
Principals are generated using the $\newPrin{p}{RS};C$ command,
where $RS$ are the keys to use to protect the principal (and therefore cannot $\bot$).
The rule for this command \eqref{sem:newPrin} generates a fresh key pair $(\pubof{k},\secof{k})$
and stores the principal $\prinv{k}{\mathit{LR}}$
at a new location $p'$ in the memory,
where $\evaluates{\mem}{RS}{\mathit{LR}}$.
To bootstrap the creation of these principals, they can be declared with $RS=\{\}$;
such principal identities can only be used on a single device, they cannot be sent over channels.
Additionally some devices may start off with the public keys of some trusted parties,
i.e., the same assumption as TLS.
This too lends itself well to cloud systems, in which web browsers come with a number of trusted certificates.
Communication between devices uses Java like channels: a channel is first established
then it can be used to input and output values.
The channel establishment is done by substituting the channel names in both devices by a unique fresh channel name
added to $\activechans$ (we assume that initial channel names and active channel names
range over distinct sub-domains of $\ChanNames$ to avoid collision).
Note that channels do not name the sending and receiving device as these may be spoofed by an attacker,
however, to get a more tuneable system, it would be a simple extension to add a port number which would restrict possible connections.
For secure channels \eqref{red:open-for}, in a similar way to TLS with client certificates,
both devices must provide the public key $\pubof{k}$ of who they want to connect to. They must also provide the principal (which includes a private key) to identify themselves to the other party.
To set up a secure channel, the client and the server also have to
ensure that they are considering the same rights for the channel.
For that they have to exchange
the value of their channel right $\mem(\Chan(S_{R_1})_{R_2})$
and make sure that it corresponds to the distant right value $\mem'(\Chan(S_{R'_1})_{R'_2})$.
Indeed, even if type-checking is static inside a device, type-checking
has to be dynamic between distinct devices since programs are type-checked on each device and not globally.
\begin{figure}
\[
\begin{array}{rcll}
e & ::= & x,y,\dots & \text{variable names}\\
& | &\publicKey{p} & \text{the public key of $p$}\\
& | & \release{p} & \text{pack a principal}\\
& | & \encE{e}{RS} & \text{encrypt some data}\\
& | & e_1 \oplus e_2 & \text{where $\oplus$ is $+,-,\times,\dots$}\\
& | & \{e_1, \dots e_n \} & \text{an array of expressions}\\
& | & x[e] & \text{an element of an array} \\
& | & i & \text{an integer } i \in \mathbb{Z}\\
\end{array}
\]
\caption{The syntax of the expressions }
\label{fig:expressions}
\end{figure}
\input{semantics-rules}
\begin{example}[Principal set up]
Assume that a cloud service $C$ has a public key $\pubof{c}$, which is known to Alice and Bob,
and that Alice wants to share some private data with Bob using this cloud service.
Alice can do this using the code shown in \autoref{fig:Alice}.
Alice starts by generating a key pair $(\secof{a},\pubof{a})$.
As neither Alice nor Bob have certificates, Bob just sends his key publicly to Alice over a public channel.
Alice receives it, and creates a new variable to be shared with Bob and the cloud service.
She then opens a secure channel with the cloud
that is typed to allow data of type $\{\pubof{a},\pubof{b},\pubof{c}\}$, the $\bot$ right on this channel indicates that, while the data on the channel must be kept confidential, the knowledge that some value has been sent is not.
This fragment of code does not authenticate Bob, this could be done using another protocol, or offline, but we will show that if the device that sent her this key, and the cloud server, both run well typed code, then she is guaranteed that the secret will only be shared by the device sending the key, the cloud server and herself.
She knows that no leak can come from, for instance, bad code design on the cloud device.
\begin{figure}
\[
\dev{\loc{k_c}{\pubof{c}}}{
\begin{array}{l}
\newPrin{A}{\{\}};\\
\acceptPub{\mathit{c}}{\chanTypePub{\pubKeyType_{\bot}}};\\
\inputChanII{c}{x_b};\\
\letk{k_b}{x_b} \\
\new{secret}{ \Int_{\{k_c,\publicKey{A},k_b\}}}{42};\\
\connectPub{upload}{\chanTypePub{\Int_{\{k_c,\publicKey{A},k_b\}}}}\\
~~~~~\TO k_c \AS \publicKey{A};\\
\outputChan{secret}{upload};\\
\end{array}
}
\]
\caption{Alice sharing data with Bob using a cloud service. N.B. this code does not authenticate Bob.}\label{fig:Alice}
\end{figure}
\end{example}
The $\encE{e}{RS}$ expression, governed by the \eqref{red:enc} rule, encrypts the evaluation of $e$ for each of the public keys $\pubof{k_i}$
named in $RS$, i.e.,
anyone that has a single private key corresponding to any $\pubof{k_i}$ can decrypt it,
the set of all $\pubof{k_i}$ is also included in the encryption.
We use randomised encryption to avoid leakage that would occur otherwise when
the same value is encrypted twice, and we model this by including a fresh nonce in the encryption.
The $\decrypt{p}{e}{x}{S_{RS}}{C_1}{C_2}$ command reduces successfully \eqref{red:decT}
when $e$ evaluates to a ciphertext $\enc{v}{n}{RS}$ that can be opened by the secret key of $p$
and that the $\LR$, which is packed into the encryption, is a subset of the evaluation of $RS$.
The $\mathbf{release}(p)$ expression reduces by encrypting the principal $p$ for each of the set of public keys representing the principals that can access it.
It is the only way to produce a value which contains a secret key and therefore to send private keys through a channel.
The $\mathbf{register}$ command behaves as $\mathbf{decrypt}$ except that it deals with encrypted principals instead of encrypted values.
All other semantics rules are standard except that instead of returning run-time error (division by $0$, illegal offset index etc.)
expression returns a special value $\NotAValue$.
This feature is critical to guarantee the security of our system.
Indeed, we allow a device to evaluate expressions with secure variables and then to do an output on a public channel.
This scenario is safe only if we can ensure that no expression will block any thread.
Note that the attacker can also send values with some type through a channel of another type,
consequently run time type errors can also occur.
Finally, the command $\mathbf{synchronised}\{C\}$ executes a command $C$ with no communication or interleaving of other processes. This is useful to avoid race conditions.
\input{types-rules.tex}
\subsection{Types}
The type judgment for expressions takes the form $\GammaPrin ;\GammaKey; \Gamma \vdash e : S_R$
and the type judgment for commands takes the form $pc; \GammaPrin ;\GammaKey; \GammaChan; \Gamma \vdash C$
where $\Gamma$ is a mapping from variable names to types $S_R$,
$\GammaChan$ from channel names to channel type $\Chan(S_{R_1})_{R_2}$,
$\GammaPrin$ is a set of principal names,
$\GammaKey$ is a set of public key names,
and where $pc$ is a right of form $R$ called the \emph{program-counter}. The program counter allows to analyse programs for indirect secure information flow~\cite{Denning1977}.
\autoref{fig:types-rules-cmd} defines the main type rules for commands and \autoref{fig:types-rules-expr} defines the rules for expressions and rights.
In many typing judgments, we use a condition $\rightsComp{R_1}{R_2}$ that states that $R_1$ is more confidential than $R_2$.
The predicate $\rightsComp{R_1}{R_2}$ holds either when $R_2 = \bot$ or when $R_1$ is a syntactical subset of $R_2$
(no aliasing). For instance, we have $\rightsComp{\{k_2,\pub(p)\}}{\{k_1,\pub(p),k_2\}}$
and ${\{k_1,k_2\}}\varsubsetneq {\{k_2\}}$ even if $k_1$ and $k_2$ map to the same key in memory.
We also use $R_1 \cap R_2$ to define the syntactic intersection of the sets $R_1$ and $R_2$
(which is $R_2$ if $R_1=\bot$).
\paragraph*{Types rules for new principals and variables} The typing rule for principal declaration \eqref{type:newPrin} only allows the program counter to be bottom.
This restriction avoids the situation in which a variable with a right including this principal
might be less confidential than the principal itself.
The new variable declaration \eqref{type:new} checks that the rights $R_1$ to access the new variable $x$
are more restrictive than (a subset of) the rights $R_2$ of the expression being assigned
and of the program counter $pc$.
We also ensure that one of the principal in $R_1$ belongs to $\GammaPrin$.
The type rule for assignment \eqref{type:assign} ensures that high security values cannot be assigned to lower security variables.
While the semantics for new principals \eqref{sem:newPrin} stores the rights set $\LR$ dynamically
(as $\LR$ is only used when the principal is sent to another device),
the semantics for managing variables \eqref{red:new_var} does not consider them:
their confidentiality is entirely provided by the type system.
\begin{example} We consider the following piece of code in which two new principals are declared,
and both Alice and Bob may know the value of $y$, but only Alice may know the value of $x$:
\[
\begin{array}{ll}
\langle \{\} \blacktriangleright & \newPrin{Alice}{\{\}};\\
& \newPrin{Bob}{\{\}};\\
& \new{x}{\mathit{Int}_{\{\publicKey{Alice}\}}}{5};\\
& \new{y}{\mathit{Int}_{\{\publicKey{Alice},\publicKey{Bob}\}}}{7};\\
&\assign{x}{y};\\
&\mathbf{if}(x\boldsymbol{=}1)~\mathbf{then}~\assign{y}{1};
\\
\rangle
\end{array}
\]
Here the assignment of $y$ to $x$ should be allowed because $x$ is protected by rights more confidential than $y$.
However, in the last line, the value of $y$ (which Bob can read)
leaks some information about the value of $x$ (which Bob should not be able to read).
Therefore, this is an unsafe command and it cannot be typed.
\end{example}
\paragraph*{Types rules for encryption}
The type rule for encrypting values \eqref{type:enc} verifies
that the encrypted value is less confidential than the set of keys used for encryption,
it then types the ciphertext as a public value, i.e.,
encryption removes the type restrictions on a value while ensuring that the encryption provides at least as much protection.
We note that if the encrypting key depends on non-public data,
then the \progc would not be public, which would ensured that the ciphertext was not stored in a public variable.
Hence the use of restricted keys will not leak information.
The corresponding decryption rule \eqref{type:dec}
verifies that the principal $p$ used to decrypt the cipher is valid ($p \in \GammaPrin$)
and is consistent with the rights of the decrypted value.
As the knowledge of which keys has been used to encrypt is protected with the rights $R_2$
of the cipher, the success of the decryption also depends on $R_2$.
Therefore, the \progc has to be at least as high as $R_2$ when typing the continuation.
Finally, as with an assignment, the rule enforces
that the created variable does not have a type that is more confidential than the \progc.
\paragraph*{Types rules for public channels} Typing rules for public channels ensures that these are only of type public and, when they are used, the program counter is $\bot$.
\begin{example}
The following system illustrates the use of public channels and encryption:
\[\!\!
\begin{array}{ll}
&\langle \{ Alice \mapsto \prin{k^+_a}{k^-_a}{ \{ \}},bobPub \mapsto k^+_b \}\} \blacktriangleright \\
&~~~~\new{x}{\Int_{\{Alice,bobPub\}}}{7};\\
&~~~~ \mathbf{connect}~c:\chanTypePub{\cipherType{\Int}_{\bot}};\\
&~~~~\outputChan{\encE{x}{\{\pub(Alice),bobPub\}}}{c};\\
&~~~~\inputChanII{c}{e};\\
&~~~~ \decryptThen{Alice}{e}{xInc}{\Int_{\{\pub(Alice),bobPub\}}}\\
&~~~~ \assign{x}{xInc};\rangle\\
|& \langle \{Bob \mapsto \prin{k^+_b}{k^-_b}{ \{ \}},alicePub \mapsto k_a^+ \} \blacktriangleright \\
&~~~~!~\mathbf{accept}~c:\chanTypePub{\cipherType{\Int}_{\bot}};\\
&~~~~\inputChanII{c}{z};\\
&~~~~\decryptThen{Bob}{z}{w}{\Int_{\{\pub(Bob),alicePub\}}}\\
&~~~~\outputChan{\encE{w+1}{\{\pub(Bob),alicePub\}}}{c};\rangle\\
\end{array}\!\!
\]
Alice and Bob start off knowing each other's public keys, and Bob provides a service to add one to any number sent by Alice.
The variable $x$ is restricted so that only Alice and Bob can know the value.
Encrypting this value removes these type protections, so that it can be sent across the public channel $c$.
On Bob's device decrypting with Bob's private key replaces these type protections.
\end{example}
\paragraph*{Types rules for secure channels}
For secure channels (client and server side), the rule \eqref{type:open-cert-client} enforces that
the principal who is creating the channel and the principal being connected to,
both have the right to access the data passed over the channel,
hence $\{\pub(p),k\} \subseteq R_1$.
In order to ensure that the possible side effects caused by using the channel are not more restrictive than the data passed over the channel
we need that $R_1 \subseteq R_2$.
The $R_2 \subseteq pc$ condition stops side channel leakage to the device receiving the connection at the time the channel is opened.
Finally, the \progc is set to $R_2$ once connected:
this ensures both devices have the same \progc. Without this we would have implicit leakage, for instance, one device with a public \progc could wait for a message from a device with a non public \progc, then outputs something on a insecure channel.
As the sending of the message may depend on a value protected by the \progc,
this would result in a leakage.
We make the strong assumption that the existence of a connection attempt can only be detected
by someone with the correct private key to match the public key used to set up the connection.
If we assumed a stronger attacker, who could observe all connection attempts, we will need the condition that $pc = \bot$
at least for the client.
The output rule \eqref{type:output} has two main restrictions:
one which verifies that the device still has the \progc agreed with the corresponding device,
and $R_1 \subseteq R_3$ i.e.,
the type on the channel is no less restrictive than the type of data sent.
This is because when this data is received it will be treated as data of type $R_1$.
For channel creation the restriction on the channel must be at least as restrictive as the program counter.
For input and output we must additionally check that the program counter has not become more restrictive,
hence requiring that the channel restriction and the program counter are equal, i.e.,
testing the value of a high level piece of data and then sending data over a lower level channel is forbidden.
\begin{example}
The different roles of $R_1$ and $R_2$ is illustrated in these two programs.
\[\!\!
\begin{array}{l}
\new{x}{\Int_{\{\publicKey{Alice},bob\}}}{7};\\
\acceptCCert{c}{\Chan(\Int_{\{\publicKey{Alice},bob\}})_{\{\publicKey{Alice},bob\}}\\~~~~}{bob}{Alice};\\
\mathbf{if}(x > 10)\{\\
~~\assign{x}{x+1};\\
~~\outputChan{x}{c};\}
\end{array}
\]
\[
\begin{array}{l}
\new{x}{\Int_{\{\publicKey{Alice},bob\}}}{7};\\
\acceptCCert{c}{\Chan(\Int_{\{\publicKey{Alice},bob\}})_{\bot}}{bob}{Alice};\\
~~ \{ \mathbf{if}(x > 10)\{\\
~~~~\assign{x}{x+1};~\}\}\\
~ | ~
~~\outputChan{x}{c};
\end{array}\!\!
\]
Both programs aim at sending $x$ to Bob, which is a secret shared by Alice and Bob.
In the first case, the sending of $x$ depends on its value:
therefore the communication should can only be on a channel with rights
$\Chan(\Int_{\{\publicKey{Alice},bob\}})_{\{\publicKey{Alice},bob\}}$.
In the other example, even if the value of $x$ is updated due to a parallel thread that has a non public \progc,
the sending of $x$ is unconditional.
Note that the language does not have \emph{``\{if condition then $C$ \}; $C''$} structure as this construct would not be safe:
if $C$ waits infinitely for a connection then $C''$ is not executed.
However, a \emph{delay} command could be added to
help the second program to output $x$ after $x$ has been updated.
\end{example}
\paragraph*{Type rules for release and register} The release command is similar to the encryption command except that the rights with which the principal is encrypted are provided by the principal value.
Therefore, there is no static check to perform in \eqref{type:release}.
The registration rule \eqref{type:register}, for the same reason has less checks than \eqref{type:dec}.
However, it does enforce that $pc=\bot$, without which we could get non public rights; revealing a such a none public right would then be an information leak. Removing this restriction, and allowing non public rights, would be possible in a more complex type system but we decide not to do so to keep the type system more understandable.
\subsection*{Other Type Rules for Commands}
\begin{gather}
\inferrule{
\gamma \cup \{ R_2 \subseteq R_1\} ; pc; \Gamma \vdash C_1
\\ \gamma;pc;\Gamma \vdash C_2
}{ \gamma;pc;\Gamma \vdash \compare{R_1}{R_2}{C_1}{C_2}}
\tag{compare\_T} \label{type:compare}
\end{gather}
\begin{gather}
\inferrule{
S \neq \pubKeyType \\
\typeVar{e : S_{R_2}} \\
\gamma \vdash R_1 \subseteq pc \cap R_2 \\
\gamma;pc;\Gamma \vdash C
}{
\gamma;pc;\Gamma \vdash \assign{x}{e}; ~C } \tag{assign\_T}\label{type:assign}
\\
\inferrule{
\typeVar{e_1:\Int_{R_1}} \\
\typeVar{e_2 : S_{R_2}} \\
\typeVar{x : \arrayType{S}_{R_3}} \\
S \neq \pubKeyType \\
\gamma \vdash R_3 \subseteq pc \cap R_1 \cap R_2 \\
\gamma;pc;\Gamma \vdash C
}{
\gamma;pc;\Gamma \vdash \assign{x[e_1]}{e_2}; ~C } \tag{assign\_array\_T}\label{type:assignArray}
\\
\inferrule{ \typeVar{v_1\!:\!B_R} \dots \typeVar{v_n\!:\!B_R}}{
\typeVar{ \{v_1, \dots v_n \} : \arrayType{B}_R}}
\tag{array\_T} \label{type:array}
\\[0.4cm]
\inferrule{ \typeVar{x\!:\! \arrayType{B}_{R_1}} \\ e:Int_{R_2} \\ R \subseteq R_1 \cap R_2 }{
\typeVar{ x[e]\!:\!B_R}}
\tag{element\_T} \label{type:element}
\end{gather}
\begin{gather}
\inferrule{
\typeVar{e_1 : S_{R_1}} \\
\typeVar{e_2 : S_{R_2}} \\
\gamma;pc \cap R_1 \cap R_2; \Gamma \vdash C_1 \\
\gamma;pc \cap R_1 \cap R_2; \Gamma \vdash C_2
}{ \gamma;pc;\Gamma \vdash \cond{e_1}{e_2}{C_1}{ C_2}} \tag{if\_T}\label{type:if}
\end{gather}
\begin{gather}
\inferrule{
\gamma;pc;\Gamma \vdash G \{C / \nop \}
}{
\gamma;pc;\Gamma \vdash \sync\{G\};C }
\tag{sync\_T} \label{type:sync}
\end{gather}
Where
\[
\begin{array}{rcl}
G & ::= & \cond{e_1}{e_2}{G_1}{G_2} \\
& | & \new{x}{S_R}{e};~G \\
& | & \assign{x}{e};~G \\
& | & \assign{x[e_1]}{e_2};~G\\
& | & \compare{R_1}{R_2}{G_1}{G_2}\\
& | & \decrypt{P}{e}{x}{S_R}{G_1}{G_2} \\
& | & \register{P_1}{e}{P_2}{G_1}{G_2} \\
& | & \nop
\end{array}
\]
\begin{gather}
\inferrule{
\gamma;pc;\Gamma \vdash C_1 \\
\gamma;pc;\Gamma \vdash C_2
}{
\gamma;pc;\Gamma \vdash ~C_1~|~C_2 }
\tag{bang\_T} \label{type:bang}
\\
\inferrule{
}{
\gamma;pc;\Gamma \vdash \nop }
\tag{skip\_T} \label{type:skip}
\\
\inferrule{\gamma;pc;\Gamma \vdash C
}{
\gamma;pc;\Gamma \vdash ~\bang C }
\tag{para\_T} \label{type:paral}
\end{gather}
\subsection*{Other Semantic Rules}
\begin{gather}
\inferrule{
M(R_1) \subseteq M(R_2)
}{
\dev{M}{\compare{R_1}{R_2}{C_1}{C_2}}
\rightarrow \dev{M}{C_1}}
\tag{compare1\_S} \label{red:compare1}
\end{gather}
\begin{gather}
\inferrule{
M(R_1) \not\subseteq M(R_2)
}{
\dev{M}{\compare{R_1}{R_2}{ C_1}{C_2}}
\rightarrow \dev{M}{C_2}
}\tag{compare2\_S} \label{red:compare2}
\end{gather}
\begin{gather}
\inferrule{
\dev{M}{C_1} \rightarrow^* \dev{M'}{\nop}
}{
\dev{M}{ \sync\{C_1\};C_2 } \rightarrow \dev{M'}{C_2}
}
\tag{sync\_S} \label{red:sync}
\end{gather}
\begin{gather}
\inferrule{
M((e_1) = v \\
M(e_1) = v
}{
\dev{M}{\cond{e_1}{e_2}{C_1}{C_2}}
\rightarrow \dev{M}{C_1}
}\tag{if1\_S} \label{red:if1}
\\
\inferrule{
M((e_1) = v' \\
M(e_1) = v' \\
v \neq v'
}{
\dev{M}{\cond{e_1}{e_2}{C_1}{C_2}}
\rightarrow \dev{M}{C_2}
}\tag{if2\_S} \label{red:if2}
\\
\inferrule{
\dev{M}{C_1}|\dev{M_2}{C_3} \rightarrow \dev{M'}{C'_1} |\dev{M'_2}{C'_3}
}{
\dev{M_1}{\paral{C_1}{C_2}} | \dev{M_2}{C_3}
\rightarrow \dev{M'}{\paral{C'_1}{C_2}}| \dev{M'_2}{C'_3}
}\tag{comp\_S} \label{red:paral}
\\
\inferrule{
}{
\dev{M}{~ \bang{C} }
\rightarrow \dev{M}{ C~|~\bang{C}}}\tag{bang\_S} \label{red:bang}
\\
\inferrule{
M(e) = v_2
}{
\dev{M\cup\{x \mapsto v_1\}}{\assign{x}{e}; ~C}
\rightarrow \dev{M \cup \{x \mapsto v_2\}}{C}
}\tag{assign\_S} \label{red:assign}
\end{gather}
\begin{gather}
\inferrule{
M(e_1) = i \\
M(e_2) = v
}{
\dev{M\cup\{x \mapsto \{v_1,\dots v_i, \dots v_n\}}{\assign{x[e_1]}{e_2}; ~C}
\\ \rightarrow \dev{M \cup \{x \mapsto \{v_1,\dots v, \dots v_n\}\}}{C}
}\tag{assignArray\_S} \label{red:assignArray}
\end{gather}
Plus the standard rules for evaluating sums.
\subsubsection*{Other Type Rules for Values}
\begin{gather}
\inferrule{ v\!:\!T \in \Gamma}{ \typeVar{v} : T} \tag{var\_T}\label{type:var}
\end{gather}
\begin{gather}
\inferrule{
}{ \typeVar{i} : \Int_\bot} \tag{int\_T}\label{type:int}
\end{gather}
\begin{gather}
\inferrule{ \typeVar{P} : \prinType}{ \typeVar{\publicKey{P}} : \pubKeyType_{\bot}} \tag{pubKey\_T}\label{type:pubKey}
\end{gather}
\subsubsection*{Other Semantic Rules for Values}
\begin{gather}
\inferrule{
M(e) = i \\
M(x) = \{v_1,\dots,v_i,\dots,v_n\}
}{
M(x[e]) = v_i
} \tag{element\_E}\label{red:arrayelement}
\end{gather}
\begin{gather}
\inferrule{
M(P) = \prin{\pubKey}{\secKey}{R}
}{
M(\publicKey{P}) = \pubKey
} \tag{pub\_E}\label{red:pub}
\end{gather}
Plus the standard rules for typing sums.
\subsection{Equivalence rules}
Reduction is defined modulo the standard equivalence rules, which may be applied in any context, e.g.\\
$D_1 ~|~ D_2 \equiv D_2 ~|~ D_1$ \\
$D_1 ~|~ (D_2 ~|~ D_2) \equiv (D_1 ~|~ D_2) ~|~ D_2$ \\
$\dev{M_1}{C_1~|~C_2} \equiv \dev{M_1}{C_2~|~C_1}$ \\
$\dev{M_1}{C_1~|~(C_2~|~C_3)} \equiv \dev{M_1}{(C_1~|~C_2)~|~C_2}$ \\
\subsection{Comparing Rights}
These are the rules used to decide rights inclusion at the compile-time.
The set $\gamma$ provides a first set of relation for confidentiality.
It is also possible to directly check the relation when both sets a explicitly given.
\begin{gather}
\inferrule{
R_1 \subseteq R_2
}{
\gamma \vdash R_1\subseteq R_2 }
\tag{straight}\label{type:straight}
\\
\inferrule{
}{ \gamma \vdash R \subseteq \bot} \tag{$\bot$}\label{type:bot}
\\
\inferrule{
\gamma \vdash R_1 \subseteq R_2
\\ \gamma \vdash R'_1 \subseteq R'_2
}{
\gamma \vdash R_1 \cup R'_1 \subseteq R_2 \cup R'_2
} \tag{union}\label{type:union}
\\
\inferrule{ R_1 \subseteq R_2 \in \gamma
}{\gamma \vdash R_1 \subseteq R_2} \tag{init}\label{type:init-rights}
\\
\inferrule{\gamma\vdash R_1 \subseteq R_2 \quad \gamma \vdash R_2 \subseteq R_3}{\gamma \vdash R_1 \subseteq R_3} \tag{trans}\label{type:transitivity}
\end{gather}
\section{Proofs of correctness}
\label{app:proofs-correctness}
Here we provide the proof of all propositions of \autoref{sec:result}.
\subsection{From rights to allowed devices}
No proposition in this section.
\subsection{Definition of the attacker and of the open process semantics}
\subprocess*
\begin{proof}
By induction on the number of reduction steps.
We assume that the result is true for $n-1$ reductions
i.e we have $P ~|~ A \ra\!^* P' ~|~ A'$
which is mimicked by
\[\attKnowledge \grants \subp{P}{S} \lra{l_1,\ldots,l_m} \subp{\attKnowledge' \grants P'_a}{S}\]
and we prove that if $P' \mid A' \ra P'' \mid A''$ then we can also have
\[\attKnowledge \grants \subp{P'_a}{S} \lra{l?} \subp{\attKnowledge' \grants P''_a}{S}.\]
\begin{enumerate}
\item
If the last reduction involves devices which are part of $S$, then this same reduction can be done on $\subp{P'_a}{S}$.
\item If the last reduction involves devices which are not part of $S$ then
no reduction has to be done in the open semantics.
\item If the last reduction $\nu \activechans.c. P \mid A \ra P_1 \mid A_1$ is \eqref{red:i/o}
from outside $S$ to $S$ transferring $v$ on $c$ then
the labeled reduction
$\attKnowledge \grants \nu \activechans.P \{\ca{c} / c \}
\lra{\LabIn{\ca{c},v}} \attKnowledge \grants \nu \activechans.P_1 \{\ca{c} / c \}$ is possible
since $v$ has been produced from values into memory not in $S$ and the attacker can derive all these values.
\item If the last reduction is a channel establishment between a device from $S$ and a one not from $S$,
the proof is similar. Note that the new channel name is annotated with $\ca{c}$ instead of $c$.
\item If the last reduction $\nu \activechans.c. P \mid A \ra P_1 \mid A_1$ is \eqref{red:i/o}
from $S$ to outside $S$ transferring $v$ on $c$ then
the labeled reduction $\attKnowledge \grants \nu \activechans.P \lra{\LabOut{c,v}} \attKnowledgeAdd{v} \grants \nu \activechans.P_1$
exists and we still have for all $v'$ in memory of a device of $P$ which identifier is not in $S$,
$ \attKnowledgeAdd{v} \vdash v'$.
\end{enumerate}
\end{proof}
\subsection{Extended syntax with extra annotations}
\safeStandard*
\begin{proof}
We assume that $P'$ is the $n$-th reduction of $P$.
We denote by $P_m$, $P$ after $m$ reductions.
Let $(I_i, \LR_i)= \backward{P \ra P_1 } (I_{i+1},\LR_{i+1})$
for $0 \leq i < n$ and $(I_n, \LR_n)=(\emptyset, \LR)$.
We now prove by induction on the number of reduction steps
that the annotation
$\attKnowledge_0; \refrights_0 \grants \subp{P}{D_H}
\Lra{l_1,\ldots,l_m} \attKnowledge_m; \refrights_m \grants \subp{P'_m}{D_H}$
such that $\refrights_m = \bigcup_{0\leq k \leq m} \LR_i$ is \standard.
Note that as the set is safe,
we have $\forall \pubof{k} \in \refrights_0,~ \attKnowledge_0 \ngetPower_{\refrights_0} \secof{k}$.
Moreover we also $\LR \subseteq \refrights_n$ by definition.
$\LR_m \subseteq \refrights_m$ where $\LR_m$ contains all the keys of $\LR$ which have already been created.
The only reduction we need to consider are the one which might not be \standard i.e.
when a reduction which creates a new principal $\pvalue=\prinv{k}{\{k_1, \ldots, k_n\}}$
where $k$ is in $\bigcup_{0\leq k \leq m} \LR_i$.
However, by design of the $\backward{}$ function, we have $\{k_1, \ldots, k_n\} \in \refrights_{m-1}$:
the reduction is \standard.
\end{proof}
In the following auxiliary lemma,
we state that \lowr expressions reduces to \lowr values while \highr expressions reduces
to \highr values.
\begin{lemma}\label{lemma:tag-on-expression}
Let $e$ and $\mem$ be such that the sub-expressions $e_i : R_i$ of $e$ are such
that $\evaluates{\mem}{e_i}{\tagx{v_i}{\ell_i}}$ with $x_i=\high$ iff. $\refrights \lpc R_i$.
Let $\tagx{v}{\ell}$ such that $\evaluates{\mem}{e}{\tagx{v}{\ell}}$.
We have: $e : S_R$ with $\refrights \lpc R$ iff $\ell=\high$.
\end{lemma}
\begin{proof}
If $\refrights \lpc R$, we consider all constructors:
\begin{enumerate}
\item $e=a+b$.
If $e : S_R$ with $\refrights \lpc R$, due to the typing rule
$a$ or $b$ has type $\Int_{R'}$ with $\refrights \lpc R'$,
by the induction hypothesis, one of them reduced to a \highr value and
the reduction rule states that the result has to be \highr.
If $e : S_R$ with $\refrights \nlpc R$ due to the typing rule
both $a$ and $b$ has type $\refrights \nlpc R'$,
by hypothesis both of them reduce to a \lowr value,
the reduction rule states that the result will not be \lowr.
\item $e=x[e']$.
If $e : S_R$ with $\refrights \lpc R$, due to the typing rule \ref{type:element}
$x$ or $e'$ has type with label $\refrights \lpc R'$,
by the induction hypothesis, one of them reduced to a \highr value and
the reduction rule states that the result has to be \highr.
If $e : S_R$ with $\refrights \nlpc R$, due to the typing rule
both $x$ and $e'$ has type $\refrights \nlpc R'$,
by hypothesis both of them reduce to a \lowr value,
the reduction rule states that the result will be \lowr.
\item $e=\encE{e_1}{R}$.
According to \ref{type:enc}, we have $e : S_\bot$ and reduces to a \lowv value (since the new root is \lowv).
\item $e= \release{P}$, according to \ref{type:release}, $e :\SecK_\bot$ and reduces to a \lowv value.
\item $e=\publicKey{P}$, according to \ref{type:pubKey}, $e :\PubK_\bot$ and reduces a \lowv value.
\end{enumerate}
\end{proof}
\begin{lemma}\label{lemma:no-tag<=>low-type}
Let $\refrights,C,\mem,y$ such that $\safe{\refrights}{\mem}{y}{C}$ for some $\ctx$ and
where $C$ is a command with an expression $e$ such that $\typeVar{e} : S_R$.
We have that $\refrights \lpc R$ iff. $\evaluates{\mem}{e}{\tagged{v}}$ for some value $v$.
\end{lemma}
\begin{proof}
By induction on the structure of $e$.
If $e$ is a variable, we conclude from Item \ref{safe:variables} of \autoref{def:safe}.
For the inductive case, we use \autoref{lemma:tag-on-expression} to conclude.
\end{proof}
\subjectreduction*
\begin{proof}
W.l.o.g. we consider that the reduction is done on $D_1$ (eventually $D_1$ and $D_2$ if it is a communication between two device).
We write $D_1=\dev{\mem_1}{\thr{x}{C_1} ~|~ \ldots ~|~ \thr{x_n}{C_n}}$ and
$D'_1=\dev{\mem'_1}{\thr{x'}{C'_1} ~|~ \ldots ~|~ \thr{x_n}{C'_n}}$.
Let ${\GammaPrin}_i$, ${\GammaKey}_i$, $\ctx_i$ and $pc_i$ such that $\safe{\refrights}{x_i}{\mem_i}{C_i}$.
We prove all the conditions of \wa separately.
\begin{enumerate}
\item[\ref{safe:well-type}.] {\bf $C_i'$ is well-typed for some $pc_i',\ctx_i'$}
By hypothesis, we know that $C_i$ is well-typed for some ${\GammaPrin}_i$, ${\GammaKey}_i$, $pc_i,\ctx_i$.
If $C_i := C \mid C'$ then the two new threads after reduction are well-typed with ${\GammaPrin}_i$, ${\GammaKey}_i$, $\ctx_i$ and $pc_i$
due to \eqref{type:para}.
If $C_i := !C$ then the two new threads are also well-typed due to \eqref{type:bang}.
Otherwise, the form of $C_i$ is $c ; C'_i$ (up to name renaming)
or $\textrm{cond}(c)\THEN C_a \ELSE C_b$ where $C_a$ or $C_b$ is
an renaming of $C'_i$.
All the corresponding type rules enforces that $C_i$ is well-typed
only if $C'_i$ is well-typed.
\item[\ref{safe:variables}.] {\bf For all location $x$ in $\mem$, we have
\begin{itemize}
\item either $\locl{x}{\untagged{v}}$ in $\mem$ for some value $v$ and $x \in \GammaPrin \cup \GammaKey$
\item or $\GammaPrin;\GammaKey;\ctx \vdash x : S_R$ and
\begin{itemize}
\item if $\refrights \lc \mem(R)$, $\loch{x}{\tagged{v}}$ in $\mem$,
\item if $\refrights \nlc \mem(R)$, $\locl{x}{\untagged{v}}$ in $\mem$ for some value $v$.
\end{itemize}
\end{itemize}}
First, we consider the annotation of variables.
Once a memory location is created,
there is no reduction rule to change its type ($\lowr$ or $\highr$),
$\refrights$ never becomes more confidential ($\refrights$ increases only with new fresh keys)
and all types rules enforce that the reduced command $C'$ can be typed
with a context which preserves rights for all variables.
For these reasons, if the property holds when a variable is created, it holds forever.
During creation, by design of the annotated rules, the location is created as \highr or \lowr
only depending on if $\refrights \lpc R$ for regular variable and is always \lowr
when the location contains a principal or a key.
For inputs, since the input command does not specify the type,
we look at the annotation of the channel,
which is itself defined from the condition $\refrights \lpc R_1$ in the annotated semantic rules
about channel creation
\eqref{red:h:open-for}, \eqref{red:lh:open-for}, \eqref{red:ll:open-for}
for channel opening with the attacker,
from the fact that $\attKnowledge \ngetPower_\refrights \secof{k}$ for all $\pubof{k} \in \refrights$
we know that the channel has a type for values less confidential than $\refrights$.
For the annotation of values, we need to check that no \highv values are stored into \lowr memory
(the annotation always produces \highv values from \highr memory).
The reductions which set new values to \lowr memory locations are the following:
\eqref{red:l:aff}, \eqref{red:l:new_var}, \eqref{red:let},
\eqref{red:ll:dec1}, \eqref{red:l:i/o} and \eqref{redatt:input}.
For the first rules (\eqref{red:l:aff}, \eqref{red:l:new_var} ),
the stored value is the evaluation of an expression $E$.
Since the type rules associated to these commands enforces $E$ to be of a type $R$ such that $\refrights \lpc R$,
according to Lemma \ref{lemma:no-tag<=>low-type}, $E$ reduces to a \lowv term.
The argument is the same for \eqref{red:let}.
For the internal communication \eqref{red:l:i/o},
the argument is the same except that the type judgment of $E$ is on the other device.
For the input from the attacker \ref{redatt:input},
the rule set that attacker's inputs are \lowv.
For rule \eqref{red:ll:dec1} where one layer of encryption is removed,
we have to ensure that the decrypted value is \lowv.
The typing rule requires that $\refrights \nlpc R_1$ and $R_2 \lc R_1$
which implies $\refrights \nlpc R_2$.
From Item~\ref{safe:cipher-variable}, we conclude.
The rule \eqref{red:hl:dec1} can never be applied.
Indeed, if the cipher is \highv, from \autoref{lemma:no-tag<=>low-type}, the cipher has a \highr type,
then the typing rule enforce the \progc to be high which means the thread has to be \hight.
\item[\ref{safe:pc}.] {\bf $\refrights \lc pc$ if and only if $y=\high$.}
First note that all types rules of commands requires that their continuation can be typed with the same \progc.
The interesting cases are when the type rules requires the continuation to be typed with a more restrictive \progc
and, for the other direction of the equivalence, when the reduction rules reduces a \lowt thread into a \hight thread.
\begin{itemize}
\item Conditional is typed with \eqref{type:if}: the \progc $pc'$ of the continuation if set to $\refrights \lc pc'$
when at least one of the expressions is more confidential than $\refrights$ (we assume that initially $\refrights \nlpc pc$).
According to \autoref{lemma:no-tag<=>low-type}, one of the expression reduces to a \highv value.
In this case, the reductions rules \eqref{red:h:if1} and \eqref{red:h:if0} sets the thread to \hight.
Reciprocally, if the thread is set to \hight, on of the value is \highv and according to \autoref{lemma:no-tag<=>low-type}
the type of the continuation is $\refrights \lc pc'$.
\item Secure channel opening is typed with \eqref{type:open-cert-client} and \eqref{type:open-cert-server}.
Both type rules requires the continuation to have a \progc $pc'$ set such that $\refrights \lc pc'$ iff
$\refrights \lc R_2$ where $R_2$ is the right to see the channel.
The reduction rule \eqref{red:h:open-for} can be applied only when $R_2$ and $R'_2$, the rights to see the channel of both threads
are equal and sets both threads to \hight exactly with the same condition.
\item Decryption is typed with \eqref{type:dec}, the \progc $pc'$ of the continuation if set to $\refrights \lc pc'$
when the expression to decrypt has rights $R$ with $\refrights \lc R$.
This coincides with the reductions rules \eqref{red:hh:dec1}, \eqref{red:hl:dec1},\eqref{red:h:dec0}
where the thread becomes \hight iff the decrypted value is \highv (due to \autoref{lemma:no-tag<=>low-type}).
\end{itemize}
\item[\ref{safe:channel}.] {\bf For all $c$ in the thread such that $\ctx \vdash c : \Chan({S}_{R_1})_{R_2}$,
the annotation of $c$ is $c^z_{(z')}$
where $z=\high$ iff. $\refrights \lc R_2$, $z'=\high$ iff. $\refrights \lc R_1$.}
The annotation on channel is definitively fixed once it is created.
The channel establishment rules \eqref{red:h:open-for}, \eqref{red:lh:open-for},
\eqref{red:lh:open-for} and \eqref{red:ll:open-for} all enforce this property in their premisses.
Public channels have type $\bot$ and are annotated with $c^-_\low$.
\item[\ref{safe:no-high-attacker-chan}] {\bf For all $\ca{c}$,
we have $\ctx \vdash \ca{c} : \Chan({S}_{R_1})_{R_2}$
with $\refrights \nlc R_2$ and $\refrights \nlc R_1$.}
The interesting case is the creation of a new channel with the attacker.
This can be done through rules \eqref{redatt:auth-server-chan-for}
and \eqref{redatt:auth-client-chan}.
By hypothesis, the attacker does not know any key in $\refrights$ so it can only provides a secret key $\secof{k}$
not in $\refrights$.
Due to \eqref{type:open-cert-client} or \eqref{type:open-cert-server},
$R_1$ and $R_2$ should contains $\pubof{k}$.
Therefore neither $R_1$ or $R_2$ is a subset of $\refrights$, which means $\refrights \nlc R_2$ and $\refrights \lc R_1$
as $\gamma$ is required to be empty.
\item[\ref{safe:low-pc-low-chan}] {\bf If $y$ is $\low$, then there is no $\chanhh{c}$ in $C$.}
This is true before reduction. Since establishing a new channel $\chanhh{c}$ set the thread
to \hight, the property is also true after reduction.
\item[\ref{safe:cipher-variable}]{ \bf For all $x$ in memory, if a sub-term of $x$ is $\enc{\tagged{t}}{n}{RS}$
then $\refrights \lc RS$.}
The encryption typing rule for $E=\encE{E_1}{R}$, \eqref{type:dec}, requires that $E_1 :R_1$ is such that $R_1 \lc R$.
From \autoref{lemma:no-tag<=>low-type},
we have $\evaluates{\mem}{E_1}{\tagged{v}}$ implies $\refrights \lc R_1$
and therefore $\refrights \lc R$ which allows to conclude.
\item[\ref{safe:released-prin}] {\bf For all $x$ in memory, if a sub-term of $x$ matches $\enc{\prin{k}{\LR}}{n}{\LR'}$
then $\LR = \LR'$ or $\pubof{k} \notin \refrights$.}
Encapsulated principals can only be produced with a $\release{P}$ expression or by an input of the attacker.
In the first key, the release reduction \eqref{rede:release} always encrypts the principal $\prinv{k}{\LR}$
with the keys of $\LR$ in the other case since by hypothesis we have $\attKnowledge \ngetPower_{\refrights} \secof{k}$
we also have $\attKnowledge \ngetPower_{\refrights} \prin{k}{r}$ for any $r$ so the attacker cannot output this value.
\end{enumerate}
Finally, we prove that when the annotation is \standard, we have $\attKnowledge' \ngetPower_{\refrights'} \secof{k}$
for all $\pubof{k} \in \refrights'$.
The result is immediate for reductions which do not change $\attKnowledge$ or $\refrights$.
The set $\attKnowledge$ increases only with the reduction \eqref{redatt:output}.
The values which contains secret keys of $\refrights$ are of type $\privKeyType$
(or a combination of tuples and encryptions of this type).
According to item \ref{safe:released-prin}, any $\prinv{k}{R}$ is encrypted with $R$.
Moreover, by definition of \standard annotation, all keys $\prinv{k_i}{R_i}$ in $\refrights$
are such that all keys of $R_i$ are also in $\refrights$.
Since $\attKnowledge \ngetPower_\refrights k$, the attacker cannot decrypt the key.
The reduction which modify $\refrights$ is \eqref{red:h:nwp}, but the new key is fresh
so the attacker cannot derive new facts from the fact that $\attKnowledge \ngetPower_\refrights' v$
is syntactically more powerful than $\attKnowledge \ngetPower_\refrights v$.
\end{proof}
\initialprocess*
\begin{proof}
Condition \autoref{safe:low-pc-low-chan} of \wa is true since $pc=\bot$ and the tread is $\low$.
Since $\mem_i$ and $\ctx$ only contains principals and public keys, the other conditions which concerns
other kind of values and variables are immediately true.
\end{proof}
\subsection{Labelled bisimilarity}
\begin{lemma}\label{lemma:memrel=>eval-equal}
When two memories $\mem_1$ and $\mem_2$ only contains \lowr locations,
$\mem_1 \nvdash \secof{k}$ and $\mem_2 \nvdash \secof{k}$ for all $k$ such that $\pubof{k} \in \refrights$
and $\mem_1 \memrel{\refrights} \mem_2$
implies that, for all extended attacker expression $f$ (\autoref{fig:extended-expressions}),
$\erase{\refrights}{\mem_1(f)}= \erase{\refrights}{\mem_2(f)}$.
\end{lemma}
\begin{proof}
By induction on the structure of $f$.
This is true if $f$ is a variable or an integer.
We assume that $\erase{\refrights}{\mem_1(f_i)}=\erase{\refrights}{\mem_2(f_i)}$ for all sub-expressions $f_i$ of $f$.
For $\mathrm{freshprin}(i)$, $i$ has to evaluate has an integer. Since
the function $\mathrm{freshprin}(i)$ returns the $i$-th principal of a determined sequence of principals,
the expression returns the same key in both memory.
For $\mathrm{encr}_r(f)$, since the extended expression $r$ has to evaluate to a right it evaluate to the same right for both
memories, so the result is either obfuscated with both memories or none of them.
For $\mathrm{decr}_s(f)$, the result is immediate if $f$ evaluates to a cipher which is not obfuscated.
Otherwise, $f$ is a cipher encrypted with rights $r'$, $\refrights \lc r'$, by hypothesis,
we have that $s$ cannot corresponds to any key in $r'$ therefore the decryption fails (result $\NotAValue$) in both memories.
\end{proof}
\begin{lemma}\label{prop:memrel=>static-equiv}
When two memories $\mem_1$ and $\mem_2$ only contain \lowr locations,
$\mem_1 \nvdash \secof{k}$ and $\mem_2 \nvdash \secof{k}$ for all $k$ such that $\pubof{k} \in \refrights$
and $\mem_1 \memrel{\refrights} \mem_2$
implies that $\mem_1 \approx_s \mem_2$.
\end{lemma}
\begin{proof}
Let $f$ and $g$ be two extended expressions which evaluates to the same value $v$ under $\mem_1$ ($\mem_1(f)=\mem_1(g)=v$).
We show that $\mem_2(f)=\mem_2(g)$.
From \autoref{lemma:memrel=>eval-equal}, we have
$\erase{\refrights}{\mem_2(f)}=\erase{\refrights}{\mem_2(g)}=\erase{\refrights}{v}$.
However the obfuscation function does not obfuscate the nonce of ciphers.
And the attacker power does not allow the attacker to generate a cipher with a nonce which is not fresh
(this is due to the fact that nonce cannot be extracted from ciphers from which the key is unknown).
Therefore each nonce is uniquely associated to a unique value.
As nonces are equals the obfuscated values are equals too.
\end{proof}
\begin{lemma}\label{lemma:no-tag=>equiv}
Given a command context $C$, a set of public keys $\refrights$,
two memories $\mem$ and $\mem'$, an expression $E$ and $\ell' \in \{ \low, \high \}$,
if we have $\safe{\refrights}{\mem}{\ell'}{C[E]}$ and $\safe{\refrights}{\mem'}{\ell''}{C[E]}$, $\mem \memrel{\refrights} \mem'$
, $\evaluates{\mem}{E}{\untagged{v}}$ and $\evaluates{\mem'}{E}{\tagx{v'}{\ell}}$
then $\erase{\refrights}{v}=\erase{\refrights}{v'}$.
\end{lemma}
\begin{proof}
By induction on the structure of $E$.
\begin{enumerate}
\item
If $E$ is a variable $x$ with $\evaluates{\mem}{E}{\untagged{v}}$ then due to Item \ref{safe:variables} of Definition \ref{def:safe},
we have $\locl{x}{\untagged{v}}$.
By definition of $\mem \memrel{\refrights} \mem'$, we conclude $\evaluates{\mem'}{E}{\untagged{v}}$.
\item
If $E$ is $e_1 + e_2$ with $\evaluates{\mem}{E}{\untagged{v}}$, due to rule \eqref{rede:l:sum} and \eqref{rede:h:sum}
$v$ is \lowv implies that none of its sub-expressions is \highv, we conclude by induction.
\item For $E=x[n]$, the principle is the same.
\item For $E=x\{E_1,\ldots,E_n\}$, the principle is also the same.
\item If $E = \encE{e}{\LR'}$ with $\evaluates{\mem}{E}{v}$.
If $\refrights \nlpc \LR'$, due to the type rule \eqref{type:enc},
$e : B_R''$ with $\mem(R'') \lpc \LR' \lpc \refrights$.
According to \autoref{lemma:no-tag<=>low-type} $e$ is \lowv,
we conclude by induction.
If $\refrights \lpc R'$, then $\erase{\refrights}{\enc{v}{n}{\LR'}}=\enc{\_}{n}{\LR'}$ so $v$ does not appear.
\item For expressions which involves principals ($\mathbf{pub}(p)$ and $\mathbf{release}(p)$) we conclude as principals are not stored in \highr location.
\end{enumerate}
\end{proof}
\begin{restatable}{proposition}{stronger}\label{thr:stronger}
Let $\attKnowledge_1; \refrights \grants P_1$ and $\attKnowledge_2; \refrights \grants P_2$
be two \wa processes such that
$\forall \pubof{k} \in \refrights,\quad \attKnowledge_i \ngetPower_\refrights \secof{k} $ ($i \in \{1,2\}$) and
$P_1 \labrel P_2$, we have:
\begin{enumerate}
\item if $P_1 \lra{l} P_1'$
then $P_2 \lra{l} P_2'$ and $P_1' \labrel P_2'$ for some $P_2'$.
\item if $P_1 \ra P_1'$, then $P_2 \ra^? P_2'$ and $P_1' \labrel P_2'$ for some $P_2'$,
\end{enumerate}
\end{restatable}
\begin{proof}
\newcommand{P^A}{P^A}
\newcommand{P^B}{P^B}
To avoid conflict of indexes, we consider $P^A$ and $P^B$ instead of $P_1$ and $P_2$.
\paragraph{When the reduction is a labeled reduction with the attacker}
\begin{itemize}
\item Case where the reduction rule applied to $P^A$ is \eqref{redatt:pub-chan}
on a thread $\thr{x}{\connectPub{\ca{c^A}}{\Chan(S_\bot)_\bot};{C'^A}}$.
From \eqref{type:connectPub}, we know that $\refrights \lc pc$.
From Item \ref{safe:pc} of \autoref{def:safe}, we know that this reduction is possible only when
$x = \low$.
Hence there exists the same thread in $P^B$.
The reduction on the corresponding thread of $P^B$ leads to $C'^A$ through the same label $\LabIn{c,S}$
up to the name of $\ca{c^B}$,
but they are equal up to alpha-renaming of the channel name.
Hence we have the condition on commands of \autoref{def:final-relation}.
Finally the memory is unchanged and the attacker does not learn any value any both process:
the condition about memories of \autoref{def:final-relation} and memory equivalence of the attackers hold.
\item Case where the reduction rule applied to $P^A$ is \eqref{redatt:auth-server-chan-for},
on a thread $\thr{x}{\connectCCert{\ca{c^A}}{\Chan(S_{R_1})_{R_2}}{k}{P};{C'^A}}$,
with label $\LabIn{\ca{c^A},\secof{k_s},\pubof{k_c},S,r,r'}$ be the values in the label of the reduction.
Since $\pubof{k_s} \notin \refrights$ (according to our hypothesis),
due to \eqref{redatt:auth-server-chan-for}, $k \notin \refrights$ and
due to the type rule \eqref{type:open-cert-server}, we have
$\refrights \nlpc R_1$ and $\refrights \nlpc R_2$.
According to Item \ref{safe:pc} of \autoref{def:safe}, the thread is \lowt ($x=\low$).
So an identical thread exists in $P^B$, and since the label enforces $S$, $R_1$ and $R_2$ to be the sames,
it reduces to $C'^A$ up to the renaming of the channel name.
Finally, $\attKnowledge^A$, $\attKnowledge^B$, $\mem^A$ and $\mem^B$ remain the sames.
\item The case where the reduction rule applied to $P^A$ is \eqref{redatt:auth-client-chan} is similar.
\item Case where the reduction rule applied to $P^A$ is \eqref{redatt:output}
on a thread $\thr{z}{\outputChan{\ca{c}}{e};C^A}$, with label $\LabOut{\ca{c^A},x}$.
According to Item \ref{safe:no-high-attacker-chan} of \autoref{def:final-relation}
the channel is of type $\Chan({S}_{R_1})_{R_2}$ with $\refrights \nlpc R_1$ and $\refrights \nlpc R_2$.
According to \eqref{type:output}, we have $R_2 \nlpc pc$ and so $\refrights \nlpc pc$.
According to Item \ref{safe:pc} of \autoref{def:safe} the thread is \lowt ($z=\low$).
Therefore there exists an identical thread in $P^B$ where the same label reduction is possible.
Moreover, according to \eqref{type:output}, we have $e :R_1$ with $\refrights \nlc R_1$ so
according to \autoref{lemma:no-tag<=>low-type}, $\evaluates{\mem^A}{e}{\untagged{v^A}}$ for some $v^A$.
According to Lemma \ref{lemma:no-tag=>equiv},
we have $\erase{\refrights}{v^B}=\erase{\refrights}{v^A}$, hence $\attKnowledge^A \memrel \attKnowledge^B$.
\item Case where the reduction rule applied to $P^A$ is \eqref{redatt:input}
on a thread $\thr{z}{\inputChanII{\ca{c}}{x};C^A}$ with label $\LabIn{\ca{c^A},f}$.
According to Item~\ref{safe:no-high-attacker-chan} of \autoref{def:final-relation}
the channel is of type $\Chan({S}_{R_1})_{R_2}$ with $\refrights \nlpc R_1$ and $\refrights \nlpc R_2$.
According to \eqref{type:input}, we have $R_2 \nlpc pc$ and so $\refrights \nlpc pc$.
According to Item \ref{safe:pc} of \autoref{def:safe} the thread is \lowt ($z=\low$).
So there is an identical thread in $P^B$ (which reduces with the same label).
According to \autoref{lemma:memrel=>eval-equal} we have
$\erase{\refrights}{\attKnowledge^A(f)}=\erase{\refrights}{\attKnowledge^A(f)}$.
Therefore, the new memories $\mem'^A$ and $\mem'^B$ are equivalent.
\end{itemize}
\paragraph{When the reduction is made on a thread where $\safe{\refrights}{\low}{\mem}{C}$}
In that case, we use the fact
for any thread $\thr{\low}{C^A}$ on some device with memory $\mem^A$ on which the reduction happens,
there exists a thread $\thr{\low}{C^B}$ on the other process with memory $\mem^B$
such that $C^A \simeq C^B$ and $\mem^A \memrel{\refrights} \mem^B$.
We prove all the requirements sequentially: first, we prove that $\refrights$ reduces to the same $\refrights'$
in both process.
Secondly, we prove the commands reduce to equivalent commands.
Thirdly, we prove the equivalence of the new memories.
\begin{enumerate}
\item {\bf We have ${\refrights}'^A = {\refrights}'^B$}
The one reduction that changes $\refrights$ is \eqref{red:h:nwp}.
When reference rights change in a reduction due to \eqref{red:h:nwp},
the thread is \lowt due to the typing rule so the reduction can also occurs in process $B$.
We conclude by renaming the new key variables of both processes to the same name.
\item {\bf Reductions rules for $C^B$ is the same as for $C^A$: $C'^A=C'^B$ (or both new threads are \hight)}
There are two cases for ``if'', and two cases for ``dec''
\begin{itemize}
\item The rule $C^A \ra C'^A$ is \eqref{red:h:if1} or \eqref{red:h:if0}.
In these cases, according to Lemma \ref{lemma:no-tag<=>low-type},
the evaluated expressions was \highr.
So it is also true for $C^B$ therefore
the conditional expression of $C^B$ also evaluates
to a \highv value according to Lemma \ref{lemma:no-tag<=>low-type}.
On the other hand, the new thread $C'^A$ is $\high$
so whatever $C^B$ reduces to the then or the else branch,
the condition about commands of \autoref{def:final-relation} is satisfied.
\item The rule $C^A \ra C'^A$ is \eqref{red:l:if1} or \eqref{red:l:if0}.
This means the expression evaluates to a \lowv value.
In addition, the evaluation returns an integer which implies the expression
can only contains $+$, integers and variables.
This implies that the results is only dependent on \lowv values:
since \lowv values in $C^A$ and $C^B$ are the same both reduce according to the same rule.
\item The rule is \eqref{red:l:dec0}, \eqref{red:ll:dec1} or \eqref{red:lh:dec1}.
Since the value to decrypt is \lowv, the value in $A$ and $B$ differ only on \highv sub-terms
which means that the encryption key is the same, so both processes take the same branch.
\item The rule is \eqref{red:h:dec0} or \eqref{red:hh:dec1}:
whatever \eqref{red:l:dec0} or \eqref{red:ll:dec1} is taken the thread become \hight on $A$ and $B$.
\end{itemize}
\item {\bf New values in memories are such that $\mem'^A \memrel{\refrights} \mem'^B$.}
First of all, because the rights are the same in $C^A$ and $C^B$
and premisses on the rules depends only on rights, the high or low rule is applied for both command.
\begin{itemize}
\item Rules that store values into \highr memory locations
\eqref{red:h:new_var}, \eqref{red:h:aff},
\linebreak
\eqref{red:lh:dec1}, \eqref{red:hh:dec1}:
they affect \highr locations so condition $\mem'^A \memrel{\refrights} \mem'^B$ holds whatever is the stored value.
\item Rules that store values into \lowr memory locations:
\eqref{red:l:new_var}, \eqref{red:l:aff}, \eqref{red:ll:dec1}, \eqref{red:let}
according to Item \ref{safe:variables} of Definition \ref{def:safe}, these values are not \highv
so, according to Lemma \ref{lemma:no-tag=>equiv}, we have
$\erase{\refrights}{v^A}=\erase{\refrights}{v^B}$.
\item Rule \eqref{red:l:register1}: $K^A$ is in a \lowr memory location so $K^A=K^B$
and so the new principals are identical.
\item Creates a principal \eqref{red:h:nwp} and \eqref{red:l:nwp}:
the new value contains fresh values and rights that are identical in $A$ and $B$.
\end{itemize}
\end{enumerate}
\paragraph{When the reduction is done on a thread $C$ where $\safe{\refrights}{\high}{\mem}{C}$}
\begin{enumerate}
\item Internal reductions does not change the equivalence class of the process
(so the other process can simulate it with no reduction).
Indeed, first, there is no reduction that reduces a \hight thread to a \lowt thread:
the reduced command $C'$ does not impact the equivalence class of the process.
Secondly, the reductions that create or change memories location are:
\eqref{red:h:new_var}, \eqref{red:hh:dec1} and \eqref{red:h:aff}.
In each case, the type rules states that $pc \lpc R$ where $R$ is the right of the memory.
Due to Item \ref{safe:pc} of Definition \ref{def:safe}, we have
that $pc$ is high.
Hence $R$ is high too, so the rule either creates or change a memory location with flag $\high$.
\end{enumerate}
\paragraph{When the reduction is made between two threads $C_1$ and $C_2$ where $C_1$ is \hight.}
\begin{itemize}
\item If both $C_1$ and $C_2$ are \hight. The only possible reduction are \eqref{red:h:i/o} and \eqref{red:h:open-for}.
In case of \eqref{red:h:open-for}, from Item \ref{safe:low-pc-low-chan}, we have $\refrights \lc pc$.
The types rules \eqref{type:open-cert-client} and \eqref{type:open-cert-server}
enforces that $R_1$ and $R_2$ are \highr. Due to Item \ref{safe:channel}, the channel is annotated with $\chanhh{c}$.
In case of \eqref{red:h:i/o}, the type rules \eqref{type:input} enforces that all received values are stored
into \highv memory. Since \hight threads and \highr memory locations are free to differ between the two processes,
the equivalence is preserved after reduction.
\item If $C_2$ is \lowt. Any annotation variant of the rule \eqref{red:i/o}
is not possible when one thread is \lowt and the other is \hight.
Indeed, according to Item \ref{safe:channel} of Definition \ref{def:safe},
there is no $c_\high^\high$ channel on the \lowt thread.
On the other \hight thread, a $c_\low^\low$ or $c_\low^\high$ channel has a \lowr type according to
Item \ref{safe:channel} of Definition \ref{def:safe},
so according to \eqref{type:output} and \eqref{type:input} they cannot be used one this thread.
So only establishing connection is possible with rule \eqref{red:h:open-for}
where the client is on the \lowt thread $C_2$
and the server is on the \hight thread $C_1$.
Due to the reduction rule \eqref{red:h:open-for}, $C_2'$ is a \hight thread
and $C'_1$ is \hight too so the equivalence is preserved in both processes.
\end{itemize}
\paragraph{When the reduction is made on two threads which are \lowt.}
\
For all communication opening rules, rights in both process are identical since the public keys of the rights set are public.
So both processes thread reduces either to a \hight thread or a \lowt thread.
Hence the two reduced processes remains in the same equivalent class.
For the input/output reduction rule \eqref{red:l:i/o}, according to Item~\ref{safe:low-pc-low-chan} of Definition \ref{def:safe},
the channel type can only be $c^\low_\low$ or $c^\high_\low$ since the threads are \lowt.
On the output thread, \highv values are sent only on $c^\high_\low$ channels.
According to Item~\ref{safe:channel}, on the input side $c^\high_\low$ has type $\Chan(S_R)_{R'}$ with $\refrights \lc R$.
According to \eqref{type:input}, the value is stored in a \highv memory location so
even if the values differ between $P^A$ and $P^B$ memories are still equivalent.
On the other hand, if the values $v^A$ and $v^B$ sent on the channels are not \highv then they have to be equivalence:
$\erase{\refrights}{v^A}=\erase{\refrights}{v^B}$.
\end{proof}
\implylabelled*
\begin{proof}
The first item is a direct consequence of \autoref{prop:memrel=>static-equiv}
The two last items are a consequence of \autoref{thr:stronger} with the fact that
when the annotation is \standard, according to \autoref{lemma:subred},
we have that $\forall \pubof{k} \in \refrights,\quad \attKnowledge_i \ngetPower_\refrights \secof{k} $
is preserved by the reduction, so the proposition can be generalized to any number of reduction steps.
\end{proof}
\subsection{Main theorems}
\thmB*
\begin{proof}
Since there is no untyped attacker, we can use non-\standard annotations.
We consider the one such that at the beginning $\refrights$ contains all the keys of $R$ which are present in some memory,
and which add a key in $\refrights$ if and only if this key is in $R$.
From \autoref{thr:stronger} on this annotated process,
we get the existence of $Q$ such that $Q \labequiv P''$ which imply that
for all memory $\mem_i$ in $P''$ and $\mem'_i$ in $Q$, we have $\mem_i \memrel{R} \mem'_i$.
By definition of $\memrel{R}$, we conclude.
\end{proof}
\section{Annotated rules}\label{sec:ext-rules}
\small
We define $\topc(x,y)$ to be $\low$ except if $x=y=\high$.
\begin{gather}
\inferrule{\fresh{(k)} \\ \fresh(P')
}{
\attKnowledge; \refrights \grants \devA{\mem}{\thr{x}{\newPrin{P}{R} ; ~C}}
\\ \ra \attKnowledge; \refrights \cup \{ \pubof{k} \}
\grants \devA{\mem \addm{ \loc{P'}{\prinv{k}{R}}}}{\thr{x}{C\{P'/P\}}}
} \tag{high newPrin}\label{red:h:nwp}
\\
\inferrule{\fresh{(k)} \\ \fresh{P'}
}{
\attKnowledge; \refrights \grants \devA{\mem}{\thr{x}{\newPrin{P}{R} ; ~C}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem \addm{ \loc{P'}{\prinv{k}{R}}}}
{\thr{x}{C\{P'/P\}}}
} \tag{low newPrin}\label{red:l:nwp}
\\
\inferrule{
\evaluates{\mem}{e}{\tagx{\enc{\prinv{k_1}{R_1}}{R}{n}}{a}} \\
\evaluates{\mem}{P_2}{\prinv{k_2}{R_2}} \\
\pubof{k_2} \in R_1 \\
\fresh(P_3)
}{
\devA{\mem}{\thr{x}{\register{P_2}{e}{P_1}{C_1}{C_2}}} \\
\ra \devA{\mem \addm{\locl{P_3}{\prinv{k_1}{R_1}}}}{\thr{x}{C_1\{P_3 / P_1\}}}
}\tag{low register}\label{red:l:register1}
\end{gather}
\begin{gather}
\inferrule{
\evaluates{\mem}{p}{\prinv{k}{r}} \\
\evaluates{\mem}{e}{\tagx{\enc{v}{n}{RS}}{a}} \\
RS \lpc \mem(R_1)
\\ \pubof{k} \in \mem(R_1) \\
\fresh(y)
\\ \refrights \nlpc \mem(R_1)
}{
\attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{\decrypt{p}{e}{x}{S_{R_1}}{C_1}{C_2}}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem \addm{\locl{y}{v}}}{\thr{z}{C_1 \{y /x \}}}
}\tag{low dec\_true}\label{red:ll:dec1}
\\
\inferrule{
\evaluates{\mem}{P}{\prinv{k}{r}} \\
\evaluates{\mem}{e}{\tagged{\enc{v}{n}{RS}}} \\
RS \lpc \mem(R_1)
\\ \pubof{k} \in \mem(R_1) \\
\fresh(y)
\\ \refrights \nlpc \mem(R_1)
}{
\attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{\decrypt{P}{e}{x}{S_{R_1}}{C_1}{C_2}}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem\addm{\locl{y}{v}}}{\thr{\high}{C_1 \{y /x \}}}
}\tag{high thread/low var dec\_true}\label{red:hl:dec1}
\\
\inferrule{
\evaluates{\mem}{P}{\prinv{k}{r}} \\
\evaluates{\mem}{e}{\enc{v}{n}{RS}} \\
RS \lpc \mem(R_1)
\\ \pubof{k} \in \mem(R_1) \\
\fresh(y)
\\ \refrights \lc \mem(R_1)
}{
\attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{\decrypt{P}{e}{x}{S_{R_1}}{C_1}{C_2}}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem\addm{\loch{y}{v}}}{\thr{z}{C_1\{y /x \}}}
}\tag{low thread/high var dec\_true}\label{red:lh:dec1}
\\
\inferrule{
\evaluates{\mem}{P}{\prinv{k}{r}} \\
\evaluates{\mem}{e}{\tagged{\enc{v}{n}{RS}}} \\
RS \lpc \mem(R_1)
\\ \pubof{k} \in \mem(R_1) \\
\fresh(y)
\\ \refrights \lpc \mem(R_1)
}{
\attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{\decrypt{P}{e}{x}{S_{R_1}}{C_1}{C_2}}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem\addm{\loch{y}{v}}}{\thr{\high}{C_1\{y /x \}}}
}\tag{high dec\_true}\label{red:hh:dec1}
\\
\inferrule{
\evaluates{\mem}{P}{\prinv{k}{r}} \\
\evaluates{\mem}{e}{{\enc{v}{n}{RS}}} \\
(RS \nlpc \mem(R_1) \vee \pubof{k} \notin \mem(R_1))
}{
\attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{\decrypt{P}{e}{x}{S_{R_1}}{C_1}{C_2}}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{C_2}}
}\tag{low dec\_false}\label{red:l:dec0}
\\
\inferrule{
\evaluates{\mem}{P}{\prinv{k}{r}} \\
\evaluates{\mem}{e}{\tagged{\enc{v}{n}{RS}}} \\
(RS \nlpc \mem(R_1) \vee \pubof{k} \notin \mem(R_1))
}{
\attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{\decrypt{P}{e}{x}{S_{R_1}}{C_1}{C_2}}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem}{\thr{\high}{C_2}}
}\tag{high dec\_false}\label{red:h:dec0}
\end{gather}
\begin{gather}
\inferrule{
\evaluates{\mem}{e}{\tagx{v}{t}} \\
\fresh(y)
\\ \refrights \subseteq \mem(R)
}{
\attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{\newvar{x}{S_R}{e} ; ~C}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem \addm{\loch{x}{\tagged{v}}}}{\thr{z}{C \{y/x\}}}
} \tag{high new}\label{red:h:new_var}
\\
\inferrule{
\evaluates{\mem}{e}{\tagx{v}{t}}
\\ \refrights \varsubsetneq \mem(R)
\\\fresh(y)
}{
\attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{\newvar{x}{S_R}{e} ; ~C}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem \addm{\locl{x}{\tagx{v}{t}}}}{\thr{z}{C}}
} \tag{low new} \label{red:l:new_var}
\\
\inferrule{
\evaluates{(\mem\addm{\locl{x}{\tagx{v}{t}}})}{e}{\tagx{v'}{t'}}
}{
\attKnowledge; \refrights \grants \devA{\mem \addm{\locl{x}{v}}}{\thr{z}{\assign{x}{e} ; ~C}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem, \locl{x}{\tagx{v'}{t'}}}{\thr{z}{C}}
} \tag{low assign}\label{red:l:aff}
\\
\inferrule{
\evaluates{(\mem\addm{\loch{x}{\tagged{v}}})}{e}{\tagx{v'}{t}}
}{
\attKnowledge; \refrights \grants \devA{\mem \addm{\loch{x}{\tagged{v}}}}{\thr{z}{\assign{x}{e} ; ~C}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem \addm{ \loch{x}{\tagged{v'}}}}{\thr{z}{C}}
}\tag{high assign} \label{red:h:aff}
\\
\inferrule{
\evaluates{\mem}{e_1}{\untagged{v}}
\\ \evaluates{\mem}{e_2}{\untagged{v}}
}{
\attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{\cond{e_1}{e_2}{C_1}{C_2}}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{C_1}}
} \tag{low if\_true}\label{red:l:if1}
\\
\inferrule{
\evaluates{\mem}{e_1}{\untagged{v}}
\\ \evaluates{\mem}{e_2}{\untagged{v'}}
\\ v \neq v'
}{
\attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{\cond{e_1}{e_2}{C_1}{C_2}}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{C_2}}
} \tag{low if\_false}\label{red:l:if0}
\\
\inferrule{
\evaluates{\mem}{e_1}{\tagx{v}{t}}
\\ \evaluates{\mem}{e_2}{\tagx{v'}{t'}}
\\ \topc(t,t')=\high
}{
\attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{\cond{e_1}{e_2}{C_1}{C_2}}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem}{\thr{\high}{C_1}}
}\tag{high if\_true} \label{red:h:if1}
\\
\inferrule{
\evaluates{\mem}{e_1}{\tagx{v}{t}}
\\ \evaluates{\mem}{e_2}{\tagx{v'}{t'}}
\\ v \neq v' \\ \topc(t,t')=\low
}{
\attKnowledge; \refrights \grants \devA{\mem}{\thr{z}{\cond{e_1}{e_2}{C_1}{C_2}}}
\\ \ra \attKnowledge; \refrights \grants \devA{\mem}{\thr{\high}{C_2}}
}\tag{high if\_false} \label{red:h:if0}
\end{gather}
\begin{gather}
\inferrule{
\fresh(c)
\\ \evaluates{\mem_1}{P_s}{\prinv{K_s}{R_s}}
\\ \evaluates{\mem_2}{P_c}{\prinv{K_c}{R_c}}
\\ \mem_1({R_1}) = \mem_2({R'_1})
\\ \mem_1(R_2) = \mem_2(R'_2)
\\ \evaluates{\mem_1}{k_c}{\pubof{K_c}}
\\ \evaluates{\mem_2}{k_s}{\pubof{K_s}}
\\ \refrights \lpc \mem_1(R_1)
\\ \refrights \lpc \mem_1(R_2)
}{
\attKnowledge; \refrights \grants \devA{\mem_1}{\thr{z}{\acceptCCert{c_1}{\Chan({S}_{R_1})_{R_2}}{k_c}{P_s}; ~C_1 }}
\\ | \devB{\mem_2}{\thr{z'}{\connectCCert{c_2}{\Chan({S}_{R'_1})_{R'_2}}{k_s}{P_c} ; ~C_2}}
\\ \ra
\attKnowledge; \refrights \grants \devA{\mem_1}{\thr{\high}{C_1 \{\chanhh{c}/c_1\}}}
\\ | \devB{\mem_2}{\thr{\high}{C_2 \{\chanhh{c}/c_2\}}}
} \tag{high open\_priv} \label{red:h:open-for}
\\
\inferrule{ \fresh(c)
\\ \evaluates{\mem_1}{P_s}{\prinv{K_s}{R_s}}
\\ \evaluates{\mem_2}{P_c}{\prinv{K_c}{R_c}}
\\ \mem_1({R_1}) = \mem_2({R'_1})
\\ \mem_1(R_2) = \mem_2(R'_2)
\\ \evaluates{\mem_1}{k_c}{\pubof{K_c}}
\\ \evaluates{\mem_2}{k_s}{\pubof{K_s}}
\\ \refrights \nlpc \mem_1(R_1)
\\ \refrights \nlpc \mem_1(R_2)
}{
\attKnowledge; \refrights \grants \devA{\mem_1}{\thr{z}{\acceptCCert{c_1}{\Chan({S}_{R_1})_{R_2}}{k_c}{P_s}; ~C_1}}
\\ | \devB{\mem_2}{\thr{z'}{\connectCCert{c_2}{\Chan({S}_{R'_1})_{R'_2}}{k_s}{P_c} ; ~C_2}}
\\ \ra
\attKnowledge; \refrights \grants \devA{\mem_1}{\thr{z}{C_1 \{\chanll{c}/c_1\}}}
\\ | \devB{\mem_2}{\thr{z'}{C_2 \{\chanll{c}/c_2\}}}
} \tag{low open\_priv} \label{red:ll:open-for}
\\
\inferrule{
\fresh(c)
\\ \evaluates{\mem_1}{P_s}{\prinv{K_s}{R_s}}
\\ \evaluates{\mem_2}{P_c}{\prinv{K_c}{R_c}}
\\ \mem_1({R_1}) = \mem_2({R'_1})
\\ \mem_1(R_2) = \mem_2(R'_2)
\\ \evaluates{\mem_1}{k_c}{\pubof{K_c}}
\\ \evaluates{\mem_2}{k_s}{\pubof{K_s}}
\\ \refrights \nlpc \mem_1(R_1)
\\ \refrights \lpc \mem_1(R_2)
}{
\attKnowledge; \refrights \grants \devA{\mem_1}{\thr{z}{\acceptCCert{c_1}{\Chan({S}_{R_1})_{R_2}}{k_c}{P_s}; ~C_1}}
\\ | \devB{\mem_2}{\thr{z'}{\connectCCert{c_2}{\Chan({S}_{R'_1})_{R'_2}}{k_s}{P_c} ; ~C_2}}
\\ \ra
\attKnowledge; \refrights \grants \devA{\mem_1}{\thr{z}{C_1 \{\chanlh{c}/c_1\}}}
\\ | \devB{\mem_2}{\thr{z'}{C_2 \{\chanlh{c}/c_2\}}}
} \tag{low thread/high value open\_priv} \label{red:lh:open-for}
\\
\inferrule{
\evaluates{\mem_1}{e}{v} \\
\fresh(y)
}{
\attKnowledge; \refrights \grants \devA{\mem_1}{\thr{z}{\outputChan{\chanxh{c}}{E}; ~C_1}}
\\ | \devB{\mem_2}{\thr{z'}{\inputChan{\chanxh{c}}{x}; ~C_2}}
\\ \ra
\attKnowledge; \refrights \grants \devA{\mem_1}{\thr{z}{C_1}}
\\ | \devB{\mem_2 \addm{\loch{y}{\tagged{v}}}}{\thr{z'}{C_2 \{ y/x\}}}
}\tag{high i/o} \label{red:h:i/o}
\\
\inferrule{
\evaluates{\mem_1}{e}{v}\\
\fresh(y)
}{
\attKnowledge; \refrights \grants \devA{\mem_1}{\thr{z}{\outputChan{\chanll{c}}{e}; C_1}}
\\ | \devB{\mem_2}{\thr{z'}{\inputChan{\chanll{c}}{X}; C_2}}
\\ \ra
\attKnowledge; \refrights \grants \devA{\mem_1}{\thr{z}{C_1}}
\\ | \devB{\mem_2 \addm{\locl{y}{v}}}{\thr{z'}{C_2 \{y/x\}}}
}\tag{low i/o} \label{red:l:i/o}
\end{gather}
\begin{gather}
\inferrule{
\evaluates{\mem}{P}{\prinv{k}{R}} \\ R \neq \{\} \\ \fresh(n)
}{
\evaluates{\mem}{\release{P}}{\untagged{\enc{\prinv{k}{R}}{n}{R}}}
}\tag{\anne{release}}\label{rede:a:release}
\\
\inferrule{
\evaluates{\mem}{e}{\tagx{v}{t}}
\\ \fresh(n)
}{
\evaluates{\mem}{\encE{e}{RS}}{\untagged{\enc{\tagx{v}{t}}{n}{RS})}}
} \tag{\anne{enc}}\label{rede:a:enc}
\\
\inferrule{
\evaluates{\mem}{e_1 }{\tagged{v_1}}
\\ \evaluates{\mem}{e_2 }{\tagx{v_2}{t}}
}{
\evaluates{\mem}{e_1 + e_2}{\tagged{v_1+v_2}}
}\tag{\higha{sum}}\label{rede:h:sum}
\\
\inferrule{
\evaluates{\mem}{e_1 }{\untagged{v_1}}
\\ \evaluates{\mem}{e_2 }{\untagged{v_2}}
}{
\evaluates{\mem}{e_1 + e_2}{\untagged{v_1+v_2}}
}\tag{\lowa{sum}}\label{rede:l:sum}
\end{gather}
\begin{gather}
\inferrule{
\fresh(c)
}{ \attKnowledge; \refrights \grants \devA{\mem_1}{\thr{x}{\connectPub{c_1}{\Chan(S_\bot)_\bot} ; ~C_1}} \lra{\LabIn{c,S}}
\\ \attKnowledge; \refrights \grants \devA{\mem_1}{\thr{x}{C_1 \{\ca{c}/c_1\}}}
}
\tag{\atta{open\_public}}\label{redatt:pub-chan}
\\
\inferrule{
\evaluates{\attKnowledge}{f}{\{ \secof{k_s},\pubof{k_c},S,r,r' \}}
\\ \evaluates{\mem_2}{R}{r}
\\ \evaluates{\mem_2}{R'}{r'}
\evaluates{\mem_2}{k}{\pubof{k_s}}
\\ \evaluates{\mem_2}{P}{\prinv{k_c}{r'}}
\\ \fresh(c)
}{
\attKnowledge; \refrights \grants \devA{\mem_2}{\thr{x}{\connectCCert{c_2}{\Chan(S_{R_1})_{R_2}}{k}{P}; ~C_2}}
\\ \lra{\LabIn{c,f} }
\attKnowledge; \refrights \grants \devA{\mem_2}{\thr{x}{C_2 \{\ca{c}/c_2\}}}
} \tag{\atta{open\_priv\_client}} \label{redatt:auth-client-chan}
\\
\inferrule{
\evaluates{\attKnowledge}{f}{\{ \pubof{k_s},\secof{k_c},S,r,r' \}}
\\ \evaluates{\mem_1}{k}{\pubof{k_c}}
\\ \evaluates{\mem_1}{P}{\prinv{k_s}{r'}}
\\ \evaluates{\mem_1}{R}{r}
\\ \evaluates{\mem_1}{R'}{r'}
\\ \fresh(c)
}{
\attKnowledge; \refrights \grants \devA{\mem_1}{\thr{x}{\acceptCCert{c_1}{\Chan(S_{R_1})_{R_2}}{k}{P}; ~C_1}}
\\ \lra{\LabIn{c,f}}
\attKnowledge; \refrights \grants \devA{\mem_1}{\thr{x}{C_1 \{\ca{c}/c_1\}}}
} \tag{\atta{open\_server}} \label{redatt:auth-server-chan-for}
\\
\inferrule{
\evaluates{\mem_1}{e}{\tagx{v}{t}}
}{
\attKnowledge; \refrights \grants \devA{\mem_1}{\thr{z}{\outputChan{\ca{c}}{e}; C_1}}
\\ \lra{\LabOut{c,m}}
\attKnowledgeAdd{(\locl{m}{\untagged{v}})}; \refrights \grants \devA{\mem_1}{\thr{z}{C_1}}
} \tag{\atta{output}} \label{redatt:output}
\\
\inferrule{
\evaluates{\attKnowledge}{\attExpr}{\untagged{v}}
\fresh(y)
}{
\attKnowledge; \refrights \grants \devA{\mem_2}{\thr{z}{\inputChan{\ca{c}}{x}; ~C}}
\\ \lra{\LabIn{c,\attExpr}}
\attKnowledge; \refrights \grants \devA{\mem_2\addm{\locl{y}{v}}}{\thr{z}{C \{ y / x\}}}
} \tag{\atta{input}} \label{redatt:input}
\end{gather}
\section{Security analysis}
\label{sec:result}
We now prove that the type system preserves confidentiality of data:
when a variable is declared with rights $R$ then
the only devices that can observe anything when the variable's value changes are the devices that are \emph{allowed} to know one of the keys in $R$.
The proof uses techniques from the applied pi-calculus, rephrased for
our formalism. Our basic result uses a notion of bisimulation formulated
for reasoning about information flow in
nondeterministic programs \cite{SabelfeldSands00}.
Intuitively, two programs are bisimilar
(for ``low'' observers) if
each one can ``imitate'' the low actions of the other, and at each
step the memories are equivalent at low locations. Note that memory
can change arbitrarily at each step, reflecting the ability of
concurrent attacker threads to modify memory at any time.
The applied
pi-calculus extends the well-known pi-calculus, a process calculus
where communication channels may be sent between processes,
with binding of variables to non-channel values. In our approach,
``memory'' is this set of bindings of variables to values in the
applied pi-calculus. Also, our bisimilarity is a labelled
bisimilarity since we consider communications on channels as
observable events. Our
correctness result shows that a high (insider) attacker cannot leak
information to low observers by communication on high channels or by
modifying high locations in memory.
We explain our proof over the following five subsections. In the following subsection we annotate devices with an identifier, so that we can keep track of particular devices as a process reduces, and we define when a particular device is entitled to read data protected with a particular set of rights. In Subsection \ref{sec:attacker} we define our untyped attacker and outline an labelled, open semantics which defines how an ``honest'' (typed) process can interact with an untyped attacker process. We also prove that this open semantics is correct with respect to the semantics presented above.
To give us the machinery we need to prove our main results, in Subsection \ref{sec:annotations} we annotate our processes with the rights that apply to all variables. We show that a well annotated, well typed process reduces to a well annotated, well typed process, this results shows that a well typed system does not leak data, but it does not account for untyped attackers. To do this we introduce a labelled bisimulation in Subsection \ref{sec:bisim}. This bisimulation relation defines the attackers view of a process, and their ability to distinguish systems. Finally, in Subsection \ref{sec:results}, we prove that, for our open semantics, a well annotated, well typed process is bisimular to another process that is the same as the first, except that the value of a high level variable is changed. This means that no information can leak about the value of that variable for any possible attacker behaviour, so proving our main correctness results.
\subsection{From rights to allowed devices}
\label{sec:rightsdevices}
As a preliminary step, we need to formally define which devices are and are not granted permissions by a particular set of rights. To do this we need a way to refer to particular devices while they make reductions, so as a notational convention, we place \emph{identifiers} on devices, that are preserved through reductions.
By convention an identifier will be an index on each device, so for example $D_1 \mid D_2 \ra D'_1 \mid D'_2$
expresses that $D_i$ and $D'_i$ represent the same physical device in different states.
In Definition~\ref{def:initial-process},
Definition~\ref{def:back-rel} and Definition~\ref{def:dev-from} below, we formally define an association between the public keys in a rights set and devices, but first we motivate these definitions with an example:
\begin{example}
Consider the the system $SD_A \mid SD_B \mid MD_M \mid MD_N \mid RD_X \mid RD_Y \mid Srv_S$
where $SD,MD,RD$ and $Srv$ are defined in \autoref{fig:example-2-a}
and \autoref{fig:example-2-b} (i.e. there are two clones of each devices of the system
from \autoref{sec:example}, except for the server).
Consider the variable $\mathit{data} : \Int_{\{\publicKey{\mathit{Server}} , \mathit{client1}, \mathit{client2} \}}$
of the $\mathit{RegisterUser}$ command on Device $S$ (the server).
There are three reasons for a device to be allowed to access shared
data, depending on which reduction occurs in the system.
First, the devices that created the keys $\mathit{client1}$ and
$\mathit{client2}$ are allowed access to this data. This pair of keys is passed to the
server at the start of its loop.
Depending on which device ($A$ or $B$) made the connection to the server channel $\mathit{newUsers}$,
$\mathit{client1}$ allows either Device $A$ or Device $B$ (as $\mathit{client1}$).
Assume that it is Device $A$.
Similarly $\mathit{client2}$ represents Device $X$ or $Y$ depending on which device connected to channel $c$
during the $\mathit{Sender}$ command of Device $A$. Assume it is Device $X$.
Next, since the public key $\mathit{client1}$ has been created by the command $\newPrin{\mathit{Alice}}{\{\mathit{mobile}\}}$ in Device $A$,
the device which corresponds to the public key $\mathit{mobile}$ is also allowed to access $\mathit{data}$. We assume that it is Device $M$.
Thirdly, the public key $\publicKey{\mathit{Server}}$ has not been
generated by any device. However it was in the initial memory of
Device $S$, therefore
this device is also allowed to access the shared data by the right
granted by this key.
Our security property grants that no other device than Device $S, A, X$ and $M$ can get information about the value of $data$.
On the other hand, if an untyped attacker provides its own key to Device $A$, through channel $c$,
then no security guarantee can be provided about
$\mathit{data}$.
Indeed, such a case means that the rights explicitly allows the attacker's device to access the data
as any other regular device.
\end{example}
Before we formalise what are the allowed devices, we make reasonable assumption about the initial process.
For instance, when the process starts, we assume that devices have not already established any channel between them.
We also consider that they have an empty memory except for some public keys and principals
(and we do not allow duplicate principals).
Finally, we consider that all devices are well-typed except one (Device $0$) which is the untyped attacker.
We first define a well-formed and well-typed condition on processes:
\begin{definition}\label{def:initial-process}
A \emph{valid} initial process
$P= \nu \activechans.~ \dev{\mem_0}{C_0}_0 \mid \dev{\mem_1}{C_1}_1 \mid \ldots \mid \dev{\mem_n}{C_n}_n$
is a process where:
\begin{enumerate}
\item There is no active channel already established between the
processes: $\activechans = \{\}$.
\item The bound values in memory are either principals or public
keys: For all $0 \leq i \leq n$, $\loc{x}{w} \in \mem_i$ implies there exists $\pubof{k}$, $w = \prinv{k}{\{\}}$ or $w=\pubof{k}$.
\item Each principal exists only on one device: For all $0 \leq i , j \leq n$, $i\neq j$, $\prinv{k}{\{\}} \in \mem_i$ implies $\prinv{k}{\{\}} \notin \mem_j$.
\item The memory of every device is well-typed with contexts corresponding to its memory and $pc=\bot$:
for all $1 \leq i \leq n$, w.l.o.g. assume that
$\mem_i =
\{ \loc{p_1}{\prinv{k_1}{\{\}}},\ldots, \loc{p_m}{\prinv{k_m}{\{\}}},\loc{pk_1}\pubof{k'_1},\ldots \loc{pk_p}{\pubof{k'_p}} \}$,
we have
$\bot; \{p_1,\ldots,p_n\}; \{pk_1,\ldots,pk_p\}; \{\}; \{\} \vdash C$
for some command $C$.
\end{enumerate}
\end{definition}
Before defining the set of allowed devices, we define an auxiliary function
that maintains which devices are allowed to access shared data, and
which public keys need to be associated to devices. This auxiliary
metafunction maps backward from a set of rights $\LR$ that confers access, to all
possible devices that may have provided the keys that gave them those
rights. This is the set of allowed devices $\devicesFrom{\LR}{T}$ where $T$ is a process trace,
defined below. Any device that is not in this set is not
allowed by $\LR$; we will consider such devices as attacker
devices in our threat model.
\begin{definition}\label{def:back-rel}
Given a reduction $ P \ra P' $ where devices identifiers are in $\{0,\ldots,n\}$,
given a subset of identifiers $I \subseteq \{1,\ldots,n\}$ and
a set of public keys $\LR$,
we define the backward function $\backward{P \ra P' }(I,\LR)$ in the following way.
\begin{itemize}
\item If $P \ra P' $ is the reduction \eqref{sem:newPrin}
on a device $D_i$, $i \neq 0$ that creates a new principal $\prinv{k}{\LR'}$
and that $\pubof{k} \in \LR$
then \[\backward{P \ra P'}(I, \LR)=\left(I \cup \{ i \}, \LR' \cup \LR \setminus \{ \pubof{k} \}\right).\]
\item Otherwise $\backward{P \ra P'}(I, \LR)=\left(I, \LR \right)$.
\end{itemize}
\end{definition}
\begin{definition}\label{def:dev-from}
Let $P_0 = \dev{\mem_0}{C_0}_0 \mid \dev{\mem_1}{C_1}_1 \mid \ldots \mid \dev{\mem_n}{C_n}_n$ a valid initial process.
Let a sequence of reductions $T=P_0 \ra P_1 \ldots \ra P_n $ and let $\LR$ a set of public keys,
we consider
\[(I_0, \LR_0)= \backward{P_0 \ra P_1 }
\circ \ldots \circ \backward{P_{n-1}\ra P_n}(\emptyset, \LR).\]
Let $I' = \{i \mid \exists \pubof{k} \in \LR_0, i \in \{1,\ldots,n\}, \prinv{k}{\{\}} \in \mem_i \}$.
We define the set of allowed devices identifiers $\devicesFrom{\LR}{T}$
as $\devicesFrom{\LR}{T} = I_0 \cup I'$.
Consider the set $\{\pubof{k} \mid \pubof{k}\in \LR_0 \wedge \nexists i \in I', \prinv{k}{\{\}} \in \mem_i \}$.
We say that $\devicesFrom{\LR}{T}$ is \emph{safe} if this set is empty.
\end{definition}
In other words, $\devicesFrom{\LR}{T}$ is safe
when all keys involved by $\LR$
have been either created by devices of $\devicesFrom{\LR}{T}$
or owned by them at the beginning.
This implies, since valid initial processes don't have duplicated keys,
that the untyped attacker whose index cannot be in $\devicesFrom{\LR}{T}$
have not generated any of these keys.
\subsection{Definition of the attacker and of the open process semantics}
\label{sec:attacker}
An attacker is a device $A=\dev{\mem}{C}$ where $\mem$ is a standard memory
and $C$ is a command which is not typed and which contains
additional expressions to do realistic operations that an attacker can perform
like extracting $\secof{k}$, $\pubof{k}$ and $\LR$ from $\prinv{k}{\LR}$,
decrypting a ciphertext with only a secret key, or releasing a principal with
arbitrary rights ($\enc{\prinv{k}{\LR'}}{n}{\LR}$ with $\LR \neq \LR'$)
However, the attacker is not able to create principals with a public key that does not correspond to the private key
because we assume that the validity of any pairs is checked when received by an honest device.
We denote such an extended expression using $\attExpr$.
To reason about any attacker, we introduce open processes in a similar way as in the applied pi-calculus \cite{AbadiFournet2001}.
An open process has the syntax $\attKnowledge \models \nu\activechans.~ D_{1} \mid \ldots \mid D_{n}$
where $D_1,\ldots,D_n$ are well-typed devices
(the indexes $1,\ldots n$ are the tags of the devices: we do not change them through reductions),
where $\activechans$ are the channels which have been established between devices $D_1,\ldots,D_n$ (not with the attacker)
and where $\attKnowledge$ is a memory representing the values that the
attacker already received.
We refer to $D_1,\ldots,D_n$ as the \emph{honest devices}.
We also refer to $\attKnowledge$ as the \emph{attacker knowledge}.
This plays the same role as frames in the applied pi-calculus, and
also plays a similar role as computer memory in the bisimulation that
we use for reasoning about noninterference for nondeterministic
programs.
We denote $\attKnowledge(\attExpr)$ the evaluation of
$\attExpr$ with the memory $\attKnowledge$
(to be defined the variables of $\attExpr$ should exists in $\attKnowledge$).
Our type system ensures that an attacker is never able to learn any of
the secret keys belonging to ``honest'' devices, as represented by the
notion of reference rights defined below. The following predicate
overapproximates what an attacker can learn about a value, based
on the ``knowledge'' represented by its memory $\attKnowledge$
and on the assumption that it knows all keys which are not in
$\LR$ (which aims at being the reference rights).
\begin{definition}\label{def:super-attacker}
Given a set of keys $\LR$ and a value $v$, we define the predicate
$\attKnowledge \getPower_{\LR} v$ as
there exists an extended expression $\attExpr$ such that
$\attKnowledge(\attExpr)=v$, where
this extended expression contains all standard functions and attacker functions,
as well as an oracle function which provides the secret key of any public key which is not in $\LR$.
\end{definition}
Open processes have two forms of reductions: \emph{internal reductions}, which are the same as the reductions for closed processes, and
\emph{labeled reductions} which are reductions involving the attacker.
Labels on these latter reductions represent
the knowledge that an attacker can use to distinguish between two
traces, effectively the ``low'' information that is leaked from the system.
There are two forms of labelled reductions, both of which take the form $P \lra{l} P'$. In the first form,
\emph{input reductions} $P\lra{\LabIn{\ca{c},\attExpr}} P'$, the attacker provides data, and in the second form, \emph{output reductions} $P\lra{\LabOut{\ca{c},x}} P'$, the attacker receives data from an honest device.
There are also two further forms of input reductions: those for establishing
channels and those which send data.
The reduction that establishes a secure channel takes the form:
\[\!\!
\begin{array}{c}
\attKnowledge\! \grants \!\!\nu \activechans. D ~|~ \!\! \deva{i}{\mem\!}{\!\acceptCCert{c}{\Chan(S_{R_1})_{R_2}\!\!}{k}{P}; C}
\\ \lra{\LabIn{\ca{c},(\chanType{S_{R_1}}{R_2},\attExpr,\attExpr')}}
\\ \attKnowledge \grants \nu \activechans. D ~|~ \deva{i}{\mem}{C \{\ca{c}/c\}}
\end{array}\!\!
\]
where $\ca{c}$ is any attacker channel name,
$\attKnowledge(\attExpr)$ should be the private key corresponding to $\mem(k)$
and $\attKnowledge(\attExpr')$ should be the public key of $\mem(p)$.
The reduction to establish a public channel is similar but simpler.
There is no need for checks on $\attExpr$ or $\attExpr'$.
Note that, unlike standard connection establishment where a fresh channel name is
added to $\nu \activechans$, here the name of the established channel is provided by the attacker
and is not added in $\activechans$, which is out of the scope of the attacker.
However the attacker has to provide channel names in a separate subdomain
which prevents it from using an existing honest channel name.
The names which are the attacker's channel names are written $\ca{c}$.
To summarize, a channel name of form $\ca{c}$ represents a channel which is established between a device and the attacker,
a channel $c \in \activechans$ is a channel between two devices (not accessible from the attacker)
and a channel name $c \notin \activechans$ and not in the attacker's channel domain
is just a program variable representing a future channel.
Finally, we consider an implicit injection $c \mapsto \ca{c}$ from $\activechans$ to attacker's channels.
For input reductions that sends data on an established attacker channel,
$\attExpr$ is an expression of the extended syntax
admitting lower level operations that are available to attackers but
not to honest devices, as explained above.
There is just one rule for output reduction, saying that an attacker
can learn from a value output on an attacker channel:
\[
\inferrule{
\fresh(x) \\
\evaluates{\mem_1}{e}{v}
}{
\attKnowledge \grants \nu \activechans. D ~|~ \deva{i}{\mem_1}{C' ~|~ \outputChan{e}{\ca{c}}; C }
\\ \lra{\LabOut{\ca{c},x}}
\attKnowledgeAdd{(\loc{x}{v})} \grants \nu \activechans. D ~|~ \deva{i}{\mem_1}{C' ~|~ C}
}
\]
\begin{example}\label{example:secure1}
We consider the system consisting of $\mathit{MD} \mid \mathit{SD}$ from \autoref{fig:example-2-b}
running in parallel with an untyped attacker $A$.
The corresponding open process is initially $\{\} \grants \mathit{SD}_A \mid \mathit{MD}_{M} $.
Assume that Device $M$ ($\mathit{MD}_M$) reduces with the attacker instead of $\mathit{SD}_A$, we have:
\[\begin{array}{ll}
\ra & \{\} \grants \mathit{SD}_{A} \mid \mathit{MD}'_{M} \\
\lra{\LabIn{\ca{c}, ct}} & \{\} \grants \mathit{SD}_{A} \mid \mathit{MD}''_{M} \\
\lra{\LabOut{\ca{c},x}} & (\loc{x}{k^+}) \grants \mathit{SD}_{A} \mid \mathit{MD}'''_{M}
\end{array}
\]
where $ct = \chanTypePub{\pubKeyType_{\bot}}$ and Device $M$ has memory $\loc{\mathit{Mobile}'}{\prinv{k}{\{\}}}$
(a renaming of the local variable $\mathit{Mobile}$ on the device),
after the first internal reduction where the principal is created.
After the first reduction where $\mathit{MD}_M$ creates its principal,
the attacker establish the connection with Device $M$:
as $M$ is expecting a connection of type $ct$,
the attacker have to provide $ct$ and one of its channel name $\ca{c}$.
Next, Device $M$ outputs the value of $\pub(Mobile)$ on $\ca{c}$ which is then stored on the attacker's memory.
\end{example}
The following defines a subprocess of the ``honest'' devices of
a system $P$, where some (other) devices of that system may be attacker devices.
This subprocess of honest devices will be those defined by
$\devicesFrom{\LR}{T}$. In other words, all devices
which are not allowed by some key in $\LR$ are assumed to be controlled by the attacker.
\begin{definition}
Given a process $P=\nu \activechans.~ D_{1}~|~ \dots ~|~ D_{n} $
and $\{\ident_1,\dots,\ident_m \} \subseteq \{1,\dots,n\}$,
let $\activechans'$ the names of channels between devices of $\{\ident_1,\dots,\ident_m \}$
we define the subprocess of devices
$\subp{P}{\{\ident_1,\dots,\ident_m\}} = \nu \activechans'. D'_{\ident_1}~|~ \dots ~|~ D'_{\ident_m}$
where $D'_i$ is $D_i$ where each channel name $c \in \activechans \setminus \activechans'$
have been replaced by an attacker-channel name $\ca{c}$.
\end{definition}
In the following, we will denote by $P\Lra{l_1,\ldots,l_n} P'$ a
sequence of reductions $P \ra^* P_1 \lra{l_1} P'_1 \ra^* P_2 \ldots P_n \lra{l_n} P'_n \ra^* P'$.
We also denote by $P\lra{l^?} P'$ a reduction which is either $P \ra P'$ or $P \lra{l'} P'$ for some label $l'$
and by $P\lra{l^?}\!^? P'$ either $P\lra{l^?} P'$ or $P=P'$.
The following proposition states that if there is an execution
of a system that includes communication with attacker devices, where
all communication is local in this closed system, then we can consider
subsystem of this, omitting the attacker devices,
where communications with attacker devices are
modelled by labelled reductions of the form described above. So the
attacker devices become part of the context that the devices in the
subsystem interact with through a labelled transition system. Such a
subsystem may also exclude some of the ``honest'' devices in the
original system, and in that case we treat those excluded devices as
attacker devices in the context (since labels on the reductions only
model communication with attackers).
\begin{restatable}{proposition}{subprocess}\label{prop:identifiers}
Let $P=\nu \activechans. A \mid D_{1} \mid \ldots \mid D_{n}$ where all $D_{i}$ are well-typed and $A$ is an untyped device.
If $ P \ra\!^* \nu \activechans'. P'$,
then for all subset $S$ of $\{1, \dots, n\}$,
there exist $l_1,\ldots,l_m$ and $\attKnowledge'$ (the attacker
knowledge at the end of the execution) such that
\[\attKnowledge \grants \subp{P}{S}
\Lra{l_1,\ldots,l_m}
\attKnowledge' \grants \subp{P'}{S}\]
where $\attKnowledge$ is
a memory which is the union of the memories of $A$ and all $D_i$ with $i \notin S$
(variable names are renamed whenever there is a name conflict).
\end{restatable}
For instance, the system $SD_A \mid \mathit{MS}_M \mid \mathit{SD}_0$,
where $\mathit{SD}_0$ is part of the attacker,
can perform three internal reductions between $\mathit{MS}_M$ and $\mathit{SD}_0$
where $\mathit{MS}_M$ sends its public key to $\mathit{SD}_0$.
In \autoref{example:secure1}, we provided the three reductions of the system
$\subp{(\{\}\grants \mathit{SD}_A \mid \mathit{MS}_M \mid \mathit{SD}_0)}{\{A,M\}}$.
\subsection{Extended syntax with extra annotations}
\label{sec:annotations}
In this section, we add extra annotations to processes to perform a specific analysis about a given right $\LR=\{pk_1,\ldots,pk_n\}$.
Since the keys in $\LR$ do not necessary exist in the initial process,
we first annotate open processes with a \emph{reference right} $\refrights$
with the intention that this right will eventually grow to
the right $\LR$ as keys are generated and added to this right during execution.
Given a reference right $\refrights$,
we define any rights whose all keys are in $\refrights$ to be \emph{\highr} (by opposition to \emph{\lowr}).
The set $\refrights$ starts with keys that exists in the initial
process.
An \emph{annotated process} has the syntax
\[\attKnowledge; \refrights \models P\]
for attacker knowledge $\attKnowledge$, reference right $\refrights$
and process $P$. The exact form of the annotations is
explained below.
The reference right $\refrights$ only changes during a reduction of a command $\newPrin{p}{RS}$.
In this case, there is a choice of whether or not to include the
generated public key in $\refrights$.
\begin{definition}
A sequence of reductions is called \emph{\standard} if
each time a \eqref{sem:newPrin} reduction adds a key to $\refrights$:
\begin{multline*} \attKnowledge; \refrights \models \nu \activechans. \dev{\mem}{\newPrin{p}{RS}; C} \mid P \\ \ra
\attKnowledge; \refrights \cup \{ \pubof{k}\} \models \nu \activechans.
\dev{\mem \cup{
\loc{p}{\prinv{k}{\LR}}}}{ C} \mid P \!\!\! \end{multline*}
we have $\LR \subseteq \refrights$.
\end{definition}
The next proposition ensures the existence of a \standard annotation such that
the rights we want to consider at the end are \highr and that the attacker does know any key
in the set $\refrights$ of the initial process.
We will state in \autoref{lemma:subred} that this implies that the attacker never knows the keys in
$\refrights$ during the whole reduction.
\begin{restatable}{proposition}{safeStandard}\label{prop:safe->standard}
Let $P$ be a valid initial process such that $P \ra{\!^*} P'$ and let $\LR$ a set of keys defined in $P'$.
If $D_H=\devicesFrom{\LR}{P \ra{\!^*} P'}$ is safe
then there exists a \standard annotation for the reduction
provided by \autoref{prop:identifiers}:
$\attKnowledge_0; \refrights_0 \grants \subp{P}{D_H} \Lra{l_1,\ldots,l_n} \attKnowledge; \refrights \grants \subp{P'}{D_H}$
where $\refrights_0$ and $\refrights$ are
such that $\forall \pubof{k} \in \refrights_0,~ \attKnowledge_0 \ngetPower_{\refrights_0} \secof{k}$
and $\LR \subseteq \refrights$.
\end{restatable}
When a variable or a channel is created with some rights, the
reduction rules of the operational semantics
remove all information about those rights. Therefore we add annotations to devices
to remember if the defined right was \highr or \lowr, according to
$\refrights$. Recall that a right is \highr if it
contains a key in the reference right $\refrights$.
We use $\ell$ as a metavariable for an annotation $\high$ or $\low$.
\begin{enumerate}
\item A memory location $\loc{x}{v} \in \mem$ which is created by a command $\new{x}{S_R}{e};C $,
where $R$ evaluates in $\mem$ to a \highr right according to $\refrights$, is annotated as a \highr location: $\loch{x}{v}$.
Otherwise $x$ is annotated as a \lowr location: $\locl{x}{v}$. By convention $\attKnowledge$ contains only \lowr locations.
\item
A new channel name $c$, which is created by a command that establishes a channel $c : \Chan(S_{R_1})_{R_2}$,
is annotated as ${c}^{\ell_1}_{\ell_2}$ where $\ell_1$ resp. $\ell_2$ is $\high$ if the evaluation of $R_1$
(resp. $R_2$) is $\highr$, and is annotated as $\low$ otherwise.
\item A value which is the result of an expression (besides an
encryption expression) where one variable refers to a \highr{} location
is annotated as a \highv value $\tagged{v}$. Otherwise, it is annotated as a \lowv{} value $\untagged{v}$.
When a value $\tagx{v}{\ell}$ is encrypted, it becomes $\untagged{\enc{\tagx{v}{\ell}}{n}{RS}}$
i.e., the initial tag is associated to the subterm.
\item A device $\dev{\mem}{C_1 ~|~ \dots ~|~ C_n}$
is annotated as $\dev{\mem}{\thr{\ell_1}{C_1} ~|~ \dots ~|~ \thr{\ell_n}{C_n}}_i$.
There is one tag $\ell_i \in \{\low,\high\}$ for each sub-command $C_i$ which can be reduced.
The annotation of each {thread} $\thr{\ell_i}{C_i}$ records whether
the existence of this thread was due to a \highv value or a \highr right.
When $\ell_i=\high$, we say that the thread is \emph{\hight}, otherwise the thread is \emph{\lowt}.
For instance, the annotated device $\dev{\loch{a}{\tagged{1}}}{\thr{\low}{\IF\ (a = 0) \THEN C_1 \ELSE C_2}}_1$
reduces to $\dev{\loch{a}{1}}{\thr{\high}{C_2}}_1$ because $a$ is a \highr location.
The other case where a thread can be set to \hight is in the
establishment of a secure channel that is annotated with $\chanhh{c}$.
\end{enumerate}
These annotations allow us to define technical invariants that are preserved during reduction.
In the following technical definition, we formalize the idea that
there exist a typing judgment for devices (Case~\eqref{safe:well-type}
below) which is consistent with
the annotations:
\begin{enumerate}
\item
Variables (Case~\eqref{safe:variables}) and channels (Case~\eqref{safe:channel})
should have a type which corresponds to their annotation
\item The type system tracks a notion of security level for the
control flow, and this level $pc$ must be consistent with the
thread annotation (Case~\eqref{safe:pc}).
\item
In addition, we express that the devices are not in a corrupted
configuration, in the sense that
secure channels are not being used to communicate with the attacker
(Case~\eqref{safe:no-high-attacker-chan}), nor are they used
in a \lowt thread (Case~\eqref{safe:low-pc-low-chan}).
\item
Finally, ciphers for values (Case~\eqref{safe:cipher-variable}) and principals (Case~\eqref{safe:released-prin})
should not have \highv contents protected by \lowr keys.
\end{enumerate}
\begin{definition}\label{def:safe}
A tuple consisting of a reference right $\refrights$,
a memory $\mem$ and a thread $\thr{\ell}{C}$ is \emph{\wa}
written ``\emph{$\safe{\refrights}{\ell}{\mem}{C}$}'' if
there exists $pc$, $\GammaPrin$, $\GammaKey$, $\GammaChan$ and $\ctx$ such that
\begin{enumerate}
\item \label{safe:well-type} $pc;\GammaPrin;\GammaKey;\GammaChan;\ctx \vdash C$
\item \label{safe:variables} For all locations $x$ in $\mem$, we have
\begin{itemize}
\item either $\locl{x}{\untagged{v}}$ in $\mem$ for some value $v$ and $x \in \GammaPrin \cup \GammaKey$
\item or $\GammaPrin;\GammaKey;\ctx \vdash x : S_R$ and
\begin{itemize}
\item if $\refrights \lc \mem(R)$, $\loch{x}{\tagged{v}}$ in $\mem$,
\item if $\refrights \nlc \mem(R)$, $\locl{x}{\untagged{v}}$ in $\mem$ for some value $v$.
\end{itemize}
\end{itemize}
\item \label{safe:channel} For all channels $c$ in the thread such that $\GammaChan \vdash c : \Chan({S}_{R_1})_{R_2}$,
the annotation of $c$ is $c^{\ell_2}_{(\ell_1)}$
where $\ell_2=\high$ iff. $\refrights \lc R_2$, $\ell_1=\high$ iff. $\refrights \lc \mem(R_1)$.
\item \label{safe:pc} $\refrights \lc pc$ if and only if $\ell=\high$.
\item \label{safe:no-high-attacker-chan} For all $\ca{c}$,
we have $\GammaChan \vdash \ca{c} : \Chan({S}_{R_1})_{R_2}$
with $\refrights \nlc \mem(R_2)$ and $\refrights \nlc \mem(R_1)$.
\item \label{safe:low-pc-low-chan}if $\ell$ is $\low$, then there is no $\chanhh{c}$ in $C$.
\item \label{safe:cipher-variable} For all values $v$ stored in memory, if a sub-term of $v$ matches $\enc{\tagged{t}}{n}{\LR}$
then $\refrights \lc \LR$.
\item \label{safe:released-prin} For all values $v$ in memory, if a sub-term of $v$ matches $\enc{\prin{k}{\LR}}{n}{\LR'}$
then $\LR = \LR'$ or $\refrights \lc \LR$.
\end{enumerate}
When, for a device $D=\dev{\mem}{\thr{\ell_1}{C_1}~|~ \dots ~|~ \thr{\ell_n}{C_n}}_i$ and a set $\refrights$,
we have $\safe{\refrights}{\ell_i}{\mem}{C_i}$ for $i\in\{1,\dots,n\}$,
then we use the notation $\safeDev{\refrights}{D}$.
\end{definition}
Finally, we get the following subject-reduction result:
\begin{restatable}{proposition}{subjectreduction}\label{lemma:subred}
Let $\attKnowledge; \refrights \grants \nu \activechans. D_1 \mid \ldots \mid D_n$ an open process
such that for all $\pubof{k} \in \refrights$ we have $\attKnowledge \ngetPower_\refrights \secof{k}$
and for all $1 \leq i \leq n$ we have $\safeDev{\refrights}{D_i}$.
If
$\attKnowledge; \refrights \grants \nu \activechans . D_1 \mid \ldots \mid D_n
\lra{l^?}
\attKnowledge'; {\refrights}' \grants \nu \activechans' . D'_1 \mid \ldots \mid D'_n $
then
for all $1 \leq i \leq n$ we have $\safeDev{\refrights}{D'_i}$.
Moreover if the reduction is \standard,
we have $\attKnowledge' \ngetPower_{\refrights'} \secof{k}$ for all
$\pubof{k} \in \refrights'$.
\end{restatable}
Finally, valid initial processes which only require each device to be well-typed are \wa.
\begin{restatable}{proposition}{initialprocess}\label{prop:init-well-annotated}
Given a valid initial process $P = \Big(\attKnowledge \grants \deva{1}{\mem_1}{C_1} | \ldots | \deva{n}{\mem_n}{C_n} \Big)$,
We have $\safe{\refrights}{\low}{\mem_i}{C_i}$ for $1\leq i\leq n$ for any $\refrights$.
\end{restatable}
\subsection{Labelled bisimilarity}
\label{sec:bisim}
The invariants expressed above are about a single process.
To ensure that the attacker cannot track implicit flows,
we need to compare the execution of two processes in parallel.
In this section, we define a relation between processes which implies
an adapted version of the bisimilarity property of the applied pi-calculus~\cite{AbadiFournet2001}.
The two processes that we compare are the actual process and another one
where the value of one of the \highv variables of the memory of some device has been changed to another one.
So first, we define what is a process where a variable is modified arbitrarily.
\begin{definition}
Given a device $D=\dev{\mem \addm{\{\loc{x}{v'}\}}}{C}$, and a value $v$,
we define $D_{x=v}$ to be the device that updates the variable $x$ to
be $v$ by assignment, $\dev{\mem
\addm{\{\loc{x}{v'}\}}}{\paral{C}{\assign{x}{v};}}$.
Extending this from devices to processes, given a process $P$ which contains $D$ with index $i$,
we define $P_{i:x=v}$ to be the same process
except that $D$ has been replaced by $D_{x=v}$.
\end{definition}
In contrast to systems where the attacker can only observe public
values in memory after reduction,
here we model that the attacker can observe communications on channels
that have been established with other devices.
In the following examples, we stress how an attacker can distinguish between two processes even without
knowing actual confidential values in the memory of those devices.
\begin{example}
We consider the device $D(X,Y)$, where the description is parametrized
by two meta-variables: $X$ is a value stored in memory and $Y$ is a
value that is encrypted and sent on an attacker channel. The
device has a memory $\mem(X) = \{\loc{x}{X} , \loc{k}{\pubof{k_0}}\}$,
and the full description of the device is
\[
\devA{\mem(X)}{ \IF \ x = 0 \THEN \outputChan{\encE{Y}{k}}{\ca{c}}}.
\]
The process $D(0,Y)$ can be distinguished from
the process $D(1,Y)$.
In the first case, we have:
\begin{eqnarray*}
\lefteqn{ \{\} \grants D(0,Y) \lra{\LabOut{\ca{c},m}} } \\
& &
\{\loc{m}{\encE{Y}{k}}\} \grants \devA{\mem(X)}{\SKIP}
\end{eqnarray*}
On the other hand, there is no reduction with only the label
$\LabOut{\ca{c},m}$ and internal reductions
starting from $\{\} \grants D(1,Y)$.
This distinction models the fact that if the attacker receives data on
$\ca{c}$, it learns that $X=0$.
The processes
$D(0,2)$ and $D(0,3)$ can also be distinguished
even if both
$\{ \loc{k}{\secof{k_0}} \} \grants D(0,2)$ and $\{ \loc{k}{\secof{k_0}} \} \grants D(0,3)$
can reduce with a label $\LabOut{\ca{c},m}$.
Indeed, after reduction the attacker's knowledge is $\attKnowledge = \{\loc{k}{\secof{k_0}},\loc{m}{\enc{Y}{n}{\pubof{k_0}}}\}$
where $Y$ is $2$ (resp. $3$):
By performing the decryption of $m$ with an untyped decryption, the
attacker can compare the result to $2$, and
$\attKnowledge(\mathrm{decr}_k(m))=2$ is only true in the first case.
Finally, the processes $\{\} \grants D(0,2)$ and $\{\} \grants D(0,3)$ are not distinguishable.
In both cases:
\begin{itemize}
\item there is no test to distinguish between the two attacker's
knowledge, and
\item the labelled reductions are the same i.e $\LabOut{\ca{c},m}$
\end{itemize}
\end{example}
With these examples in mind,
we introduce static equivalence, an adaptation of the one used in the applied pi-calculus, which
expresses that it is not possible to test some equality which would work with one memory but not with the other.
\begin{definition}
We say that two memories $\mem_1$ and $\mem_2$ are statically equivalent ($\approx_s$) if
they have exactly the same variable names and for all
extended expressions $\attExpr$ where its variables $x_1,\ldots,x_n \in
\mem_1$, we have $\mem_1(\attExpr)=\mem_2(\attExpr)$.
\end{definition}
Finally, we define an adaptation of the labelled bisimilarity.
This recursive definition generalizes the conclusion of the example:
the two memories should be statically equivalent,
and a transition in one process can be mimicked in the other process,
where the reduced processes should also be bisimilar.
\begin{definition}
Labeled bisimilarity ($\approx_l$) is the largest symmetric relation $\mathcal{R}$
on open processes such that $(\attKnowledge^A \grants P^A) \labrel (\attKnowledge^B \grants P^B)$ implies:
\begin{enumerate}
\item $\attKnowledge^A \approx_s \attKnowledge^B$;
\item if $(\attKnowledge^A \grants P^A) \ra ({\attKnowledge^A}' \grants {P^A}')$,
then $(\attKnowledge^B \grants P^B) \ra^{\!*} ({\attKnowledge^B}' \grants {P^B}')$
and $({\attKnowledge^A}' \grants {P^A}')\labrel({\attKnowledge^B}' \grants {P^B}')$ for some ${\attKnowledge^B}' \grants {P^B}'$;
\item if $(\attKnowledge^A \grants P^A) \lra{l} ({\attKnowledge^A}' \grants {P^A}')$,
then $(\attKnowledge^B \grants ({\attKnowledge^B} \grants {P^B}) \Lra{l}
({\attKnowledge^B}' \grants {P^B}')$ and $({\attKnowledge^A}' \grants {P^A}')\labrel({\attKnowledge^B}' \grants {P^B}')$
for some ${\attKnowledge^B}' \grants {P^B}'$.
\end{enumerate}
\end{definition}
The labelled bisimilarity is a strong equivalence property, and its
we use it to state the security property that an attacker is unable to distinguish
between two processes in the same class \cite{Arapinis2014}.
However this definition does not help to actually compute the processes in the same class.
Therefore we define a stronger relation
that can be defined from our annotated semantics.
First, we define an obfuscation function $\erase{\LR}{w}$
which takes a set of public key $\LR$
and a value or a principal $w$
and returns an
obfuscated value (its syntax is like the syntax of value except that there is an additional option $\erasedValue$
and that a principal value is also an option).
\begin{definition}\label{def:erase}
Let $\LR$ a set of public key, $w$ a principal $p$ or a value $v$.
We define $\erase{\LR}{w}$ depending on the structure of $w$.\\
{\small
\[\!\!\begin{array}{lcl}
\erase{\LR}{\enc{w'}{n}{\LR'}}\!\!&\!\!\!=\!\!\! & \!\!\! \begin{cases}
\enc{\erase{\LR}{w'}}{n}{\LR'} \text{ if }\LR \nlc \LR' \\
\enc{\erasedValue}{n}{\LR'} \text{ if } \LR \lc \LR'
\end{cases}\\[4mm]
\erase{\LR}{\{v_1,\ldots,v_n\}}\!\!&\!\!\!=\! \!\!& \!\!\! \{ \erase{\LR}{v_1},\ldots, \erase{\LR}{v_n} \}\\[1mm]
\text{otherwise }\erase{\LR}{w}\!\!&\!\!\!=\!\!\! & \!\!\! w.
\end{array}\!\!\!\!\!\!\!\!\!
\]}
where $w'$ is a value or a principal and $n$ a nonce.
\end{definition}
The set $\LR$ aims at containing a set of keys whose private keys will never be known by the attacker.
In our previous example, we have $\erase{\pubof{k_0}}{\enc{Y}{n}{\pubof{k_0}}}=\enc{\erasedValue}{n}{\pubof{k_0}}$:
if $\secof{k_0}$ is never known by the attacker, the attacker will never be able to know anything about $Y$.
Note that the random seed $n$ used for the cipher is not hidden.
Indeed, the attacker is able to distinguish between a cipher that is sent twice
and two values which are encrypted then sent:
in the first case the two message are strictly identical.
We now define an equivalence on memories:
given a reference right $\refrights$, a set of safe keys, then we say
that two memories are equivalent
if they differ only by the \highv values which aims at never been sent to the attacker
and by the obfuscated terms of the \lowv values.
\begin{definition}[equivalent memories]\label{def:eqmem}
\emph{Equivalent memory} is a relation on memories such that $\mem_1
\memrel{\refrights} \mem_2$
if
for each \lowr location $\locl{x}{v^A}$ in $\mem_1$ (resp. $\mem_2$),
there exists $\locl{x}{v^B}$ in $\mem_2$ (resp. $\mem_1$) such that
$\erase{\refrights}{v^A}=\erase{\refrights}{v^B}$ and each location $\loc{p}{\pvalue}$ in $\mem_1$ (resp. $\mem_2$)
exists in $\mem_2$ (resp. $\mem_1$).
\end{definition}
Next, we define an equivalence relation between two \wa processes:
two processes are equivalent if they have the same commands up to some additional \hight threads
and have equivalent memories:
\begin{definition}\label{def:final-relation}
Two annotated processes $P^A$ and $P^B$ are \emph{annotated-equivalent} ($P^A \labrel P^B$)
when there exists an alpha-renaming (capture-avoiding renaming of bound variables) of $P^B$ such that
\begin{multline*}
P^A\ \mathrm{is}\ \attKnowledge^A; {\refrights} \grants \nu \activechans. \deva{1}{\mem^A_1}{\paral{C^A_{(1,1)}}{\paral{\dots}{C^A_{(1,m_1)}}}} |
\\
\dots | \deva{n}{\mem^A_n}{\paral{C^A_{(n,1)}}{\paral{\dots}{C^A_{(n,m_n)}}}},
\end{multline*}
\vspace{-2em}
\begin{multline*}P^B\ \mathrm{is}\ \attKnowledge^B;{\refrights} \grants \nu \activechans'. \deva{1}{\mem^B_1}{\paral{C^B_{(1,1)}}{\paral{\dots}{C^B_{(1,m_1)}}}} |
\\
\dots | \deva{n}{\mem^B_n}{\paral{C^B_{(n,1)}}{\paral{\dots}{C^B_{(n,m_n)}}}},
\end{multline*}
and we have $\attKnowledge^A \memrel{\refrights} \attKnowledge^B$,
for all $\pubof{k} \in \refrights$, we have $\attKnowledge^A \ngetPower_\refrights \secof{k}$
and furthermore for all $(i,j)$,
first
$\mem^A_i \memrel{\refrights} \mem^B_i$,
next,
the annotation on each thread $C^X_{(i,j)}$ (where $X$ stands for $A$ or $B$)
is either $\high$ or $\low$ such that either:
\begin{itemize}
\item $\safe{\refrights}{\high}{\mem^X_i}{C^X_{(i,j)}}$
\item $\safe{\refrights}{\low}{\mem^X_i}{C^X_{(i,j)}}$ and
$C^A_{(i,j)} = C^B_{(i,j)}$ (the commands are syntactically
identical up to renaming of bound variables).
\end{itemize}
\end{definition}
Finally, we prove that this relation actually implies bisimilarity.
\begin{restatable}{proposition}{implylabelled}\label{prop:=>labelled}
Let $P^A$ be $(\attKnowledge^A; \refrights \grants \nu \activechans. Q^A)$
and $P^B$ be $(\attKnowledge^B; \refrights \grants \nu
\activechans'. Q^B)$, where both are \wa processes such that $P^A \labrel P^B$,
Furthermore assume that for all $ \pubof{k} \in \refrights$
we have $\attKnowledge^A \ngetPower_\refrights \secof{k}$.
Then the processes are annotated equivalent, $P^A \approx_l P^B$ (with the annotations removed).
\end{restatable}
\subsection{Main theorems}
\label{sec:results}
Our first security property grants confidentiality for each created variable in the following way.
When a variable $x$ is created with a protection $R$, this implicitly defines a set of devices which are allowed
to access $x$.
If the untyped attacker is not in this set,
then any collaboration of the attacker with the denied-access devices can not
learn any information about the value stored by the variable:
they cannot detect an arbitrary modification of the variable.
\begin{restatable}{theorem}{thmA}\label{prop:att-never-sees-external-change}
Let $P= A ~|~ D_1 ~|~ \ldots ~|~ D_n $ be a valid initial process.
We consider a reduction $P \ra\!^* P'$ with
$P'=\nu \activechans. A' ~|~ D'_1 ~|~ \ldots ~|~ D'_n$ such that for some $1 \leq i \leq n$,
$D'_i$ is $\dev{\mem}{\paral{\newvar{x}{S_R}{E};C}{C'}}$.
Let $\LR=\mem(R)$ be the set of keys corresponding to $R$,
let $D_H = \devicesFrom{\LR}{P\ra P'}$
and let $\attKnowledge$ be the unions of memories of the devices of $P'$ whose indexes are not in $D_H$ and of device $A'$.
If $D_H$ is safe (as stated in \autoref{def:dev-from}),
then $(\attKnowledge \grants \subp{P'}{D_H})\approx_l (\attKnowledge \grants \subp{P'_{i:x=v}}{D_H})$.
\end{restatable}
\begin{proof}
According to \autoref{prop:identifiers}, we have
$\attKnowledge_0 \grants \subp{P}{D_{H}} \Lra{l_1,\ldots,l_{n}}^* \attKnowledge' \grants \subp{P'}{D_{H}}$
where $\attKnowledge_0 = \bigcup_{i \notin D_H}{\mem_i}$.
As $P$ is a valid initial process,
we get that $\subp{P}{D_{H}}$ is also a valid initial process
(the verification of all conditions to be a valid initial process is immediate).
Since $D_H$ is safe, we consider $\refrights_0$, $\refrights$
and the \standard annotated semantics
from \autoref{prop:safe->standard}:
\[\attKnowledge_0; \refrights_0 \grants \subp{P}{D_{H}} \Lra{l_1,\ldots,l_{n}}
\attKnowledge; \refrights \grants \subp{P'}{D_H}\]
where $\LR \subseteq \refrights$ and
\begin{equation}\label{eq:1}
\forall \pubof{k} \in \refrights_0,~ \attKnowledge_0 \ngetPower_{\refrights_0} \secof{k}.
\end{equation}
From \autoref{prop:init-well-annotated}, the annotation of the initial process is \wa.
From \autoref{lemma:subred} on this annotation, we get for all $i \in D_H$:
$\safeDev{\refrights}{D_i}$
and, due to \eqref{eq:1}, for all $\pubof{k} \in \refrights$ we have $\attKnowledge \ngetPower_\refrights \secof{k}$.
Since $\LR \subseteq \refrights$, and given the \eqref{type:assign} rule, we also have
\[\safe{\refrights}{\high}{\mem \addm{\{\loch{x}{v'}}\}}{\assign{x}{v}}.\]
Therefore, we satisfy all conditions of \autoref{def:final-relation}:
\[(\attKnowledge; \refrights \models P') \labrel (\attKnowledge ; \refrights \models P'_{i:x=v}).\]
Finally, we conclude with \autoref{prop:=>labelled}.
\end{proof}
\begin{example}
From the example of \autoref{sec:example},
let consider the variable
\linebreak
$\mathit{sharedSecret} : \Int_{\{\mathit{serverKey}, \mathit{Alice}, \mathit{Bob}\}}$
of the device $SD$.
The \autoref{prop:att-never-sees-external-change} states that only devices
from $\devicesFrom{\{\mathit{serverKey}, \mathit{Alice}, \mathit{Bob}\}}{\mathit{System} \ra \mathit{System'}}$
can distinguish between $\mathit{sharedSecret}=42$ or $\mathit{sharedSecret}=43$.
Whatever are the reductions, these devices contains for sure
$Srv$ since its key is known from the beginning and $\mathit{SD}$ since it creates $\mathit{Alice}$.
The only threat is that the channel $\mathit{otherPrin}$ has not been established with $\mathit{MD}$
or that $c$ has not been established with the device $\mathit{RD}$ of Bob.
These threats could be removed by an additional authentication protocol
or the use of a private channel (for instance if the connection between $\mathit{SD}$ and $\mathit{MD}$ is a direct wired connection).
This means that not knowing which code is run on $\mathit{Srv}$ and $\mathit{RD}$ is not a threat
as long as $\mathit{Srv}$ and $\mathit{RD}$ guarantee that their codes are well-typed.
\end{example}
Finally, we state a standard security property in the simpler case where there is no untyped attacker.
Given a process $P$, if, at some point, we change the value that a
variable is bound to in memory, where that variable has been typed
with right $R$,
then new reductions will not alter values in memory locations that
have been typed strictly less confidential than $R$ (i.e., those
variables have rights that contain public keys not contained in
$R$)
\begin{restatable}{theorem}{thmB}\label{thm:taint-marking}
Let $P$ be a valid initial process.
We consider a reduction $P \ra P'$ with
$P'=D'_1 | \dots | D'_n$ such that for some $i$,
$D'_i$ is $\dev{\mem}{\paral{\newvar{x}{S_R}{E};C}{C'}}$.
Let $v$ be any value of type $S$.
Let $P''=D''_1| \dots|D''_n$ such that $P' \ra^* P''$
then there exists $Q''$
such that $P'_{x=v} \ra^* Q''$
where for all memory location $y$ that have been created in any device with rights $R_l$ with
$R \nlpc R_l$, we have $\erase{R}{v_P}=\erase{R}{v'_Q}$ where $v_P$ is the value of $y$ in $P''$
and $v_Q$ the value of $y$ in $Q''$.
\end{restatable}
{\bf Implementation:} We have implemented an interpreter for this language in Ocaml\footnote{https://github.com/gazeaui/secure-type-for-cloud}.
The program strictly follows the extended semantics,
it has commands to add a new device; to do an internal reduction on the selected thread(s) of the selected device(s);
to perform an attacker communication,
and to type-check each device of the system according to the annotations.
To define a device which starts with keys in memory,
two additional commands are provided which are allowed only as a preamble:
$\mathbf{load~principal} ~p~ \mathbf{ from }~ i;$
and $\mathbf{load } ~x~ :~ \pubKeyType~ \mathbf{ from }~ i;$
where $i$ is a number; an identical $i$ on two devices represents a shared key. This implementation demonstrates that the syntax is well-defined and effective,
and allows us to test the invariance of the properties with demonstrative examples.
The example of \autoref{sec:example} has been tested
using this implementation:
we are able to reduce the process such that Bob gets the secret from Alice
and we can verify that each step correctly type-checks.
\section{Conclusion}
\label{sec:concl}
We have presented a security type system that provides location based correctness results
as well as a more traditional non-interference result.
The key novelty of our system is to allow principal identities to be created and shared across devices in a controlled way, without the need for a global PKI or middleware layer.
Hence, our correctness result states that well-typed devices can control which other devices may acquire their data, even in the presents of untyped attackers.
We have illustrated our system with an example of an open cloud server that accepts new users.
This server does perform some monitoring of its users but our type system proves that it does not monitor the content of their data.
We argued that our framework is particularly appropriate to cloud systems
where organizations will want guarantees about where their data will be stored as well as the secrecy of their data.
\subsubsection*{Acknowledgement} We would like to thank Alley Stoughton for her help with this work; her insightful comments and useful advice greatly improved this paper.
\section{Examples}
In this example, we encode a server which can accept a finite set of accounts.
An account is set up for one or two principals and allow them to
store private data and ask for computations about these data.
Once an account has been created,
the first member of the account can do three kind of operations to his account:
\begin{itemize}
\item first, he can upload data (here an integer) into the server.
\item next, he can ask the server for the result of a computation based on his data.
\item finally, he can ask to transfer its data to another account whenever the members of the other account
are a subset of the initial account.
\end{itemize}
While users data are ensured to remain private (only the server and the members can access it),
the server is still able to maintain statistical record about how many operation has been done for each account.
\begin{code}
Main := \\
\nwp{Server}{\{\}};\\
\new{Array(int)}{$\bot$}{usage} \{0,0,0,0,0 \};\\
\new{int}{$\bot$}{nextId} 0;\\
\new{int}{$\bot$}{lock}0;\\
\new{Enc(int)}{$\bot$}{init} $\encrypt{\publicKey{Server}}{\{\publicKey{Server}\}}{0}$;\\
\new{Enc(int)}{$\bot$}{stores} \{init,init,init,init,init\};\\
\new{int}{$\bot$}{status} \{0,0,0,0,0\};\\
$\paral{ \bang{register}}{\bang{stats}}$\\
\end{code}
The register process ensures that each userId is unique.
For that it uses a lock that prevents two parallel processes to use nextId at the same time.
\begin{code}
Register := \\
\opc{c}{PubK,PubK, int};\\
\new{int}{$\bot$}{userId} 0;\\
\bang{}\begin{bl}
lock = lock + 1;\\
if(lock = 1)
\begin{bl}
if(userId = 0)
\begin{bl}
userId = nextId;\\
nextId = nextId + 1 ;\\
lock = lock - 1 ;\\
\In{principal,nextPrincipal,v}{c};\\
\new{int}{\{$\publicKey{Server}$,principal,nextPrincipal\}}{data}0;\\
\Out{principal,nextPrincipal,userId}{c};\\
$\paral{\bang{Upload}}{\paral{\bang{Download}}{\paral{\bang{SendToOtherAccount}}{\bang{ReceiveFromOtherAccount}}}}$
\end{bl}
else
\begin{bl}
lock = lock -1;
\end{bl}
\end{bl}
else
\begin{bl}
lock = lock -1;
\end{bl}
\end{bl}
\end{code}
\begin{code}
Upload := \\
\oscf{u}{\bot}{int_{\{\publicKey{Server},principal,nextPrincipal\}}}{Server}{principal};\\
\In{x}{u};\\
usage[userId]=usage[userId]+1;\\
data=x;\\
\\
Download := \\
\oscf{d}{\bot}{int_{\{\publicKey{Server},principal,nextPrincipal\}}}{Server}{principal};\\
usage[userId]=usage[userId]+1;\\
\Out{f(data)}{d}
\end{code}
The two next processes enable the transfer of data from one account to another account:
the first process which is a sub-process of the sending account stores the data encrypted in the store buffer and
warn the process of the other account that it get some data through the status variable.
The second process which is a sub-process of the receiver account checks for notifications about received data and,
if any, transfers them to the account's data.
\begin{code}
SendToOtherAccount := \\
\opc{t}{int};\\
\In{to}{t};\\
if(status[to]=0)
\begin{bl}
stores[to]=$\encrypt{\publicKey{Server}}{\{\publicKey{Server},principal,nextPrincipal\}}{data}$;\\
status[to]=1;\\
$!$\{if(status[to]=2)
\begin{bl}
\Out{0}{t};\\
stats[to]=0;
\end{bl}\}
\end{bl}
\end{code}
\begin{code}
ReceiveFromOtherAccount := \\
if(status[userId]=1)
\begin{bl}
$\decrypt{Server}{stores[userId]}{packet}{int_{\{\publicKey{Server},principal,nextPrincipal\}}}$
\begin{bl}
data=packet;\\
status[userId]=2;
\end{bl}
else
\begin{bl}
status[userId]=2;
\end{bl}
\end{bl}
\end{code}
\subsubsection*{Expressions:}
v & ::= & i & \text{an integer}\\
& | & \pubKeyOf{k} & \text{the value of a public key }\\
& | & \enc{v}{n}{\LR} & \text{a cipher of $v$ with seed $n$}\\
& | & \enc{\pvalue}{n}{\LR} & \text{an encapsulated principal}\\
& | & \{v_1, \dots v_n \} & \text{an array of values}\\
& | & \NotAValue & \text{a special error value}\\
\pvalue & ::= & \prin{\pubKey}{\secKey}{\LR}\!\!\! & \text{a principal value}\\
\LR & ::= & \{ \pubKey \} \cup \LR & \text{a set of public keys}\\
& | & \{~\}\\
\activechans &::= & \{\} & \\
&|& \activechans.c & c :\text{established channel}
\end{array}
\]
\caption{The syntax of devices, values, principals and rights where $\secof{k} / \pubof{k}$ is a secret/public key pair. }
\label{fig:syntax}
\end{figure}
\section{Introduction}
Organisations commonly trust their cloud providers not to be actively malicious
but may still need to verify that the cloud service does not make mistakes and does store their data at particular locations.
For example, data protection laws prevent
the storage of certain forms of data outside the European Union.
In order to ensure compliance, a company policy may require that data from a user's device not be
synchronized with a cloud storage provider, unless that provider can certify that the data will not be stored in data centers outside the EU.
Such checks against inappropriate storage of data can be costly and time consuming,
sometimes leading to organisations not allowing their employees to use cloud services,
even though a particular cloud service may be known to be compliant with data handling policies.
This paper presents a language-based approach to dealing with these kinds of scenarios, of ensuring that data can be shared with cloud services while ensuring compliance with policies on data storage.
The approach is based on a type system that explicitly models trust between cloud services and mobile devices, based on a notion of principals represented at runtime by cryptographic keys.
In this language, principals are dynamically associated to (non-disjoint) sets of devices,
and the rights of devices to access data is based on sets of principals (delineating the principals that are allowed to access protected data).
For instance, if two devices $A$ and $B$ can (individually) act for a principal $P$, while devices $B$ and $C$ can act for principal $Q$,
then the right $\{P,Q\}$ implicitly allows the devices $A$, $B$ and $C$ to access data guarded by this right.
We argue that this two-layer representation of access rights (data guarded by principal rights, and devices acting for principals) is convenient to
allow principals to share a device, and to allow one principal to use several devices (laptop, mobile phone etc.)
Based on this type system, we present a language that includes most of the primitives necessary for secure imperative programming
(multi-threading, references, secure channel establishment, and cryptographic ciphers).
A key feature of this language is the ability for new principals to dynamically join the network (in the sense of making network connections to cloud services and other devices) without having to register to any public key infrastructure (PKI) or to use a particular middleware layer\footnote{
Although middleware for e-commerce (such as CORBA) was popular in the 1990s, that approach was discredited by experience, while SOAP-based approaches have been largely superseded by REST-based Web services, that deliberately eschew the notion of a middleware at least for Internet communication..
}.
Our threat model assumes some ``honest''
collection of principals (e.g.~the employees of an enterprise) and some collection of devices acting for those principals (e.g.~devices provided to those employees). A device may act for several principals, in the sense that it may issue access requests on behalf of any of the principals that it acts for), while a principal may be associated with several devices. We describe the devices acting for these principals as \emph{honest devices}, in the sense that they are certified according to the type system presented in this paper to be in conformance with data sharing policies.
We refer to the corresponding principals for these devices as ``honest'' rather than ``trusted'' because trust management is an orthogonal issue for the scenarios that we consider.
Our threat model also allows for ``dishonest'' or untyped devices, acting for outside principals, who should not be able to access the data. These are the attacker devices.
Our security guarantee is that, as long as no honest device provides access to a dishonest principal, the dishonest devices will not be able to obtain any information from any honest devices, unless an honest device has explicitly given the attacker access.
This capability is critical for cloud services.
While it is reasonable to assume that there exists a PKI to certify the identities of cloud providers,
and that cloud providers are trusted by their users,
client devices and their corresponding principals
are unlikely to have certificates. While an infrastructure for mutual authentication, based on client and server X509 certificates,
might be provided as part of an enterprise data sharing network, there are difficult issues with extending this trust model to third party cloud service providers. Furthermore, such a PKI does not provide the level of confidence in conformance with data-sharing protocols, that our approach provides for honest (well-typed) devices.
Instead of requiring such a global PKI, the approach described in this article represents principals by cryptographic public keys,
and these are stored on devices like any other values. Our type system therefore uses a nominal form of dependent types, to reflect these runtime representatives of principal identity to the type system, where access rights on data are tracked through security labels attached to types.
Another contribution of the paper is a security guarantee suitable for our threat model.
As stated above, in an open network, we must allow for ``dishonest'' devices that are unchecked (untyped), and potentially malicious.
These devices are able to use any third-party cloud services, including services used by honest devices.
A secure data-sharing system should remain robust to such an intruder. Our security guarantee is that
if data is protected with rights that only includes honest principals (i.e., that do not include any principal which is associated to an attacker device),
then an attacker cannot learn any information about that data. In this work, we are focused on confidentiality of the data, and do not consider integrity (that data has not been tampered with by attackers). There is a notion of integrity in the sense of trust management underlying our approach: Honest principals identify themselves by their public keys, and these keys are to state access restrictions on data, to specify when a device is allowed to ``act for'' a principal, and to validate that communication channels are with honest parties trusted to be type-checked and therefore conformant with data-sharing policies. This is reflected in several aspects of the communication API, including the establishment of communication channels, generating new principals and transmitting those principals between devices.
A practical difficulty with expressing security guarantees in this setting is that, as principals can be created dynamically, it is not possible to statically check if a variable has a higher or lower security level than some other variable. Consider the following example:
\begin{example}
Assume three devices: an honest cloud service with a certified principal $p$, and two (mobile) devices, an honest device $A$ and a malicious device $B$.
The server code consists of receiving two principal values $p_1$ and $p_2$ from the network before it creates
two memory locations $x_1$ and $x_2$ where $x_1$ has rights $\{ p , p_1 \}$ while $x_2$ has right $\{ p, p_2\}$.
A secure location is defined one which cannot be accessed by the attacker.
If we assume that devices $A$ and $B$ send their principal values (public keys) to the server,
then depending on which key is received first, either $x_1$ or $x_2$ will be considered secure (only accessible by the honest principal and the cloud provider), while the other
is explicitly accessible by the attacker. As usual with information flow control type systems, we propagate these access restrictions through the handling of data by the cloud provider and the devices, ensuring that data protected by the right $\{p,p_i\}$, where $p_i$ is the representative for the honest principal.
\end{example}
Therefore, our security property is a posteriori: once the system has created a memory cell corresponding to some variable,
if the rights associated to this variable at creation time did not include a principal controlled by the attacker, then
there will never be any leak about the contents of this memory cell to the attacker.
We argue that such a property is suitable for cloud services to increase users' confidence that their data will not be leaked by the service due to a programming error.
Indeed, our system allows us to certify that once some principal creates data, only explicitly authorised principals can obtain information about that data,
by statically checking the code that processes that data.
Verifying the identity of the principals allowed to access the data, and deciding where to place trust among the principals in a distributed system, is an important consideration. However it properly remains the responsibility of the application written in our language, and a concern which is independent of this type system. Our approach serves to guarantee proper handling of data among honest principals, once an appropriate trust management system has established who is honest.
Our typed language is intended to be a low level language, without high-level notions such as objects and closures.
It includes consider references, multi-threading and a realistic application programming interface (API) for distributed communication.
Communications can either be through a secure channel mechanism, implementable using a secure transport layer such as TLS for example,
or through public connections, in which case any device can connect.
The language includes primitives for asymmetric key encryption, since we represent by public keys.
``Possessing'' a secret key, in the sense that the private key of a public-private key is stored in its memory, allows a device to ``act for'' the principal that key represents. Our approach is similar in philosophy to the Simple Public Key Infrastructure (SPKI), where principals and public keys are considered as synonymous, rather than linking principals to a separate notion of public key representatives. However, we do not include notions such as delegation that are the central consideration of SPKI, since we explicitly avoid the consideration of trust management, leaving that to applications written using the API that we provide. This also differentiates our approach from frameworks such as JIF and Fabric, that include delegation of authority to principals based on an assumed trust management infrastructure.
Nevertheless, there is a notion at least tangentially relegated to delegation of trust in our framework: In order to allow a device to act for more than one principal, our semantics allows a principal to be created on one device and communicated to another device, where it is registered on the receiver device as one of the principals upon whose behalf that device can access data. For example, a client of a cloud service provider may generate a proxy principal representing that client on the cloud service, and then upload that principal to the cloud service in order to access data that the client is storing on the cloud service. This ability to share principals across devices is controlled by restrictions established when proxy principals are generated: Such a proxy (client) principal can only be registered on a device that acts for (cloud service) principals that are identified at the point of generation of the proxy.
The security analysis of the type system uses standard techniques from the applied-pi calculus
\cite{AbadiFournet2001}.
This allows us to prove our correctness property as a non-interference property based on process equivalence, i.e.,
two systems
differing by one value are indistinguishable by any party that is not allowed to access this value.
The standard pi-calculus includes message-passing with structured values, but does not include an explicit notion of memory (although it can obviously be modeled using processes as references). Since our language combines message-passing communication and localized stateful memory, we use
the stateful applied pi-calculus \cite{Arapinis2014} as the starting point for our security analysis.
This calculus does not explicitly model location (i.e., the distinction between two processes on the same device and two processes on two distinct devices).
Since this distinction is critical for our security analysis, we add this notion in our calculus. Nevertheless the proof techniques that we employ are heavily based on those developed for the stateful applied pi-calculus.
The security analysis that we perform expresses that data are secure if
keys received from other devices are not associated to an attacker.
To formalise this conditional statement, we need more techniques than
in a standard protocol where data are either secret or public,
but their status does not depend on the execution.
In our verification in \autoref{sec:annotations}, we introduce an extended syntax that marks
which keys, variables and channels are secure in the current trace.
We then prove that when a new memory location is created with a secure key according to this marking,
then the attacker cannot distinguish between two scenarios:
one where the system reduces normally, and another one where the memory location is sometimes altered to another value. This is the basis for our noninterference property for the security guarantee provided by this approach.
\iftoggle{techreport}{
}{
The full details of the proofs of correctness for information flow control are provided in the complete version of the paper \cite{tech-report}.
}
In the next section we discuss related work. In \autoref{sec:lang} we present our language, type system and semantics.
In \autoref{sec:example} we present an extended example
and in \autoref{sec:result} present our result and outline the proof,
then we conclude in \autoref{sec:concl}.
\iftoggle{techreport}{
\autoref{app:other-rules} provides addtional type rules for the language considered in this paper. \autoref{app:proofs-correctness} considers proofs of correctness omitted from \autoref{sec:result}. \autoref{sec:ext-rules} considers addtional operational semantics rules for the ``open'' semantics that enables us to reason about interactions with untyped attackers.
}{
}
\section{Related Work}
\paragraph*{Implicit flow}
Implicit information flow properties involve the ability for an attacker to distinguish between two executions.
Previous work that has provided type systems to control implicit information flow \cite{CDLM,Masked08} considered high and low data,
and this could be extended to a bigger lattice but not to the creation of new principals,
as the security of a variable is defined statically.
Zheng and Myers presented an information flow type system that includes dynamic checks on rights \cite{Zheng2005} which can be used,
for instance, when opening a file.
The Jif Project \cite{JIF} adds security types to a subset of Java, leading to a powerful and expressive language.
Unlike our work, this other work does not address how to enforce
principal identities and type information
to be correctly communicated to other locations.
\paragraph*{Security properties on distributed system}
Work on type security for distributed systems can be distinguished according to the kind of security they aim to provide.
Muller and Chong present a type system that includes a concept of place \cite{MullerC12}
and their type system ensures that covert channels between ``places'' cannot leak information.
Vaughan et al. look at types that can be used to provide evidence based audit \cite{AURA,JMZ08}.
Fournet et al. look at adding annotations with a security logic to enforce policies \cite{Fournet2008}.
Liu and Myers \cite{Liu2014} look at a type system which ensures referential integrity in a distributed setting.
This work uses a fix lattice of policy levels, which does not change at runtime.
The Fabric language \cite{Fabric} provides decentralised, type-enforced security guarantees using a powerful middleware layer for PKI,
and Morgenstern et al. \cite{Morgenstern2010} extend Agda with security types.
In contrast, our work allows programs to generate new principals at run-time
and provides a security property that tracks implicit information flow, without requiring the support of a purpose built middleware layer or global PKI.
Due to the fact that the attackers in our model can access services in the same way as honest principals, this security property is an adaptation of the bisimulation property which is a strong property introduced in the (s)pi-calculus by \cite{AbadiFournet2001}.
Bisimilation can be checked for processes by tools like Proverif \cite{Blanchet2001}
but these kind of tools do not scale up to large systems.
\paragraph*{Managements of new principals}
Bengtson et al. \cite{Bengtson2011} present a security type system which allows creation of dynamic principals
in presence of an untyped attacker. However, this type system provides only assertion-based security properties of cryptographic protocols.
These are weaker than non-interference properties as they are expressed on one process instead of comparing two processes.
\cite{KDLM} considers a framework in which principals can be created at run time (without a global PKI) they prove type soundness rather than a non-interference result. Finally, the DSTAR program \cite{Zeldovich2008} achieves these two goals but is focused on network information
and relies on local systems to actually analyse implicit flow, which leads to a more coarse system.
\paragraph*{Safety despite compromised principals}
Past work \cite{CD05} has looked at un-typed attackers in a security type system, however this work only considers a static number of principals, fixed at run time.
Fournet, Gordan and Maffeis \cite{Fournet2007} develop a security type system for a version of the applied pi-calculus extended with locations and annotation. Their type system can enforce complex policies on these annotations, and they show that these policies hold as long as they do not depend on principals that have been compromised. Unlike our work they assume that the principals are all known to each other and there is a direct mapping from each location to a single principal that controls it. Our work allows principals to be dynamically created, shared between locations and for locations to control multiple principal identities. We argue that this model is a better fit to cloud systems in which users can dynamically create many identities and use them with many services.
\section{The Language}\label{sec:language}
\section{The Syntax}
\label{sec:syntax}
\subsection{Types}
The most basic values are integers ($\Int$).
We also allow the encryption of any values of type $S$ which has a parametric type ($\Cipher(S)$).
To express confidentiality policy the types of values have a label containing information about which principals
are allowed to learn any information from the value.
Principals mainly consists of a pair of public and secret keys.
The public key is used by labels to identity which principal is allowed to access data and for encryption.
The secret key is used for device to identify themselves for secure connection as well as for decryption:
the knowledge of a secret key means the device has the right to act for this principal.
These values are either created in the device or received by another device,
inside the program these values are referred by names.
This means that the program can receive different keys for a given name depending on the executions.
To still be able to reason about rights statically,
keys names are not considered as standard types : they cannot be changed with an affectation rule.
To enable principal to propagate on other devices we use an encapsulation of principal of type $\SecK$.
Syntax for types appearing into the code are the following.
$S$ represents the standard types. Note that because values might come from untyped attacker
these types play no role to grant confidentiality, they are just for readability reasons.
$R$ is the syntax for label rights. When the program is written $R$ can only be
a set of public keys whose first key is the public key of a known private key
(just to avoid device to declare variable with unusable types) or a name.
When the program runs, rights are progressively replaced by actual set of public keys.
\subsection{Principals}
Principals are created with the \cmd{\newPrin{P}{R}} command.
They can by transferred to other devices that owns one of the principals in \KNW.
It consists of a triple of a private key and its corresponding public key as well as the set of allowed owners.
To transfer a principal to someone who is allowed to get it,
a principal has to be released into a regular variable of type \SecK.
The $\RELEASE$ expression encrypts the secret key to provide a transferable variable of type \SecK.
The encryption of the key allows to send it through public channels which is a crucial point.
Indeed, a secret key contains two kinds of information:
what is the key value that will allow decryption authentication and so on
and the fact the secret key is the one corresponding to a known public key.
When sending a secret key, if the sent key depends on some confidential variable, then a device that will use
that key to authenticate itself would leak information about this confidential variable.
To avoid this issue, we encrypt all private keys such that only the value is protected
not the fact that a specific key has been released.
The encryption does not need any parameter: the key is encrypted automatically for all principal that know that key.
The reverse operation that converts a mutable secret key in a key usable for encryption is $\REGISTER$
which take a secret key and returns, if the decryption succeed, the secret value used as a principal.
\subsection{Rights and public keys}
The language provides several primitives to handle rights and keys.
First, from a principal $P$, it is possible to extract its public key with
$\publicKey{P}$ which provides the key $\pubKeyType$.
In addition, since most rights are known only at run-time
while some commands require one right to be less confidential then another one,
the language provides run-time comparison with the structure $\IF( R_1 \lc R_2 ) C \ELSE C$
which enforce the constraint in the true branch.
\subsection{Channels}
In our type system there is three ways to communicate :
\begin{enumerate}
\item \label{chan:pub} A symmetric public channel which do not require any authentication: $\OPUBCHAN ~c : S; $.
\item \label{chan:private} An asymmetric channel,
where the server and the client authenticate themselves and the server only accept a designed client.
The client side is identical to above while the server command is \cmd{\OSECSCHANF(P,K_p) ~c : S \DEN \alpha;}.
\end{enumerate}
Input and output are done with the \cmd{\NEW X = \INPUT( c );} and \cmd{\OUTPUT E \AT c;} commands.
\subsubsection{Encrypting data}
When data are sent over a channel, they may need to be secured: either the channel itself is secure
or the data are encrypted.
The encryption primitive is the expression $\ENC E \USING R$: it is possible to encrypt for several principals.
To decrypt a data we would like to use a command like $\NEW S X = \DEC E \USING P$.
However it is not always possible to decrypt because we do not know form the type for who the data is encrypted.
Therefore, we have to deal with dynamic checking.
This is represented by the full instruction $\IF( \NEW S X = \DEC E \USING P ) C \ELSE C $.
\subsection{Standard commands}
Finally, we have standard command like conditional branching, declaration of variables and affectation of variables.
We also consider multi-threads devices with the command $|$ and the bang operator to open an arbitrary number of threads.
There is no loop instruction in this language but while loop can be simulated with a bang and the use
of auxiliary variables that allow a new thread to start only when the previous one has ended.
About expressions, we only consider addition of integers but the language can be easily extended to any standard operator.
\section{The Syntax}
\begin{figure}
\[
\begin{array}{rcl}
C & ::= & \cond{e_1}{e_2}{C_1}{C_2
\\& | & \new{x}{S_R}{e};~C
\\& | & \assign{x}{e};~C
\\& | & \assign{x[e_1]}{e_2};~C
\\& | & \letk{k}{x}~C
\\& | & \paral{C_1}{C_2}
\\& | &\nop
\\& | &\bang{C}
\\& | & \connectPub{c}{\chanType{S_{\bot}}{\bot}};~C
\\& | & \acceptPub{c}{\chanType{S_{\bot}}{\bot}};~
\\& | & \connectCCert{c}{\chanType{S_R}{R'}}{k}{p};~
\\& | & \acceptCCert{c}{\chanType{S_R}{R'}}{k}{p};~
\\& | & \outputChan{e}{c};~
\\& | & \inputChanII{c}{x};~
\\& | &\sync\{G\};C_2
\\& | & \newPrin{p}{RS}; C
\\& | & \decrypt{p}{e}{x}{S_{RS}}{C_1}{C_2}
\\& | & \register{p_1}{e}{p_2}{C_1}{C_2}
\end{array}
\]
\caption{The syntax of the commands.}
\label{fig:commands}
\end{figure}
| {'timestamp': '2017-06-07T02:06:29', 'yymm': '1706', 'arxiv_id': '1706.01742', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01742'} | arxiv |
\section{Minimum Kantorovitch Estimators}
\paragraph{MKE.} Given some empirical distribution $\nu \eqdef \frac{1}{n}\sum_{j=1}^n \de_{y_j}$ where $y_j \in \Xx\subset\RR^p$, and a parametric family of probability distributions $(\mu_\th)_{\th\in\Theta} \subset \Pp(\Xx)$, $\Theta\subset \mathbb{R}^q$, a Minimum Kantorovitch Estimator (MKE)~\cite{bassetti2006minimum,montavon2016wasserstein,bernton2017inference} for $\th$ is defined as any solution of the problem
\eql{\label{eq-fitting-energy-orig}\tag{MKE}
\umin{\th} W_c(\mu_\th,\nu),
}
where $W_c$ is the Wasserstein cost on $\Pp(\Xx)$ for some ground cost function $c:\Xx\times\Xx \rightarrow \RR$, defined as
\eql{\label{eq-primal-formula}
W_c(\mu,\nu) = \umin{\ga \in \Pp(\Xx \times \Xx)} \enscond{ \int_{\Xx \times \Xx} c(x,y) \d \ga(x,y) }{ P_{1\sharp}\ga=\mu, P_{2\sharp}\ga=\nu },
}
where $P_1(x,y)=x$ and $P_2(x,y)=y$, and $P_{1\sharp}$ and $P_{2\sharp}$ are marginalization operators that return for a given coupling $\gamma$ its first and second marginal, respectively.
The notations $P_{1\sharp}$ and $P_{2\sharp}$ above agree with the more general notion of pushforward measures: Given a measurable map $g: \Zz\rightarrow \Xx$, which can be interpreted as a function ``moving'' points from a measurable space to another, one can naturally extend $g$ to become a more general map $g_\sharp$ that can now ``move'' an entire probability measure on $\Zz$ towards a new probability measure on $\Xx$. The operator $g_\sharp$ ``pushes forward'' each elementary mass of a measure $\zeta$ in $\Pp(\Zz)$ by applying the map $g$ to obtain then a mass in $\Xx$, to build on aggregate a new measure in $\Pp(\Xx)$ written $g_{\sharp}\zeta$. More rigorously, the pushforward measure of a measure $\zeta \in \Pp(\Zz)$ by a map $g: \Zz\rightarrow \Xx$ is the measure denoted as $g_{\sharp}\zeta$ in $\Pp(\Xx)$ such that for any set $B\subset\Xx$, $(g_{\sharp}\zeta)(B) \eqdef \zeta(g^{-1}(B))=\zeta(\enscond{z\in\Zz}{g(z)\in B})$.
\begin{figure}[ht]
\centering
\includegraphics[width=\linewidth]{images/fig-gan-vae.pdf}
\caption{\label{fig-workflow}
Left: illustration of density fitting using the Minimum Kantorovitch Estimator for a generative model.
Middle and right: comparison of the GAN vs. VAE setups.
}
\end{figure}
\paragraph{MKE-GM.} The MKE approach can be used directly in the case where $(\mu_\theta)_{\theta}$ is a statistical model, namely a parameterized family of probability distributions with a given density with respect to a dominant base measure, as considered for instance with exponential families on discrete spaces in~\cite{montavon2016wasserstein}. However, the MKE approach can also be used in a \emph{generative model} setting, where $\mu_\th$ is defined instead as the push forward of a fixed distribution $\zeta$ supported on a low dimensional space $\Zz\subset\RR^d$, $d\ll p$, where the parameterization lies now in choosing a map $g_\th : \Zz \mapsto \Xx$, i.e. $\mu_\th = g_{\th\sharp}\zeta$, resulting in the following special case of the original~\eqref{eq-fitting-energy-orig} problem:
\eql{\label{eq-fitting-energy}\tag{MKE-GM}
\umin{\th} E(\th) \eqdef W_c(g_{\th\sharp}\zeta,\nu),
}
The map $g_\th$ should be therefore thought as a ``decoding'' map from a low dimensional space to a high dimensional space.
In such a setting, the maximum likelihood estimator is in general undefined or difficult to compute (because the support of the measures $\mu_\th$ are singular) while MKEs are attractive because they are always well defined.
\section{Dual Formulation and GAN}
Because~\eqref{eq-primal-formula} is a linear program, it has a dual formulation, known as the Kantorovich problem~\cite[Thm. 5.9]{villani2008optimal}:
\eql{\label{eq-dual-w}
E(\th) = \umax{h,\tilde h}
\enscond{ \int_{\Zz} h(g_\th(z)) \d\zeta(z) + \int_{\Xx} \tilde h(y) \d\nu(y) }{ h(x) + \tilde h(y) \leq c(x,y) }.
}
where $(h,\tilde h)$ are continuous functions on $\Xx$ often called Kantorovich potentials in the literature.
In the dual formulation~\eqref{eq-dual-w}, $\th$ does not appear anymore in the constraints. Therefore, the gradient of $E$ can be computed as
\eql{\label{eq-grad-dual}
\nabla E(\th) = \int_{\Zz} [\partial_\th g_\th(z)]^\top \nabla h^\star( g_\th(z) ) \d \zeta(z),
}
where $h^\star$ is an optimal dual function solving~\eqref{eq-dual-w}. Here $[\partial_\th g_\th(z)]^\top \in \RR^{q \times p}$ is the adjoint of the Jacobian of $\th \mapsto g_\th(z)$, where $q$ is the dimension of the parameter space $\Theta$.
A key remark in Kantorovich's formulation is to notice that the cost of any pair $(h,\tilde h)$ can always be improved by replacing $\tilde h$ in~\eqref{eq-dual-w} by the $c$-transform $h^c$ of $h$ defined as
\eq{
h^c(y) \eqdef \umax{x} c(x,y) - h(x),
}
which is, indeed, given a candidate potential $h$ for the first variable, the best possible potential that can be paired with $h$ that satisfies the constraints of~\eqref{eq-dual-w} (see~\cite[Thm. 5.9]{villani2008optimal}). For this reason, one can parameterize problem \eqref{eq-dual-w} as depending on one potential function only.
A first approach to solve~\eqref{eq-dual-w} is to remark that since $\nu$ is discrete, one can replace the continuous potential $\tilde h$ by the discrete vector $( \tilde h(y_j) )_j \in \RR^n$ and impose $h=(\tilde h)^c$. As shown in~\cite{2016-genevay-nips}, the optimization over $\tilde h$ can then be achieved using stochastic gradient descent.
Similarly to~\cite{WassersteinGAN}, another approach is to approximate~\eqref{eq-dual-w} by restricting the dual potential $h$ to have a parametric form $h=h_{\xi} : \Xx \rightarrow \RR$ where $\xi$ is a discriminative deep network (see Figure~\ref{fig-workflow}, center). This map $h_\xi$ is often referred to as being an ``adversarial'' map. Plugging this ansatz in~\eqref{eq-dual-w} leads to the Wasserstein-GAN problem
\eql{\label{eq-gan}\tag{WGAN}
\umin{\th} \umax{\xi} \int_{\Zz} h_\xi \circ g_\xi(z) \d\zeta(z) + \sum_j h_\xi^c(y_j).
}
In the special case where $c(x,y)=\norm{x-y}$, one can prove that the mechanics of $c$-transforms result in the additional constraint that $\tilde h=-h$, subject to $h$ being a $1$-Lipschitz function, see~\cite[Particular case 5.4]{villani2008optimal}. This is used in~\cite{WassersteinGAN} to replace $h_\xi^c$ by $-h_\xi$ in~\eqref{eq-gan} and use a deep network made of ReLu units whose Lipschitz constant is upper-bounded by $1$.
As a side-note, and as previously commented in the literature, there is at this point no empirical evidence that supports the idea that using discriminative deep networks that way can result in accurate approximations of Wasserstein distances. These alternative formulations provide instead a very useful proxy for a quantity directly related to the Wasserstein distance.
\section{Primal Formulation and VAE}
Following~\cite{Bousquet2017,2017-Genevay-AutoDiff}, in the special case of a generative model $\mu_\th = g_{\th\sharp}\zeta$, formula~\eqref{eq-primal-formula} can be conveniently re-written as
\eql{\label{eq-primal-rewrite}
E(\th) = \umin{\pi \in \Pp(\Zz \times \Xx)} \enscond{ \int_{\Zz \times \Xx} c(g_\th(z),y) \d \pi(z,y) }{ P_{1\sharp}\pi=\zeta, P_{2\sharp}\pi=\nu }.
}
This is advantageous because now $\pi$ is defined over $\Zz \times \Xx$, which is lower-dimensional than $\Xx \times \Xx$, and also because, as in Equation~\eqref{eq-dual-w}, $\th$ does not appear in the constraints either.
This provides an alternative formula for the gradient of $E$:
\eql{\label{eq-grad-primal}
\nabla E(\th) = \int_{\Zz \times \Xx} [\partial_\th g_\th(z)]^\top \nabla_1 c(g_\th(z),y) \d \pi^\star(z,y),
}
where $\pi^\star$ is an optimal coupling solving~\eqref{eq-primal-rewrite}. Here $\nabla_1 c(x,y) \in \RR^p$ denotes the gradient of $c$ with respect to the first variable.
\cite{Bousquet2017} suggests to look for couplings $\pi$ with a parametric form. A simple way to achieve this is to restrict couplings $\pi$ to those of the form
\eq{
\pi_{\xi} \eqdef \sum_{j} \de_{(f_\xi(y_j),y_j)} \in \Pp(\Zz \times \Xx),
}
where $f_\xi : \Xx \rightarrow \Zz$ is a parametric ``encoding'' map (typically a deep network), see Figure~\ref{fig-workflow}, right. This $\pi_\xi$ satisfies by construction the marginal constraint $P_{2\sharp}\pi=\nu$, but in general it cannot satisfy the other constraint $P_{1\sharp}\pi=\zeta$ (because $P_{1\sharp}\pi_\xi$ is discrete while $\zeta$ is not). So following~\cite{Bousquet2017}, it makes sense to consider a relaxed ``unbalanced'' formulation (in the sense of~\cite{2016-chizat-sinkhorn}) of the form
\eql{\label{eq-relaxed-estimator}
E_\la(\th) = \umin{\pi} \enscond{ \int_{\Zz \times \Xx} c(g_\th(z),y) \d \pi(z,y) + \la D(P_{1\sharp}\pi|\zeta) }{ P_{2\sharp}\pi=\nu },
}
where $D(\cdot|\cdot)$ is some distance or divergence between positive measures on $\Zz$ and $\la>0$ a relaxation parameter.
Plugging the ansatz $\pi=\pi_\xi$ in~\eqref{eq-relaxed-estimator}, one obtains the Wasserstein-VAE formulation
\eql{\label{eq-vae}\tag{WVAE}
\umin{(\th,\xi)} \De_\nu( g_\th \circ f_\xi, \Id_{\Xx} ) + \la D( f_{\xi\sharp} \nu |\zeta),
}
where $\De_\nu( \phi, \Id_{\Xx} )$ is the cost measuring the deviation of a map $\phi : \Xx \rightarrow \Xx$ to identity
\eq{
\De_\nu( \phi, \Id_{\Xx} ) \eqdef
\int_\Xx c(\phi(y),y) \d\nu(y)
=
\frac{1}{n}\sum_{j=1}^n c(\phi(y_j),y_j).
}
Such a cost is usually associated with the Monge formulation of optimal transport~\cite{Monge1781}, whose original motivation was to find an optimal \emph{map} under that cost that would be able to push forward a given measure onto another\cite[\S1.1]{santambrogio2015optimal}.
\section{Conclusions}
\newcommand{\thA}[1]{\th_{\text{\tiny #1}}}
The~\ref{eq-gan} and~\ref{eq-vae} formulations are very different, and are in some sense dual one of each other.
For GAN, the couple $(g_\th,h_\xi)$ should be thought as a (primal, dual) pair (often referred to as adversarial pair, which is reminiscent of game theory saddle points). For VAE, the couple $(f_\xi,g_\th)$ is rather an (encoding, decoding) pair, and both have the flavour of transportation maps.
In sharp contrast to the primal gradient formula~\eqref{eq-grad-primal} which only requires integrating against an optimal coupling $\pi^\star$, the dual gradient formula~\eqref{eq-grad-dual} involves the integration of the \emph{gradient} of an optimal potential $h^\star$. The latter tends to be more unstable and thus necessitates accurate optimization sub-iterations to obtain an optimal dual potential $h^\star$~\cite{2016-genevay-nips} or an approximation $h_\xi^\star$ within a restricted parametric class~\cite{WassersteinGAN}. This is somehow inline with the empirical observation that training VAE is more stable than training GAN.
One should however bear in mind that, although both formulations can be motivated by the same minimum Kantorovitch estimation problem~\eqref{eq-fitting-energy}, they define quite different estimators. In particular, GAN is often credited for producing less blurry outputs when used for image generation.
Denoting $\thA{MKE}, \thA{WGAN}$ and $\thA{WVAE}$ the solutions of~\eqref{eq-fitting-energy}, \eqref{eq-gan} and \eqref{eq-vae}, one has in the limit $\la \rightarrow +\infty$ (to cancel the bias due to the marginal constraint relaxation),
\eq{
E(\thA{WGAN}) \leq E(\thA{MKE}) \leq E(\thA{WVAE}).
}
\cite{Bousquet2017} furthermore mentions that in the ``non-parametric limit'' (i.e. when the number of parameters appearing in $\xi$ tends to $+\infty$, and also letting $\la \rightarrow +\infty$), the gap between the estimators should vanish. Indeed, $h_\xi$ and $f_\xi$ should capture the desired optimal map in the limit and one thus recovers the true solution to~\eqref{eq-fitting-energy}. While it would be interesting from a theoretical perspective to prove and quantify such a claim, it is unclear wether it would be useful for the practitioner. Indeed, the convergence rate might be slow, so that in practice one can be quite far from this non-parametric limit. One could even argue that this limit may give poor estimators for complicated datasets, so that parameterizing the maps and using non-convex optimization solvers lead instead to a beneficial and implicit regularization of these estimators.
\bibliographystyle{plain}
| {'timestamp': '2017-06-07T02:07:29', 'yymm': '1706', 'arxiv_id': '1706.01807', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01807'} | arxiv |
\section{Introduction} \label{introduction}
With the explosive growth of informal electronic communications such as email, social media, web comments, etc., colloquial languages that were historically unwritten are starting to be written for the first time. For these languages, there are extremely limited (approximately zero) resources available, not even large amounts of monolingual text data or possibly not even small amounts of monolingual text data. Even when audio resources are available, difficulties arise when converting sound to text \cite{tratz2013,robinson2003}. Moreover, the text data that can be obtained often has non-standard spellings and substantial code-switching with other traditionally written languages \cite{tratz2013}.
In this paper we present a method for the acquisition of translation lexicons via loanwords and expert knowledge that requires zero resources of the borrowing language. Many historically unwritten languages borrow from highly resourced languages. Also, it is often feasible to locate a language expert to find out how sounds in these languages would be rendered if they were to be written as many of them are beginning to be written in social media, etc. We thus expect the general method to be applicable for multiple historically unwritten languages.
In this paper we investigate inducing a Moroccan Darija-English translation lexicon via borrowed French words.
Moroccan Darija is an historically unwritten dialect of Arabic spoken by millions but lacking in standardization
and linguistic resources \cite{tratz2013}. Moroccan Darija is known to borrow many words from French, one of the most highly resourced languages in the world. By mapping Moroccan Darija-French borrowings to their donor French words, we can rapidly create lexical resources for portions of Moroccan Darija vocabulary for which no resources currently exist.
For example, we could use one of many bilingual French-English dictionaries to bridge into English and create a Moroccan Darija-English translation lexicon that can be used to assist professional translation of Moroccan Darija into English and to assist with construction of Moroccan Darija-English Machine Translation (MT) systems.
The rest of this paper is structured as follows. Section~\ref{related} summarizes related work; section~\ref{method} explains our method; section~\ref{experiments}
discusses experimental results of applying our method to the case of building a Moroccan Darija-English translation lexicon; and section~\ref{conclusions} concludes.
\section{Related Work} \label{related}
Translation lexicons are a core resource used for multilingual processing of languages.
Manual creation of translation lexicons by lexicographers is time-consuming and expensive.
There are more than 7000 languages in the world, many of which are historically unwritten \cite{lewis2015}.
For a relatively small number of these languages there are extensive resources available that have been manually
created.
It has been noted by others \cite{mann2001,schafer2002} that languages are organized into families and that using cognates between sister
languages can help rapidly create translation lexicons for lower-resourced languages.
For example, the methods in \cite{mann2001} are able to detect that English {\em kilograms} maps
to Portuguese {\em quilogramas} via bridge Spanish {\em kilogramos}. This general idea has
been worked on extensively in the context of cognates detection, with `cognate' typically re-defined to include loanwords as well as true cognates. The methods use monolingual data at a minimum and many signals such as orthographic similarity, phonetic similarity,
contextual similarity, temporal similarity, frequency similarity, burstiness similarity, and topic similarity \cite{bloodgood2017,irvine2013,kondrak2003,schafer2002,mann2001}. Inducing translations via loanwords was specifically targeted in \cite{tsvetkov2015a,tsvetkov2015b}.
While some of these methods don't require bilingual resources, with the possible exception of small bilingual seed dictionaries, they do at a minimum require monolingual text data in the languages to be modeled and sometimes have specific requirements on the monolingual text data such as having text coming from the same time period for each of the languages being modeled. For colloquial languages that were historically unwritten, but that are now starting to be written with the advent of social media and web comments, there are often extremely limited resources of any type available, not even large amounts of monolingual text data. Moreover, the written data that can be obtained often has non-standard spellings and code-switching with other traditionally written languages. Often the code-switching occurs within words whereby the base is borrowed and the affixes are not borrowed, analogous to the multi-language categories ``V" and ``N" from \cite{mericli2012}. The data available for historically unwritten languages, and especially the lack thereof, is not suitable for previously developed cognates detection methods that operate as discussed above. In the next section we present a method for translation lexicon induction via loanwords that uses expert knowledge and requires zero resources from the borrowing language other than a language informant.
\section{Method} \label{method}
Our method is to take word pronunciations from the donor language we are using and convert them to how they would be rendered in the borrowing language if they were to be borrowed.
These are our candidate loanwords.
There are three possible cases for a given generated candidate loanword string:
\begin{description}
\item[true match] string occurs in borrowing language and is a loanword from the donor language;
\item[false match] string occurs in borrowing language by coincidence but it's not a loanword from the donor language;
\item[no match] string does not occur in borrowing language.
\end{description}
For the case of inducing a Moroccan Darija-English translation lexicon via French we start with a French-English bilingual dictionary and take all the French pronunciations in IPA (International Phonetic Alphabet)\footnote{\url{https://en.wikipedia.org/wiki/International_Phonetic_Alphabet}} and convert them to how they would be rendered in Arabic script. For this we created a multiple-step transliteration process:
\begin{description}
\item [Step 1] Break pronunciation into syllables.
\item [Step 2] Convert each IPA syllable to a string in modified Buckwalter transliteration\footnote{The modified version of Buckwalter transliteration, \url{https://en.wikipedia.org/wiki/Buckwalter_transliteration}, replaces special characters such as $<$ and $>$ with alphanumeric characters so that the transliterations are safe for use with other standards such as XML (Extensible Markup Language). For more information see \cite{habash2010}.}, which supports a one-to-one mapping to Arabic script.
\item [Step 3] Convert each syllable's string in modified Buckwalter transliteration to Arabic script.
\item [Step 4] Merge the resulting Arabic script strings for each syllable to generate a candidate loanword string.
\end{description}
For syllabification, for many word pronunciations the syllables are already marked in the IPA by the `.' character; if syllables are not already marked in
the IPA, we run a simple syllabifier to complete step 1.
For step 2, we asked a language expert to give us a sequence of rules to convert a syllable's pronunciation to modified Buckwalter transliteration.
This is itself a multi-step process (see next paragraph for details). In step 3, we simply do the one-to-one conversion and obtain Arabic script for each syllable.
In step 4, we merge the Arabic script for each syllable and get the generated candidate loanword string.
The multi-step process that takes place in step 2 of the process is:
\begin{description}
\item [Step 2.1] Make minor vowel adjustments in certain contexts, e.g., when `a' is between two consonants it is changed to `A'.
\item [Step 2.2] Perform bulk of conversion by using table of mappings from IPA characters to modified Buckwalter characters such as `a'$\rightarrow$`a',`k'$\rightarrow$`k', `y:'$\rightarrow$`iy', etc. that were supplied by a language expert.
\item [Step 2.3] Perform miscellaneous modifications to finalize the modified Buckwalter strings, e.g., if a syllable ends in `a', then append an `A' to that syllable.
\end{description}
The entire conversion process is illustrated in Figure~\ref{f:exampleConversion} for the French word {\em raconteur}.
At the top of the Figure is the IPA from the French dictionary entry with syllables marked.
At the next level, step 1 (syllabification) has been completed.
Step 2.1 doesn't apply to any of the syllables in this word since there are no minor vowel adjustments that are applicable for this word so at the next level
each syllable is shown after step 2.2 has been completed.
The next level shows the syllables after step 2.3 has been completed.
The next level shows after step 3 has been completed and then at the end the strings are merged to form the candidate loanword.
\begin{figure}[t]
\includegraphics[width=\columnwidth]{FrenchToArabic.pdf}
\caption{Example of French to Arabic Process for the French word {\em raconteur}. As discussed in the main text, step 2.1 doesn't apply to this example so it is omitted from the diagram to conserve space. Note that in the final step the word is in order of Unicode codepoints.
Then application software that is capable of processing Arabic will render that as a proper Arabic string in right-to-left order with proper
character joining adjustments as \<راكونتير>} \label{f:exampleConversion}
\end{figure}
\section{Experiments and Discussion} \label{experiments}
In our experiments we extracted a French-English bilingual dictionary using the freely available English Wiktionary dump 20131101 downloaded from
\url{http://dumps.wikimedia.org/enwiktionary}.
From this dump we extracted all the French words, their pronunciations, and their English definitions.
Using the process described in section~\ref{method} to convert each of the French pronunciations into Arabic script yielded 8277 unique loanword candidate strings.
The data used for testing consists of a million lines of user comments crawled from the Moroccan news website \url{http://www.hespress.com}.
The crawled user comments contain Moroccan Darija in heavily code-switched environments. While this makes for a challenging setting, it is a realistic representation of the types of environments in which historically unwritten languages are being written for the first time. The data we used is consistent with well-known code-switching among Arabic speakers, extending spoken discourse into formal writing \cite{bentahila1983,redouane2005}.
The total number of tokens in our Hespress corpus is 18,781,041. We found that 1150 of our 8277 loanword candidates appear in our Hespress corpus. Moreover, more than a million (1169087) loanword candidate instances appear in the corpus. Recall that a match could be a true match that really is a French loanword or a false match that just happens to coincidentally have string equality with words in the borrowing language, but is not a French loanword. False matches are particularly likely to occur for very short words. Accordingly, we filter out candidates that are of length less than four characters. This leaves us with 838 candidates appearing in the corpus and 217616 candidate instances in the corpus. To get an idea of what percentage of our matches are true matches versus false matches, we conducted an annotation exercise with two native Moroccan Darija speakers who also knew at least intermediate French. We pulled a random sample\footnote{We removed 15 Arabic stopwords from our candidate list before pulling the random sample.} of 1185 candidate instances from our corpus and asked each annotator to mark each instance as either:
\begin{description}
\item[A] if the instance is originally from Arabic,
\item[F] if the instance is originally from French, or
\item[U] if they were not sure.
\end{description}
The results are shown in Table~\ref{t:annotationResults}. There are a substantial number of French loanwords that are found. Some examples of translations successfully induced by our method are:
\begin{description}
\item[omelette] \<اومليت>; and
\item[bourgeoisie] \<بورجوازي>.
\end{description}
\begin{table}
\begin{center}
\begin{tabular}{ccccc}
Annotator & Arabic & Unknown & French & Total \\ \hline
A & 907 & 88 & 190 & 1185 \\
B & 812 & 174 & 199 & 1185 \\
\end{tabular}
\end{center}
\caption {Number of word instances annotated.} \label{t:annotationResults}
\end{table}
We hypothesize that our method can help improve machine translation (MT) of historically unwritten dialects with nearly zero resources.
To test this hypothesis, we ran an MT experiment as follows.
First we selected a random set of sentences from the Hespress corpus that each contained at least one candidate instance and had an
MSA/Moroccan Darija/English trilingual translator translate them into English. In total, 273 sentences were translated. This served as our test set.
We trained a baseline MT system using all GALE MSA-English parallel corpora available from the Linguistic Data Consortium (LDC) from 2007 to 2013.\footnote{The LDC catalog numbers for the corpora we used are: LDC2008T09, LDC2007T24, LDC2008T02, LDC2009T09, LDC2009T03, LDC2012T14, LDC2012T06, LDC2012T17, LDC2012T18, LDC2013T01, and LDC2013T14.}
We trained the system using Moses 3.0 with default parameters.
This baseline system achieves BLEU score of 7.48 on our difficult test set of code-switched Moroccan Darija and MSA.
We trained a second system using the parallel corpora with our induced Moroccan Darija-English translation lexicon appended to the end of the training data. This time the BLEU score increased to 8.11, a gain of .63 BLEU points.
\section{Conclusions} \label{conclusions}
With the explosive growth of informal textual electronic communications such as social media, web comments, etc., many colloquial everyday languages that were historically unwritten are now
being written for the first time often in heavily code-switched text with traditionally written languages. The new written versions of these languages pose significant
challenges for multilingual processing technology due to Out-Of-Vocabulary (OOV) challenges. Yet it is relatively common that these historically unwritten languages borrow significant amounts of vocabulary from relatively well resourced written languages.
We presented a method for translation lexicon induction via loanwords for alleviating the OOV challenges in these settings where the borrowing language has extremely limited
amounts of resources available, in many cases not even substantial amounts of monolingual data that is typically exploited by previous cognates and loanword detection methods
to induce translation lexicons. This paper demonstrates induction of a Moroccan Darija-English translation lexicon via bridging French loanwords using the method and in MT experiments, the addition of the induced Moroccan Darija-English lexicon increased system performance by .63 BLEU points.
\section*{Acknowledgments}
We would like to thank Tim Buckwalter for his support and for providing us with the initial mapping of IPA syllables to their corresponding Arabic orthographies as well as the contextual adjustment rules that we used in our experiments.
| {'timestamp': '2017-08-22T02:07:39', 'yymm': '1706', 'arxiv_id': '1706.01570', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01570'} | arxiv |
\section{Introduction}
Summarization of large texts is still an open problem in language processing. People nowadays have lesser time and patience to go through large pieces of text which make automatic summarization important. Automatic summarization has significant applications in summarizing large texts like stories, journal papers, news articles and even larger texts like books.
Existing methods for summarization can be broadly categorized into two categories \textit{Extractive} and \textit{Abstractive}. Extractive methods picks up words and sometimes directly sentences from the text. These methods are inherently limited in the sense that they can never generate human level summaries for large and complicated documents which require rephrasing sentences and incorporating information from full text to generate summaries. Most of the work done on summarization in past has been extractive.
On the other hand most Abstractive methods take advantages of the recent developments in deep learning. Specifically the recent success of the sequence to sequence learning models where recurrent networks read the text, encodes it and then generate target text. Though these methods have recently shown to be competitive with the extractive methods they are still far away from reaching human level quality in summary generation.
The work on summarization using AMR was started by ~\citet{AMR_Summarization}. Abstract Meaning Representation (AMR) was as introduced by ~\citet{AMR}. AMR focuses on capturing the meaning of the text, by giving a specific meaning representation to the text. AMR tries to capture the \textit{"who is doing what to whom"} in a sentence. The formalism aims to give same representation to sentences which have the same underlying meaning. For example \textit{"He likes apple"} and \textit{"Apples are liked by him"} should be assigned the same AMR.
~\citet{AMR_Summarization}'s approach aimed to produce a summary for a story by extracting a summary subgraph from the story graph and finally generate a summary from this extracted graph. But, because of the unavailability of AMR to text generator at that time their work was limited till extracting the summary graph. This method extracts a single summary graph from the story graph. Extracting a single summary graph assumes that all of the important information from the graph can be extracted from a single subgraph. But, it can be difficult in cases where the information is spread out in the graph. Thus, the method compromises between size of the summary sub-graph and the amount of information it can extract. This can be easily solved if instead of a single sub-graph, we extract multiple subgraphs each focusing on information in a different part of the story.
We propose a two step process for extracting multiple summary graphs. First step is to select few sentences from the story. We use the idea that there are only few sentences that are important from the point of view of summary, i.e. most of the information contained in the summary is present in very few sentences and they can be used to generate the summary. Second step is to extract important information from the selected sentences by extracting a sub-graph from the selected sentences.
Our main contributions in this work are three folds,
\begin{itemize}
\item We propose a full-fledged pipeline for text summarization, providing strong baseline for future work on summarization using AMR.
\item Present a novel approach for extracting multiple summary graphs that outperforms the previous methods based on a single sub-graph extraction.
\item Expose some problems with existing evaluation methods and datasets for abstractive summarization.
\end{itemize}
The rest of the paper is organized as follows. Section~\ref{sec:2} contains introduction to AMR, section~\ref{sec:3} and~\ref{sec:4} contains the datasets and the algorithm used for summary generation respectively. Section~\ref{sec:5} has a detailed step-by-step evaluation of the pipeline and in section~\ref{sec:6} we discuss the problems with the current dataset and evaluation metric.
\begin{figure}
\centering
\includegraphics[scale=0.4,keepaspectratio]{example}
\label{exmfig}
\caption{The graphical representation of the AMR graph of the sentence : \textit{"I looked carefully all around me"} using AMRICA}
\label{fig:1}
\end{figure}
\section{Background: AMR Parsing and Generation}
\label{sec:2}
AMR was introduced by ~\citet{AMR} with the aim to induce work on statistical Natural Language Understanding and Generation. AMR represents meaning using graphs. AMR graphs are rooted, directed, edge and vertex labeled graphs. Figure~\ref{fig:1} shows the graphical representation of the AMR graph of the sentence \textit{"I looked carefully all around me"} generated by JAMR parser (~\citet{JAMR}). The graphical representation was produced using AMRICA ~\citet{AMRICA}. The nodes in the AMR are labeled with \textit{concepts} as in Figure~\ref{fig:1} \textit{around} represents a concept. Edges contains the information regarding the \textit{relations} between the concepts. In Figure~\ref{fig:1} \textit{direction} is the relation between the concepts \textit{look-01} and \textit{around}. AMR relies on Propbank for semantic relations (edge labels). Concepts can also be of the form \textit{run-01} where the index \textit{01} represents the first sense of the word \textit{run}. Further details about the AMR can be found in the AMR guidelines ~\citet{AMR-Guidelines}.
A lot of work has been done on parsing sentences to their AMR graphs. There are three main approaches to parsing. There is alignment based parsing ~\citet{JAMR} (JAMR-Parser), ~\citet{ZJAMR} which uses graph based algorithms for concept and relation identification. Second, grammar based parsers like ~\citet{CAMR} (CAMR) generate output by performing shift reduce transformations on output of a dependency parser. Neural parsing ~\citet{Neural_AMR,data_sparsity} is based on using \textit{seq2seq} models for parsing, the main problem for neural methods is the absence of a huge corpus of human generated AMRs. ~\citet{data_sparsity} reduced the vocabulary size to tackle this problem while ~\citet{Neural_AMR} used larger external corpus of external sentences.
Recently, some work has been done on producing meaningful sentences form AMR graphs. ~\citet{JAMR} used a number of tree to string conversion rules for generating sentences. ~\citet{song} reformed the problem as a traveling salesman problem. ~\citet{Neural_AMR} used \textit{seq2seq} learning methods.
\section{Datasets}
\label{sec:3}
We used two datasets for the task - AMR Bank ~\citet{AMR_Bank} and CNN-Dailymail (~\cite{cnn_dm} ~\cite{Abstractive_Text_Summarization}). We use the proxy report section of the AMR Bank, as it is the only one that is relevant for the task because it contains the gold-standard (human generated) AMR graphs for news articles, and the summaries. In the training set the stories and summaries contain 17.5 sentences and 1.5 sentences on an average respectively. The training and test sets contain 298 and 33 summary document pairs respectively.
CNN-Dailymail corpus is better suited for summarization as the average summary size is around 3 or 4 sentences. This dataset has around 300k document summary pairs with stories having 39 sentences on average. The dataset comes in 2 versions, one is the anonymized version, which has been preprocessed to replace named entities, e.g., \textit{The Times of India}, with a unique identifier for example \textit{@entity1}. Second is the non-anonymized which has the original text. We use the non-anonymized version of the dataset as it is more suitable for AMR parsing as most of the parsers have been trained on non-anonymized text. The dataset does not have gold-standard AMR graphs. We use automatic parsers to get the AMR graphs but they are not gold-standard and will effect the quality of final summary. To get an idea of the error introduced by using automatic parsers, we compare the results after using gold-standard and automatically generated AMR graphs on the gold-standard dataset.
\section{Pipeline for Summary Generation}
\label{sec:4}
The pipeline consists of three steps, first convert all the given story sentences to there AMR graphs followed by extracting summary graphs from the story sentence graphs and finally generating sentences from these extracted summary graphs. In the following subsections we explain each of the methods in greater detail.
\subsection{Step 1: Story to AMR}
As the first step we convert the story sentences to their Abstract Meaning Representations. We use JAMR-Parser version 2 \citet{JAMR} as it’s openly available and has a performance close to the state of the art parsers for parsing the CNN-Dailymail corpus. For the AMR-bank we have the gold-standard AMR parses but we still parse the input stories with JAMR-Parser to study the effect of using graphs produced by JAMR-Parser instead of the gold-standard AMR graphs.
\subsection{Step 2: Story AMR to Summary AMR}
After parsing (Step 1) we have the AMR graphs for the story sentences. In this step we extract the AMR graphs of the summary sentences using story sentence AMRs. We divide this task in two parts. First is finding the important sentences from the story and then extracting the key information from those sentences using their AMR graphs.
\subsubsection{Selecting Important Sentences}
\label{ssec:impsnt}
\begin{figure}
\includegraphics[scale=0.4,keepaspectratio]{imp_sent_hypothesis_dailymail_5000_figure_1}
\caption{\label{graph}Graph of the best Rogue-1 recall scores for 5000 summaries (around 20000 sentences) in the CNN-Dailymail corpus. Y-axis is the ROGUE score and X-axis is the cumulative percentage of sentence with the corresponding score}
\end{figure}
Our algorithm is based on the idea that only few sentences are important from the point of view of summary i.e. there are only a few sentences which contain most of the important information and from these sentences we can generate the summary.
\textbf{Hypothesis:} Most of the information corresponding to a summary sentence can be found in only one sentence from the story.
To test this hypothesis, for each summary sentence we find the sentence from the story that contains maximum information of this summary sentence. We use ROGUE-1 ~\citet{ROGUE} Recall scores (measures the ratio of number of words in the target summary that are contained in the predicted summary to the total number of words in the target summary) as the metric for the information contained in the story sentence. We consider the story sentence as the predicted summary and the summary sentence as the target summary. The results that we obtained for 5000 randomly chosen document summary pairs from the CNN-Dailymail corpus are given in figure~\ref{graph}. The average recall score that we obtained is 79\%. The score will be perfectly 1 when the summary sentence is directly picked up from a story sentence. Upon manual inspection of the summary sentence and the corresponding best sentence from the story we realized, when this score is more than 0.5 or 0.6, almost always the information in the summary sentence is contained in this chosen story sentence. The score for in these cases is not perfectly 1 because of stop words and different verb forms used in story and summary sentence. Around 80\% of summary sentences have score above 0.5. So, our hypothesis seems to be correct for most of the summary sentences. This also suggests the highly extractive nature of the summary in the corpus.
Now the task in hand is to select few important sentences. Methods that use sentence extraction for summary generation can be used for the task. It is very common in summarization tasks specifically in news articles that a lot of information is contained in the initial few sentences. Choosing initial few sentences as the summary produces very strong baselines which the state-of-the-art methods beat only marginally. Ex. On the CNN-Dailymail corpus the state-of-the-art extractive method beats initial 3 sentences only by 0.4\% as reported by ~\cite{summarunner}.
\blfootnote{Note that methods \textit{first-n} and \textit{first co-occurrence+first} are by default followed by the summary graph extraction step and they are not just sentence selection methods.}
Using this idea of picking important sentences from the beginning, we propose two methods, first is to simply pick initial few sentences, we call this \textit{first-n} method where n stands for the number of sentences. We pick initial 3 sentences for the CNN-Dailymail corpus i.e. \textit{first-3} and only the first sentence for the proxy report section (AMR Bank) i.e. \textit{first-1} as they produce the best scores on the ROGUE metric compared to any other \textit{first-n}. Second, we try to capture the relation between the two most important entities (we define importance by the number of occurrences of the entity in the story) of the document. For this we simply find the first sentence which contains both these entities. We call this the \textit{first co-occurrence} based sentence selection. We also select the first sentence along with \textit{first co-occurrence} based sentence selection as the important sentences. We call this the \textit{first co-occurrence+first} based sentence selection.
\subsubsection{Extracting Summary Graph}
\label{ssec:extract-AMR}
As the datasets under consideration are news articles. The most important information in them is about an entity and a verb associated with it. So, to extract important information from the sentence. We try to find the entity being talked about in the sentence, we consider the most referred entity (one that occurs most frequently in the text), now for the main verb associated with the entity in the sentence, we find the verb closest to this entity in the AMR graph. We define the closest verb as the one which lies first in the path from the entity to the root.
We start by finding the position of the most referred entity in the graph, then we find the closest verb to the entity. and finally select the subtree hanging from that verb as the summary AMR.
\subsection{Step 3: Summary Generation}
To generate sentences from the extracted AMR graphs we can use already available generators. We use Neural AMR (~\citet{Neural_AMR}) as it provides state of the art results in sentence generation. We also use ~\citet{JAMR2} (JAMR-Generator) in one of the experiments in the next section. Generators significantly effect the results, we will analyze the effectiveness of generator in the next section.
\section{Results and Analysis}
\label{sec:5}
\subsection{Baselines}
\label{ssec:baselines}
\label{ssec:evaluation}
\begin{table*}[h]
\centering
\caption{\label{proxy-section-results}Comparison with previous methods and baselines. This table reports ROGUE scores on the proxy report section using alignment based generator.}
\vspace{1.5mm}
\begin{tabular}{c|c|c|c}
\hline
Method & Rogue-1 Recall & Rogue-1 Precision & Rogue-1 $F_{1}$\\
\hline
~\citet{AMR_Summarization} & 51.9 & 39.0 & 44.3 \\
Lead-1-AMR & 50.4 & 57.5 & 51.0 \\
fist co-occurrence + first & ~\textbf{52.4} & 55.7 & \textbf{51.3}\\
first-1 & 49.1 & \textbf{60.1} & 51.2\\
\hline
\end{tabular}
\end{table*}
\begin{table*}[h]
\centering
\caption{\label{final-results}Table for analyzing the effect of using JAMR-Parser in step-1. This table has ROGUE scores after using Neural AMR for sentence generation i.e. step-3. First half contains scores by using gold-standard AMR graphs, second half has AMR graphs generated by JAMR-Parser}
\vspace{2.0mm}
\begin{tabular}{c|c|c|c|c|c}
\hline
Method & Rogue-1 Recall & Rogue-1 Precision & Rogue-1 $F_{1}$ & Rogue-2 & Rogue-L\\
\hline
\multicolumn{6}{c}{Using gold-standard AMR in step-1}\\
\cline{1-6}
Lead-1-AMR & 46.8 & 49.0 & 45.5 & 21.5 & \textbf{35.2} \\
first co-occurrence + first & \textbf{49.5} & 48.1 & \textbf{46.3} & 21.7 & 34.7 \\
first-1 & 45.9 & \textbf{51.4} & 45.9 & \textbf{21.9} & 35.0 \\
\cline{1-6}
\multicolumn{6}{c}{Using JAMR-Parser for step-1}\\
\cline{1-6}
Lead-1-AMR & 43.7 & 44.7 & \textbf{41.4} & 16.2 & \textbf{28.3} \\
first co-occurrence + first & \textbf{44.5} & 42.4 & 40.0 & \textbf{17.0} & 27.5 \\
first-1 & 41.1 & \textbf{45.4} & 40.1 & 15.3 & 28.2 \\
\cline{1-6}
\hline
\end{tabular}
\end{table*}
In this section, we present the baseline models and analysis method used for each step of our pipeline.
For the CNN-Dailymail dataset, the Lead-3 model is considered a strong baseline; both the abstractive ~\cite{deep_rl} and extractive ~\cite{summarunner} state-of-the art methods on this dataset beat this baseline only marginally. The Lead-3 model simply produces the leading three sentences of the document as its summary.
The key step in our pipeline is step-2 i.e. summary graph extraction.
Directly comparing the Lead-3 baseline, with AMR based pipeline to evaluate the effectiveness of step-2 is an unfair comparison because of the errors introduced by imperfect parser and generator in the AMR pipeline. Thus to evaluate the effectiveness of step-2 against Lead-3 baseline, we need to nullify the effect of errors introduce by AMR parser and generator. We achieve this by trying to introduce similar errors in the leading thre sentences of each document. We generate the AMR graphs of the leading three sentences and then generate the sentences using these AMR graph. We use parser and generator that were used in our pipeline. We consider these generated sentences as the new baseline summary, we shall now refer to it \textit{Lead-3-AMR} baseline in the remaining of the paper.
For the proxy report section of the AMR bank, we consider the \textit{Lead-1-AMR} model as the baseline. For this dataset we already have the gold-standard AMR graphs of the sentences. Therefore, we only need to nullify the error introduced by the generator.
\subsection{Procedure to Analyze and Evaluate each step}
For the evaluation of summaries we use the standard ROGUE metric. For comparison with previous AMR based summarization methods, we report the \textit{Recall}, \textit{Precision} and \textit{$F_{1}$} scores for ROGUE-1. Since most of the literature on summarization uses \textit{$F_{1}$} scores for ROGUE-2 and ROGUE-L for comparison, we also report \textit{$F_{1}$} scores for ROGUE-2 and ROGUE-L for our method. ROGUE-1 Recall and Precision are measured for uni-gram overlap between the reference and the predicted summary. On the other hand, ROGUE-2 uses bi-gram overlap while ROGUE-L uses the longest common sequence between the target and the predicted summaries for evaluation. In rest of this section, we provide methods to analyze and evaluate our pipeline at each step.
\textbf{Step-1: AMR parsing} To understand the effects of using an AMR parser on the results, we compare the final scores after the following two cases- first, when we use the gold-standard AMR graphs and second when we used the AMR graphs generated by JAMR-Parser in the pipeline. Section~\ref{ssec:jamr_effect} contains a comparison between the two.
\textbf{Step-2: Summary graph extraction} For evaluating the effectiveness of the summary graph extraction step we compare the final scores with the \textit{Lead-n-AMR} baselines described in section~\ref{ssec:baselines}.
In order to compare our summary graph extraction step with the previous work (~\citet{AMR_Summarization}), we generate the final summary using the same generation method as used by them. Their method uses a simple module based on alignments for generating summary after step-2. The alignments simply map the words in the original sentence with the node or edge in the AMR graph. To generate the summary we find the words aligned with the sentence in the selected graph and output them in no particular order as the predicted summary. Though this does not generate grammatically correct sentences, we can still use the ROGUE-1 metric similar to ~\citet{AMR_Summarization}, as it is based on comparing uni-grams between the target and predicted summaries.
\textbf{Step-3: Generation} For evaluating the quality of the sentences generated by our method, we compare the summaries generated by the first-1 model and Lead-1-AMR model on the gold-standard dataset. However, when we looked at the scores given by ROGUE, we decided to do get the above summaries evaluated by humans. This produced interesting results which are given in more detail in section~\ref{ssec:generator_effect}.
\subsection{Results on the Proxy report section}
\begin{table*}[h]
\centering
\caption{\label{human_evaluation}Comparion of the scores given by ROGUE and human evaluators on different models. Scores suggest that Rogue don't co-relate with the human evaluators}
\vspace{1.5mm}
\begin{tabular}{c|c|c|c|c|c|c}
\hline
Parser & Generator & Information contained & Readability & R-1 & R-2 & R-L \\
\hline
gold & jamr & 5.24 & 5.48 & 43.3 & 16.3 & 29.9 \\
jamr & neural & 4.52 & 7.04 & 47.7 & 19.0 & 32.9 \\
gold & neural & 6.19 & \textbf{7.88} & 49.7 & 25.0 & 38.0 \\
\hline
\multicolumn{2}{c|}{original sentence} & \textbf{6.88} & 7.4 & \textbf{62.6} & \textbf{48.6} & \textbf{54.7}\\
\hline
\end{tabular}
\end{table*}
\begin{table*}[h]
\centering
\caption{\label{fig:CNN-Results}Results on CNN-Dailymail corpus. Table has 2 parts. First part contains baselines, our method and the state-of-the-art on the non-anonymized dataset, second part has scores on the anonymized dataset.}
\vspace{1.5mm}
\begin{tabular}{c|c|c|c|c|c}
\hline
Method & \multicolumn{5}{c}{ROGUE} \\
\cline{2-6}
& 1 Recall & 1 Precision & 1 & 2 & L \\
\hline
Lead-3-AMR (baseline) & 40.4 & 27.8 & 31.7 & 5.8 & 16.8 \\
first-3 & 38.1 & 28.8 & 31.6 & 5.7 & 16.9 \\
Lead-3 (non-anonymized) ~\cite{pointer-generator} &-&- &40.34 &17.70 &36.57\\
pointer-generator + coverage ~\cite{pointer-generator} &- &- &39.53 &17.28&36.38 \\
\hline
Lead-3 (anonymized) ~\cite{summarunner} &- &- &39.2 &15.7 &35.5 \\
RL, with intra-attention ~\cite{deep_rl} &-&- &41.16 &15.75 &39.08 \\
\hline
\end{tabular}
\end{table*}
In table~\ref{proxy-section-results} we report the results of using the pipeline with generation using the alignment based generation module defined in section~\ref{ssec:evaluation}, on the proxy report section of the AMR Bank. All of our methods out-perform ~\citet{AMR_Summarization}'s method. We obtain best ROGUE-1 $F_{1}$ scores using the ~\textit{first co-occurrence+first} model for important sentences. This also out-perform our ~\textit{Lead-1-AMR} baseline by 0.3 ROGUE-1 $F_{1}$ points.
\subsection{Effects of using JAMR Parser}
\label{ssec:jamr_effect}
In this subsection we analyze the effect of using JAMR parser for step-1 instead of the gold-standard AMR graphs. First part of table~\ref{final-results} has scores after using the gold-standard AMR graphs. In the second part of table~\ref{final-results} we have included the scores of using the JAMR parser for AMR graph generation. We have used the same Neural AMR for sentence generation in all methods. Scores of all methods including the ~\textit{Lead-1-AMR} baseline have dropped significantly.
The usage of JAMR Parser has affected the scores of \textit{first co-occurrence+first} and \textit{first-1} more than that for the \textit{Lead-1-AMR}. The drop in ROGUE $F_{1}$ score when we use \textit{first co-occurrence+first} is around two ROGUE $F_{1}$ points more than when \textit{Lead-1-AMR}. This is a surprising result, and we believe that it is worthy of further research.
\subsection{Effectiveness of the Generator}
\label{ssec:generator_effect}
In this subsection we evaluate the effectiveness of the sentence generation step. For fair comparison at the generation step we use the gold-standard AMRs and don't perform any extraction in step-2 instead we use full AMRs, this allows to remove any errors that might have been generated in step-1 and step-2. In order to compare the quality of sentences generated by the AMR, we need a gold-standard for sentence generation step. For this, we simply use the original sentence as gold-standard for sentence generation. Thus, we compare the quality of summary generated by \textit{Lead-1} and \textit{Lead-1-AMR}. The scores using the ROGUE metric are given in bottom two rows of table~\ref{human_evaluation}. The results show that there is significant drop in \textit{Lead-1-AMR} when compared to \textit{Lead-1}.
We perform human evaluation to check whether the drop in ROGUE scores is because of drop in information contained, and human readability or is it because of the inability of the ROGUE metric to judge. To perform this evaluation we randomly select ten test examples from the thirty- three test cases of the proxy report section. For each example, we show the summaries generated by four different models side by side to the human evaluators. The human evaluator does not know which summaries come from which model. A score from 1 to 10 is then assigned to each summary on the basis of \textit{readability}, and \textit{information contained} of summary, where 1 corresponds to the lower level and 10 to the highest. In table~\ref{human_evaluation} we compare the scores of these four cases as given by ROGUE along with human evaluation. The parser-generator pairs for the four cases are gold-JAMR(generator), JAMR(parser)-neural, gold-neural, and the original sentence respectively. Here gold parser means that we have used the gold-standard AMR graphs.
The scores given by the humans do not correlate with ROGUE. Human evaluators gives almost similarly scores to summary generated by the \textit{Lead-1} and \textit{Lead-1-AMR} with \textit{Lead-1-AMR} actually performing better on \textit{readability} though it dropped some information as clear from the scores on \textit{information contained}. On the other hand, ROGUE gives very high score to Lead-1 while models 1,2 and 4 get almost same scores. The similar scores of model 2 and 3 shows that generators are actually producing meaningful sentences. Thus the drop in ROGUE scores is mainly due to the inability of the ROGUE to evaluate abstractive summaries. Moreover, the ROGUE gives model 4 higher score compared to model 1 while human evaluators give the opposite scores on ~\textit{information contained} in the sentence.
A possible reason for the inability of the ROGUE metric to properly evaluate the summaries generated by our method might be due to its inability to evaluate restructured sentences. AMR formalism tries to assign the same AMR graphs to the sentences that have same meaning so there exists a one-to-many mapping from AMR graphs to sentences. This means that the automatic generators that we are using might not be trying to generate the original sentence; instead it is trying to generate some other sentence that has the same underlying meaning. This also helps in explaining the low ROGUE-2 and ROGUE-L scores. If the sentences might be getting rephrased, they would loose most of the bi- and tri-grams from the original sentence resulting in low ROGUE-2 and ROGUE-L scores.
\subsection{Analyzing the effectiveness of AMR extraction}
The aim of extracting summary graphs from the AMR graphs of the sentence is to drop the not so important information from the sentences. If we are able to achieve this perfectly, the ROGUE-1 Recall scores that we are getting should remain almost the same (since we are not add any new information) and the ROGUE-1 precision should go up (as we have thrown out some useless information); thus effectively improving the overall ROGUE-1 $F_{1}$ score. In the first two rows of table ~\ref{final-results} we have the scores after using the full-AMR and extracted AMR for generation respectively. It is safe to say that extracting the AMR results in improved ROGUE-1 precision whereas ROGUE-1 Recall reduces only slightly, resulting in an overall improved ROGUE-1 $F_{1}$.
\subsection{Results on the CNN-Dailymail corpus}
In table~\ref{fig:CNN-Results} we report the results on the CNN-Dailymail corpus. We present scores by using the \textit{first-3} model. The first row contains the \textit{Lead-3-AMR} baseline. The results we achieve are competitive with the \textit{Lead-3-AMR} baseline. The rest of the table contains scores of Lead-3 baseline followed by the state-of-the-art method on the anonymized and non-anonymized versions of the dataset. The drop in the scores from the Lead-3(non-anonymized) to \textit{Lead-3-AMR} is significant and is largely because of the error introduced by parser and generator.
\section{Related Work and Discussion}
\label{sec:6}
\subsection{Related Work}
~\citet{tac2008} showed that most of the work in text summarization has been extractive, where sentences are selected from the text which are then concatenated to form a summary. ~\citet{Vanderwende2004} transformed the input to nodes, then used the Pagerank algorithm to score nodes, and finally grow the nodes from high-value to low-value using some heuristics. Some of the approaches combine this with sentence compression, so more sentences can be packed in the summary. ~\citet{raynmcd2007}, ~\citet{Martins2009}, ~\citet{Almeida2013}, and ~\citet{Gillick2009} among others used ILPs and approximations for encoding compression and extraction.
Recently some abstractive approaches have also been proposed most of which used sequence to sequence learning models for the task. ~\cite{neural_attention}, ~\cite{neural_attention_sentence}, ~\cite{Abstractive_Text_Summarization}, ~\cite{pointer-generator} used standard encoder-decoder models along with their variants to generate summaries. ~\cite{NeuralheadlineAMR} incorporated the AMR information in the standard encoder-decoder models to improve results. Our work in similar to other graph based abstractive summarization methods ~\cite{Penn2014} and ~\citet{Gerani2014}. ~\cite{Penn2014} used dependency parse trees to produce summaries. On the other hand our work takes advantage of semantic graphs.
\subsection{Need of an new Dataset and Evaluation Metric}
\label{ssec:rogue_problems}
ROGUE metric, by it is design has lots of properties that make it unsuitable for evaluating abstractive summaries. For example, ROGUE matches exact words and not the stems of the words, it also considers stop words for evaluation. One of the reasons why ROGUE like metrics might never become suitable for evaluating abstractive summaries is its incapabilities of knowing if the sentences have been restructured. A good evaluation metric should be one where we compare the meaning of the sentence and not the exact words. As we showed section ~\ref{ssec:generator_effect} ROGUE is not suitable for evaluating summaries generated by the AMR pipeline.
We now show why the CNN-Dailymail corpus is not suitable for Abstractive summarization. The nature of summary points in the corpus is highly extractive (Section ~\ref{ssec:impsnt} for details) where most of the summary points are simply picked up from some sentences in the story. Tough, this is a good enough reason to start searching for better dataset, it is not the biggest problem with the dataset. The dataset has the property that a lot of important information is in the first few sentences and most of the summary points are directly pick from these sentences. The extractive methods based on sentence selection like SummaRunNer are not actually performing well, the results they have got are only slightly better than the Lead-3 baseline. The work doesn't show how much of the selected sentences are among the first few and it might be the case that the sentences selected by the extractive methods are mostly among the first few sentences, the same can be the problem with the abstractive methods, where most the output might be getting copied from the initial few sentences.
These problems with this corpus evoke the need to have another corpus where we don't have so much concentration of important information at any location but rather the information is more spread out and the summaries are more abstractive in nature.
\section{Possible Future Directions}
As this proposed algorithm is a step by step process we can focus on improving each step to produce better results. The most exciting improvements can be done in the summary graph extraction method. Not a lot of work has been done to extract AMR graphs for summaries. In order to make this pipeline generalizable for any sort of text, we need to get rid of the hypothesis that the summary is being extracted exactly from one sentence. So, the natural direction seems to be joining AMR graphs of multiple sentences that are similar and then extracting the summary AMR from that large graph. It will be like clustering similar sentences and then extracting a summary graph from each of these cluster. Another idea is to use AMR graphs for important sentence selection.
\section{Conclusion}
In this work we have explored a full-fledged pipeline using AMR for summarization for the first time. We propose a new method for extracting summary graph, which outperformed previous methods. Overall we provide strong baseline for text summarization using AMR for possible future works. We also showed that ROGUE can't be used for evaluating the abstractive summaries generated by our AMR pipeline.
| {'timestamp': '2017-07-19T02:02:19', 'yymm': '1706', 'arxiv_id': '1706.01678', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01678'} | arxiv |
\section{Introduction}
\vspace{-0.10cm}
\todo{Need motivating sentence.}
Chemical space is huge: it is estimated to contain over $10^{60}$ molecules.
Among these, fewer than 100 million compounds can be found in public
repositories or databases \cite{Reymond_2012}. This discrepancy between
\textit{known} compounds and \textit{possible} compounds
indicates the potential for discoverying many new compounds with highly desirable functionality
(e.g., new energy materials, pharmaceuticals, dyes, etc.). While the
vast size of chemical space makes this an enormous opportunity, it also
presents a significant difficulty in the identification of new relevant
compounds among the many unimportant ones. This challenge is so great that any
discovery process relying purely on the combination of scientific intuition
with trial and error experimentation is slow, tedious and in many cases
infeasible.
To accelerate the search, high-throughput approaches can be used in a
combinatorial exploration of small specific areas of chemical space
\cite{Rajan_2008}. These have led to the development of high-throughput virtual
screening \cite{Pyzer_Knapp_2015,G_mez_Bombarelli_2016} in which large
libraries of molecules are created and then analyzed using theoretical and
computational techniques, typically by running a large number of parallel
simulations in a computer cluster. The objective is to reduce an initially very
large library of molecules to a small set of promising leads for which expensive experimental evaluation is justified. However, even though these techniques only search
a tiny drop in the ocean of chemical space, they can result in massive
libraries
whose magnitude exceeds traditional computational capabilities. As a result,
at present, there is an urgent need to accelerate high-throughput screening
approaches.
Bayesian optimization (BO) \cite{jones1998efficient} can speed up the discovery
process by using machine learning to guide the search and make improved
decisions about what molecules to analyze next given the data collected so far. \todo{This really needs to connect with the larger literature on Bayesian optimal experimental design.}
However, current BO methods cannot scale to the large number of parallel
measurements and the massive libraries of candidate molecules currently used in
high-throughput screening \cite{Pyzer_Knapp_2015}. \todo{Explain why BO doesn't scale.} While there are BO methods that
allow parallel data collection, these methods have typically been limited to tens of data points per batch
\cite{snoek2012practical,shahriari2014entropy,GonDaiHenLaw16}. In contrast,
high-throughput screening may allow the simultaneous collection of thousands
of data points via large-scale parallel computation. This creates a need for new scalable methods for parallel Bayesian optimization.
To address the above difficulty, we present here a scalable solution for
parallel Bayesian optimization based on a distributed implementation of the
Thompson sampling heuristic \cite{Thompson_1933,Chapelle2011}. We show that,
for the case of small batch sizes, the proposed parallel and distributed
Thompson sampling (PDTS) method performs as well as a parallel implementation
of expected improvement (EI) \cite{snoek2012practical,ginsbourger2011dealing},
the most widely used Bayesian optimization heuristic. Parallel EI selects the batch entries sequentially and so EI proposals can't be parallelized, which limits its scalability properties. PDTS generates each batch of evaluation locations by selecting the
different batch entries independently and in parallel. Consequently, PDTS is highly scalable and applicable to large batch sizes.
We also evaluate the performance of PDTS in several real-world high-throughput screening
experiments for material and drug discovery, where parallel EI is infeasible. In these problems, PDTS
outperforms other scalable baselines such as a greedy search strategy,
$\epsilon$-greedy approaches and a random search method.
These results indicate
that PDTS is a successful solution for large-scale parallel Bayesian
optimization.
\begin{algorithm}
\caption{Sequential Thompson sampling} \label{alg:seq_thompson_sampling}
\begin{algorithmic}
\STATE {\bfseries Input:} initial data $\mathcal{D}_{\mathcal{I}(1)}=\{ (\mathbf{x}_i, y_i) \}_{i\in \mathcal{I}(1)}$
\FOR{$t=1$ {\bfseries to} $T$}
\STATE Compute current posterior $p(\bm \theta|\mathcal{D}_{\mathcal{I}(t)})$
\STATE Sample $\bm \theta$ from $p(\bm \theta|\mathcal{D}_{\mathcal{I}(t)})$
\STATE Select $k\leftarrow \text{argmax}_{j \not \in {\mathcal{I}(t)}} \mathbf{E}[y_j|\mathbf{x}_j,\bm \theta]$
\STATE Collect $y_k$ by evaluating $f$ at $\mathbf{x}_k$
\STATE $\mathcal{D}_{\mathcal{I}(t+1)}\leftarrow \mathcal{D}_{\mathcal{I}(t)}\cup \{(\mathbf{x}_k,y_k)\}$
\ENDFOR
\end{algorithmic}
\end{algorithm}
\begin{figure}
\centering
\includegraphics[width=0.9\columnwidth]{small_figure.pdf}
\caption{Illustration of Thompson sampling and PDTS.}
\vspace{-0.5cm}
\label{fig:illustration_thompson_sampling}
\end{figure}
\vspace{-0.2cm}
\section{BO and Thompson Sampling}
\vspace{-0.1cm}
Let us assume we have a large library of candidate molecules
${\mathcal{M}=\{ m_1,\ldots,m_{|\mathcal{M}|}\}}$. Our goal is to identify a
small subset of elements ${\{m_i\} \subset \mathcal{M}}$ for which the $f(m_i)$ are as high as
possible, with $f$ being an expensive-to-evaluate objective function. The objective $f$ could be, for example, an estimate of the
power-conversion efficiency of organic photovoltaics, as given by expensive
quantum mechanical simulations \cite{ADMA200501717}, and we may want to identify the top 1\% elements in $\mathcal{M}$
according to this score.
Bayesian optimization methods can be used to identify the inputs that maximize
an expensive objective function $f$ by performing only a reduced number of
function evaluations. For this, BO uses a model to make predictions for the
value of $f$ at new inputs given data from previous evaluations. The next point
to evaluate is then chosen by maximizing an acquisition function that
quantifies the benefit of evaluating the objective at a particular location.
Let $\mathbf{x}_1,\ldots,\mathbf{x}_{|\mathcal{M}|}$ be $D$-dimensional feature
vectors for the molecules in~$\mathcal{M}$ and let~${\mathcal{D}_\mathcal{I}=\{
(\mathbf{x}_i, y_i): i\in I \}}$ be a dataset with information about past
evaluations, where~$I$ is a set with the indices of the molecules already
evaluated,~$\mathbf{x}_i$ is the feature vector for the $i$-th molecule in~$\mathcal{M}$ and~${y_i = f(m_i)}$ is the result of evaluating the objective
function $f$ on that molecule. We assume that the evaluations of $f$ are
noise free, however, the methods described here can be applied to the
case in which the objective evaluations are corrupted with additive Gaussian
noise. BO typically uses a probabilistic model to
describe how the~$y_i$ in~$\mathcal{D}_\mathcal{I}$ are generated as a function of the
corresponding features~$\mathbf{x}_i$ and some model parameters~$\bm \theta$,
that is, the model specifies~$p(y_i|\mathbf{x}_i,\bm\theta)$.
Given the data~$\mathcal{D}_\mathcal{I}$ and a prior distribution~$p(\bm \theta)$, the
model also specifies a posterior distribution~${p(\bm \theta
|\mathcal{D}_\mathcal{I})\propto p(\bm\theta)\prod_{i \in I}
p(y_i|\mathbf{x}_i,\bm\theta)}$.
The predictive distribution for
any~${m_j\in\mathcal{M}\setminus \{m_i : i \in I\}}$ is then given by~${p(y_j|\mathbf{x}_j,\mathcal{D}_\mathcal{I})=\int p(y_j|\mathbf{x}_j,\bm\theta)p(\bm \theta
|\mathcal{D}_\mathcal{I})\,d\bm\theta}$.
BO methods use this predictive distribution to
compute an acquisition function (AF) given by
\vspace{-0.4cm}
{\small
\begin{equation}
\alpha(\mathbf{x}_j|\mathcal{D}_\mathcal{I}) =
\mathbf{E}_{p(y_j|\mathbf{x}_j,\mathcal{D}_\mathcal{I})} \left[ U(y_j|\mathbf{x}_j,\mathcal{D}_\mathcal{I}) \right]\,,\label{eq:AF}
\end{equation}}where $U(y_j|\mathbf{x}_j,\mathcal{D}_\mathcal{I})$ is the utility of obtaining value~$y_j$ when evaluating~$f$ at~$m_j$. Eq.~(\ref{eq:AF}) is then maximized with respect to~${j\not \in I}$ to select
the next molecule~$m_j$ on which to evaluate~$f$. The most common choice for the utility
is the improvement:~${U(y_j|\mathbf{x}_j,\mathcal{D}_\mathcal{I})= \max(0, y_j -
y_\star)}$, where~$y_\star$ is equal to the best~$y_i$ in~$\mathcal{D}_\mathcal{I}$.
In this case, Eq.~(\ref{eq:AF}) is called the expected improvement (EI) \cite{jones1998efficient}.
Ideally, the AF should encourage both exploration and exploitation.
For this, the expected utility should increase when $y_j$ takes
high values on average (to exploit), but also when there is high
uncertainty about~$y_j$ (to explore). The EI utility function satisfies these two requirements.
\todo[inline]{This description of Thompson sampling is confusing and doesn't seem correct. It is needless formalization that does not provide insight. Thompson sampling is not trying to form a Monte Carlo estimate of the distribution over $y_i$. It is sampling from the distribution over maxima implied by the posterior. The exploration in TS does not arise from Monte Carlo variance, but from the true uncertainty associated with the distribution over maxima. I don't see how this maps into the utility framework.}
Thompson sampling (TS) \cite{Thompson_1933} can be understood as a version of the previous
framework in which the utility function is defined as~${U(y_j|\mathbf{x}_j,\mathcal{D}_\mathcal{I}) = y_j}$ and the expectation in (\ref{eq:AF})
is taken with respect to $p(y_j|\mathbf{x}_j,\bm\theta)$ instead of
$p(y_j|\mathbf{x}_j,\mathcal{D}_\mathcal{I})$, with $\bm \theta$ being a sample
from the posterior $p(\bm \theta|\mathcal{D}_\mathcal{I})$. That is, when computing the
AF, TS approximates the integral in
$p(y_j|\mathbf{x}_j,\mathcal{D}_\mathcal{I})=\int
p(y_j|\mathbf{x}_j,\bm\theta)p(\bm \theta |\mathcal{D}_\mathcal{I})\,d\bm\theta$ by Monte
Carlo, using a single sample from $p(\bm \theta|\mathcal{D}_\mathcal{I})$ in the
approximation. The TS utility function enforces only exploitation because the
expected utility is insensitive to any variance in $y_j$. Despite this, TS
still enforces exploration because of the variance produced by the Monte Carlo
approximation to $p(y_j|\mathbf{x}_j,\mathcal{D}_\mathcal{I})$. Under TS,
the probability of
evaluating the objective at a particular location matches the probability of
that location being the maximizer of the objective, given the model assumptions
and the data from past evaluations. Algorithm \ref{alg:seq_thompson_sampling}
contains the pseudocode for TS. The plots in the top of Figure
\ref{fig:illustration_thompson_sampling} illustrate how TS works. The top-left
plot shows several samples from a posterior distribution on $f$ induced by
$p(\bm\theta|\mathcal{D}_\mathcal{I})$ since each value of the parameters $\bm \theta$ corresponds to
an associated value of $f$.
Sampling from $p(\bm\theta|\mathcal{D}_\mathcal{I})$ is then equivalent to selecting one of these
samples for $f$. The selected sample
represents the current AF, which is
optimized in the top-right plot in Figure \ref{fig:illustration_thompson_sampling}
to select the next evaluation.
\vspace{-0.1cm}
\subsection{Parallel BO}\label{sec:parallelBO}
\vspace{-0.10cm}
So far we have considered the sequential evaluation setting, where BO methods
collect just a single data point in each iteration. However, BO can also be
applied in the parallel setting, which involves choosing a batch of multiple points to
evaluate next in each iteration. For example, when we run
$S$ parallel simulations in a computer cluster and each simulation performs one
evaluation of $f$.
\todo[inline]{One thing that is missing here is clarity on what the nature of the parallelism is. There are certainly situations where you have a big batch of experiments that are all running in lockstep, in particular in biology with microarrays. However, a much more common situation is that you're being asked to choose a new place for evaluation, when many other things are currently pending. Computational chemistry is certainly in this category, since the run times are different for different molecules. It needs to be clear what kind of parallelism is being discussed.}
\citet{snoek2012practical} describe how to extend sequential BO methods to the
parallel setting. The idea is to select the first evaluation location in the
batch in the same way as in the sequential setting. However, the next evaluation
location is then selected while the previous one is still pending. In
particular, given a set $K$ with indexes of pending evaluation locations, we
choose a new location in the batch based on the expectation of the AF under all
possible outcomes of the pending evaluations according to the predictions of
the model. Therefore, at any point, the next evaluation location is obtained by
optimizing the AF
\vspace{-0.5cm}
{
\small
\begin{align}
& \alpha_\text{parallel} (\mathbf{x}_j|\mathcal{D}_\mathcal{I},\mathcal{K}) = \nonumber\\
&\hspace{0.9cm} \mathbf{E}_{p(\{y_k\}_{k \in \mathcal{K}}|\{ \mathbf{x}_k\}_{k \in \mathcal{K}},\mathcal{D}_\mathcal{I})}\left[
\alpha(\mathbf{x}_j|\mathcal{D}_\mathcal{I} \cup \mathcal{D}_\mathcal{K}) \right]
\,,\label{eq:integratedAF}
\end{align}}where $\mathcal{D}_\mathcal{K}=\{(y_k,\mathbf{x}_k)\}_{k\in \mathcal{K}}$ and
$\alpha(\mathbf{x}_j|\mathcal{D}_\mathcal{I} \cup \mathcal{D}_\mathcal{K})$
is given by (\ref{eq:AF}).
Computing this expression exactly is infeasible in most cases.
\citet{snoek2012practical} propose a Monte Carlo approximation in which the expectation
in the second line is approximated by averaging across a few samples from
the predictive distribution at the pending evaluations,
that is, $p(\{y_k\}_{k \in \mathcal{K}}|\{ \mathbf{x}_k\}_{k \in \mathcal{K}},\mathcal{D}_\mathcal{I})$.
These samples are referred to as \emph{fantasized} data.
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=0.4pt] (char) {#1};}}
This approach for parallel BO has been successfully used to collect small
batches of data (about 10 elements in size), with EI as utility function and
with a Gaussian process as the model for the data \cite{snoek2012practical}.
However, it lacks scalability to large batch sizes, failing when we need to
collect thousands of simultaneous measurements. The reason for this is the
high computational cost of adding a new evaluation to the current
batch. The corresponding cost includes: \circled{1} sampling the fantasized data, \circled{2} updating
the posterior predictive distribution to
$p(y_j|\mathbf{x}_j,\mathcal{D}_\mathcal{I}\cup \mathcal{D}_\mathcal{K})$,
which is required for evaluating $\alpha(\mathbf{x}_j|\mathcal{D}_\mathcal{I}
\cup \mathcal{D}_\mathcal{K})$, and \circled{3} optimizing the Monte Carlo approximation
to (\ref{eq:integratedAF}). Step \circled{2} can be very expensive when the number of
training points in $\mathcal{D}_\mathcal{I}$ is very large. This step is
also
considerably challenging when the model does not allow for exact
inference, as it is often the case with Bayesian neural networks. Step \circled{3} can
also take a very long time when the library of candidate molecules
$\mathcal{M}$ is very large (e.g., when it contains millions of elements)
and among all the remaining molecules we have to find one that maximizes
the AF.
Despite these difficulties, the biggest disadvantage in this approach for
parallel BO is that it cannot be parallelized since it is a sequential process
in which (\ref{eq:integratedAF}) needs to be iteratively optimized, with each
optimization step having a direct effect on the next one. This prevents this
method from fully exploiting the acceleration provided by multiple processors
in a computer cluster. \todo{Let's be honest here: this only matters if the ``expensive'' computation is not that expensive relative to the parallelism. That is, if it takes 1 minute to make a sequential prediction and we have $N$ machines, then once the optimization is going, the bottleneck only arises if the expensive function takes less than $N$ minutes. In other words, this argument somewhat contradicts the philosophy behind BO.} The sequential nature of the algorithm is illustrated by
the plot in the left of Figure \ref{fig:parallel_visualization}. In this plot
computer node 1 is controlling the BO process and decides the batch evaluation
locations. Nodes $2,\ldots,5$ then perform the evaluations in parallel. Note
that steps \circled{2} and \circled{3} from the above description have been highlighted in green
and magenta colors.
In the following section we describe an algorithm \todo[inline]{This algorithm is useful, but no way it's novel. It's the most obvious thing to do with Thompson sampling in the batch setting. We can argue that this is a sensible thing to do for chemistry, but I think basically everyone who has thought about TS realizes you can do it trivially in parallel. } for batch BO which can
be implemented in a fully parallel and distributed manner and which,
consequently, can take full advantage of multiple processors in a computer
cluster. This novel method is based on a parallel implementation of the Thompson sampling heuristic.
\begin{algorithm}
\caption{Parallel and distributed Thompson sampling}\label{alg:thompson_sampling_distributed}
\begin{algorithmic}
\STATE {\bfseries Input:} initial data $\mathcal{D}_{\mathcal{I}(1)}=\{ \mathbf{x}_i, y_i \}_{i \in \mathcal{I}(1)}$, batch size $S$
\FOR{$t=1$ {\bfseries to} $T$}
\STATE \tikzmark{a} Compute current posterior $p(\bm \theta|\mathcal{D}_{\mathcal{I}(t)})$
\FOR{$s=1$ {\bfseries to} $S$}
\STATE Sample $\bm \theta$ from $p(\bm \theta|\mathcal{D}_{\mathcal{I}(t)})$
\STATE Select $k(s)\leftarrow \text{argmax}_{j \not \in {\mathcal{I}(t)}} \mathbf{E}[y_j|\mathbf{x}_j,\bm \theta]$
\STATE Collect $y_{k(s)}$ by evaluating $f$ at $\mathbf{x}_{k(s)}$
\ENDFOR
\STATE $\mathcal{D}_{\mathcal{I}(t+1)}=\mathcal{D}_{\mathcal{I}(t)}\cup \{\mathbf{x}_{k(s)},y_{k(s)}\}_{s=1}^S$
\ENDFOR
\begin{tikzpicture}[remember picture, overlay]
\node
[draw=blue!80!black, very thick, dotted, rectangle, anchor=north west,
minimum width=5.9cm,
minimum height=1.3cm]
(box) at ($(a) + (0.15, -0.5)$) {};
\node[text=blue!80!black, rotate=90, anchor=south] at ($(a) + (6.6, -1.16)$) {Executed};
\node[text=blue!80!black, rotate=90, anchor=south] at ($(a) + (7.0, -1.16)$) {in parallel};
\node[text=blue!80!black, rotate=90, anchor=south] at ($(a) + (7.3, -1.16)$) {in node $s$};
\end{tikzpicture}
\end{algorithmic}
\end{algorithm}
\begin{figure*}
\centering
\includegraphics[width=1.00\textwidth]{drawing.pdf}
\caption{A visualization of one iteration of BO using parallel EI as implemented in \cite{snoek2012practical} and PDTS. Note that in PDTS the model is updated once and sample points are acquired independently by the nodes. With parallel EI, the the location of the next sample points is dependent on the location of previous sample points in the batch so these are computed sequentially.
\todo[inline]{I think this figure could be helpful, but it doesn't really address the situation here in which the experiments take variable amounts of time. Also, these figures make it clear that it only matters if the red lines are short!}
}
\label{fig:parallel_visualization}
\vspace{-3mm}
\end{figure*}
\vspace{-0.3cm}
\section{Parallel and Distributed Thompson Sampling}
\vspace{-0.1cm}
We present an implementation of the parallel BO method from Section
\ref{sec:parallelBO} based on the Thompson sampling (TS) heuristic. In
particular, we propose to apply to (\ref{eq:integratedAF}) the same
approximation that TS applied to (\ref{eq:AF}). For this, we choose
in (\ref{eq:integratedAF}) the same utility function used by TS in the sequential setting, that is,
$U(y_j|\mathbf{x}_j,\mathcal{D}_\mathcal{I} \cup \mathcal{D}_\mathcal{K}) = y_j$.
Then, we approximate the expectation with respect to $\{y_k\}_{k \in \mathcal{K}}$
in (\ref{eq:integratedAF}) by Monte Carlo, averaging across just one sample of
$\{y_k\}_{k \in \mathcal{K}}$
drawn from
$p(\{y_k\}_{k \in \mathcal{K}}|\{ \mathbf{x}_k\}_{k \in \mathcal{K}},\mathcal{D}_\mathcal{I})$.
After that,
$\alpha(\mathbf{x}_j|\mathcal{D}_\mathcal{I} \cup \mathcal{D}_\mathcal{K})$ in
(\ref{eq:integratedAF}) is approximated in the same way as in the sequential
setting by first sampling $\bm \theta$ from $p(\bm
\theta|\mathcal{D}_\mathcal{I}\cup \mathcal{D}_\mathcal{K})$ and then
approximating $p(y_j|\mathbf{x}_j,\mathcal{D}_\mathcal{I}\cup
\mathcal{D}_\mathcal{K})$ with $p(y_j|\mathbf{x}_j,\bm\theta)$. Importantly,
in this process, sampling first $\{y_k\}_{k \in \mathcal{K}}$ from
$p(\{y_k\}_{k \in \mathcal{K}}|\{ \mathbf{x}_k\}_{k \in
\mathcal{K}},\mathcal{D}_\mathcal{I})$ and then $\bm \theta$ from $p(\bm
\theta|\mathcal{D}_\mathcal{I}\cup \mathcal{D}_\mathcal{K})$ is equivalent to
sampling $\bm \theta$ from just $p(\bm \theta|\mathcal{D}_\mathcal{I})$. The
reason for this is that updating a posterior distribution with synthetic data
sampled from the model's predictive distribution produces on average the same
initial posterior distribution. The result is that parallel TS with batch size
$S$ is the same as running sequential TS $S$ times without updating the current
posterior $p(\bm \theta|\mathcal{D}_\mathcal{I})$, where each execution of
sequential TS produces one of the evaluation locations in the batch.
Importantly, these executions can be done in distributed manner, with each one running in
parallel in
a different node.
The resulting parallel and distributed TS (PDTS) method is highly scalable and
can be applied to very large batch sizes by running each execution of
sequential TS on the same computer node that will then later evaluate $f$ at
the selected evaluation location. Algorithm
\ref{alg:thompson_sampling_distributed} contains the pseudocode for PDTS. The
parallel nature of the algorithm is illustrated by the plot in the right of
Figure \ref{fig:parallel_visualization}. In this plot computer node 1 is
controlling the BO process. To collect four new function evaluations in
parallel, computer node 1 sends the current posterior $p(\bm
\theta|\mathcal{D}_\mathcal{I})$ and $\mathcal{I}$ to nodes $2,\ldots,5$. Each of them
samples then a value for $\bm \theta$ from the posterior and optimizes its own AF given by $\mathbf{E}[y_j|\mathbf{x}_j,\bm \theta]$,
with $j \not \in \mathcal{I}$.
The objective function is evaluated at the selected input and the resulting data is sent back to node 1.
Figure \ref{fig:illustration_thompson_sampling} illustrates how PDTS selects two parallel
evaluation locations. For this, sequential TS is run twice.
The scalability of PDTS makes it a promising method for parallel BO in
high-throughput screening. However, in this type of problem, the optimization
of the AF is done over a discrete set of molecules. Therefore,
whenever we collect a batch of data in parallel with PDTS, several of the
simultaneous executions of sequential TS may choose to evaluate the same
molecule. A central computer node (e.g. the node controlling the BO process)
maintaining a list of molecules currently selected for evaluation can be used
to avoid this problem. In this case, each sequential TS node sends to the central node a ranked
list with the top $S$ (the batch size) molecules according to its AF. From
this list, the central node then selects the highest ranked molecule that
has not been selected for evaluation before.
\vspace{-0.1cm}
\section{Related Work}
\vspace{-0.1cm}
Ginsbourger et al. \cite{ginsbourger2010kriging} proposed the following framework for parallel BO:
given a set of current observations
$\mathcal{D}_{\mathcal{I}}$ and pending experiments
$\{\mathbf{x}_k\}_{k=1}^\mathcal{K}$, an additional set of fantasies
$\mathcal{D}_\mathcal{K} = \{(\mathbf{x}_k, {y}_k)\}_{k=1}^\mathcal{K}$ can
be assumed to be the result of those pending experiments. A step of Bayesian
optimization can then be performed using the augmented dataset
$\mathcal{D}_\mathcal{I} \cup \mathcal{D}_\mathcal{K}$ and the
acquisition function $\alpha(\mathbf{x}| \mathcal{D}_\mathcal{I} \cup
{\mathcal{D}_\mathcal{K}})$. Two different values are proposed for the fantasies:
the \textit{constant liar}, where ${y}_k = L$ for some constant $L$
and all $k=1\ldots \mathcal{K}$, and the \textit{Kriging believer}, where
${y}_k$ is given by the GP predictive mean at $\mathbf{x}_k$.
\citet{snoek2012practical} compute a Monte Carlo approximation
of the expected acquisition function over potential fantasies
sampled from the model's predictive distribution.
Recent methods have been proposed to
modify the parallel EI procedure to recommend points jointly
\cite{chevalier2013fast,marmin2015differentiating,wang2016parallel}.
\citet{azimi2010batch} describe a procedure called \textit{simulated matching}
whose goal is to propose a batch ${\mathcal{D}_\mathcal{K}}$ of points which is
a good match for the set of samples that a sequential BO policy $\pi$ would
recommend. The authors consider a batch ``good'' if it contains a sample that
yields, with high probability, an objective value close to that of the best
sample produced by a sequential execution of $\pi$.
Several authors have proposed to extend the \textit{upper confidence bound}
(UCB) heuristic to the parallel setting.
Since the GP predictive variance depends only on the input location of the observations, \citet{desautels2014parallelizing} propose GP-BUCP acquisition which uses the UCB acquisition with this updated variance.
\citet{contal2013parallel} introduce the Gaussian Process Upper Confidence
Bound with Pure Exploration (GP-UCB-PE). Under this procedure, the first point
is obtained using the standard UCB acquisition function while the remaining
points are sequentially selected to be the ones yielding the highest predictive
variance, while still lying in a region that contains the maximizer with high
probability.
\citet{shah2015parallel} extend the Predictive Entropy Search (PES) heuristic
to the parallel setting (PPES). PPES seeks to recommend a collection of samples
${\mathcal{D}_\mathcal{\mathcal{K}}}$ that yields the greatest reduction in
entropy for the posterior distribution of $\mathbf{x}^\star$, the latent
objective maximizer. \citet{wu2016parallel} propose the \text{Parallel
Knowledge Gradient Method} which optimizes an acquisition function called the
parallel knowledge gradient (q-KG), a measure of the expected incremental
solution quality after $q$ samples.
An advantage of PDTS over parallel EI and other related methods is that the
approximate marginalization of potential experimental outcomes adds no
extra computational cost to our procedure and so PDTS is highly parallelizable.
Finally, unlike other approaches, PDTS can be applied to a wide
variety of models, such as GPs and Bayesian neural networks, since it only
requires samples from an exact or approximate posterior distribution.
\newcommand{\text{Gam}}{\text{Gam}}
\vspace{-0.2cm}
\section{Bayesian Neural Networks for High-throughput Screening}
\vspace{-0.1cm}
Neural networks are well-suited for implementing BO on molecules. They produce
state-of-the-art predictions of chemical properties
\cite{Ma_2015,Mayr_2016,ramsundar2015massively} and can be applied to large
data sets by using stochastic optimization
\cite{bousquet2008tradeoffs}. Typical applications of neural networks focus on
the deterministic prediction scenario. However,
in large search spaces with multiple local optima (which is
the case when navigating chemical space),
it is desirable to use a probabilistic approach that can produce accurate
estimates of uncertainty for efficient exploration and so, we use
\emph{probabilistic back-propagation} (PBP), a recently-developed technique for
the scalable training of Bayesian neural networks
\cite{hernandez2015probabilistic}. Note that other methods for approximate
inference in Bayesian neural networks could have been chosen as well
\cite{BlundellCKW15,SnoekRSKSSPPA15,GalG16}. We prefer PBP because it is fast
and it does not require the tuning of hyper-parameters such as learning rates
or regularization constants \cite{hernandez2015probabilistic}.
Given a dataset $\mathcal{D}_\mathcal{I} = \{ (\mathbf{x}_i, y_i) \}_{i \in\mathcal{I}}$, we
assume that ${y_i = f(\mathbf{x}_i;\mathcal{W}) + \epsilon_i}$, where $f(\cdot
;\mathcal{W})$ is the output of a neural network with weights $\mathcal{W}$.
The network output is corrupted with additive noise variables ${\epsilon_i \sim
\mathcal{N}(0,\gamma^{-1})}$. The network has~$L$ layers, with $V_l$ hidden
units in layer $l$, and ${\mathcal{W} = \{ \mathbf{W}_l \}_{l=1}^L}$ is the
collection of $V_l \times (V_{l-1}+1)$ synaptic weight matrices. The $+1$ is
introduced here to account for the additional per-layer biases. The activation
functions for the hidden layers are rectifiers: ${\varphi(x) = \max(x,0)}$.
The likelihood for the network weights~$\mathcal{W}$ and the noise
precision~$\gamma$ is
\vspace{-0.5cm}
{\small
\begin{align}
p(\{y_i\}_{i\in|\mathcal{I}}|\mathcal{W},\{\mathbf{x}_i\}_{i\in \mathcal{I}},\gamma)
&= \prod_{i\in \mathcal{I}}\mathcal{N}(y_i | f(\mathbf{x}_i;\mathcal{W}),\gamma^{-1})\,.\nonumber
\end{align}
}We specify a Gaussian prior distribution
for each entry in each of the weight matrices in $\mathcal{W}$:
\begin{align}
p(\mathcal{W}|\lambda) &= \prod_{l=1}^L \prod_{k=1}^{V_l} \prod_{j=1}^{V_{l-1}+1} \mathcal{N}(w_{kj,l}|0,\lambda^{-1})\,,\label{eq:prior_weights}
\end{align}
where $w_{kj,l}$ is the entry in the $k$-th row and $j$-th column
of $\mathbf{W}_l$ and $\lambda$ is a precision parameter. The hyper-prior
for~$\lambda$ is gamma: $p(\lambda) = \text{Gam}(\lambda|\alpha_0^\lambda,\beta_0^\lambda)$
with shape $\alpha^\lambda_0 = 6$ and inverse scale $\beta^\lambda_0 = 6$.
This relatively low value for the shape and inverse scale parameters makes this prior weakly-informative.
The prior for the noise precision $\gamma$ is also gamma: $p(\gamma) =
\text{Gam}(\gamma|\alpha_0^{\gamma},\beta_0^{\gamma})$. We assume that the
$y_i$ have been normalized to have unit variance and, as above, we
fix ${\alpha^{\gamma}_0 = 6}$ and~${\beta^{\gamma}_0 = 6}$.
The exact
computation of the posterior distribution for the model parameters $p(\mathcal{W},\gamma, \lambda|\mathcal{D}_\mathcal{I})$ is not tractable in most cases.
PBP approximates the intractable posterior on $\mathcal{W}$, $\gamma$ and $\lambda$ with the tractable approximation
\vspace{-0.5cm}
{
\small
\begin{align}
q(\mathcal{W},\gamma, \lambda) = & \left[ \prod_{l=1}^L\! \prod_{k=1}^{V_l}\!
\prod_{j=1}^{V_{l\!-\!1}\!+\!1} \mathcal{N}(w_{kj,l}| m_{kj,l},v_{kj,l})\right ]\nonumber\\
& \text{Gam}(\gamma \,|\, \alpha^\gamma, \beta^\gamma)
\text{Gam}(\lambda \,|\, \alpha^\lambda, \beta^\lambda)\,,\label{eq:posterior_approximation}
\end{align}}whose parameters are tuned by iteratively running an assumed density filtering
(ADF) algorithm over the training data \cite{Opper1998}. The main operation in
PBP is the update of the mean and variance parameters of $q$, that is, the
$m_{kj,l}$ and $v_{kj,l}$ in (\ref{eq:posterior_approximation}), after
processing each data point $\{(\mathbf{x}_i,y_i)\}$. For this, PBP matches
moments between the new $q$ and the product of the old $q$ with the
corresponding likelihood factor $\mathcal{N}(y_i \,|\,
f(\mathbf{x}_i;\mathcal{W}),\gamma^{-1})$. The matching of moments for the
distributions on the weights is achieved by using well-known Gaussian ADF
updates, see equations 5.12 and 5.1 in \cite{minka2001family}.
To compute the ADF updates, PBP finds a Gaussian approximation to the distribution
of the network output $f(\mathbf{x}_i;\mathcal{W})$ when $\mathcal{W} \sim q$.
This is achieved by doing a forward pass of
$\mathbf{x}_i$ through the network, with the weights $\mathcal{W}$ being
randomly sampled from $q$. In this forward pass the non-Gaussian distributions
followed by the output of the neurons are approximated with Gaussians that have the same
means and variances as the original distributions. This is a Gaussian approximation by moment matching.
We refer the reader to
\citet{hernandez2015probabilistic} for full details on PBP.
After several ADF iterations over the data by PBP, we can then make predictions
for the unknown target variable $y_\star$ associated with a new feature vector
$\mathbf{x}_\star$. For this, we obtain a Gaussian approximation to
$f(\mathbf{x}_\star;\mathcal{W})$ when $\mathcal{W}\sim q$ by applying the
forward pass process described above.
To implement TS, as described in Algorithm \ref{alg:seq_thompson_sampling}, we
first sample the model parameters $\bm \theta$ from the posterior
$p(\bm \theta|\mathcal{D}_{\mathcal{I}})$ and then optimize the AF
given by $\mathbf{E}[y_j|\mathbf{x}_j,\bm \theta]$, with $j \not \in {\mathcal{I}}$.
When the model is a Bayesian neural network trained with PBP, the corresponding operations
are sampling $\mathcal{W}$ from $q$ and then optimizing the AF
given by
$f(\mathbf{x}_j;\mathcal{W})$, with $j \not \in {\mathcal{I}}$. This last step
requires the use of a deterministic neural network, with weight values given by the
posterior sample from $q$, to make predictions on all the molecules that have
not been evaluated yet. Then, the molecule with highest predictive value is
selected for the next evaluation.
\section{Experiments with GPs and Parallel EI}
\begin{figure*}[h!]
\includegraphics[width=1.00\textwidth]{results_gps.pdf}
\caption{Immediate regret in experiments with GPs, using TS,
EI, PDTS and parallel EI for optimizing synthetic functions (first 3 plots) and
functions sampled from a GP prior (fourth plot).}\label{fig:gp_experiments}
\vspace{-4mm}
\end{figure*}
We first compare the performance of our parallel and distributed Thompson
sampling (PDTS) algorithm with the most popular approach for parallel BO: the
parallel EI method from Section \ref{sec:parallelBO}. Existing implementations
of parallel EI such as
spearmint\footnote{\url{https://github.com/HIPS/Spearmint}} use a Gaussian
process (GP) model for the objective function. To compare with these methods, we
also adopt a GP as the model in PDTS. Note that parallel EI cannot
scale to the large batch sizes used in high-throughput screening. Therefore,
we consider here only parallel optimization problems with small batch sizes and
synthetic objective functions.
Besides PDTS and parallel EI, we also analyze the performance of the sequential
versions of these algorithms: TS and EI.
To implement Thompson sampling (TS) with a GP model, we approximate the
non-parametric GP with a parametric approximation based on random features, as
described in the supplementary material of \cite{hernandez2014predictive}. For
the experiments, we consider a cluster with 11 nodes: one central node for
controlling the BO process and 10 additional nodes for parallel evaluations. We
assume that all objective evaluations take a very large amount of time and
that the cost of training the GPs and recomputing and optimizing the AF is
negligible in comparison. Thus, in practice, we perform these experiments
in a sequential (non-parallel) fashion with the GP model being updated only in
blocks of 10 consecutive data points at a time.
As objective functions we consider the two dimensional Bohachevsky and
Branin-Hoo functions and the six dimensional Hartmann function, all available
in Benchfunk\footnote{\url{https://github.com/mwhoffman/benchfunk}}. We also
consider the optimization of functions sampled from the GP prior over the 2D unit square using a
squared exponential covariance function with fixed 0.1 length scale. After each objective evaluation, we compute the immediate
regret (IR), which we define as the difference between the best objective value
obtained so far and the minimum value of the objective function. The measurement
noise is zero in these experiments.
Figure \ref{fig:gp_experiments} reports mean and standard errors for the
logarithm of the best IR seen so far, averaged across 50 repetitions of the experiments.
In the plots, the horizontal axis
shows the number of function evaluations performed so far. Note that in these
experiments TS and EI update their GPs once per sample, while PDTS and parallel
EI update only every 10 samples.
Figure \ref{fig:gp_experiments} shows that EI is
better than TS in most cases, although the differences between these two
methods are small in the Branin-Hoo function. However, EI is considerably much
better than TS in Hartmann. The reason for this is that in Hartmann there are
multiple equivalent global minima and TS tends to explore all of them. EI is by contrast
more exploitative and focuses on evaluating the objective around only one of
the minima.
The differences between parallel EI and PDTS are much
smaller, with both obtaining very similar results.
The
exception is again Hartmann, where parallel EI is much better than PDTS,
probably because PDTS is more explorative than
parallel EI. Interestingly, PDTS performs better than parallel EI
on the random samples from the GP prior, although parallel EI eventually catches up.
These results indicate that PDTS performs in practice very similarly to parallel EI,
one of the most popular methods for parallel BO.
\section{Experiments with Molecule Data Sets}\label{sec:data_sets}
We describe the molecule data sets used in our experiments. The input features for
all molecules are 512-bit Morgan circular fingerprints \cite{Rogers_2010},
calculated with a bond radius of 2, and derived from the canonical SMILES as
implemented in the RDkit package \cite{rdkit}.
\textbf{Harvard Clean Energy Project}: The Clean Energy Project is the world's
largest materials high-throughput virtual screening effort
\cite{Hachmann_2014,Hachmann_2011}, and has scanned more than 3.5 million
molecules to find those with high power conversion efficiency (PCE) using
quantum-chemical techniques, taking over 30,000 years of CPU time. The target
value within this data set is the power conversion efficiency (PCE), which is
calculated for the 2.3 million publicly released molecules, using the Scharber
model \cite{Dennler_2008} and frontier orbitals calculated at the BP86
\cite{Perdew_1986,Becke_1993} \/ def2-SVP \cite{Weigend_2005} level of theory.
\textbf{Dose-Response Data Set}: These data sets were obtained from the
NCI-cancer database \cite{_nci_}. The dose-response target value has a
potential range of -100 to 100, and reports a percentage cell growth relative
to a no-drug control. Thus, a value of +40 would correspond to a 60\% growth
inhibition and a value of -40 would correspond to 40\% lethality. Molecules
with a positive value for the dose-response are known as inhibitors, molecules
with a score less than 0 have a cytotoxic effect. Results against the NCI-H23
cell line were taken against a constant log-concentration of -8.00M and where
multiple identical conditions were present in the data an average was used for
the target variables. In this data set we are interested in finding molecules
with smaller values of the target variable.
\textbf{Malaria Data Set}: The Malaria data set was taken from the \textit{P.
falciparum} whole cell screening derived by combining the GSK TCAMS data set,
the Novatis-GNF Malaria Box data set and the St Jude's Research Hospital data
set, as released through the Medicines for Malaria Venture website
\cite{Spangenberg_2013}. The target variable is the EC50 value, which is
defined as the concentration of the drug which gives half maximal response.
Much like the Dose response data set, the focus here is on minimization: the
lower the concentration, the stronger the drug.
\begin{figure*}[h!]
\begin{center}
\includegraphics[width=1\textwidth]{thompson_tile4.png}
\vspace{-3mm}
\caption{{Recall obtained by PDTS on each data set.
For the CEP
data, the recall for molecules with a PCE $>10\%$ is reported, whilst for
One-dose and Malaria we report the recall for the molecules in the top 1\%. In
addition to the Monte Carlo sampling baseline, we also include results for a
greedy sampling approach, in which there is no exploration, and the molecules
are chosen according to the mean of the predictive distribution given by PBP.
The overall lower performance of this greedy strategy illustrates the
importance of exploration in this type of problems.
\label{fig:thompson_1pc}
}}
\end{center}
\vspace{-4mm}
\end{figure*}
\subsection{Results}\label{sec:thompson_sampling}
We evaluate the gains produced by PDTS in experiments
simulating a high throughput virtual screening setting. In these experiments,
we sequentially sample molecules from libraries of candidate molecules given by
the data sets from Section \ref{sec:data_sets}. After each sampling step, we
calculate the 1\% recall, that is, the fraction of the top 1\% of molecules
from the original library that are found among the sampled ones. For the CEP
data, we compute recall by focusing on molecules with
PCE larger than 10\%. In all data sets, each sampling step
involves selecting a batch of molecules among those that have not been sampled
so far. In the Malaria and One-dose data sets we use batches of size 200. These
data sets each contain about 20,000 molecules. By contrast, the CEP data set
contains 2 million molecules. In this latter case, we use batches of size 500.
We use Bayesian neural networks with one hidden layer
and 100 hidden units.
We compare the performance of PDTS with two baselines. The first one,
\emph{greedy}, is a sampling strategy that only considers exploitation and does
not perform any exploration. We implement this approach by selecting molecules
according to the average of the probabilistic predictions generated by PBP.
That is, the greedy approach ignores any variance in the predictions of the
Bayesian neural network and generates batches by just ranking molecules
according to the mean of the predictive distribution given by PBP. The second
baseline is a Monte Carlo approach in which the batches of molecules are
selected uniformly at random. These two baselines are comparable to PDTS in that
they can be easily implemented in a large scale setting in which the library of
candidate molecules contains millions of elements and data is sampled using
large batch sizes.
In the Malaria and One-dose data sets, we average across 50 different
realizations of the experiments. This is not possible in the CEP data set,
which is 100 times larger than the two other data sets. In the CEP case, we
report results for a single realization of the experiment (in a second
realization we obtained similar results). Figure \ref{fig:thompson_1pc} shows
the recall obtained by each method in the molecule data sets.
PDTS significantly outperforms the Monte Carlo
approach, and also offers better performance than greedy sampling. This shows
the importance of building in exploration into the sampling strategy, rather
than relying on purely exploitative methods. The greedy approach performs best
in the CEP data set. In this case, the greedy strategy initially finds better
molecules than PDTS, but after a while PDTS overtakes, probably because a promising
area of chemical space initially discovered by the greedy approach starts to
become exhausted.
The previous results allow us to consider the savings produced by BO.
In the CEP data set, PDTS achieves about 20 times higher
recall values than the Monte Carlo approach, which is comparable to the
exhaustive enumeration that was used to collect the CEP data. We estimate that,
with BO, the CEP virtual screening process would have
taken 1,500 CPU years instead of the 30,000 that were actually used. Regarding
the One-dose and Malaria data sets, PDTS can locate in both sets about 70\% of
the top 1\% molecules by sampling approximately 6,000 molecules. By contrast,
the Monte Carlo approach would require sampling 14,000 molecules. This
represents a significant reduction in the discovery time for new therapeutic
molecules and savings in the economic costs associated with molecule synthesis
and testing.
\vspace{-0.1cm}
\subsection{Comparison with $\epsilon$-greedy Approaches}
\vspace{-0.1cm}
We can easily modify the greedy baseline from the previous section to include
some amount of exploration by replacing a small fraction of the
molecules in each batch with molecules chosen uniformly at random. This
approach is often called $\epsilon$-greedy \cite{watkins1989learning}, where
the variable $\epsilon$ indicates the fraction of molecules that are sampled
uniformly at random. The disadvantage of the $\epsilon$-greedy approach is that
it requires the tuning of $\epsilon$ to the problem of interest
whereas the amount of exploration is automatically set by PDTS.
\begin{table}
\centering
\caption{Average rank and standard errors by each method.}\label{table1}
\begin{tabular}{lr@{$\pm$}l}
\hline
\bf{Method}& \multicolumn{2}{c}{\bf{Rank}}\\
\hline
$\epsilon = 0.01$ & 3.42 & 0.28 \\
$\epsilon = 0.025$ & 3.02 & 0.25 \\
$\epsilon = 0.05$ & 2.86 & 0.23 \\
$\epsilon = 0.075$ & 3.20 & 0.26 \\
PDTS & \bf{2.51} & \bf{0.20} \\
\hline
\vspace{-8mm}
\end{tabular}
\end{table}
We compared PDTS with different versions of $\epsilon$-greedy in the same way as
above, using $\epsilon = 0.01, 0.025, 0.05$ and $0.075$. The experiments with
the One-dose and the Malaria data sets are similar to the ones done before.
However, we now sub-sample the CEP data set to be able to average across 50
different realizations of the experiment: we choose 4,000 molecules uniformly
at random and then collect data in batches of size 50 across 50 different
repetitions of the screening process. We compute the average rank obtained by
each method across the $3\times 50 = 150$ simulated screening experiments. A
ranking equal to 1 indicates that the method always obtains the highest recall
at the end of the experiment, while a ranking equal to 5 indicates that the
method always obtains the worst recall value. Table \ref{table1} shows that the
lowest average rank is obtained by PDTS, which achieves better
exploration-exploitation trade-offs than the $\epsilon$-greedy approaches.
\vspace{-0.1cm}
\section{Conclusions}
\vspace{-0.1cm}
We have presented a Parallel and Distributed implementation of Thompson
Sampling (PDTS), a highly scalable method for parallel Bayesian
optimization. PDTS can be applied when scalability limits the
applicability of competing approaches. We have evaluated the performance of
PDTS in experiments with both Gaussian process and probabilistic neural
networks. We show that PDTS compares favorably with parallel EI in problems with
small batch sizes. We also demonstrate the effectiveness of PDTS
on large scale real world applications that involve searching chemical space
for new molecules wit improved properties. We show that PDTS outperforms other scalable
approaches on these applications, in particular, a greedy search strategy,
$\epsilon$-greedy approaches and a random search method.
\subsection*{Acknowledgements}
J.M.H.L. acknowledges support from the Rafael del Pino Foundation.
The authors thank Ryan P. Adams for useful discussions.
A.A.-G. and E.O.P.-K. acknowledge the Department of Energy Program on Theory and modeling through grant {DE-SC0008733}.
{\small
| {'timestamp': '2017-06-07T02:08:02', 'yymm': '1706', 'arxiv_id': '1706.01825', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01825'} | arxiv |
\section*{Introduction}
Bibliometric indices are ubiquitous in measuring the scientific impact of both journals, institutions, research groups and individual researchers. At some stage in their evaluation process, scientific committees, administrators or policy makers often rely on citation data to assess scientific output. Among the variety of measures that can be derived from raw citation data, the $h$-index~\cite{Hirsch2005} became the most popular bibliometric criterion for the ranking of research accomplishment~\cite{Ball2005,Fersht2009,Alonso2009}.
The $h$-index of an individual is given by the total number of published papers with citations $\geq h$. Due to its simple definition, its ease of computation from existing bibliography databases, its robustness against errors in the long tails of the citations-rank distribution~\cite{Vanclay2007} and its good properties when quantifying the scientific production and its impact, the $h$-index has been largely adopted as a reliable measure of research output~\cite{Alonso2009}. Nowadays, the automatic calculation of $h$-indices is a built-in feature of major bibliographic databases such as Google Scholar, Researchgate, Scopus and Web of Science. While it is quite dependent on the database being used, the typical value of the $h$-index is robust when it comes to ranking both individuals and research institutions.
Shortcomings of the $h$-index have been pointed out, although many other available indicators do suffer from similar biases~\cite{Alonso2009}. Among the arguments raised against using the $h$-index one can enumerate: it does not allow to compare scientists from different disciplines~\cite{Batista2006}, it does not take into account multi-authored papers~\cite{Iglesias2007,Egghe2008b,Radicchi2008,Sekercioglu2008,Zhang2009,Hirsch2010}, it is a time-dependent quantity~\cite{Burrell2007,Eom2011,Acuna2012,Wang2016}, it does not highlight the citation scores of top articles~\cite{Egghe2006}, it does not take into account the context of the citations in the papers. Consequently, several subsequent variations of the $h$-index have been proposed to overcome some of these drawbacks~\cite{Batista2006,Iglesias2007,Egghe2008b,Radicchi2008,Sekercioglu2008,Zhang2009,Hirsch2010,Burrell2007,Eom2011,Acuna2012,Wang2016,Egghe2006,Komulski2006,Sidiropoulos2007,Jin2007a,Jin2007b,VanEck2008,Rousseau2008,Egghe2008a,Ruane2008,Anderson2008,Bornmann2008,Antonakis2008,Schreiber2009,Guns2009}. A non exhaustive list of such bibliometric indices include the $g$-index~\cite{Egghe2006}, the $h^{(2)}$-index~\cite{Komulski2006}, the $A$- $R$- and $AR$-index~\cite{Jin2007a,Jin2007b}, the $m$-index~\cite{Bornmann2008}, the $h_m$-index~\cite{Schreiber2009}, etc. Interestingly, all of them were based on an increasingly sophisticated analysis of raw citation data, which makes them more difficult to access. Moreover, although being designed to surmount its perceived shortcomings, they were found to be quite positively correlated with the $h$-index~\cite{Alonso2009,Bornmann2008}. This fact yielded the general consensus that no other bibliometric indicator of research output is clearly preferable to the $h$-index~\cite{Alonso2009,Hirsch2007}.
Since it is desirable to evaluate researchers and/or institutions on more than a single quality, we propose to supplement the $h$-index with a new quantitative indicator specialized to interdisciplinary research and readership extent. This journal-based index is by construction independent of citation counts and measures different qualities that could be useful to assess, for example in the process of hiring individuals who are expected to teach and to advise, for which high specialization values are not required.
\section*{A new two-dimensional index}
Many refinements of the $h$-index, on both theoretical and empirical sides, were based on alternative analysis of citation data. We believe that this is the reason for their strong positive correlation with the latter. Therefore, the quest for other bibliometric indices should be aimed at complementing the $h$-index rather than replacing it. A new index should be a quantitative indicator with a core that is independent of citation data and as easy to compute from existing bibliographic databases as the $h$-index. It should concern both individuals, research groups and institutions and should highlight different achievements than research output, which is already well quantified by the $h$-index.
Noticing that the $h$-index is bounded by the total number of published papers, $h\leq N$, we have looked for another possibly interesting and simple quantity that satisfies the same property. A straightforward one is the number of different journals in which these papers were published. This number, denoted by $N_j$, is not directly available in existing bibliographic databases but can be easily extracted from them, either by direct counting or using simple script codes. Obviously, $N_j\leq N$ and is not based on citation count, thus one would expect that it is unlikely correlated to research output. Indeed, common publishing habits show that a paper is submitted to a given journal because of the studied area of research, to reach a specific scientific community, to fit a specific format or to be faced with a given more or less selective refereeing procedure. One could argue that a such choice is mainly dictated by the journal's impact factor, its ranking by a target institution or its interdisciplinary readership. Nevertheless, if the published research is worthwhile it will positively impact the $h$-index and consequently research output, regardless of the journal's ranking. Moreover, a paper in a high impact journal with an interdisciplinary readership is often followed by a series of detailed papers in the same subject intended for a specific scientific community, which thus contributes to increase $N_j$.
However, what type of research achievement is embedded in this new number? On the one hand, publishing in a small set of journals could indicate mono-thematic research interests while a multidisciplinary researcher is prone to publish in a wide range of journals. On the other hand, a researcher could impact a single field by publishing in the same journal on a single subject, and conversely, an author may publish about various subjects in many journals by achieving a moderate impact. These two extreme and antagonistic examples are in favour of taking into account both $N_j$ and the $h$-index for more elaborate ranking purposes.
Although $N_j$ may exhibit some flaws, which will be discussed later, one can reasonably assume that it carries information about either the multidisciplinary nature of the research, the diversity of interests of the researcher, or the extent of his readership. While these features are indicators of research quality, they are clearly not directly provided by the $h$-index.
\begin{figure}[htb]
\begin{center}
\includegraphics[width=0.6\textwidth]{Figure1.pdf}
\caption{Scatter plot of $N_j$ as a function of $h$ for a panel of researchers working at the Physics Department of ENS Paris (see Text for details).
\label{fig:example1}}
\end{center}
\end{figure}
To test the relevance of this two-dimensional index, we have chosen as a panel 95 permanent physicists belonging to a same department, namely the Physics Department of ENS Paris, which is divided in three sub-departments (\enquote{Laboratoires}) with more or less specific research areas: condensed matter physics (Laboratoire Pierre Aigrain, LPA, 31 researchers), theoretical and statistical physics (Laboratoire de Physique Th\'eorique, LPT, 26 researchers), statistical physics, biophysics and nonlinear physics (Laboratoire de Physique Statistique, LPS, 38 researchers). The $h$-index and $N_j$ of each individual have been retrieved from Web of Science in July 2016. All types of publications were taken into account. Fig.~\ref{fig:example1} shows the results of this survey: a scatter plot of these quantities, though containing a global trend, is dominated by the scatter noise, illustrating the signals low correlation. This confirms that when the department is taken as a whole, individuals bibliometric indicators $h$ and $N_j$ carry complementary information. This example justifies the use of both $h$ and $N_j$ to characterise research accomplishment. In order to sharpen the comparison between individuals, we propose a different representation of these two bibliometric indicators. Since both $h$ and $N_j$ are bounded by $N$, one can define a \enquote{complex} representation of the two-dimensional index $(h,N_j)$ as follow
\begin{equation}
H \exp\left(\frac{i\pi}{2}M\right)= \frac{h}{\sqrt{2}}+i\,\frac{N_j}{\sqrt{2}}\;.
\label{eq:first}
\end{equation}
or, equivalently
\begin{equation}
H=\sqrt{\frac{h^2+N_j^2}{2}}\,,\qquad M=\frac{2}{\pi}\,\arctan\left(\frac{N_j}{h}\right)\;.
\label{eq:second}
\end{equation}
Obviously, the two-dimensional index $(H,M)$ is defined such that $0<H\leq N$ and $0<M\leq 1$. This representation separates the extensive contribution characterizing the volume of quality output, from an intensive characterization of its multidisciplinarity: small values of the argument $M$ indicates strong specialization, while $M$ close to one indicates thematic dispersion with rather low impact. Fig.~\ref{fig:example2} reproduces the same set of data as Fig.~\ref{fig:example1} in these two variables. Interestingly, while $H$ is widely distributed, the average of $M$ discriminates more sharply between the different \enquote{Laboratoires}. One can even identify that the overlap between LPT and LPS is ensured by LPT researchers working in statistical physics. The overlap between data of LPA and LPS is due to the fact that LPA benefits from large publication material due the applied part of its research area (readership extent), while LPS researchers often work in different fields (multidisciplinarity). Clearly the $M$-index differentiates between communities and highlights readership diversity and research multidisciplinarity. The two indices together allow for a better qualification of research achievement compared to a single evaluator. Moreover, this alternative representation increases the level of independance between the two components, with a coefficient of correlation of 0.7 for $h$ and $N_j$ and $0.14$ for $H$ and $M$ in our dataset.
\begin{figure}[htb]
\begin{center}
\includegraphics[width=0.6\textwidth]{Figure2.pdf}
\caption{Scatter plot of $M$ as a function of $H$ for the same panel as in Fig.~\ref{fig:example1}. Continuous lines show the mean $M$-index for each \enquote{Laboratoire} (see Text for details): 0.61 for LPA, 0.42 for LPT and 0.59 for LPS. The corresponding standard deviations are: 0.128 fxor LPA, 0.135 for LPT and 0.094 for LPS.
\label{fig:example2}}
\end{center}
\end{figure}
\section*{Discussion}
The use of the $h$-index to compare scientists from different research areas is a quite difficult task due to the inherent differences among different research fields. Although it is not an exclusive problem of the $h$-index, there have been several different efforts in the literature to supersede it. Interestingly, our work quantitatively demonstrates a bias associated with a citation-only index, namely its inability to capture research diversity. This is in favour to define $N_j$ as an additional index to supplement the $h$-index. However, the representation using the two-dimensional index $[H,M]$ is preferable since it yields weakly correlated components. Furthermore, while $M$ is bounded by 1 and separates finely the different disciplines, $H$, which is bounded by the number of papers, balances impact and diversity. In the following, we discuss questions that this two-dimensional index may rise and propose refinements to tackle its possible drawbacks.
\begin{itemize}
\item There are generalist journals that encompass different research areas and that could be downgraded by the proposed index. In order to overcome this difficulty, one could for example modify $N_j$ to categorize the paper using its research topic. Unfortunately, there is no uniform nomenclature between journal publishers (PACS numbers, keywords, subject classification,...). To do that, one would need a standard classification of research topics that is equivalent to Digital Object Identifier (DOI) system for publishers.
\item Let's try to compare two individuals with the same $H$. In an extreme case, an individual with $h=1$ and $N_j=N_0$, though carrying out multidisciplinary research, is not very successful since his research is not followed up by others. On the other side of the spectrum, a scientist with $h=N_0$ and $N_j=1$, though very exclusive in his publication choices, can be considered much more successful due to his citation rate. Hence having $M\approx1$ is never a good thing, while having $M\approx0$ can be of interest in some situations. That is why we claim that it would be ideal to have $h\approx N_j$, then $M\approx 1/2$, thus balancing recognition and curiosity.
\item The choice of the \enquote{perfect} $M$ would of course strongly depend on the kind of target one aims at, but it lifts a degeneracy and provides deciders with an additional lever. The existence of a two-dimensional index refines the judgement depending of what one looks for. For example, hiring a researcher for a specific research position or for his teaching abilities is not the same, the former would require a smaller $M$ than the latter. Furthermore, evaluating an institution through citation metrics only is not fair because interdisciplinary research is an indisputable quality of an institution as it illustrates its local and international attractiveness and the diversity of education offered to students.
\end{itemize}
We claim that it is too limiting of an approach to categorize individuals along a single axis. Additional and independent indicators should complement such an approach. Our main line of axiomatics is that, independently of how \enquote{good or bad} a researcher is ranked through the $h$-index, he may actually exhibit alternative qualities, like being a specialist, or conversely foraging results in various scientific areas. We claim that the two-dimensional index we introduced in Eq.~(\ref{eq:second}) is orthogonal to the usually accepted notion of \enquote{good or bad}.
Finally, we hope our proposition will trigger more bibliometric studies. Full-scale analysis of the $(H,M)$-index using different databases is an interesting question that will test its robustness and ease of computation. Before being adopted, it is necessary to apply it to real evaluation problems and situations: for example, additional studies comparing institutions should be developed. Nevertheless, we believe that combining the two numbers will refine degenerate situations and balance between impact and scope. Eventually, adding indices as legitimate as the $h$-index that quantify different facets of research achievements limit the misuse of the $h$-index.
| {'timestamp': '2017-10-06T02:07:52', 'yymm': '1706', 'arxiv_id': '1706.01882', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01882'} | arxiv |
\section*{Acknowledgements}
MML is supported by a grant from the ABC, KR is supported by a grant from COMMIT and EHFdH by an ERC (339374 - FAB4V).
{\small
\bibliographystyle{apacite}
\section{Multi-task DNNs as models of neural information processing in the brain}
\label{sec:2}
Artificial neural networks are inspired by computational principles of biological neuronal networks and are part of a large class of machine learning models that learn feature representations from data by optimizing a cost function. In this section, we discuss why we believe models based on optimizing cost functions, such as DNNs, are relevant for understanding brain function.
\subsection{Similarities in architecture and behavior between DNNs and the brain}
\label{sec:2_1}
Alexnet \cite{Krizhevsky2012-dk}, a model that is has been used extensively in research relating DNN's to the brain, consists of 7 layers (see \hyperref[sec:box]{box 1}). The first layer consists of filters with small kernels that are applied to each position of the input. In the subsequent four layers this procedure is repeated using the output of the preceding layer. This results in an increase in receptive field (RF) size and concurrently an increase in the specificity of tuning \cite{Zeiler2014-pw}. This increase of receptive field size and tuning specificity traversing the layers resemble the general architecture of feed-forward visual representations in the human brain \cite{Lamme2000-fv,DiCarlo2012-jk}.
A number of BOLD-MRI studies have revealed that the neural activation's in early areas of visual cortex show the best correspondence with the early layers of DNNs and that higher-tier cortical areas show the best correspondence with higher-tier DNN layers \cite{Guclu2015-gl,Eickenberg2017-mr}. MEG/EEG studies have furthermore shown that early layers of DNNs have a peak explained variance that is earlier than higher-tier DNN layers \cite{Cichy2016-sw,Ramakrishnan2016-da}. In addition, the DNN model has been shown to predict neural responses in IT, both from humans and macaque, much better than any other computational model \cite{Khaligh-Razavi2014-ap,Yamins2014-xi}.
A number of BOLD-MRI studies have revealed that the neural activations in early areas of the visual cortex show the best correspondence with the early layers of DNNs and that higher-tier cortical areas show the best correspondence with higher-tier DNN layers \cite{Guclu2015-gl,Eickenberg2017-mr}. MEG/EEG studies have furthermore shown that early layers of DNNs have a peak explained variance that is earlier than higher-tier DNN layers \cite{Cichy2016-sw,Ramakrishnan2016-da}. In addition, the DNN model has been shown to predict neural responses in IT, both from humans and macaque, much better than any other computational model \cite{Khaligh-Razavi2014-ap,Yamins2014-xi}.
The correspondence between DNNs and the brain begs the question of the degree to which DNNs show ‘behavior’ similar to humans. Early results indicate that humans and DNNs have a similar pattern of performance in terms of the kinds of variation (size, rotation) that make object recognition harder or simpler \cite{Kheradpisheh2016-ei}. It has also been shown that higher-tier layers of DNNs follow human perceptual shape similarity while the lower-tier layers strictly abide by physical similarity \cite{Kubilius2016-ho}. On the other hand, DNNs are, for instance, much more susceptible to the addition of noise to input images than humans \cite{Jang2017-fw} and the exact degree to which the behavior of DNNs and humans overlap is currently a central topic of research.
As others \cite{Kriegeskorte2015-kw,Yamins2016-cz}, we therefore believe that there is a strong case that DNNs can serve as a model for information processing in the brain. From this perspective, using DNNs to understand the human brain and behavior is similar to using an animal model. Like any model, it is a far cry from a perfect reflection of reality, but it is still useful, with unique possibilities to yield insights in the computations underlying cortical function.
\input{sections/box}
\subsection{Cost functions as a metric to optimize tasks}
\label{sec:2_2}
While deep neural networks offer the representational power to learn features from data, the actual learning process is guided by an objective that quantifies the performance of the model for each input-output pair. Common practice in machine learning is to express such an objective as a cost function \cite{Domingos2012-ex}. As Marblestone and colleagues argue, the human brain can be thought of implementing something very similar to cost functions to quantify the collective performance of neurons and consequently to steer the learning of representations in a direction that improves a global outcome \cite{Marblestone2016-od}.
\subsection{Problem simplification by task decomposition}
\label{sec:2_3}
While humans may act under a grand evolutionary objective of staying alive long enough to reproduce, we accomplish many small-scale objectives along the way, like guiding our arms to our mouth to eat or plan our path through the city. Each of these smaller objectives can be thought of as being governed by their own cost functions (see figure \ref{fig:1}). These could be embedded in the brain, either hard coded into the neural substrate by evolution, by sovereign decision making, or as part of meta-learning: learning to learn \cite{Baxter1998-el}.
While humans may act under a grand evolutionary objective of staying alive long enough to reproduce, we accomplish many small-scale objectives along the way, like guiding our arms to our mouth to eat or plan our path through the city. Each of these smaller objectives can be thought of as being governed by their own cost functions (see figure \ref{fig:1}). These could be embedded in the brain, either hard-coded into the neural substrate by evolution, by sovereign decision making, or as part of meta-learning: learning to learn \cite{Baxter1998-el}.
\begin{figure}[t]
\centering
\includegraphics[width=0.5\linewidth]{./img/params_under_pressure.pdf}
\caption{\textbf{Hierarchy of tasks related to the objectives the brain has to accomplish.} To make the evolutionary goal of Life tractable, the brain must be able to decompose it into manageable subtasks (blue and yellow arcs). All tasks and their cost functions effectively act on the same set of parameters (gray semicircle), while there may be differing degree of influence.}
\label{fig:1}
\end{figure}
It has been argued that a task becomes easier to solve if it can be decomposed into simpler tasks \cite{Jacobs1991-eg,Sutton1999-zf}. To support their argument they state that the simple problem of learning the absolute value function can be decomposed into learning two linear functions and a switching function, which leads to a model with fewer parameters that can be trained faster. While such a decomposition could be predefined through the neural substrate, they observe in their experiments that such a decomposition can naturally arise from competitive learning, if the same set of parameters are optimized for multiple tasks. As the decomposition of tasks is underdetermined, the learner may come up with different decompositions, each time it is trained.
The notion of decomposition has been frequently used in machine learning literature on reinforcement learning \cite{Dietterich2000-ka} to increase learning speed and enable the learning of task-local optima that can be reused to learn a superordinate goal. Very often it is even impossible to specify the objective for a complex task so that it is a necessity to decompose it into tractable partial objectives. An example is the objective of vision. Finding an objective for such a broad and vague task appears futile so that it is easier to define a subset of tasks like figure ground segmentation, saliency and boundaries. A noteworthy implementation of such a decomposition is the recent DNN ‘Uber-Net’ \cite{Kokkinos2016-jq}, which solves 7 vision related tasks (boundary, surface normals, saliency, semantic segmentation, semantic boundary and human parts detection) with a single multi-scale DNN network to reduce the memory footprint. It can be assumed that such a multi-task training improves convergence speed and better generalization to unseen data, something that already has been observed on other multi-task setups related to speech processing, vision and maze navigation \cite{Dietterich1990-mx,Dietterich1995-ia,Bilen2016-bv,Mirowski2016-aa,Caruana1998-ix}.
\section{Introduction}
The visual system is described as consisting of two parallel pathways. Research by Gross, Mishkin and colleagues, integrating insights from lesion \cite{Newcombe1969-yj} and anatomical studies \cite{Schneider1969-yc}, showed that these pathways emerge beyond the striate cortex with one involved in the identification of objects projecting ventrally, and the other involved in localization of objects, projecting to the parietal cortex \cite{Gross1977-xv,Mishkin1983-qi}. From the start of the dual-pathway theory, multiple pathways were believed to be computationally efficient \cite{Gross1977-xv}. Support for this idea comes from research using artificial networks with one hidden layer, showing that location and identity are better learned when units in the hidden layers are uniquely assigned to one of these functions \cite{Rueckl1989-ze,Jacobs1991-eg}.
In the early nineties, Goodale \& Milner argued that, on the basis of neuropsychological, electrophysiological and behavioural evidence, these pathways should be understood as have different goals. The ventral pathway (“vision for perception”) is involved in computing the transformations necessary for the identification and recognition of objects. The dorsal pathway (“vision for action”) is involved in sensorimotor transformations for visually guided actions directed at these objects \cite{Goodale1992-ww}.
It was recently suggested that the brain uses a variety of cost functions for learning \cite{Marblestone2016-od}. These cost functions can be highly diverse. The brain must optimize a wide range of cost functions, such as keeping body temperature constant or optimizing future reward from social interactions. High-level cost functions, by necessity, also shape other cost functions that determine the organization of perception: a cost function that is being optimized to minimize hunger affects the visual recognition cost function as foods have to be recognized. Mechanistically, this could take place directly through, for instance, a reward modulation of object recognition learning, or indirectly through evolutionary pressure on the cost function associated with object recognition learning. In this paper, we try to understand how multiple pathways in the visual cortex might evolve from the perspective of Deep Neural Networks (DNNs) (see \hyperref[sec:box]{box 1}) and cost functions (see \hyperref[sec:box2]{box 2}), and what this implies for how object information is stored in these networks.
We start with a discussion of the relevance of DNNs \cite{LeCun2015-lc,Schmidhuber2015-ae} and, following Marblestone \cite{Marblestone2016-od}, of cost functions for understanding the brain in section \ref{sec:2}. We extend our discussion with the importance of optimizing different cost functions simultaneously, presenting a hypothesis on the relationship between relatedness of tasks and the degree of feature representation sharing.
We test this hypothesis in a computational experiment with DNNs in section \ref{sec:3} to evaluate how much its feature representations contribute to each task. In section \ref{sec:4}, we discuss the degree to which we are able to translate our experimental findings to the division between the ventral and dorsal pathway, the multiple functions of the ventral cortex, and the apparent co-occurrence of both distributed and modular representations related to object recognition.
We finish this paper with a discussion of how this framework can be used experimentally to understand the human brain while elaborating on the limitations of DNNs and cost functions. For brevity, we do not consider models of re-current processing.
\section{Functional organization in multi-task DNNs}
\label{sec:3}
One hypothesis for the emergence of different functional pathways in the visual system is that learning and development in the cortex is under pressure of multiple cost functions induced by different objectives. It has been argued that the brain can recruit local populations of neurons to assign local cost functions that enable fast updating of these neurons \cite{Marblestone2016-od}.
We explore in this section the ramifications of multiple cost functions acting on the same neurons by translating the problem to instances of multi-task DNNs sharing the same parameters. By observing the contributions each feature representation in a DNN has to each task, we will draw conclusions about the functional separation we observe in the visual cortex in section \ref{sec:4}.
\subsection{Hypothesis}
\label{sec:3_1}
Given two cost functions that optimized two related tasks, which both put pressure on the same set of parameters, we conjecture that the parameters learned will be general enough to be used for both tasks (see figure \ref{fig:2}B). In contrast, we speculate that, when the tasks are unrelated, two subsets of parameters will emerge during learning that each lie within their task-respective feature domain (see figure \ref{fig:2}C). Because the amount of feature representation sharing is determined by the relation between tasks, and ultimately by the statistics of the credit assignments, we predict an upper to lower tier gradient of feature representation sharing with the least sharing in higher tier layers.
\begin{figure*}[t]
\centering
\includegraphics[trim=15mm 90mm 15mm 0mm, clip, width=1\linewidth]{./img/featuresharing.pdf}
\caption{\textbf{Task relatedness and feature representation sharing in deep neural networks.} Given a multi-layered neural network with a set of feature representations $\theta$ (indicated by cells) that optimize differently related tasks, we conjecture that the degree to which representations can be shared is dependent on the generalizability, which reduces with the depth of the network for single modality inputs. The generalizability is indicated by the strength of the color. Gray tones indicate high generalizability, while strong colors indicate features that are tuned to one respective cost function. \textbf{A} | Initial, untrained network configuration with 5 layers for a single modality input $x$. Cost functions $f_A$ and $f_B$ have direct access to their respective parameters $\theta_A$ and $\theta_B$. \textbf{B} | Two strongly related tasks inducing features that are generalizable to both tasks. Little function-specificity identifiable. \textbf{C} | Two largely unrelated tasks. While early simple features representations can be shared, intermediate and higher level representations are likely to be exclusive to their respective cost function due to their task-specificity.}
\label{fig:2}
\end{figure*}
\subsection{Training models for multiple tasks}
We test this hypothesis on feature representation sharing with DNNs trained for two tasks simultaneously. We construct two example setups involving a pair of related tasks (which we call RelNN), namely the simultaneous classification of ordinate and subordinate categories of objects in images, and a pair of unrelated tasks (which we call UnrelNN) namely the classification of objects and text labels in images (see figure \ref{fig:3}). As the relatedness of tasks is not clearly defined and an open problem \cite{Caruana1998-ix,Zhang2014-ta}, the tasks were selected based on the assumption that text recognition in UnrelNN is mostly independent of object recognition while in contrast ordinate level classification in RelNN is highly dependent on the feature representations formed for subordinate level classification.
\subsubsection{Training setup}
Both setups were implemented by training a version of AlexNet \cite{Krizhevsky2012-dk} on approximately half a million images from the ImageNet database \cite{Russakovsky2015-js} each
\footnote{The code, data and pretrained models are available here: \\\url{https://github.com/mlosch/FeatureSharing}}.
To optimize the models for two tasks simultaneously, the output layer of AlexNet was split into two independent layers.
Both models were trained on an identical set of images consisting of 15 ordinate classes further divided into 234 subordinate classes, each image augmented with an overlay of 3 letter labels from 15 different classes (see figure \ref{fig:3_1}).
The overlays were randomly scaled, colored and positioned while ensuring that the text is contained within the image boundaries.
Furthermore to enable the networks to classify two tasks at once, the output layer was split in two independent layers (see figure \ref{fig:3_2}) for which each had its own softmax activation.
For classification performance results see table \ref{tab:1}.
\begin{table}[t]
\begin{center}
\begin{tabular}{l|c|c|}
\cline{2-3}
& \multicolumn{2}{c|}{Top-5-error} \\
& \begin{tabular}[c]{@{}c@{}}Subordinate-level\\recognition\end{tabular} & \begin{tabular}[c]{@{}c@{}}Ordinate-level/Text\\recognition\end{tabular} \\ \hline\hline
Chance & 97.9\% & 66.7\% \\ \hline
RelNN & 14.0\% & 2.9\% \\ \hline
UnrelNN & 15.2\% & 4.9\% \\ \hline
\end{tabular}
\end{center}
\caption{\textbf{Classification errors.} Comparison of the error rates of RelNN and UnrelNN on a validation set of 11,800 images. The Top-5-error is defined as the correct prediction not being under the 5 most likely predictions. Both models were trained for $90$ epochs until convergence with Nesterov accelerated gradient descent \protect\cite{Nesterov1983-dp} with momentum of $0.9$, starting with a learning rate of $0.01$ and decreasing it every $30$ epochs by a factor of $10$.}
\label{tab:1}
\end{table}
\begin{figure}[t]
\centering
\subfloat[]{
\includegraphics[height=0.35\linewidth]{./img/example_tasks.pdf}
\label{fig:3_1}
}
\subfloat[]{
\includegraphics[height=0.35\linewidth]{./img/mtl_output.pdf}
\label{fig:3_2}
}
\caption{\textbf{Multi-Task-Learning setup.} (a) Two example images and their corresponding classification for our example setups of related and unrelated tasks. (b) To classify an input into two categories from different domains using AlexNet, the output layer is split in two where each split has its own softmax activation layer.}
\label{fig:3}
\end{figure}
\subsubsection{Measuring feature representation contribution}
To determine the degree of feature representation sharing in a neural network we measure the contribution each feature representation has to both tasks. Our method is inspired by the attribute contribution decomposition by \cite{Robnik-Sikonja2008-of} which has recently been used to visualize the inner workings of deep convolutional networks \cite{Zintgraf2016-yc}. The method is used to marginalize out features in the input image in the shape of small image patches, to observe the impact on the classification. In comparison, our method considers feature representations instead of features as we are not interested in the contribution of particular feature instances. The interested reader is referred to appendix \ref{sec:appendix} for the definition and derivation of the task contribution.
\subsubsection{Results}
We visualize the layer-wise task contributions by unrolling the feature representations of a layer on a rectangle and coloring each resulting cell by the composition of its contribution. Blue is used as indicator for the subordinate-level recognition task and yellow as indicator for the text- and basic-level-recognition task respectively. Equal contribution to both tasks results in grayish to white tones while little contribution to either task causes dark to black tones (see figure \ref{fig:4} for the color coding). A high degree of feature representation sharing would hereby generate cells colored in the range from black and gray to white, while low degree of sharing would result in more pronounced and clearly distinguishable colors of yellow and blue.
The two visualizations in figure \ref{fig:4} show a substantial difference in feature representation contribution as the representations in layer 2 to 5 of the RelNN contribute to both tasks much more equally than the representations of the UnrelNN. This is in line with our expectation depicted in figure \ref{fig:2} and our choice of setups. Contrary to our prediction, the degree of feature representation sharing in layer 1 of the UnrelNN is lower than expected; this can be explained by assuming that text recognition is mostly independent of all features but horizontal and vertical lines. Note also that most of the representations in the fully connected layers in both setups have only little contribution. This might seem counter-intuitive at first sight but is an effect of the abundance of representations coupled with the training scheme involving dropout. Dropout significantly reduces co-dependencies between units \cite{Dahl2013-io} resulting in only small changes in classification probability after marginalizing out a single representation.
We also observe that there is a dominance of blue cells expressing low contribution to the text- and basic-level-recognition task but high contribution to the subordinate-level-recognition task. We conjecture that this is because the subordinate-level-recognition task uses a larger fraction of units to distinguish between 200 classes.
Comparing the layers of both networks, it becomes evident that there generally is a higher degree of feature representation sharing in the RelNN consistent with the idea that relatedness between tasks and therefore cost functions strongly influences the degree of feature representation sharing across layers. More importantly, these results demonstrate that these types of ideas can be translated, using the right image data-sets and task-labels, into quantifiable predictions on the degree of feature sharing that might be observed in the brain.
\begin{figure*}[!htb]
\centering
\subfloat{
\includegraphics[width=1\linewidth]{./img/featuresharing_basicsubord.pdf}
\label{fig:4_1}
}
\\
\subfloat{
\includegraphics[width=1\linewidth]{./img/featuresharing_objectstext.pdf}
\label{fig:4_2}
}
\caption{\textbf{Composition of feature representation contribution in DNNs to dual task.} (Best viewed in color) Each cell represents a feature representation in a neural network and its contribution. Task description and color coding of the contributions are displayed in the top left corner of each visualization. The cells are ordered by contribution magnitude of the yellow task so that the first cell in each layer displays the representation that contributes the least. (a) Contributions to RelNN, subordinate- and ordinate-level-recognition. (b) Contributions to UnrelNN, subordinate-level- and text-recognition.}
\label{fig:4}
\end{figure*}
\section{Measuring parameter contribution}
\label{sec:appendix}
\subsection{Marginalization of parameters}
In models that are able to handle the lack of information about a particular representation like in na\"ive Bayesian classifiers, the contribution can be measured by marking the representation as unknown. Typically though, neural networks are not able to handle missing information and setting the parameters of a representation to zero will still result in interpretable information for subsequent layers. While removing a feature representation and retraining the network would alleviate this issue, quantifying the contribution of thousands of representations this way is generally unfeasible. Instead we make use of the models classification probabilities given by the softmax activation output which allows us to estimate the classification probability while lacking a representation by marginalizing it out via standard method from statistics. Marginalization effectively computes the weighted average of the classification probabilities after the representation has been replaced with random values sampled from an appropriate distribution. See equation \ref{eq:1} for the mathematical definition used for our evaluation.
\begin{align}
p(y|x,\Theta_{\setminus \theta}) = \sum_{\theta} p(y | x,\Theta) p(\theta)
\label{eq:1}
\end{align}
$p(y|x,\Theta)$ defines here the probability of input $x$ belonging to class $y$ and $p(y|x,\Theta_{\setminus \theta})$ the probability if $\theta$ is unknown. Note that a feature representation is represented by its parameters $\theta$, which in turn consists classically of a weight $w$ and a potential bias $b$ in a neural network setting. $\Theta$ defines then the set of all parameters such that $\theta \in \Theta$. Each classification probability is eventually weighted by the prior probability of the sample $\theta$ expressing the likelihood the parameter in question takes value $\theta$. We used 100 samples in our experiments to approximate the contribution.
\subsubsection{Derivation}
Given a parametric model like a DNN that is described by its parameters $\Theta$, we can express the probability of input $x$ belonging to class $y$ as $p(y|x,\Theta)$, where the probabilities are given by the softmax output layer. To measure the contribution of a feature generated by parameter $\theta \in \Theta$, we are interested in what the probability is when $\theta$ is missing or unknown. By assuming that the input is independent of the parameters as well as the parameters are independent of each other, such that $p(x,\Theta) = p(x)p(\Theta)$ and $p(\Theta) = p(\Theta_{\setminus \theta}) p(\theta)$ and by treating the parameters as random variables we can marginalize out $\theta$ as follows.
\begin{align}
p(y|x,\Theta_{\setminus \theta}) &= \frac{\int_{\theta} p(y,x,\Theta) d\theta}{\int_{\theta} p(x, \Theta) d\theta}\\
&= \frac{\int_{\theta} p(y | x,\Theta) p(x,\Theta_{\setminus \theta}) p(\theta) d\theta}{p(x, \Theta_{\setminus\theta}) \int_{\theta} p(\theta) d\theta} \\
&= \int_{\theta} p(y | x,\Theta) p(\theta) d\theta
\end{align}
As the integral over all possible values of $\theta$ is intractable for DNN-like structures, we instead approximate the probability by sampling from $\theta$ a finite number of times. We can now express the upper equation with a sum over all samples of $\theta$.
\begin{align}
p(y|x,\Theta_{\setminus \theta}) = \sum_{\theta} p(y | x,\Theta) p(\theta)
\end{align}
To sample from $\theta$, we assume that the values are normal distributed with uniform variance and mean centered at the learned weight $w$ and bias $b$:
\begin{align}
\theta &\sim \mathcal{N}(\mu=w,\,\Sigma=I), \mathcal{N}(\mu=b,\,\Sigma=I) \\
\textit{so that }
p(\theta) &= p_{\mathcal{N}(w,I)}(w) \cdot p_{\mathcal{N}(b,I)}(b)
\end{align}
\subsection{Generalizing contributions from classes to tasks}
As proposed by \cite{Robnik-Sikonja2008-of}, we use the weighted evidence ($WE$) to measure the contribution of parameter towards class probability $p(y|x,\Theta)$ (see equation A.6) instead of taking the difference of probabilities directly. $WE_{\theta}(y|x,\Theta)$ gives us a positive value indicating $\theta$ adds evidence for class $y$ for input $x$, while a negative value adds evidence against class $y$ and zero if $\theta$ has no contribution at all. To eventually determine the contribution towards a class independent of the input we calculate the arithmetic mean of the absolute weighted evidence over more than 500 input samples (see equation \ref{eq:class_contribution}) from the test set.
\begin{align}
odds(z) &= \frac{p(z)}{1-p(z)} \\
WE_{\theta}(y|x,\Theta)&=log_2(odds(y|x,\Theta)) \nonumber\\
&- log_2(odds(y|x,\Theta_{\setminus \theta})) \\
C_{\theta}(y|\Theta) &= \frac{1}{n}\sum_{j=1}^n \left| WE_\theta(y|x_j,\Theta) \right| \label{eq:class_contribution}
\end{align}
We finally measure the contribution to a task $t$ by selecting the contributions $C_{\theta}(y|\Theta)$ that satisfy $y = y_{true}$ which are the class predictions that are correct. Furthermore filtering out predictions that had been incorrectly inferred from the network, we can increase certainty that the inputs used to evaluate the contributions lead to high probability for the correct class and low everywhere else. We further generalize the contribution of $\theta$ to task $t$ by averaging over the contributions to each class $y_k$ within task $t$ (see equation \ref{eq:task_contribution}).
\begin{align}
TC_{\theta}(t | \Theta) = \frac{1}{K} \sum_{k=1}^K C_\theta (y_k|\Theta) \label{eq:task_contribution}\\
\nonumber t \in Tasks,\, K \in |outputs_t|
\end{align}
\end{appendix}
\section{Implications of models optimized for multiple tasks for understanding the visual system}
\label{sec:4}
In section \ref{sec:3} we presented an example in which the degree to which feature representations can be shared in a neural network depended on the relatedness of the tasks they are optimized for. In a neural population under pressure of the optimization for two unrelated tasks and the pressure to optimize the length of neuronal wiring \cite{Chklovskii2004-ki}, a spatial segregation is likely to occur, resulting in anatomically and functionally separate pathways. In this section we consider to what degree we can understand the organization of the visual system from the perspective of a DNN that has been trained on multiple tasks and discuss three hypotheses derived from the simulations.
\subsection{The visual system optimizes two cost functions of unrelated tasks}
\label{sec:4_1}
The early visual cortex has neurons that respond to properties such as orientation, wavelength, contrast, disparity and movement direction that are relevant for a broad range of visual tasks \cite{Wandell1995-yx}. Moving upwards from early cortex we see a gradual increase in the tuning specificity of neurons resulting in the dorsal and ventral pathways that have, as has become clear the last 25 years, unrelated goals \cite{Goodale1992-ww}. The dorsal pathway renders the representation of objects invariant to eye-centered transformations in a range of reference frames to allow efficient motor planning and control \cite{Kakei1999-vh}, while the ventral pathway harbors object-centered, transformation invariant features \cite{Leibo2015-nb,Higgins2016-aj} to allow efficient object recognition.
These observations concur well with the predictions and experimental results we made about feature representation sharing in DNNs. Given that the two tasks, vision for recognition and vision for action, are mostly unrelated we can understand the gradual emergence of functional and anatomical separation between these systems from this perspective.
Nonetheless, we note that the functional units of the pathways beyond the occipital lobe are not entirely separated and cross-talk does exist between these pathways \cite{McIntosh2009-ua,Farivar2009-qe,De_Haan2011-aq,Van_Polanen2015-tg}: a phenomenon we also observed in our experiment in section \ref{sec:3}. In the UnrelNN, there are feature representations that contribute to both tasks throughout all layers of the network. Consequently the brain might trade off contribution and wiring length so that neurons that contribute little are tolerable to have long wiring to the functional epicentre.
As a whole the existence of two pathways guided by two cost functions of unrelated tasks might be seen as an illustration of the efficient decomposition of the overall vision function.
\subsection{The visual pathways contain further task decompositions each with their own cost functions}
\label{sec:4_2}
We further generalize our perspective on cost function optimization of the visual system via the general observation made from machine learning that a complex task becomes simpler to solve if it is decomposed into simpler smaller tasks (see section \ref{sec:2_3}). Given that the tasks we assign to the visual pathways are rather complex and vague we conjecture that there might be a broad range of cost functions active in the pathway regions to optimally decompose the task of vision resulting in a schematic similar to figure \ref{fig:5}.
\begin{figure*}[t!]
\centering
\includegraphics[width=1\linewidth]{./img/visual_pathways.pdf}
\caption{\textbf{How functional pathways in the visual system could be associated with cost functions.} (Vision for perception pathway in blue, vision for action pathway in yellow). Within the pathways are streams that develop under guidance from cost functions which are a direct decomposition of the pathways cost function. Feature representations that are learned for one task can still be used by units in the other pathway (crosstalk arrows). Both pathways share the same input units that either develop through the relation between tasks and/or evolutionary or developmental learning.}
\label{fig:5}
\end{figure*}
The ventral and dorsal pathways are each involved in a multitude of tasks serving the overall goals of vision for perception and vision for action. Examples of subordinate tasks for vision for action are localization, distance, relative position, position in egocentric space and motion and these interact with the goals that are part of vision for action: pointing, grasping, self-termination movements, saccades and smooth pursuit \cite{De_Haan2011-aq}. Sub-ordinate tasks for vision for perception include contour integration, processing of surface properties, shape discrimination, surface depth and surface segmentation. These in turn interact with executing the goals that are part of vision for perception: categorization and identification of object but also scene understanding \cite{Groen2017-ax}.
Reasoning from this framework we can also understand the existence of multiple ‘processing streams’ within the dual pathways. For instance, within ventral cortex there appears to be a pathway for object recognition and a pathway for scene perception. The object recognition pathway consists of areas like V4 which responds to simple geometric shapes and the anterior part of inferior temporal (aIT) that is sensitive for complete objects \cite{Kravitz2013-rv}. The scene recognition pathway contains areas such as the occipital place area (OPA), involved in the analyses of local scene elements and the parahippocampal place area (PPA) which responds to configurations of these elements \cite{Kamps2016-ov}. The tasks of scene and object perception are closely related; scenes consist of objects. However, scene perception involves relating the positions of multiple objects to each other, scene gist and navigability \cite{Groen2017-ax}. From our framework we would predict that an area like OPA is mainly involved in the task of scene perception but has RFs that are also used for object perception and the opposite pattern for V4. Crucially, we believe this framework can be used to generate quantitative predictions for this amount of sharing.
\subsection{Distributed versus modal representations}
\label{sec:4_3}
How information is represented is one of the major questions in cognitive neuroscience. When considering object based representations both distributed \cite{Haxby2001-qj,Avidan2009-cu} and module-based representations \cite{Cohen2000-bs,Kanwisher2000-ei,Puce1995-qs} have been observed.
Module-based representations, and theories stressing their importance, point to the existence of distinct cortical modules specialized for the recognition of particular classes such as words, faces and body parts. These modules encompass different cortical areas and, in case of the fusiform face area and visual word form area, even similar areas but in different hemispheres \cite{Plaut2011-gq}. Conversely, distributed theories of object recognition point to the possibility to decode information from a multitude of classes from the patterns of activity present in a range of cortical regions \cite{Haxby2001-qj,Avidan2009-cu}.
If we consider feature representations in the early and intermediate layers of the UnrelNN (figure \ref{fig:4}) as a reasonable approximation of representations in early / intermediate visual areas, we note that most units are being shared by both streams. However, some units contribute more to one than the other task and are spatially intermingled at the same time. An external observer, analyzing the activity of these representations under stimulation with pattern analysis would conclude that information from both tasks is present, and conclude that a distributed code is present. If the same observer would investigate the representations at the top of the stream the observer would conclude that there is an area dedicated to the analysis of text and another to the analysis of the subordinate task.
Translated to the visual system this would mean that distributed representations should be observed in areas such as posterior inferior temporal (pIT), OPA and V4 because these units are activated by multiple tasks but with a different weighting. Vice versa, at the top of a pathway or stream the network would show a strong module based pattern of activation. In sum, multi-task DNNs provide a framework in which we can potentially understand that both modal and distributed representations can be observed experimentally but suggest that the patterns of activity should be interpreted as emerging from the network as a whole.
\section{Discussion}
\label{sec:5}
Following Marblestone and colleagues \cite{Marblestone2016-od}, and the strength of the similarities between DNNs and the visual brain, we hypothesize that cost functions, associated with different tasks, are a major driving force for the emergence of different pathways.
A central insight from machine learning is that functions become easier to learn when they are decomposed as a set of unrelated subtasks. As a whole, the existence of two pathways guided by two cost functions of unrelated tasks might be seen as an illustration of the efficient decomposition of the overall vision function \cite{Sutton1999-zf}. Observing that DNNs decompose a problem in multiple steps, with the earlier layers related to the input and later layers related to outputs demanded for the task, we hypothesized that the degree of feature representation sharing between tasks, will be determined by the relatedness of the tasks with an upper-to-lower tier gradient.
On this basis, we performed simulations that confirm that units in a DNN show a strong degree of sharing when tasks are strongly related and a separation between units when tasks are unrelated. The degree to which this framework will be useful depends on the degree to which understanding elements of brain function using DNNs is valid which is discussed in section \ref{sec:5_1} and \ref{sec:5_2}.
Subsequently, we will argue that having multiple pathways within a multi-task network might also help explaining catastrophic forgetting, the phenomenon that an old task is overwritten by learning a new task (section \ref{sec:5_3}). Next, we will discuss the ‘vision for perception’ and ‘vision for action’ framework (section \ref{sec:5_4}), and finally we discuss the possibilities of using multi-task for further understanding the brain and ways in which our current analysis approach can be extended (section \ref{sec:5_5}).
\subsection{The biological realism of machine learning mechanisms}
\label{sec:5_1}
While there has been much progress in the field of Deep Learning, it remains a question how and if the weights of neurons are updated in learning under the supervision of cost functions in the brain, that is, what the actual learning rules of the brain are.
DNNs are trained using back-propagation, an algorithm believed to miss a basis in biology \cite{Crick1989-dl,Stork1989-kg}. Some of the criticisms include the use in backpropagation of symmetrical weight for the forward inference and backward error propagation phase, the relative paucity of supervised signals and the clear and strong unsupervised basis of much learning. Recent research has shown that the symmetrical weight requirement is not a specific requirement \cite{Lillicrap2016-eg}. Roelfsema \& Van Ooyen already showed in \cite{Roelfsema2005-so} that a activation feedback combined with a broadly distributed, dopamine-like error-difference signal can on average learn error-backpropagation in a reinforcement learning setting. Alternative learning schemes, like Equilibrium Propagation \cite{Scellier2017-ai} have also been shown to approximate error-backpropagation while effectively implementing basic STDP rules.
Alternatively, effective deep neural networks could be learned through combination of efficient unsupervised discovery of structure and reinforcement learning. Recent work on predictive coding suggests this might indeed be feasible \cite{Whittington2017-if}. Still, the learning rules that underpin deep learning in biological systems are very much an open issue.
\subsection{Cost functions as the main driver of functional organization}
\label{sec:5_2}
Reviewing literature on the computational perspective for functional regions in the visual system, we conclude that each region might be ultimately traced back to being under the influence of some cost function that the brain optimizes and its interplay or competition for neurons \cite{Jacobs1991-eg} with other cost functions resulting in different degrees of feature representation sharing. The domain-specific regions in the ventral stream for example may be caused by a cost function defined to optimize for invariance towards class-specific transformations \cite{Leibo2015-nb}, of which the Fusiform Face Area could additionally be bootstrapped from a rudimentary objective, hard coded by genetics, to detect the pattern of two dots over a line \cite{McKone2012-bv,Marblestone2016-od}. Finally, as we argued in section \ref{sec:4}, the functional separation of the ventral and dorsal pathway can be associated with two cost functions as well. We emphasize that the precise implementation of these cost functions is unknown and note the concept of the task ``vision for recognition" and ``vision for action" is merely a summary of all the subordinate tasks that these two tasks have been decomposed into, as argued in section \ref{sec:2_3} and the \hyperref[sec:box]{cost function box}.
Reviewing literature on the computational perspective for functional regions in the visual system, we conclude that each region might be ultimately traced back to being under the influence of some cost function that the brain optimizes and its interplay or competition for neurons \cite{Jacobs1991-eg} with other cost functions resulting in different degrees of feature representation sharing. The domain-specific regions in the ventral stream for example may be caused by a cost function defined to optimize for invariance towards class-specific transformations \cite{Leibo2015-nb}, of which the Fusiform Face Area could additionally be bootstrapped from a rudimentary objective, hard coded by genetics, to detect the pattern of two dots over a line – being the basic constellation of a face \cite{McKone2012-bv,Marblestone2016-od}. Finally, as we argued in section \ref{sec:4}, the functional separation of the ventral and dorsal pathway can be associated with two cost functions as well. We emphasize that the precise implementation of these cost functions is unknown and note the concept of the task “vision for recognition” and “vision for action” is merely a summary of all the subordinate tasks that these two tasks have been decomposed into, as argued in section \ref{sec:2_3} and the \hyperref[sec:box]{cost function box}.
\subsection{Multiple pathways as a solution for catastrophic forgetting}
\label{sec:5_3}
While joint cost functions can be learned when the quantities needed by the cost functions are all present at the same time, most animals are continually learning and different aspects of cost functions are present at different times. Then, it is well known that standard neural networks have great difficulty learning a new task without forgetting an old task, so-called catastrophic forgetting. Effectively, when training the network for the new task, the parameters that are important for the old task are changed as well, with negative results. While very low learning rates, in combination with an alternating learning scheme, can mitigate this problem to some degree, this is costly in terms of learning time. For essentially unmixed outputs, like controlling body temperature and optimizing financial welfare, an easy solution is to avoid shared parameters, resulting in separate neural networks, or “streams”. Similarly, various properties can be derived from a single stream, like visual aspects (depth, figure-ground separation, segmentation), from an object recognition stream, where each aspect substream is learned via a separate cost function. For tasks sharing outputs, and thus having overlap over different tasks, evidence increasingly suggests that the brain selectively “protects” synapses for modification by new tasks, effectively “unsharing” these parameters between tasks \cite{Kirkpatrick2016-qa}.
\subsection{What and where vs. vision for action and perception}
\label{sec:5_4}
Goodale \& Milner argued that the concept of a ‘what and where’ pathway should be replaced by the idea that there are two pathways with different computational goals, vision for perception and vision for action, summarized as a ‘what’ and ‘how’ pathway \cite{Goodale1992-ww}. Insights from the last 25 years of research in vision science have shown that the original idea of a what and where pathway lack explanatory power. It is clear that RFs in inferior temporal cortex are large when objects are presented on a blank background \cite{Gross1985-hg}. However, these become substantially smaller and thereby implicitly contain positional information, when measured against a natural scene background \cite{Rolls2003-aq}. Interestingly, studies on DNNs have shown that approximate object localization can be inferred from a CNN trained on only classification, although the spatial extend of an object cannot not be estimated \cite{Oquab2015-lj}.
With regards to the dorsal pathways it has been observed that there are cells relating to gripping an object that are specific for object-classes \cite{Brochier2007-bk} showing that this pathway contains, in addition to positional information, categorical information. These observations are in direct opposition to one of the central assumptions, a strong separation between identity and location processing, of the ‘what’ and ‘where’ hypothesis. It is now abundantly clear that the move from ‘what’ and ‘where’ pathway to ‘what’ and ‘how’ pathways and moving from input to function fits particularly well with vision as a multi-task DNN.
\subsection{Future research}
\label{sec:5_5}
Originally DNNs were criticised for being “black” boxes, and using DNNs to understand the brain would equate to replacing one black box with another. Recent years have shown a rapid increase in our understanding of what makes a DNN work \cite{LeCun2015-lc,Simonyan2014-uo,Zeiler2014-pw} and how to visualize the features \cite{Zintgraf2016-yc,Zhou2014-ue,Zeiler2014-pw} that give DNNs its power.
These developments illustrate that DNNs are rapidly becoming more “gray” boxes, and are therefore a promising avenue into increasing our understanding of the architecture and computations used by the visual system and brain.
We therefore believe it is sensible to investigate to which degree multi-task DNNs, trained using the same input, will allow us to understand the functional organisation of the visual system. Using the analytical framework introduced in section \ref{sec:3}, we can generate a fingerprint for each of the layers in a network based on the degree of feature representation sharing. This can be subsequently related to the activation patterns, evoked by different tasks observed within different cortical areas. Alternatively it is possible to compare representational dissimilarity matrices \cite{Kriegeskorte2008-vo} obtained from single and multitask-DNNs and determine which better explain RDMs obtained from cortical areas.
An open question remains how subtasks and their associated cost functions are learned from overall goals/general cost functions, both in machine learning \cite{Lakshminarayanan2016-ro} and in neuroscience \cite{Marblestone2016-od,Botvinick2009-qs}.
| {'timestamp': '2017-09-19T02:04:44', 'yymm': '1706', 'arxiv_id': '1706.01757', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01757'} | arxiv |
\section{Introduction}
\IEEEPARstart{O} ne of the phenomena that influences significantly the performance of binary low-density parity-check codes (or simply LDPC codes) is known as $trapping$ $sets$. An $(a,b)$ trapping set of size $a$ is an induced subgraph of the Tanner graph on $a$ variable nodes and $b$ check nodes of odd degrees. Among all trapping sets, the most impressive ones are those with check nodes of degrees one or two. This category is so-called elementary trapping sets (or simply ETSs). In addition, according to the literature, ETSs that cause high decoding failure rate and are the main culprit of high error floor are those which satisfy the inequality $\frac{b}{a}<1$.
Hereafter, the symbol $\gamma$ and $\lambda$ stand for the column weight and the row weight of variable-regular LDPC codes, respectively. In $\cite{2011}$ it is proved that a binary $(\gamma,\lambda)$-regular LDPC code whose Tanner graph is 4-cycle free contains no $(a,b)$ trapping set of size $a\leq \gamma$, where $\frac{b}{a}<1$. In $\cite{2014}$ Karimi et al. present a class of ETSs based on short cycles in the Tanner graph of variable-regular LDPC codes. Any member of a class such as $S$ is a sequence of ETSs starting from a short cycle which grows by one variable node at a time to generate $S$. Such obtained sequence is called a layered superset (LSS) of a short cycle. For column weight values of $3,4,5,6$, girths $6,8$ and $a,b\leq10$ all classes of ETSs are presented. In $\cite{2015}$, LSSs of some graphical structures other than short cycles are demonstrated, by Hashemi et al., to find all $(a,b)$ elementary trapping sets. In $\cite{2016}$, they propose three expansion techniques to obtain all ETSs, referred to as leafless ETSs (LETSs), in which each variable node is connected to at least two even degree check nodes. This new characterization has some advantages compared to their counterparts. For example, it covers all the LETSs with $a\leq a_{max}$ and $b\leq b_{max}$, for any value of $a_{max}$ and $b_{max}$. Moreover, short cycles enumerated have less lengths compared to LSS-based search. Furthermore, in $\cite{2010}$ by assuming $a\leq8$ and $\frac{b}{a}<1$, a characterization of $(a,b)$ trapping sets of $(3,\lambda)$-regular LDPC codes from Steiner triple systems is studied. Moreover, in $\cite{Vasic}$, a method to construct $(3,\lambda)$-regular LDPC code whose Tanner graph has girth 8 and contains a minimum number of small trapping sets is provided.
In this paper, we provide analytically lower bounds on the size of ETSs of a variable-regular LDPC code. Some of our results are independent of the girth of the Tanner graph. For example, we prove that if $\frac{b}{a}<1$ then a variable-regular LDPC code contains no $(a,b)$ ETS of size $a\leq\gamma$. Some others are provided directly according to the girth. We demonstrate that the Tanner graph of a variable-regular LDPC code with girth 8 contains no $(a,b)$ ETS of size $a\leq2\gamma-2$ and the minimum number of unsatisfied check nodes in ETSs is $\gamma$. We present a construction for ETSs belonging to variable-regular LDPC codes with girth 8 which shows the obtained lower bounds for $a$ and $b$ are tight for all values of $\gamma$. These lower bounds on the size and the number of degree-one check nodes of ETSs provide us with a chance to present a method to achieve the lower bounds for the size of ETSs belonging to irregular LDPC codes. We apply this method on irregular LDPC codes whose column weight values are a subset of $\{2,3,4,5,6\}$.
Moreover, we show that the minimum size of $(a,b)$ ETSs related to a variable-regular LDPC code with girth 10 and $\gamma=3,4$ are 7 and 12, respectively. And we prove that, generally, variable-regular LDPC codes with girth 10 contain no ETS of size $a\leq(\gamma-1)^2$. Finally, we generalize our results for variable-regular LDPC codes with any girth and column weight values, as follows. Variable-regular LDPC codes with girths $g=2(2k+1)$ and $g=2(2k+2)$ contain no $(a,b)$ ETSs of sizes $a\leq(\gamma-2)^k$ and $a\leq2(\gamma-2)^k$, respectively. We believe that the main contribution of this article is that if all types of $(a,b)$ ETSs of a Tanner graph with the property of $\frac{b}{a}<1$ are under consideration, the achieved lower bound can be the minimum value of the parameter $a$ as the initial input of search algorithms.
The rest of the paper is organized as follows. Section II presents some basic notations, definitions and graph theories which are our principle tools to prove our results. In section III, we provide lower bounds for the size of ETSs which are independent of the girth. Section IV presents the lower bounds for the size of ETSs belonging to variable-regular and irregular LDPC codes with girth 8 as well as tables to illustrate the influence of lower bounds on investigating the existence and non-existence of some ETSs. Lower bounds for the size of ETSs of variable-regular LDPC codes with girth 10 are investigated in Section V. In section VI we generalize our results for variable-regulare LDPC codes with any girth. In the last section we summarize our results.
\section{Preliminaries}\label{}
One of the most important representations of codes is a Tanner graph. A Tanner graph is a bipartite graph in which the set of variable nodes (VNs) forms one of the vertex sets, which is denoted by $V$, and the set of check nodes (CNs) forms the other vertex set, which is denoted by $C$. The degree of a node $v$, either variable or check node, is denoted by $d(v)$. The minimum degree of nodes is denoted by $\delta$. The set of vertices connected to a vertex $v$ forms a neighbor set of $v$ and is denoted by $N(v)$. A variable-regular LDPC code is corresponding to a Tanner graph in which for all $v\in V$ we have $d(v)=\gamma$. Since a bipartite graph has no odd cycle, any cycle is represented by alternating sequence of check nodes and variable nodes. The length of the shortest cycle is called girth and denoted by $g$.
Take an induced subgraph of the Tanner graph on a subset $S$ of $V$. The subgraph contains some check nodes of odd degrees and some check nodes of even degrees referred to as unsatisfied check nodes and satisfied check nodes, respectively. If $|S|=a$ and the number of unsatisfied check nodes is $b$ then the induced subgraph provides an $(a,b)$ trapping set of size $a$. An $(a,b)$ trapping set is called elementary if all check nodes are of degrees one or two. As a result, all unsatisfied check nodes in an elementary trapping set (or ETS) are of degree one. In this paper we concentrate on all ETSs whose parameters satisfy the inequality $\frac{b}{a}<1$ because of their significant influence on the error floor region.
In an $(a,b)$ ETS, by removing all unsatisfied check nodes and replacing every satisfied check node with an edge we obtain a graph with $a$ vertices which is called a normal graph. In this paper instead of searching all ETSs, we consider their corresponding normal graphs.
In this section, we also provide some graph theories and definitions which are our principle tools to prove our results.
\begin{Definition}
Given a graph $G=(V,E)$, where $|V|$ and $|E|$ are the number of vertices and edges, respectively. The degree sum formula is as follows
\begin{center}
$\sum_{v\in V}d(v)=2|E|$.
\end{center}
\end{Definition}
\begin{Definition}
A complete bipartite graph is a type of bipartite graph in which every vertex of the first vertex set is connected to every vertex of the second vertex set. A complete bipartite graph with $m$ vertices in one of the vertex sets and $n$ vertices in the other is denoted by $K_{m,n}$.
\end{Definition}
\begin{Definition}
A complete graph is a graph in which every pair of distinct vertices is connected by a unique edge. A complete graph on $n$ vertices is denoted by $K_{n}$.
\end{Definition}
\begin{Definition}
A triangle-free graph is a graph in which no three vertices form a cycle of length three. In other words, a triangle-free graph is a $K_3$-free graph.
\end{Definition}
The existence of a $2k$-cycle in the ETS is equivalent to the existence of a cycle of length $k$ in its correspondent normal graph. For example, if a sequence of $v_0,c_0,v_1,c_1,v_2,c_2$ is a 6-cycle of an ETS, where $v_i\in V$ and $c_i\in C$, then by replacing any check node with an edge we obtain a cycle of length three in the normal graph whose vertices are $v_1,v_2,v_3$ . For example, in Fig. 1 $(a)$ the trapping set contains two 6-cycles and its corresponding normal graph has two triangles. Moreover, any 4-cycle in the trapping set is equivalent to a multiple edge in its corresponding normal graph. As an example, if a sequence of $v_0,c_0,v_1,c_1$ is a 4-cycle of a trapping set then by replacing any check node with an edge we have a multiple edge $(v_1,v_2)$.
In a 4-cycle free Tanner graph, the normal graph of each ETS is free of multiple edges which is called a simple graph. And in a Tanner graph with girth at least 8, the normal graph of each ETS is a simple and triangle-free graph. For example, in Fig. 1 $(b)$ the ETS contains no 6-cycle and its corresponding normal graph is triangle-free.
\begin{center}
\begin{figure}
\centering
\includegraphics[scale=.3]{corres.pdf}
\caption{$(a)$ is a normal graph and its corresponding (4,6) ETS with $\gamma=4$ and $(b)$ is a (5,3) ETS with $\gamma=4$ and its corresponding normal graph}
\end{figure}
\end{center}
\section{Lower bounds for the size of ETSs which are independent of the girth}\label{}
In this section all the results are analytically obtained and are compared with those based on exhaustive search algorithms. First, we demonstrate some results regarding to the variables $a$, $b$ and $\gamma$ in an $(a,b)$ ETS.
\begin{lemma}
An $(a,b)$ ETS and its corresponding normal graph of a variable-regular Tanner graph, for which $\frac{b}{a}<1$, hold the following conditions.
\noindent $(i)$ The normal graph has at least one vertex of degree $\gamma$.
\noindent $(ii)$ There is no $(a,b)$ ETS, where $a\leq \gamma$.
\noindent $(iii)$ If the normal graph contains $|E|$ edges then $b=a\gamma-2|E|$.
\noindent $(iv)$ If $a$ is an even number then $b$ is also an even number.
\noindent $(v)$ If $a$ is an odd number then parameters $\gamma$ and $b$ both are even or odd.
\end{lemma}
\begin{proof}
$(i)$ Since our desire $(a,b)$ ETSs are those hold the inequality $\frac{b}{a}<1$, the normal graph has at least a vertex of degree $\gamma$. Because, if for each vertex, $v$, we have $d(v)<\gamma$ then $\gamma-d(v)\geq1$. Therefore $b=\sum_{i=1}^{a}(\gamma-d(v_i))\geq a$ and so $\frac{b}{a}\geq1$.
$(ii)$ It is clear that in any graph with $a$ vertices, the degree of each vertex is at most $a-1$, since the normal graph has at least a vertex of degree $\gamma$ we have $\gamma\leq a-1$.
$(iii)$ According to the degree sum formula we have: $b=\sum_{i=1}^{a}(\gamma-d(v_i))=a\gamma-\sum_{i=1}^{a}d(v_i)=a\gamma-2|E|$.
$(iv)$ Since $a\gamma=2|E|+b$, if $a$ is an even number then the left side of the equality is even so $b$ is also an even number.
$(v)$ If $a$ is an odd number then the parameter $\gamma$ determines $b$ as an odd or even number. In this case if $\gamma$ is odd then the left side of the equality, $a\gamma=2|E|+b$, is also an odd number, as a result the right side must be an odd number which proves $b$ is odd. If $\gamma$ is even then the left side of the equality is also an even number, as a result the right side must be an even number which proves $b$ is even.
\end{proof}
An immediate consequence of the above Lemma is shown in Table I for $\gamma=3,4,5,6$ which demonstrates the non-existence of some of $(a,b)$ ETSs of a variable-regular LDPC code. The table indicates that in order to consider the existence of some $(a,b)$ ETSs there is no need to apply the proposed exhaustive search algorithms in the literature. Moreover, it expresses that the non-existence of some of $(a,b)$ ETSs is independent of the girth of the Tanner graph, while in \cite{2014} they are obtained by exhaustive search algorithms for Tanner graphs with girth 6. Additionally, the sign of "-" in the table illustrates the non-existence of corresponding $(a,b)$ ETS which is proved by Lemma 1 $(ii)$.
\begin{table}[h]
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
& $\gamma=3$ & $\gamma=4$ & $\gamma=5$ & $\gamma=6$\\
\hline
$a=4$ & $b=1,3$ & - & - & -\\
\hline
$a=5$ & $b=0,2,4$ & $b=1,3$ & - & -\\
\hline
$a=6$ & $b=1,3,5$ & $b=1,3,5$ & $b=1,3,5$ & -\\
\hline
$a=7$ & $b=0,2,4,6$ & $b=1,3,5$ & $b=0,2,4,6$ & $b=1,3,5$\\
\hline
$a=8$ & $b=1,3,5,7$ & $b=1,3,5,7$ & $b=1,3,5,7$ & $b=1,3,5,7$\\
\hline
$a=9$ & $b=0,2,4,6,8$ & $b=1,3,5,7$ & $b=0,2,4,6,8$ & $b=1,3,5,7$ \\
\hline
\end{tabular}
\caption{Non-existence of $(a,b)$ ETSs of variable-regular LDPC codes}
\end{center}
\end{table}
\section{Lower bounds on the size of ETSs for both variable-regular and irregular LDPC codes with girth 8}\label{}
In this section and the following ones we provide lower bounds on the size of elementary trapping sets according to the girth of the Tanner graph. Although in the section VI we obtain a lower bound for the size of ETSs belonging to Tanner graphs with any girth $g\geq8$, the lower bounds for the size of ETSs belonging to Tanner graphs with girths 8 and 10 are investigated separately to make the lower bounds tighter.
This section contains two parts. In the first part, we consider the size and the number of degree-one check nodes of ETSs belonging to variable-regular LDPC codes whose Tanner graphs have girth 8. In the second part, we take benefit from the results in the first part and present a method to determine a lower bound for the size of ETSs belonging to irregular LDPC codes whose Tanner graphs have girth 8. We provide numerical results for irregular LDPC codes whose variable nodes are a subset of $\{2,3,4,5,6\}$.
\subsection{ Variable-regular LDPC codes with girth 8}
In \cite{2014} there are some numerical results, which are search-based, about ETSs belonging to Tanner graphs with girth 8 and $\gamma=3,4,5$. In order to consider the lower bound for the size of ETSs belonging to LDPC codes with girth 8 and any value of $\gamma$ we provide the well-known Turan's Theorem about all $K_{r+1}$-free graphs, as follows.
\begin{Theorem}~\label{lemOrder}
$\cite{Turan}$ Let $G$ be any graph with $n$ vertices, such that $G$ is $K_{r+1}$-free. Then the number of edges in $G$ is at most $\frac{r-1}{r}\times\frac{n^2}{2}=(1-\frac{1}{r})\times\frac{n^2}{2}$.
\end{Theorem}
As mentioned in Section II, the normal graph corresponding to an ETS belonging to LDPC codes with girth 8 is a $K_3$-free graph. The following proposition for triangle-free graphs, which is a consequence of the above theorem, is our main tool to obtain the lower bounds for $a$ and $b$.
\begin{Proposition}
Let $G$ be a triangle-free graph with $n$ vertices, then the number of edges in $G$ is at most $\frac{n^2}{4}$.
\end{Proposition}
\begin{Theorem}~\label{lemOrder}
In a variable-regular LDPC code, whose Tanner graph has girth at least 8, there is no $(a,b)$ ETS of size less than $2\gamma-1$, where $a,b$ satisfy the inequality $\frac{b}{a}<1$.
\end{Theorem}
\begin{proof}
According to Lemma 1 $(iii)$ we have $b=a\gamma-2|E|$, where $|E|$ is the number of edges in the normal graph corresponding to an $(a,b)$ ETS. Since the Tanner graph has girth at least 8, it is 6-cycle free. Therefore as mentioned in the previous section, the normal graph is triangle-free and so according to proposition 1 the maximum number of edges is $\frac{a^2}{4}$. Assume that the normal graph has the maximum number of edges. In this case $b=a\gamma-2|E|=a\gamma-2(\frac{a^2}{4})$. So the number of unsatisfied check nodes is $a\gamma-\frac{a^2}{2}$. In order to consider dominant $(a,b)$ ETSs we focus on those with the property of $\frac{b}{a}<1$. So we have $\frac{b}{a}=\frac{a\gamma-\frac{a^2}{2}}{a}=\gamma-\frac{a}{2}<1$, which results in the following inequality $2\gamma-2<a$. As a consequence, there is no $(a,b)$ ETS of size less than or equal to $2\gamma-2$ with the property of $\frac{b}{a}<1$.
\end{proof}
\begin{Theorem}
For each $(a,b)$ ETS of a variable-regular LDPC code, whose Tanner graph has girth at least 8, the number of odd degree check nodes is at least $a\gamma-\frac{a^2}{2}$.
\end{Theorem}
\begin{proof}
As considered in Lemma 1 $(iii)$, if the number of edges in a normal graph is $|E|$ then $a,b,\gamma$ and $|E|$ hold the equality $b=a\gamma-2|E|$. If the Tanner graph has girth at least 8 then $2|E|\leq \frac{a^2}{2}$. Therefore $b=a\gamma-2|E|\geq a\gamma-\frac{a^2}{2}$.
\end{proof}
For example, if an ETS contains the minimum size, $a=2\gamma-1$, then $b=\gamma$. In the following we explain how a $(2\gamma-1,\gamma)$ ETS belonging to a variable-regular LDPC code is constructed. This structure proves that the obtained lower bounds for $a$ and $b$ are tight. In this case the corresponding normal graph has $a=2\gamma-1$ vertices and so has the maximum number of edges, which is $|E|=[\frac{(2\gamma-1)^2}{4}]=\gamma^2-\gamma$. Such a normal graph can be a complete bipartite graph $K_{\gamma-1,\gamma}$. Therefore, normal graphs corresponding to ETSs where $\gamma=3,\gamma=4,\gamma=5$ and $\gamma=6$ are $K_{2,3},K_{3,4},K_{4,5}$ and $K_{5,6}$, respectively. The corresponding ETSs are shown in Fig. 2.
\begin{center}
\begin{figure}[h!]
\centering
\includegraphics[scale=.3]{figure111.pdf}\\
\caption{ETSs for $\gamma=3,\gamma=4,\gamma=5$ and $\gamma=6$}
\end{figure}
\end{center}
The lower bounds obtained for $a$ and $b$ in Theorem 2 and Theorem 3 as well as Lemma 1 provide us with useful information about the existence of ETSs without using any search-based method. As an example, for variable-regular LDPC codes whose Tanner graphs have $\gamma=6$ and $g=8$ we have $a\geq11$ and $b\geq 6a-\frac{a^2}{2}$. So for $a=11$ the minimum number of unsatisfied check nodes is 6. And finally by applying Lemma 1 we conclude that there are three ETSs to investigate, which are (11,6) ETS, (11,8) ETS and (11,10) ETS.
For $\gamma=3,4,5$ we provide Table II to demonstrate the existence of some $(a,b)$ ETSs with the property of $\frac{b}{a}<1$ belonging to variable-regular LDPC codes whose Tanner graph have $g=8$. The table also expresses that the non-existence of some of $(a,b)$ ETSs is independent of the girth of the Tanner graph and relies on $a,b$ and $\gamma$. Note that the lower bound we provided analytically is used for any given value of $\gamma$.
\begin{table}[h]
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
& $\gamma=3$ & $\gamma=4$ & $\gamma=5$\\
\hline
$a=4$ & & & \\
\hline
$a=5$ & $b=3$ & & \\
\hline
$a=6$ & $b=0,2,4$ & & \\
\hline
$a=7$ & $b=1,3,5$ & $b=4,6$ & \\
\hline
$a=8$ & $b=0,2,4,6$ & $b=0,2,4,6$ & \\
\hline
$a=9$ & $b=1,3,5,7$ & $b=0,2,4,6,8$ & $b=5,7$\\
\hline
\end{tabular}
\caption{Existence of $(a,b)$ ETSs of variable-regular LDPC codes whose Tanner graph have $g=8$}
\end{center}
\end{table}
\subsection{Irregular LDPC codes with girth 8}
There are a number of irregular LDPC codes with different variable node degrees. Hence, considering all types of ETSs belonging to irregular LDPC codes seems difficult and rather impossible. Although there is a search-based algorithm in \cite{2012} to find ETSs belonging to a given irregular LDPC code, it is not comprehensive. And, as a whole, there are not much works done to determinate all types of ETSs in this catagory. However, the results proposed in the part A provide us with a chance to find out a method to obtain lower bounds for the size of ETSs belonging to irregular LDPC codes whose Tanner graphs have girth 8. We apply the method on irregular LDPC codes whose variable node degrees belong to the set $\{2,3,4,5,6\}$.
In this case our desire $(a,b)$ ETSs are also those satisfying in the inequality $\frac{b}{a}<1$. From Theorem 2 we conclude that if the minimum degree of variable nodes is $\delta$ then we have $a\geq2\delta-1$. In order to consider the lower bound for the size of ETSs belonging to an irregular LDPC code we first take into account an ETS belonging to a variable-regular LDPC code with $\gamma=\delta$, $a=2\delta-1$ and $b=\delta$ like those shown in Fig. 2. Depending on the difference between two parameters $a$ and $b$ there are two cases to consider.
\begin{itemize}
\item If $a-b=1$ then we have to increase the number of variable nodes in the ETSs belonging to a variable-regular LDPC code with $\gamma=\delta$ at least by one. Because, adding a check node of degree 1 to an ETS belonging to a variable-regular LDPC code with $\gamma=\delta$ results in an $(a,a)$ ETS belonging to an irregular LDPC code whose column weight values contain $\delta$ and $\delta+1$. But for this case we have $\frac{b}{a}=1$ which contradicts our desire.
For example, suppose the lower bound for the size of ETSs belonging to irregular LDPC codes whose column weights are in a set $\{2,3\}$ is under consideration. For this case we have $\delta=2$ and according to Theorem 2 we have $a\geq3$. We first take a $(3,2)$ ETS belonging to a variable-regular LDPC code with $\gamma=2$. Since $a-b=1$ inorder to obtain an ETS belonging to irregular LDPC codes whose column weights are in a set $\{2,3\}$ we have to increase the number of variable nodes of the mentioned $(3,2)$ ETS at least by one. Because by adding a check node of degree 1 to the mentioned $(3,2)$ ETS we obtain a $(3,3)$ ETS for which we have $\frac{b}{a}=1$. In this case $a=4$ is considered as the lower bound for the size of ETSs belonging to an irregular LDPC code with $d(v)\in\{2,3\}$. In Fig. 3 we present all types of ETSs with the minimum size 4 belonging to four types of irregular LDPC codes. They are a (4,1) ETS for $d(v)\in\{2,3\}$, a (4,2) ETS for $d(v)\in\{2,4\}$, two (4,3) ETSs for $d(v)\in\{2,5\}$ and $d(v)\in\{2,3,4\}$.
\begin{center}
\begin{figure}[h!]
\centering
\includegraphics[scale=.3]{figure333.pdf}\\
\caption{$(g)$ is a (4,1) ETS with $d(v)\in\{2,3\}$, $(h)$ is a (4,2) ETS with $d(v)\in\{2,4\}$, $(i)$ is a (4,3) ETS with $d(v)\in\{2,5\}$ and $(j)$ is a (4,3) ETS with $d(v)\in\{2,3,4\}$}
\end{figure}
\end{center}
\item If $a-b=i\geq2$ then the lower bound for the size of the ETS obtained for variable-regular LDPC codes with the column weight $\delta$ can be accounted for irregular LDPC codes with the minimum degree $\delta$, as well. On the condition that the number of degree-one check nodes which have to be added to a $(2\delta-1,\delta)$ ETS to achieve an ETS belonging to irregular LDPC codes with minimum degree $\delta$ is less than $i$, otherwise in order to obtain an ETS belonging to an irregular LDPC code from an ETS belonging to a variable-regular LDPC code with $\gamma=\delta$, the number of variable nodes has to be raised at least by one.
For example, suppose the lower bounds for the size of ETSs belonging to irregular LDPC codes whose column weights are in a set $\{4,5\}$, $\{4,6\}$ or $\{4,7\}$ are under consideration. For all three cases we have $\delta=4$. According to Theorem 2, for a variable-regular LDPC code whose column weight is 4 we have $a\geq7$. We first take a (7,4) ETS belonging to a variable-regular LDPC code with $\gamma=4$. Since $a-b=3$, the lower bound for the size of ETSs belonging to irregular LDPC codes whose column weights are in a set $\{4,5\}$ or $\{4,6\}$ is also 7, because in these cases the number of degree-one check nodes added to the (7,4) ETS is at most 2. But if column weights are in the set $\{4,7\}$ then the size of ETSs is at least 8. To clarify this construction we present Fig. 4.
\begin{center}
\begin{figure}[h!]
\centering
\includegraphics[scale=.3]{Untitled.pdf}\\
\caption{$(e)$ and $(f)$ are a (7,5) ETS and a (7,6) ETS obtained from (7,4) ETS shown in Fig. 2 $(c)$}
\end{figure}
\end{center}
\end{itemize}
Generally, we obtain the exact lower bound for the desire irregular LDPC codes by the use of the difference between two parameters $a$ and $b$. In the following table we provide the lower bounds for ETSs belonging to irregular LDPC codes whose column weights are a subset of $\{2,3,4,5,6\}$ and their Tanner graphs have girth 8.
\begin{table}[h]
\begin{center}
\begin{tabular}{|c|c|}
\hline
$a=4$ & (4,1) ETS and $d(v)\in\{2,3\}$, (4,2) ETS and $d(v)\in\{2,4\}$\\
& (4,3) ETS and $d(v)\in\{2,5\}$, (4,3) ETS and $d(v)\in\{2,3,4\}$\\
\hline
$a=5$ & (5,4) ETS and $d(v)\in\{2,6\}$, (5,4) ETS and $d(v)\in\{3,4\}$\\
& (5,2) ETS and $d(v)\in\{2,3,5\}$, (5,3) ETS and $d(v)\in\{2,3,6\}$\\
& (5,3) ETS and $d(v)\in\{2,4,5\}$, (5,4) ETS and $d(v)\in\{2,4,6\}$\\
& (5,4) ETS and $d(v)\in\{2,3,4,5\}$\\
\hline
$a=6$ & (6,2) ETS and $d(v)\in\{3,5\}$, (6,3) ETS and $d(v)\in\{3,6\}$\\
& (6,3) ETS and $d(v)\in\{2,5,6\}$, (6,3) ETS and $d(v)\in\{3,4,5\}$\\
& (6,4) ETS and $d(v)\in\{3,4,6\}$, (6,5) ETS and $d(v)\in\{3,5,6\}$\\
& (6,5) ETS and $d(v)\in\{2,4,5,6\}$, (6,4) ETS and $d(v)\in\{2,3,5,6\}$\\
\hline
$a=7$ & (7,5) ETS and $d(v)\in\{4,5\}$, (7,6) ETS and $d(v)\in\{4,6\}$\\
& (7,3) ETS and $d(v)\in\{3,4,5,6\}$, (7,4) ETS and $d(v)\in\{2,3,4,5,6\}$ \\
\hline
$a=8$ & $d(v)\in\{4,6\}$, $d(v)\in\{4,5,6\}$\\
\hline
$a=9$ & $d(v)\in\{5,6\}$\\
\hline
\end{tabular}
\caption{Lower bounds for the size of ETSs belonging to irregular LDPC codes whose column weights are a subset of $\{2,3,4,5,6\}$ and Tanner graphs have girth 8}
\end{center}
\end{table}
\section {Lower bounds for the size of ETSs for variable-regular LDPC codes with girth 10}
The normal graph corresponding to an elementary trapping set belonging to LDPC codes with girth 10 is triangle-free and has no 4-cycles. The following definition and theorem contribute to present lower bounds of the size of ETSs.
\begin{Definition}
Suppose a cycle of length $i$ is denoted by $C_i$. If a simple graph has girth $g$ then it is $i$-cycle free for each $3\leq i\leq g-1$. The maximum number of edges of a graph with $n$ vertices and girth $g$ is denoted by $ex(n,{C_3,C_4,\dots,C_{g-1}})$.
\end{Definition}
For example, in a triangle-free graph we have: $ex(n,C_3)\leq\frac{n^2}{4}$. To consider the maximum number of edges of a graph with girth 5 we utilize the following Theorem.
\begin{Theorem}~\label{lemOrder}
$\cite{Garnick}$ For a graph with $n$ vertices and girth $g=5$, the maximum number of edges is as follows:
\begin{center}
$ex(n,{C_3,C_4})\leq\frac{1}{2}n^\frac{3}{2}$.
\end{center}
\end{Theorem}
Now, by assuming the maximum number of edges in a normal graph with girth 5 we propose the following theorem related to the Tanner graph with girth 10.
\begin{Theorem}~\label{lemOrder}
In a variable-regular LDPC code, whose Tanner graph has girth at least 10, there is no $(a,b)$ ETS of size less than $(\gamma-1)^2+1$, that is $a\geq (\gamma-1)^2+1$, where $a,b$ satisfy the inequality $\frac{b}{a}<1$.
\end{Theorem}
\begin{proof}
Take an $(a,b)$ ETS whose normal graph has the maximum number of edges. In this case $b=a\gamma-2|E|=a\gamma-2(\frac{a^\frac{3}{2}}{2})$. So the number of unsatisfied check nodes is $a\gamma-a^\frac{3}{2}$. In order to consider dominant $(a,b)$ ETSs we focus on those ETSs with the property of $\frac{b}{a}<1$. So we have $\frac{b}{a}=\frac{a\gamma-a^\frac{3}{2}}{a}=\gamma-a^\frac{1}{2}<1$. As a consequence, there is no $(a,b)$ ETS of size less than or equal to $(\gamma-1)^2$ with the property of $\frac{b}{a}<1$.
\end{proof}
In the following we provide some properties related to a normal graph corresponding to an ETS belonging to a Tanner graph with girth at least 10. By this consideration we conclude that the proposed lower bound above can be also improved by more investigations.
\begin{itemize}
\item As mentioned in Lemma 1 $(i)$, the normal graph has at least a vertex of degree $\gamma$. Suppose $d(v)=\gamma$. If there is an edge between two vertices of neighbours of $v$ then the normal graph has a triangle. So there are no edges between neighbours of $v$.
\item Suppose $z,z'\in N(v)$, in other words $z$ and $z'$ are connected to $v$. If $w$ is a neighbour of $z$ then it does not connect $z'$. Otherwise, $z,z'\in N(w)$ and if $|N(v)\cap N(w)|\geq2$ then the normal graph has 4-cycles. As a result each vertex other than $v\cup N(v)$ has only one connection with $v\cup N(v)$.
\end{itemize}
In the following we apply Theorem 5 as well as the two items above to provide the exact lower bound for the size of an ETS where $\gamma=3$ and $\gamma=4$.
\begin{itemize}
\item ETSs belonging to a Tanner graph with girth 10 and $\gamma=3$ have no triangles and is 4-cycle free so according to Theorem 5 it has the size of at least 5. By making use of the mentioned properties we conclude that $a\geq7$. A normal graph with 7 vertices and girth 5 is illustrated in Fig. 5 $(a)$.
\item We prove for $\gamma=4$ and $g=10$ the lower bound of the size of ETSs is 12. Theorem 5 gives $a\geq10$. According to Lemma 1 $(iv)$, if we take $a=10$ then we have $b\leq8$. Suppose that there is a $(10,8)$ ETS. Lemma 1 $(iii)$ proves that the number of edges in the normal graph is 16. According to Theorem 4 the maximum number of edges of the graph with girth 5 and 10 vertices is 15. So the normal graph with 16 edges has a triangle or a 4-cycle. Now by similar proof we illustrate that for $\gamma=4$ and $g=10$ there is no $(11,b)$ ETS for which $\frac{b}{a}<1$. The maximum number of edges of a graph with 11 vertices and girth 5 ,which is obtained in $\cite{Garnick}$, is 16. Therefore, if we take $b=10$ then the maximum number of edges in the normal graph is 17 and so it has a triangle or a 4-cycle. An example of such a normal graph is shown in Fig. 5 $(b)$ which has a 4-cycle. Finally, Fig. 5 $(c)$ demonstrates a $(12,10)$ ETS with $\frac{b}{a}<1$.
\begin{figure}[h!]
\centering
\includegraphics[scale=.3]{girth1011.pdf}\\
\caption{$(a)$ is a normal graph corresponding to a (7,5) ETS with $\gamma=3$, $(b)$ is a normal graph corresponding to a (11,10) ETS with $\gamma=4$ which has a 4-cycle and $(c)$ is a normal graph corresponding to a (12,10) ETS with $\gamma=4$ which is free of triangles and 4-cycles}
\end{figure}
\end{itemize}
\section{Lower bounds for the size of ETSs for variable-regular LDPC codes with $g\geq12$}
Now we generalize our results for all values of the girth in two steps. In the first step we investigate the lower bound for the size of ETSs belonging to variable-regular LDPC codes whose Tanner graph have girth $g=2(2k+1)$. In this case the normal graph has girth $g=2k+1$ and according to Difinition 5 it is $i$-cycle free for each $3\leq i\leq 2k$ for which we have the following theorem as our main tool to obtain our result.
\begin{Theorem}~\label{lemOrder}
$\cite{Furedi}$ For a graph with $n$ vertices and girth $g=2k+1$, the maximum number of edges is as follows:
\begin{center}
$ex(n,{C_3,C_4,\dots,C_{2k}})<\frac{1}{2}n^{1+\frac{1}{k}}+\frac{1}{2}n$.
\end{center}
\end{Theorem}
\begin{Theorem}~\label{lemOrder}
In a variable-regular LDPC code, whose Tanner graph has girth $g=2(2k+1)$, there is no $(a,b)$ ETS of size less than or equal to $(\gamma-2)^k$, where $a,b$ satisfy the inequality $\frac{b}{a}<1$.
\end{Theorem}
\begin{proof}
The normal graph has $a$ vertices and $|E|$ edges. Since the Tanner graph has girth $g$, it is $2i$-cycle free for all $3\leq i\leq \frac{g}{2}-1$. Therefore, according to Definition 5, the normal graph is $i$-cycle free and so according to Theorem 6 the maximum number of edges is less than $\frac{1}{2}a^{1+\frac{1}{k}}+\frac{a}{2}$. Without loss of generality, assume that the number of edges in the normal graph is $\frac{1}{2}a^{1+\frac{1}{k}}+\frac{a}{2}-1$. In this case $b=a\gamma-2|E|=a\gamma-2(\frac{1}{2}a^{1+\frac{1}{k}}+\frac{a}{2}-1)$. So we have $\frac{b}{a}=\frac{a\gamma-a^{1+\frac{1}{k}}-a+2}{a}=\gamma-a^{\frac{1}{k}}-1+\frac{2}{a}<1$. Therefore, the inequality $\gamma-a^{\frac{1}{k}}-1<\gamma-a^{\frac{1}{k}}-1+\frac{2}{a}<1$ results in the inequality $\gamma-2<a^{\frac{1}{k}}$. As a consequence, there is no $(a,b)$ ETS of size less than or equal to $(\gamma-2)^k$ with the property of $\frac{b}{a}<1$.
\end{proof}
In the second step we investigate the lower bound for the size of ETSs belonging to variable-regular LDPC codes whose Tanner graphs have girth $g=2(2k+2)$. In this case the normal graph has girth $g=2(k+1)$ and according to Difinition 5 it is $i$-cycle free for each $3\leq i\leq 2k+1$ for which we have the following theorem which contributes to achieve our result.
\begin{Theorem}~\label{lemOrder}
$\cite{Furedi}$ For a graph with $n$ vertices and girth $g=2k+2$, the maximum number of edges is as follows:
\begin{center}
$ex(n,{C_3,C_4,\dots,C_{2k+1}})<\frac{1}{2^{1+\frac{1}{k}}}n^{1+\frac{1}{k}}+\frac{1}{2}n$.
\end{center}
\end{Theorem}
\begin{Theorem}~\label{lemOrder}
In a variable-regular LDPC code, whose Tanner graph has girth $g=2(2k+2)$, there is no $(a,b)$ ETS of size less than or equal to $2(\gamma-2)^k$, where $a,b$ satisfy the inequality $\frac{b}{a}<1$.
\end{Theorem}
\begin{proof}
The Tanner graph has girth $g$, it is $2i$-cycle free for all $3\leq i\leq\frac{g}{2}-1$. Therefore, the normal graph is $i$-cycle free and according to Theorem 8 the maximum number of edges is less than $\frac{1}{2^{1+\frac{1}{k}}}a^{1+\frac{1}{k}}+\frac{a}{2}$. Assume that the normal graph has $\frac{1}{2^{1+\frac{1}{k}}}a^{1+\frac{1}{k}}+\frac{a}{2}-1$ edges. In this case $\frac{b}{a}=\frac{a\gamma-2(\frac{1}{1+2^{\frac{1}{k}}}a^{1+\frac{1}{k}}+\frac{a}{2}-1)}{a}$. By considering the inequality $\frac{b}{a}<1$ and similar to the proof of Theorem 7 we obtain $\gamma-\frac{a}{2}^\frac{1}{k}<2$. Consequently, there is no $(a,b)$ ETS of size less than or equal to $2(\gamma-2)^k$ with the property of $\frac{b}{a}<1$.
\end{proof}
\section{Conclusion}\label{}
In this paper, we provide lower bounds for the size of $(a,b)$ elementary trapping sets for variable-regular LDPC codes with any girth and irregular LDPC codes with girth 8, where $a$ is the number of variable nodes and $b$ is the number of check nodes of odd degrees which satisfy the inequality $\frac{b}{a}<1$. We analytically demonstrate that depending on the number of variable nodes, the number of degree-one check nodes and the column weight, some of ETSs do not exist. It indicates that the non-existence of some of $(a,b)$ ETSs not only is independent of the girth of the Tanner graph but also in order to consider them we do not need to conduct exhaustive search algorithms. Also, making use of some results on the maximum number of edges of a graph based on its girth, we provide the lower bounds for the size of ETSs for Tanner graphs with girths 8, 10 and larger. In fact, we prove that the Tanner graph of a variable-regular LDPC code, with the column weight $\gamma$ and girth 8 contains no $(a,b)$ ETS of size $a<2\gamma-1$. We also demonstrate that the lower bound of degree-one check nodes is $\gamma$. We show that these lower bound are tight. Along with making use of them we present a method to obtain the lower bounds of ETSs belonging to irregular LDPC codes. We apply our proposed method on irregular LDPC codes whose column weight values are a subset of $\{2,3,4,5,6\}$. In addition, we prove that variable-regular LDPC codes with girth 10 contain no ETS of size $a\leq(\gamma-1)^2$. Moreover, for this case the lower bounds for $a$, assuming $\gamma=3$ and 4, are also improved which are 7 and 12, respectively. Finally, we generalize our results for all values of the girth, as follows. Variable-regular LDPC codes with girths $g=2(2k+1)$ and $g=2(2k+2)$ contain no $(a,b)$ ETSs of sizes $a\leq(\gamma-2)^k$ and $a\leq2(\gamma-2)^k$, respectively.
| {'timestamp': '2017-06-07T02:05:26', 'yymm': '1706', 'arxiv_id': '1706.01703', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01703'} | arxiv |
\subsection{Lane Modeling on Simulated Data \label{simulation-eval}}
\begin{figure}[t]
\centering
\setlength\figureheight{5cm}
\setlength\figurewidth{7cm}
\input{carmaker_eval.tikz}
\caption{Double bend of the simulated scenario. The double bend consists of four connected $50~m$ long clothoid segments. Along each segment the radius of curvature changes from $1000~m$ to $100~m$ or vice versa.}
\label{fig:simulated-scenario}
\end{figure}
To demonstrate the functioning and the flexibility of the presented method, a spline and a clothoid \footnote{Here, clothoids are approximated by a third order polynomial~\cite{Dickmanns1992}.} model are compared using a simulated scenario.
Due to the generic description of the lane model, clothoids can be modeled with the proposed method by simply using a third order polynomial as line function with one segment.
The CarMaker simulation software~\footnote{http://ipg.de/de/simulation-software/carmaker/} is used to generate odometry and lane features of the simulated scenario. It consists of a $200~m$ long straight road section followed by a double bend, which is composed of four connected clothoid segments. The s-shape curve of the simulated scenario is shown in fig. \ref{fig:simulated-scenario}. At each time step, lane features up to a longitudinal distance of $100~m$ in front of the vehicle serve, together with the current odometry, as input for the lane modeling. As a measure of performance, the Root Mean Square Error (RMSE) of the lateral distance between the estimated lane model and simulated lane features is computed. Fig. \ref{fig:rmse-sim} shows the measured RMSE for the resulting lanes when using clothoids and cubic splines in the modeling method. As expected, there is no difference between the two models for the straight road section. However, one can clearly see the benefit of the spline model once the curve comes into range. The maximum error for the clothoid model is approximately four times as high as the one for the spline model. Note that the cubic spline model is not able to perfectly describe the simulated scenario, as its control points are not positioned at the connection points of the simulated clothoids. Nevertheless, using the spline model the lanes are modeled at any point of the simulated scenario with an RMSE below $0.1~m$.
\begin{figure}[t]
\centering
\setlength\figureheight{5cm}
\setlength\figurewidth{7cm}
\input{carmaker_scenario4_comparison.tikz}
\caption{RMSE of the difference between modeled and simulated lanes. The result is shown for clothoids (red) and cubic splines (blue) in a simulated scenario containing a double bend.}
\label{fig:rmse-sim}
\end{figure}
\subsection{Lane Estimation Evaluation on Sensor Data \label{real-data-eval}}
In the analysis described in the following, the performance of lane feature fusion \cite{TeamMuc2016} and subsequent lane modeling using the proposed modeling method with cubic splines is evaluated on real data measurements. The modeled lanes are compared to a ground truth map that contains global positions of lane markings as a point vector. The analyzed route is a highway in Germany with three lanes and left and right curves~\footnote{The analysis presented in \cite{TeamMuc2016} is based on the same data and ground truth map.}. The map is generated using a high precision GPS system, which is also used for localization in the map. The input data has been collected during several drives on the highway with a development vehicle corresponding to a total driving distance of $24~km$. The development vehicle is equipped with camera and radar systems to detect lane markings and other traffic participants. The sensor information is fused in a GraphSLAM based process that yields the lane features which serve as input for the modeling. In the analysis, the lateral deviation of the modeled lanes to the relevant map points is computed at each time step. The result is accumulated in dependence of the longitudinal distance for all of the recorded data. As a measure of performance the RMSE is determined within distance intervals of $10~m$. Fig. \ref{fig:rmse-real} shows the result for ego and adjacent lanes up to a longitudinal distance of $120~m$. Due to higher precision of the input data, the result for the ego lane is better in comparison to the one for adjacent lanes. At a distance of $120~m$ lanes are modeled with an RMSE of less than $0.75~m$. Compared to the result presented in \cite{TeamMuc2016}, the application of the proposed modeling approach using cubic splines provides a similar performance but offers a higher degree of flexibility as shown in section \ref{simulation-eval} and in the following.
\begin{figure}[t]
\centering
\setlength\figureheight{5cm}
\setlength\figurewidth{7cm}
\input{rmse_laatzen.tikz}
\caption{RMSE of the difference between estimated lanes and ground truth for ego (red) and neighbor lane (blue).}
\label{fig:rmse-real}
\end{figure}
In fig. \ref{fig:construction_site} an example of feature extraction and lane model estimation result inside a construction zone is shown. In this setting the lane markings inside the construction zone are yellow and have a double bend shape. Features are extracted along the lane markings in the camera image (fig.~\ref{fig:features_from_longrange}). After accumulation and fusion of the features, the lanes are modeled using the presented method with cubic splines and three segments (fig.~\ref{fig:modeling_construction_site}). As one can see, the resulting lane model is properly describing the shape of the lane within the construction zone. Despite outliers in the input data, a robust estimation of the lane is obtained.
\begin{figure}[t]
\centering
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=8.5cm]{meas_points_final_13-0_red_small.png}
\centering
\caption{Snapshot of lane features (red) detected in a camera image.}
\label{fig:features_from_longrange}
\vspace{0.2cm}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\setlength\figureheight{3cm}
\setlength\figurewidth{7cm}
\input{lane_model_baustelle.tikz}
\caption{Modeling of camera features accumulated over time (red).}
\label{fig:modeling_construction_site}
\end{subfigure}
\caption{Example of lane modeling based on cubic splines inside a construction zone.}
\label{fig:construction_site}
\end{figure}
\subsubsection{Measurement optimization}
To find the lane model which represents the current lane features in the best way, eq. \ref{eq:maximization} is formulated as a quadratic minimization problem
\begin{equation}
\hat{\mathbf{L}}_{t} = \underset{\mathbf{L}_{t}}{\arg \min}
\sum_{\left\langle \mathbf{f}_i, \mathbf{l}_n^m \right\rangle \in \mathbf{c}_t} \mathbf{e}(\mathbf{f}_i,\mathbf{l}_n^m)^T \mathbf{\Omega}_{i} \mathbf{e}(\mathbf{f}_i,\mathbf{l}_n^m),
\label{eq:minimization}
\end{equation}
where $\mathbf{c}_t$ is the correspondence vector determined in the expectation step (see section \ref{model-feature-association}).
The error function
\[
\mathbf{e}(\mathbf{f}_i,\mathbf{l}_n^m) =
\left[
\begin{array}{c}
f(x_i,\mathbf{l}_n^m) - y_i \\
f'(x_i,\mathbf{l}_n^m) - \theta_i
\end{array}
\right]
\]
is defined as the distance of position and heading between a lane feature ($x_i,y_i,\theta_i \in \mathbf{f}_i$) and the associated line segment.
It is multiplied from both sides to the information matrix $\mathbf{\Omega}_{i} = diag([\sigma_{y}^2, \sigma_{\theta}^2])^{-1}$ which corresponds to the variances of feature $\mathbf{f}_i$.
The sum over the non-linear quadratic equations in eq. \ref{eq:minimization} can be solved by the Gauss-Newton algorithm as shown for example for pose graph optimization \cite{Grisetti2010}. Given an initial guess $\breve{\mathbf{L}}_t$, the solution to the minimization problem can be found iteratively by solving
\begin{equation}
\mathbf{H}
\Delta \mathbf{L}^{\ast}_t = -\mathbf{b}
\label{eq:solve_system}
\end{equation}
with
\begin{equation}
\mathbf{H} = \sum_{\left\langle \mathbf{f}_i, \breve{\mathbf{l}}_n^m \right\rangle \in \mathbf{c}_t} \mathbf{J}(\mathbf{f}_i, \breve{\mathbf{l}}_n^m)^T \mathbf{\Omega}_{i} \mathbf{J}(\mathbf{f}_i,\breve{\mathbf{l}}_n^m)
\label{eq:H-matrix}
\end{equation}
and
\begin{equation}
\mathbf{b} = \sum_{\left\langle \mathbf{f}_i , \breve{\mathbf{l}}_n^m \right\rangle \in \mathbf{c}_t} \mathbf{e}(\mathbf{f}_i, \breve{\mathbf{l}}_n^m)^T \mathbf{\Omega}_{i} \mathbf{J}(\mathbf{f}_i, \breve{\mathbf{l}}_n^m).
\label{eq:b-vector}
\end{equation}
Here $\mathbf{J}(\mathbf{f}_i, \breve{\mathbf{l}}_n^m)$ is the Jacobian of the error function $\mathbf{e}(\mathbf{f}_i,\breve{\mathbf{l}}_n^m)$ evaluated at the current estimate $\breve{\mathbf{L}}_t$.
After solving eq.~\ref{eq:solve_system} for $\Delta \mathbf{L}^{\ast}_t$, the current estimate is updated
\[
\mathbf{L}^{\ast}_t = \breve{\mathbf{L}}_t + \Delta \mathbf{L}^{\ast}_t
\]
and used in the next iteration as initial guess.
After convergence (no change in the parameter update $\Delta \mathbf{L}^{\ast}_t$), the optimized solution $\hat{\mathbf{L}}_t = \mathbf{L}^{\ast}_t$ is found.
\subsubsection{Time filter optimization}
In addition, the previous state $\mathbf{L}_{t-1}$ is considered in the optimization to ensure continuity of the result over time.
As shown in section \ref{model-prediction} the control points of the previously derived lane model can be predicted to the current time step.
Therefore, an additional sum of error terms
\[
\sum_{n,m} \mathbf{e}(\check{\mathbf{s}}_n^m, \mathbf{l}_n^m)^T \mathbf{\Omega}_n^m \mathbf{e}(\check{\mathbf{s}}_n^m,\mathbf{l}_n^m)
\]
is added to the optimization (eq. \ref{eq:minimization}), where $\check{\mathbf{s}}_n^m$ corresponds to position and orientation of the predicted control point.
The information matrix $\mathbf{\Omega}_n^m$ regarding the lateral displacement and orientation of the control point is calculated by the inverse of the previous system matrix $\mathbf{H}_{t-1}$ (eq. \ref{eq:H-matrix}), the Jacobian of the line function and the Jacobian of the coordinate transformation.
Incorporation of these error terms into eq. \ref{eq:solve_system} prevents large jumps in position and heading of the lane model between two subsequent time steps.
\subsubsection{Continuity and Parallelism as equality constraints}
In addition to previously formulated optimization problem, equality constraints can be added to limit the state space of the lane model.
On the one hand the function defining the geometry of a line needs to be continuous in position, heading and curvature at the control points.
On the other hand lanes on highways are often parallel and therefore this parallelism needs to be taken into account while solving the optimization problem.
As described in section \ref{lane-model-describtion}, the lane model is composed of $N$ lines with $M$ segments each.
For each pair of successive line segments $\left\langle m,m+1 \right\rangle$ the continuity with respect to position, orientation and curvature is established by the equality constraints
\[
f(s^{m+1}_n,\mathbf{l}^m_n) - f(s^{m+1}_n,\mathbf{l}^{m+1}_n) \overset{!}{=} 0
\]
\[
f'(s^{m+1}_n,\mathbf{l}^m_n) - f'(s^{m+1}_n,\mathbf{l}^{m+1}_n) \overset{!}{=} 0
\]
\begin{equation}
f''(s^{m+1}_n,\mathbf{l}^m_n) - f''(s^{m+1}_n,\mathbf{l}^{m+1}_n) \overset{!}{=} 0,
\label{eq:continuity_constraint}
\end{equation}
where $s^{m+1}_n$ is the longitudinal position of the control point between the two segments.
\\
\\
For arbitrary line functions
the equality constraints can be incorporated by extending the system of eq.~\ref{eq:solve_system} using the method of Lagrange multipliers \cite{griva2009linear}.
In general, the quadratic function from eq. \ref{eq:minimization} subject to the constraints $\mathbf{g}(\mathbf{L}_t) = \mathbf{0}$
can be iteratively minimized by solving the linear equation system
\begin{equation}
\left[
\begin{array}{cc}
\mathbf{H} & -\mathbf{K}^T \\
-\mathbf{K} & \mathbf{0}
\end{array}
\right]
\left[
\begin{array}{c}
\Delta \mathbf{L}_t^\ast\\
\boldsymbol{\lambda}
\end{array}
\right]
=
\left[
\begin{array}{c}
-\mathbf{b} \\
\mathbf{g}(\breve{\mathbf{L}}_t)
\end{array}
\right],
\label{eq:constraint_GN}
\end{equation}
for the state space update $\Delta \mathbf{L}_t^\ast$ and $\boldsymbol{\lambda}$ as the Lagrange multiplier.
$\mathbf{K}$ is the Jacobian of $\mathbf{g}(\breve{\mathbf{L}}_t)$ evaluated at the current state estimate $\breve{\mathbf{L}}_t$. $\mathbf{H}$ and $\mathbf{b}$ are the matrices defined for the measurement optimization in eq.~\ref{eq:H-matrix} and eq.~\ref{eq:b-vector}. Using this method to integrate the equality constraints of eq.~\ref{eq:continuity_constraint} into the optimization problem, $\mathbf{g}(\mathbf{x})$ is a vector of $3N(M-1)$ equations.
For certain functions, the linear equation system resulting from eq.~\ref{eq:continuity_constraint} can be solved explicitly.
For a cubic polynomial the eight parameters
($[\mathbf{l}^{m}_n, \mathbf{l}^{m+1}_n]^T = [a_n^m, b_n^m, c_n^m, d_n^m,
a_n^{m+1}, b_n^{m+1}, c_n^{m+1}, d_n^{m+1}]^T$)
of two successive segments can be reduced to five applying the substitutions:
\[
c_n^{m+1} = c_n^m + 3 (d_n^m - d_n^{m+1}) s^{m+1}_n,
\]
\[
b_n^{m+1} = b_n^m + 2(c_n^m - c_n^{m+1}) s^{m+1}_n + 3(d_n^m - d_n^{m+1}) (s^{m+1}_n)^2,
\]
\[
a_n^{m+1} = a_n^m + (b_n^m - b_n^{m+1}) s^{m+1}_n + (c_n^m - c_n^{m+1})(s^{m+1}_n)^2
\]
\[
+ (d_n^m - d_n^{m+1}) (s^{m+1}_n)^3.
\]
This method has two advantages.
First, the state space of $\mathbf{L}_t$ in eq. \ref{eq:constraint_GN} is reduced from $4MN$ parameters to $4 M N - 3(M-1)N = (M+3)N$. Additionally in this case the $3(M-1)N$ equations for $\mathbf{g}(\mathbf{L}_t)$ are not needed, which makes the solving of the linear system computationally faster.
\\
To also incorporate parallelism constraints between neighboring lines, the vector of equality equations $\mathbf{g}(\mathbf{L}_t)$ can be extended.
For cubic splines the degree of freedom of the model can be considered to find the number of necessary constraints.
Two cubic spline lines have $8M$ individual parameters, respectively $2(M+3)$ parameters after including continuity constraints with the substitutions.
If these lines should be parallel, the degree of freedom needs to be reduced to two lateral offsets for left and right line, heading, curvature and curvature derivate for the first segment and one curvature change per following segment:
\[
\left| [d^1_n, d^1_{n+1}, c^1, d^1, a^1, a^2, ... , a^{m}]^T \right| = (M+4).
\]
Therefore, $2(M+3) - (M+4) = M+2$ constraints need to be added to the system of eq. \ref{eq:constraint_GN}, three for the first segment and one per additional segment, where a constraint is defined as the equality of the orientation:
\[
g(\mathbf{l}_i, \mathbf{l}_j) =
f'(x, \mathbf{l}_i) - f'(x, \mathbf{l}_j)
\overset{!}{=} 0.
\]
The evaluation point $x$ corresponds either to the control points or in the first segment also to the middle of the two limiting control points.
Note that the parallelism criteria is approximated by demanding equality of orientation.
\section{INTRODUCTION AND RELATED WORK \label{introduction}}
\input{Introduction.tex}
\section{LANE MODEL ESTIMATION\label{lane-model-estimation}}
\input{ArchitectureFig.tex}
\input{LaneModelEstimation.tex}
\subsection{Input Data \label{input-data}}
\input{LaneFeatureFusion.tex}
\subsection{Lane Model Description \label{lane-model-describtion}}
\input{LaneModelDescription.tex}
\subsection{Initial Lane Model \label{lane-model-init}}
\input{LaneModelInit.tex}
\subsection{Prediction \label{model-prediction}}
\input{ModelPrediction.tex}
\subsection{Association and Model Assumptions \label{model-feature-association}}
\input{Association.tex}
\subsection{Lane Model Fit Using Constrained Gauss Newton Method \label{gauss-newton-fit}}
\input{GaussNewtonFit.tex}
\section{EXPERIMENTAL EVALUATION \label{evaluation}}
\input{Evaluation.tex}
\section{CONCLUSION \label{conclusion}}
\input{Conclusion.tex}
{\small
\bibliographystyle{IEEEtran}
| {'timestamp': '2017-06-07T02:03:59', 'yymm': '1706', 'arxiv_id': '1706.01631', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01631'} | arxiv |
\section{Introduction}
This paper is about the use of transactions as a common means to
control concurrent access of programs to shared locations and to avoid
that values stored at these locations are changed almost randomly. A
{\em transaction controller} interacts with concurrently running
programs (read: sequential components of an asynchronous system) to
control whether access to a shared location can be granted or not,
thus ensuring a certain form of consistency for these locations. A
commonly accepted consistency criterion is that the joint behavior of
all transactions (read: programs running under transactional control)
with respect to the shared locations is equivalent to a serial
execution of those programs. Serialisability guarantees that each
transaction can be specified independently from the transaction
controller, as if it had exclusive access to the shared locations.
It is expensive and cumbersome to specify transactional behavior and
prove its correctness again and again for components of the great
number of concurrent systems. Our goal is to define once and for all
an abstract (i.e. programming language independent) transaction
controller $\ASM{TaCtl}$ which can simply be ``plugged in'' to turn
the behavior of concurrent programs (read: components~$M$ of any given
asynchronous system $\cal M$) into a transactional one. This involves
to also define an operator~$TA(M,\ASM{TaCtl})$ which forces the
programs~$M$ to listen to the controller $\ASM{TaCtl}$ when trying to
access shared locations.
For the sake of generality we define the operator and the controller
in terms of Abstract State Machines (ASMs) which can be read and
understood as pseudo-code so that $\ASM{TaCtl}$ and the operator $TA$
can be applied to code written in any programming language (to be
precise: whose programs come with a notion of single step, the level
where our controller imposes shared memory access constraints to
guarantee transactional code behavior). On the other side, the precise
semantics underlying ASMs (for which we refer the reader
to~\cite{BoeSta03}) allows us to mathematically prove the correctness
of our controller and operator.
We concentrate here on transaction controllers that employ locking
strategies such as the common two-phase locking protocol (2PL). That
is, each transaction first has to acquire a (read- or write-) lock for
a shared location, before the access is granted. Locks are released
after the transaction has successfully committed and no more access to
the shared locations is necessary. There are of course other
approaches to transaction handling, see
e.g. \cite{elmasri:2006,gray:1993,kirchberg:2009,schewe:actac2000} and
the extensive literature there covering classical transaction control
for flat transactions, timestamp-based, optimistic and hybrid
transaction control protocols, as well as non-flat transaction models
such as sagas and multi-level transactions.
We define $\ASM{TaCtl}$ and the operator $TA$ in
Sect.~\ref{sect:TAoperator} and the $\ASM{TaCtl}$ components in
Sect.~\ref{sect:TaCtl}. In Sect.~\ref{sect:Thm} we prove the
correctness of these definitions.
\section{The Transaction Operator $TA(M,\ASM{TaCtl}$)}
\label{sect:TAoperator}
As explained above, a transaction controller performs the lock
handling, the deadlock detection and handling, the recovery mechanism
(for partial recovery) and the commit of single machines. Thus we
define it as consisting of four components specified in
Sect.~\ref{sect:TaCtl}.
\begin{asm}
\ASM{TaCtl}=\+
\ASM{LockHandler} \\
\ASM{DeadlockHandler} \\
\ASM{Recovery} \\
\ASM{Commit}
\end{asm}
The operator~$TA(M,\ASM{TaCtl})$ transforms the components~$M$ of any
concurrent system (asynchronous ASM) ${\cal M} = (M_i)_{i \in
I}$ into components of a concurrent system $TA({\cal M},\ASM{TaCtl})$ where
each $TA(M_i,\ASM{TaCtl})$ runs as transaction under the control
of~$\ASM{TaCtl}$:
\begin{asm}
TA({\cal M},\ASM{TaCtl})= ((TA(M_i,\ASM{TaCtl}))_{i \in I},\ASM{TaCtl})
\end{asm}
$\ASM{TaCtl}$ keeps a dynamic set $TransAct$ of those machines~$M$
whose runs it currently has to supervise to perform in a transactional
manner until~$M$ has $Terminated$ its transactional behavior (so that
it can $\ASM{Commit}$ it).\footnote{In this paper we deliberately keep
the termination criterion abstract so that it can be refined in
different ways for different transaction instances.} To turn the
behavior of a machine~$M$ into a transactional one, first of all~$M$
has to register itself with the controller $\ASM{TaCtl}$, read: to be
inserted into the set of currently to be handled $TransAct$ions. To
$\ASM{Undo}$ as part of a recovery some steps~$M$ made already during
the given transactional run segment of~$M$, a last-in first-out queue
$history(M)$ is needed which keeps track of the states the
transactional run goes through; when~$M$ enters the set $TransAct$ the
$history(M)$ has to be initialized (to the empty queue).
The crucial transactional feature is that each non private
(i.e. shared or monitored or output) location~$l$ a machine~$M$ needs
to read or write for performing a step has to be $LockedBy(M)$ for
this purpose;~$M$ tries to obtain such locks by calling the
$\ASM{LockHandler}$. In case no $newLocks$ are needed by~$M$ in its
$currState$ or the needed $newLocks$ can be $Granted$ by the
$\ASM{LockHandler}$, $M$ performs its next step; in addition, for a
possible future recovery, the machine has to $\ASM{Record}$ in its
$history(M)$ the current values of those locations which are (possibly
over-) written by this~$M$-step together with the obtained
$newLocks$. Then~$M$ continues its transactional behavior until it is
$Terminated$. In case the needed $newLocks$ are $Refused$, namely
because another machine~$N$ in $TransAct$ for some needed~$l$ has
$W\mbox{-}Locked(l,N)$ or (in case~$M$ wants a W-(rite)Lock) has
$R\mbox{-}Locked(l,N)$, $M$ has to $Wait$ for~$N$; in fact it
continues its transactional behavior by calling again the
$\ASM{LockHandler}$ for the needed $newLocks$---until the needed
locked locations are unlocked when~$N$'s transactional behavior is
$\ASM{Commit}$ed, whereafter a new request for these locks this time
may be $Granted$ to~$M$.\footnote{As suggested by a reviewer, a
refinement (in fact a desirable optimization) consists in replacing
such a waiting cycle by suspending~$M$ until the needed locks are
released. Such a refinement can be obtained in various ways, a
simple one consisting in letting~$M$ simply stay in $waitForLocks$
until the $newLocks$ $CanBeGranted$ and refining $\ASM{LockHandler}$
to only choose pairs $(M,L)\in LockRequest$ where it can
$\ASM{GrantRequestedLocks}(M,L)$ and doing nothing otherwise
(i.e. defining $\ASM{RefuseRequestedLocks}(M,L)=~\mathrel{\mathbf{skip}}$). See
Sect.~\ref{sect:TaCtl}.}
As a consequence deadlocks may occur, namely when a cycle occurs in
the transitive closure $Wait^*$ of the $Wait$ relation. To resolve
such deadlocks the $\ASM{DeadlockHandler}$ component of $\ASM{TaCtl}$
chooses some machines as $Victim$s for a recovery.\footnote{To
simplify the serializability proof in Sect.\ref{sect:TaCtl} and
without loss of generality we define a reaction of machines~$M$ to
their victimization only when they are in $ctl\_state(M)=~$TA-$ctl$
(not in $ctl\_state(M)=waitForLocks$). This is to guarantee that no
locks are $Granted$ to a machine as long as it does
$waitForRecovery$.} After a victimized machine~$M$ is $Recovered$ by
the $\ASM {Recovery}$ component of $\ASM{TaCtl}$, so that~$M$ can exit
its $waitForRecovery$ state, it continues its transactional behavior.
This explains the following definition of $TA(M,\ASM{TaCtl})$ as a
control state ASM, i.e. an ASM with a top level Finite State Machine
control structure. We formulate it by the flowchart diagram of
Fig.~\ref{fig:TA(M,C)}, which has a precise control state ASM
semantics (see the definition in~\cite[Ch.2.2.6]{BoeSta03}). The
components for the recovery feature are highlighted in the flowchart
by a colouring that differs from that of the other components. The
macros which appear in Fig.~\ref{fig:TA(M,C)} and the components of
$\ASM{TaCtl}$ are defined below.
\begin{figure}[htb]
\begin{center}
\includegraphics[width=0.9\textwidth]{figure1.png}
\end{center}
\caption{TA(M,C)}
\label{fig:TA(M,C)}
\end{figure}
The predicate $NewLocksNeededBy(M)$ holds if in the current state
of~$M$ at least one of two cases
happens:\footnote{See~\cite[Ch.2.2.3]{BoeSta03} for the classification
of locations and functions.} either $M$ to perform its step in this
state reads some shared or monitored location which is not yet
$LockedBy(M)$ or~$M$ writes some shared or output location which is
not yet $LockedBy(M)$ for writing. A location can be $LockedBy(M)$ for
reading ($R\mbox{-}Locked(l,M)$) or for writing
($W\mbox{-}Locked(l,M)$). Formally:
\begin{asm}
NewLocksNeededBy(M)=\+
newLocks(M,currState(M))\footnote{
For layout reasons we omit in Fig.\ref{fig:TA(M,C)} the arguments of the
functions $newLocks$ and $overWrittenVal$.}\not = (\emptyset,\emptyset) \-
newLocks(M,currState(M))\footnote{By the second argument
$currState(M)$ of $newLocks$ (and below of $overWrittenVal$) we indicate that this
function of~$M$ is a dynamic function which is evaluated in each
state of~$M$, namely by computing in this state the sets $ReadLoc(M)$ and
$WriteLoc(M)$; see Sect.~\ref{sect:Thm} for the detailed definition.}
=(R\mbox{-}Loc,W\mbox{-}Loc)\+
\mathrel{\mathbf{where}} \\
R\mbox{-}Loc = ReadLoc(M,currState(M)) \cap (SharedLoc(M) \cup MonitoredLoc(M))\+
~~~~~~~~~~~~~~~~\cap \overline{LockedBy(M)}
\footnote{By $\overline{X}$ we denote the complement of~$X$.}\-
W\mbox{-}Loc = WriteLoc(M,currState(M)) \cap (SharedLoc(M) \cup OutputLoc(M))\+
~~~~~~~~~~~~~~~~\cap \overline{W\mbox{-}LockedBy(M)}\global\advance\asmi by-1\-
LockedBy(M)= \{l \mid R\mbox{-}Locked(l,M) \mathrel{\mathbf{or}} W\mbox{-}Locked(l,M)\}\\
W\mbox{-}LockedBy(M)= \{l \mid W\mbox{-}Locked(l,M)\}
\end{asm}
The $overWrittenVal$ues are the $currState(M)$-values (retrieved by
the $eval$-function) of those shared or output locations $(f,args)$
which are written by~$M$ in its $currState(M)$. To $\ASM{Record}$ the
set of these values together with the obtained $newLocks$ means to
append the pair of these two sets to the $history$ queue of~$M$ from
where upon recovery the values and the locks can be retrieved.
\begin{asm}
overWrittenVal(M,currState(M))= ~ \{((f,args),val) \mid \+
(f,args) \in WriteLoc(M,currState(M))\cap (SharedLoc(M) \cup OutputLoc(M))\\
\mathrel{\mathbf{and}} val = eval(f(args),currState(M))\} \-
\ASM{Record}(valSet,lockSet,M) = ~ \ASM{Append}((valSet,lockSet),history(M))
\end{asm}
To $\ASM{CallLockHandler}$ for the $newLocks$ requested by~$M$ in its
$currState(M)$ means to $\ASM{Insert}(M,newLocks)$ into the
$\ASM{LockHandler}$'s set of to be handled $LockRequest$s. Similarly
we let $\ASM{CallCommit(M)}$ stand for insertion of~$M$ into a set
$CommitRequest$ of the $\ASM{Commit}$ component.
\begin{asm}
\ASM{CallLockHandler}(M,L)=~\ASM{Insert}((M,L),LockRequest)\\
\ASM{CallCommit}(M)=~\ASM{Insert}(M,CommitRequest)
\end{asm}
\section{The Transaction Controller Components}
\label{sect:TaCtl}
A $\ASM{CallCommit(M)}$ by machine~$M$ enables the $\ASM{Commit}$
component. Using the $\mathrel{\mathbf{choose}}$ operator we leave the order in which
the $CommitRequest$s are handled refinable by different instantiations
of $\ASM{TaCtl}$.
$\ASM{Commit}$ing~$M$ means to $\ASM{Unlock}$ all locations~$l$ that
are $LockedBy(M)$. Note that each lock obtained by~$M$ remains
with~$M$ until the end of~$M$'s transactional behavior. Since~$M$
performs a $\ASM{CallCommit(M)}$ when it has $Terminated$ its
transactional computation, nothing more has to be done to
$\ASM{Commit}$ $M$ besides deleting~$M$ from the sets of
$CommitRequest$s and still to be handled $TransAct$ions.\footnote{We
omit clearing the $history(M)$ queue since it is initialized
when~$M$ is inserted into $TransAct(\ASM{TaCtl})$.}
Note that the locations $R\mbox{-}Locked(l,M)$ and
$W\mbox{-}Locked(l,M)$ are shared by the $\ASM{Commit}$,
$\ASM{LockHandler}$ and $\ASM{Recovery}$ components, but these
components never have the same~$M$ simultaneously in their request
resp. $Victim$ set since when machine~$M$ has performed a
$\ASM{CallCommit(M)}$, it has $Terminated$ its transactional
computation and does not participate any more in any $(M,L) \in
LockRequest$ or $Victim$ization.
\begin{asm}
\ASM{Commit} =\+
\mathrel{\mathbf{if}} CommitRequest \not = \emptyset \mathrel{\mathbf{then}} \+
\mathrel{\mathbf{choose}} M \in CommitRequest ~\ASM{Commit}(M) \-
\mathrel{\mathbf{where}} \+
\ASM{Commit}(M) = \+
\mathrel{\mathbf{forall}} l \in LockedBy(M) ~~ \ASM{Unlock}(l,M) \\
\ASM{Delete}(M,CommitRequest)\\
\ASM{Delete}(M,TransAct)\-
\ASM{Unlock}(l,M)= \+
\mathrel{\mathbf{if}} R\mbox{-}Locked(l,M) \mathrel{\mathbf{then}} R\mbox{-}Locked(l,M):=false \\
\mathrel{\mathbf{if}} W\mbox{-}Locked(l,M) \mathrel{\mathbf{then}} W\mbox{-}Locked(l,M):=false
\end{asm}
As for $\ASM{Commit}$ also for the $\ASM{LockHandler}$ we use the
$\mathrel{\mathbf{choose}}$ operator to leave the order in which the $LockRequest$s are
handled refinable by different instantiations of $\ASM{TaCtl}$.
The strategy we adopt for lock handling is to refuse all locks for
locations requested by~$M$ if at least one of the following two cases
happens:
\begin{itemize}
\item some of the requested locations is $W\mbox{-}Locked$ by another
transactional machine~$N \in TransAct$,
\item some of the requested locations is a $WriteLoc$ation that is
$R\mbox{-}Locked$ by another transactional machine~$N \in TransAct$.
\end{itemize}
This definition implies that multiple transactions may
simultaneoulsy have a $R\mbox{-}Lock$ on some location. It is specified below by the predicate
$CannotBeGranted$.
To $\ASM{RefuseRequestedLocks}$ it suffices to set the communication
interface $Refused$ of $TA(M,\ASM{TaCtl})$; this makes~$M$ $Wait$ for
each location~$l$ that is $ W\mbox{-}Locked(l,N)$ and for each
$WriteLoc$ation that is $R\mbox{-}Locked(l,N)$ by some other transactional
component machine $N \in TransAct$.
\begin{asm}
\ASM{LockHandler} =\+
\mathrel{\mathbf{if}} LockRequest \not = \emptyset \mathrel{\mathbf{then}} \+
\mathrel{\mathbf{choose}} (M,L) \in LockRequest \+
\ASM{HandleLockRequest}(M,L)\global\advance\asmi by-1\-
\mathrel{\mathbf{where}} \+
\ASM{HandleLockRequest}(M,L) = \+
\mathrel{\mathbf{if}} CannotBeGranted(M,L) \+
\mathrel{\mathbf{then}} ~ \ASM{RefuseRequestedLocks}(M,L)\\
\mathrel{\mathbf{else}} ~ \ASM{GrantRequestedLocks}(M,L) \-
\ASM{Delete}((M,L),LockRequest)\-
CannotBeGranted(M,L)=\+
\mathrel{\mathbf{let}} L=(R\mbox{-}Loc,W\mbox{-}Loc), Loc= R\mbox{-}Loc \cup W\mbox{-}Loc\+
\mathrel{\mathbf{forsome}} l \in Loc ~~\mathrel{\mathbf{forsome}} N \in TransAct \setminus \{M\}\+
W\mbox{-}Locked(l,N) \mathrel{\mathbf{or}} \+
(l \in W\mbox{-}Loc \mathrel{\mathbf{and}} R\mbox{-}Locked(l,N))\global\advance\asmi by-1\dec\-
\ASM{RefuseRequestedLocks}(M,L) = (Refused(M,L):=true)\\
\ASM{GrantRequestedLocks}(M,L)=\+
\mathrel{\mathbf{let}} L=(R\mbox{-}Loc,W\mbox{-}Loc)\+
\mathrel{\mathbf{forall}} l \in R\mbox{-}Loc ~~(R\mbox{-}Locked(l,M):=true)\\
\mathrel{\mathbf{forall}} l \in W\mbox{-}Loc ~~(W\mbox{-}Locked(l,M):=true)\-
Granted(M,L):=true
\end{asm}
A $Deadlock$ originates if two machines are in a $Wait$ cycle,
otherwise stated if for some (not yet $Victim$ized) machine~$M$ the
pair $(M,M)$ is in the transitive (not reflexive) closure $Wait^*$ of
$Wait$. In this case the $\ASM{DeadlockHandler}$ selects for recovery
a (typically minimal) subset of $Deadlocked$ transactions
$toResolve$---they are $Victim$ized to $waitForRecovery$, in which
mode (control state) they are backtracked until they become
$Recovered$. The selection criteria are intrinsically specific for
particular transaction controllers, driving a usually rather complex
selection algorithm in terms of number of conflict partners,
priorities, waiting time, etc. In this paper we leave their
specification for $\ASM{TaCtl}$ abstract (read: refinable in different
directions) by using the $\mathrel{\mathbf{choose}}$ operator.
\begin{asm}
\ASM{DeadlockHandler} =\+
\mathrel{\mathbf{if}} Deadlocked \cap \overline{Victim} \not = \emptyset \mathrel{\mathbf{then}}
\mbox{ // there is a Wait cycle}\+
\mathrel{\mathbf{choose}} toResolve \subseteq Deadlocked \cap \overline{Victim} \+
\mathrel{\mathbf{forall}} M \in toResolve~ Victim(M):=true\global\advance\asmi by-1\-
\mathrel{\mathbf{where}} \+
Deadlocked = \{M \mid (M,M) \in M^*\}\\
M^*= \mbox{ TransitiveClosure}(Wait)\\
Wait(M,N) = ~ \mathrel{\mathbf{forsome}} l ~ Wait(M,l,N) \\
Wait(M,l,N) = \+
l \in newLocks(M,currState(M)) \mathrel{\mathbf{and}} N \in TransAct \setminus \{M\}
\mathrel{\mathbf{and}} \\
W\mbox{-}Locked(l,N) \mathrel{\mathbf{or}} (l \in W\mbox{-}Loc \mathrel{\mathbf{and}} R\mbox{-}Locked(l,N))\+
\mathrel{\mathbf{where}} newLocks(M,currState(M)) =(R\mbox{-}Loc,W\mbox{-}Loc)\global\advance\asmi by-1\-
\end{asm}
Also for the $\ASM{Recovery}$ component we use the $\mathrel{\mathbf{choose}}$ operator
to leave the order in which the $Victim$s are chosen for recovery
refinable by different instantiations of $\ASM{TaCtl}$. To be
$Recovered$ a machine~$M$ is backtracked by $\ASM{Undo}(M)$ steps
until $M$ is not $Deadlocked$ any more, in which case it is
deleted from the set of $Victim$s, so that be definition it is
$Recovered$. This happens at the latest when $history(M)$ has become
empty.
\begin{asm}
\ASM{Recovery} =\+
\mathrel{\mathbf{if}} Victim \not = \emptyset \mathrel{\mathbf{then}} \+
\mathrel{\mathbf{choose}} M \in Victim ~\ASM{TryToRecover}(M)\global\advance\asmi by-1 \-
\mathrel{\mathbf{where}} \+
\ASM{TryToRecover}(M) = \+
\mathrel{\mathbf{if}} M \not \in Deadlocked \mathrel{\mathbf{then}} Victim(M):=false \+
\mathrel{\mathbf{else}} ~ \ASM{Undo}(M)\global\advance\asmi by-1\-
Recovered = \+
\{M \mid ctl\mbox{-}state(M)=waitForRecovery \mathrel{\mathbf{and}} M \not \in Victim\}\-
\ASM{Undo}(M)= \+
\mathrel{\mathbf{let}} (ValSet,LockSet) = youngest(history(M))\+
\ASM{Restore}(ValSet)\\
\ASM{Release}(LockSet)\\
\ASM{Delete}((ValSet,LockSet),history(M))\global\advance\asmi by-1\-
\mathrel{\mathbf{where}} \+
\ASM{Restore}(V) =\+
\mathrel{\mathbf{forall}} ((f,args),v) \in V ~ f(args):=v \-
\ASM{Release}(L)= \+
\mathrel{\mathbf{let}} L = (R\mbox{-}Loc,W\mbox{-}Loc)\+
\mathrel{\mathbf{forall}} l \in Loc=R\mbox{-}Loc \cup W\mbox{-}Loc ~ \ASM{Unlock}(l,M)
\end{asm}
Note that in our description of the \ASM{DeadlockHandler} and the
(partial) \ASM{Recovery} we deliberately left the strategy for victim
seclection and $\ASM{Undo}$ abstract leaving fairness considerations to be
discussed elsewhere. It is clear that if always the same victim is
selected for partial recovery, the same deadlocks may be created again
and again. However, it is well known that fairness can be achieved by
choosing an appropriate victim selection strategy.
\section{Correctness Theorem}
\label{sect:Thm}
In this section we show the desired correctness property: if all
monitored or shared locations of any $M_i$ are output or controlled
locations of some other $M_j$ and all output locations of any $M_i$
are monitored or shared locations of some other $M_j$ (closed system
assumption)\footnote{This assumption means that the environment is
assumed to be one of the component machines.}, each run
of $TA({\cal M},\ASM{TaCtl})$ is equivalent to a serialization of the
terminating $M_i$-runs, namely the $M_{i_{1}}$-run followed by the
$M_{i_{2}}$-run etc., where $M_{i_{j}}$ is the $j$-th machine of $\cal
M$ which performs a commit in the $TA({\cal M},\ASM{TaCtl})$ run. To
simplify the exposition (i.e. the formulation of statement and proof
of the theorem) we only consider machine steps which take place under
the transaction control, in other words we abstract from any
step~$M_i$ makes before being $\ASM{Insert}$ed into or after being
$\ASM{Delet}$ed from the set $TransAct$ of machines which currently
run under the control of $\ASM{TaCtl}$.
First of all we have to make precise what a {\em serial} multi-agent
ASM run is and what {\em equivalence} of $TA({\cal M},\ASM{TaCtl})$
runs means in the general multi-agent ASM framework.
\subsubsection{Definition of run equivalence.}
Let $S_0, S_1, S_2, \dots$ be a (finite or infinite) run of the system $TA({\cal
M},\ASM{TaCtl})$. In general we may assume that \ASM{TaCtl} runs
forever, whereas each machine $M \in \mathcal{M}$ running as
transaction will be terminated at some time -- at least after commit
$M$ will only change values of non-shared and non-output
locations\footnote{It is possible that one ASM $M$ enters several
times as a transaction controlled by \ASM{TaCtl}. However, in this
case each of these registrations will be counted as a separate
transaction, i.e. as different ASMs in $\mathcal{M}$.}. For $i =
0,1,2,\dots$ let $\Delta_i$ denote the unique, consistent update set
defining the transition from $S_i$ to $S_{i+1}$. By definition of $TA({\cal
M},\ASM{TaCtl})$ the update set is the union of the update sets of
the agents executing $M \in \mathcal{M}$ resp. $\ASM{TaCtl}$:
\[ \Delta_i = \bigcup\limits_{M \in \mathcal{M}} \Delta_i(M)
\cup \Delta_i(\ASM{TaCtl}). \]
\noindent $\Delta_i(M)$ contains the updates defined by the ASM
$TA(M,\ASM{TaCtl})$ in state $S_i$\footnote{We use the shorthand
notation $\Delta_i(M)$ to denote $\Delta_i(TA(M,\ASM{TaCtl}))$; in
other words we speak about steps and updates of~$M$ also when they
really are done by~$TA(M,\ASM{TaCtl})$. Mainly this is about
transitions between the control states, namely TA-$ctl$,
$waitForLocks$, $waitForRecovery$ (see Fig.\ref{fig:TA(M,C)}), which
are performed during the run of~$M$ under the control of the
transaction controller $\ASM{TaCtl}$. When we want to name an
original update of~$M$ (not one of the updates of $ctl\_state(M)$ or
of the $\ASM{Record}$ component) we call it a proper $M$-update.}
and $\Delta_i(\ASM{TaCtl})$ contains the updates by the transaction
controller in this state. The sequence of update sets $\Delta_0(M)$,
$\Delta_1(M)$, $\Delta_2(M)$, \dots will be called the {\em schedule}
of $M$ (for the given transactional run).
To generalise for transactional ASM runs the equivalence of
transaction schedules known from database systems
\cite[p.621ff.]{elmasri:2006} we now define two {\em cleansing
operations} for ASM schedules. By the first one (i) we eliminate all
(in particular unsuccessful-lock-request) computation segments which
are without proper $M$-updates; by the second one (ii) we eliminate
all $M$-steps which are related to a later $\ASM{Undo}(M)$ step by the
$\ASM{Recovery}$ component:
\begin{enumerate}
\item Delete from the schedule of $M$ each $\Delta_i(M)$ where one
of the following two properties holds:
\begin{itemize}
\item $\Delta_i(M)=\emptyset$ ($M$ contributes no update to $S_i$),
\item $\Delta_i(M)$ belongs to a step of an $M$-computation segment
where~$M$ in its $ctl\_state(M)=$ TA-$ctl$ does
$\ASM{CallLockHandler}(M,newLocks)$ and in its next step moves
from control-state $waitForLocks$ back to control state TA$-ctl$, because the
$\ASM{LockHandler}$ refused new locks by $Refused(M,newLocks)$.\footnote{Note that by
eliminating this $\ASM{CallLockHandler}(M,L)$ step also the
corresponding $\ASM{LockHandler}$ step
$\ASM{HandleLockRequest}(M,L)$ disappears in the run.}
\end{itemize}
In such computation steps~$M$ makes no proper update.
\item Repeat choosing from the schedule of $M$ a pair
$\Delta_j(M)$ with later $\Delta_{j'}(M)$ ($j<j'$) which belong
to the first resp. second of two consecutive $M$-Recovery steps
defined as follows:
\begin{itemize}
\item a (say $M$-RecoveryEntry) step whereby~$M$ in state $S_j$
moves from control-state TA-$ctl$ to $waitForRecovery$, because it became a
$Victim$,
\item the next $M$-step (say $M$-RecoveryExit) whereby~$M$ in
state $S_{j'}$ moves back to control state TA-$ctl$ because it has
been $Recovered$.
\end{itemize}
In these two $M$-Recovery steps~$M$ makes no proper update. Delete:
\begin{enumerate}
\item $\Delta_j(M)$ and $\Delta_{j'}(M)$,
\item the $((Victim,M),true)$ update from the corresponding
$\Delta_t(\ASM{TaCtl})$ ($t< j$) which in state $S_j$ triggered the
$M$-RecoveryEntry,
\item $\ASM{TryToRecover}(M)$-updates in any update set
$\Delta_{i+k}(\ASM{TaCtl})$ between
the considered $M$-RecoveryEntry and $M$-RecoveryExit step
($i<j<i+k<j'$),
\item each $\Delta_{i'}(M)$ belonging to the $M$-computation segment
from TA-$ctl$ back to TA-$ctl$ which contains the
proper $M$-step in $S_i$ that is $\ASM{UNDO}$ne in $S_{i+k}$ by the
considered $\ASM{TryToRecover}(M)$ step; besides
control state and $\ASM{Record}$ updates these $\Delta_{i'}(M)$
contain updates $(\ell,v)$ with $\ell =
(f,(val_{S_i}(t_1),\dots,val_{S_i}(t_n)))$ where the
corresponding $\ASM{Undo}$ updates are
$(\ell,val_{S_i}(f(t_1,\dots,t_n))) \in
\Delta_{i+k}(\ASM{TaCtl})$,
\item the $\ASM{HandleLockRequest}(M,newLocks)$-updates in
$\Delta_{l\prime}(\ASM{TaCtl})$ corresponding to $M$'s
$\ASM{CallLockHandler}$ step (if any: in case $newLocks$ are needed
for the proper $M$-step in $S_i$) in state $S_l$ ($l<l^\prime<i$).
\end{enumerate}
\end{enumerate}
The sequence $\Delta_{i_1}(M), \Delta_{i_2}(M), \dots$ with $i_1 < i_2
< \dots$ resulting from the application of the two cleansing
operations as long as possible -- note that confluence is obvious, so
the sequence is uniquely defined -- will be called the {\em cleansed
schedule} of $M$ (for the given run).
Before defining the equivalence of transactional ASM runs we
remark that $TA({\cal M},\ASM{TaCtl})$ has indeed several runs, even
for the same initial state $S_0$. This is due to the fact that a lot
of non-determinism is involved in the definition of this ASM. First,
the submachines of \ASM{TaCtl} are non-deterministic:
\begin{itemize}
\item In case several machines $M, M^{\prime} \in \mathcal{M}$ request
conflicting locks at the same time, the \ASM{LockHandler} can only
grant the requested locks for one of these machines.
\item Commit requests are executed in random order by the \ASM{Commit} submachine.
\item The submachine \ASM{DeadlockHandler} chooses a set of victims,
and this selection has been deliberately left abstract.
\item The \ASM{Recovery} submachine chooses in each step a victim $M$,
for which the last step will be undone by restoring previous values
at updated locations and releasing corresponding locks.
\end{itemize}
Second, the specification of $TA({\cal M},\ASM{TaCtl})$ leaves
deliberately open, when a machine $M \in \mathcal{M}$ will be started,
i.e., register as a transaction in $TransAct$ to be controlled by
\ASM{TaCtl}. This is in line with the common view that transactions $M
\in \mathcal{M}$ can register at any time to the transaction
controller \ASM{TaCtl} and will remain under its control until they
commit.
\begin{definition}\rm
\ Two runs $S_0,S_1,S_2,\dots$ and
$S_0^{\prime},S_1^{\prime},S_2^{\prime},\dots$ of $TA({\cal
M},\ASM{TaCtl})$ are {\em equivalent} iff for each $M \in
\mathcal{M}$ the cleansed schedules $\Delta_{i_1}(M), \Delta_{i_2}(M),
\dots$ and $\Delta_{j_1}^\prime(M), \Delta_{j_2}^\prime(M), \dots$ for
the two runs are the same and the read locations and the values read
by~$M$ in $S_{i_k}$ and $S_{j_k}'$ are the same.
\end{definition}
That is, we consider runs to be equivalent, if all
transactions $M \in \mathcal{M}$ read the same locations and see there
the same values and perform the same updates in the same order
disregarding waiting times and updates that are undone.
\subsubsection{Definition of serializability.}
Next we have to clarify our generalised notion of a serial run, for
which we concentrate on committed transactions -- transactions that
have not yet committed can still undo their updates, so they must be
left out of consideration\footnote{Alternatively, we could concentrate
on complete, infinite runs, in which only committed transactions
occur, as eventually every transaction will commit -- provided that
fairness can be achieved.}. We need a definition of the read- and
write-locations of $M$ in a state $S$, i.e. $ReadLoc(M,S)$ and
$WriteLoc(M,S)$ as used in the definition of $newLocks(M,S)$.
The definition of $Read/WriteLoc$ depends on the locking level,
whether locks are provided for variables, pages, blocks, etc. To
provide a definite definition, in this paper we give the definition at
the level of abstraction of the locations of the underlying class
$\cal{M}$ of component machines (ASMs)~$M$. Refining this definition
(and that of $newLocks$) appropriately for other locking levels does
not innvalidate the main result of this paper.
We define $ReadLoc(M,S) = ReadLoc(r,S)$, where $r$ is the defining rule of
the ASM $M$, and analogously $WriteLoc(M,S)$ $= WriteLoc(r,S)$. Then we use structural induction according to the
definition of ASM rules in ~\cite[Table 2.2]{BoeSta03}. As an
auxiliary concept we need to define inductively the read and write
locations of terms and formulae. The definitions use an
interpretation~$I$ of free variables which we suppress notationally
(unless otherwise stated) and assume to be given with (as environment
of) the state~$S$. This allows us to write $ReadLoc(M,S)$,
$WriteLoc(M,S)$ instead of $ReadLoc(M,S,I)$, $ReadLoc(M,S,I)$
respectively.
\subsubsection{Read/Write Locations of Terms and Formulae.}
For state~$S$ let~$I$ be the given interpretation of the variables
which may occur freely (in given terms or formulae). We write
$val_S(construct)$ for the evaluation of~$construct$ (a term or a
formula) in state~$S$ (under the given interpretation~$I$ of free
variables).
\begin{asm}
ReadLoc(x,S)= WriteLoc(x,S)= \emptyset \mbox{ for variables }x \\
ReadLoc(f(t_1, \ldots , t_n) ,S)=\+
\{(f,(val_S(t_1), \ldots , val_S(t_n)))\}
~\cup ~\bigcup_{1 \leq i \leq n}ReadLoc(t_i,S)\-
WriteLoc(f(t_1 , \ldots , t_n),S)=\{(f,(val_S(t_1), \ldots , val_S(t_n)))\}
\end{asm}
Note that logical variables are not locations: they cannot be written
and their values are not stored in a location but in the given
interpretation~$I$ from where they can be retrieved.
We define $WriteLoc(\alpha,S)=\emptyset$ for every formula $\alpha$
because formulae are not locations one could write into.
$ReadLoc(\alpha,S)$ for atomic formulae $P(t_1 , \ldots , t_n )$ has to be
defined as for terms with $P$ playing the same role as a function
symbol~$f$. For propositional formulae one reads the locations of
their subformulae. In the inductive step for quantified formulae
$domain(S)$ denotes the superuniverse of~$S$
minus the Reserve set~\cite[Ch.2.4.4]{BoeSta03} and
$I_{x}^{d}$ the extension (or modification) of~$I$ where~$x$ is
interpreted by a domain element~$d$.
\begin{asm}
ReadLoc(P(t_1 , \ldots , t_n ),S)= \+
\{(P,(val_S(t_1), \ldots , val_S(t_n)))\}
~\cup ~ \bigcup_{1 \leq i \leq n}ReadLoc(t_i,S)\-
ReadLoc(\neg \alpha)= ReadLoc(\alpha)\\
ReadLoc(\alpha_1 \wedge \alpha_2) = ReadLoc(\alpha_1) \cup ReadLoc(\alpha_2)\\
ReadLoc(\forall x \alpha,S,I)= \bigcup_{d \in domain(S)}ReadLoc(\alpha,S,I_{x}^{d})
\end{asm}
\noindent Note that the values of the logical variables are not read
from a location but from the modified state environment function~$I_{x}^{d}$.
\subsubsection{Read/Write Locations of ASM Rules.}
\begin{asm}
ReadLoc(\mathrel{\mathbf{skip}},S)=WriteLoc(\mathrel{\mathbf{skip}},S)= \emptyset\\
ReadLoc(t_1 := t_2,S)= ReadLoc(t_1,S) \cup ReadLoc(t_2,S)\\
WriteLoc(t_1 := t_2,S)= WriteLoc(t_1,S)\\
ReadLoc(\mathrel{\mathbf{if}} \alpha \mathrel{\mathbf{then}} r_1 \mathrel{\mathbf{else}} r_2,S) = \+
ReadLoc(\alpha,S) \cup \left\{
\begin{array}{ll}
ReadLoc(r_1,S) & \mathrel{\mathbf{if}} val_S(\alpha)=true \\
ReadLoc(r_2,S) & \mathrel{\mathbf{else}}
\end{array} \right.\-
WriteLoc(\mathrel{\mathbf{if}} \alpha \mathrel{\mathbf{then}} r_1 \mathrel{\mathbf{else}} r_2,S) =
\left\{
\begin{array}{ll}
WriteLoc(r_1,S) & \mathrel{\mathbf{if}} val_S(\alpha)=true\\
WriteLoc(r_2,S) & \mathrel{\mathbf{else}}
\end{array} \right. \\
ReadLoc(\mathrel{\mathbf{let}} x = t \mathrel{\mathbf{in}} r,S,I)= ReadLoc(t,S,I) \cup ReadLoc(r,S,I_x^{val_S(t)})\\
WriteLoc(\mathrel{\mathbf{let}} x = t \mathrel{\mathbf{in}} r,S,I)= WriteLoc(r,S,I_x^{val_S(t)}) \mbox{ // call by value}\\
ReadLoc(\mathrel{\mathbf{forall}} x \mathrel{\mathbf{with}} \alpha \mathrel{\mathbf{do}} r,S,I)= \+
ReadLoc(\forall x \alpha,S,I) ~\cup ~ \bigcup_{a \in range(x,\alpha,S,I)}ReadLoc(r,S,I_x^a)\+
\mathrel{\mathbf{where}} range(x,\alpha,S,I)= \{d \in domain(S) \mid val_{S,I_x^d}(\alpha) = true\}\global\advance\asmi by-1\-
WriteLoc(\mathrel{\mathbf{forall}} x \mathrel{\mathbf{with}} \alpha \mathrel{\mathbf{do}} r,S,I)=
\bigcup_{a \in range(x,\alpha,S,I)}WriteLoc(r,S,I_x^a)\\
\end{asm}
In the following cases the same scheme applies to read and write
locations:\footnote{In $yields(r_1,S,I,U)$~$U$ denotes the update set
produced by rule~$r_1$ in state~$S$ under~$I$.}
\begin{asm}
Read[Write]Loc(r_1 \mathrel{\mathbf{par}} r_2,S)= \+
Read[Write]Loc(r_1,S) \cup Read[Write]Loc(r_2,S)\-
Read[Write]Loc(r(t_1, \ldots, t_n),S) = Read[Write]Loc(P(x_1/t_1,\ldots,x_n/t_n),S) \+
\mathrel{\mathbf{where}} r(x_1,\ldots,x_n)=P \mbox{ // call by reference}\-
Read[Write]Loc(r_1 \mathrel{\mathbf{seq}} r_2,S,I) = Read[Write]Loc(r_1,S,I) \cup \+
\left\{
\begin{array}{ll}
Read[Write]Loc(r_2,S+U,I) & \mathrel{\mathbf{if}}
yields(r_1,S,I,U) \mathrel{\mathbf{and}} Consistent(U)\\
\emptyset & \mathrel{\mathbf{else}}
\end{array} \right.
\end{asm}
For $\mathrel{\mathbf{choose}}$ rules we have to define the read and write locations
simultaneously to guarantee that the same instance satisfying the
selection condition is chosen for defining the read and write
locations of the rule body~$r$:
\begin{asm}
\mathrel{\mathbf{if}} range(x,\alpha,S,I)= \emptyset \mathrel{\mathbf{then}} \+
ReadLoc(\mathrel{\mathbf{choose}} x \mathrel{\mathbf{with}} \alpha \mathrel{\mathbf{do}} r,S,I)= ReadLoc(\exists x \alpha,S,I)\\
WriteLoc(\mathrel{\mathbf{choose}} x \mathrel{\mathbf{with}} \alpha \mathrel{\mathbf{do}} r,S,I)=\emptyset \mbox{ // empty action}\-
\mathrel{\mathbf{else}} ~\mathrel{\mathbf{choose}} a \in range(x,\alpha,S,I)\+
ReadLoc(\mathrel{\mathbf{choose}} x \mathrel{\mathbf{with}} \alpha \mathrel{\mathbf{do}} r,S,I)= \+
ReadLoc(\exists x \alpha,S,I)
\cup ReadLoc(r,S,I_x^a)\-
WriteLoc(\mathrel{\mathbf{choose}} x \mathrel{\mathbf{with}} \alpha \mathrel{\mathbf{do}} r,S,I)= WriteLoc(r,S,I_x^a)
\end{asm}
We say that~$M$ has or is committed (in state~$S_i$, denoted
$Committed(M,S_i)$) if step $\ASM{Commit}(M)$ has been performed (in
state~$S_i$).
\begin{definition}\rm
\ A run of $TA({\cal M},\ASM{TaCtl})$ is {\em serial} iff there is a
total order $<$ on $\mathcal{M}$ such that the following two
conditions are satisfied:
\begin{enumerate}
\item If in a state $M$ has committed, but $M^\prime$ has not, then
$M < M^\prime$ holds.
\item If $M$ has committed in state $S_i$ and $M < M^\prime$ holds,
then the cleansed schedule $\Delta_{j_1}(M^\prime)$,
$\Delta_{j_2}(M^\prime), \dots$ of $M^\prime$ satisfies $i < j_1$.
\end{enumerate}
\end{definition}
That is, in a serial run all committed transactions are executed
in a total order and are followed by the updates of transactions that did not
yet commit.
\begin{definition}\rm
\ A run of $TA({\cal M},\ASM{TaCtl})$ is {\em serialisable} iff it is
equivalent to a serial run of $TA({\cal
M},\ASM{TaCtl})$.\footnote{Modulo the fact that ASM steps permit
simultaneous updates of multiple locations, this definition of
serializability is equivalent to Lamport's sequential consistency
concept~\cite{Lamport79}.}
\end{definition}
\begin{theorem}
\ Each run of $TA({\cal M},\ASM{TaCtl})$ is serialisable.
\end{theorem}
\begin{proof}
\ Let $S_0,S_1,S_2,\dots$ be a run of $TA({\cal M},\ASM{TaCtl})$. To
construct an equivalent serial run let $M_1 \in \mathcal{M}$ be a
machine that commits first in this run, i.e. $Committed(M,S_i)$
holds for some $i$ and whenever $Committed(M,S_j)$ holds for some $M
\in \mathcal{M}$, then $i \le j$ holds. If there is more than one
machine $M_1$ with this property, we randomly choose one of them.
Take the run of $TA(\{ M_1 \},\ASM{TaCtl})$ starting in state $S_0$,
say $S_0, S_1^\prime, S_2^\prime, \dots, S_n^\prime$. As $M_1$
commits, this run is finite. $M_1$ has been $\ASM{Delete}$d from
$TransAct$ and none of the $\ASM{TaCtl}$ components is triggered any
more: neither $\ASM{Commit}$ nor $\ASM{LockHandler}$ because
$CommitRequest$ resp. $LockRequest$ remain empty; not
$\ASM{DeadlockHandler}$ because $Deadlock$ remains false since~$M_1$
never $Wait$s for any machine; not $\ASM{Recovery}$ because$Victim$
remains empty. Note that in this run the schedule for $M_1$ is already
cleansed.
We now define a run $S_0^{\prime\prime} , S_1^{\prime\prime},
S_2^{\prime\prime}, \dots$ (of $TA({\cal M} - \{ M_1 \},\ASM{TaCtl})$,
as has to be shown) which starts in the final state $S_n^\prime =
S_0^{\prime\prime}$ of the $TA(\{ M_1 \},\ASM{TaCtl})$ run and where
we remove from the run defined by the cleansed schedules $\Delta_i(M)$
for the originally given run all updates made by steps of~$M_1$ and
all updates in $\ASM{TaCtl}$ steps which concern~$M_1$. Let
\[ \Delta_i^{\prime\prime} = \bigcup\limits_{M \in \mathcal{M} - \{M_1\} } \Delta_i(M) \cup \{ (\ell,v) \in \Delta_i(\ASM{TaCtl}) \mid (\ell,v) \;\text{does not concern $M_1$} \} . \]
That is, in the update set $\Delta_i^{\prime\prime}$ all updates are removed from the
original run which are done by $M_1$---their effect is reflected
already in the initial run segment from $S_0$ to $S_n^\prime $---or
are $\ASM{LockHandler}$ updates involving a $LockRequest(M_1,L)$ or
are $Victim(M_1):=true$ updates of the $\ASM{DeadlockHandler}$ or are
updates involving a $\ASM{TryToRecover}(M_1)$ step or are done by
a step involving a $\ASM{Commit}(M_1)$.
\begin{lemma}\label{lem1}
\ $S_0^{\prime\prime}, S_1^{\prime\prime}, S_2^{\prime\prime}, \dots$
is a run of $TA({\cal M} - \{ M_1 \},\ASM{TaCtl})$.
\end{lemma}
\begin{lemma}\label{lem2}
\ The run $S_0, S_1^\prime, S_2^\prime, \dots, S_n^\prime,
S_1^{\prime\prime}, S_2^{\prime\prime}, \dots$ of $TA({\cal
M},\ASM{TaCtl})$ is equivalent to the original run
$S_0,S_1,S_2,\dots$.
\end{lemma}
By induction hypothesis $S_0^{\prime\prime}, S_1^{\prime\prime},
S_2^{\prime\prime}, \dots$ is serialisable, so
$S_0,S_1^\prime,S_2^\prime,\dots$ and thereby also $S_0,S_1,S_2,\dots$ is
serialisable with $M_1 < M$ for all $M \in \mathcal{M} - \{ M_1 \}$.\hfill
\end{proof}
\begin{proof}\textbf{(Lemma \ref{lem1})}
\ We first show that omitting in $\Delta_i^{\prime\prime}$ every update
from $\Delta_i(\ASM{TaCtl})$ which concerns $M_1$ does not affect
updates by $\ASM{TaCtl}$ in $S_i^{\prime\prime}$ concerning $M \neq
M_1$. In fact starting in the final $M_1$-state $S_0^{\prime\prime}$,
$TA({\cal M} - \{ M_1 \},\ASM{TaCtl})$ makes no move with a
$Victim(M_1):=true$ update and no move of $\ASM{Commit}(M_1)$ or
$\ASM{HandleLockRequest}(M_1,L)$ or $\ASM{TryToRecover}(M_1)$
It remains to show that every $M$-step defined by
$\Delta_i^{\prime\prime}(M)$ is a possible $M$-step in a $TA({\cal M}
- \{ M_1 \},\ASM{TaCtl})$ run starting in $S_0''$. Since the
considered $M$-schedule $\Delta_i(M)$ is cleansed, we only have to
consider any proper update step of $M$ in state~$S_i''$ (together with
its preceding lock request step, if any). If in~$S_i''$ $M$ uses
$newLocks$, in the run by the cleansed schedules for the original run
the locks must have been granted after the first $\ASM{Commit}$, which
is done for~$M_1$ before $S_0''$. Thus these locks are granted also
in~$S_i^{\prime\prime}$ as part of a $TA({\cal M} - \{ M_1
\},\ASM{TaCtl})$ run step. If no $newLocks$ are needed, that proper
$M$-step depends only on steps computed after $S_0''$ and thus is part
of a $TA({\cal M} - \{ M_1 \},\ASM{TaCtl})$ run step. \hfill
\end{proof}
\begin{proof}\textbf{(Lemma \ref{lem2})}
\ The cleansed machine schedules in the two runs, the read locations
and the values read there have to be shown to be the same. First
consider any $M \not = M_1$. Since in the initial segment $S_0,
S_1^\prime, S_2^\prime, \dots, S_n^\prime$ no such~$M$ makes any move
so that its update sets in this computation segment are empty, in the
cleansed schedule of~$M$ for the run $S_0, S_1^\prime, S_2^\prime,
\dots, S_n^\prime, S_1^{\prime\prime}, S_2^{\prime\prime}, \dots$ all
these empty update sets disappear. Thus this cleansed schedule is the
same as the cleansed schedule of $M$ for the run
$S_n^\prime,S_1^{\prime\prime}, S_2^{\prime\prime}, \dots$ and
therefore by definition of $\Delta_i^{\prime\prime}(M) = \Delta_i(M)$
also for the original run $S_0,S_1,S_2,\dots$ with same read locations
and same values read there.
Now consider $M_1$, its schedule $\Delta_0(M_1), \Delta_1(M_1), \dots$
for the run $S_0,S_1,S_2,\dots$ and the corresponding cleansed
schedule $\Delta_{i_0}(M_1), \Delta_{i_1}(M_1), \Delta_{i_2}(M_1),
\dots$. We proceed by induction on the cleansed schedule steps of
$M_1$. When $M_1$ makes its first step using the
$\Delta_{i_0}(M_1)$-updates, this can only be a proper~$M_1$-step
together with the corresponding $\ASM{Record}$ updates (or a lock
request directly preceding such a $\Delta_{i_1}(M_1)$-step) because in
the computation with cleansed schedule each lock request of $M_1$ is
granted and $M_1$ is not $Victim$ized. The values $M_1$ reads or
writes in this step (in private or locked locations) have not been
affected by a preceding step of any $M \not = M_1$---otherwise~$M$
would have locked before the non-private locations and keep the locks
until it commits (since cleansed schedules are without $\ASM{Undo}$ steps),
preventing $M_1$ from getting these locks which contradicts the fact
that $M_1$ is the first machine to commit and thus the first one to
get the locks. Therefore the values $M_1$ reads or writes in the step
defined by $\Delta_{i_0}(M_1)$ (resp. also $\Delta_{i_1}(M_1)$)
coincide with the corresponding location values in the first
(resp. also second) step of $M_1$ following the cleansed schedule to
pass from $S_0$ to $S_1^\prime$ (case without request of $newLocks$)
resp. from $S_0$ to $S_1^\prime$ to $S_2^\prime$ (otherwise). The same
argument applies in the inductive step which establishes the claim.\hfill
\end{proof}
\section{Conclusion}
In this article we specified (in terms of Abstract State Machines) a
transaction controller $\ASM{TaCtl}$ and a transaction operator which
turn the behaviour of a set of concurrent programs into a
transactional one under the control of $\ASM{TaCtl}$. In this way the
locations shared by the programs are accessed in a well-defined
manner. For this we proved that all concurrent transactional runs are
serialisable.
The relevance of the transaction operator is that it permits to
concentrate on the specification of program behavior ignoring any
problems resulting from the use of shared locations. That is,
specifications can be written in a way that shared locations are
treated as if they were exclusively used by a single program. This is
valuable for numerous applications, as shared locations (in
particular, locations in a database) are common, and random access to
them is hardly ever permitted.
Furthermore, by shifting transaction control into the rigorous
framework of Abstract State Machines we made several extensions to
transaction control as known from the area of databases
\cite{elmasri:2006}. In the classical theory schedules are sequences
containing read- and write-operations of the transactions plus the
corresponding read- and write-lock and commit events, i.e., only one
such operation or event is treated at a time. In our case we exploited
the inherent parallelism in ASM runs, so we always considered an
arbitrary update set with usually many updates at the same time. Under
these circumstances we generalised the notion of schedule and
serialisability in terms of the synchronous parallelism of ASMs. In
this way we stimulate also more parallelism in transactional systems.
Among further work we would like to be undertaken is to provide a
(proven to be correct) implementation of our transaction controller
and the $TA$ operator, in particular as plug-in for the
CoreASM~\cite{farahbod:scp2014,farahbod:fi2007} or Asmeta~\cite{arcaini:spe2011,gargantini:jucs2008}
simulation engines. We would also like to see refinements or
adaptations of our transaction controller model for different
approaches to serialisability~\cite{gray:1993}, see also the ASM-based
treatment of multi-level transaction control
in~\cite{kirchberg:2009}. Last but not least we would like to see
further detailings of our correctness proof to a mechanically verified
one, e.g. using the ASM theories developed in KIV (see~\cite{kiv} for
an extensive list of relevant publications) and
PVS~\cite{GarRic00,GoVhLa96,Verifix96} or the (Event-)B~\cite{Abrial96,Abrial10} theorem prover for an (Event-)B transformation of
$TA({\cal M},\ASM{TaCtl})$ (as suggested in~\cite{GlaHLR13}).
\subsubsection{Acknowledgement.}
We thank Andrea Canciani and some of our referees for useful comments
to improve the paper.
\def\note#1{}
\bibliographystyle{abbrv}
| {'timestamp': '2017-06-07T02:06:44', 'yymm': '1706', 'arxiv_id': '1706.01762', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01762'} | arxiv |
\section{Introduction}
The recovery of camera parameters and scene structure have been studied for over two decades since several applications, such as 3D vision from multiple views~\cite{Hartley2003}, are heavily dependent on the quality of the camera calibration. In particular, two major calibration types can be considered: aiming at the determination of the intrinsic and/or extrinsic parameters. The former ones include focal lengths, principal point, aspect ratio, and non-perspective distortion parameters, while the extrinsic parameters are the relative pose.
Assuming two cameras with unknown extrinsic and \textit{a priori} intrinsic parameters except a common focal length is called the \textit{semi-calibrated case}~\cite{li2006simple}. It leads to the \textit{unknown focal-length problem}: estimation of the relative motion and common focal length, simultaneously.
The semi-calibrated case is realistic since (1) the aspect ratio is determined by the shape of the pixels on the sensors, it is usually 1:1; (2) the principal point is close to the center of the image, thus it is a reasonable approximation and (3) the distortion can be omitted if narrow field-of-view lenses are applied.
Considering solely the locations of point pairs makes the problem solvable using at least six point pairs~\cite{li2006simple,stewenius2008minimal,torii2010six}. The objective of this paper is to \textit{solve the problem exploiting only two local affine transformations}.
In general, 3D vision approaches~\cite{Hartley2003} including state-of-the-art structure-from-motion pipelines~\cite{Agarwal2011,BodisCVPR2014,Frahm2010,Moulon2013} apply a robust estimator, e.g.\ RANSAC~\cite{RANSAC}, augmented with a minimal method, such as the five~\cite{nister2004efficient} or six-point~\cite{li2006simple} algorithm as an engine. Selecting a method exploiting as few point pairs as possible gains accuracy and drastically reduces the processing time. Benefiting from estimators which use less input data, the understanding of low-textured environment becomes significantly easier~\cite{Raposo2016}. Moreover, minimal methods are advantageous from theoretical point-of-view leading to deeper understanding.
Local affine transformations represent the warp between the infinitely close vicinities of corresponding point pairs~\cite{koser2009geometric} and have been investigated for a decade. Their application field includes homography~\cite{Barath2016novel} and surface normal~\cite{koser2009geometric,Barath2015} estimation; recovery of the epipoles~\cite{Bentolila2014}; triangulation of points in 3D~\cite{koser2009geometric}; camera pose estimation~\cite{Koser2008}; structure-from-motion~\cite{Raposo2016}. In practice, local affinities can be accurately retrieved~\cite{barath2016accurate,mikolajczyk2005comparison} using e.g.\ affine-covariant feature detectors, such Affine-SIFT~\cite{Morel2009} and Hessian-Affine~\cite{mikolajczyk2002affine}.
To the best of our knowledge, no paper has dealt with the unknown focal length problem using local affine transformations.
This paper proposes two novel linear constraints describing the relationship between local affinities and epipolar geometry. Forming a multivariate polynomial system and solving it by the \textit{hidden-variable technique}~\cite{cox2006using}, the proposed method is efficient and estimates the focal length and the relative motion using only two affinities. In order to eliminate invalid roots, a novel condition is introduced investigating the geometry of local affinities. To select the best candidate out of the remaining ones, we propose a root selection technique which is as accurate as the state-of-the-art for small noise and outperforms it for high-level noise.
\section{Preliminaries and Notation}
\noindent
\textbf{Epipolar geometry.}
Assume two perspective cameras with a common intrinsic camera matrix $\mathbf{K}$ to be known. Fundamental and essential matrices~\cite{Hartley2003} are as follows:
\begin{equation*}
\mathbf{F} = \begin{bmatrix}
f_1 & f_2 & f_3 \\
f_4 & f_5 & f_6 \\
f_7 & f_8 & f_9
\end{bmatrix}, \quad
\mathbf{E} = \begin{bmatrix}
e_1 & e_2 & e_3 \\
e_4 & e_5 & e_6 \\
e_7 & e_8 & e_9
\end{bmatrix}.
\end{equation*}
If the cameras are calibrated ($\mathbf{K}$ is known) matrix $\mathbf{F}$ can be transformed to be an essential matrix $\mathbf{E}$ as follows:
\begin{equation}
\mathbf{E} = \textbf{K}^{T} \mathbf{F} \mathbf{K}.
\end{equation}
The epipolar relationship of corresponding point pair $\mathbf{p}_1$ and $\mathbf{p}_2$ are described by $\mathbf{F}$ as
\begin{equation}
\label{eq:epipolar_constraint}
\mathbf{p}_2^T \mathbf{F} \mathbf{p}_1 = 0.
\end{equation}
A valid fundamental matrix must satisfy singularity constraint $\det(\mathbf{F}) = 0$.
Considering this cubic constraint and the fact that a fundamental matrix is defined up to an arbitrary scale, its degrees-of-freedom is reduced to seven. Thus seven point pairs are enough for the estimation.
As the essential matrix encapsulates the full camera motion, the orientation and direction of the translation, it has five degrees-of-freedom. The two additional constraints are described by the well-known trace constraint~\cite{li2006simple} as
\begin{equation}
\label{eq:trace_constraint}
2 \mathbf{E} \mathbf{E}^T \mathbf{E} - \textrm{tr}(\mathbf{E} \mathbf{E}^T) \textbf{E} = 0.
\end{equation}
Even though Eq.~\ref{eq:trace_constraint} yields nine polynomial equations for $\mathbf{E}$, only two of them are algebraically independent.
Semi-calibrated case is assumed in this paper as only the common focal-length $f$ is considered to be unknown. Without loss of generality, the intrinsic camera matrix is
\mathbf{K} = \mathbf{K}^T= \text{diag}(f, f, 1),
$
where $f$ is the unknown focal-length. In order to replace $\mathbf{E}$ with $\mathbf{F}$ in Eq.~\ref{eq:trace_constraint} we define matrix $\mathbf{Q}$ as follows:
\begin{equation}
\mathbf{Q} = \text{diag} \left( 1,1,\tau \right),
\quad \tau = f^{-2}.
\end{equation}
\noindent
Due to the fact that $\mathbf{K}$ is non-singular, and trace($\mathbf{E} \mathbf{E}^T$) identifies a
scalar value, Eq.~\ref{eq:trace_constraint} can be simplified by multiplying with $\mathbf{K}^{-T}$ and $\mathbf{K}^{-1}$ from the left and the right sides, respectively. Moreover, trace is invariant under cyclic permutations. As a consequence, Eq.~\ref{eq:trace_constraint} is written as~\cite{Kukelova2008BMVC,Pernek2013PRL}
\begin{equation}
\label{eq:focal_trace_constraint}
2 \mathbf{F} \mathbf{Q} \mathbf{F}^T \mathbf{Q} \mathbf{F} - \textrm{tr}(\mathbf{F} \mathbf{Q} \mathbf{F}^T \mathbf{Q}) \mathbf{F} = 0.
\end{equation}
This relationship will help us to recover the focal length and the fundamental matrix using two affine correspondences.
\noindent
\textbf{An affine correspondence} $(\mathbf{p}_1, \mathbf{p}_2, \mathbf{A})$ consists of a corresponding point pair and the related local affinity $\mathbf{A}$ transforming the vicinity of point $\mathbf{p}_1$ to that of $\mathbf{p}_2$. In the rest of the paper, $\mathbf{A}$ is considered as its left $2 \times 2$ submatrix
\begin{equation*}
\mathbf{A} = \begin{bmatrix} a_1 & a_2 \\
a_3 & a_4
\end{bmatrix}
\end{equation*}
since the third column -- the translation part -- is determined by the point locations.
We use the \textbf{hidden variable technique} in the proposed method. It is a resultant technique in algebraic geometry for the elimination of variables from a multivariate polynomial system~\cite{cox2006using}. Suppose that $m$ polynomial equations in $n$ variables are given. In brief, one can assume an unknown variable as a parameter and rewrite the equation system as $\textbf{C}(y_1) \textbf{x} = 0$, where $\textbf{C}$ is a coefficient matrix depending on the unknown $y_1$ (hidden variable) and vector $\textbf{x}$ is the vector of $n - 1$ unknowns. If the number of equations equals to that of the unknown monomials in $\textbf{x}$, i.e. matrix $\textbf{C}$ is square, the non-trivial solution can be carried out as $\det(\textbf{C}(y_1)) = 0$. Solving the resultant equation for $y_1$ and back-substituting it, the whole system is solved.
\section{Focal-length using Two Correspondences}
This section aims the recovery of the unknown focal length and fundamental matrix using two affine correspondences. First, the connection between the fundamental matrix and local affinity is introduced, then we discuss the estimation technique. \vspace{5px}
\noindent \vspace{2px}
\textbf{3.1. Exploiting a Local Affine Transformation}
Suppose that an affine correspondence $(\mathbf{p_1}, \mathbf{p_2}, \mathbf{A})$ and fundamental matrix $\mathbf{F}$ are known. It is trivial that every affine transformation preserves the direction of the lines going through points $\mathbf{p_1}$ and $\mathbf{p_2}$ on the first and second images. As a consequence, the link between directions $\mathbf{v_1}$ and $\mathbf{v_2}$ of epipolar lines can be described~\cite{barath2016accurate} by affine transformation $\mathbf{A}$ as
\begin{equation}
\label{eq:a_v1_par_v2}
\mathbf{A} \mathbf{v_1} \parallel \mathbf{v_2}.
\end{equation}
Reformulating Eq.~\ref{eq:a_v1_par_v2} using the well-known fact from Computer Graphics~\cite{turkowski1990transformations} leads to $\mathbf{A}^{-T} \mathbf{R}^{90} \mathbf{v_1} = \beta \mathbf{R}^{90} \mathbf{v_2}$,
where matrix $\mathbf{R}^{90}$ is a 2D orthonormal (rotation) matrix rotating with $90$ degrees and $\beta$ is an unknown scale. Vectors $\mathbf{R}^{90} \mathbf{v_1}$ and $\mathbf{R}^{90} \mathbf{v_2}$ are the line normals $\mathbf{n_1}$ and $\mathbf{n_2}$ as
\begin{equation}
\label{eq:a_n1_eq_n2}
\mathbf{A}^{-T} \mathbf{n_1} = \beta \mathbf{n_2}.
\end{equation}
In Appendix~\ref{appendix:proof_affine_constraints}, it is proven that $\beta$ is equal to $-1$ if $\mathbf{n_1}$ and $\mathbf{n_2}$ are calculated from the fundamental matrix using relationships $\mathbf{F} \mathbf{n_1}$ and $\mathbf{F}^T \mathbf{n_2}$ and they are \textit{not normalized}. In brief, it is given as the distance ratio of neighboring epipolar lines on the two images. For the case when the normals are not normalized -- the original scale has not been changed --, $\beta$ is only a scale inverting the directions.
Normals are expressed from $\mathbf{F}$ as the first two coordinates of the epipolar lines: $\mathbf{n}_1 = (\mathbf{l}_1)_{(1:2)} = (\mathbf{F}^T \mathbf{p}_2)_{(1:2)}$ and $\mathbf{n}_2 = (\mathbf{l}_2)_{(1:2)} = (\mathbf{F} \mathbf{p}_1)_{(1:2)}$~\cite{Hartley2003}, where the lower indices select a subvector. Therefore, Eq.~\ref{eq:a_n1_eq_n2} is written as
\begin{equation}
\mathbf{A}^{-T} (\mathbf{F}^T \mathbf{p}_2)_{(1:2)} = -(\mathbf{F} \mathbf{p}_1)_{(1:2)}
\end{equation}
and forms a system of linear equations consisting of two equations as follows:
\begin{eqnarray}
\label{eq:affine_constraint_1}
(u_2 + a_1 u_1) f_1 + a_1 v_1 f_2 + a_1 f_3 + (v_2 + a_3 u_1) f_4 + \nonumber \\ a_3 v_1 f_5 + a_3 f_6 + f_7 = 0 \\
\label{eq:affine_constraint_2}
a_2 u_1 f_1 + (u_2 + a_2 v_1) f_2 + a_2 f_3 + a_4 u_1 f_4 + \nonumber \\ (v_2 + a_4 v_1) f_5 + a_4 f_6 + f_8 = 0.
\end{eqnarray}
Thus each local affine transformation \textit{reduces the degrees-of-freedom by two}.
\vspace{5px}
\noindent \vspace{2px}
\textbf{3.2. Two-point Solver}
Suppose that two affine correspondences ($\mathbf{p}_1^{1}$, $\mathbf{p}_2^{1}$, $\mathbf{A}^{1}$) and ($\mathbf{p}_1^{2}$, $\mathbf{p}_2^{2}$, $\mathbf{A}^{2}$) are given. Coefficient matrix
\begin{equation*}
\resizebox{1.0\columnwidth}{!}{
$\mathbf{C}^i =
\begin{bmatrix}
u_2 + a_1 u_1 & a_1 v_1 & a_1 & v_2 + a_3 u_1 & a_3 v_1 & a_3 & 1 & 0 & 0 \\
a_2 u_1 & u_2 + a_2 v_1 & a_2 & a_4 u_1 & v_2 + a_4 v_1 & a_4 & 0 & 1 & 0 \\
u_1 u_2 & v_1 u_2 & u_2 & u_1 v_2 & v_1 v_2 & v_2 & u_1 & v_1 & 1
\end{bmatrix}$
}
\end{equation*}
related to the $i$-th ($i \in \{1,2\}$) correspondence is formed as the combination of Eqs.~\ref{eq:epipolar_constraint},~\ref{eq:affine_constraint_1},~\ref{eq:affine_constraint_2} and satisfies formula $\mathbf{C}^i \mathbf{x} = 0$, where $\mathbf{x} = \begin{bmatrix} f_1 & f_2 & f_3 & f_4 & f_5 & f_6 & f_7 & f_8 & f_9 \end{bmatrix}^T$ is the vector of unknown elements of the fundamental matrix. We denote the concatenated coefficient matrix of both correspondences as follows:
\begin{equation}
\mathbf{C} = \begin{bmatrix}
\mathbf{C}^1 \\
\mathbf{C}^2
\end{bmatrix}.
\end{equation}
It is of size $6 \times 9$, therefore, its left null space is three-dimensional. The solution is carried out as
\begin{equation}
\label{eq:null_space}
\mathbf{x} = \alpha \mathbf{a} + \beta \mathbf{b} + \gamma \mathbf{c},
\end{equation}
where $\mathbf{a}$, $\mathbf{b}$ and $\mathbf{c}$ are the singular vectors and $\alpha$, $\beta$, $\gamma$ are unknown non-zero scalar values.
Remember that only the common focal length is unknown from the intrinsic parameters, therefore, we are able to exploit the trace constraint. Eq.~\ref{eq:focal_trace_constraint} yields ten cubic equations for four unknowns $\alpha$, $\beta$, $\gamma$ and $\tau$, where $\tau = f^{-2}$ encapsulates the unknown focal length.
We consider $\tau$ as the hidden variable and form coefficient matrix $\mathbf{C}(\tau)$ w.r.t.\ the other three ones -- thus the rows of $\mathbf{C}(\tau)$ are univariate polynomials with variable $\tau$. Even though $\alpha$, $\beta$ and $\gamma$ are defined up to a common scale, we do not fix this scale in order to keep the homogenity of the system. The monomials of this polynomial system are as
$
\mathbf{y} = [ \alpha^3 \;\; \alpha^2 \beta \;\; \alpha^2 \gamma \;\; \alpha \beta^2 \;\; \alpha \beta \gamma \;\; \alpha \gamma^2 \;\; \beta^3 \;\; \beta^2 \gamma \;\; \beta \gamma^2 \;\; \gamma^3 ]^T
$.
Table~\ref{tab:coefficient_table} demonstrates the coefficient matrix.
Since the scale of monomial vector $\mathbf{x}$ has not been fixed, the non-trivial solution of equation $\mathbf{C}(\tau) \mathbf{y} = 0$ is when the determinant vanishes as
\begin{equation}
\label{eq:determinant_hidden}
\det(\mathbf{C}(\tau)) = 0.
\end{equation}
Therefore, the hidden-variable resultant -- a polynomial of the hidden variable -- is $\det(\mathbf{C}(\tau))$. As the current problem is fairly similar to that of~\cite{li2006simple}, we adopt the proposed algorithm. It is proved that $\det(\mathbf{C}(\tau))$ is actually a 15-th degree polynomial and it obtains the candidate values for $\tau$. Then the solution for $\alpha$, $\beta$, $\gamma$ and $\tau$ is given as $\mathbf{y} = \text{null}(\mathbf{C}(\tau))$. Finally, fundamental matrix $\mathbf{F}$ regarding to each obtained focal length can be directly estimated using Eq.~\ref{eq:null_space}.
\begin{table}[h!]
\centering
\resizebox{\columnwidth}{!}{ \begin{tabular}{ | c | c c c c c c c c c c | }
\hline
\multirow{2}{*}{$\mathbf{C}(\tau)$} & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\
& $\alpha^3$ & $\alpha^2 \beta$ & $\alpha^2 \gamma$ & $\alpha \beta^2$ & $\alpha \beta \gamma$ & $\alpha \gamma^2$ & $\beta^3$ & $\beta^2 \gamma$ & $\beta \gamma^2$ & $\gamma^3$ \\
\hline
1 & $c_1$ & $c_2$ & $c_3$ & $c_4$ & $c_5$ & $c_6$ & $c_7$ & $c_8$ & $c_9$ & $c_{10}$ \\
. & . & . & . & . & . & . & . & . & . & .\\
10 & $c_{91}$ & $c_{92}$ & $c_{93}$ & $c_{94}$ & $c_{95}$ & $c_{96}$ & $c_{97}$ & $c_{98}$ & $c_{99}$ & $c_{100}$ \\
\hline
\end{tabular} }
\caption{ The coefficient matrix $\mathbf{C}(\tau)$ related to the ten polynomial equations of the trace constraint.}
\label{tab:coefficient_table}
\end{table}
\section{Elimination and Selection of Roots}
In this section, a novel technique is proposed to omit roots on the basis of the underlying geometry. Then we show a heuristics considering the properties of digital cameras to remove invalid focal lengths. In the end, we introduce a root selection algorithm. \vspace{5px}
\noindent \vspace{2px}
\textbf{4.1. Elimination of Invalid Focal Lengths}
A solution is proposed here based on the underlying geometry to eliminate invalid focal lengths. Suppose that a point pair $(\mathbf{p}_1, \mathbf{p}_2)$, the related local affinity $\mathbf{A}$, the fundamental matrix $\mathbf{F}$, and an obtained focal length $f$ are given. As the semi-calibrated case is assumed, $\mathbf{F}$ and $f$ exactly determines the projection matrices $\mathbf{P}_1$ and $\mathbf{P}_2$ of both cameras~\cite{Hartley2003}. Denote the 3D coordinates and the surface normal induced by point pair $(\mathbf{p}_1, \mathbf{p}_2)$, local affinity $\mathbf{A}$ and the projection matrices with $\mathbf{q} = [x \quad y \quad z]^T$ and $\mathbf{n} = [n_x \quad n_y \quad n_z]^T$, respectively. According to our experiences, linear triangulation~\cite{Hartley2003} is a suitable and efficient choice to estimate $\mathbf{q}$. Surface normal $\mathbf{n}$ is estimated exploiting affinity $\mathbf{A}$ by the method proposed in~\cite{Barath2015}.\footnote{\url{http://web.eee.sztaki.hu/~dbarath/}}
Without loss of generality, we assume that a point of a 3D surface cannot be observed from behind. As a consequence, the angle between vectors $\mathbf{c}_{i} - \mathbf{q}$ and $\mathbf{n}$ must be smaller than $90^{\circ}$ for both cameras, where $\mathbf{c}_{i}$ is the position of the $i$-th camera ($i \in \{1,2\}$). This can be interpreted as follows: each camera selects a half unit-sphere around the observed point $\textbf{q}$. Surface normal $\textbf{n}$ must lie in the intersection of these half spheres.
These half spheres are described by a rectangle in the spherical coordinate system as follows:
\textrm{rect}_{i} = \begin{bmatrix} \theta_{i} - \frac{\pi}{2} & \sigma_{i} - \frac{\pi}{4} & \pi & \frac{\pi}{2} \end{bmatrix}
$,
where $\theta_{i}$, $\sigma_{i}$ are the corresponding spherical coordinates and $\textrm{rect}_{i}$ is of format $\begin{bmatrix} \textrm{corner}_\theta & \textrm{corner}_\sigma & \textrm{width} & \textrm{height} \end{bmatrix}$. The intersection area induced by the two cameras is as
\begin{equation*}
\textrm{rect}_\cap = \bigcap_{i \in [1,2]} \textrm{rect}_{i}.
\end{equation*}
Point $\textbf{q}$ is observable from both cameras \textit{if and only if} surface normal $\textbf{n}$, represented by spherical coordinates $\Theta$ and $\Sigma$, lies in the intersection area: $\begin{bmatrix} \Theta & \Sigma \end{bmatrix} \in \textrm{rect}_\cap$. A setup, induced by focal length $f$, not satisfying this criteria is an invalid one and can be omitted. Note that this constraint can be straightforwardly extended to the multi-view case making the intersection area more restrictive. \vspace{5px}
\noindent \vspace{2px}
\textbf{4.2. Physical Properties of Cameras}
We introduce restrictions on the estimated roots considering the physical limits of the cameras. The focal length within camera matrix $\mathbf{K}$ is not equivalent to the focal length of the lenses, since it is the ratio of the optical focal length and the pixel size~\cite{Hartley2003}. Particularly, the latter one is a few micrometers, while the optical focal length are within interval $[1 \dots 500]$ mm. Therefore, coarse lower and upper limits for a realistic camera are $100$ and $500.000$. Focal lengths out of this interval are automatically discarded. Note that these limits can be easily changed considering cameras with different properties. \vspace{5px}
\noindent \vspace{2px}
\textbf{4.3. Root Selection}
To resolve the ambiguity of multiple roots and to minimize the effect of the noise, the classical way is to exploit multiple measurements eliminating the inconsistent ones. Since Eq.~\ref{eq:determinant_hidden} is a high-degree polynomial it is sensitive to noise -- small changes in the coordinates and affine elements cause significantly different coefficients.
RANSAC~\cite{RANSAC} is a successful technique for that problem, e.g. in the five-point relative-orientation one~\cite{nister2004efficient}. Recent methods, i.e. Kernel Voting, exploit the property that the roots form a peak around the real solution~\cite{li2005non,li2006simple,kukelova2012algebraic}. Kernel Voting maximizes a kernel density function like a maximum-likelihood-decision-maker. To our experiences, this technique works accurately if the noise in the coordinates does not exceed $1-2$ pixels on average. Over that, the roots may form several strongly supported peaks and it is not guaranteed that the true solution is found.
Thus we formulate the problem as a mode-seeking in a one dimensional domain: the real focal length appears as the most supported mode. Among several mode-seeking techniques~\cite{jain1999data} the most robust one is the Median-Shift~\cite{shapira2009mode} according to extensive experimentation. Median-Shift providing Tukey-medians~\cite{tukey1975mathematics} as modes does not generate new elements in the domain it is applied to. In particular, there is no significant difference in the results of Tukey-~\cite{tukey1975mathematics} and Weiszfeld-medians~\cite{weiszfeld1937point}, however, the former one is slightly faster to compute. Finally, in order to overcome the discrete nature of Median-Shift -- since it does not add new instances, only operates with the given ones --, we apply a gradient descent from the retrieved mode $x_0$ maximizing function
\begin{equation}
f(x) = \sum_{i = 1}^{n} \frac{\kappa(x_i - x)}{h},
\end{equation}
where $n$ is the number of focal lengths, $\kappa$ is a kernel function -- we chose Gaussian-kernel --, $x_i$ is the $i$-th focal length, and $h$ is a bandwidth same as for the Median-Shift.
\section{Experimental Results}
For the synthesized tests, we used the MATLAB code shown in Alg.~\ref{MatlabAlgorithm}. For the real world tests, we used our C++ implementation\footnote{\url{http://web.eee.sztaki.hu/~dbarath/}} which is a modification of the solver of Hartley et al.~\cite{hartley2012efficient}.
\noindent \vspace{5px}
\noindent \vspace{2px}
\textbf{5.1. Synthesized tests}
For synthesized testing, two perspective cameras are generated by their projection matrices $\mathbf{P}_1$ and $\mathbf{P}_2$. The first camera is at position $[0 \; 0 \; 1]^T$ looking towards the origin, and the distance of the second one from the first is $0.15$ in a random direction. Five random planes passing over the origin are generated and each is sampled in fifty random locations. The obtained 3D points are projected onto the cameras. Zero-mean Gaussian-noise is added to the point coordinates.
The local affine transformations are calculated by derivating the homographies induced by the tangent planes at the noisy point correspondences similarly to~\cite{barathnovel}.
Figure~\ref{fig:root_number} reports the kernel density function with Gaussian-kernel width $10$ plotted as the function of the relative error (in percentage). Candidate focal lengths are estimated as follows:\vspace{3px}
\noindent \hspace{8px} \vspace{0.5px}
\textbf{1.} Select two affine correspondences.
\noindent \hspace{8px} \vspace{0.5px}
\textbf{2.} Apply the proposed 2-point method.
\noindent \hspace{8px}
\textbf{3.} Repeat from Step 1.\vspace{3px}
The iteration limit is chosen to $100$. The blue horizontal line reports the result of Median-Shift, the green one is that of Kernel Voting. The $\sigma$ value of the zero-mean Gaussian-noise added to the point locations and affinities is (a) $0.01$ pixels, (b) $0.1$ pixels, (c) $1.0$ pixels, (d) $3.0$ pixels, (e) $3.0$ pixels and there are $10\%$ outliers, (f) $1.0$ pixels with some errors in the aspect ratio: the true one is $1.00$ but $0.95$ is used. The real focal length is $600$.
Confirming the validity of the proposed theory, the peak is over the ground truth focal length: $0\%$ relative error. The proposed root selection is more robust than the Kernel Voting approach since the blue line is closer to the zero relative error even if the noise is high.
\begin{figure*}[htbp]
\centering
\begin{subfigure}[b]{0.33\textwidth}
\includegraphics[width = 0.999\columnwidth]{assets/filename_1.pdf}
\caption{}
\end{subfigure}
\begin{subfigure}[b]{0.33\textwidth}
\includegraphics[width = 0.999\columnwidth]{assets/filename_2.pdf}
\caption{}
\end{subfigure}
\begin{subfigure}[b]{0.33\textwidth}
\includegraphics[width = 0.999\columnwidth]{assets/filename_3.pdf}
\caption{}
\end{subfigure}\\
\begin{subfigure}[b]{0.33\textwidth}
\includegraphics[width = 0.999\columnwidth]{assets/filename_4.pdf}
\caption{}
\end{subfigure}
\begin{subfigure}[b]{0.33\textwidth}
\includegraphics[width = 0.999\columnwidth]{assets/filename_5.pdf}
\caption{}
\end{subfigure}
\begin{subfigure}[b]{0.33\textwidth}
\includegraphics[width = 0.999\columnwidth]{assets/filename_6.pdf}
\caption{}
\end{subfigure}
\caption{ The kernel density function (vertical axis) with Gaussian-kernel width $10$ plotted as the function of the relative error ($\%$). Five planes are generated and each is sampled in $20$ locations -- points are projected onto the cameras and local affinities are calculated. The blue horizontal line is the result of Median-Shift, the green one is that of the Kernel Voting. The $\sigma$ value of the zero-mean Gaussian-noise added to the point locations and affinities is (a) $0.01$ pixels, (b) $0.1$ pixels, (c) $1.0$ pixels, (d) $3.0$ pixels, (e) $3.0$ pixels and there are $10\%$ outliers, (f) $1.0$ pixels with some errors in the aspect ratio: the true one is $1.00$ but $0.95$ is used. Ground truth focal length is $600$. Best viewed in color.}
\label{fig:root_number}
\end{figure*}
\vspace{5px}
Fig.~\ref{fig:fundamental_error} reports the mean (top) and median (bottom) errors of the estimated fundamental matrices plotted as the function of the noise $\sigma$ and compared with the results of Hartley et al.\cite{hartley2012efficient} and Perdoch et al.\cite{PerdochMC06}. The error is the Frobenious norm of the estimated and ground truth fundamental matrices. $100$ runs were performed on each noise level. It can be seen that the accuracy of the estimated fundamental matrices is similar to that of Hartley et al.~\cite{hartley2012efficient}.
\noindent \vspace{5px}
\begin{figure}[htbp]
\centering
\includegraphics[width = 0.70\columnwidth]{assets/fundamental_matrix_test.pdf}
\includegraphics[width = 0.70\columnwidth]{assets/median_fundamental_error.pdf}
\caption{The mean (top) and median (bottom) Frobenious norms of the estimated and the ground truth fundamental matrices plotted as the function of the noise $\sigma$. 100 runs on each noise level were performed.}
\label{fig:fundamental_error}
\end{figure}
\vspace{5px}
\noindent \vspace{2px}
\textbf{5.2. Tests on Real Images\footnote{Test data are provided as supplemental material.}}
To test the proposed method on real world photos, $104$ image pairs were downloaded\footnote{\url{http://www2c.airnet.ne.jp/kawa/photo/ste-idxe.htm}} each containing the ground truth focal length in the EXIF data (see Fig.~\ref{fig:example_pairs} for examples). Affine correspondences are detected by ASIFT~\cite{Morel2009} and the same procedure is applied as for the synthesized tests. Fig.~\ref{fig:real_focals} reports the histogram of the relative errors (in percentage) in the focal length estimates on all the $104$ pairs. It can be seen that in most of the cases the obtained results are accurate, the relative error is close to zero. Fig.~\ref{fig:real_image} shows the first image of an example pair and the point correspondences.
In Table~\ref{tab:comparison1}, the proposed method is compared with the 6-point algorithm~\cite{hartley2012efficient} and the one creating point correspondences from two local affinities~\cite{PerdochMC06}. The reported relative errors are computed as the ratio of the estimation error and the ground truth focal length as $|f_{est} - f_{gt}|/f_{gt}$. It can be seen that the 2-point technique outperforms the other ones in terms of both mean and median accuracy and spread.
\begin{table}
\caption{ Mean (Avg) and median (Med) relative error (in percentage) and the spread ($\sigma$) of the relative errors in the estimated focal lengths on the $104$ real image pairs. Corr \# denotes the required correspondence number.}
\center
\begin{tabular}{| l || c | c c c |}
\hline
Method & Corr \# & Avg & Med & $\sigma$ \\
\hline
\textbf{Proposed} & 2 & \phantom{x}\textbf{9.62} & \phantom{x}\textbf{3.88} & \textbf{14.08} \\
Perdoch et al.~\cite{PerdochMC06} & 2 & 44.66 & 45.89 & 26.43 \\
Hartley et al.~\cite{hartley2012efficient} & 6 & 21.79 & \phantom{x}8.61 & 27.48 \\
\hline
\end{tabular}
\label{tab:comparison1}
\end{table}
\begin{figure}[htbp]
\centering
\begin{subfigure}[b]{0.50\columnwidth}
\includegraphics[width = 1.0\columnwidth]{assets/real_test_0.pdf}
\caption{}
\label{fig:real_focals}
\end{subfigure}
\begin{subfigure}[b]{0.46\columnwidth}
\includegraphics[width = 1.0\columnwidth]{assets/motion_1.jpg}
\caption{}
\label{fig:real_image}
\end{subfigure}
\caption{ (a) Histogram of focal length estimation on 104 image pairs. The horizontal axis is the number of the pairs plotted as the function of the relative error ($\%$, vertical axis) in the focal length. (b) The first image of an example pair. Point coordinates on the first image (green dots), on the second one (red dots) and the point movements (red lines). }
\end{figure} \vspace{5px}
\noindent \vspace{2px}
\textbf{5.3. Time Demand}
Augmenting RANSAC or other robust statistics with the proposed method significantly reduces the processing time. Table~\ref{tab:ransac_iterations} reports the required iteration number~\cite{Hartley2003} of RANSAC to converge using different minimal methods (columns) as engine. Rows show the ratio of the outliers.
\begin{table}[h!]
\centering
\caption{Required iteration number of RANSAC augmented with minimal methods (columns) with $95\%$ probability on different outlier levels (rows).}
\begin{tabular}{ | c | r r r r r r | }
\hline
& \multicolumn{5}{c}{\# of required points} & \\
Outl. & \textbf{2} & 5\phantom{x} & 6\phantom{x} & 7\phantom{x} & 8\phantom{x} & \\
\hline
50\% & \textbf{11} & $95${\footnotesize\phantom{x}} & $191${\footnotesize\phantom{x}} & $383${\footnotesize\phantom{x}} & $766${\footnotesize\phantom{x}} & \\
80\% & \textbf{74} & $\sim10^3$ & $\sim10^4$ & $\sim10^5$ & $\sim10^6$
& \\
\hline
\end{tabular}
\label{tab:ransac_iterations}
\end{table}
\begin{figure}[htbp]
\centering
\includegraphics[width = 0.49\columnwidth]{assets/motion_27.jpg}
\includegraphics[width = 0.49\columnwidth]{assets/motion_31.jpg}
\includegraphics[width = 0.49\columnwidth]{assets/motion_33.jpg}
\includegraphics[width = 0.49\columnwidth]{assets/motion_34.jpg}
\includegraphics[width = 0.49\columnwidth]{assets/motion_45.jpg}
\includegraphics[width = 0.49\columnwidth]{assets/motion_51.jpg}
\caption{The first images of example pairs. Point coordinates on the first image (green dots), on the second one (red dots) and the point movements (red lines). The ground truth focal lengths, the results of the 6-point~\cite{hartley2012efficient} and the proposed methods are written in gray rectangle.}
\label{fig:example_pairs}
\end{figure}
\vspace{5px}
\section{Conclusion}
A theory and an efficient method is proposed to estimate the unknown focal-length and the fundamental matrix using only two affine correspondences. The 2-point method is validated on both synthesized and real world data. Compared with the state-of-the-art methods, it obtained the most accurate focal lengths with fundamental matrices having similar quality as the recent algorithms. Combining the minimal solver with a robust statistics, e.g.\ RANSAC, allows significant reduction in computation. Particularly, its time demand is around a few milliseconds, thus it is much faster than affine-covariant detectors providing the input.
The proposed algorithm can also be applied in reconstruction or multi-view pipelines, e.g.\ that of Bujnak et al.~\cite{bujnak2010robust}, if at least two images of the same camera with fixed focal length are available.
| {'timestamp': '2017-06-07T02:04:27', 'yymm': '1706', 'arxiv_id': '1706.01649', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01649'} | arxiv |
\section{Introduction}
\begin{wrapfigure}{r}{0.5\textwidth}\vskip -0.18in
\centering
\includegraphics[width=6cm]{lr_qh-eps-converted-to.pdf}
\caption{\label{1D example} Linear regression with contaminated data: true model (black),
linear regression estimate (blue dash) and penalty-tuned estimate (red dash). }
\end{wrapfigure}
When designing machine learning formulations, choice of penalty plays a key role in the accuracy of the inferred model,
and robustness of the learning procedure.
Consider Figure \ref{1D example}, where data from a simple linear regression has been
contaminated with asymmetric outliers.
The data generating mechanism is shown in black. The linear regression model for the data $\{y_i, a_i\}$
is given by
\begin{equation}
\label{eq:LG}
y = \ip{a_i,x} + \epsilon_i,
\end{equation}
with $\epsilon_i$ assumed i.i.d. Gaussian variables. The maximum likelihood formulation is equivalent to the least square problem,
\[\min_x \frac{1}{2}\|Ax - y\|^2.\]
This assumption is violated in Figure \ref{1D example}; the data are corrupted with asymmetric errors, and contain outliers.
The least squares fit, shown in blue dash, fails to detect the true data generating mechanism.
To learn effectively in these cases, we consider a parameterized family of penalties $\rho(x;\theta)$,
where $x$ are model parameters and $\theta$ control the shape of the penalty. The family is rich enough
to allow the kinds of errors in Figure \ref{1D example}, and we learn $x$ and $\theta$ simultaneously
using an extended statistical model.
Two immediate examples of $\theta$ are the {robustness threshold} $\kappa$ in the Huber penalty,
and the slope $\tau$ in the asymmetric quantile penalty, see Figure~\ref{fig:Qhub}.
Selecting the appropriate $\theta$ is important. The quantile Huber case was considered by \cite{ramamurthy2015automatic}.
\begin{wrapfigure}{r}{0.5\textwidth}\vspace{-.1in}
\centering
\begin{tabular}{p{3.6cm}p{3.6cm}}
\centering
\begin{tikzpicture}
\begin{axis}[
thick,
height=2cm,
xmin=-2,xmax=2,ymin=0,ymax=1,
no markers,
samples=50,
axis lines*=left,
axis lines*=middle,
scale only axis,
xtick={-1,1},
xticklabels={$-\kappa$, $\kappa$},
ytick={0},
]
\addplot[red,domain=-2:-1,densely dashed]{-x-.5};
\addplot[blue, domain=-1:+1]{.5*x^2};
\addplot[red,domain=+1:+2,densely dashed]{x-.5};
\addplot[blue,mark=*,only marks] coordinates {(-1,.5) (1,.5)};
\end{axis}
\end{tikzpicture}
& \begin{tikzpicture}
\begin{axis}[
thick,
height=2cm,
xmin=-2,xmax=2,ymin=0,ymax=1,
no markers,
samples=50,
axis lines*=left,
axis lines*=middle,
scale only axis,
xtick={-1,1},
xticklabels={-1,1},
ytick={0},
]
\addplot[red,domain=-2:0,densely dashed]{-.3*x};
\addplot[red,domain=0:+2,densely dashed]{.7*x};
\draw[color=black] (20,30) node {$-\tau$};
\draw[color=black] (330,30) node {$1-\tau$};
\end{axis}
\end{tikzpicture} \\
\centering\footnotesize
(a) Huber ($\kappa$) &\footnotesize (b) quantile ($\tau$).
\end{tabular}
\caption{\label{fig:Qhub} Huber and quantile penalties are parametrized by $\kappa$ and $\tau$.}
\vspace{-.5in}
\end{wrapfigure}
For example, the fit with the correctly set quantile penalty is shown in red dash in Figure \ref{1D example}.
The value of $\tau$ was obtained automatically
from the data using a statistical model detailed in Section \ref{sec:model}, and did not require cross-validation.
The main focus of this paper is data-drive approaches for simultaneously selecting $\theta$ and solving for $x$,
without cross-validation or prior/additional information.
\subsection{Related work}
Meta-parameters are classically estimated using cross-validation or grid search.
These methods typically require multiple solutions of any given learning problem, where a held-out dataset is used
to evaluate each configuration.
More recently, Bayesian optimization \citep{snoek,hutter,bergstra,fastBO} and random search \citep{randSearch,randSA} have
come to the forefront as two leading techniques that can be used to obtain meta-parameters in a very wide range of contexts.
All of these techniques can also be used for the problem class we consider.
However, applying these approaches is always more computationally expensive than solving a single instance of a learning problem; both random search and Bayesian optimization require many instance evaluations. In contrast, for the narrower context of shape parameter estimation, we solve a {\it single} extended problem to simultaneously fit the $x$ and $\theta$.
The most relevant works related to this paper focus on the relation between the quantile penalty and the asymmetric Laplace distribution(ALD)~\citep{yu2001bayesian, Tu2017, bera2016asymmetric}.
\cite{bera2016asymmetric} jointly estimate the model and the shape parameters for quantile penalty,
and~\cite{Tu2017} infer the joint posterior distribution of these parameters.
\subsection{Contributions}
We develop a maximum-likelihood approach to simultaneously learn both the model and shape parameters
for a broad class of penalties, of which the quantile is one example.
The likelihood is obtained by interpreting each penalty as a statistical density, with normalization constant depending on the shape parameters $\theta$.
The modeling innovation is to systematically incorporate the log of the normalization constant into the joint inference problem:
\begin{equation}
\min_{x,\theta\in\mathcal{D}} \rho(x;\theta) + g(x) + l(\theta).
\label{eq:mainFormulation}
\end{equation}
Here, $g(x)$ is any regularization term on $x$, while $l(\theta)$ is the log of the normalization constant
that arises from the statistical model,
and ensures the model remains statistically valid as $\rho$ is adapted.
Our second contribution is algorithmic. We consider first-order schemes, and show how to apply
the PALM~\citep{bolte2014proximal} algorithm to problem~\eqref{eq:mainFormulation}.
The PALM algorithm is limited to penalties $\rho$ that are smooth in $(x,\theta)$,
and so we design a new second-order interior point algorithm
for problems with non-smooth coupling. The approach and algorithms are illustrated using synthetic and real data.
\subsection{Roadmap}
The paper proceeds as follows. In Section~\ref{sec:model} we derive the maximum likelihood model for joint inference in $x$ and $\theta$ and characterize theoretical properties of the resulting objectives from an optimization perspective. In Section~\ref{sec:algo}, we consider first- and second-order algorithms for the structured but generally nonconvex and nonsmooth objective~\eqref{eq:mainFormulation}.
Section~\ref{sec:synthetic} illustrates the convergence rates of the methods, as well as behavior of the shape-tuned estimates, using synthetic data. In Section~\ref{sec:real}, we develop self-tuning RPCA approaches, and apply them to real data.
\section{Statistical Model and Properties of Joint Objective}
\label{sec:model}
Penalties in learning formulations have underlying statistical assumptions.
In this section we first review the relationship between penalties and corresponding residual distributions.
We then use this relationship to develop a {joint} maximum likelihood approach for {model and} shape parameter inference,
and characterize properties of the resulting objective function.
\subsection{Statistical view}
Recall the quantile penalty in Figure~\ref{fig:Qhub}.
If we choose $\tau$ to be close to 1, we penalize the negative errors a lot more than the positive.
Equivalently, we assume that the distribution of the errors $\epsilon_i$ is biased towards positive errors.
The relationship between penalties and associated densities can be made precise. Given a penalty
$\rho(r; \theta)$, we assume $\epsilon_i$ in \eqref{eq:LG} are i.i.d. samples from the distribution with
density
\begin{equation}
\label{eq:penalty-density}
p(r;\theta) = \frac{1}{n_c(\theta)}\exp[-\rho(r;\theta)],\quad \text{where} \quad n_c(\theta) = \int_\mathbb{R} \exp[-\rho(r;\theta)]\,dr.
\end{equation}
The term $n_c(\theta)$ is a normalization constant that ensures that $\rho(r,\theta)$ can be interpreted as a density
as in~\eqref{eq:penalty-density}.
We can now formulate the {\it joint} maximum likelihood problem in $(x,\theta)$, or equivalently minimize its negative log:
\begin{equation}
\label{eq:obj}
\min_{x,\theta\in\mathcal{D}} \sum_{i=1}^m \rho(y_i - \ip{a_i,x};\theta) + g(x) + m\log[n_c(\theta)].
\end{equation}
The parameter $\theta$ may be restricted to a domain $\mathcal{D}$; for example, the slope parameter $\tau$ must be between $0$ and $1$ (see Figure~\ref{fig:Qhub}). The term $g(x)$ is an optional regularization function, e.g. $\lambda \|x\|_1$ or indicator of $x \in \mathcal{C}$ for some set $\mathcal{C}$.
The objective in the quantile example used to obtain the penalty-tuned fit in Figure~\ref{1D example} is given by
\begin{equation}
\label{eq:quantile}
\min_{x, \tau \in [0,1]} q_{\tau} (Ax-b) + m\log\left(\frac{1}{\tau} + \frac{1}{1-\tau}\right),
\end{equation}
with $q_\tau$ the asymmetric 1-norm, and $m$ the length of the residual.
In this special case, $\log(n_c)$ is available in closed form,
is smooth in the interior of its domain, and acts as a barrier function for the interval $[0,1]$
that favors $\tau = 0.5$. It's also a strongly convex function, but has {\it no global quadratic upper bound},
violating a key assumption often required by optimization algorithms.
In the remainder of this section, we characterize theoretical properties
of the objective~\eqref{eq:obj}.
\subsection{Theoretical properties}
Smoothness, convexity, and quadratic upper bounds are at the center of algorithm design,
and understanding these properties guide the choice of algorithms for~\eqref{eq:obj}.
\begin{assumption}
\label{asp:smoothness}
To ensure the validity of the statistical viewpoint, we require $\rho$ to satisfy:
\begin{enumerate}
\item $\rho(r;\theta)\ge0$, for every $\theta\in\mathcal{D}$ and $r\in\mathbb{R}$ ({\bf non-negativity})
\item For any $\theta\in\mathcal{D}$, $n_c(\theta) = \int_\mathbb{R} \exp[-\rho(r;\theta)]\,dr < \infty$ ({\bf integrability})
\item For any $\theta_0\in\mathcal{D}$, $\rho(r;\theta)$ is $C^2$ around $\theta_0$ for almost every $r\in\mathbb{R}$ ({\bf smoothness in $\theta$})
\end{enumerate}
\end{assumption}
Under these assumptions, we can obtain formulas for the first and second derivatives of $n_c(\theta)$.
\begin{theorem}[smoothness of $n_c(\theta)$]
\label{th:smoothness}
For $n_c(\theta)$in~\eqref{eq:penalty-density}, suppose Assumption \ref{asp:smoothness} holds
and for $\theta_0\in\mathcal{D}$, there exist functions $g_k(r)$, $k=1,2$, such that,
\begin{enumerate}
\item for any unit vector $v$, $|\ip{\nabla_\theta\exp[-\rho(r;\theta)],v}|\le g_1(r)$ for any $\theta$ around $\theta_0$,
\item for any unit vector $v$, $\left|\ip{\nabla_\theta^2\exp[-\rho(r;\theta)]v,v}\right|\le g_2(r)$ for any $\theta$ around $\theta_0$,
\item $\int_\mathbb{R} g_k(r)\,dr < \infty$, $k=1,2$.
\end{enumerate}
then $n_c(\theta)$ is $C^2$ continuous around $\theta_0$ and,
\begin{equation}
\label{eq:nc_form}
\nabla n_c(\theta_0) = \int_\mathbb{R} \nabla_\theta\exp[-\rho(r;\theta_0)]\,dr,\quad\nabla^2 n_c(\theta_0) = \int_\mathbb{R}\nabla_\theta^2\exp[-\rho(r;\theta_0)]\,dr.
\end{equation}
\end{theorem}
The proof is straightforward, and included in the supplementary materials. The derivative formulas~\eqref{eq:nc_form} are used for first- and second-order methods to infer $x$ and $\theta$. The parametrization conditions in $\theta$ are satisfied by all commonly used piecewise linear quadratic (PLQ) examples~\citep{JMLR:v14:aravkin13a}, including Huber and quantile penalties in Figure~\ref{fig:Qhub}.
The theorem applies more generally to densities that are not log-concave. For example, the Student's $t$ density
and associated penalty satisfy Assumption~\ref{asp:smoothness} and other
assumptions of Theorem~\ref{th:smoothness} for $\nu > 1$.
In the quantile case~\eqref{eq:quantile}, the term $\log[n_c(\theta)]$ is convex. We characterize sufficient conditions
for convexity of $\log[n_c(\theta)]$ for a general class of penalties $\rho$.
\begin{theorem}[convexity of $\log\lbrack n_c(\theta)\rbrack$]
\label{th:convexity}
Consider same definition of $n_c(\theta)$ in Theorem \ref{th:smoothness}, and suppose Assumption \ref{asp:smoothness} holds. We have the following results:
\begin{enumerate}
\item If $\rho(r;\theta)$ is jointly convex in $r$ and $\theta$, then $\log[n_c(\theta)]$ is a concave function of $\theta$.
\item If $\rho(r;\theta)$ is concave with respect to $\theta$ for every $r$, then $\log[n_c(\theta)]$ is a convex function.
\end{enumerate}
\end{theorem}
This result follows from \cite[Chapter 3.5]{boyd2004convex}.
Theorems~\ref{th:smoothness} and~\ref{th:convexity} tell an interesting story. The log-normalization constant
$\log[n_c(\theta)]$ is nearly always smooth; even when the loss $\rho$ is nonsmooth in $x$.
The inference problem~\eqref{eq:obj} is {\it never jointly convex} in $(x,\theta)$; in particular looking for a jointly
convex formulation $\rho(x;\theta)$ guarantees $\log[n_c(\theta)]$ will be {\it concave}. This is intuitive, as
we are attempting to learn both the model and error structure at the same time. Objective~\eqref{eq:obj} is,
in general, nonsmooth and nonconvex; but it has a fairly simple structure that is exploited to design
first and second order methods in the next section.
{
To understand how non-convex \eqref{eq:obj} is, we apply partial minimization, and consider the function
\[
\varrho(\theta) = \min_{x} \sum_{i=1}^m \rho(y_i - \ip{a_i,x};\theta) + m\log[n_c(\theta)].
\]
This is the {\it value function} of the shape parameters, after $x$ has been minimized.
For simple examples, $\theta$ may have dimension 1 or 2, we can plot either the graph or the level sets of this function.
We generate the samples $\epsilon_i$ from distribution defined by quantile Huber function with $\kappa = 1$ and $\tau = 0.05$,
and plot $\varrho(\theta)$ in Figure \ref{fig:levelset}.}
\begin{figure}[h]
\centering
\begin{tabular}{cc}
\includegraphics[width=7cm]{qlevelset-eps-converted-to.pdf}&
\includegraphics[width=7cm]{qHlevelset-eps-converted-to.pdf}\\
(a) Graph of quantile value function $\varrho(\tau)$ &
(b) level sets of the QH value function $\varrho(\tau, \kappa)$.
\end{tabular}
\caption{\label{fig:levelset} Left panel: graph of value function $\varrho(\tau)$. Right panel: level sets of quantile huber (QH) value function $\varrho(\tau, \kappa)$. Blue dots show optimal parameter estimates, while red dots show true parameters.}
\end{figure}
From Figure \ref{fig:levelset} (a), we can see that for the quantile penalty, the value function $\varrho$ appears to be quasi-convex for this example; and we can expect
to find the unique global minimum in $x$ and $\tau$, since computing the projection require solving a convex problem. When $\theta$ comprises both $\tau$ and $\kappa$ in (b), the joint objective is clearly noncovex and may be more challenging for a local search (the level sets are stretched and bent).
Nonetheless, there is a unique global minimum that is close to the true parameters; and this minimum was found by
a local search.
\section{First- and Second-Order Algorithms.}
\label{sec:algo}
In this section, we consider first- and second-order methods for problems of type~\eqref{eq:obj}.
When $\rho$ is smooth in $x$ and $\theta$, we show how to apply the
Proximal Alternating Linearized Minimization (PALM) algorithm \citep{bolte2014proximal}.
The development is straightforward, but the log normalization constant $\log[n_c(\theta)]$
must be treated carefully, as its gradient does not have a global Lipschitz constant.
Requiring smoothness in $\rho$ is restrictive; and in particular eliminates the quantile example~\eqref{eq:quantile}.
The quantile penalty is not smooth, but it is piecewise linear. Interior point methods have been shown to be effective for convex problems of moderate scale (thousands of variables and data points)
where $\rho$ and $g$ are nonsmooth piecewise linear-quadratic penalties~\citep{JMLR:v14:aravkin13a}.
Examples include symmetric penalties (1-norm, quadratic) as well as asymmetric penalties, such as quantile and quantile Huber~\citep{aravkin2014orthogonal}. All of these penalties are shown in detail in the supplementary materials.
Our main algorithmic contribution is to extend this approach to the joint nonconvex inference problem~\eqref{eq:obj}.
\subsection{PALM for inference and shape estimation}
\label{sec:PALM}
The PALM algorithm \citep{bolte2014proximal} can be used to minimize any problem of form
\[
\min_{x,\theta} H(x,\theta) + r_1(x) + r_2(\theta),
\]
where $H$ is $C^1$, with globally Lipschitz partial gradients, while the functions $r_1$ and $r_2$ are required to be only proper lower semicontinuous (in particular not necessarily convex, finite valued, or smooth). Even though
$\log[n_c(\theta)]$ is smooth (see Theorem~\ref{th:smoothness}), it must be relegated to $r_2(\theta)$,
since otherwise it can easily violate the Lipschitz assumptions on $H$. Therefore, to apply PALM to~\eqref{eq:obj},
we take
\begin{equation}
\label{eq:palm_detail}
H(x,\theta) = \sum_{i=1}^m \rho(y_i - \ip{a_i,x};\theta), \quad r_1(x) = g(x), \quad r_2(\theta) = \delta_\mathcal{D}(\theta) + m\log[n_c(\theta)].
\end{equation}
Here $\delta_{\mathcal{D}}$ is the indicator function for the set $\mathcal{D}$, ensuring $\theta \in \mathcal{D}$,
and $g$ is any `prox-friendly' regularizer for $x$. The PALM algorithm is detailed in Algorithm~\ref{alg:PALM}.
The steps $c_k$ and $d_k$ are obtained from
Lipschitz constants of the (partial) gradients of $H$.
\begin{algorithm}
\caption{PALM for~\eqref{eq:palm_detail}}\label{alg:PALM}
\begin{algorithmic}[1]
\Require{$A$, $y$}
\State \textbf{Initialize}: $x^0$, $\theta^0$
\While{not converge}
\Let{$x^{k+1}$}{$\text{prox}_{\frac{1}{c_k}r_1}\left(x^k - \frac{1}{c_k}\nabla_x H(x^k,\theta^k)\right)$}
\Let{$\theta^{k+1}$}{$\text{prox}_{\frac{1}{d_k}r_2}\left(\theta^k - \frac{1}{d_k}\nabla_\theta H(x^{k+1},\theta^k)\right)$}
\EndWhile
\Ensure{$x^k$ and $\theta^k$}
\end{algorithmic}
\end{algorithm}
\vspace{-.2cm}
{\bf Detail:} The prox operator of $\log[n_c(\theta)]$ is not available in closed form for any examples of interest. However, the prox operator can be efficiently computed using the results of Theorem~\ref{th:smoothness}:
\begin{equation}
\label{eq:prox_compute}
\text{prox}_{\frac{1}{d_k}r_2}(\phi) = \arg\min_{\theta\in \mathcal{D}} \frac{1}{2d_k}\|\theta - \phi\|^2 + \log[n_c(\theta)].
\end{equation}
In all examples of interest, $\theta$ is low dimensional; so we compute~\eqref{eq:prox_compute} using Newton's method
or an interior point method (when $\mathcal{D}$ must be accounted for).
This requires $\nabla \log[n_c(\theta)]$ and $\nabla^2 \log[n_c(\theta)]$, which are calculated
numerically using formulas~\eqref{eq:nc_form}.
The PALM algorithm is well suited to large-scale shape inference problems with smooth coupling of $x$ and $\theta$
in $\rho$. We use it for the self-tuning RPCA experiments in Section~\ref{sec:real}.
\subsection{Interior point method for self-tuning piecewise linear-quadratic penalties}
\label{sec:IP}
\begin{wrapfigure}{r}{0.4\textwidth
\centering
\begin{tabular}{p{3.6cm}}
\centering
\begin{tikzpicture}
\begin{axis}[
thick,
height=2cm,
xmin=-1.5,xmax=1.5,ymin=0,ymax=4,
no markers,
samples=100,
axis lines*=left,
axis lines*=middle,
scale only axis,
xtick={-0.45,1.05},
xticklabels={\small$-\tau\kappa$,\small$(1-\tau)\kappa$},
ytick={0},
]
\addplot[red,domain=-1.5:-3*0.3*0.5,densely dashed]{3*0.3*abs(x)*2 - 0.5*3^2*0.3^2};
\addplot[blue,domain=-3*0.3*0.5:3*0.7*0.5]{2*x^2};
\addplot[red,domain=3*0.7*0.5:1.5,densely dashed]{3*0.7*abs(x)*2 - 0.5*0.7^2*3^2};
\addplot[blue,mark=*,only marks] coordinates {(-0.45,0.405) (1.05,2.205)};
\end{axis}
\end{tikzpicture}\\
\centering\footnotesize
\footnotesize quantile Huber ($\tau$, $\kappa$).
\end{tabular}
\caption{\label{fig:QuantileQHub}
Quantile Huber $(\tau, \kappa)$ penalty has conjugate representation
$\displaystyle\sup_{u \in [-\kappa\tau, \kappa(1-\tau)]} ux -\frac{1}{2}u^2$.}
\vspace{-.15in}
\end{wrapfigure}
The restriction that $\rho$ must be smooth in $(x,\theta)$ is unsatisfying, given that one of the simplest
examples of self-tuning penalties comes from the nonsmooth quantile loss. Here, we develop
an interior point method for the quantile problem~\eqref{eq:quantile}, as well as any other analogous
problems for shape parameter estimation with PLQ penalties. The class includes many familiar losses
(Huber, quantile, quantile Huber, $\ell_2$ and $\ell_1$).
While many of these are nonsmooth, they all have smooth conjugate representations.
\cite{JMLR:v14:aravkin13a} used these representations to solve convex PLQ problems,
including Lasso, support vector machine, and Huber regression.
We extend the approach to solve nonconvex extended problems of form
\(
\min_{x,\theta \in \mathcal{D}} \rho(x;\theta) + \log[n_c(\theta)].
\)
The approach is limited to moderate problem dimensions\footnote{If
$A$ has dimensions $m$ and $n$, interior point methods require $O(n(m^2+n^2))$ arithmetic operations,
where $n$ is the smaller dimension. This limits practical applications for large-scale problems; to go beyond $2000 \times 2000$ with modest compute, some sort of special structure or technique (sparsity, preconditioning) is typically needed.}, but converges at a superlinear rate, and solves problems with nonsmooth coupling in $(x,\theta)$. We first review conjugate representations of PLQ penalties.
The quantile Huber penalty (Figure~\ref{fig:QuantileQHub}) is the convex conjugate of the function
$\frac{1}{2}\|u\|^2 + \delta_{[-\kappa \tau, \kappa(1-\tau)]}(u)$, {For more examples, see the Appendix}.
PLQ functions are closed under sums and affine compositions, and the generic PLQ object has can be expressed
as the conjugate of $\frac{1}{2}u^TMu + \delta_{U}(u)$, evaluated at some input $Br-\bar b$~\cite{JMLR:v14:aravkin13a}:
\begin{equation}
\label{eq:PLQdual}
\rho(r, \theta;B,\bar{b},C,\bar{c},M) = \sup_{u} \left\{u^{\mathsf{T}}(Br-\bar{b}) - \frac{1}{2} u^{\mathsf{T}} Mu \mid C^{\mathsf{T}} u\le \bar{c}
\right\}
\end{equation}
where $M\succeq0$, and $U:=\{u \mid C^{\mathsf{T}} u\le \bar{c}\}$ is a polyhedral set with $0 \in U$.
To incorporate shape penalty estimation, we allow $\bar b$ and $\bar c$ to be affine
functions of $\theta$, and assume $\mathcal{D}$ is also polyhedral:
\[
\bar{b} = G^{\mathsf{T}}\theta + b,\quad\bar{c} = H^{\mathsf{T}}\theta + c,
\quad
\mathcal{D} = \{\theta\mid S^{\mathsf{T}}\theta\le s\}.
\]
Our goal now is to now solve a {\it saddle point} system that includes primal variables $x$, conjugate
variables $u$, and shape parameters $\theta$:
\begin{equation}
\label{eq:PLQprimaldual}
\min_{x,S^{\mathsf{T}}\theta\le s}\sup_{C^{\mathsf{T}} u \le H^{\mathsf{T}}\theta + c}\left\{u^{\mathsf{T}}[B(Ax-y)-G^{\mathsf{T}}\theta - b]-\frac{1}{2}u^{\mathsf{T}} M u\right\} + m\log[n_c(\theta)]
\end{equation}
For example, the self-tuning quantile penalty~\eqref{eq:quantile} (with $\theta =\tau$) gives
\[
\min_{x, \scriptsize\begin{bmatrix} 1 \\ -1 \end{bmatrix}\tau \leq \begin{bmatrix}1 \\ 0 \end{bmatrix}}
\quad \sup_{\scriptsize \begin{bmatrix}1 \\ -1 \end{bmatrix} u \leq -\begin{bmatrix}1 \\ 1\end{bmatrix}
\tau +\begin{bmatrix}
1 \\ 0\end{bmatrix}}
u^{\mathsf{T}}(Ax-b) + m\log\left(\frac{1}{\tau} + \frac{1}{1-\tau}\right).
\]
Interior point (IP) methods apply damped Newton to a relaxation of the optimality conditions~\eqref{eq:PLQprimaldual}, see~\citep{KMNY91,NN94,Wright:1997}.
{
The relaxation can be derived by approximating indicator functions of the constraints using a log-barrier function with parameter $\mu$:
\[\delta_{\{(u,\theta)\mid C^{\mathsf{T}} u \le H^{\mathsf{T}}\theta + c\}}(u,\theta) \approx -\mu\mathbf{1}^{\mathsf{T}}\log(c + H^{\mathsf{T}}\theta-C^{\mathsf{T}} u).\]
Note that as $\mu \downarrow 0$, the barriers approach true indicator functions for $U$. The barrier parameter $\mu$ is aggressively decreased to a specified optimality criterion as the optimization proceeds.
For fixed $\mu$, there is an associated approximate objective for~\eqref{eq:PLQprimaldual}, given by
\begin{equation}
\begin{aligned}
\label{eq:PLQprimaldualapp}
\min_{x,S^{\mathsf{T}}\theta\le s}\sup_{u}\left\{u^{\mathsf{T}}[B(Ax-y)-G^{\mathsf{T}}\theta - b]-\frac{1}{2}u^{\mathsf{T}} M u + \mu\mathbf{1}^{\mathsf{T}}\log(c + H^{\mathsf{T}}\theta-C^{\mathsf{T}} u)\right\}\\
+ m\log[n_c(\theta)]-\mu\mathbf{1}^{\mathsf{T}}\log(s-S^{\mathsf{T}}\theta)
\end{aligned}
\end{equation}}
And we apply the Lagrangian dual formulation for this objective,
\begin{equation}
\begin{aligned}
\mathcal{L}_\mu(d_1,q_1,x,u,\theta) = u^{\mathsf{T}}[B(Ax-y)-G^{\mathsf{T}}\theta - b]-\frac{1}{2}u^{\mathsf{T}} M u + \mu\mathbf{1}^{\mathsf{T}}\log(c + H^{\mathsf{T}}\theta-C^{\mathsf{T}} u)\\
+ m\log[n_c(\theta)]-\mu\mathbf{1}^{\mathsf{T}}\log(s-S^{\mathsf{T}}\theta) + q_1^{\mathsf{T}}(d_1+S^{\mathsf{T}}\theta-s)
\end{aligned}
\end{equation}
where $q_1$ is the dual variable and $d_1$ is the slack variable. By introducing another pair of dual-slack variable $q_2$ and $d_2$ for log-barrier function,
\[d_2 = c - C^{\mathsf{T}} u + H^{\mathsf{T}}\theta,\quad q_2 = \mu D_2^{-1}\mathbf{1}\]
{
\noindent where all the capital letters represent diagonal matrices with corresponding little letters vector as the diagonal. We could form the KKT system of \eqref{eq:PLQprimaldualapp},
\begin{equation}
\label{eq:KKT}
F_\mu(z) = \mat{
D_1q_1 - \mu\mathbf{1}\\
d_1+S^{\mathsf{T}}\theta-s\\
D_2q_2 - \mu\mathbf{1}\\
B(Ax-y) - G^{\mathsf{T}}\theta - b -Mu -Cq_2\\
A^{\mathsf{T}} B^{\mathsf{T}} u\\
-Gu + m\nabla\log[n_c(\theta)] + Sq_1 + Hq_2.
}
\end{equation}
The Jacobian matrix $\nabla F_\mu$ of the system is given by
\begin{equation}
\label{eq:KKTJacobian}
\def1.5{1.5}
\nabla F_\mu(z) = \left[\begin{array}{c|c|c|c|c|c}
Q_1& D_1 & & & & \\\hline
I & & & & & S^{\mathsf{T}}\\\hline
& & D_2 & -Q_2C^{\mathsf{T}}& & Q_2H^{\mathsf{T}}\\\hline
& & -C & -M & BA & -G^{\mathsf{T}}\\\hline
& & & A^{\mathsf{T}} B^{\mathsf{T}} & &\\\hline
& S & H & -G & &\nabla^2\log[n_c(\theta)]
\end{array}\right]
\end{equation}
Where $z = [d_1,q_1,q_2,u,x,\theta]^{\mathsf{T}}$. Notice that when $\mu\downarrow0$, \eqref{eq:KKT} will approach to the optimality condition of \eqref{eq:PLQprimaldual}, Algorithm \ref{alg:IPsolve} shows the IP method.}
\begin{algorithm}[h!]
\caption{Interior point method for PLQ with $\theta$ estimation}\label{alg:IPsolve}
\begin{algorithmic}[1]
\Require{$A$, $y$, $B$, $b$, $C$, $c$, $G$, $H$, $S$, $s$}
\State \textbf{Initialize}: $z^0$, $\mu = 1$
\While{not converged}
\Let{$p$}{$\nabla F_\mu(z^k)^{-1}F_\mu(z^k)$}
\Let{$\alpha$}{$\text{LineSearch}(z^k,p)$, using merit function $\|F_\mu(\cdot)\|$}
\Let{$z^{k+1}$}{$z^k - \alpha p$}
\Let{$\mu$}{$0.1\cdot$ (Average complementarity conditions)}
\EndWhile
\Ensure{$z^{k+1}$}
\end{algorithmic}
\end{algorithm}
Implementability of Algorithm \ref{alg:IPsolve} is analyzed in Theorem~\ref{th:Implementability}.
\begin{theorem}[Implementability]
\label{th:Implementability}
Let $T_2 = Q_2^{-1}D_2$. Suppose the following conditions are satisfied:
\begin{itemize}
\item $\text{null}(M)\cap\text{null}(C^{\mathsf{T}}) = \{0\}$
\item $\text{null}(BA) = \{0\}$
\item $\text{null}(\nabla^2\log[n_c(\theta)])\cap\text{null}(S^{\mathsf{T}})\cap\text{null}(H^{\mathsf{T}})\cap\text{null}(-G^{\mathsf{T}}+CT_2^{-1}H^{\mathsf{T}}) = \{0\}$
\end{itemize}
for every $\theta\in\mathcal{D}$. Then Algorithm \ref{alg:IPsolve} is implementable; in particular $p$ in step 3 can always be found.
Moreover, we could replace the third condition by a stronger assumption that is if $\log[n_c(\theta)]$ is strongly concave.
\end{theorem}
The proof appears in the appendix.
\section{Synthetic Data Experiments}
\label{sec:synthetic}
We illustrate the proposed approach using a {linear} regression example. We consider a data set contaminated by asymmetric errors and outliers, two features captured by the quantile Huber penalty (Figure~\ref{fig:QuantileQHub}).
The slope $\tau$ controls for the asymmetry, while the threshold $\kappa$ detects the point beyond which a residual might
be classified as an `outlier'. The goal of the experiment is to simultaneously learn the regression model parameters $x$ as well as obtain the correct $\tau$ and $\kappa$. Simple residual analysis is not possible {\it a priori}, since the model parameters $x$ are also unknown.
{When $\kappa > 0$ in quantile Huber, $\rho(x;\theta)$ is smooth, and we can use the PALM algorithm from Section~\ref{sec:PALM}.
The quantile penalty is also PLQ, so we can also apply the proposed IP method from Section~\ref{sec:IP}.
We use both and compare their performance.}
The primal form for the quantile Huber {penalty is}
\begin{equation}
\label{eq:quantileHuberPrimal}
\small
\rho(r;\theta) = \begin{cases}
-\tau\kappa r - \frac{(\tau\kappa)^2}{2},& r < -\tau\kappa\\
\frac{1}{2}r^2,& r\in[-\tau\kappa,(1-\tau)\kappa]\\
(1-\tau)\kappa r - \frac{((1-\tau)\kappa)^2}{2},& r > (1-\tau)\kappa.
\end{cases}
\end{equation}
We must choose a parametrization in terms of $\theta$. One option would be to take $\theta = [\tau,\kappa]^{\mathsf{T}}$.
But this parametrization would violate assumptions of both the first- and second-order approaches in Section~\ref{sec:algo}.
Indeed, $\nabla_\theta \rho(r;\theta)$ would not have a global Lipschitz constant, so we could not use PALM.
Similarly, we could not write the conjugate representation~\eqref{eq:PLQprimaldual} using affine functions of $\theta$.
Looking carefully at either~\eqref{eq:quantileHuberPrimal} or~\eqref{eq:PLQprimaldual}, we instead choose
$\theta_1 = \tau\kappa, \theta_2 = \tau(1-\kappa)$. The only requirement on these parameters is that they are each non-negative.
The primal objective can be written as
\[
\min_{x,\theta\geq 0} \rho(Ax-y;\theta) + m\log[n_c(\theta)].
\]
where $A\in\mathbb{R}^{m\times n}$ {is the design matrix}, $x\in\mathbb{R}^n$ is {the model parameter vector}, and $y\in\mathbb{R}^m$ is the observed data vector contaminated by outliers. From Theorem \ref{th:smoothness}, $n_c(\theta)$ is $\mathcal{C}^2$ smooth.
From Theorem \ref{th:convexity}, {the objective in $\theta$ is the sum of a concave term $\rho(Ax-y;\theta)$
and a convex term $m\log(n_c(x))$. The joint problem in $(x,\theta)$ is nonconvex.}
Nonetheless, both first- and second-order methods from Section \ref{sec:algo} can be applied to solve the problem.
We generate synthetic data with $m = 1000$, $n = 50$, and {generate the elements of $A\in \mathbb{R}^{m\times n}$
from a standard Gaussian random distribution.} The measurement errors are sampled from quantile Huber distributions, to {verify} that the approach is able to recover `ground truth' values for $(\tau, \kappa)$ parameters.
We denote ground truth parameters as $x_t$, $\tau_t$, $\kappa_t$,
while $x^*$, $\tau^*$, $\kappa^*$ are the solutions obtained by solving~\eqref{eq:obj}.
We provide two reference solutions: $x_{LS}$ is the least square solution, and $x_M$ is
the solution obtained by solving $\|Ax-b\|_1$.
For each $\kappa$ and $\tau$ setting, we run the simulation 10 times, and show the average of the results in Table \ref{tb:exp}. Results shown are obtained by the IP method.
\begin{table}[H]
\begin{center}
\setlength{\tabcolsep}{10pt}
\begin{tabular}{c|c|c|c|c}
\hline
$[\tau_t,\kappa_t]$ & $[\tau^*,\kappa^*]$ & $\|x^*-x_t\|/\|x_t\|$ & $\|x_{LS}-x_t\|/\|x_t\|$ & $\|x_M-x_t\|/\|x_t\|$ \\ \hline
[0.1,1.0] & [0.090,1.165] & 0.142 & 0.412 &0.255\\ \hline
[0.2,1.0] & [0.196,1.067] & 0.101 & 0.155& 0.125\\ \hline
[0.5,1.0] & [0.501,0.948] & 0.077 & 0.122& 0.085\\ \hline
[0.8,1.0] & [0.807,1.041] & 0.092 & 0.189& 0.113\\ \hline
[0.9,1.0] & [0.912,1.173] & 0.119 & 0.379& 0.359\\
\hline
\end{tabular}
\caption{\label{tb:exp} Joint inference of the shape and model parameters for the quantile Huber loss.
}
\end{center}
\end{table}
\begin{figure}[h]
\centering
\includegraphics[width=4.5cm]{conHis_both01-eps-converted-to.pdf}
\includegraphics[width=4.5cm]{conHis_both05-eps-converted-to.pdf}
\includegraphics[width=4.5cm]{conHis_both09-eps-converted-to.pdf}
\caption{Convergence history (iterations) for PALM (green) and interior point method (blue). Three
experiments are shown, for $\tau = 0.1, 0.5$, and $0.9$. The proposed IP method converges in fewer than 20 iterations in all cases.
}
\label{conhis}
\end{figure}
The maximum likelihood formulation correctly recovers the shape parameters $(\theta, \tau)$ in the context of
solving a regression problem. Moreover, the solution $x^*$ obtained from the self-tuned regression is always better
compared to reference solutions; and the improvement increases as measurement errors become more biased ($\tau$ close
to $0$ or to $1$).
We also compared the performance of PALM and IP, in terms of iterations.
The result (for three selections of $\tau$ and $\kappa$ values) is shown in Figure \ref{conhis}.
The IP method takes very few iterations to converge. However, the cost of each IP iteration grows cubically in the minimum of $(n,m)$, and only quadratically for each PALM iteration. In case of nonsmooth $\rho$, PALM cannot be applied.
{
Here, we replicate the experiment for the quantile penalty alone, to show that the IP approach indeed handles fully nonsmooth problems.
We choose $m=500$, $n=50$, same way generate $A\in\mathbb{R}^{m\times n}$ and $x_t\in\mathbb{R}^n$ with Section 4. And then we generate independent samples from distribution defined by quantile function. The result is shown in the Table~\ref{tb:exp2}.
\begin{table}[h]
\label{table:quantile}
\begin{center}
\begin{tabular}{c|c|c|c|c}
\hline
$\tau_t$ & $\tau^*$ & $\|x^*-x_t\|/\|x_t\|$ & $\|x_{LS}-x_t\|/\|x_t\|$ & $\|x_{l_1}-x_t\|/\|x_t\|$ \\ \hline
0.1 & 0.096 & 0.253 & 0.749 &0.439\\ \hline
0.2 & 0.216 & 0.139 & 0.191& 0.160\\ \hline
0.5 & 0.491 & 0.134 & 0.134& 0.134\\ \hline
0.8 & 0.794 & 0.136 & 0.341& 0.208\\ \hline
0.9 & 0.903 & 0.242 & 0.542& 0.475\\
\hline
\end{tabular}
\caption{\label{tb:exp2} Joint inference of the shape and model parameters for the quantile penalty.}
\end{center}
\end{table}}
Conclusions similar to self-tuning quantile Huber can be drawn here. We recover $\tau$ accurately and when $\tau$ is close to 0 and 1, our solution is much better than least squares and $\ell_1$ norm solutions.
\section{Self-Tuning RPCA}
\label{sec:real}
Robust principal component analysis (RPCA)
has applications to alignment of occluded images \citep{peng2012rasl}, scene triangulation \citep{zhang2012tilt}, model selection \citep{chandrasekaran2009sparse}, face recognition \citep{turk1991face} and document indexing \citep{candes2011robust}.
We develop a self-tuning background separation approach.
Given a sequence of images\footnote{Publicly available at \url{http://vis-www.cs.umass.edu/~narayana/castanza/I2Rdataset/}},
our goal is to separate the moving objects from the background.
We pick $202$ images from the data set, convert them to grey scale and reshape them as column vectors of matrix $Y\in\mathbb{R}^{20480\times202}$.
We model the data $Y$ as the sum of low rank component $L$ of $Y$ and sparse noise $S$; we expect moving objects to be captured by $S$.
The stable version of RPCA is equivalent to regularized Huber regression:
\begin{equation}
\label{eq:RPCAhuber}
\min_{L,S} \frac{1}{2}\|L+S-Y\|_F^2 + \kappa\|S\|_1 + \lambda\|L\|_* = \min_{L} \rho_{\kappa}(Y-L) + \lambda \|L\|_*.
\end{equation}
The equality is obtained by partially minimizing in $S$. We can simplify~\eqref{eq:mainFormulation} further by
modeling $L = U^{\mathsf{T}} V$, where $U$ and $V$ are matrices with $k \ll \min(m,n)$ columns.
The resulting objective is given by
\[\min_{U,V}\sum_{i,j}\rho(\ip{U_i,V_j} - Y_{i,j};\kappa)\]
where $U\in\mathbb{R}^{k\times m}$ and $V\in\mathbb{R}^{k\times n}$ and $U_i$, $V_j$ are the column vectors. In this experiment we choose $k=2$.
Shape parameter $\kappa$ play a key role for the performance of the formulation: a bad choice of $\kappa$ translates into poor separation, see Figure~\ref{RPCA} (a). Cross-validation is computationally expensive for RPCA,
so we can instead automatically tune $\kappa$ as we fit $U$ and $V$.
\begin{wrapfigure}{r}{0.3\textwidth}\vspace{-.3in}
\centering
\begin{tikzpicture}
\begin{axis}[
thick,
height=2cm,
width = 3cm,
xmin=-0.7,xmax=0.7,ymin=0,ymax=5,
no markers,
samples=50,
axis lines*=left,
axis lines*=middle,
scale only axis,
xtick={-0.3,0.3},
xticklabels={$-\kappa\sigma$, $\kappa\sigma$},
ytick={0},
]
\addplot[blue,domain=-0.7:-0.3, very thick]{-6*x+0.5};
\addplot[blue, domain=-0.3:+0.3, very thick]{ln(1+x^2/0.01)};
\addplot[red, domain=-0.7:+0.7, dashed]{ln(1+x^2/0.01)};
\addplot[black, domain=-0.7:-0.05, densely dashed]{-10*x-.25};
\addplot[black, domain=-0.05:+0.05, densely dashed]{x^2/0.01};
\addplot[black, domain= .05:0.7, densely dashed]{10*x-.25};
\addplot[blue,domain=+0.3:+0.7, very thick]{6*x + 0.5};
\addplot[blue,mark=*,only marks] coordinates {(-0.3,2.3) (0.3,2.3)};
\end{axis}
\end{tikzpicture}
\caption{\label{fig:Tiber} Huberized Student's $t$ (thick blue) interpolates between Student's $t$ (red dash) and
Huber (black dash).}
\vspace{-0.1in}
\end{wrapfigure}
In order to get the result in Figure~\ref{RPCA} (b), we introduce a variance parameter $\sigma$ {for the Huber penalty} to automatically estimate the right scale of the residual. The joint $(\kappa, \sigma)$ parametrization is given by
\[
\rho(r;[\kappa,\sigma]) = \begin{cases}
\kappa|r|/\sigma - \kappa^2/2, & |r|>\kappa\sigma\\
r^2/(2\sigma^2), & |r|\le\kappa\sigma,
\end{cases}
\]
with the resulting self-tuning RPCA formulation (solved by Algorithm~\ref{alg:PALM}):
\[
\min_{U,V,\kappa>0,\sigma>0} \sum_{i,j}\rho(\ip{U_i,V_j} - Y_{i,j};[\kappa,\sigma]) + mn\log[n_c([\kappa,\sigma])].
\]
The result is shown in Figure~\ref{RPCA}(b). As the optimization proceeds,
$\kappa, \sigma \rightarrow0^+$ with a fixed ratio $\alpha = \kappa/\sigma$.
The self-tuning Huber becomes the scaled 1-norm,
recovering the original RPCA formulation~\citep{candes2011robust}. The result in Figure~\ref{RPCA}(b) is an improvement
over the result with $(\kappa, \sigma)$ fixed at the initial values in Figure~\ref{RPCA}(a).
\begin{figure}[h]
\centering
\begin{tabular}{c c}
{
\includegraphics[width=5.5cm]{bLS202-eps-converted-to.pdf}
}
& {
\includegraphics[width=5.5cm]{kLS202-eps-converted-to.pdf}
}\\
(a) Huber with fixed
&(b) Self-tuned Huber\\
$\kappa=2\times10^{-3},\sigma=1$.
& initial: $\kappa=2\times10^{-3}$, $\sigma=1$\\
& final: $\kappa = 1.94\times10^{-2},\sigma=8.28\times10^{-4}$\\
{
\includegraphics[width=5.5cm]{btLS202-eps-converted-to.pdf}
}
&{
\includegraphics[width=5.5cm]{tLS202-eps-converted-to.pdf}
}\\
(c) Huberized Student's $t$ with fixed
&(d) Self-tuned Huberized Student's $t$\\
$\kappa = 8,\sigma=0.1$
& initial: $\kappa = 8,\sigma=0.1$\\
& final: $\kappa = 7.64,\sigma=2.24\times10^{-2}$
\end{tabular}
\caption{\label{RPCA} RPCA background separation: self-tuning automatically discovers shape parameters to produce desired result. Recovered backgrounds and foregrounds are in the top and bottom rows. }
\end{figure}
The weakness of the Huber is that the $\kappa$ has to work well for residuals near the origin as well as in the tail.
The self-tuning approach makes it easy to {create} and adapt new penalties.
To get additional flexibility, we introduce an inflection point; letting the `slope' near the origin
be different from slopes in the tails. The Huberized Student's t penalty is shown in Figure~\ref{fig:Tiber},
and detailed below:
\begin{equation}
\label{eq:tiber}
\hspace{-.4cm}
\rho(r;[\kappa,\sigma]) = \begin{cases}
\frac{2\kappa}{\sigma(\kappa^2+1)}(|r| - \kappa\sigma) + \log(1+\kappa^2), & |r| > \kappa\sigma\\
\log(1+r^2/\sigma^2),&|r|\le\kappa\sigma
\end{cases}
\end{equation}
Penalty~\eqref{eq:tiber} is flexible, in the sense that behavior for large residuals and small ones is decoupled.
When we self-tune this new penalty, the additional flexibility indeed improves on the self-tuned Huber,
recovering the results shown in Figure~\ref{RPCA}(d).
It is clear the self-tuning approach succeeds, as
the Huberized Student's $t$ result at the initial $\kappa, \sigma$ values is useless (Figure~\ref{RPCA}(c)).
In this data set, the advantage of self-tuned Huberized Student's $t$ over self-tuned Huber may not be that obvious.
We also apply our approach to Escalator data set\footnote{Publicly available at \url{http://vis-www.cs.umass.edu/~narayana/castanza/I2Rdataset/}}. This data set is is less noisy than the first, but contains multiple moving objects.
We select a time window with $200$ pictures, and $Y\in \mathbb{R}^{20800\times200}$, and apply the huber and Huberized Student's $t$ to this data set, with results shown in Figure~\ref{fig:esc_result}.
We can see that there are a lot of artifacts in the self-tuned Huber penalty result, e.g., the escalator stairs and shadow of people. Instead the result for self-tuned Huberized Student's $t$ is much cleaner and we isolate the moving people successfully. All of these results are achieved with fully automatic parameter tuning.
\begin{figure}[t]
\centering
\begin{tabular}{c}
{\includegraphics[width=14cm]{airport_kLS150_both-eps-converted-to.pdf}}\\
(a) self-tuned Huber\\
initial: $\kappa = 0.02$, $\sigma = 0.02$\\
final: $\kappa = 7.48\times10^{-3}$, $\sigma = 3.49\times10^{-4}$\\
{\includegraphics[width=14cm]{airport_tLS150_both-eps-converted-to.pdf}}\\
(b) self-tuned Huberized Student's $t$\\
intial: $\kappa = 10$, $\sigma = 2\times10^{-2}$\\
final: $\kappa = 23.2$, $\sigma = 1.66\times10^{-2}$\\
\end{tabular}
\caption{\label{fig:esc_result} Background separation with the Escalator data. First column is the background, second column is the foreground, third column is the binary plot of the foreground.}
\end{figure}
\begin{wrapfigure}{r}{0.37\textwidth}\vspace{-0.2in}
\includegraphics[width=4.7cm]{dis-eps-converted-to.pdf}
\caption{\label{fig:dis} Best fit for residual empirical CDF}
\end{wrapfigure}
Here, we use self-tuning Huber and self-tuning Huberized Student's $t$ penalties.
Looking at Figure \ref{fig:esc_result}, the self-tuned Huber has stronger signal but includes more background;
the picture looks better to the eye but a closer examination reveals parts of the escalator are present.
The self-tuned Huberized Student's $t$ has weaker $S$ which is harder to see; but actually gives a much better result.
To get more insights into the problem, we also look at the empirical distribution of the residual.
In Figure \ref{fig:dis}, the light blue line denote the empirical CDF for the residual ($R = Y - U^{\mathsf{T}} V$),
red dashed line is the the best Huberized Student's $t$ fit, blue dashed line is the best $\ell_2$ fit and green dashed line is the best $\ell_1$ fit. We can see that Huberized Student's $t$ has a perfect fit, and in particular is much better that $\ell_1$ and $\ell_2$.
\section{Conclusions}
We introduced a method for self-tuning error penalties, incorporates the log of the normalization constant (a function of the shape parameters) into an extended joint inference problem. Results with synthetic data as well as real data show promise. Future research includes designing innovative `flexible' penalties and automatically adapting them to different applications.
| {'timestamp': '2017-06-07T02:08:52', 'yymm': '1706', 'arxiv_id': '1706.01865', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01865'} | arxiv |
\section{Introduction}
Given an unweighted 2-edge connected graph $G=(V, E)$, the \emph{minimum size 2-edge connected spanning subgraph problem} (henceforth \emph{2EC}) consists of finding a 2-edge connected spanning subgraph of $G$ with the minimum number of edges. Multiple copies of an edge are not allowed, and are not necessary \cite{cheriyan}. The problem has important applications in the design of networks that can survive the failure of a link, but it is MAX SNP-hard even for special cases \cite{csaba}.
Letting $x_{e}$ be a binary variable with value 1 when edge $e\in E$ is in a 2EC solution, 2EC can be formulated as an integer program as follows:\begin{equation}\label{ilpTwoEC}
\begin{aligned}
\text{Minimize}\quad & \sum_{e\in E}x_e& \\
\text{Subject to}\quad &\sum(x_{ij}:i\in S, j\notin S) \geq 2 &\text{for all } \emptyset \subset S \subset V,\\
& 0 \leq x_e \leq 1\text{, and integer} &\text{for all } e \in E. \\
\end{aligned}
\end{equation}
The linear programming (LP) relaxation of 2EC, denoted by 2EC$^\text{LP}$, is obtained by relaxing the integer requirement in (\ref{ilpTwoEC}). Let OPT$(G)$ and OPT$_{\text{LP}}(G)$ denote the optimal value of 2EC for $G$ and the value of its LP relaxation, respectively. In order to measure the quality of the LP relaxation as a lower bound, we define the \emph{unit integrality gap} $\alpha$2EC as the supremum of the ratio of OPT$(G)$ over OPT$_{\text{LP}}(G)$ over all input graphs $G$. This gives a measure of the quality of the lower bound provided by 2EC$^\text{LP}$, which is crucial for approximation algorithms and methods like branch and bound. Note that a polynomial-time constructive proof that the unit integrality gap equals $k\in\mathbb{R}$ would provide a $k$-approximation algorithm for 2EC.
\looseness=-1
While $\alpha$2EC has been intensely studied, little is known about it other than that $\frac{9}{8}\leq\alpha\text{2EC}\leq\frac{4}{3}$ \cite{vygen}. A natural next step is to focus on the simplest form of the problem known to remain NP-hard, when 2EC is restricted to graphs that are \emph{cubic} (i.e., every vertex has degree three) and 3-edge connected \cite{csaba}; we thus hope to generalizing successful methods. In this paper, we demonstrate an improved upper bound for $\alpha$2EC when restricted to 3-edge connected cubic graphs.
\section{Notation and Background}\label{notation}
This section is dedicated to basic notions of graph theory, which will be used throughout the paper.
Let $G=(V, E)$ be a simple undirected graph with vertex set $V$, edge set $E$ and $n=|V|$. A graph is \emph{subcubic} if all vertices have degree 3 or less. A \emph{subgraph} of $G$ is a graph $H=(V_{H}, E_{H})$ where $V_{H}\subseteq V$ and $E_{H}\subseteq E$, such that if edge $uv\in E_{H}$, then $u, v\in V_{H}$. Subgraph $H$ is said to be \emph{spanning} if $V_{H}=V$. For any subgraph $H$ of $G$ we sometimes use the notation $E(H)$ and $V (H)$ to denote the edge set and the vertex set for $H$, respectively, and we use $\chi^{E(H)} \in\mathbb{R}^{E}$ to denote the incidence vector of subgraph $H$ (i.e. $\chi^{E(H)}_{e}$ is the number of copies of edge $e$ in $H$). A \emph{component} of $G$ is a subgraph of $G$ for which any two vertices are connected to each other by paths, and which is not connected to any other vertex in $G$.
For any subset $A\subseteq V$, the \emph{complement} of $A$ is $\overline{A}=V\setminus A$. For any two non-overlapping subsets $A, B\subseteq V$, the edge set between $A$ and $B$ is denoted by $E[A: B]$, i.e. $E[A: B] = \{ij\in E\ |\ i\in A, j\in B\}$. Note that the subset $F=\delta(A)$ of $E$ for some $A\subset V$ is called a \emph{cut} $\delta(A)=E[A:V\setminus A]$ as it disconnects $G$. Graph $G$ is considered $k$-edge connected if and only if all cuts of $G$ have size greater or equal to $k$, $k\in\mathbb{N}$. An edge cut that contains $k$ edges is a \emph{$k$-edge cut}. An edge cut $F$ of $G$ is \emph{essential} if $G'=(V, E\setminus F)$ has at least two components each containing more than one vertex. Each of those components is called a \emph{shore} of the cut. For a $k\in\mathbb{N}$, $G$ is said to be \emph{essentially $k$-edge connected} if and only if $G$ does not have an essential edge cut $F$ with $|F|<k$. If $G$ is cubic, simple and essentially 4-edge connected, then it is also 3-edge connected.
The function $|\delta(\cdot)|$ is \emph{symmetric submodular} for $G$, i.e. for every two sets $Y, Z\subseteq V$, the following two properties hold:
\begin{eqnarray}
|\delta(Y)|+|\delta(Z)|\geq |\delta(Y\cup Z)| + |\delta(Y\cap Z)|\text{,}\\
|\delta(Y)|+|\delta(Z)|\geq |\delta(Y\setminus Z)| + |\delta(Z\setminus Y)|\text{.}
\end{eqnarray}
The concept of convex combination is used extensively: in the context
of this paper, we say that a vector $y\in\mathbb{R}^{E}$ is a \emph{2EC convex combination} if there exist 2-edge connected spanning subgraphs $H_{i}$ with multipliers $\lambda_{i}\in{\mathbb R}_{\geq 0}, i=1, 2, \dotsc, j$ such that $y=\sum_{i=1}^{j}\lambda_{i}\chi^{E(H_{i})}$ and $\sum_{i=1}^{j}\lambda_{i} = 1$.
\section{Contribution}
Our main result, which is proven in Section \ref{sectionProof}, is the following.
\begin{corollary}\label{mainCorollary}
Given a 3-edge connected cubic graph $G=(V, E)$ with $n=|V|$, there exists a 2-edge connected spanning subgraph with at most $\frac{7}{6}n$ edges.
\end{corollary}
\noindent In other words, we show that the unit integrality gap for 2EC is bounded above by $\frac{7}{6}$ for \mbox{3-edge} connected cubic graphs, which improves upon Boyd, Iwata and Takazawa's upper bound of $\frac{6}{5}$\,\cite{iwata}. Since 2EC restricted to 3-edge connected cubic graph is the simplest form of the problem known to remain NP-hard, it also implies that successful methods can be generalized. Our methods are not polynomial and thus, do not result in an approximation algorithm. Nevertheless, they give hope that a $\frac{7}{6}$-approximation algorithm exists, which would improve on the existing methods which gives a $\frac{6}{5}$-approximation \cite{iwata}. It would also extend Takazawa's $\frac{7}{6}$-approximation for bipartite cubic 3-edge connected graphs to all cubic 3-edge connected graphs \cite{takazawa}. In order to prove Corollary \ref{mainCorollary}, we prove the following stronger statement which uses the concept of convex combination.
\begin{theorem}\label{mainThm}
Given a 3-edge connected cubic graph \hbox{$G=(V, E)$}, the vector \mbox{$y\in{\mathbb R}^{E}$} defined by $y_{e} = \frac{7}{9}$ for all $e\in E$ is a convex combination of incidence vectors of 2-edge connected spanning subgraphs $H_{i}$, $i=1, 2, \ldots, k$.
\end{theorem}
In Section \ref{sectionProof}, we also prove the following intermediary result for essentially 4-edge connected cubic graphs.
\begin{lemma} \label{submodularLemma}
Given an essentially 4-edge connected cubic simple graph $G = (V, E)$ with $|V| > 6$ and edges $au, uv, vc, vd \in E$, no two subsets $S, S'\subset V$ different than $\{u, v\}$ exist such that $au, vd \in \delta(S)$, $au, vc \in \delta(S')$, and $|\delta(S)|=|\delta(S')|=4$.
\end{lemma}
Besides being useful in our proof for the main result, Lemma\,\ref{submodularLemma} is also of independent interest because it is a new reduction operation that is very specific to essentially 4-edge connected cubic simple graphs.
\iffalse
\section{Literature Review on 2EC}
General case
- Khuller + Vishkin, 3/2
- Cheriyan, Sebo, Szigeti, 17/12
- Vempala, Vetta, 4/3
- Sebo, Vygen, 4/3
- Krysta, Kuma, 4/3 - 1/1344
- Jothi, Raghavachari, Varadarajan, 5/4
- Explain why not Frederickson, Jaja
For special cases
- subcubic bridgeless
- Csaba, Karpinski, Krysta, 5/4 + epsilon
- Boyd, Fu, Sun, 5/4
- cubic, 3-edge connected
- Boyd, Iwata, Takazawa, 6/5
- Huh, 5/4
- bipartite: Takazawa: 7/6
Bounds
- Sebo, Vygen, 9/8 <= alpha2EC <= 4/3 in general
Boyd, Iwata,, Takazawa, alpha2EC <= 6/5 for cubic 3-edge connected
Yu Sun showed that for cubic bridgeless graphs, you can't
do better than 7/6n (but that isn't a bound on the integrality gap). For
subcubic, the integrality gap is at least 8/7. For cubic 3-edge
connected, as far as I know, the lower bound stands at 11/10 (the Petersen
graph).
\fi
\section{Literature Review}
The first to improve the 2-approximation ratio for 2EC were Khuller and Vishkin \cite{khuller}, in 1994, with their $\frac{3}{2}$-approximation algorithm obtained using depth-first search trees and a method called ``tree-carving''. This was later refined in 1998 to $\frac{17}{12}$ by Cheriyan, Seb\H{o} and Szigeti \cite{cheriyan} via ear decompositions, then to $\frac{4}{3}$ by Seb\H{o} and Vygen \cite{vygen}, in 2014. Krysta and Kumar \cite{kumar} improved the ratio to $\frac{4}{3}-\epsilon$ based on a charging scheme. Other results have been claimed, but have either been shown to be false, or are without conclusive proofs \cite{heeger}.
In parallel, much development also occurred for special cases, especially cubic and subcubic graphs. Krysta and Kumar \cite{kumar} designed a $\frac{21}{16}$-approximation algorithm for cubic graphs. For subcubic graphs, in 2002, Csaba, Karpinski and Krysta \cite{csaba} attained the approximation ratio of $\frac{5}{4} + \epsilon$, which was then improved to $\frac{5}{4}$ by Boyd, Fu and Sun \cite{fu} in 2014, using circulations. When 2EC is further restricted to 3-edge connected cubic graphs, we denote the work of Huh \cite{huh}, and of Boyd, Iwata and Takazawa \cite{iwata}, who achieved ratios of $\frac{5}{4}$, and $\frac{6}{5}$, respectively. Very recently, Takazawa\,\cite{takazawa} obtained a $\frac{7}{6}$-approximation algorithm for bipartite cubic 3-edge connected graphs, inspired from the work of Boyd, Iwata and Takazawa, by using 2-factors covering specified cuts.
In the general case, Seb\H{o} and Vygen proved that the unit integrality gap $\alpha$2EC is bounded as follows: $\frac{9}{8}\leq\alpha\text{2EC}\leq\frac{4}{3}$ \cite{vygen}. The integrality gap 2EC for cubic 3-edge connected graphs was shown in 2013 by Boyd, Iwata and Takazawa \cite{iwata} to be bounded above by $\frac{6}{5}$, and it is known that they are bounded below by the Petersen graph, at $\frac{11}{10}$, as shown in Figure \ref{Petersen} (where bold lines represent edges in the subgraph and dotted edges stand for edges in the Petersen graph, but not in the subgraph).
\iffalse
- Define ILP and LP.
- Define integrality gap
- Importance: indicator of the quality of the lower bound given by the LP
relaxation (important for branch and bound and approximations that depend on lower bounds for success)
- Conjecture
- Where is that gap today?
\fi
\begin{figure}
\begin{center}
\includegraphics{Petersen.pdf}
\end{center}
\caption{The minimum size 2-edge connected spanning subgraph for the Petersen graph.}
\label{Petersen}
\end{figure}
\iffalse
Define 2EC
- finding a minimum size 2-edge connected spanning subgraph in a given 2-edge connected graph
Why is 2EC important
- survivable network design, train network
- NP hard even for special cases (e.g. regular bipartite graphs)
- Why do we care if it's not an approximation algorithm?
Khuller and Vishkin gave a $\frac{3}{2}$-approximation for this problem using depth-first search trees and a notion called ``tree carving''
followed by a 17/12-approximation algorithm due to Cheriyan, Seb\H{o} and Szigeti [6]. They use ear decomposition.
Garg et al. [3] claimed to have a 5/4 -approximation algorithm for the minimum size 2-ECSS problem, but no proof was given.
Improvements in the approximation ratio in several graph classes are made.
For the minimum
2-edge connected spanning subgraph problem in 3-edge connected cubic graphs, Huh [16] gave a 5/4-approximation algorithm.
A further improvement is given by Boyd, Iwata and Takazawa [5], who designed two algorithms with approximation ratio 6=5.
Kenjiro came up with a 7/6 approximation scheme on bipartite graphs, using two-factors. Based on Boy'd method and exploiting the bipartiteness of graphs.
Lower bounds: Yu Sun showed that for cubic bridgeless graphs, you can't
do better than 7/6n (but that isn't a bound on the integrality gap). For
subcubic, the integrality gap is at least 8/7. For cubic 3-edge
connected, as far as I know, the lower bound stands at 11/10 (the Petersen
graph).
\fi
\section{2EC Convex Combinations for 3-edge Connected Graphs}\label{sectionProof}
In this section, we provide a proof for Lemma\,\ref{submodularLemma}, i.e. we show that for any essentially 4-edge connected cubic graph $G = (V, E)$ with $|V|>6$ and edges $au, uv, vc, vd \in E$, no two subsets $S, S'\subset V$ different than $\{u, v\}$ exist such that $au, vd \in \delta(S)$, $au, vc \in \delta(S')$, and $|\delta(S)|=|\delta(S')|=4$. This result will be used to prove the main theorem.
\subsection*{Proof of Lemma \ref{submodularLemma}.}
Here we provide a proof of Lemma \ref{submodularLemma}. Suppose that $G = (V, E)$ with $|V|>6$, edges $au, uv, vc, vd \in E$ and subsets $S, S'\subset V$ is the smallest counter-example to the lemma.
Let edges incident to $u$ and $v$ be as illustrated in Figure \ref{UvAndIncidentEdges}, with the unlabelled vertex neighbour to $u$ called $b$. Some edges incident to the unlabelled vertices are not shown.
\begin{figure}
\begin{center}
\includegraphics{UvAndIncidentEdges.pdf}
\end{center}
\caption{Edges incident to $u$ and $v$ in $G$.}
\label{UvAndIncidentEdges}
\end{figure}
$G$ is simple and essentially 4-edge connected, and $|V|>6$, which implies that labelled vertices in Figure \ref{UvAndIncidentEdges} are distinct, as there would otherwise exist an essential 3-edge cut. Without loss of generality, assume that $u \in S$ and $u \in S'$ (if not, take the complement of the set). The cuts $\delta(S)$ and $\delta(S')$ are minimal and $G$ is cubic, which implies that two adjacent edges may not be in the same cut. Therefore $v, b, c \in S$ and $v, b, d \in S'$. We already know that $a, d \notin S$ and $a, c \notin S'$. Figure \ref{CutsDisposition} shows this disposition of the vertices in the cut.
\begin{figure}
\begin{center}
\includegraphics{CutsDisposition.pdf}
\end{center}
\caption{Disposition of the vertices adjacent to $u$ and $v$ in $S$ and $S'$.}
\label{CutsDisposition}
\end{figure}
Throughout this proof, we exploit the symmetric submodularity property of the function $|δ\delta(\cdot)|$, which states that
\begin{eqnarray}
|\delta(S)|+|\delta(S')|\geq |\delta(S\cup S')| + |\delta(S\cap S')|\text{,}\nonumber\\
8\geq |\delta(S\cup S')| + |\delta(S\cap S')|\text{.}\label{eqn1}
\end{eqnarray}
Because $u, v \in S \cap S'$, then $|S\cap S'| > 1$; similarly because $a \notin S\cup S'$, then
$\overline{|S \cup S'|} > 0$. It follows that $|\delta(S\cup S')| \geq 3$ and $|\delta(S\cap S')| \geq 4$ (since $G$ has no essential 3-edge cut). There exist two cases, when $|\delta(S\cup S')| = 3$ and $|\delta(S\cap S')|=4$ or $5$ and where $|\delta(S \cup S')| = 4$, because the cardinality of the cuts are restricted by (\ref{eqn1}).
\begin{case}\label{submodularCase1}
$|\delta(S\cup S')|=3$ and $|\delta(S\cap S')|=4$ or $5$.
\end{case}
Graph $G$ is simple and essentially 4-edge connected, which implies that one of the shores of $\delta(S\cup S')$ must consist of a single vertex, as the cardinality of this cut is 3: vertices $u$ and $v$ belong to $S\cup S'$, so $\overline{S\cup S'}=\{a\}$.
\looseness=-1
Any partition of a cubic graph has an even number of odd parts, because cubic graphs have an even number of vertices. We use this parity to show that $|\delta(S\cap S')| = 5$. The partition $\{S \setminus S', S' \setminus S, S \cap S', \overline{S \cup S'}\}$ (displayed in Figure \ref{Partition}) has $|\overline{S \cup S'}|$ odd, which implies that at least one of $S\setminus S'$, $S'\setminus S$ and $S\cap S'$ also has an odd number of vertices. The graph $G$ is cubic, which implies that for any subset $S\subseteq V$ of vertices, $\delta(S)$ is odd if and only if $|S|$ is odd. Given that $|\delta(S)| = |\delta(S')| = 4$, then $|S|$ and $|S'|$ must be even. This implies that the parity of $|S' \setminus S|$ and $|S \cap S'|$ must be the same; similarly, the parity of $|S \setminus S'|$ and $|S \cap S'|$ must also be the same. Therefore, either $|S \setminus S'|$, $|S' \setminus S|$ and $|S \cap S'|$ are all odd, or all even, to respect parity. But from the above, they cannot all be even. Thus, $|S \cap S'|$ is odd, which means that $|\delta(S \cap S')|$ must be odd as well. Therefore,
\begin{equation}
|\delta(S \cap S')| = 5\text{.}\label{SandSEquals5}
\end{equation}
\begin{figure}
\begin{center}
\includegraphics{Partition.pdf}
\end{center}
\caption{Partition of $G$ to show the parity of parts, in Case \ref{submodularCase1}.}
\label{Partition}
\end{figure}
All edges at $u$ and $v$ are known: let us examine an edge $bx$, for a vertex $x \in V$. We already know of 3 edges in $\delta(S \cap S')$, which means that there are exactly 2 others edges $e$ and $f$ in the cut. Assume that $x \in S \cap S'$: this means
that $bu$, $e$ and $f$ are in an essential 3-edge cut, because such a cut contains $b$ and $x$. Such a cut contradicts the fact that $G$ is essentially 4-edge connected. Therefore, $x \notin S \cap S'$, which immediately implies that $|S \cap S'| = 3$. We have that
\begin{eqnarray}
4=|\delta(S)| = |\delta(S\setminus S')| + |\delta(S\cap S')| - 2|E[S\setminus S': S\cap S'])|\text{,}\label{eqn5}\\
4=|\delta(S')| = |\delta(S'\setminus S)| + |\delta(S\cap S')| - 2|E[S'\setminus S: S\cap S']|\text{.}\label{eqn6}
\end{eqnarray}
\noindent We also have that $ba \notin E$ or else there would be an essential 3-edge cut
$\delta(\{u, b, a\})$, which means that from the five edges in $\delta(S \cap S')$, four link to either $S \setminus S'$ or $S' \setminus S$:
\begin{eqnarray}
4 = |E[S'\setminus S: S\cap S']| + |E[S\setminus S': S\cap S']|\text{.}\label{eqn7}
\end{eqnarray}
\noindent From the premise $|V | > 6$, it is implied that one of $S \setminus S'$ and $S' \setminus S$ contains more than one vertex. Without loss of generality, let it be $S \setminus S'$. Because $G$ has no essential 3-edge cut and $|S \setminus S'|>1$, we infer that.
\begin{eqnarray}
4 \leq |\delta(S \setminus S')| \text{,}\label{sNewBound}\\
3 \leq |\delta(S' \setminus S)|\text{.}\label{sPrimeNewBound}
\end{eqnarray}
\noindent The symmetric submodularity property ensures that
\begin{eqnarray}
|\delta(S)|+|\delta(S')|&\geq |\delta(S\setminus S')| + |\delta(S'\setminus S)|\nonumber\\
8&\geq |\delta(S\setminus S')| + |\delta(S'\setminus S)|\text{.}
\label{symMod2}
\end{eqnarray}
\noindent We will now use algebraic manipulations to show a contradiction. We subtract (\ref{eqn6}) from (\ref{eqn5}) and add (\ref{eqn7}) twice:
\begin{eqnarray}
8 = |\delta(S\setminus S')| - |\delta(S'\setminus S)| + 4|E[S'\setminus S: S\cap S']|\text{.}\label{eqn8}
\end{eqnarray}
\looseness=-1
\noindent In equation (\ref{eqn8}), $|\delta(S\setminus S')| - |\delta(S'\setminus S)|$ must be a multiple of 4. Because inequalities (\ref{sNewBound}), (\ref{sPrimeNewBound}) and (\ref{symMod2}) restrict the values of \mbox{$|\delta(S\setminus S')|$} and \mbox{$|\delta(S'\setminus S)|$}, their difference must be zero, i.e.
\begin{eqnarray}
|\delta(S\setminus S')|=4\text{.}\label{diffZero}
\end{eqnarray}
Equation (\ref{eqn8}) is simplified to
\begin{eqnarray}
2 = |E[S\setminus S': S\cap S']|\text{.}\label{eqn9}
\end{eqnarray}
We now conclude by substituting (\ref{SandSEquals5}), (\ref{diffZero}) and (\ref{eqn9}) in (\ref{eqn5}):
\begin{align}
& 4=|\delta(S\setminus S')| + |\delta(S\cup S')| - 2|E[S\setminus S': S\cap S']|\nonumber\\
& \quad = 4 + 5 - 2 \times 2\nonumber\\
& \quad = 5\nonumber\text{,}
\end{align}
which gives a contradiction.
\begin{case}
$|\delta(S \cup S')| = 4$ and $|\delta(S\cap S')|=4$.
\end{case}
Since $|\delta(S\cap S')|=4$, it follows that $|S\cap S'|$ is even, because $G$ is cubic. So there is at least one more vertex $w$ in $S\cap S'$. Since $G$ is 3-edge connected, at least one edge incident with $w$ is in $\delta(S\cap S')$. However, $vc, vd, au\in\delta(S\cap S')$ already, so we only have one other edge $e$ in the cut (as shown in Figure \ref{Case2}). Therefore $w$ is one end of $e$. This means that $\{ub, e\}$ is a 2-edge cut in $G$, which is a contradiction.\qed
\begin{figure}
\begin{center}
\includegraphics{Case2.pdf}
\end{center}
\caption{Disposition of the vertices adjacent to $u$ and $v$ when $|\delta(S \setminus S')| = 4$.}
\label{Case2}
\end{figure}
\subsection*{Proof of Theorem \ref{mainThm}.}
Let $G=(V, E)$ be the smallest counter-example for which the theorem does not hold. There are only three 3-edge connected essentially 4-edge connected cubic graphs with 6 vertices or less, on which the theorem can be shown to be true directly, as demonstrated in Figure \ref{basecase}, where bold lines represent edges in the subgraph, and dotted lines represent edges in $G$ not in the subgraph. In the figure, for each such graph $G$, the subgraphs $H_{i}$ and the corresponding $\lambda_{i}$ values for the required convex combination are shown. The smallest cubic 3-edge connected simple graph which is not essentially 4-edge connected has $|V|=6$, which means that either
\begin{figure}
\begin{center}
\includegraphics{BaseCase.pdf}
\end{center}
\caption{Base cases for Theorem \ref{mainThm}. In the subgraphs $H_{i}$, bold lines indicate the edges in the subgraph and dotted lines indicate the edge omitted in the subgraph.}
\label{basecase}
\end{figure}
\begin{enumerate}
\item $G$ is essentially 4-edge connected and $|V| > 6$,
\item $G$ has an essential 3-edge cut and $|V| \geq 6$.
\end{enumerate}
\setcounter{case}{0}
\begin{case}\label{case1}
$G$ is essentially 4-edge connected and $|V|>6$.
\end{case}
We pick an arbitrary edge $uv\in E$, and we label the other adjacent vertices of $u$ as $a$ and $b$, and the other adjacent vertices at $v$ as $c$ and $d$. We will use this edge to create the vector $z\in\mathbb{R}^{E}$ as a convex combination of incidence vectors of 2-edge connected spanning subgraphs, where for all $e\in E$, \[
z_{e} =
\begin{cases}
\hfill 1 \hfill & \text{ if $e = uv$,} \\
\hfill \frac{1}{2} \hfill & \text{ if $e \in \{ua, ub, vc, vd\}$,} \\
\hfill \frac{8}{9} \hfill & \text{ if $e \neq uv$ and $e$ adjacent to one of $ua, ub, vc$ or $vd$,} \\
\hfill 1 \hfill & \text{ if $e \neq uv$ and $e$ adjacent to two of $ua, ub, vc$ or $vd$,} \\
\hfill \frac{7}{9} \hfill & \text{ otherwise.} \\
\end{cases}
\]
Graph $G$ has no essential 3-edge cut and $|V|>6$, which implies that $a$, $b$, $c$ and $d$ are distinct. Lemma \ref{submodularLemma} states that there does not exist two subsets $A, B\subset V$ different from $\{u, v\}$ such that $au, vc\in \delta(A)$, $au, vd\in \delta(B)$ and $|\delta(A)|=|\delta(B)|=4$. Thus, assuming that $\delta(B)$ is an essential 4-edge cut for some $B$ automatically means that $\delta(A)$ is not a 4-edge cut for any such $A$, and vice-versa. Without loss of generality, assume that edges $au$ and $vc$ are not in an essential 4-edge cut together, other than $\delta(\{u, v\})$, i.e. $\delta(A)>4$.
By Lemma \ref{submodularLemma} again, there does not exist two subsets $C, D\subset V$ different from $\{u, v\}$ such that $bu, vd\in \delta(C)$, $bu, vc\in \delta(D)$ and $\delta(C)=\delta(D)=4$. Knowing that $|\delta(A)| > 4$ for all $A$ such that $au, vc\in\delta(A)$ and $A\neq\{u,v\}$ implies that $|\delta(C)|>4$ for all $C$ such that $bu, vd\in\delta(C)$ and $C\neq\{u, v\}$, which means that edges $bu$ and $vd$ are not in an essential 4-edge cut together.
Armed with these facts, we create graph $G_{1}$ by removing edges $au$ and $vc$, and $G_{2}$ by removing edges $bu$ and $vd$. In both graphs, any vertex $s$ of degree 2 with incident edges $st$ and $sr$ is removed, and the edge $sr$ is added. Because $\delta(A)>4$, $bd, ac\notin E$, no multi-edge are created. This situation is illustrated in the first part of Figure \ref{UVPartialTransform}; the second part of the figure illustrates the same situation, but when $|\delta(A)| = 4$ and $|\delta(B)| > 4$, for any $B$ such that $au, vd\in \delta(B)$ and $B\neq\{u, v\}$.
The astute reader may ask what happends if an edge links one of $a$, $b$, $c$ or $d$: assume that such an edge $rs\in E$ exists, for $\{r, s\}\subset\{a, b, c, d\}$. It is immediately apparent that $r$ and $s$ cannot both be neighbor to the same vertex, either $u$ or $v$, otherwise there would exist an essential 3-edge cut, e.g. $\{rsu\}$. Without loss of generality, let $r$ be adjacent to $u$ and let $s$ be adjacent to $v$. For simplicity, let $r=a$ and $s=c$. Cut $\delta(\{a, c\})$ is an essential 4-edge cut and $ua, vc\in\delta(\{a, c\})$. By Lemma \ref{submodularLemma} and because $|V|>6$, edges $au$ and $vd$ are not in an essential 4-edge cut together, and edges $bu$ and $vc$ are not in an essential 4-edge cut together, which means that the transformation is valid.
Both $G_{1}$ and $G_{2}$ are 3-edge connected and cubic, because $G$ was simple and essentially 4-edge connected and the two edges removed in $G$ were not in an essential 4-edge cut together.
\begin{figure}
\begin{center}
\includegraphics{UVTransform1.pdf}
\end{center}
\caption{Partial transformation of $G$ into $G_{1}$ or $G_{2}$ in Case 2 of Theorem \ref{mainThm}.}
\label{UVPartialTransform}
\end{figure}
The theorem holds for $G_{1}$ and $G_{2}$, as they are both smaller than $G$, and gives two convex combinations of incidence vectors of 2-edge connected spanning subgraphs $C_{1}$ and $C_{2}$ for $G_{1}$ and $G_{2}$, respectively. Note that an edge in the convex combination is present $\frac{7}{9}$ times overall in subgraphs. We will now modify the subgraphs in $C_{1}$ and $C_{2}$ to form sets $C_{1}'$ and $C_{2}'$ of subgraphs for $G$ in the following way: assume that edges $s$ and $t$ were the two edges that we removed to transform $G$ into $G_{i}$, then any 2-edge connected spanning subgraph for $G_{i}$ is 2-edge connected and spanning for $G$ with the same edge selection, save for edges adjacent to $s$ and $t$ which we always select, and $s$ and $t$ which we always omit. This is illustrated on the left side of Figure \ref{PatternsToMissingEdgeSevenNineth}, where bold lines represent edges in the subgraph, dotted line represent edges omitted in the subgraph and dashed lines represent edges which may or may not be in the subgraph. In the figure, edges incident to $a$, $b$, $c$ and $d$, but not adjacent to $uv$ are shown as distinct, for simplicity.
We now take $\frac{1}{2}C_{1}'+\frac{1}{2}C_{2}'$ to obtain a 2EC convex combination for $G$. The occurrence of each edge in this convex combination is shown in the rightmost part of Figure \ref{PatternsToMissingEdgeSevenNineth}. Note that this is the occurrence for the case that no edges with both endpoints in the set $\{a, b, c, d\}$ exist. In the event such edges exist, then these edges have an occurrence of $1$, which does not affect the end result, as is shown later.
\begin{figure}
\begin{center}
\includegraphics{PatternsToMissingEdge7.pdf}
\end{center}
\caption{Transformation of the 2-edge connected spanning subgraphs for $G_{1}$ and $G_{2}$ into 2-edge connected spanning subgraphs for $G$.}
\label{PatternsToMissingEdgeSevenNineth}
\end{figure}
The convex combination $\frac{1}{2}C_{1}'+\frac{1}{2}C_{2}'$ is symmetrical (see the rightmost part of Figure \ref{PatternsToMissingEdgeSevenNineth}): therefore, repeating all the steps from Case \ref{case1}, taking every edge of $G$ in turn as edge $uv$ gives $|E|$ convex combinations which we label $F_{i}$, for $i=1,\ldots,|E|$. We build a new convex combination by setting the lambda value $\lambda_{F_{i}}=\frac{1}{|E|}$ for each $F_{i}$, and conclude that it selects every edge $\leq\frac{7}{9}$ times overall. We shall show this property in more detail here for an edge $yz\in E$:
\begin{itemize}
\item edge $yz$ is treated as edge $uv$ in exactly one of the $|E|$ convex combinations. It then has an occurrence of 1.
\item there are no doubled edges, which means that $yz$ is adjacent to $uv$ in exactly 4 of the $|E|$ convex combinations. It then has an occurrence of $\frac{1}{2}$.
\item Because $G$ is cubic, there are exactly 8 ways to find an edge $yz$ exactly one edge away from $uv$, which are handled differently if $yz$ and $uv$ are in a 4-cycle together or not.
\subitem Assume that $yz$ and $uv$ are not in a 4-cycle $r$ times out of $|E|$, where $r \leq 8, r\in \mathbb{N}$ (the graph is cubic and simple, so there can be at most 8 such distinct edges for $yz$). It then has an occurrence of $\frac{8}{9}$.
\subitem If $yz$ and $uv$ are in a 4-cycle (i.e. $yu, zu\in E$), then $yz$ is one edge away from $uv$ both by $yu$ and $zu$. This happens $t$ times over the $|E|$ convex combinations and $yz$ then has an occurrence of 1. Because there are 8 ways to be one edge away from $uv$, and any 4-cycle with $yz$ and $uv$ uses two of those ways,
\begin{equation}
2t + r = 8,\text{ for }t\in \mathbb{N}\text{.} \label{firstLine}
\end{equation}
\item The occurrence of $yz$ in the other convex combinations is $\frac{7}{9}$.
\end{itemize}
The average occurrence of an edge over the $|E|$ convex combinations is
\begin{align}
&\leq \frac{1}{|E|}\Big(1+t+4\times \frac{1}{2}+ r\times\frac{8}{9}+(|E|-r-t-5)\times\frac{7}{9}\Big)\nonumber\\
&=\frac{1}{|E|}\Big(\frac{2t}{9} + \frac{r}{9}-\frac{8}{9}+\frac{7|E|}{9}\Big)\nonumber\\
&= \frac{7}{9} + \frac{1}{9|E|}(2t+r-8)\text{.}\label{lastLine}
\end{align}
\noindent Since $2t + r = 8$, by (\ref{firstLine}), it follows from (\ref{lastLine}) that the average edge occurrence over the $|E|$ convex combinations is at most $\frac{7}{9}$. The convex combination which results from giving each convex combination a weight of $\frac{1}{|E|}$ selects every edge $\frac{7}{9}$ times. If an edge is selected less than $\frac{7}{9}$ of the time, we add it back arbitrarily to have it selected exactly $\frac{7}{9}$ of the time. The theorem holds.
\begin{case}
$G$ has an essential 3-edge cut $C$ and $|V| \geq 6$.
\end{case}
\begin{figure}
\begin{center}
\includegraphics{3ECSplit.pdf}
\end{center}
\caption{Contracting both sides of an essential 3-edge cut of $G$.}
\label{3ECSplittingSevenNinth}
\end{figure}
Notice that the ends of the three edges in $C$ must be distinct because $G$ is \mbox{3-edge} connected. In this case we contract each shore of $C$ to a single pseudo-vertex, to obtain graphs $G_{1} = (V_{1},E_{1})$ with pseudo-vertex $v_{1}$ and $G_{2} = (V_{2},E_{2})$ with pseudo-vertex $v_{2}$ (as shown in Figure \ref{3ECSplittingSevenNinth}). Both $G_{1}$ and $G_{2}$ are smaller than $G$ so the theorem holds for $G_{1}$ and $G_{2}$. Moreover the patterns formed by the occurrence of the edges incident to $v_{1}$ and $v_{2}$ are unique and identical in the subgraphs in the corresponding convex combination. More specifically, exactly $\frac{2}{9}$ of the time, one of the incident edges will not be in the subgraph, on both sides of the cut, and this is true for each of the three incident edges. The remaining subgraphs contain all three incident edges. These constant patterns allow us to “glue” (reconnect the edges as there were before the inductive step) the subgraphs for $G_{1}$ and $G_{2}$ together, in such a way that identical patterns at $v_{1}$ and $v_{2}$ are matched and the resulting subgraphs are 2-edge connected. Figure \ref{3ECSplittingSevenNinth} displays the patterns formed by the occurrence of the edges incident to $v_{1}$ and $v_{2}$ and their occurrence, on the left. The figure also illustrates the process of gluing the 2-edge connected spanning subgraph in the convex combinations for $G_{1}$ and $G_{2}$ .
\begin{figure}
\begin{center}
\includegraphics{3ECSplitWhenSevenNinth.pdf}
\end{center}
\caption{``Gluing'' the 2-edge connected spanning subgraphs in the 2EC convex combinations for $G_{1}$ and $G{1}$.}
\label{3ECSplittingSevenNinth}
\end{figure}
This results in a convex combination that shows that the theorem holds for $G$, which gives a contradiction.\qed
\subsection*{Proof of Corollary \ref{mainCorollary}.}
\noindent Theorem\,\ref{mainThm} implies that for graph $G=(V, E)$, there exists a set of 2-edge connected spanning subgraphs $H_{i}$ with $\lambda_{i}\in\mathbb{R}_{\geq 0}$, $i=1,\ldots,j$ such that $\sum_{i = 1}^{j}\lambda_{i}=1$ and $\sum_{i = 1}^{j}\lambda_{i}\chi^{E(H_{i})}_{e}=\frac{7}{9}$ for all $e\in E$. This implies that for at least one of the $H_{i}$, $\sum_{e \in E}\chi^{E(H_{i})} \leq \frac{7|E|}{9}=\frac{7n}{6}$, since $|E|=\frac{3n}{2}$ for cubic graphs.\qed
\vspace{1em}
In other words, we show that the unit integrality gap for 2EC is bounded above by $\frac{7}{6}$ for \mbox{3-edge} connected cubic graphs, which improves upon Boyd, Iwata and Takazawa's upper bound of $\frac{6}{5}$ \cite{iwata}. Our methods are not polynomial and thus, do not result in an approximation algorithm. Nevertheless, they give hope that a $\frac{7}{6}$-approximation algorithm exists, which would improve upon the $\frac{6n}{5}$-approximation algorithm by Boyd, Iwata and Takazawa \cite{iwata}, and the $\frac{7n}{6}$-approximation algorithm when $G$ is bipartite, by Takazawa \cite{takazawa}.
| {'timestamp': '2017-06-07T02:03:22', 'yymm': '1706', 'arxiv_id': '1706.01609', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01609'} | arxiv |
\section{Introduction}
\noindent Evidence suggests that cognitive performance decreases following periods of sustained mental effort and that taking breaks helps knowledge workers of all types from paid-per-task Mechanical Turk workers to full-time analysts of every domain \cite{ariga2011brief,borghini2014measuring,lim2010imaging,lottridge2015effects,rzeszotarski2013inserting,warm2008vigilance}. For instance, \cite{rzeszotarski2013inserting} asserts that workers are refreshed after breaks and that workers who take breaks perform more work compared to those who do not. It has also been observed that participant's resting baseline behavior predicts subsequent performance declines \cite{lim2010imaging}. It may be possible to improve a worker’s overall performance by improving his/her baseline between periods of task activity. But there is competition between the production rate of work from knowledge worker and the quality of their work. Highly motivated knowledge workers’ performance may decrease in quality if they continue to work for long periods of time without some sort of break. Knowledge workers focused on completion of tasks may not be able to accurately monitor their own fatigue level and may miss subtle cues indicating that they would benefit from some sort of break.
We explore the notion of cognitive depletion where knowledge workers’ cognitive resources are depleted by continued work and their ability to accurately complete their task or provide meaningful analytical feedback becomes compromised. Cognitive depletion extends beyond simple sleep-deprivation related fatigue, and experts are susceptible to cognitive depletion because they may not feel (or admit to) the early signs of mental fatigue we often associate with exhaustion. It is important then to have a mechanism for identifying impending cognitive depletion without the direct input of an individual to describe their current levels of fatigue and depletion. This mechanism must be able to reason about a person's state based on overt, observable symptoms in an unbiased way if it is to benefit its users. Identifying such observable symptoms remains a challenge because fatigue, in general, is not well understood.
In this work, we present the results of a user study designed to evaluate a set of potential symptoms of cognitive depletion from a total of 19 participants. We use a browser-based game to simulate the analysis of Nuclear Magnetic Resonance (NMR) spectrum and asked participants to play this game for up to 3 hours. During this session researchers observed the participants for candidate symptoms of cognitive depletion while collecting game event logs and eye tracking data. We use the results of this study to draw inferences about how cognitive depletion manifests when people are asked to perform demanding problem-solving tasks for long durations of time. Our work provides early insights into cognitive depletion and addresses the future research implications of the findings. The following are the contributions of this paper:
\begin{itemize}
\item We summarize fourteen symptoms observed over the course of three hours of the user study (19 participants).
\item We describe characteristics of each symptom and its relationship with others through the triangulation of different datasets (e.g., symptom observations, event logging, and eye-tracking) as well as individual- and group-level analyses.
\end{itemize}
\section{Related Works}
Our work understanding cognitive depletion builds on research in the related fields of attention, interruption and task resumption, multitasking, error and mistake frameworks, quality control, working memory, and cognitive overload.
\subsection{Attention, Interruptions, and Task Resumption}
Research into attention processes often attempts to measure and predict how long individuals can attend to a specific task. One important concept from attention research is the often observed vigilance decrement: after periods of sustained effort on a vigilance task, individuals’ begin to miss cues critical to their task or workflow~\cite{anderson2015polymorphic,ariga2011brief,pattyn2008psychophysiological,warm2008vigilance}. Task-unrelated thoughts (TUTs) are another important phenomenon from attentional research. Individuals required to focus on a task for long periods of time often report self-distracting thoughts that are unrelated to the task at hand~\cite{adler2013self,forster2009harnessing}. Suppressing TUTs is a current topic of research but for our purposes, we view TUTs as a potential symptom of cognitive depletion. Interruption and task resumption research seeks to understand workflows and predict the optimal time to interrupt an individual so that the interruption is as minimally detrimental as possible (see our references for just a few examples). Such understanding is important to the study of cognitive depletion because any coping or mitigation strategies must also be minimally intrusive to workflows.
\subsection{Quality Control, Error, and Mistake Frameworks}
The study of Mechanical Turk-style economies has provided a wealth of techniques for assessing the quality of worker contributions and for detecting workers who are abusing task structures for their own gain~\cite{cheng2015measuring,rzeszotarski2011instrumenting,salvucci2009toward}. These techniques are beneficial to the study of cognitive depletion as they provide potential metrics that can be automatically collected without interrupting workers as well as providing insight into the working patterns of large groups of individuals. It also provides an easily accessible real-world example of an ideal scenario for cognitive depletion research: an economy based on constant completion of micro-tasks where workers are motivated to work beyond the point where their cognitively depleted state begins affecting the quality of their output.
A tremendous amount of work has been done to understand and categorize human error in a variety of contexts. This work is particularly important in fields such as air traffic control where human error endangers hundreds of lives~\cite{kontogiannis2009proactive,zuger2015interruptibility}. Our work and model presented here do not attempt to replicate the in depth error frameworks completed by others. Rather, we use them as a source of observations and discrete observable phenomena which may be symptoms of cognitive depletion.
\subsection{Working Memory and Cognitive Overload}
Research into working memory and cognitive overload are the closest parallels to cognitive depletion that we have found and numerous works have provided the foundation for this current work. From these works important concepts such as mental and cognitive fatigue have arisen~\cite{galy2012relationship,guastello2012catastrophe,van2003mental}. Such research makes important distinctions between the effects of acute workload and extended engagement. Particularly, a sudden acute workload may cause a sort of `buckling stress' where an individual is unable to cope, while fatigue is the gradual loss of work capacity~\cite{guastello2012catastrophe}. \cite{van2003mental} defines mental fatigue as a change in psychophysiological state due to sustained performance. Both working memory and cognitive overload research study the immediate effects of task load in order to determine when a person is cognitively overloaded. We view cognitive overload as one mechanism which will, with extended engagement, result in a state of cognitive depletion. Highly overloaded persons will reach a state of cognitive depletion at a rate faster than those who are not cognitively overloaded. Mental fatigue as defined by \cite{van2003mental} is then a cue that an individual is cognitively depleted. One seminal work of this field is the frequently used NASA-TLX~\cite{hart1988development} which provides a six-axis inventory for self-assessing the cognitive load of a task. Our work builds on this foundation to assess signs indicating that a person may be in a state of cognitive depletion.
\section{Symptoms of Cognitive Depletion}
Building on the discussed related fields, we drafted a collection of potential symptoms of cognitive depletion based on the results of published experimental evaluations (see Table \ref{tab:summary_symptoms}). This gave us a starting collection of possible symptoms that we can group into three broad categories as follows.
\begin{table}[t!]
\centering
\footnotesize
\begin{tabular}{p{1.5cm} | p{1cm} | p{4.5cm}}
\hline
\bf Category & \bf Code & \bf Symptom \\ \hline
VR & D & Distraction \\
VR & I & Inattention \\
VR & IDT & Increased Decision Time \\
VR & TUT & Task Unrelated Thoughts \\ \hline
PED & DCE & Data/Command Errors \\
PED & INA & Increased Negative Affect \\
PED & PE & Physical Effects \\ \hline
PJS & C & Confusion \\
PJS & ERE & Effort/Risk Over/Under Estimation \\
PJS & F & Forgetting \\
PJS & LAP & Lack of Advancement/Progress \\
PJS & STI & Strategy Inefficiency \\
PJS & TA & Task Abandonment \\
PJS & TR & Task Rushing \\ \hline
\end{tabular}
\caption{Symptoms and symptom categories under study. Categories are Vigilance and Reactionary Symptoms (VR), Physical and Emotional Deregulation (PED), and Personal Judgment Symptoms (PJS)}
\label{tab:summary_symptoms}
\end{table}
\subsection{Vigilance and Reactionary Symptoms (VR)}
Vigilance and reactionary symptoms include phenomena such as habituation to status alerts, increased reaction time, distraction, and inattention. These symptoms are most likely to manifest in conditions require active monitoring of real-time events. For example, `vigilance decrement' is a well known phenomenon where reaction time and attentiveness to a stimuli stagnates as function of time task~\cite{lim2010imaging,pattyn2008psychophysiological,rzeszotarski2011instrumenting,warm2008vigilance}. In this study, we focus on four potential symptoms: distraction (D), inattention (I), increased decision time (IDT), and task-unrelated thoughts (TUT).
\subsection{Physical and Emotional Deregulation (PED)}
Physical and motor symptoms include drowsiness, exhaustion, clumsiness, etc. as well as unintentional mistakes providing input, data, or keystrokes involving fine-motor skills. For example, a person may begin to fidget or change their seated posture rapidly or begin to click the wrong buttons on an interface~\cite{kontogiannis2009proactive,lim2010imaging,rzeszotarski2013inserting,gevins2003neurophysiological,adler2013self}. This category also includes emotional effects such as increased negative affect where a person may begin to complain about the difficulty of a task~\cite{adler2013self,bixler2013detecting,carver2003pleasure}. In this study, physical and emotional deregulation manifests as data/command errors (DCE), increased negative affect (INA), and physical effects (PE).
\subsection{Personal Judgment Symptoms (PJS)}
Personal judgment symptoms include occasions where a person is not accurately accounting for the state or their task and is confused or rushing tasks. It also includes disruptive workflows and the failure to form or adjust strategies. The distinguishing characteristic of symptoms in this category is that the person intends the actions resulting from an inaccurate judgement. If asked, the person would not say that he/she had made a mistake in the same sense that a person who misspelled a word might. In the latter case, the person knew how to spell the word but physically hit the wrong key. In the former, a person may intentionally use the word "then" when the grammatically correct word would be "than". Another symptom belonging to this category would be a demonstrated fixedness or rigidity in strategy towards a task even when it repeatedly fails~\cite{adler2013self,butler2015automatic,van2003mental}. Symptoms such as confusion (C), effort/risk under/over estimation (ERE), forgetting (F), task abandonment (TA), lack of advancement/progress (LAP), strategy inefficiency (STI), and task rushing (TR) belong to this category.
\section{Methodology}
Here we describe the environment and protocol we used to investigate cognitive depletion. Our study involved participants playing a puzzle-solving game for several hours while we collected data on overt symptoms of cognitive depletion.
\subsection{Apto Game Environment}
Participants were recruited to play a web-game, Apto (see Figure \ref{aptoss}), which simulated the Nuclear Magnetic Resonance (NMR) spectrum analysis process and was designed to be similar to the professional software packages such as The Chenomx NMR suite~\footnote{http://www.chenomx.com/software/} used by experts to analyze spectrum results. Each spectrum was randomly generated and consisted of 1 to 16 compounds depending on the difficulty level. The score for each puzzle was calculated based on a formula that awarded more points per compound to higher levels. During the game, these scores were abstracted to a star system based on the game level: participants earned one bronze star for each completed level 1 puzzle, 2 bronze stars for level 2, 3 bronze stars for level 3, 1 silver star for level 4, and 1 gold star for each level 5 puzzle. The total score earned by a participant was available to him/her in this star form through a slide-down window.
\begin{figure}[t]
\centering
\includegraphics[width=0.45\textwidth]{aptoss.png}
\caption{The Apto Game Environment.}
\label{aptoss}
\end{figure}
Participants solved puzzles by clicking peaks of the spectrum to search for compounds with peaks near the search point. Participants selected candidate matching compounds from the search results of suggested compounds and then adjusted the fit of each compound to match as precisely as possible by clicking and dragging the compound's individual spectrum up or down relative to the puzzle spectrum. Compounds could have closely overlaping spectra, so three additional tools were available to help participants. A "sum line" showed the summation of the candidate compounds the participant currently had selected, so they could compare against the puzzle. A "difference line" drew a red line along the spectrum to highlight the difference between the sum line and the spectrum. An "error line" drew a bright-magenta line to draw attention to areas where the mean squared error between the sum and spectrum lines was great. These three tools operated independently and could be used in any combination by the participant. Participants had a "restart puzzle" button available to them which undid all their actions on a puzzle and returned it to its initial state. A "skip" button allowed participants to abandon the current puzzle in an unfinished state and be given a new puzzle to try. The restart and skip buttons did not affect the participant's score. When a participant completed a puzzle, they were given the option to change their level and could jump to any level from 1 - 5. Puzzles were considered solved when participants achieved 99\% of the available points.
\subsection{Participants}
We recruited 19 participants (8 female) from our organization through flyers, emails, and meeting announcements. 9 of these participants wore glasses. Participants ranged in age and job description but did not have prior experience conducting NMR analysis. Participants were compensated for their time away from their regular jobs. In addition, we offered a small prize to be awarded to the participant with the highest session score at the end of the study.
\subsection{Protocol}
Our procedures were reviewed and approved by our IRB. Participants arrived and signed a consent form which explained what data would be collected and what their task for the session would be. Next, study facilitators attempted to set up the eye tracking device. Participants then completed an in-game tutorial which taught them how to query the system for suggested compounds and fit compounds into a spectrum to solve the puzzle. During this tutorial period, participants could ask for as much help as they needed from study facilitators to feel comfortable. When the tutorial finished, participants were given an additional tip-sheet which reminded them of how to use game controls and provided some basic strategies for solving complicated puzzles. Participants were then directed to play the game for the entire 3 hour session. Because we hypothesized that taking breaks related to cognitive depletion, we instructed them that they could take breaks whenever they chose, but we neither encouraged nor discouraged the users to take breaks. A study facilitator was present for the entire session and collected observational data by hand.
\subsection{Data Collection}
The game participants played automatically collected event information as the participants interacted with it. From this data, we have information about how many puzzles participants solved, how many compounds were in each puzzle (which refer to difficulty levels), and click data representing participant interactions with controls. We also collected timing information about how long it took for each puzzle to be solved through this game log. A Tobii Glasses 2 Eye Tracker~\footnote{http://www.tobiipro.com/product-listing/tobii-pro-glasses-2/} was used to collect eye movement, accelerometers, pupil dilation, and fixation data. We could not calibrate the eye tracker and collect eye-tracking data on 6 of the 9 participants who wore glasses. For these 6 participants, we rely on event log and observational notes to capture activity during the session. The eye tracker was turned off when participants took breaks so that they could leave to use the restroom and then re-calibrated upon their return from break. Study facilitators used a predetermined coding scheme to capture the symptoms observed during the session as well as general notes about the session such as errors encountered, break times, and any interrupting factors. To account for differences in timing devices and the reaction-time of study facilitators, the observed time of each symptom was recorded at the minute level.
After the study, for data reliability, four people (including two study facilitators and two researchers) looked into the logs and made sure that all the symptoms were all correctly and consistently annotated based on the symptom descriptions.
\section{Results}
\subsection{Study Engagement}
\begin{table}[t]
\centering
\footnotesize
\begin{tabular}{p{0.8cm} | p{0.7cm} | p{0.7cm} | p{1cm} | p{0.8cm} | p{0.8cm}}
\hline
\bf Parti-cipant & \bf Avg. Difficulty & \bf \# Completions & \bf \# Skips & \bf Score & \bf Break \\ \hline
P1 & 2.35 & 90 & 5 & 273K & Yes \\
P2 & 3.48 & 23 & 0 & 431K & No \\
P3 & 1.97 & 169 & 4 & 778K & Yes \\
P4 & 3.63 & 35 & 3 & 578K & Yes \\
P5 & 1.81 & 127 & 3 & 501K & Yes \\
P6 & 2.76 & 95 & 10 & 1.1M & Yes \\
P7 & 3.58 & 29 & 1 & 581K & Yes \\
P8 & 3.60 & 45 & 0 & 767K & No \\
P9 & 4.10 & 49 & 0 & 1.4M & Yes \\
P10 & 2.30 & 62 & 10 & 160K & Yes \\
P11 & 4.58 & 61 & 0 & 2.8M & No \\
P12 & 2.55 & 78 & 2 & 331K & Yes \\
P13 & 1.00 & 39 & 2 & 37K & Yes \\
P14 & 3.79 & 22 & 1 & 425K & Yes \\
P15 & 1.01 & 226 & 18 & 221K & Yes \\
P16 & 3.05 & 41 & 2 & 555K & No \\
P17 & 3.78 & 31 & 2 & 626K & Yes \\
P18 & 4.42 & 28 & 0 & 799K & No \\
P19 & 2.13 & 18 & 5 & 51K & Yes \\ \hline
\end{tabular}
\caption{Summary of task engagement by participants. Five participants did not take a break during the study. Participants who did not take a break completed more difficult tasks and less skipped than those who took a break (p$<$.05).}
\label{tab:summary_participant}
\end{table}
A total of 19 participants engaged in the study differently with respect to average level of task difficulty, the number of trials and completions, the number of skips, total game score, and break (Table~\ref{tab:summary_participant}). Each participant showed different degrees of engagement but we found some correlations among the variables. Participants who worked at higher difficulty levels solved and skipped fewer puzzles ($p<$.05) but also spent more time on these difficult puzzles and so attempted fewer. We consider a break as variable and found that participants who did not take a break completed more difficult tasks, higher scores, and had less skips than those who took a break ($p<$.05).
We were interested in which types of symptoms and how much of each appeared in general. In addition, as we found different activity levels between the non-break and break groups, we decided to look into symptoms at the group level. \emph{We did not find any differences in symptoms between difficulty levels.}
In the following subsections, we will first summarize 14 symptoms identified in the study and then report characteristics of the symptoms from all participants as a whole and at the group level.
\subsection{Observed Symptoms}
Symptoms were collected through observations and cross-checked with inter-rater agreement, game event logs, and eye tracking data when possible (the eye tracker would not calibrate on 5 participants). Symptoms in our study were operationalized as follows:
\begin{itemize}
\item \textit{Distraction} (D, appeared 17 times) was recorded when participants showed signs of attending to stimuli that did not come from the Apto game environment. This included briefly re-orienting towards hallway noise, diverting attention to their cell phone if it rang, etc.
\item \textit{Inattention} (I, N=30) was typically characterized as a participants lack of correction of errors: i.e. some participants picked poorly fitting compounds which caused them to lose points, however eye tracking data confirms they did not always look at their score to pay attention to the effects of their actions.
\item \textit{Increased decision time} (IDT, N=73) and \textit{Lack of advancement/progress} (LAP) were both judged based on the time it took a participant to take an action and complete a puzzle relative to their performance during the rest of the session. Participants who took longer than usual to make a single decision were noted for IDT. Participants who took longer than usual to solve a puzzle or never attempted puzzles of higher levels were noted for LAP.
\item \textit{Data/Command errors} (DCE, N=34) manifest as actions which were immediately undone and followed by a nearly identical action with preferred outcome (frequently paired with a audible ''Oops'').
\item \textit{Increased Negative Affect} (INA, N=44) was recorded when participants verbal expressed emotional states such as frustration or impatience (''I'm still at 96\%? This is so frustrating!'').
\item \textit{Physical effects} (PE, N=251) were the easiest symptoms for observers to confirm as they included events such as fidgeting and posture changes. The study protocol did not request or encourage a ''talk-aloud'' protocol so participants who chose to speak were often expressing confusion (''I don't know why that happened''), forgetfulness (''How do I scroll again?''), distraction(''The browser is running very slow''), effort/risk over/under estimation (''This is a tough one!''), negative affect (''This [puzzle] is taking forever''),or task-unrelated-thoughts (''I'm glad I participated today, this study is interesting!''). These verbalizations were not counted as PE.
\item \textit{Confusion} (C, N=27) was typically noted through verbalizations such as "I don't understand" or "What did I just do?".
\item \textit{Effort/Risk Over/Under Estimation} (ERE, N=6) manifested as level-increase actions followed by quick task abandonment and level decreases or verbalizations such as "This is harder than I thought!" and "Level 5 is much harder than it looks."
\item \textit{Forgetting} (F, N=21) is indicated by participants asking study facilitators to repeat instructions covered in the tutorial or re-reading the tip sheet multiple times. In one case, a participant asked for scratch paper to use as a memory aid to write down the names of compounds she had looked at in solving a puzzle.
\item \textit{Strategy inefficiency} (STI, N=53) typically manifest as a lack of help-line use: some participants manually searched for incomplete puzzle pieces instead of using the error or difference lines explicitly described in the tip-sheet.
\item \textit{Task abandonment} (TA, N=62) was recorded as use of the game's 'skip puzzle' button.
\item \textit{Task Rushing} (TR, N=33) is similar to IDT in that it represents a deviation from some baseline-level of participant actions. In the case of TR, this is a pace beyond what would be expected from experience and naturally improved skill. TR will likely manifest with DCE and I: participants rushing through a task make mistakes but do not correct them right away. TR also manifests as trial-and-error attempts to improve a participant's score on a puzzle (as opposed to carefully searching for a matching compound or using the error/difference/sum line tools).
\item \textit{Task Unrelated Thoughts} (TUT, N=27) were noted when participants verbalized their thoughts which had no impact at all on their puzzle solving tasks such as whether or not the random spectrum matched real-world substances ("Is this hydrogen or something?") or even what researchers did in their free time ("You mush all meet up for drinks when this is over!")
\end{itemize}
Note that this list is not meant to be exhaustive. It is an overview of the symptoms we learned about from our study. Certain symptoms suggested by related work were not expected to be seen in this study. For instance, habituation occurs when people stop reacting to important information in the form of alerts \cite{anderson2015polymorphic}. The Apto game environment has no such alerts and therefor habituation (among other real-time-response-based symptoms) would not be detected in this study.
\begin{figure}[t]
\centering
\includegraphics[width=0.4\textwidth]{Symptoms_and_Clicks.pdf}
\hspace*{.3cm}
\vspace*{-.3cm}
\caption{Correlation between the number of symptoms and clicks (normalized) in every one minute. Two variables showed a positive relationship ($r$=.23, $p<$.05).}
\label{Symptoms_clicks}
\end{figure}
\begin{table}[t]
\centering
\footnotesize
\begin{tabular}{p{1.5cm} | p{1.2cm} | p{1.3cm} | p{1.2cm} | p{1.0cm}}
\hline
\bf Participant & \bf \# Symptoms & \bf Symptom Diversity & \bf \# Co-Symptoms & \bf Break \\ \hline
P1 & 38 & 12 & 28 & Yes \\
P2 & 36 & 11 & 28 & No \\
P3 & 39 & 12 & 21 & Yes \\
P4 & 16 & 10 & 10 & Yes \\
P5 & 34 & 12 & 15 & Yes \\
P6 & 17 & 6 & 1 & Yes \\
P7 & 9 & 9 & 1 & Yes \\
P8 & 69 & 14 & 28 & No \\
P9 & 88 & 12 & 55 & Yes \\
P10 & 39 & 11 & 36 & Yes \\
P11 & 19 & 7 & 1 & No \\
P12 & 34 & 8 & 15 & Yes \\
P13 & 41 & 7 & 21 & Yes \\
P14 & 27 & 9 & 21 & Yes \\
P15 & 52 & 13 & 15 & Yes \\
P16 & 16 & 6 & 6 & No \\
P17 & 12 & 8 & 0 & Yes \\
P18 & 45 & 9 & 15 & No \\
P19 & 75 & 14 & 91 & Yes \\ \hline
\end{tabular}
\caption{Summary of the number of symptoms and diversity by participants. The number of symptoms are strongly correlated with the diversity of symptoms ($r$=.75, $p<$.001) and the number of co-symptoms ($r$=.80, $p<$.0001).}
\label{tab:summary_symptom_participant}
\end{table}
\begin{figure}[t]
\centering
\includegraphics[width=0.4\textwidth]{Symptoms_over_time.pdf}
\hspace*{.4cm}
\vspace*{.3cm}
\includegraphics[width=0.4\textwidth]{Symptoms_category_over_time.pdf}
\hspace*{.3cm}
\vspace*{-.3cm}
\caption{The number of symptoms during the study from all participants. Generally more symptoms appeared over time. For category, PED and VR increased ($p<$.05) while PJS decreased ($p<$.10) over time.}
\label{Symptoms_over_time}
\end{figure}
\subsubsection{Overall Summary}
From a total of 14 symptoms, physical effects (PE) were detected the most followed by increased decision time (IDT), increased task abandonment (ITA), etc. As shown in Table~\ref{tab:summary_symptom_participant}, more than 50\% of the participants (10) showed more than 10 symptom types. We also found that the number of symptoms was positively associated with the number of clicks, indicating that the participants tended to click more when they presented symptoms (Figure~\ref{Symptoms_clicks}).
\begin{figure}[h]
\centering
\includegraphics[width=0.45\textwidth]{Symptoms_by_Type_over_1_hour.pdf}
\vspace*{-.3cm}
\caption{The number of symptoms per participant by type over time (1 hour bin). Physical effects (PE), forgetting (F), inattention (I), and task rush (TR) generally increased whereas strategy inefficiency (STI) and task abandonment (TA) decreased over time.}
\label{symptoms_by_type_over_time_5}
\end{figure}
The number of symptoms generally increased over time (Figure~\ref{Symptoms_over_time}). We saw the significant drop at the end of the study. When we saw the results at the group level, PED and VR were found to be increased and PJS was decreased over time. As the participants progressed the study, it seems that they showed less task-related judgement symptoms but showed more physical and emotional symptoms. As shown in Figure~\ref{symptoms_by_type_over_time_5}, each symptom shows a different distribution over time. Linear regression results showed statistically significant increases in physical effects (PE) and inattention (I) and significant decreases in strategy inefficiency (STI) at $p<$.05. Given the length of the user study (3 hours), an increase in fatigue or decrease in concentration could contribute to PE and I. Learning effects could contribute to a decrease in STI because it is more pertinent to task efficiency. Although not statistically significant, TA generally decreased over time, also possibly due to a learning effect.
\begin{figure}[t]
\centering
\includegraphics[width=0.40\textwidth]{Symptoms_Sequence.pdf}
\vspace*{-.3cm}
\caption{Two symptoms sequentially shown within one minute. A great number of symptoms occurred with others (64\%).}
\label{Symptoms_sequence}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[width=0.4\textwidth]{Symptoms_CoSymptoms.pdf}
\hspace*{.7cm}
\vspace*{-.3cm}
\caption{Percentages of symptoms occurred with other symptoms. Four symptoms (i.e., TA, INA, TR, and I) are most likely to show together with other symptoms (especially TA, INA, and I showed 100\% co-occurrence), whereas PE is relatively independent.}
\label{Symptoms_CoSymptoms}
\end{figure}
We also considered a possibility of two symptoms' appearing together or sequentially. Our observation logs indicated that there were lists of symptoms which together in the same one-minute window. We measured symptom pairs and their frequency. Out of 706 individual observations, a total of 456 symptoms in 62 groups of two symptoms (64\%) were identified.
Figure~\ref{Symptoms_sequence} illustrates the results. As PE occurred the most during the study, it occurred together with many other symptoms. The symptom group with the top two symptoms showed the highest count. Figure~\ref{Symptoms_CoSymptoms} presents another aspect of co-occurrence. We measured the percentage of co-occurrence from the total number of occurrences for each symptom. Although the raw number of co-occurrences for PE was the largest, when it comes to percentage, it showed lower than 50\%. This indicates that PE also occurs independently and individually. This result applies to IDT (51\%) as well. In addition, TA, INA, TR, and I exhibited very high percentages (especially TA, INA, and I showed 100\%), indicating that these are the symptoms that could entail or be led by other symptoms.
\begin{figure}[t]
\centering
\includegraphics[width=0.45\textwidth]{Symptoms_by_participant_over_tme.pdf}
\vspace*{-.3cm}
\caption{Percentage of symptoms in 10-minute bin for participants. Numbers on the right y-axis indicate total symptom counts. The first 14 participants were the ones who took break(s). Red arrow represents break. 6 participants (P1, P3, P9, P10, P15, P19) showed more than the average of symptoms at the same time slot or one time slot before the break. No symptom appeared during the same time slot after the break. The last 5 participants did not take a break.}
\label{symptoms_by_participant_over_time}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=0.42\textwidth]{Symptoms_by_Type_over_1_hour_break.pdf}
\includegraphics[width=0.42\textwidth]{Symptoms_by_Type_over_1_hour_no_break.pdf}
\caption{Number of symptoms per participant (average) for the break (top) and non-break groups (bottom). Participants in the break group showed an overall increase in F, I, IDT, and PE, and decrease in C and STI. Participants in the non-break group showed an overall increase in I, PE, and TR, and decrease in STI and TA. Interestingly, the non-break group showed a great level of PE.}
\label{Symptoms_by_type_over_time_5_break_non_break}
\end{figure}
\subsubsection{Symptoms by Participant and Break Group}
We now switch our focus to the results by an individual level and a group level. We had two user groups (i.e., break and non-break groups) for the analysis. Table~\ref{tab:summary_symptom_participant} summarizes the number of symptoms, symptom diversity, and co-symptoms which appeared in one minute (Figure~\ref{Symptoms_CoSymptoms}) by each participant. The number of symptoms is strongly correlated to symptom diversity ($r$=.75, $p<$.001) and the number of co-symptoms ($r$=.80, $p<$.0001). However there was no significant difference between break and non-break groups.
Figure~\ref{symptoms_by_participant_over_time} illustrates the number of symptoms from each participant (clustered into either a break or non-break group) over time (5-minute bin). Red arrows represent breaks. Note that the break was found to be the last event of each time slot. We confirmed that no symptom appeared after the break for all participants. The results indicate that for quite a few participants (i.e., P1, P3, P9, P10, P15, P19) in the break group, the number of symptoms appeared at the same time of the break or one time slot before the break was above the average.
\begin{figure}[t]
\centering
\includegraphics[width=0.40\textwidth]{Symptom_diff_before_after_break_2.pdf}
\vspace*{-.3cm}
\caption{Difference in symptom percentage between 10 minute before and after break. Especially, physical effects (PE), increased decision time (IDT), task abandonment (TA), increased negative affect (INA), and confusion (C) appeared more before the break.}
\label{Symptom_diff_before_after_break}
\end{figure}
Figure~\ref{Symptoms_by_type_over_time_5_break_non_break} shows a variance of each symptom by the break and non-break groups. On the one hand, the break group showed the results that were quite consistent with the ones from all participants (see Figure~\ref{symptoms_by_type_over_time_5}). F, I, IDT, and PE generally increased while C and STI decreased. On the other hand, for the non-break group three symptoms (i.e., I, PE, and TR) increased and other three symptoms (i.e., STI, TA, and TUT) decreased. Especially for TA and TUT, two groups showed quite opposite results. It appears that the participants in the break group tended to be less focused than those in the non-break group. Another interesting finding is that the non-break group showed more PE than the break group.
We were interested in the effects of breaks and investigated the differences in the types and frequencies of symptoms during the 10 minutes before and the 10 minutes after breaks. Figure~\ref{Symptom_diff_before_after_break} showed several interesting insights. First, PE, C, and ERE appeared more before the break. PE appeared 17 times more before breaks, which indicates it could be a sign of one's intention to take a break. Second, for some symptoms, we found differences in frequency between their overall trends (see Figure~\ref{Symptoms_by_type_over_time_5_break_non_break}, top) and break periods. PE and IDT generally increased over time, but when it comes to the time around breaks, they appeared more before the break. TA, INA, and C appeared more before the break. Participants showed more physical effects (PE), increased decision time (IDT), task abandonment (TA), negative effects (INA), and confusion (C) before they decided to take a break. This indicates that these symptoms could be considered as possible signs of cognitive depletion and factors that could indicate that someone is in need of a break.
\begin{figure}[t]
\centering
\includegraphics[width=0.4\textwidth]{Break_group_low_performance.pdf}
\includegraphics[width=0.4\textwidth]{Break_group_high_performance.pdf}
\vspace*{-.3cm}
\caption{Difference in symptom groups between low- (top) and high (bottom) -performance break groups. The low group showed steady increases in PED and VR while the high group showed decreases from 2nd and 3rd time slots.}
\label{Symptoms_by_low_and_high_performance_group}
\end{figure}
Our last investigation in this section was looking into the participants in the break group. In the previous section, we showed generally lower performance by the break group than the non-break group. However we realized that some participants actually showed good performance and engagement (e.g., P6, P8). Thus, we measured differences in symptoms between two groups of participants based on their performance. We used the median of the scores to have the high and low groups (7 participants were assigned to each group). Figure~\ref{Symptoms_by_low_and_high_performance_group} shows the results. Both the low and high groups showed a decrease in PJS; however, showed different results in PED and VR. This low group still showed increases in PED and VR even they took breaks during the study.
\subsubsection{Symptoms with Eye-Tracking Data}
\begin{figure}[t]
\centering
\includegraphics[width=0.40\textwidth]{P16_P23_and_Others.pdf}
\vspace*{-.3cm}
\caption{Difference in the level of activity and participation between P13 and P19 (who showed the positive relationship between pupil dilation and symptom frequency), and the rest of the participants. Both P13 and P19 worked primarily on low-level tasks, had significantly fewer task trials, more symptoms, and lower game scores. This clearly indicates the effect of cognitive loads and depletion on task performance. Red cross mark indicates an outlier.}
\label{P16_P23_and_Others}
\end{figure}
Our last investigation was to map the eye-tracking data to the observed symptoms. A pupil dilation response points to a level of emotion, arousal, stress, pain, or cognitive load of a human. In this regard, we were especially interested in the relationship between pupil dilation and the number of symptoms both by an individual level and a group level. For the group level, Spearman's correlation results (which is a nonparametric measure of the strength and direction of association) show that both break and non-break groups did not show any significant difference in pupil dilation.
However, when looking into individual differences, we found that two participants from the break group showed significantly positive relationships (P13: $\rho$=0.28, $p<$0.05; P19: $\rho$=0.23, $p<$0.05), meaning that more symptoms appeared as the average of the pupil dilation increased. We took a look at them more closely. It turned out that P13 and P19 were in the break group and also showed the lowest performance and least engagement during the study. As shown in Figure~\ref{P16_P23_and_Others}, these two participants worked primarily on low level (easy) tasks, had significantly fewer task trials, more symptoms, and lower game scores compared to the rest of the participants. This demonstrates the effect of cognitive loads and loss of concentration well but it is unclear why these two participants were affected more than others.
\section{Discussion}
We gained a number of insights from this study. Firstly, while the total number of symptoms tended to increase over time, individual symptoms varied. Physical effects (PE), forgetting (F), inattention (I), and task rushing (TR) generally increased, whereas strategy inefficiency (STI) and task abandonment (TA) decreased over time. At the higher symptom-group level, physical and emotional deregulation (PED), and vigilance and reactionary symptoms (VR) increased, whereas personal judgement symptoms (PJS) decreased over time. This result is likely due to learning effects: as participants gained familiarity over the course of the three hour study, they became more confident in completing puzzles and had developed the most efficient strategies for doing so. But even as participants learned, cognitive depletion produced other effects to make them appear restless and impatient.
The number of symptoms and that of clicks are positively correlated, which indicates that a degree of clicks could be used as a signal of symptoms. Future work will verify this result and investigate how click behavior might be used as a metric of cognitive depletion. An increase in symptoms seems to be a predictor of a break. Six participants (P1, P3, P9, P10, P15, P19) in the break group showed an above average number of symptoms at the same time as a break or one time slot before a break. This gives us an opportunity to provide systematic support (e.g., encouraging users to take a short break) to individuals when they show more symptoms over time. Particularly, some symptoms (e.g., PE, IDT, TA, INA, C) appeared more before the break compared to after breaks.
Although in general both the break and non-break groups showed similar patterns of symptoms over time, TA and TUT were found to be quite different between the groups. It appears that the participants in the break group tended to be less focused than those in the non-break group. We identified additional two sub-break groups based on their performance. It turned out that the low performance group still showed an increase in PED and VR, whereas the high performance group showed a decrease. Systematic supports or suggestions could be applied to people in the low performance group to lower cognitive depletion and recover concentration.
\subsection{Limitations and Future Work}
Although our study gives us a number of interesting insights, there exist some limitations which we believe will be addressed in our future study. First, our findings may not be generalizable due to small sample size. Results could also be sensitive on other characteristics of individuals like their experience and expertise in using computer systems, concentration levels, work strategies, etc. We plan to conduct a more refined user study with more participants, and one of our focuses will be to see repeatability of the results.
Second, although we were confident that symptoms were correctly detected during the study, we also acknowledge that human errors and bias may exist. Presumably, some symptoms were easy to detect (e.g., most people would easily identify yawning) while others might be more difficult. We believe that symptoms would be better detected and understood by combining system usage logs and human annotations, which will be a primary method in our future study.
Lastly, expanding the second point, cognitive depletion may manifest in more ways than the 14 symptoms observed in our study. For example, in many real scenarios, people sometimes work on multiple tasks. A cognitive depleted person may attempt to unnecessarily complete multiple tasks at once, increase the number of simultaneous tasks they attempt, switch between concurrent tasks more frequently, or make mid-progress switches between tasks more often \cite{dabbish2011keep,lottridge2015effects}. Moreover, a cognitively depleted person's strategy for handling pushed information (e.g., emails, updates, text messages, phone calls, etc.) will fail and become unable to continue tasks. Our current protocol and study environment was not designed to produce these conditions or provide an opportunity for related symptoms to be observed.
\section{Conclusion}
This paper presents the results of a three hour user study designed to induce cognitive depletion in 19 participants. Through the collection of different datasets including activity logs, observations, and eye-tracking data and through the individual and group-level analyses, we have gained insight into how cognitive depletion manifests in novice NMR analysts. Our work provides early insights into cognitive depletion in human computation and addresses future research implications of the findings. Future work will focus on repeatability of these results, building models that will predict cognitive status and depletion, and introducing interventions target to relieve cognitive depletion and improve overall task performance.
\bibliographystyle{aaai}
| {'timestamp': '2017-06-08T02:01:05', 'yymm': '1706', 'arxiv_id': '1706.01919', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01919'} | arxiv |
\section{Dataset}
\label{sec:data}
To analyze password usage across services, we gathered a
large collection of publicly available password datasets. In January
2017, we searched through online forums and public
data archives for candidate datasets using two criteria. First, the dataset
should contain email addresses to link a user's passwords
across services. Second, we exclude datasets with only {\em salted hashes} since
it is difficult to massively recover their passwords.
We collected 107 datasets leaked between 2008--2016, which contain 497,789,976 passwords and
428,199,842 unique users (email addresses). 14 datasets contain hashed
passwords, and we spent a week to recover the
plaintext using offline guessing tools~\cite{JtR, ur2015,
pars15}. In total, we obtained 460,874,306 plaintext passwords (93\% of all passwords).
The rest 7\% are difficult to recover, and we will use them
to test our guessing algorithm later. Figure~\ref{fig:size} shows the
number of passwords in each dataset. In Table~\ref{tab:cat}, we
classify the datasets into 10 categories. The ``others'' category contains 7
datasets with generic file names (difficult to label). We have made sure that the 7
datasets did not overlap with any existing ones.
\para{Primary Dataset (28.8 Million Users).} To study cross-site
password usage, we need users who appear on at least two websites.
To this end, we construct a {\em primary} dataset of 28,836,775 users
who have at least two plaintext passwords (61,552,446
passwords in total). Our analysis in the paper will focus on this
primary dataset. Note that users outside of the primary dataset are
not necessarily risk-free: they might still have accounts in services that we didn't cover.
\para{Ethic Guidelines.} Our work involves analyzing leaked datasets
that contain sensitive information. We have worked closely with our local
IRB and obtained the approval for our research. Our study is
motivated by the following considerations. First, we only analyze datasets that are already publicly
available. Analyzing such data does not add additional risks other
than what already exist. Second, these datasets
are also publicly available to potential attackers.
Failure to include the data for research may give attackers an
advantage over researchers that work on defensive
techniques. In the past decades, leaked password datasets have been
extensively used in academic
research~\cite{Ur:2015:,DasBCBW14,pars15,CarnavaletM14,VerasCT14,Wang:2016:,info16:}
to develop security mechanisms to protect users in the long run.
\section{Discussion}
After analyzing 28.8 million users' passwords across 107 services, we
find that a majority of users have reused the same password or slightly modified
an existing password for different services. Password modification
patterns are highly consistent across various user populations,
allowing attackers to crack massive passwords {\em online} with
minimal training.
Moving forward, the challenge is how to effectively mitigate the
threat after a service is breached. Given the high reuse
rate of passwords, it is necessary to immediately notify users to
reset the password, not only for the breached service but also other services with a similar
password. The question is who should play the role to notify users,
given that not all the breached services would immediately disclose
the incident or contact users~\cite{new16, new15}. In addition,
during password reset, it is critical to make sure users don't modify
the already-leaked password to create the new one. A better practice is to use
password managers ({\em e.g.}, 1Password) to set unique and
complex passwords for each service without the need to memorize
them. Finally, our result shows a concerning
high ratio of {\em email password reuse}. We argue that more specific warnings should be given
to users to avoid reusing the email password when signing up for a service.
\section{Introduction}
The widespread of data breaches ({\em e.g.}, Yahoo, Myspace,
Office of Personnel Management, Ashley Madison) are posing
significant threats to users and organizations. In
2016 alone, there were more than 2000 confirmed
breaches causing a leakage of billions of user
records~\cite{verizon17}. Many of the leaked datasets contain
sensitive information such as {\em user passwords}, which are often made publicly available on the Internet by
attackers~\cite{new11,new10,new8,new7,new9}.
A leaked password incurs serious risks if the user reuses the password
across different services. Reusing the same or even slightly
modified passwords allows attackers to further compromise the user's accounts in
other ``un-breached'' services~\cite{new13,new14}. Even worse, if the
target user happens to be the administrator of another service,
password reuse may lead to new massive data breaches ({\em e.g.},
Dropbox~\cite{new12}).
With more passwords leaked everyday~\cite{site1,site5}, there is still a
lack of large-scale quantitative understanding on password usage
across online services. Existing work studies password
reuse and transformation either through a user survey~\cite{Komanduri:2011,DasBCBW14}
or small-scale data analytics (6--7K
users)~\cite{Zhang:2010:,DasBCBW14}. The limited scope of the data
(sample size, service type, user demographics) makes it challenging to
comprehensively quantify the risks to see the bigger picture.
In this paper, we conduct a large-scale measurement on 28,836,775
users on their password reuse and modification patterns
across 107 online services.\footnote{Our study has received IRB
approval (Protocol \#17-393).}
By analyzing publicly available password datasets, we seek to
empirically measure the common ways in which users reuse/modify
passwords. In addition, to quantify the security risks introduced by
password reuse and modification, we develop a
{\em training-based} algorithm to guess a target user's
password based on her leaked one. Our study reveals several key findings.
\para{How often do users reuse or modify existing passwords? }\\
Among the 28.8 million users, we find that 38\% of users have
once reused the same password in two different services and 21\% of
the users once modified an existing password to sign up a new service.
Particularly, passwords of email services ({\em e.g.}, Gmail) have a noticeably high reuse
rate (60.4\%). Given the sensitivity of email accounts, reusing
the password of email accounts incurs serious risks.
\para{What are the common ways of modifying passwords?}\\
We empirically measure 8 high-level categories of password
transformation rules. We find that users prefer using simple rules
to modify passwords. More importantly, the password
transformation patterns are highly consistent across users of
different professions (military, government, education) and
countries. The low variance of the transformation patterns is
likely to make the modified passwords predictable.
\para{How likely can attackers guess a modified password?}\\
Our training-based algorithm can guess 30\% of the modified passwords
within 10 attempts (46.5\% within 100 attempts). Together with the
identical passwords (reused), more than 16 million
password pairs can be cracked within 10 guesses. In addition, the
algorithm achieves a similar performance even if it is trained with
only 0.1\% of the data. This confirms the low-variance of password
modification patterns, indicating that attackers can learn the basic
patterns with minimal training to crack massive passwords in an {\em
online fashion}.
This work is the first large-scale measurement on
the password reuse and modification patterns across online
services. Our result sheds light on the emerging
security threats introduced by
massive data breaches, and calls for more effective tools to secure
users' online accounts and digital assets.
\section*{Acknowledgments}
\newpage
\balance
\begin{small}
\bibliographystyle{acm}
\section{Related Work}
\label{sec:related}
\para{Password Reuse \& Transformation.}
Password guessing attacks become a major concern as data breaches are
increasingly frequent. The attack is immediately
effective if the user reuses {\em the same} password for
different services~\cite{www07pass,Bailey2014}. Even if non-identical
passwords are used, users may follow simple transformation patterns
to modify their passwords, which makes their
passwords predicable~\cite{DasBCBW14,Zhang:2010:}. Existing work
investigated this problem based on
user surveys or small-scale data analytics (6--7K
users)~\cite{DasBCBW14,Zhang:2010:,Komanduri:2011,197316}. In this work, we
perform the first a large-scale measurement to understand cross-site password
usage and quantify the risk of leaked passwords (28.8 million users, 107 websites).
\para{Online \& Offline Password Guessing.}
Online password guessing requires attackers to guess the password within a
limited number of attempts. Trawling based approach simply guesses
the most popular passwords chosen by users~\cite{Mazurek:2013:}.
More targeted guessing exploits the fact that users may reuse the
same/similar passwords across services~\cite{DasBCBW14,Zhang:2010:} or
include PII information (name, birthday) in their
passwords~\cite{Wang:2016:,info16:}.
A larger body of work focuses on offline
guessing~\cite{pars15,ur2016,VerasCT14, Weir:2009:PCU,
KelleyOakland2012, password15, Narayanan:2005}, where the number of
attempts is unlimited. A common scenario is that given a hashed
password dataset, offline guessing seeks to recover the
plaintext passwords. A number of approaches have been proposed,
including Markov Models~\cite{Narayanan:2005, Ma:2014:SPP:}, Mangled
Wordlist methods~\cite{ur2015}, Probabilistic
Context-Free Grammars
(PCFGs)~\cite{Weir:2009:PCU,KelleyOakland2012,VerasCT14,Narayanan:2005},
and Neural Networks~\cite{ur2016}. Offline guessing has also been used to
measure password strength~\cite{Ur:2012:YPM:,CarnavaletM14,pars15}.
\section{Password Reuse Across Services}
\label{sec:reuse}
We start by analyzing how often users reuse {\em exactly the same}
password for different services. Out of the 28.8 million users in the
primary dataset, we extract 37,301,406 password pairs where both
passwords are from the same user. If a user has more than two
passwords, then all possible pairs are considered ({\em e.g.}, 4
passwords means 6 pairs). We find that 34.3\% of the pairs are
identical pairs. At the user level, 38\% of the users (10.9 million)
have at least one identical pair, indicating that the user
sets the same password for different services. This ratio is slightly lower than
the self-reported result (51\%) from a user study~\cite{DasBCBW14}.
Next, we are curious whether users with more passwords are more likely to
reuse the same password. The intuition is that it is difficult to
memorize many completely different passwords. Our result in
Table~\ref{tab:pwreuse} shows that this hypothesis
is true for users with less than 5 passwords.
However, the trend is reversed for users
with even more passwords. A careful examination
shows that users with more passwords are more likely to ``modify''
an existing password for new services. Based on the results in
\S\ref{sec:rule}, users with more than 4 passwords have a higher
chance of modifying existing passwords (64.0\%)
compared with the overall ratio (21.0\%).
As a case study, we specifically analyze the passwords for ``email''
services. Email accounts are sensitive due to the fact that emails can be used to
reset the password for various online services. Many online
accounts will be in danger if the user's email account is compromised.
As shown in Table~\ref{tab:cat}, we have 3
leaked email datasets from {\tt Gmail}, {\tt Mail.ru} and
{\tt Yandex}. We identify 4,033,847 password
pairs (involving 3 million users) that contain an email password. We find
that 2,440,232 of the pairs are identical, which yields a much higher
reuse ratio (60.4\%) than the overall ratio (34.3\%). This indicates
users are more likely to use their email password for another
service, a practice that incurs serious risks.
\begin{table}[t]
\centering
\begin{small}
\begin{tabu}{l|l|r}
\tabucline[1.1pt]{-}
\#PWs per User & \# of Users & \% of Users w/ PW Reuse \\
\hline
2 & 25,515,516 & 34.6\% \\
3 & 2,877,322 & 63.4\% \\
4 & 370,990 & {\bf 78.8\%} \\
5 & 54,258 & 74.6\% \\
6 & 11,112 & 51.5\% \\
7 & 3,701 & 29.6\% \\
$\geq$ 8 & 3,876 & 22.6\% \\
\tabucline[1.1pt]{-}
\end{tabu}
\vspace{-0.12in}
\caption{Password reuse rate vs. \# of passwords per user. }
\label{tab:pwreuse}
\end{small}
\vspace{-0.12in}
\end{table}
\section{Password Transformation}
\label{sec:rule}
In addition to reusing the same password, users may also modify an
existing password when signing up for a new service.
Given a password pair of the same user, our goal is to infer the ``transformation rule''
(it there is one) that the user follows to modify the password. Then, we
seek to understand how much the transformation patterns differ across
users from different demographics.
\subsection{Transformation Rules}
Our measurement workflow is shown in Figure~\ref{fig:flow}. In total,
we construct 8 rules for password transformation based on our manual
examinations of 1000 random password pairs and results from prior
studies~\cite{DasBCBW14,Zhang:2010:,7487945}. We test these rules against the
password pairs in the {\em primary dataset}, and the results are shown
in Table~\ref{tab:rulefound}.
The majority of the password pairs (55.6\%) can be explained by one of
the transformation rules. To translate the numbers to the user level, 38\% of the users have reused the
same password at least once, and 21\% of the users have once
modified an existing password to create a new one. Collectively, these
users count for 52\%. The rest 48\% of the users are likely
to create a new password from scratch for each service.
Below, we discuss each rule in details and further analyze the
unmatched passwords.
\begin{table}[t]
\begin{small}
\centering
\begin{tabu}{l|l|l}
\tabucline[1.1pt]{-}
Rule & \# Pairs of Passwords & Ratio (\%) \\
\hline
\ding{202}. Identical & 12,780,722 & 34.3\%\\
\ding{203}. Substring & 3,748,258 & 10.0\% \\
\ding{204}. Capitalization & 478,233 & 1.3\% \\
\ding{205}. Leet & 93,418 & 0.3\% \\
\ding{206}. Reversal & 5,938 & < 0.1\% \\
\ding{207}. Sequential keys & 12,118 & < 0.1\% \\
\ding{208}. Common Substring & 2,103,888 & 5.7\% \\
\ding{189}. Combination of Rules & 754,393 & 2.0\%\\
\hline
Can Not Find A Rule & 17,324,438 & 46.4\% \\
\hline
Total & 37,301,406 &100\% \\
\tabucline[1.1pt]{-}
\end{tabu}
\vspace{-0.07in}
\caption{Distribution of password transformation rules.}
\vspace{-0.2in}
\label{tab:rulefound}
\end{small}
\end{table}
\para{Identical.} The most common rule is reusing the same password
(12 million password pairs, 34.3\%).
\para{Substring.} This rule indicates that one password is a substring
of the other one ({\em e.g.}, {\tt abc} and {\tt abc12}). This rule
matches 3.7 million password pairs (10\%), indicating that users have
inserted/deleted a string to/from an existing password to make a
new one. As shown in Table~\ref{tab:substring}, most
insertions/deletions happened at the tail (87.2\%). Most inserted/deleted
strings are pure digits (74\%) and short (1--2 characters), {\em
e.g.}, ``{\tt 1}'', ``{\tt 2}'', and ``{\tt 12}''.
\para{Capitalization.} Users may simply capitalize certain letters in
a password. Even though the ratio of matched pairs is not high (1.3\%), the
absolute number is still significant (478,233 pairs). We observe
that users commonly capitalize letters in the beginning of the password
(73\%), particularly the first letter (68.6\%).
\para{Leet.} 93,418 password pairs match the leet
rule (0.3\%)~\cite{leet}. Leet transformation refers to replacing certain characters
with other similar-looking ones.
Our analysis shows the top 10 most common transformations are: {\tt
0}\ding{214}{\tt o}, {\tt 1}\ding{214}{\tt i}, {\tt 3}\ding{214}{\tt e},
{\tt 4}\ding{214}{\tt a}, {\tt 1}\ding{214}{\tt !}, {\tt 1}\ding{214}{\tt l}, {\tt
5}\ding{214}{\tt s}, {\tt @}\ding{214}{\tt a}, {\tt 9}\ding{214}{\tt 6}, and {\tt
\$}\ding{214}{\tt s}. These 10 transformations already cover 96.6\% of
the leet pairs.
\begin{table}[t]
\begin{small}
\centering
\begin{tabu}{lr|lr}
\tabucline[1.1pt]{-}
Insert/Delete Position & Ratio &Inserted/Deleted Length & Ratio \\
\hline
Tail & 87.2\% & 1 & 48.3\% \\
Head & 11.0\% &2 & 28.0\%\\
Both Ends & 1.8\% & 3+ & 23.7\% \\
\tabucline[1.1pt]{-}
Insert/Delete Type & Ratio & Top Inserted/Deleted Str. & Ratio \\
\hline
Digit & 74.0\% & ``{\tt 1}'' & 24.2\%\\
Letter & 17.8\% & ``{\tt 2}'' & 4.0\%\\
Combined & 4.5 \% & ``{\tt 12}'' & 2.1\%\\
Special Char & 3.7\% & ``{\tt 123}'' & 1.9\%\\
\tabucline[1.1pt]{-}
\end{tabu}
\vspace{-0.07in}
\caption{Substring rule: insertion/deletion patterns.}
\vspace{-0.05in}
\label{tab:substring}
\end{small}
\end{table}
\begin{figure*}
\centering
\subfigure[Profession]{
\includegraphics[width=0.32\textwidth]{plots/example_big/bar_rule.eps}
\vspace{-0.05in}
\label{fig:p1}
\vspace{-0.08in}
}
\hfill
\subfigure[Country]{
\includegraphics[width=0.64\textwidth]{plots/example_big/bar_rule_country.eps}
\vspace{-0.05in}
\label{fig:p2}
\vspace{-0.08in}
}
\vspace{-0.05in}
\caption{Distribution of password transformation rules for users
of different professions and countries.
}
\vspace{-0.05in}
\label{fig:pattern}
\end{figure*}
\para{Reversal.} Reversal rule is rarely used (5938
pairs, $<$0.1\%), which means reversing the order of the
characters in a password, {\em e.g.}, {\tt abcd}\ding{214}{\tt
dcba}. Intuitively, reversed password is hard to memorize.
\para{Sequential Keys.} Sequential keys include alphabetically-ordered letters ({\tt abcd}), sequential numbers ({\tt
1234}) and adjacent keys on the keyboard ({\tt qwert}, {\tt asdfg}, {\tt
!@\#\$\%}). The matched pairs ({\em i.e.}, both passwords are
sequential keys) are also below 0.1\%.
\begin{table}[t]
\begin{small}
\centering
\begin{tabu}{lr|lr}
\tabucline[1.1pt]{-}
Longest Comm. Substring & Ratio & Transformation Rules & Ratio \\
\hline
Letter & 63.8\% & Substitution &84.7\% \\
Digit & 22.0\% & Insertion/Deletion & 32.4\% \\
Combined & 13.7\% & Capitalization & 3.2\% \\
Special Char & 0.5\% & Switching Order & 2.2\% \\
\tabucline[1.1pt]{-}
\end{tabu}
\vspace{-0.07in}
\caption{Common substring rule: longest common
substring and transformation patterns.}
\vspace{-0.15in}
\label{tab:comm}
\end{small}
\end{table}
\para{Common Substrings.} When a user modifies an existing
password to create a new one, we assume the majority of the password
remains the same. As shown in Figure~\ref{fig:flow}, we extract the
longest common substrings from the two passwords to learn how they transform
the rest parts. To avoid accidental character overlaps, we require the longest common
string to be $>$2 characters, and all the common
substrings should cover $>$50\% characters of a password
({\em i.e.}, the majority).
This rule matches 2.1 million password pairs (5.7\%).
To make sure the thresholds make sense, we manually examine a random
sample of 1000 matched pairs. 44 pairs look like to have accidental
overlaps, which projects a false positive rate of 4.4\%. We can
tolerate false negatives for now since we have one more rule left.
Based on the false positive rate, we estimate that the common substring rule should
count for at least 5.4\% of all password pairs.
Table~\ref{tab:comm} shows that the longest common substrings are often
pure letters (63.8\%) or pure digits (22\%). 56.7\% of the pure-letter
strings are English words/names (based on NLTK
corpus~\cite{Bird:2009:NLP:1717171}). Table~\ref{tab:comm} also shows
the typical transformations. Note that one password pair
may have multiple transformations (total exceeds 100\%).
\begin{table}[t]
\begin{small}
\centering
\begin{tabu}{lr|lr}
\tabucline[1.1pt]{-}
Rule Combination & Ratio & Rule Combination & Ratio \\
\hline
Capitalization+Substring & 26.2\% &Reversal+CSS & 6.1\% \\
Leet+CSS & 21.8\% & Leet+SubString& 5.6\% \\
Seqkey+CSS & 13.2\% & Seqkey+SubString & 4.2\% \\
Reversal+Leet+CSS & 7.1\% &Seqkey+Leet+CSS & 2.9\% \\
Capitalization+CSS & 6.2\% & Others & 6.8\% \\
\tabucline[1.1pt]{-}
\end{tabu}
\vspace{-0.07in}
\caption{Rule combinations (CSS: Common SubString).}
\vspace{-0.05in}
\label{tab:comb}
\end{small}
\end{table}
\para{Combination of Rules.} As a final step, we combine possible rules
to find a match. Note that rule3--6 modify the characters (or the
sequence) in a password, while rule2 and rule7 operate on substrings.
Our approach is to use a combination of rule3--6 to modify the
password first, and then test if rule2 or rule7 can declare a match.
In this way, we further matched another 754,000+ pairs
(2.0\%). Table~\ref{tab:comb} shows the most common ways of combining rules.
\para{Unmatched Password Pairs.} After testing all the above rules, there
are 46.4\% of password pairs remain unmatched. To make sure we did not
miss any major rules, we randomly sample 1000 unmatched pairs for
manual examination. We did not find any password pair that still
exhibited a meaningful transformation. We regard the 46.4\% of
password pairs as the result of users ``making new passwords from scratch''.
\subsection{Impact of User Demographics}
Next, we seek to understand how much the transformation patterns differ across
different user demographics. We infer user demographics from their email addresses.
\para{Profession.} Certain email domains are exclusive to people of
special organizations. For example, ``{\tt .edu}'' is limited to higher educational
institutions, ``{\tt .mil} '' is exclusively to military, and ``{\tt
.gov}'' represents government agencies. In total, we identify
128,036 users from educational institutions, 7,376 users from military,
and 3,384 users from the government. As shown in Figure~\ref{fig:p1},
we find that their password transformation patterns are
surprisingly consistently: about 30\% password pairs are identical,
followed by those that apply the substring rule (about 10\%), common
substring rule (about 5\%) and capitalization rule (about 3\%). Rules
such as leet, reversal and sequential key are consistently below 1\%.
\para{Country.} Similar results are observed in Figure~\ref{fig:p2},
where we divide users based on their countries. More specifically, we
identify email domains that contain a country code ({\em e.g.}, ``{\tt
.ru}'' stands for Russia). This returns 233 country codes and
5,892,528 users. In Figure~\ref{fig:p2}, we plot the distributions of the transformation rules for
the top 10 countries (counting for 90.5\% of the users with a
country code). Again, the transformation patterns are very similar for
users from different countries.
Our result demonstrates a high-level of consistency (low
variance) for password transformation patterns across different user
populations. This, however, could make the attacker's job
easier. Even using a small dataset, it is possible for the attacker to
learn the basic transformation patterns that apply to broader user
populations. In the next section, we develop a {\em
training-based} algorithm to validate this hypothesis.
\section{Password Guessing}
\label{sec:guess}
Based on the measurement results, we then evaluate the security risks
introduce by users modifying an existing password for different
services. We perform password guessing experiments using a {\em
training-based} algorithm to answer two key
questions: First, how quickly can attackers guess a modified password
based on a known one? Second, given the low variance of
password transformation patterns, can attackers use a small training
data ({\em e.g.}, 0.1\%) to achieve effective guessing?
\subsection{Guessing Algorithm}
We build a new password guessing algorithm by addressing the
weaknesses in DBCBW~\cite{DasBCBW14}. DBCBW is a popular algorithm to
guess a target user's password by transforming a known password of the
same user. DBCBW's design goal is simplicity, but has two weaknesses: First, due
to the lack of training data, the algorithm uses hand-crafted
transformation rules. Second, it applies these rules in a
{\em fixed order}, which may not be optimal for individual
passwords. For example, ``{\tt l0ve}'' should try the leet rule first ({\tt
0}\ding{213}{\tt o}), even though the substring rule is overall more
popular.
Our algorithm overcomes these drawbacks by introducing a training phase. Using
ground-truth password pairs as the training data, we learn two
things: (1) the transformation procedure for each rule, and (2) a
model to customize the ordering of the rules for each password.
\para{Training: Transformation Procedures. } For each rule $R_i$, we seek
to learn a list of password transformations $T_i=[t_{i1}, t_{i2}, ... t_{iN_i}]$ where
$t_{ij}$ represent one transformation under this rule. $T_i$ is sorted by
the frequency of each transformation's appearance in the training
dataset. During password guessing, we will test each transformation
{\em independently}. For example, in the ``substring rule'', $t$ is characterized by
{\em <insert/delete><position><string>}. In ``capitalization
rule'', $t$ is characterized by {\em <position><\#chars>}. In a
similar way, we learn the transformation list $T$ for ``leet'', ``sequential keys''
and ``reversal''.
Common substring rule is special. During training, we learn the
sorted transformation list (insert, delete, replace, substitute, switch orders). However, when applying
the transformation to a given password, we need to first split the password
to detect potential common substrings. In our design, we test 3 types of candidate:
(1) substrings of pure digits/letters/special characters, (2) English words/names, and (3) popular common substrings in
the {\em training data}. For the ``combined rule'', $T$ is a sorted list of
rule-combinations where each rule-combination has a sorted list of
transformations to be tested.
\begin{figure*}
\begin{minipage}{0.68\textwidth}
\centering
\subfigure[5000 Guesses]{
\includegraphics[width=0.47\textwidth]{plots/example_big/cdf_four_2000.eps}
\vspace{-0.05in}
\label{fig:g1}
\vspace{-0.08in}
}
\hfill
\subfigure[10 Guesses]{
\includegraphics[width=0.47\textwidth]{plots/example_big/cdf_four_10.eps}
\vspace{-0.05in}
\label{fig:g2}
\vspace{-0.08in}
}
\vspace{-0.16in}
\caption{Password guessing with 50\% of the data for training. }
\vspace{-0.05in}
\label{fig:guess}
\end{minipage}
\vspace{-0.03in}
\hfill
\begin{minipage}{0.31\textwidth}
\centering
\includegraphics[width=1\textwidth]{plots/example_big/cdf_train_1_50.eps}
\vspace{-0.27in}
\caption{Password guessing with different training data sizes.}
\label{fig:train}
\end{minipage}
\vspace{-0.03in}
\end{figure*}
\para{Training: Rule Ordering.} For a given password, we
learn which rule should be applied first using a Bayesian model.
We treat this as a multiple-class classification problem. Given a
password, we train a model to estimate the likelihood that the
password can be transformed by each rule. To achieve a quick training,
we choose the Naive Bayes classifier (multinomial model)~\cite{MB2008},
which produces the {\em probability} that a data point
(password) belong to a class (rule). Based on the probability, we
customize the ordering of the rules for this password.
Table~\ref{tab:feature} shows the 18 features used in the Bayesian model.
\para{Password Guessing.} For a given password pair $(pw_1, pw_2)$,
we test how many attempts are needed to guess $pw_2$ by transforming
a known $pw_1$.
We first use the Bayesian model to generate a customized order of rules for
$pw_1$. Following the ordered rule list, we have two options for guessing:
\begin{packed_itemize}
\item {\em Sequential}: testing one rule at a time. After testing
all the transformations under a rule, we move to the next
rule. Since certain rules have a significantly longer list than
others, we set a threshold $M$ as the maximum number of
guesses under each rule ($M=800$ for our experiment).
\item {\em Rotational:} testing one rule and one transformation at
a time. After testing one transformation under a rule, we move to
the next rule to test another transformation. We rotate to test each
rule for just one guess.
\end{packed_itemize}
Sequential guessing requires a higher accuracy of the predicted
order. If the predicted order is wrong, it will waste many guesses on
the wrong rule before moving on. Rotational method is more tolerable
to the prediction errors
\begin{table}[t]
\begin{small}
\centering
\begin{tabu}{l}
\tabucline[1.1pt]{-}
{\bf 18 Features Extracted from a Password} \\
\hline
PW (password) length, \# Lowercase letters, \# Uppercase letters, \#
Digits, \\
\# Special chars, Letter-only pw?, Digit-only pw?, \#
Repeated chars, \\
Max \# consec. letters, Max \# consec. digits,
Max \# sequential keys, \\
Englishword-only pw?, \# Consec. digits (head), \# Consec. digits (tail), \\
\# Consec. letters (head), \# Consec. letters (tail), \\
\# Consec. special-chars (head), \# Consec. special-chars (tail) \\
\tabucline[1.1pt]{-}
\end{tabu}
\vspace{-0.1in}
\caption{Feature list of the Bayesian model. }
\vspace{-0.15in}
\label{tab:feature}
\end{small}
\end{table}
\para{Baselines.}
We use two baselines for comparison. First, instead of customizing the
order for each password, we apply the rules with {\em a fixed order} for ``sequential
guessing'' (similar to DBCBW). The fixed order is based on the overall rule popularity in
the training data. Our second baseline is a popular off-the-shelf password
cracking tool John the Ripper (JtR)~\cite{JtR}. We use the ``single'' mode
of JtR and keep the default setting. Given a password, JtR applies a list of mangling rules to
transform the password. The guessing stops when all the mangling rules are exhaustively tested.
\subsection{Password Guessing Results}
We use the proposed algorithm to evaluate the risks of modified
passwords. For this experiment, we exclude identical password pairs
(34.3\%) since they only take one guess, and 46.4\% of pairs that
did not match a rule ({\em i.e.}, new passwords created from
scratch). This leaves us 7,196,242 password pairs that represent password
modifications ({\em exp dataset}). We conduct two experiments. First,
we split the {\em exp dataset} to use 50\% for training and the other 50\%
for testing. Second, to validate the ``low-variance''
assumption we try to use much smaller training data.
\para{Training on 50\% of the Data.} During password guessing, we test
both directions for each password pair ($pw_1$\ding{213}$pw_2$ and
$pw_2$\ding{213}$pw_1$), which doubles the testing data.
As shown in Figure~\ref{fig:guess}, our best algorithm guessed 46.5\% of the
passwords within just 100 attempts.
Figure~\ref{fig:g2} shows that 10 guesses already cracked 30\% of the passwords. In
comparison, the JtR baseline almost got nothing in the
first 10 attempts and exhausted all the mangling rules after 1081
guesses. Since we evaluate an online-guessing scenario, we stopped our
algorithm after 5000 guesses for each password.\footnote{Our experiment
shows that 50,000 guesses can crack 70\%.}
Comparing different algorithms, we show that the Bayesian
model outperforms the fixed ordering method. This confirms the
benefits to prioritize the more likely
rules for each password. In addition, rotational guessing is
better than sequential guessing. Sequential
guessing has a clear stair-step increase of the hit rate after
switching to a new rule. This indicates that the first few
transformations under each rule are the most effective ones.
Sequential guessing's advantage is in the first 5 guesses
(Figure~\ref{fig:g2}) --- if the Bayesian prediction
is correct, sticking to the right rule helped to guess the password
quicker. Rotational guessing has an overall
better performance by switching the rules more frequently.
\para{Using Smaller Training Data.} To validate the low-variance
assumption of the transformation patterns, we use even smaller
datasets to train our algorithm (Bayesian+rotational). We
vary the size of the training data from 0.01\% to 10\% of the {\em exp
dataset}. To be consistent, we use the same 50\% as the testing data
(training and testing data has no overlap). As shown in
Figure~\ref{fig:train}, the 0.1\%-training curve is still overlapped
with the 50\%-curve, suggesting that extremely
small training data can achieve a comparable performance.
This confirms the low-variance in password transformation patterns.
Intuitively, users modify a password for the ease of
remembering. This is likely to introduce easy-to-predict passwords.
To measure the number of vulnerable password pairs, we use
the 0.1\%-trained model to guess the rest 99.9\% of the
password pairs. Since we guess both directions, the testing data
essentially has 14 million passwords. Within 10 attempts, we guessed 30\% (4.2
million passwords) --- 3.8 million {\em password pairs} are cracked for at
least one direction. Together with the identical password pairs (12.8
million), over 16.6 million pairs can be cracked within 10 attempts.
\para{Cracking the Remaining Hashes.} Finally, we perform a quick
experiment on the uncracked hashes in Section~\ref{sec:data}. In
total, we have 6,218,778 password pairs where one password is an uncracked hash, and
the other one is in plaintext. Our algorithm successfully recovered
939,400 (15.1\%) of the hashes within 5000 attempts, which
demonstrates the value of our algorithm over existing offline cracking
tools. As a future work, we plan to further test our algorithm on {\em
salted} password hashes.
| {'timestamp': '2017-06-09T02:03:04', 'yymm': '1706', 'arxiv_id': '1706.01939', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01939'} | arxiv |
\section{Introduction}
Nowadays the pervasiveness of images and also videos as primary source of information has led the image forensics community to question about their reliability and integrity more and more often. The context in which pictures are involved is disparate. A magazine, a social network, an insurance practice, an evidence for a trial. Such images can be easily altered through the use of powerful editing software, often leaving no visual trace of any modification, so answering reliably about their integrity becomes fundamental.
Image forensics deals with these issues by developing technological instruments which allow to determine, only on the basis of a picture, if that asset has been modified and sometimes to understand what has happened localizing the tampering. Regarding forgeries individuation three are the principal classes of detectors studied so far: those based on features descriptors \cite{ameriniIC, reiss2013, cozzolino2015splicebuster}, those based on inconsistent shadows \cite{Kee2013} and finally those based on double JPEG compression \cite{Lin-FastAutomatic,bianchi-Transaction,binli2008,milani2012,becarelliwifs2014}.
In recent years, machine learning and neural networks, such as convolutional neural networks (CNNs), have shown to be capable of extracting complex statistical features and to efficiently learn their representations, allowing to generalize well across a wide variety of computer vision tasks, including image recognition and classification and so on \cite{krizhevsky2012imagenet,girshick2014rich,simonyan2014very,jj2015iccv,uricchio2016automatic}.
The extensive use of such networks in many areas has motivated and led the multimedia forensics community to comprehend if such technological solutions can be employed to exploit source identification \cite{chaumont2016,BaroffioBBT16} or for image and video manipulation detection \cite{rao2016, rota2016, Bayar:2016, wang2016}. In particular, Wang \etal \cite{wang2016} use the histogram of Discrete Cosine Transform (DCT) coefficients as input to a CNN to detect single or double JPEG compressions in order to detect tampered images. The main idea behind \cite{rao2016, Bayar:2016} is to develop a sort of pre-processing module, designed to suppress image content before training a CNN; while, in \cite{rota2016} the CNN architecture is fed with patches without pre-processing and tampered patches are extracted from the borders of the tampered areas. Although the interest in neural network in image forensics domain is growing, a real comprehension of what is possible to accomplish with it is still in an early stage.
\begin{figure*}[!t]
\centering
\includegraphics[width=1.\textwidth]{2CNN.pdf}
\caption{Architecture of the CNNs: \emph{frequency domain-based} CNN (top) and \emph{spatial domain-based} CNN (bottom).}
\label{fig:CNN}
\end{figure*}
This paper presents a step forward in this direction. Our objective is to train a neural network that, given a to-be-checked image, is able to reliably localize the possible forged areas by analyzing the presence of single or double JPEG compressed areas.
In particular, different kinds of CNNs-based approaches have been proposed and different inputs to the nets are given. First of all, a \textit{spatial domain-based CNN} is exploited performing image forgery detection starting from the RGB color images; neither pre-processing is carried out nor side information on the borders of the tampered area is adopted. The CNN is trained to distinguish among uncompressed, single and double JPEG compressed images, to reveal the primary (hidden) JPEG compression and then localize the forgery regions. Secondly, another \textit{frequency domain-based CNN} is introduced taking as input to the net the histogram of the DCT coefficient similarly as \cite{wang2016}. The third proposed approach is a \textit{multi-domain-based CNN} able to join the two previous input information on RGBs patches and on DCT histograms.
The main contribution of this work is to explore the use of a spatial domain CNN and its combination with the frequency domain for the image forgery detection task.
Disparate experimental tests have been carried out trying also to evidence potential issues to be further investigated and improved.
The rest of the paper is organized as follows. In Section \ref{sec:approaches} we discuss the proposed approaches; Section \ref{sec:expres} contains experimental results, while conclusions and open issues are finally drawn in Section \ref{sec:conc}.
\section{CNN-based proposed approaches}
\label{sec:approaches}
In this work, our objective is to investigate the possibility to discern among uncompressed, single or double compressed images with the intent to detect image regions involved in a splicing attack. In addition to this, our secondary goal is to reveal the primary quality factor applied to the image or to the patch before the secondary compression is applied.
To accomplish this task three different CNN-based approaches are devised on the basis of the input data given to the net and on the net itself.
A convolutional neural network consists of several cascaded of convolutional layers and pooling layers followed by one or more fully-connected layers. Each considered CNN in the proposed approaches differs from the others in how components of the nets are combined together and from the number of layers employed, as described in detail in the following.
In order to learn discriminant features directly from data a consistent set of labeled images is needed in the training phase. For this reason, for all the considered approaches, images of different sizes are subdivided in patches (not overlapping) and then each of them is fed to the net.
Differently from the input, that it is different among the approaches, the output of the nets is the same. In particular, the three different proposed CNNs are able to discern among 9 classes: uncompressed, single compressed and double compressed patches (7 quality factors from 60 to 95, step by 5 is considered).
\subsection{Spatial-domain CNN}
In the first CNN-based approach, named \textit{spatial domain-based CNN}, the input of the net is a NxN size patches on the three color channels (RGB), pre-processing is not considered at all and only a normalization of the data (between 0 and 1) is performed.
First of all a convolutional network \cite{lecun1995convolutional} is designed and it is summarized in Figure \ref{fig:CNN} (top).
This particular net is composed by two convolutional blocks and two fully connected layers.
Each convolutional block is composed by two convolutional layers with ReLU activation followed by a pooling layer. All convolutional layers use a kernel size of 3x3 while pooling layer kernel size is 2x2. In order to prevent overfitting, we use Dropout \cite{srivastava2014dropout} that randomly drops units at training time from the fully connected layers.
In particular, a CNN of this kind is trained for each of the considered secondary quality factor $QF_2={60:5:95}$. Thus, we obtained eight different classifiers corresponding to each value of $QF_2$.
Each classifier is required to output two levels of classifications for an input patch. The first is an inter-class categorization between uncompressed, single compressed and double compressed patch. The second is the intra-class of the $QF_1$ (ranging in ${60:5:95}$, excluding $QF_1=QF_2$) in the case of double compressed patches. We thus choose to output 9 plain classes, the uncompressed class, the single compressed class and a class for each $QF_1$.
As a result, the last fully connected layers of the CNN is sent to a nine-way softmax connection, which produces the probability that each sample should be classified into each class. As loss function, we use a categorical cross-entropy function \cite{vincent2010stacked}. We note that mis-classifying the intra-class of a double compressed patch is a smaller error compared to wrongly classify the inter-class of a patch. So, we adjust the loss to weight an intra-class error as $1/9$ of an inter-class error. In our preliminary experiments, this improved the intra-class classification accuracy.
The proposed CNN model is trained based on the labeled patch samples from the training set composed by uncompressed, single or double compressed patches (i.e $QF_2=90$ and $QF_1$ varies from 60 to 95). In the test phase, one of the eight trained CNN (selected accordingly to the quality factor saved in EXIF header of the JPEG format) is used to extract the patch-based features for a test image by applying a patch-sized sliding window to scan the whole image, assigning a class for each patch and therefore performing localization at image level.
\subsection{Frequency-domain CNN}
In the second proposed approach, \textit{frequency domain-based CNN}, a pre-processing is performed for a given patch computing the histogram of the DCT coefficients following the idea in \cite{wang2016} expanding the number of the evaluated coefficients.
In detail, given a NxN patch, DCT coefficients are extracted and, for each 8x8 block, the first 9 spatial frequencies in zig-zag scan order (DC is skipped) are selected. For each spatial frequency $i,j$, the histogram $h_{i,j}$, representing the occurrences of absolute values of quantized DCT values, is built. In detail, $h_{i,j}(m)$ is the number of values $m$ in the histogram of the $i,j$ DCT coefficient with $m=(-50..,0..,+50)$.
So the network take in total a vector of 909 elements (101 histogram bins x 9 DCT frequencies) as input.
Again, as before, an array of eight CNNs is trained, each of them corresponding at the different values of the second compression quality factor $QF_2$.
The feature vector is then used to train each CNN, in order to distinguish among the 9 classes defined before (uncompressed, single compressed and double compressed with $QF_2$ fixed and primary quality factors varying in $QF_1={60:5:95}$).
The architecture of the proposed CNN model is illustrated in Figure \ref{fig:CNN} (bottom). It contains two convolutional layers followed by two pooling connections and three full connections. The size of the input data is 909x1, and the output is a distribution of nine classes.
Each fully connected layer has 256 neurons, and the output of the last one is sent to a nine-way softmax, which produces the probability that each sample should be classified into each class. In our network, rectified linear units (ReLUs) $f(x) = max(0, x)$ as activation function, are used in each layer. In both fully
connected layers, the Dropout technique is used.
\subsection{Multi-domain CNN}
The third considered approach is a \textit{multi-domain CNN} where the three channels color patch and the histogram of DCT coefficient computed on the patch serve as input of the net in order to combine the previous two approaches.
\begin{figure}[!t]
\centering
\includegraphics[width=0.9\columnwidth]{mCNN}
\caption{Architecture of the \emph{multi-domain} CNN.}
\label{fig:mCNN}
\end{figure}
In Figure \ref{fig:mCNN} the proposed net is depicted and it consists of one \textit{spatial domain-based CNN} and one \textit{frequency domain-based CNN} up to their first respective fully connected layers. The \textit{multi-domain-based CNN} learns the inter-modal relations between features coming from R,G,B domain and from the histogram of DCT joining together the outputs of the fully connected layers of the two nets (256 dimensions each). In this way the last fully connected layer has 512 neurons, and the output is sent to a nine-way softmax connection, which produces the probability that each sample is classified into each class also using a dropout layer.
So, as well as before, eight different 9 classes classifiers are devised corresponding to each value of $QF_2$. The training and testing phase are performed as before.
\section{Experiments}
\label{sec:expres}
In this section some of the experimental tests carried out are presented. In particular, in Section \ref{ssec:setup}
the general set-up is primarily introduced while in Section \ref{ssec:exp_9class} results obtained with the 9-classes classifiers are presented and in Section \ref{ssec:exp_9class}, the performance of the three proposed approaches are compared. Ultimately, in Section \ref{ssec:exp_quality}, a qualitative point of view on some forensic-like examples is debated.
\subsection{Experimental setup}
\label{ssec:setup}
The UCID dataset \cite{Schaefer04ucid} has been used for the experimental tests; it is composed by 1338 images (TIFF format and size $384\times512$). The whole dataset has been subdivided in training set (1204, about $90\%$), validation set (67, about $5\%$) and test set (67, about $5\%$) in order to keep separate the bunches of images involved in the different phases.
It have been considered 8 diverse JPEG quality factors with $QF=60:95$ with a step of $5$ both for the first and the second compression; according to this, 8 CNNs (one for each $QF_2$) have been trained on non-overlapping image patches of size $N=64$ that is $48$ patches for every UCID image. Each CNN is trained to classify 9 different classes of images which are: \emph{uncompressed}, \emph{single compressed} and \emph{double compressed} (7 classes, given that the case $QF_1=QF_2$ is skipped because it would fall in the single compressed one). The neural network learns on 57,792 patches ($1204\times48$) for each of the 9 classes and is optimized by using AdaDelta method \cite{zeiler2012adadelta}. The training phase is stopped when the loss function on the validation set reaches its minimum that usually happens after $15/20$ epochs. Performance on the test set (28,944 patches in total) are evaluated in terms of \emph{True Positive Rate} ($TPR=\frac{TP}{TP+FN}$)
and \emph{Accuracy} ($ACC=\frac{TP+TN}{TP+FN+TN+FP}$).
\subsection{CNN-based approaches evaluation}
\label{ssec:exp_9class}
In this experiment, we have investigated the performance in terms of TPR of the CNNs trained with spatial domain-based examples and with frequency domain-based ones. Results, over a test-set of 28,944 image patches, of the different CNNs are presented in Table \ref{tab:CM1_image} and Table \ref{tab:CM1_DCT} respectively.
Both methods are able to classify all uncompressed patches almost perfectly while the spatial domain-based CNN has an higher TPR for single compressed patches.
Regarding double compressed patches, it can be seen that both methods show good performance in the top-right zone of the matrix. It is quite well-known in fact that when $QF_2 > QF_1$, traces of the first compression still survive and are easily detectable.
\begin{table*}[]
\centering
\begin{tabular}{|c|l|c|c|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{} & & \multicolumn{8}{|c|}{$QF_2$} & \\ \cline{2-11}
& & \textbf{60} & \textbf{65} & \textbf{70} & \textbf{75} & \textbf{80} & \textbf{85} & \textbf{90} & \textbf{95} & \textbf{AVG} \\ \hline \hline
\multirow{2}{*}{} & \textbf{Uncompressed} & 0.999 & 0.998 & 0.994 & 0.997 & 0.997 & 0.999 & 0.997 & 0.996 & 0.997\\ \cline{2-11}
& \textbf{Single Compressed} & 0.599 & 0.701 & 0.717 & 0.789 & 0.843 & 0.955 & 0.981 & 0.986 & 0.821\\ \hline
\multirow{8}{*}{\rotatebox[origin=c]{90}{$QF_1$}} & \textbf{60} & --- & 0.403 & 0.870 & 0.918 & 0.804 & 0.912 & 0.803 & 0.827 & 0.791\\ \cline{2-11}
& \textbf{65} & 0.235 & --- & 0.470 & 0.783 & 0.532 & 0.672 & 0.669 & 0.771 & 0.590\\ \cline{2-11}
& \textbf{70} & 0.423 & 0.356 & --- & 0.555 & 0.646 & 0.551 & 0.661 & 0.819 & 0.573\\ \cline{2-11}
& \textbf{75} & 0.633 & 0.561 & 0.415 & --- & 0.746 & 0.716 & 0.739 & 0.785 & 0.656\\ \cline{2-11}
& \textbf{80} & 0.796 & 0.714 & 0.580 & 0.467 & --- & 0.891 & 0.810 & 0.852 & 0.730\\ \cline{2-11}
& \textbf{85} & 0.636 & 0.469 & 0.792 & 0.826 & 0.794 & --- & 0.908 & 0.926 & 0.764\\ \cline{2-11}
& \textbf{90} & 0.740 & 0.755 & 0.771 & 0.746 & 0.899 & 0.956 & --- & 0.991 & 0.837\\ \cline{2-11}
& \textbf{95} & 0.702 & 0.713 & 0.395 & 0.734 & 0.896 & 0.932 & 0.942 & --- & 0.759\\ \hline
\end{tabular}
\caption{\emph{Spatial domain-based} CNNs: performance of the 8 CNNs to distinguish the 9 different classes of images in terms of TPR.}
\label{tab:CM1_image}
\end{table*}
\begin{table*}[]
\centering
\begin{tabular}{|c|l|c|c|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{} & & \multicolumn{8}{|c|}{$QF_2$} & \\ \cline{2-11}
& & \textbf{60} & \textbf{65} & \textbf{70} & \textbf{75} & \textbf{80} & \textbf{85} & \textbf{90} & \textbf{95} & \textbf{AVG} \\ \hline \hline
\multirow{2}{*}{} & \textbf{Uncompressed} & 1.000 & 0.999 & 1.000 & 1.000 & 1.000 & 0.999 & 0.999 & 0.998 & 0.998\\ \cline{2-11}
& \textbf{Single Compressed} & 0.490 & 0.395 & 0.472 & 0.717 & 0.668 & 0.765 & 0.874 & 0.995 & 0.672\\ \hline
\multirow{8}{*}{\rotatebox[origin=c]{90}{$QF_1$}} & \textbf{60} & --- & 0.886 & 0.938 & 0.991 & 0.991 & 0.992 & 0.994 & 0.995 & 0.970\\ \cline{2-11}
& \textbf{65} & 0.647 & --- & 0.868 & 0.944 & 0.959 & 0.972 & 0.972 & 0.979 & 0.906\\ \cline{2-11}
& \textbf{70} & 0.876 & 0.571 & --- & 0.873 & 0.958 & 0.977 & 0.984 & 0.982 & 0.889\\ \cline{2-11}
& \textbf{75} & 0.824 & 0.907 & 0.743 & --- & 0.970 & 0.976 & 0.982 & 0.987 & 0.913\\ \cline{2-11}
& \textbf{80} & 0.727 & 0.765 & 0.910 & 0.894 & --- & 0.979 & 0.991 & 0.994 & 0.894\\ \cline{2-11}
& \textbf{85} & 0.806 & 0.658 & 0.657 & 0.881 & 0.902 & --- & 0.984 & 0.986 & 0.839\\ \cline{2-11}
& \textbf{90} & 0.450 & 0.388 & 0.574 & 0.723 & 0.802 & 0.913 & --- & 0.991 & 0.692\\ \cline{2-11}
& \textbf{95} & 0.120 & 0.189 & 0.226 & 0.015 & 0.220 & 0.524 & 0.772 & --- & 0.295\\ \hline
\end{tabular}
\caption{\emph{Frequency domain-based} CNNs: performance of the 8 CNNs to distinguish the 9 different classes of images in terms of TPR.}
\label{tab:CM1_DCT}
\end{table*}
In Table \ref{tab:CM1_image_DCT}, the results obtained for the multi-domain-based approach which combines the two previous kinds of input, are listed. It is worthy underlining that there is a significant improvement, as general, and also in the bottom-left part of the table ($QF_1 < QF_2$). This suggests that the two inputs provide complementary information that the multi-domain approach is able to correlate and exploit.
\begin{table*}[]
\centering
\begin{tabular}{|c|l|c|c|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{} & & \multicolumn{8}{|c|}{$QF_2$} & \\ \cline{2-11}
& & \textbf{60} & \textbf{65} & \textbf{70} & \textbf{75} & \textbf{80} & \textbf{85} & \textbf{90} & \textbf{95} & \textbf{AVG} \\ \hline \hline
\multirow{2}{*}{} & \textbf{Uncompressed} & 0.999 & 1.000 & 1.000 & 0.999 & 0.999 & 1.000 & 1.000 & 0.997 & 0.999\\ \cline{2-11}
& \textbf{Single Compressed} & 0.833 & 0.833 & 0.881 & 0.903 & 0.949 & 0.971 & 0.965 & 0.994 & 0.916\\ \hline
\multirow{8}{*}{\rotatebox[origin=c]{90}{$QF_1$}} & \textbf{60} & --- & 0.892 & 0.983 & 0.987 & 0.976 & 0.990 & 0.980 & 0.992 & 0.972\\ \cline{2-11}
& \textbf{65} & 0.679 & --- & 0.864 & 0.958 & 0.946 & 0.980 & 0.994 & 0.991 & 0.916\\ \cline{2-11}
& \textbf{70} & 0.838 & 0.760 & --- & 0.869 & 0.985 & 0.982 & 0.981 & 0.985 & 0.914\\ \cline{2-11}
& \textbf{75} & 0.864 & 0.809 & 0.734 & --- & 0.952 & 0.974 & 0.982 & 0.991 & 0.901\\ \cline{2-11}
& \textbf{80} & 0.772 & 0.880 & 0.841 & 0.884 & --- & 0.982 & 0.994 & 0.991 & 0.907\\ \cline{2-11}
& \textbf{85} & 0.764 & 0.760 & 0.815 & 0.876 & 0.919 & --- & 0.984 & 0.993 & 0.873\\ \cline{2-11}
& \textbf{90} & 0.659 & 0.767 & 0.739 & 0.826 & 0.924 & 0.955 & --- & 0.996 & 0.838\\ \cline{2-11}
& \textbf{95} & 0.830 & 0.703 & 0.773 & 0.760 & 0.932 & 0.959 & 0.889 & --- & 0.835\\ \hline
\end{tabular}
\caption{\emph{Multi-domain-based} CNNs: performance of the 8 CNNs to distinguish the 9 different classes of images in terms of TPR.}
\label{tab:CM1_image_DCT}
\end{table*}
The three approaches are also compared in terms of accuracy for the different 8 classifiers according to $QF_2$. Figure \ref{fig:comparison} provides a clear evidence of the respective behaviors: the multi-domain approach outperforms the others and basically tends to achieve high level of accuracy (over $95\%$) when $QF_2$ is superior to the value of $80$.
\begin{figure}[!t]
\centering
\includegraphics[width=\columnwidth]{comparison.png}
\caption{Three approaches comparison in terms of accuracy for each of the 8 ($QF_2$) classifiers.}
\label{fig:comparison}
\end{figure}
\subsection{Qualitative results}
\label{ssec:exp_quality}
In this section, some experimental results are extrapolated and presented to provide a qualitative view of the achieved performance mainly in terms of forgery localization. In particular, in Figure \ref{fig:masks} five sample counterfeited pictures (top row) and their corresponding localization masks (bottom row) are visualized. Forged images have been constructed by inserting a $64\times64$ patch, coming from another UCID image, within a host picture (for sake of clarity, the patch is located always in the same position in this figure). Such a processing can be carried out in different manners in terms both of used JPEG quality factors and of areas undergone to single or double compression; to provide an as-wide-as-possible view of the various cases diverse situations are represented. In Figure \ref{fig:masks} (a) and (f), the forged patch was double compressed (blue color) with $QF_1=60$ and $QF_2=90$ while the remaining part was single compressed (green color) at $QF_2=90$; different color tones indicate prediction probability of that class assigned by the CNN. So in this initial case, the second JPEG quality factor is higher than the first. In Figure \ref{fig:masks} (b) and (g), a similar case is considered but now $QF_1=80$ and $QF_2=85$, so quality factors are again in increasing order but much closer each other. On the contrary, in Figure \ref{fig:masks} (c)-(h) and (d)-(i), quality factors in decreasing order have been used ($QF_1=80$, $QF_2=70$ and $QF_1=95$, $QF_2=90$ respectively). It can be seen that now, as expected, the behavior is more noisy especially when the second compression is stronger ($QF_2=70$). Finally, in Figure \ref{fig:masks} (e) and (j), the case with $QF_1=60$ and $QF_2=90$ is presented but, this time, the forged patch is single ($QF_2=90$) compressed (green color). This is the dual circumstance, in terms of areas involved in compression, with respect to Figure \ref{fig:masks} (a) and (f).
\begin{figure*}[!htb]
\centering
\subfloat[]{%
\includegraphics[width=0.19\textwidth]{6090int.jpg}
}
\subfloat[]{%
\includegraphics[width=0.19\textwidth]{8085.jpg}
}
\subfloat[]{%
\includegraphics[width=0.19\textwidth]{8070.jpg}
}
\subfloat[]{%
\includegraphics[width=0.19\textwidth]{9590.jpg}
}
\subfloat[]{%
\includegraphics[width=0.19\textwidth]{6090.jpg}
}
\\
\subfloat[]{%
\includegraphics[width=0.19\textwidth]{6090maskint.png}
}
\subfloat[]{%
\includegraphics[width=0.19\textwidth]{8085mask.png}
}
\subfloat[]{%
\includegraphics[width=0.19\textwidth]{8070mask.png}
}
\subfloat[]{%
\includegraphics[width=0.19\textwidth]{9590mask.png}
}
\subfloat[]{%
\includegraphics[width=0.19\textwidth]{6090mask.png}
}
\caption{Examples of forged images (top row) and corresponding localization masks (bottom row).}
\label{fig:masks}
\end{figure*}
\section{Conclusions}
\label{sec:conc}
In this paper we presented a step forward into adopting convolutional neural networks for the task of detecting splicing forgery. We began to explore CNN capabilities to classify and localize uncompressed, single and double compressed patches of images. In the latest case, our approach is also able to recover the original compression quality factor. We proposed a \textit{spatial domain-based CNN} and its combination with a \textit{frequency-based CNN} into a \textit{multi-domain-based} approach. Experimental results suggest that the spatial domain can be used directly and, when combined with the frequency domain, can lead to superior performance where DCT methods are usually weak (e.g. $QF_2 < QF_1$).
Some open issues remain to be explored. First, the choice of the CNN architecture can lead to very different performance as it was seen on the object classification task \cite{krizhevsky2012imagenet, simonyan2014very} where deeper architectures are used.
Second, how much data is needed to train a good CNN model should be explored by collecting a larger dataset. Our results suggest that spatial information could help where DCT methods require patches with at least 64x64 to build a useful statistic.
Third, the capability of CNNs to detect different kind of compressions (e.g. JPEG 2000 or lossy PNG) should be explored. Our promising results show that this tool can detect the subtleties features of previous compressions and learn to predict the first quality factor used in re-compressions.
{\small
\bibliographystyle{ieee}
| {'timestamp': '2017-06-07T02:07:12', 'yymm': '1706', 'arxiv_id': '1706.01788', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01788'} | arxiv |
\section{Introductions}
Barrier coverage and area coverage are two important problems in applications
of wireless sensor networks. In both two problems, sensors are deployed
in such a way that every point of the target region is monitored by
at least one sensor. For area coverage, the target region is traditionally
a bounded area in the plane; while in the barrier coverage problem
arising from border surveillance for intrusion detection, the target
region are the borders and the goal is to deploy sensors along the
borders such that at least one sensor will detect if any intruder
crosses the border. Unlike area coverage, barrier coverage requires
only to cover every points of the borders, rather than every point
of the area bounded by the border. So barrier coverage uses much fewer
sensors, and hence is more cost-efficient, particularly in practical
large-scale sensor deployment.
To accomplish a barrier coverage, sensors are dispersed along the
borders. However, there may exist gaps after the dispersal, so the
border line might not be completely covered. One approach is to disperse
the sensors in multiple rounds, and guarantee the probability of complete
coverage by the dispersal density of the sensors \cite{yang2010multi,li2012energy}.
The other approach is to acquire some sensors with the ability of
relocation (i.e. mobility), such that after dispersal, the sensors
can move to monitor the gaps on the barrier. In this context, since
the battery of a sensor is limited, a smart relocation scheme is required
to maximize the lifetime of the sensors, and hence ensures a maximum
lifetime of the barrier coverage.
\subsection{Problem Statement}
This paper studies the two-dimensional (2-D) barrier coverage problem
with mobile sensors, in which the barrier is modeled by a line segment,
while the sensors are distributed in the plane initially. The problem
is to compute the relocated positions of the sensors, such that the
barrier will be completely covered while the maximum relocation distance
among all the sensors is minimized.
Formally, we are given a line barrier $[0,M]$ on $x$-axis and a
set of sensors distributed in the Euclidean plane, say $\Gamma=\{1,\,\dots,\,n\}$,
within which sensor $i$ is with a radii $r_{i}$ and a position $(x_{i},\,y_{i})$.
The two dimensional Minimum Maximum Sensor Movement problem (MMSM)
is to compute the minimum $D\in\mathbb{Z}_{0}^{+}$ and a new position
$(x_{i}',\,0)$ for each sensor $i$, such that $\max_{i\in n}\sqrt{(x_{i}-x_{i}')^{2}+(y_{i}-0){}^{2}}\leq D$
and each point on the line barrier is covered by at least one sensor
(i.e. for each point on the line barrier there exists at least a sensor
$i$ within distance $r_{i}$).
The paper finds that, MMSM can be reduced to a discrete version called
DMMSM. In DMMSM, we are given a graph $G=(V,\,E)$, where $V=\{v_{0},\,v_{1},\,\dots,\,v_{M}\}$
and $E=\{e_{i}=(v_{i},\,v_{i+1})\vert i\in V\setminus\{M\}\}$. We
say an edge $e_{j}$ is covered by a set of sensors $\Gamma'\subseteq\Gamma$
if and only if every point on the edge is in the monitoring area of
at least one sensor of $\Gamma'$. The goal of DMMSM is also to compute
a minimum maximum movement $D\in\mathbb{Z}_{0}^{+}$ and the new relocate
position for each sensor, such that every edge of $E$ is covered
by the sensors.
We propose several algorithms that are actually first to solve decision
MMSM and decision DMMSM, which is to determine, for a given the relocation
distance bound $D$, whether the sensors can be relocated within $D$
to cover the line barrier.
\subsection{Related Works}
The MMSM problem in 2D setting was first studied in \cite{dobrev2015complexity},
and shown strongly ${\cal NP}$-complete for sensors with general
sensing radii via a reduction from the 3-partition problem which is
known strongly ${\cal NP}$-complete. Later, an algorithm with a time
complexity of $O(n^{3}\log n)$ has been developed in \cite{li2015minimizing}
for the problem where sensors are with identical sensing radii. In
the same paper, an approximation algorithm with ratio $\frac{y_{max}}{y_{min}}$
for general radii has also been developed, where $y_{max}$ and $y_{min}$
are respectively the maximum and minimum perpendicular relocation
distance from the sensors to the barrier. To the best of our knowledge,
there is no any other non-trivial approximation algorithm for MMSM
with general radii.
Unlike 2-D MMSM, the MMSM problem has been extensively studied and
well understood in 1-D setting, in which the barrier are assumed to
be a line segment on the same line where the sensors are initially
located. Paper \cite{czyzowicz2009minimizing} presented an algorithm
which optimally solves 1D-MMSM for uniform radius and runs in time
$O(n^{2})$, by observing the order preservation property. The time
complexity was improved to $O(n\log n)$ later in paper \cite{chen2013algorithms},
which also gave an $O(n^{2}\log n)$ time algorithm for general radii.
Recently, an $O(n^{2}\log n\log\log n)$ time algorithm has been presented
in \cite{wang2015minimizing} for weighted 1D-MMSM with uniform radii,
in which each sensor has a weight, and the moving cost of a sensor
is its movement times its weight. Moreover, circle/simple polygon
barriers has been studied besides straight lines in \cite{bhattacharya2009optimal},
in which two algorithms has been developed for MMSM, with an $O(n^{3.5}\log n)$
time against cycle barriers and an $O(mn^{3.5}\log n)$ time against
polygon barriers, where $m$ is the number of the edges on the polygon.
The later time complexity was then improved to $O(n^{2.5}\log n)$
in \cite{tan2010new}.
Other problems closely related to MMSM have also been well studied
in previous literature. In 1-D setting, the Min-Sum relocation problem,
to minimize the sum of the relocation distances of all the sensors,
is shown ${\cal NP}$-complete for general radii while solvable in
time $O(n^{2})$ for uniform radii \cite{czyzowicz2010minimizing}.
The Min-Num relocation problem of minimizing the number of sensors
moved, is also proven ${\cal NP}$-complete for general radii and
polynomial solvable for uniform radii \cite{mehrandish2011minimizing}.
Similar to MMSM, where a PTAS has been developed for the Min-Sum relocation
problem against circle/simple polygon barriers \cite{bhattacharya2009optimal},
which was improved by later paper \cite{tan2010new} that gave an
$O(n^{4})$ time exact algorithm.
Paper \cite{bar2013maximizing} studied a more complicated problem
of maximizing the coverage lifetime, in which each mobile sensor is
equipped with limited battery power, and the coverage lifetime is
the time to when the coverage no longer works because of the death
of a sensor. The authors presented parametric search algorithms for
the cases when the sensors have a predetermined order in the barrier
or when sensors are initially located at barrier endpoints. On the
other hand, the same authors present two FPTAS respectively for minimizing
sumed and maximum energy consumption when the radii of the sensors
can be adjusted \cite{bar2015green}. When the sensing radii is fixed,
i.e. unadjustable, the same paper showed the min-sum problem can not
be approximated within $O(n^{c})$ for any constant $c$ under the
assumption of ${\cal P}\neq{\cal NP}$, while the min-max version
is known strongly ${\cal NP}$-complete, as it can be reduced to 2-D
MMSM which is know strongly ${\cal NP}$-complete \cite{dobrev2015complexity}.
Before deployment of mobile sensors, barrier coverage was first considered
deploying stationary sensors \cite{kumar2005barrier} for covering
a closed curve (i.e. a moat), and an elegant algorithm was proposed
by transferring the Min-Sum cost barrier coverage problem to the shortest
path problem. It has then been extensively studied for line based
employment \cite{saipulla2009barrier}, for better local barrier coverage
\cite{chen2010local}, and for using camera sensors \cite{wang2011barrier,ma2012minimum}.
The most recent result \cite{fan2014barrier} studied line barrier
coverage using sensors with adjustable sensing ranges. They show the
problem is polynomial solvable when each sensor can only choose from
a finite set of sensing ranges, and ${\cal NP}$-complete if each
sensor can choose any sensing ranges in a given interval.
\subsection{Our Results and Technique}
In this paper, we present two approximation algorithms for the decision
MMSM problem. The first is a simple greedy approach based on our proposed
sufficient condition of determining whether there exists a feasible
cover for the barrier under the relocation distance bound $D$. If
$D<D^{*}$, the algorithm outputs ``infeasible''; Otherwise, the
algorithm computes new positions for the sensors, resulting a maximum
relocation distance $D+2r_{max}$, where $r_{max}=\max_{i}\{r_{i}\}$.
The algorithm is so efficient that it runs in time $O(n\log n)$,
where $n=\vert\Gamma\vert$ is the number of the sensors. The second
is generally an linear programming (LP) rounding based approach, which
first transfers MMSM to the fractional cardinality matching problem
and then solves the LP relaxation we propose for the latter problem.
The algorithm approximately solves the decision MMSM problem according
to a solution to the LP relaxation. Similar to the case for the first
algorithm, we show that the algorithm always outputs ``feasible''
if $D\geq D^{*}$. Further, for any instance our algorithm returns
``feasible'', we give a method to construct a real solution for
MMSM, with a maximum relocation distance $D+r_{max}$, by rounding
up a fractional optimum solution to the LP relaxation. The algorithm
has a runtime $O(n^{7}L)$, which is exactly the time of solving the
proposed LP relaxation by Karmakar's algorithm \cite{karmarkar1984new},
where $L$ is the length of the input. As a by-product, we give the
third algorithm for decision MMSM with a maximum relocation distance
$d(OPT)+r_{max}$, and time $O(R^{2}\sqrt{\frac{M}{\log R}})$, where
$R=\sum_{i=1}^{n}2r_{i}$ is sum of the radii of the sensors.
Based on the three above algorithms for the decision problem, the
paper proposes an unified algorithm framework to actually calculate
a solution to MMSM without a given $D$. The time complexity and the
maximum relocation distance are respectively $O(n\log n\log d_{\max})$
and $D^{*}+2r_{max}$ if employing the greedy algorithm; $O(n^{7}L\log d_{max})$
and $D^{*}+r_{max}$ if employing the LP based algorithm, where $d_{max}$
is the maximum distance between the sensors and the barriers. The
runtime $O(n^{7}L\log d_{max})$ can be improved to $O(R^{2}\sqrt{\frac{M}{\log R}}\log d_{max})$
if $M$ is not large, by using the third algorithm based on matching.
Note that, although our algorithm could compute a near-optimal solution
when $D^{*}\gg r_{max}$, the performance guarantee is not as good
when $D^{*}<r_{max}$. So in addition we give a simple factor-2 approximation
algorithm for MMSM, by extending the optimal algorithm for 1D-MMSM
as in paper \cite{chen2013algorithms}. Consequently, the ratio of
our first three algorithms can be improved for the case $D^{*}<r_{max}$,
by combining the factor-2 approximation.
\subsection{Organization of the Paper}
The remainder of the paper is organized as follows: For decision MMSM,
Section 2 gives a greedy algorithm as well as the ratio proof; Section
3 gives an approximation algorithm with an improved maximum relocation
distance $d(OPT)+r_{max}$ using LP rounding technique; Section 4
gives another approximation algorithm with the same maximum relocation
distance guarantee but a different runtime, by using maximum cardinality
matching; Section 5 present the algorithm which actually solve MMSM,
using the algorithm given in Section 2, 3 and 4; Section 6 extends
previous results and develops a factor-2 approximation algorithm with
provable performance guarantee; Section 7 concludes the paper.
\section{A Simple Greedy Algorithm For Decision MMSM}
This section presents an approximation algorithm for any instance
of decision MMSM wrt a given $D$: if the algorithm returns ``infeasible'',
then the instance is truly \emph{infeasible} with respect to $D$;
Otherwise, the instance of MMSM is feasible under the maximum movement
of $D+2r_{max}$, where $r_{max}=\max_{i}\{r_{i}\}$. To show the
performance guarantee of the algorithm, we propose a sufficient condition
for the feasibility of decision MMSM against given $D$.
\subsection{An Approximation Algorithm}
Let $[l_{i},\,g_{i}]$ be the possible coverage range for sensor $i$,
where $l_{i}$ and $g_{i}$ are respectively the leftmost and the
rightmost points of the barrier, i.e. the leftmost and the rightmost
points sensor $i$ can cover by relocating within distance $D$. The
key idea of our algorithm is to cover the barrier from left to right,
using the sensor with minimum $g_{i}$ within the set of sensors which
can cover the leftmost uncovered point with a maximum relocation distance
$D+2r_{max}$.
More detailed, the algorithm is first to compute for each sensor $i$
its possible coverage range $[l_{i},\,g_{i}]$. Let $s$ be the leftmost
point of the uncovered part of the line barrier. Then among the set
of sensors $\{i\vert l_{i}-2r_{max}\leq s\leq g_{i}\}$, the algorithm
repeats selecting the sensor with minimum $g_{i}$ to cover an uncovered
segment of the line barrier starting at $s$. Note that $\{i\vert l_{i}-2r_{max}\leq s\leq g_{i}\}$
is exactly the set of sensors, which are with $g_{i}\geq s$ and can
monitor an uncovered segment starting at $s$ by relocating at most
$D+2r_{max}$ distance. If there is a tie on $g_{i}$, then randomly
pick a sensor within the tie. The selection terminates once the line
barrier is completely covered, or the instance is found infeasible,
i.e. there exists no such $i$ with $l_{i}-2r_{max}\leq s\leq g_{i}$
while the coverage is not done. The algorithm is formally as in Algorithm
\ref{alg:mainA-simple-greedy}.
\begin{algorithm}
\textbf{Input: }A movement distance bound $D\in\mathbb{Z}^{+}$, a
set of sensors $\Gamma=\{1,\,\dots,\,n\}$ with $\{r_{i}\vert i\in[n]^{+}\}$
and $\{(x_{i},\,y_{i})\vert i\in[n]^{+}\}$, in which $r_{i}$ and
$(x_{i},\,y_{i})$ are respectively the sensing radii and the original
position of sensor $i$;
\textbf{Output: }New positions $\{(x_{i}',\,y_{i}')\vert i\in[n]^{+}\}$
for the sensors.
\enskip{}1: Set ${\cal I}:=\Gamma$, $s:=0$; /{*}$s$ is the leftmost
point of the uncovered part of the barrier.{*}/
\enskip{}2: \textbf{For} each sensor $i$ \textbf{do}
\enskip{}3: \quad{}Compute the leftmost position $l_{i}$ and the
rightmost position $g_{i}$, both of which sensor $i$ can monitor;
\enskip{}4: \textbf{While} ${\cal I}\neq\emptyset$ \textbf{do}
\enskip{}5: \quad{}\textbf{If} there exists $i'\in{\cal I}$, such
that $l_{i'}-2r_{max}\leq s\leq g_{i'}$ \textbf{then}
\enskip{}6: \quad{}\quad{}Select $i\in{\cal I}$ for which $g_{i}=\min_{i':\,l_{i'}-2r_{max}\leq s\leq g_{i'}}\{g_{i'}\}$;
\quad{}\quad{}\quad{}\quad{}/{*} Select the sensor with minimum
$g_{i}$ among the sensors $\{i'\vert l_{i'}-2r_{max}\leq s\}$; {*}/
\enskip{}7: \quad{}\quad{}Set $s:=\min\{s+2r_{i},\,g_{i}\}$, ${\cal I}:={\cal I}\setminus\{i\}$,
$x_{i}':=s-r_{i}$, $y_{i}':=0$;
\enskip{}8: \quad{}\textbf{Else}
\enskip{}9: \quad{}\quad{}Return ``infeasible''.
10: Return ``feasible'' the new positions $\{(x'_{i},\,0)\vert i\in[n]^{+}\}$.
\caption{\label{alg:mainA-simple-greedy}A simple greedy algorithm for decision
MMSM.}
\end{algorithm}
For briefness, we will simply say an instance (or the input) of MMSM
instead for the input of Algorithm \ref{alg:mainA-simple-greedy}
in the following paragraphs. Note that Steps 2-3 take time $O(n)$
to compute $l_{i}$ and $g_{i}$ for all the sensors, Steps 4-7 take
$O(n\log n)$ time to assign the sensors to cover the line barrier.
Therefore, we have the time complexity of the algorithm:
\begin{lem}
Algorithm \ref{alg:mainA-simple-greedy} runs in time $O(n\log n)$.
\end{lem}
\subsection{The Ratio of Algorithm \ref{alg:mainA-simple-greedy}}
The performance guarantee of Algorithm \ref{alg:mainA-simple-greedy}
is as below:
\begin{thm}
\label{thm:greedyfinalthr}Let $D^{*}$ be the distance of an optimal
solution. If $D\geq D^{*}$, then Algorithm \ref{alg:mainA-simple-greedy}
will return a solution with maximum relocation distance $D+2r_{max}$,
where $r_{max}=\max_{i}\{r_{i}\}$.
\end{thm}
According to Algorithm \ref{alg:mainA-simple-greedy}, we never move
a sensor out of the range $[l_{i}-2r_{max},\,g_{i}]$. It remains
to show Algorithm \ref{alg:mainA-simple-greedy} will always return
a feasible solution when $D\geq D^{*}$. For this goal, we will give
a sufficient condition for the feasibility of decision MMSM. Below
are two notations needed for the tasks:
\[
\lambda(i,\,D,\,x,\,x')=\begin{cases}
0 & g_{i}\leq x\,\mbox{or}\,l_{i}\geq x'\\
\min\{2r_{i},\,\min\{x',\,g_{i}\}-\max\{x,\,l_{i}\}\} & Otherwise
\end{cases}
\]
and
\[
\sigma(i,\,D,\,{\cal S})=\begin{cases}
0 & g_{i}\leq x\,\mbox{OR}\,l_{i}\geq x'\\
\min\{2r_{i},\,\sum_{[x,x']\in{\cal S}}\lambda(i,\,D^{*},\,x,\,x')\} & Otherwise
\end{cases}
\]
where ${\cal S}$ is a set of \emph{disjoint} segments of the line
barrier. Intuitionally $\lambda(i,\,D,\,x,\,x')$ is the maximum coverage
which sensor $i$ can provide for segment $[x,\,x']$, and $\sigma(i,\,D,\,{\cal S})$
is the sum of the coverage that sensor $i$ can provide for all the
segments in ${\cal S}$. Then a simple necessary condition for the
feasibility of an instance of MMSM of as below:
\begin{prop}
\label{prop:necessary}If an instance of decision MMSM is feasible
wrt $D$, then $\sum_{i}\sigma(i,\,D,\,{\cal S})\geq\sum_{[x_{j},\,x_{j}']\in{\cal S}}\vert x_{j}'-x_{j}\vert$
must hold for any set of disjoint segments ${\cal S}=\{[x_{i},\,x_{i}']\vert0\leq i\leq M\}$.
\end{prop}
Intuitionally, the above proposition states that the sum of the sensor
coverage length must be not less than the length of the barrier segments
to cover. The correctness of the above lemma is obviously, since a
feasible relocation assignment must satisfy the condition. However,
this is not a sufficient condition for the feasibility of decision
MMSM (A counter example is as depicted in Figure \ref{fig:A-tight-exampleforLP}
(a): For $D=r_{1}$, the necessary condition holds for the given instance
while the instance is actually infeasible). However, if $2r_{max}$
more relocation distance is allowed as in Algorithm \ref{alg:mainA-simple-greedy},
we have the following lemma:
\begin{lem}
\label{lem:sufficientcoreforgreedy}If $\sum_{i}\sigma(i,\,D,\,{\cal S})\geq\sum_{[x_{j},\,x_{j}']\in{\cal S}}\vert x_{j}'-x_{j}\vert$
holds for every disjoint segments set ${\cal S}$, then the instance
of decision MMSM is feasible under maximum relocation distance $D+2r_{max}$,
$r_{max}=\max_{i}\{r_{i}\}$.
\end{lem}
\begin{IEEEproof}
We need only to show that if $\sum_{i}\sigma(i,\,D,\,{\cal S})\geq\sum_{[x_{j},\,x_{j}']\in{\cal S}}\vert x_{j}'-x_{j}\vert$
holds at the beginning of Algorithm \ref{alg:mainA-simple-greedy},
then $\sum_{i}\sigma(i,\,D,\,{\cal S})\geq\sum_{[x_{j},\,x_{j}']\in{\cal S}}\vert x_{j}'-x_{j}\vert$
remains true in each step of Algorithm \ref{alg:mainA-simple-greedy}.
Suppose the lemma is not true. Let the step of picking sensor $i$
be the first $\sum_{i}\sigma(i,\,D,\,{\cal S})\geq\sum_{[x_{j},\,x_{j}']\in{\cal S}}\vert x_{j}'-x_{j}\vert$
becomes \emph{false}. Then there must exist $x$ and $x'$, such that
$\sum_{j\in{\cal I}}\sigma(j,\,D,\,x,\,x')\geq\vert x'-x\vert$ and
$\sum_{j\in{\cal I}\setminus i}\sigma(j,\,D,\,x,\,x')<\vert x'-x\vert$.
We analysis all cases wrt all the possible orders of $g_{i}$, $s+2r_{i}$
and $x$ in the line barrier, and show that contradictions exist in
every case.
\begin{enumerate}
\item $g_{i}\leq x$:
In this case, $\sigma(i,\,D,\,[x,\,x'])=0$ holds, i.e. sensor $i$
does not cover any portion of $[x,\,x']$. So we have
\[
\sum_{j\in{\cal I}\setminus\{i\}}\sigma(j,\,D,\,x,\,x')=\sum_{j\in{\cal I}}\sigma(j,\,D,\,[x,\,x'])\geq\vert x'-x\vert,
\]
which contradicts with $\sum_{j\in{\cal I}\setminus\{i\}}\sigma(j,\,D,\,[x,\,x'])<\vert x'-x\vert$.
\item $x<g_{i}\leq s+2r_{i}$:
In this case, sensor $i$ will actually cover $[s,\,s+2r_{i}]$, and
hence $\sigma(i,\,D,\,[x,\,x'])=\min\{g_{i},\,x'\}-x$ is the actual
coverage that sensor $i$ can contribute to $\sum_{j\in{\cal I}}\sigma(j,\,D,\,[x,\,x'])$.
So
\begin{equation}
\sum_{j\in{\cal I}\setminus\{i\}}\sigma(j,\,D,\,[x,\,x'])=\sum_{j\in{\cal I}}\sigma(j,\,D,\,[x,\,x'])-(\min\{g_{i},\,x'\}-x).\label{eq:eq1}
\end{equation}
Then by combining $\sum_{j\in{\cal I}}\sigma(j,\,D,\,x,\,x')\geq x'-x$
with Inequality (\ref{eq:eq1}), we have
\begin{equation}
\sum_{j\in{\cal I}\setminus\{i\}}\sigma(j,\,D,\,[x,\,x'])\geq x'-x-(\min\{g_{i},\,x'\}-x)=x'-\min\{g_{i},\,x'\}\label{eq:eq3}
\end{equation}
On the other hand, the length of the portion of $[x,\,x']$ that needs
to be covered is apparently $\vert x'-x\vert-(\min\{g_{i},\,x'\}-x)$.
From the infeasibility of the remaining sensors in ${\cal I}$, we
have
\begin{equation}
\sum_{j\in{\cal I}\setminus\{i\}}\sigma(j,\,D,\,[x,\,x'])<x'-x-(\min\{g_{i},\,x'\}-x)=x'-\min\{g_{i},\,x'\}.\label{eq:reve}
\end{equation}
A contradiction arises by comparing Inequality (\ref{eq:eq3}) and
(\ref{eq:reve}).
\item $g_{i}>x$ and $g_{i}>s+2r_{i}$:
Assume that $s+2r_{i}\leq x$. This assumption is without loss of
generality, since otherwise from $\sum_{j\in{\cal I}\setminus\{i\}}\sigma(j,\,D,\,x,\,x')<\vert x'-x\vert$
and the fact that $[x,\,s+2r_{i}]$ is already covered by sensor $i$,
we have $\sum_{j\in{\cal I}\setminus\{i\}}\sigma(j,\,D,\,s+2r_{i},\,x')<x'-(s+2r_{i})$.
That is, we need only to set $x=s+2r_{i}$, and obtain contractions
similar as this case. We will show that $\sum_{j\in{\cal I}\setminus\{i\}}\sigma(j,\,D,\,s+2r_{i},\,x')\geq x'-(s+2r_{i})$
actually holds and get a construction
By inductions, we have
\[
\sum_{j\in{\cal I}}\sigma(j,\,D,\,\{[s,\,s+2r_{i}],\,[x,\,x']\})\geq2r_{i}+x'-x.
\]
That is,
\[
\sum_{j\in{\cal I}}\sigma(j,\,D,\,\{[s,\,s+2r_{i}],\,[x,\,x']\})-2r_{i}\geq x'-x.
\]
So
\begin{equation}
\sum_{j\in{\cal I}\setminus\{i\}}\sigma(j,\,D,\,\{[s,\,s+2r_{i}],\,[x,\,x']\})\geq x'-x.\label{eq:suff}
\end{equation}
Assume that sensor $j\neq i$ is a sensor which can contribute to
both $\sigma(j,\,D,\,[s,\,s+2r_{i}])$ and $\sigma(j,\,D,\,[x,\,x'])$.
Let $\phi(j,\,D,\,[s,\,s+2r_{i}])$ and $\phi(j,\,D,\,[x,\,g_{i}])$
be the portion that sensor $j$ actually contributes $[s,\,s+2r_{i}]$
and $[x,\,g_{i}]$, respectively, within $\sum_{j\in{\cal I}}\sigma(j,\,D,\,([s,\,s+2r_{i}],\,[x,\,x']))$.
We need only to show that $\sum_{j\in{\cal I}\setminus\{i\}}\phi(j,\,D,\,[s,\,s+2r_{i}])$
is sufficient to be relocated to compensate all the coverage sensor
$i$ contributes to $[x,\,g_{i}]$.
Since the chosen sensor $i$ is with smallest $g_{i}$ within all
the sensors of $l_{i}-2r_{max}\leq s$, sensor $j\in{\cal I}\setminus\{i\}$
is with $g_{j}\geq g_{i}$. So the potion of sensor $j$ covering
$[s,\,s+2r_{i}]$, i.e. $\phi(j,\,D,\,[s,\,s+2r_{i}])$, can all be
relocated to cover any portion of $[x,\,g_{i}]$. So $\phi(j,\,D,\,[s,\,s+2r_{i}])+\phi(j,\,D,\,[x,\,\min\{g_{i},\,x'\}])$
is actually the portion of the cover that sensor $j$ can contributes
to $[x,\,g_{i}]$. Therefore, we have
\begin{eqnarray}
\sum_{j\in{\cal I}\setminus\{i\}}\sigma(j,\,D,\,[x,\,x']) & = & \sum_{j\in{\cal I}\setminus\{i\}}(\phi(j,\,D,\,[s,\,s+2r_{i}])\label{eq:sum}\\
+\phi(j,\,D,\,[x,\,\min\{g_{i},\,x'\}]) & + & \sum_{j\in{\cal I}\setminus\{i\}}\phi(j,\,D,\,[\min\{g_{i},\,x'\},\,x']\}).\nonumber
\end{eqnarray}
On the other hand, we have
\begin{eqnarray}
& \sum_{j\in{\cal I}\setminus\{i\}}\sigma(j,\,D,\,\{[s,\,s+2r_{i}],\,[x,\,x']\}) & \leq\sum_{j\in{\cal I}\setminus\{i\}}\phi(j,\,D,\,[s,\,s+2r_{i}])\label{eq:theother}\\
+ & \sum_{j\in{\cal I}\setminus\{i\}}\phi(j,\,D,\,[x,\,\min\{g_{i},\,x'\}]) & +\sum_{j\in{\cal I}\setminus\{i\}}\phi(j,\,D,\,[\min\{g_{i},\,x'\},\,x']\}).\nonumber
\end{eqnarray}
Combining Inequality (\ref{eq:suff}), (\ref{eq:sum}) and (\ref{eq:theother}),
we have $\sum_{j\in{\cal I}\setminus\{i\}}\sigma(j,\,D,\,[x,\,x'])\geq\sum_{j\in{\cal I}\setminus\{i\}}\sigma(j,\,D,\,\{[s,\,s+2r_{i}],\,[x,\,x']\})\geq x'-x$,
which contradicts with the assumption.
\end{enumerate}
\end{IEEEproof}
Now we will prove Theorem \ref{thm:greedyfinalthr}. If $D\geq D^{*}$,
then the decision MMSM is feasible, and hence following Proposition
\ref{prop:necessary} $\sum_{i}\sigma(i,\,D,\,{\cal S})\geq\sum_{[x_{j},\,x_{j}']\in{\cal S}}\vert x_{j}'-x_{j}\vert$
holds for every ${\cal S}$ at the beginning of Algorithm \ref{alg:mainA-simple-greedy}.
Then from Lemma \ref{lem:sufficientcoreforgreedy}, we immediately
have the instance is feasible under relocation distance bound $D$,
which completes the proof of Theorem \ref{thm:greedyfinalthr}.
\begin{cor}
The performance guarantee of Algorithm \ref{alg:mainA-simple-greedy}
in Theorem \ref{thm:greedyfinalthr} is nearly tight.
\end{cor}
As the example depicted in Figure \ref{fig:A-tight-maingreedalgorithm},
$d(OPT)=2r_{1}$ while the output of the algorithm is with a maximum
relocation distance $2r_{2}$. So when $r_{2}\gg r_{1}$, $d(OPT)+2r_{max}\thickapprox2r_{1}+2r_{2}$,
and hence the analysis of Algorithm \ref{alg:mainA-simple-greedy}
is nearly tight in Theorem \ref{thm:greedyfinalthr}.
\begin{figure*}
\includegraphics{tightexamplegreedy1}
\caption{\label{fig:A-tight-maingreedalgorithm}A near-tight example for Algorithm
\ref{alg:mainA-simple-greedy}: (a) An instance of decision MMSM:
line barrier is between points $(0,\,0)$ and $(2r_{1}+2r_{2},\,0)$,
while the positions of sensor 1 and 2 are respectively $(2r_{2}+r_{1},\,0)$
and $(2r_{1}+r_{2},\,0)$; (b) The optimal solution with maximum relocation
distance $2r_{1}$; (c) The solution output by Algorithm \ref{alg:mainA-simple-greedy}
with maximum relocation distance $2r_{2}$.}
\end{figure*}
\section{An LP-based Approximation for Decision MMSM}
This section will give an LP-based approximation algorithm to determine
whether an instance of the decision MMSM problem is feasible. The
algorithm first transfers the instance to a corresponding instance
of decision DMMSM, and then an instance of the fractional cardinality
matching problem with a proposed LP relaxation. Our algorithm answers
``feasible'' or ``infeasible'' according to the computed optimum
solution of the LP relaxation. We show that if our algorithm returns
\emph{feasible}, then a solution to MMSM can be constructed under
the maximum relocation distance $D+r_{max}$ by rounding up a fractional
optimum solution to the relaxation.
\subsection{Transferring to an Instance of DMMSM }
The key idea of the transfer is first to compute $l_{i}$ and $g_{i}$
for each $i$ wrt to the given $D$, and then add $(l_{i},\,0)$ and
$(g_{i},\,0)$ to the barrier as two vertices on the line. That is,
$V=\{(l_{i},\,0)\vert i\in[n]^{+}\}\cup\{(g_{i},\,0)\vert i\in[n]^{+}\}$.
W.l.o.g. assume that the vertices of $V$ appear on the line barrier
in the order of $v_{0},\,\dots,\,v_{|V|}$, from left to right on
the line barrier. Then the algorithm adds an edge between every pair
of $v_{i}$ and $v_{i+1}$. So $E=\{e_{i}(v_{i},\,v_{i+1})\vert i\in[\vert V\vert-1]^{+}\}$.
Formally the transfer is as in Algorithm \ref{alg:The-transfering-algorithmfromMMSMtoDMMSM}.
\begin{algorithm}
\textbf{Input:} An instance of MMSM;
\textbf{Output: }$G=(V,\,E)$, an instance of DMMSM.
\enskip{}1: Set $V:=\emptyset$ and $E:=\emptyset$;
\enskip{}2: \textbf{For} each edge $i\in S$ \textbf{do}
\enskip{}3: \quad{}Compute $l_{i}$ and $g_{i}$;
\enskip{}4:\textbf{ }\quad{}$V\leftarrow V\cup\{(l_{i},\,0),\,(g_{i},\,0)\}$;\textbf{ }
\enskip{}5: Number the vertices of $V$, such that the vertices appear
in the barrier from left to right in the order of $v_{0},\,\dots,\,v_{|V|}$;
\enskip{}6: Set $E:=\{e_{j}(v_{j},\,v_{j+1})\vert j\in[\vert V\vert-1]^{+}\}$;
\enskip{}7:\textbf{ }Return $G=(V,\,E)$.
\caption{\label{alg:The-transfering-algorithmfromMMSMtoDMMSM}The transferring
algorithm. }
\end{algorithm}
For the time complexity and the size of the graph, we have:
\begin{lem}
Algorithm \ref{alg:The-transfering-algorithmfromMMSMtoDMMSM} runs
in $O(n\log n)$ time, and output a graph $G$ with $\vert V\vert=O(n)$
and $\vert E\vert=O(n)$.
\end{lem}
According to the algorithm, $\vert V\vert=O(n)$ and $\vert E\vert=O(n)$
hold trivially. Algorithm \ref{alg:The-transfering-algorithmfromMMSMtoDMMSM}
takes in $O(n\log n)$ time to sort (number) the vertices of $V$
in Step 5, since $\vert V\vert=O(n)$. Other steps of the algorithm
takes trivial time compared to the sorting. So the total runtime of
Algorithm \ref{alg:The-transfering-algorithmfromMMSMtoDMMSM} is $O(n\log n)$.
\begin{lem}
An instance of MMSM is feasible under $D$ if and only if its corresponding
DMMSM instance produced by Algorithm \ref{alg:The-transfering-algorithmfromMMSMtoDMMSM}
is feasible under $D$.
\end{lem}
\begin{IEEEproof}
According to Algorithm \ref{alg:The-transfering-algorithmfromMMSMtoDMMSM}
and following the definition of MMSM and DMMSM, a solution to an instance
of MMSM is obviously a solution to the corresponding instance of DMMSM,
and vice versa. So an instance of MMSM is feasible, iff its corresponding
DMMSM instance is feasible.
\end{IEEEproof}
\subsection{Fractional Maximum Cardinality Matching wrt DMMSM}
Let $\vert e_{i}\vert=v_{i+1}-v_{i}$ be the length of edge $e_{i}$.
Assuming that $v_{i_{1}}=l_{i}$ and $v_{i_{2}}=g_{i}$, we set $J_{i}=\{e_{j}\vert j=i_{1},\,i_{1}+1,\,\dots,\,i_{2}-1\}$.
Then the linear programming relaxation (LP1) for DMMSM is as below:
\[
\max\sum_{i\in[n]^{+}}\sum_{j\in J_{i}}x_{i,\,j}
\]
subject to
\begin{eqnarray}
\sum_{j\in J_{i}}x_{i,j} & \leq2r_{i} & \forall i\in\{1,\,\dots,\,n\}\label{eq:sensoratmostone}\\
\sum_{i\in[n]^{+}}x_{i,\,j} & \leq\vert e_{j}\vert & \forall j\in\{1,\,\dots,\,\vert V\vert\}\label{eq:coverrequirement}\\
0\leq x_{i,\,j} & \leq\vert e_{j}\vert & \forall i\in\{1,\,\dots,\,n\},\,j\in J_{i}\label{eq:capacitybd}
\end{eqnarray}
where $\sum_{j\in J_{i}}x_{i,j}\leq2r_{i}$ is because a sensor $i$
can at most cover length $2r_{i}$ of the barrier, and Inequality
(\ref{eq:coverrequirement}) is because the covered length of each
edge $e_{i}$ (segment) is at most $\vert e_{j}\vert$.
Our algorithm determines decision DMMSM according to the computed
optimum solution, say $\mathbf{x}$, to LP1: the algorithm outputs
``feasible'' if $\sum_{i\in[n]^{+}}\sum_{j\in J_{i}}x_{i,\,j}=M$,
and outputs ``infeasible'' otherwise.
\begin{algorithm}
\textbf{Input:} An instance of DMMSM;
\textbf{Output: }Answer whether the instance is feasible.
\enskip{}1: Solve LP1 against the instance of DMMSM by Karmakar's
algorithm as in \cite{karmarkar1984new}, and obtain an optimal solution
$\mathbf{x}$;
\enskip{}2: \textbf{If} $\sum_{i\in[n]^{+}}\sum_{j\in J_{i}}x_{i,\,j}=M$
according to $\mathbf{x}$ \textbf{then}
\enskip{}3: \quad{}Return ``feasible'';
\enskip{}4:\textbf{ else}
\enskip{}5: \quad{}Return ``infeasible'';
\caption{\label{alg:mainLProundDMMSM}The determining algorithm for decision
DMMSM. }
\end{algorithm}
It is known that there exist polynomial-time algorithms for solving
linear programs. In particular, using Karmakar's algorithm to solve
LP1 will take $O(n^{7}L)$ time \cite{karmarkar1984new}, since there
are $O(n^{2})$ variables totally in LP1.
\begin{lem}
Algorithm \ref{alg:mainLProundDMMSM} runs in time $O\left(n^{7}L\right)$.
\end{lem}
It is worth to note that the simplex algorithm has a much better practical
performance than Karmakar's algorithm \cite{korte2002combinatorial}.
So using the simplex method the algorithm would be faster than $O(n^{7}L)$
in real world applications.
The performance guarantee of Algorithm \ref{alg:mainLProundDMMSM}
is as given in the following theorem, whose proof will be given in
next subsection.
\begin{thm}
\label{thm:LPbasedratio}If Algorithm \ref{alg:mainLProundDMMSM}
returns ``infeasible'', then the instance of DMMSM is truly infeasible
under the given $D$; Otherwise, the instance of DMMSM is truly feasible
under the maximum relocation distance $D+r_{max}$, where $r_{max}=\max_{i}\{r_{i}\}$.
\end{thm}
\begin{cor}
The performance guarantee given in Theorem \ref{thm:LPbasedratio}
is nearly tight for Algorithm \ref{alg:mainLProundDMMSM}.
\end{cor}
From Figure \ref{fig:A-tight-exampleforLP}, an optimal fractional
solution to LP1 is with a maximum relocation distance $r_{1}$, while
a true optimal solution for MMSM must be with a maximum relocation
distance $r_{2}$. Thus, the integral gap for LP1 is $r_{2}-r_{1}\approx r_{max}$
when $r_{2}\gg r_{1}$. That is, for any fixed $\epsilon>0$, the
maximum relocation distance increment could be larger than $r_{max}-\epsilon$
for rounding an optimum solution of LP1 to a true solution of MMSM.
Therefore, the ratio is nearly-tight for Algorithm \ref{alg:mainLProundDMMSM}.
\begin{figure*}
\includegraphics[width=0.85\textwidth]{tightexampleLP1}
\caption{\label{fig:A-tight-exampleforLP}The integrality gap: (a) An instance
of decision MMSM: line barrier is between points $(0,\,0)$ and $(2r_{1}+2r_{2},\,0)$,
while the positions of sensor 1 and 2 are both $(r_{1}+r_{2},\,0)$;
(b) Algorithm \ref{alg:mainLProundDMMSM} outputs ``feasible'' if
$D\geq r_{2}$; (c) The optimal maximum relocation distance is actually
$r_{1}$.}
\end{figure*}
\subsection{Proof of Theorem \ref{thm:LPbasedratio} }
This subsection will prove Theorem \ref{thm:LPbasedratio} by showing
a fractional optimum solution to LP1 can be rounded up to an integral
solution of DMMSM with a maximum relocation distance $D+r_{max}$.
Let $\mathbf{x}$ be an optimum solution to LP1. Recall that $x_{ij}$
is the (fractional) portion sensor $i$ covering edge $j$, the key
idea of our algorithm is to aggregate the portions of sensor $i$
covering different $j$s, such that the portions combine to a line
segment which $i$ can cover within movement $D+r_{max}$.
Our algorithm is composed by two parts. The first part is called \emph{pre-aggregation}
which rounds $x_{ij}$ to $1$ in a ``pseudo'' way. More precisely,
assume that $0<x_{i_{1},\,j},\,\dots,\,x_{i_{h},\,j}<0$ are the variables
shares edge $e_{j}$. Then the \emph{pre-aggregation} divides $e_{j}$
to a set of sub-edges $\{e_{j,\,i_{1}},\,\dots,e_{j,\,i_{h}}\}$,
in which $\vert e_{j,\,i_{l}}\vert=\vert e_{j}\vert\cdot x_{i_{l},\,j}$.
We set $x_{i_{l},\,j,\,l}=1$, which is, edge $e_{j,\,i_{l}}$ completely
covered by sensor $i_{l}$.
Let ${\cal S}_{i}$ be the set of sub-edges covered by sensor $i$
accordingly. The second part, which is called \emph{aggregation,}
aggregates the edges of ${\cal S}_{i}$ for each $i$ such that the
edges covered by an identical sensor will connect together. The \emph{aggregation}
starts from the following simple observation whose correctness is
obviously:
\begin{prop}
Let $i$ and $i'$ be two sensors. Let ${\cal S}_{i}$ and ${\cal S}_{i}'$
be the set of edges covered by sensor $i$ and $i'$, respectively.
Then, for any sub-edges $j_{1},\,j_{2}\in{\cal S}_{i}$ and $j_{1}',\,j_{2}'\in{\cal S}_{i'}$,
w.l.o.g. assuming $j_{1}<j_{1}'$, $j_{1}<j_{2}$ and $j_{1}'<j_{2}'$,
then exactly one of the following cases holds: (1) $j_{1}<j_{2}<j_{1}'<j_{2}'$
; (2) $j_{1}<j_{1}'<j_{2}<j_{2}'$ ; (3) $j_{1}<j_{1}'<j_{2}'<j_{2}$.
\end{prop}
The key observation of the \emph{aggregation} is that if case (2)
and (3) in the above proposition can be eliminated, then the set of
edges in ${\cal S}_{i}$ are aggregated together that they can be
truly monitored by sensor $i$. So the \emph{aggregation} is accordingly
composed by two phases called the \emph{swap phase} and the \emph{exchange}
step, which are to eliminate case (2) and (3), respectively. Formally,
the algorithm is as in Algorithm \ref{alg:rounding} (An example of
such rounding depicted as in Figure \ref{fig:ori} and \ref{fig:exe}).
\begin{figure*}
\includegraphics{ori}
\caption{\label{fig:ori}An instance of decision MMSM: Sensors 1, 2 and 3 are
with identical sensing radii $r$, and positions $(3r,\,0)$, $(3r,\,-1.2r)$,
$(3r,\,2r)$, respectively. The barrier to cover is $[0,\,6r]$ and
the given $D=2r$.}
\end{figure*}
\begin{figure*}
\includegraphics{exe3}
\caption{\label{fig:exe} Execution of Algorithm \ref{alg:rounding} against
the instance as in Figure \ref{fig:ori}.}
\end{figure*}
\begin{algorithm}
Input: $\mathbf{x}$, an optimum solution to LP1 with $\sum_{i\in[n]^{+}}\sum_{j\in J_{i}}x_{i,\,j}=M$;
Output: Relocate positions for the sensors.
\enskip{}1: Run pre-aggregation: compute ${\cal S}_{i}$ for each
sensor $i$ according to $\mathbf{x}$;
\enskip{}\quad{} /{*}${\cal S}_{i}$ contains the sub-edges covered
by sensor $i$. {*}/
\enskip{}2: Set ${\cal S}=\{{\cal S}_{i}\vert i\in[n]^{+}\}$;
\enskip{}3: Swap(${\cal S}$); /{*}The \emph{swap phase}.{*}/
\enskip{}4: Combine every pairs of adjacent edges for each ${\cal S}_{i}\in{\cal S}$;
\enskip{}5: Exchange (${\cal S}$); /{*}The \emph{exchange} step.
{*}/
\enskip{}6: \textbf{For} $i=1$ to $n$ \textbf{do}
\enskip{}\quad{}\quad{} Compute $(x_{i}',\,0)$ such that every
sub-edge of ${\cal S}_{i}$ is with the range $[x_{i}'-r_{i},\,x_{i}'+r_{i}]$
while $\sqrt{(x_{i}'-x_{i})^{2}+y_{i}^{2}}$ attains minimum;
\enskip{}7: Return $\{(x'_{i},\,0)\vert i=1,\,\dots,\,n\}$.
\caption{\label{alg:rounding}An approximation algorithm for rounding an optimum
solution to LP1.}
\end{algorithm}
Note that if two adjacent sub-edges belong to the same ${\cal S}_{i}$,
say $e_{j_{1}},\,e_{j_{2}}\in{\cal S}_{i}$ with $v_{j_{1}+1}=v_{j_{2}}$,
then we can combine the two sub-edges as one, since they are segments
both covered by sensor $i$. So Step 4 of Algorithm \ref{alg:rounding}
is actually to set ${\cal S}_{i}:={\cal S}_{i}\setminus\{e_{j_{1}},\,e_{j_{2}}\}\cup e(v_{j_{1}},\,v_{j_{2}+1})$
for every such pair of adjacent edges of ${\cal S}_{i}$ for every
$i$.
The \emph{swap }phase, as in Step 3 of Algorithm \ref{alg:rounding},
will eliminate case (2) (i.e. $j_{1}<j_{1}'<j_{2}<j_{2}'$) by swapping
the coverage sensors of the edges without causing any increment on
the maximum relocation distance. The observation inspiring the swap
is that for any $j_{1}<j_{1}'<j_{2}<j_{2}'$, we can swap the two
sensors covering $j_{1}'$ and $j_{2}$ without increasing the maximum
relocation distance. More precisely, we cover a portion of $\min\{\vert j_{1}'\vert,\,\vert j_{2}\vert\}$
of $j_{1}'$ with $i$ and cover a portion of $\min\{\vert j_{1}'\vert,\,\vert j_{2}\vert\}$
of $j_{2}$ with $i'$. The formal layout of the \emph{swap phase}
is as in Algorithm \ref{alg:swap}.
\begin{algorithm}
\enskip{}1: \textbf{While} ${\cal S}\neq\emptyset$ \textbf{do}
\enskip{}2: \quad{}Find $S_{i}\in{\cal S}$ that contains the leftmost
edge;
\enskip{}3: \quad{}\textbf{For} $h=1$ to $\vert{\cal S}_{i}\vert-1$\textbf{do}
\enskip{}4: \quad{}\quad{}\textbf{For} ${\cal S}_{i'}\in{\cal S}\setminus{\cal S}$
\textbf{do}
\enskip{}5: \quad{}\quad{}\quad{}Find a pair of sub-edges $e_{u},\,e_{w}\in{\cal S}_{i'}$
such that $j_{h}<u<j_{h+1}<w$ holds;
\enskip{}\enskip{}\quad{}\quad{}\quad{}\quad{}/{*}Recall that
the two endpoints of edge $e_{u}$ is $v_{u}$ and $v_{u+1}$.{*}/
\enskip{}6: \quad{}\quad{}\quad{}\textbf{If} no such $e_{u},\,e_{w}$
exists \textbf{then}
\enskip{}7: \quad{}\quad{}\quad{}\quad{}break;
\enskip{}8: \quad{}\quad{}\quad{}\textbf{If} $\vert e_{u}\vert\geq\vert e_{j_{h+1}}\vert$
\textbf{then}
\enskip{}9: \quad{}\quad{}\quad{}\quad{}Add vertex $p=(x(v_{u})+\vert e_{j_{h+1}}\vert,\,0)$
to $G$; /{*}$x(v_{u})$ is the $x$coordinator of $v_{u}$.{*}/
10: \quad{}\quad{}\quad{}\quad{}${\cal S}_{i}:=S_{i}\setminus\{e_{j_{h+1}}\}\cup\{e(v_{u},\,p)\}$
and ${\cal S}_{i'}:=S_{i'}\setminus\{e_{u}\}\cup\{e_{j_{h+1}}\}\cup e(p,\,v_{u+1})$;
11: \quad{}\quad{}\quad{}\textbf{Else}
12: \quad{}\quad{}\quad{}\quad{}Add vertex $p=(x(v_{j_{h+1}+1})-\vert e_{u}\vert,\,0)$
to $G$;
13: \quad{}\quad{}\quad{}\quad{}${\cal S}_{i'}:=S_{i'}\setminus\{e_{u}\}\cup\{e(p,\,v_{j_{h+1}+1})\}$
and ${\cal S}_{i}:=S_{i}\setminus\{e_{j_{h+1}}\}\cup\{e_{u}\}\cup e(v_{j_{h+1}},\,p)$;
14: \quad{}\quad{}\quad{}Update the numbering of the vertices and
the edges accordingly;
15: \quad{}${\cal S}:={\cal S}\setminus{\cal S}_{i}$;
\caption{\label{alg:swap}Swap(${\cal S}$).}
\end{algorithm}
Note that Steps 8-13 will add new vertices and edges to the graph,
so $\sum_{i=1}^{n}\vert{\cal S}_{i}\vert$ may increases. However,
we can always guarantee $\sum_{i=1}^{n}\vert{\cal S}_{i}\vert\leq n\vert E\vert$.
Since otherwise, following the pigeonhole principle, there must exist
two sub-edges, say $e_{j_{1}}$ and $e_{j_{2}}$ which are in an identical
${\cal S}_{i}$ and within the range of an identical edge of $E$.
Then, such two sub-edges $e_{j_{1}},\,e_{j_{2}}$ can be combined
as one, by setting $x(v_{j_{1}+1})=x(v_{j_{1}+1})+\vert e_{j_{2}}\vert$
and move every sub-edge between $e_{j_{1}}$ and $e_{j_{2}}$ to right
with an offset with length $\vert e_{j_{2}}\vert$. Clearly, following
the meaning of a sensor covering edges as in the definition of DMMSM,
these movement does not cause any increment on the relocation distance
of each sensor.
In Algorithm \ref{alg:swap}, the \emph{while}-loop iterates for $O(n)$
times and the outer \emph{for}-loop iterates for $O(n)$ times. Since
the inner \emph{for}-loop iterates for at most $O(\sum_{i=1}^{n}\vert{\cal S}_{i}\vert)$
times. Then from $\sum_{i=1}^{n}\vert{\cal S}_{i}\vert\leq n\vert E\vert=O(n^{2})$,
the \emph{for-loops iterates at most $O(n^{2})$ time. }So we have
the total runtime of the \emph{swap phase}:
\begin{lem}
\label{lem:swaptime}Algorithm\ref{alg:swap} runs in time $O(n^{4})$.
\end{lem}
For the correctness of Algorithm \ref{alg:swap}, we have the following
lemma:
\begin{lem}
After the swap phase of Algorithm \ref{alg:mainA-simple-greedy},
there exist no ${\cal S}_{i}$ and ${\cal S}_{i'}$ with sub-edges
$j_{1},\,j_{2}\in{\cal S}_{i}$ and $j_{1}',\,j_{2}'\in{\cal S}_{i'}$,
such that $j_{1}<j_{1}'<j_{2}<j_{2}'$ holds.
\end{lem}
\begin{IEEEproof}
After the procession of ${\cal S}_{i}$, any ${\cal S}_{i'}\in{\cal S\setminus{\cal S}}_{i}$
must have all its sub-edges appear between the two edges $e_{j_{h}}\in{\cal S}_{i}$
and $e_{j_{h+1}}\in{\cal S}_{i}$ for some $h$. Then, after ${\cal S}_{i}$
is processed, Case (2) can not hold for any edge pair within ${\cal S}_{i}$
in any other latter iterations. Therefore, the algorithm guarantees
that one set contains no sub-edges of Case (2) at one iteration, and
hence after $n$ iterations, sub-edges of Case (2) are eliminated.
\end{IEEEproof}
The \emph{exchange} phase, invoked in Step 5 in Algorithm \ref{alg:rounding},
is to eliminate case (3) (i.e. $j_{1}<j_{1}'<j_{2}'<j_{2}$). The
key idea of the exchange is to move $j_{1}$ to the place exactly
before $j_{2}$ (or to move $j_{2}$ to the place exactly after $j_{1}$),
and then move the edges between $j_{1}$ and $j_{2}$ accordingly.
The choosing of movements (move $j_{1}$ to $j_{2}$, or $j_{2}$
to $j_{1}$) depends on the current \emph{offset }of the sub-edges
between $j_{1}$ and $j_{2}$, as well as the length of the edge $j_{1}$
and the length sum of the other edges in ${\cal S}_{i}\setminus\{j_{1}\}$,
where the \emph{offset} of an sub-edge $j$ is the distance from the
current position of $j$ to its original position. Formally, the \emph{exchange
}phase is as in Algorithm \ref{alg:exchange}.
\begin{algorithm}
Initially, each ${\cal S}_{i}$ contains a set of non-adjacent edges,
because the combining in Step 4 of Algorithm \ref{alg:mainLProundDMMSM}.
Assume that ${\cal E}=\{C_{1},\,\dots,\,C_{k}\}$ is the current set
of edges, which appear on the barrier from left to right in the order
of $C_{1},\,C_{2},\,\dots,$ $C_{k}$;
\enskip{}1: Set ${\cal O}:=\{o_{1},\,\dots,\,o_{k}\}$ and $o_{i}:=0$
for all $i$ initially; /{*}$o_{i}$ is the current movement offset
for $C_{i}$. {*}/
\enskip{}2: \textbf{While} true \textbf{do}
\enskip{}3: \quad{}Find the minimum $i$ such that there exists
$C_{i+\Delta}$ shares an identical ${\cal S}_{j_{i}}$ with $C_{i}$
for some $\Delta>1$;
\enskip{}4: \quad{}\textbf{If} no such $\Delta$ exists \textbf{then}
\enskip{}5: \quad{}\quad{}terminates;
\enskip{}6: \quad{}Find the minimum $\delta>1$ such that $C_{i+\delta}$
shares an identical ${\cal S}_{j_{i}}$ with $C_{i}$;
\enskip{}7: \quad{}Mover (${\cal E}$, ${\cal O}$, $i$, $i+\delta$);
/{*} Move $C_{i+\delta}$ or $C_{i}$, and the edges between them
accordingly. {*}/
\enskip{}8: Return ${\cal S}$.
\caption{\label{alg:exchange}Exchange(${\cal S}$).}
\end{algorithm}
In Algorithm \ref{alg:exchange}, the function Mover (${\cal E}$,
${\cal O}$, $i$, $i+\delta$) actually decides whether to move $C_{i+\delta}$
or $C_{i}$, according to which one of the two values $\vert C_{i}\vert-o_{i}$
and $\sum_{j:\,C_{j}\in{\cal S}_{j_{i}}\setminus\{C_{i}\}}\vert C_{j}\vert+o_{i}$
is larger. Intuitionally, without considering offsets, if we move
$C_{i}$ then the moving distance of $C_{l}$ between $C_{i}$ and
$C_{i+\delta}$ will be $\vert C_{i}\vert$; if move $C_{i+\delta}$,
the moving distance will be $\sum_{j:\,C_{j}\in{\cal S}_{j_{i}}\setminus\{C_{i}\}}\vert C_{j}\vert$
instead of $\vert C_{i+\delta}\vert$, since not only $C_{i+\delta}$
but every $C_{j}\in{\cal S}_{j_{i}}\setminus\{C_{i}\}$ will be moved
to adjacent to $C_{i}$. Then considering the offsets, we have the
criteria of moving $C_{i}$ or $C_{i+\delta}$. The moving algorithm
is as in Algorithm \ref{alg:mover}.
\begin{algorithm}
\enskip{}1: \textbf{If} $\vert C_{i}\vert-o_{i}\geq\sum_{j:\,C_{j}\in{\cal S}_{j_{i}}\setminus\{C_{i}\}}\vert C_{j}\vert+o_{i}$\textbf{
then} /{*}Move $C_{i+\delta}$ to the place adjacent to and in the
right side of $C_{i}$.{*}/
\enskip{}2: \quad{}Set ${\cal E}:={\cal E}\setminus\{C_{i+\delta}\}$
and update the numbering of the edges and vertices of ${\cal {\cal E}}$
accordingly;
\enskip{}3: \quad{}\textbf{For} $j=1$ to $\delta$ \textbf{do}
\enskip{}4: \quad{}\quad{}$x(v_{i+j}):=x(v_{i+j})+\vert C_{i+\delta}\vert$;
\enskip{}5: \quad{}\textbf{For} $j=1$ to $\delta-1$ \textbf{do
}/{*}Set the offset accordingly.{*}/
\enskip{}6: \quad{}\quad{}Set $o_{i+j}:=o_{i+j}+\vert C_{i+\delta}\vert$;
\enskip{}7: \textbf{Else} /{*}Move $C_{i+\delta}$. The case is similar
to line 1-8.{*}/
\enskip{}8: \quad{}Set ${\cal E}:={\cal E}\setminus\{C_{i}\}$ and
update the numbering of ${\cal {\cal E}}$ accordingly
\enskip{}9: \quad{}\textbf{For} $j=1$ to $\delta$ \textbf{do}
10: \quad{}\quad{}$x(v_{i+j}):=x(v_{i+j})-\vert C_{i}\vert$;
11: \quad{}\textbf{For} $j=1$ to $\delta-1$ \textbf{do}
12: \quad{}\quad{}Set $o_{i+j}:=o_{i+j}-\vert C_{i}\vert$;
\caption{\label{alg:mover}Mover (${\cal E}$, ${\cal O}$, $i$, $i+\delta$).}
\end{algorithm}
\begin{lem}
In Algorithm \ref{alg:rounding}, a sensor needs only at most $D+r_{max}$
movement to cover $C_{1},\,\dots,\,C_{k}$ when the given instance
is feasible wrt $D$.
\end{lem}
\begin{IEEEproof}
Clearly, after the swap phase sensor $i$ needs at most $D$ to any
edges of $S_{i}$. It remains to analysis the exchanging phase. We
will show that for a component $C_{i}$, its offset satisfies $-r_{max}\leq o_{i}\leq r_{max}$.
Let $o_{i_{1}}$ be the first non-zero value of $o_{i}$. Clearly
$-r_{max}\leq o_{i_{1}}\leq r_{max}$ holds, since $o_{i_{1}}$ is
actually $\min\{\vert C_{i_{1}}\vert,\,\vert C_{i_{1}+\delta_{1}}\vert\}$,
and $\vert C_{i_{1}}\vert+\vert C_{i_{1}+\delta_{1}}\vert\leq2r_{max}$,
where $\delta_{1}>1$ is minimum that $C_{i_{1}}$ and $C_{i_{1}+\delta_{1}}$
shares an identical ${\cal S}_{j}\in{\cal S}$. Then after the $t$th
times that $o_{i}$ changes, we have $o_{i_{t}}=\min\{\vert C_{i_{t}}\vert-o_{i_{t-1}},\,\vert C_{i_{t}+\delta_{t}}\vert+o_{i_{t-1}}\}$
according to Algorithm \ref{alg:mover}. So $o_{i_{t}}\leq\frac{(\vert C_{i_{t}}\vert-o_{i_{t-1}})+(\vert C_{i_{t}+\delta_{t}}\vert+o_{i_{t-1}})}{2}\leq r_{max}$.
On the other hand, from the induction hypothesis, $-r_{max}\leq o_{i_{t-1}}\leq r_{max}$
holds. So $o_{i_{t}}\geq-r_{max}$, since $\vert C_{i_{t}}\vert,\,\vert C_{i_{t}+\delta_{t}}\vert\geq0$.
\end{IEEEproof}
\begin{lem}
Algorithm \ref{alg:rounding} terminates in time $O(n^{7}L)$.
\end{lem}
\begin{IEEEproof}
The algorithm takes $O(n^{7}L)$ to solve LP1 by Karmakar's algorithm
\cite{karmarkar1984new}, since there are $O(n^{2})$ variables in
LP1. The \emph{swap} phase in the algorithm \ref{alg:rounding} takes
at most $O(n^{4})$ time as in Lemma \ref{lem:swaptime}, while the
\emph{exchange} phase iterates at most $O(k)=O(n^{2})$ times, each
iteration takes $O(k)=O(n^{2})$ time to run Mover (${\cal E}$, ${\cal O}$,
$i$, $i+\delta$). Other steps takes trivial time compared to the
above time, so the time complexity of the algorithm is $O(n^{7}L)$.
\end{IEEEproof}
\section{A Matching-Based Solution to Decision MMSM }
This subsection gives a pseudo polynomial algorithm for decision MMSM.
The key idea of the algorithm is to consider MMSM as DMMSM with uniform
edge length, where the barrier to cover is composed by $M$ edges
of length one. Then our algorithm is similar to the case in Section
3, excepting that we use maximum cardinality matching instead of fractional
cardinality matching to compute an initial solution. Using a similar
algorithm as in Subsection 3.3, we can round the initial solution,
i.e. the maximum cardinality matching, to a solution to MMSM.
To model a given instance of MMSM as maximum cardinality matching,
we will construct an equivalent bipartite graph $H=(U,\,V,\,E)$ in
which the vertex set $V$ corresponds to the sensors, the vertex set
$U$ corresponds to the edge set $\cup_{i}J_{i}$, where $J_{i}$
contains exactly the edges that can be completely sensed by sensor
$i$ within maximum movement $D$, and the edge set $E_{H}$ corresponds
to the coverage of the sensors to the edge of $\cup_{i}J_{i}$. Then
we check whether there exists a maximal cardinality matching with
size $M$ in $H$. If no such matching exists, the instance of DMMSM
is infeasible under maximum relocation distance $D$. Otherwise, similarly
as in Subsection 3.3, we can aggregate the vertices of $U$ that are
fractionally covered by an identical sensor, such that the sensors
can relocate within distance $D+r_{max}$ to cover all the edges.
The formal layout of the algorithm is as in Algorithm \ref{alg:mainMatchingbasedalgorithm.}.
\begin{algorithm}
\textbf{Input:} An instance of decision MMSM wrt a given $D$;
\textbf{Output: }$H=(U,\,V,\,E_{H})$.
\enskip{}1:\textbf{ For} each sensor $i$ \textbf{do }/{*}Compute
$J_{i}$ for each $i$. {*}/
\enskip{}2:\quad{}Compute $l_{i}$ and $g_{i}$ wrt $D$;
\enskip{}3:\quad{}Set $J_{i}=\left\{ j\vert j\in\left[\left\lceil l_{i}\right\rceil ,\,\left\lfloor g_{i}\right\rfloor \right]\right\} $;
\enskip{}4:\textbf{ For} $i=0$ to $M$ \textbf{do}
\enskip{}5: \quad{}Add a vertex $u_{i}$ to $U$;
\enskip{}6:\textbf{ For} each sensor $i$ \textbf{do}
\enskip{}7: \quad{}Add $2r_{i}$ vertices $\{v_{i,\,1},\,\dots,\,v_{i,\,2r_{i}}\}$
to $V$;
\enskip{}8:\textbf{ For} every pair of $u_{j}$ and $v_{i,\,l}$
\textbf{do}
\enskip{}9: \quad{}\textbf{If} $e_{j}\in J_{i}$ \textbf{then} Add
edge $(u_{j},\,v_{i,\,l})$ to $E_{H}$;
10: Compute a maximal cardinality matching ${\cal Y}$ for $H$;
11: \textbf{If} $\vert{\cal Y}\vert=M$ \textbf{then} return ``feasible'';
12: \textbf{Else }return ``infeasible''.
\caption{\label{alg:mainMatchingbasedalgorithm.}An matching-based approximation
algorithm for decision MMSM. }
\end{algorithm}
\begin{lem}
Let $R=\sum_{i\in{\cal I}}r_{i}$. Algorithm \ref{alg:mainMatchingbasedalgorithm.}
terminates in time $O\left(R^{2}\sqrt{\frac{M}{\log R}}\right)$.
\end{lem}
\begin{IEEEproof}
The maximal cardinality matching problem is known can be solved in
time $O(\vert V_{H}\vert\sqrt{\frac{\vert V_{H}\vert\vert E_{H}\vert}{\log\vert V_{H}\vert}})$,
where $\vert V_{H}\vert$ is the number of vertices and $\vert V_{H}\vert$
is number of edges. Following Algorithm \ref{alg:mainMatchingbasedalgorithm.},
$\vert V_{H}\vert=M+2R$ and $\vert E_{H}\vert\leq M\cdot2R$. So
the time needed to compute the matching as in Step 10 is actually
$O\left(R\sqrt{\frac{MR^{2}}{\log R}}\right)=O\left(R^{2}\sqrt{\frac{M}{\log R}}\right)$.
Other steps of the algorithm take trivial time compared to compute
the matching.
\end{IEEEproof}
\begin{thm}
\label{thm:improvedalgorithm}Let $D^{*}$ be the minimum movement
under which a given instance of MMSM is feasible. If Algorithm \ref{alg:mainMatchingbasedalgorithm.}
returns ``infeasible'', then $D<D^{*}$; Otherwise, the computed
matching ${\cal Y}$ can be transferred to a true solution to MMSM,
with a maximum relocation distance $D_{SOL}\leq D+r_{max}$.
\end{thm}
Firstly and apparently, if the DMMSM is feasible wrt a given $D$,
there must exist a matching with size $M$ in the corresponding graph
$H$. So if no such matching exists wrt $D$, then the instance DMMSM
must be infeasible wrt $D$. Secondly, similar to Algorithm \ref{alg:rounding},
the computed matching ${\cal Y}$ can be rounded to a true solution
to MMSM using \emph{swap} and \emph{exchange}.
\section{The Complete Algorithm for Solving MMSM}
The key idea of computing approximately a minimum $D$ is to use binary
search and call Algorithm \ref{alg:mainA-simple-greedy} (Or equivalently
Algorithm \ref{alg:mainLProundDMMSM} or Algorithm \ref{alg:mainMatchingbasedalgorithm.})
as a subroutine. Let $d_{i}$ be the minimum distance between sensor
$i$ and any point on the line barrier, and $d_{max}$ be the maximum
distance between the sensors and the barriers. Then clearly every
sensor of $\Gamma$ can cover any point of the barrier within movement
distance $d_{max}$. That is, within movement distance $d_{max}$
the line barrier can be covered successfully by the sensors of $\Gamma$;
Or the sensors in $\Gamma$ is not enough to cover the barrier. Then,
to find the minimum $D$ for MMSM, we need only to use binary search
within the range from 0 to $d_{max}$. Apparently, this takes at most
$O(\log(d_{max}))$ calls of Algorithm \ref{alg:mainA-simple-greedy}
(Or \ref{alg:mainLProundDMMSM}, \ref{alg:mainMatchingbasedalgorithm.})
to find the min-max feasible relocation distance bounded $D_{SOL}$.
Formally, the complete algorithm is as in Algorithm \ref{alg:greeedybasedThe-complete-algorithm1}.
\begin{algorithm}
\textbf{Input: }An instance of MMSM;
\textbf{Output:} The approximate min-max relocation distance $D_{SOL}$,
wrt which MMSM is feasible.
\enskip{}1: \textbf{If} $\sum_{i}2r_{i}<M$ \textbf{then}
\enskip{}2: \quad{}return ``infeasible'';
\enskip{}3: Compute $d_{max}=\max_{i\in[n]^{+},\,x_{l}\in[0,\,M]}\sqrt{(x_{i}-x_{l})^{2}+y_{i}^{2}}$;
\enskip{}4: Set $lower:=0$, $D:=upper:=d_{max}$; /{*} Clearly,
under maximum movement $upper$, the line barrier can be completely
covered. {*}/
\enskip{}5: \textbf{For} each sensor $i$ \textbf{do}
\enskip{}6: \quad{}Compute the leftmost position $l_{i}$ and the
rightmost position $g_{i}$ it can cover wrt $D$;
\enskip{}7: \quad{}Set $J_{i}=\{e_{j}\vert l_{i}\leq j\leq g_{i}\}$;
\enskip{}8: Call Algorithm \ref{alg:mainA-simple-greedy} to determine
whether the instance of MMSM is feasible under$D$;
\enskip{}9: \textbf{If} ``infeasible''\textbf{ then}
10: \quad{}Set $lower:=D$ and then $D=\frac{upper+D}{2}$;
11: \quad{}Go to Step 5;
12: \textbf{Else}
13: \quad{}\textbf{If} $upper-lower\leq1$ \textbf{then}
14: \quad{}\quad{}Return $D_{SOL}=D+2r_{max}$ ); /{*}The algorithm
terminates and outputs the solution.{*}/
15: \quad{}Set $upper:=D$, and then $D:=\frac{lower+D}{2}$ ;
16: \quad{}Go to Step 5.
\caption{\label{alg:greeedybasedThe-complete-algorithm1}An approximation algorithm
for MMSM. }
\end{algorithm}
From Theorem \ref{thm:greedyfinalthr}, we immediately have the time
complexity and ratio for the algorithm as follows:
\begin{lem}
Algorithm \ref{alg:greeedybasedThe-complete-algorithm1} terminates
in time $O(M\log d_{max})$, and output the relocation positions for
the sensors, within a maximum relocation distance $D+2r_{max}$.
\end{lem}
Note that, if using Algorithm \ref{alg:mainLProundDMMSM} instead
of Algorithm \ref{alg:mainA-simple-greedy} in Step 8, the runtime
and the maximum relocation distance of Algorithm \ref{alg:greeedybasedThe-complete-algorithm1}
will be $O(n^{7}L)$ and $D_{SOL}=D+r_{max}$, respectively.
\section{A Simple Factor-2 Approximation Algorithm for MMSM}
Following paper \cite{chen2013algorithms}, MMSM is solvable in time
$O(n^{2}\log n)$ if all the sensors are on the line containing the
barrier. Then a natural idea to solve 2D-MMSM is firstly to perpendicularly
move (some of) the sensors to the line barrier, and secondly solve
the consequent 1D-MMSM by using the algorithm in paper \cite{chen2013algorithms}.
Let $d_{p,\,i}$ be the perpendicular distance between sensor $i$
and the line barrier. Without loss of generality we assume that $0=d_{p,\,0}\leq d_{p,\,1}\leq\dots\leq d_{p,\,i}\leq\dots\leq d_{p,\,n}$,
where sensor $0$ is a virtual sensor with radii 0. Let $S(d_{p,\,i})=\{j\vert d_{p,\,j}\leq d_{p,\,i}\}$
be the set of sensors whose perpendicular distance to the line barrier
is not larger than $d_{p,\,i}$. Let $D_{h}(S(d_{p,\,i}))$ be the
maximum \emph{horizontal} relocation distance of the sensors in $S(d_{p,\,i})$
covering the barrier. Our algorithm will first simply compute $D_{h}(S(d_{p,\,i}))$
for every $i\in[n]^{+}$, and then select $\min\{d_{p,\,i}+D_{h}(S(d_{p,\,i}))\vert i\in[n]^{+}\}$
as the maximum relocation distance.
\begin{lem}
$\min\{d_{p,\,i}+D_{h}(S(d_{p,\,i}))\vert i\in[n]^{+}\}\leq2D^{*}$.
\end{lem}
\begin{IEEEproof}
For an optimum relocation solution to 2D-MMSM, assume that $d_{p,\,i^{*}}$
is the maximum perpendicular distance of the relocated sensors. Then
$d_{p,\,i^{*}}\leq D^{*}$, since sensor $i^{*}$ has to move at least
distance $d_{p,\,i^{*}}$ to cover the barrier. On the other hand,
apparently we have $D_{h}(S(d_{p,\,i^{*}}))\leq D^{*}$ i.e. the optimum
maximum horizontal relocation distance is not larger than $D^{*}$.
Therefore, we have $\min\{d_{p,\,i}+D_{h}(S(d_{p,\,i}))\vert i\in[n]^{+}\}\leq d_{p,\,i^{*}}+D_{h}(S(d_{p,\,i^{*}}))\leq2D^{*}$.
\end{IEEEproof}
Clearly, the above naive algorithm has to run the 1D-MMSM algorithm
for $O(n)$ times to compute $\min\{d_{p,\,i}+D_{h}(S(d_{p,\,i}))\vert i\in[n]^{+}\}$.
Hence, it runs in time $O(n^{3}\log n)$. Note that the binary search
cannot be immediately applied here, since $f(i)=d_{p,\,i}+D_{h}(S(d_{p,\,i}))$
is neither monotonously increasing nor monotonously decreasing on
$i$. Anyhow, we will give an improve algorithm in which the number
of times of solving 1D-MMSM is improved to $O(\log n)$. We will show
the ratio of the improved algorithm remains two by giving further
observations.
The key idea of our improved algorithm is, instead of finding an $i$
such that $d_{p,\,i}+D_{h}(S(d_{p,\,i}))$ attends minimum, to find
an $i_{alt}$, such that $D_{h}(S(d_{p,\,i_{alt}})\leq d_{p,\,i_{alt}}$
and $D_{h}(S(d_{p,\,i_{alt}-1})\geq d_{p,\,i_{alt}-1}$ both hold.
Note that such $i_{alt}$ can be found with solving the 1D-MMSM problem
only for $O(\log n)$ times, via a binary search in which a set of
values $[lwr,\,upp]$, $lwr\leq i_{alt}\leq upp$, is maintained.
The formal layout of the algorithm is as in Algorithm \ref{alg:factor2apprx}.
\begin{algorithm}
\textbf{Input: }An instance of MMSM, in which w.l.o.g. assume that
$y_{1}\leq\dots\leq y_{n}$;
\textbf{Output:} $i_{alt}$.
\enskip{}1: Set $upp:=n$, $j:=n$ and $lwr:=1$;
\enskip{}2: \textbf{While} $upp-lwr>1$ \textbf{do}
\enskip{}3: \quad{}Set $S(d_{p,\,j})=\{i\vert i\leq j,\,i\in S\}$,
and set the position of $i$ therein to $(x_{i},\,0)$;
\enskip{}4: \quad{}Solve the 1D-MMSM problem with respect to $S(d_{p,\,j})$
and $S(d_{p,\,j-1})$, respectively, using the algorithm as in \cite{chen2013algorithms};
\quad{}\quad{}/{*} Obtain $D_{h}(S(d_{p,\,i_{alt}-1})$ and $D_{h}(S(d_{p,\,i_{alt}})$.{*}/
\enskip{}5:\quad{}\textbf{If} $D_{h}(S(d_{p,\,j})\geq d_{p,\,j}$
\textbf{then }/{*}The current value of $j$ is too small. {*}/
\enskip{}6:\quad{}\quad{}Set $lwr:=j$, and $j:=\frac{upp+lwr}{2}$;
\enskip{}7:\quad{}\textbf{Else}
\enskip{}8:\quad{}\quad{}Set $upp:=j$, and $j:=\frac{upp+lwr}{2}$;
\enskip{}9: Return $i_{alt}:=j$.
\caption{\label{alg:factor2apprx}A factor-2 approximation algorithm for 2D-MMSM. }
\end{algorithm}
The basic observation of our algorithm is that $f(i)=D_{h}(S(d_{p,\,i}))$
will not increase while $i$ increases.
\begin{prop}
\label{prop:monotonelydcrease}$f(i)=D_{h}(S(d_{p,\,i}))$ is monotonously
decreasing on $i$.
\end{prop}
The correctness of the above proposition immediately follows from
the fact that $S(d_{p,\,i})\supseteq S(d_{p,\,i-1})$. Then the performance
guarantee of the algorithm is as in the following lemma:
\begin{lem}
$\min\{d_{p,\,i_{alt}}+D_{h}(S(d_{p,\,i_{alt}}),\,d_{p,\,i_{alt}-1}+D_{h}(S(d_{p,\,i_{alt}-1})\}\leq2D^{*}$.
\end{lem}
\begin{IEEEproof}
Assume that $d_{p,\,i^{*}}$ is the maximum perpendicular distance
of the relocated sensors in an optimum relocation solution to 2D-MMSM.
Then we show that $\min\{d_{p,\,i_{alt}}+D_{h}(S(d_{p,\,i_{alt}}),\,d_{p,\,i_{alt}-1}+D_{h}(S(d_{p,\,i_{alt}-1})\}\leq2D^{*}$
holds for either $i^{*}\geq i_{alt}$ or $i^{*}<i_{alt}$.
\begin{enumerate}
\item $i^{*}\geq i_{alt}$:
Obviously, we have $d_{p,\,i_{alt}}\leq d_{p,\,i^{*}}\leq D^{*}$.
Then since $D_{h}(S(d_{p,\,i_{alt}})\leq d_{p,\,i_{alt}}$, we have
$d_{p,\,i_{alt}}+D_{h}(S(d_{p,\,i_{alt}})\leq2D^{*}$.
\item $i^{*}<i_{alt}$:
Since $i^{*}\leq i_{alt}$ and that $f(i)=D_{h}(S(d_{p,\,i})$ is
monotonously decreasing on $i$, we have $D_{h}(S(d_{p,\,i_{alt}-1})\leq D_{h}(S(d_{p,\,i^{*}})\leq D^{*}$.
Then since $D_{h}(S(d_{p,\,i_{alt}-1})\geq d_{p,\,i_{alt}-1}$ according
to the algorithm, we have $d_{p,\,i_{alt}-1}\leq D^{*}$. Therefore,
$d_{p,\,i_{alt}-1}+D_{h}(S(d_{p,\,i_{alt}-1})\leq2D^{*}$ holds.
\end{enumerate}
\end{IEEEproof}
Since Algorithm \ref{alg:factor2apprx} iterates the \emph{while-loop}
for at most $O(\log n)$ times, we have the following theorem:
\begin{thm}
MMSM admits a factor-2 approximation algorithm with runtime $O(n^{2}(\log n)^{2})$.
\end{thm}
\section{Conclusion}
This paper developed three algorithms for MMSM via solving decision
MMSM, which are respectively with runtime $O(n\log n \log d_{max})$, $O(n^{7}L\log d_{max})$
and $O\left(R^{2}\sqrt{\frac{M}{\log R}}\log d_{max}\right)$, and
maximum relocation distance $d(OPT)+2r_{max}$, $d(OPT)+r_{max}$
and $d(OPT)+r_{max}$, where $n$ is the number of sensors, $L$ is
the length of input, $M$ is the length of the barrier, $d(OPT)$
is the maximum relocation distance in an optimum solution to MMSM,
$d_{max}$ is the maximum distance between the sensors and the barriers,
and $r_{max}=\max_{i}\{r_{i}\}$ is the maximum sensing radii of the
sensors. We proved the performance guarantee for the first algorithm
by giving a sufficient condition to check the feasibility of an instance
of decision MMSM, and for the second (and hence the third) algorithm
by rounding up an optimum fractional solution against the according
LP relaxation, to a real solution of DMMSM. To the best of our knowledge,
our method of rounding up a fractional LP solution is the first to
round an LP solution by aggregation, and has the potential to be applied
to solve other problems. In addition, we developed a factor-2 approximation
by extending a previous result in paper \cite{chen2013algorithms}.
Consequently, the performance of our first three algorithms can be
improved when $r_{max}>d(OPT)$. We note that our proposed algorithms
can only work for MMSM with only one barrier, and are currently investigating
approximation algorithms for MMSM with multiple barriers.
\bibliographystyle{plain}
| {'timestamp': '2017-06-07T02:03:39', 'yymm': '1706', 'arxiv_id': '1706.01623', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01623'} | arxiv |
\section{Introduction}
Attributed networks are ubiquitous in myriad of high impact domains, ranging from social media networks, academic networks, to protein-protein interaction networks. In contrast to conventional plain networks where only pairwise node dependencies are observed, nodes in attributed networks are often affiliated with a rich set of attributes. For example, in scientific collaboration networks, researchers collaborate and are distinct from others by their unique research interests; in social networks, users interact and communicate with others and also post personalized content. It has been widely studied and received that there exhibits a strong correlation among the attributes of linked nodes~\cite{shalizi2011homophily,pfeiffer2014attributed}. The root cause of the correlations can be attributed to social influence and homophily effect in social science theories~\cite{marsden1993network,mcpherson2001birds}. Also, many real-world applications, such as node classification, community detection, topic modeling and anomaly detection~\cite{jian2017toward,yang2009combining,li2017toward,li2017residual,he2017modeling}, have shown significant improvements by modeling such correlations.
Network embedding~\cite{chen2007directed,perozzi2014deepwalk,tang2015line,cao2015grarep,chang2015heterogeneous,grover2016node2vec,huang2017label,huang2017accelerated,qu2017attention} has attracted a surge of research attention in recent years. The basic idea is to preserve the node proximity in the embedded Euclidean space, based on which the performance of various network mining tasks such as node classification~\cite{aggarwal2011node,bhagat2011node}, community detection~\cite{tang2008community,yang2009combining}, and link prediction~\cite{liben2007link,wang2011human,barbieri2014follow} can be enhanced. However, a vast majority of existing work are predominately designed for plain networks. They inevitably ignore the node attributes that could be potentially complementary in learning better embedding representations, especially when the network suffers from high sparsity. In addition, a fundamental assumption behind existing network embedding methods is that networks are static and given a prior. Nonetheless, most real-world networks are intrinsically dynamic with addition/deletion of edges and nodes; examples include co-author relations between scholars in an academic network and friendships among users in a social network. Meanwhile, similar as network structure, node attributes also change naturally such that new content patterns may emerge and outdated content patterns will fade. For example, humanitarian and disaster relief related topics become popular on social media sites after the earthquakes as users continuously post related content. Consequently, other topics may receive less public interests. In this paper, we refer this kind of networks with both network and node attribute value changes as \emph{dynamic attributed networks}.
Despite the widespread of dynamic attributed networks in real-world applications, the study in analyzing and mining these networks are rather limited. One natural question to ask is when attributed networks evolve, how to correct and adjust the staleness of the end embedding results for network analysis, which will shed light on the understanding of their evolving nature. However, dynamic attributed network embedding remains as a daunting task, mainly because of the following reasons: (1) Even though network topology and node attributes are two distinct data representations, they are inherently correlated. In addition, the raw data representations could be noisy and even incomplete, individually. Hence, it is of paramount importance to seek a noise-resilient consensus embedding to capture their individual properties and correlations; (2) Applying offline embedding methods from scratch at each time step is time-consuming and cannot seize the emerging patterns timely. It necessitates the design of an efficient online algorithm that can give embedding representations promptly.
\begin{figure*}[!htbp]
\centering
\includegraphics[width=0.9\textwidth]{DANE.eps}
\caption{An illustration of the proposed dynamic attributed network embedding framework - DANE. At time step $t$, DANE performs spectral embedding on network structure $\mat{A}$ and node attributes $\mat{X}$, and obtain two embeddings $\mat{Y}_{\mat{A}}$ and $\mat{Y}_{\mat{X}}$. Afterwards, DANE maximizes their correlation for a consensus embedding representation $\mat{Y}$. At the following time step $t+1$, the network is characterized by both topology structure and attribute value changes $\mat{\Delta}\mat{A}$ and $\mat{\Delta}\mat{X}$ (the changes are highlighted in orange). DANE leverages matrix perturbation theory to update $\mat{Y}_{\mat{A}}$ and $\mat{Y}_{\mat{X}}$, and give the new consensus embedding $\mat{Y}$.}
\label{fig:framework}
\end{figure*}
To tackle the aforementioned challenges, we propose a novel embedding framework for dynamic attributed networks. The main contributions can be summarized as follows:
\begin{itemize}
\item \textbf{\emph{Problem Formulations}}: we formally define the problem of dynamic attributed network embedding. The key idea is to initiate an offline model at the very beginning, based on which an online model is presented to maintain the freshness of the end attributed network embedding results.
\item \textbf{\emph{Algorithms and Analysis}}: we propose a novel framework - DANE for dynamic attributed network embedding. Specifically, we introduce an offline embedding method as a base model to preserve node proximity in terms of both network structure and node attributes for a consensus embedding representation in a robust way. Then to timely obtain an updated embedding representation when both network structure and attributes drift, we present an online model to update the consensus embedding with matrix perturbation theory. We also theoretically analyze its time complexity and show its superiority over offline methods.
\item \textbf{\emph{Evaluations}}: we perform extensive experiments on both synthetic and real-world attributed networks to corroborate the efficacy in terms of two network mining tasks (both unsupervised and supervised). Also, we show its efficiency by comparing it with other baseline methods and its offline counterpart. In particular, our experimental results show that the proposed method outperforms the best competitors in terms of both clustering and classification performance. Most importantly, it is much faster than competitive offline embedding methods.
\end{itemize}
The rest of this paper is organized as follows. The problem statement of dynamic attributed network embedding is introduced in Section 2. Section 3 presents the proposed framework DANE with analysis. Experiments on synthetic and real datasets are presented in Section 4 with discussions. Section 5 briefly reviews related work. Finally, Section 6 concludes the paper and visions the future work.
\section{Problem Definition}
We first summarize some notations used in this paper. Following the commonly used notations, we use bold uppercase characters for matrices (e.g., $\mat{A}$), bold lowercase characters for vectors (e.g., $\mat{a}$), normal lowercase characters for scalars (e.g., $a$). Also we represent the $i$-th row of matrix $\mat{A}$ as $\mat{A}(i,:)$, the $j$-th column as $\mat{A}(:,j)$, the ($i,j$)-th entry as $\mat{A}(i,j)$, transpose of $\mat{A}$ as $\mat{A}'$, trace of $\mat{A}$ as $tr(\mat{A})$ if it is a square matrix. $\mat{1}$ denotes a vector whose elements are all 1 and $\mat{I}$ denotes the identity matrix. The main symbols used throughout this paper are listed in Table~\ref{table:symbols}.
\begin{table}[!htbp]
\small
\begin{tabular}{|c|c|} \hline
Notations& Definitions or Descriptions \\ \hline \hline
$\mathcal{G}^{(t)}$ & attributed network at time step $t$ \\ \hline
$\mathcal{G}^{(t+1)}$ & attributed network at time step $t+1$ \\ \hline
$\mat{A}^{(t)}$ & adjacency matrix for the network structure in $\mathcal{G}^{(t)}$\\ \hline
$\mat{X}^{(t)}$ & attribute information in $\mathcal{G}^{(t)}$\\ \hline
$\mat{A}^{(t+1)}$ & adjacency matrix for the network structure in $\mathcal{G}^{(t+1)}$\\ \hline
$\mat{X}^{(t+1)}$ & attribute information in $\mathcal{G}^{(t+1)}$\\ \hline
$\Delta\mat{A}$ & change of adjacency matrix between time steps $t$ and $t+1$ \\ \hline
$\Delta\mat{X}$ & change of attribute values between time steps $t$ and $t+1$ \\ \hline
$n$ & number of instances (nodes) in $\mathcal{G}^{(t)}$ \\ \hline
$d$ & number of attributes in $\mathcal{G}^{(t)}$\\ \hline
$k$ & embedding dimension for network structure or attributes \\ \hline
$l$ & final consensus embedding dimension \\ \hline
\end{tabular}
\caption{Symbols.}
\vspace{-1\baselineskip}
\label{table:symbols}
\end{table}
Let $\mathcal{U}^{(t)}=\{u_{1},u_{2},...,u_{n}\}$ denote a set of $n$ nodes in the attributed network $\mathcal{G}^{(t)}$ at time step $t$. We use the adjacency matrix $\mat{A}^{(t)}\in \mathbb{R}^{n\times n}$ to represent the network structure of $\mathcal{U}^{(t)}$. In addition, we assume that nodes are affiliated with $d$-dimensional attributes $\mathcal{F}=\{f_{1},f_{2},...,f_{d}\}$ and $\mat{X}^{(t)}\in \mathbb{R}^{n\times d}$ denotes the node attributes. At the following time step, the attributed network is characterized with both topology and content drift such that new/old edges and nodes may be included/deleted, and node attribute values could also change. We use $\Delta\mat{A}$ and $\Delta\mat{X}$ to denote the network and attribute value changes between two consecutive time step $t$ and time step $t+1$, respectively. Following the settings of~\cite{tong2008colibri}, and for the ease of presentation, we consider the number of nodes is constant over time, but our method can be naturally extended to deal with node addition/deletion scenarios. As mentioned earlier, node attributes are complementary in mitigating the network sparsity for better embedding representations. Nonetheless, employing offline embedding methods repeatedly in a dynamic environment is time-consuming and cannot seize the emerging/fading patterns promptly, especially when the networks are of large-scale. Therefore, developing an efficient online embedding algorithm upon an offline model is fundamentally important for dynamic network analysis, and also could benefit many real-wold applications. Formally, we define the dynamic attributed embedding problem as two sub-problems as follows. The work flow of the proposed framework DANE is shown in Figure~\ref{fig:framework}.
\begin{problem}{The offline model of DANE at time step $t$: given network topology $\mat{A}^{(t)}$ and node attributes $\mat{X}^{(t)}$; output attributed network embedding $\mat{Y}^{(t)}$ for all nodes.}
\label{problem:problem1}
\end{problem}
\begin{problem}{The online model of DANE at time step $t+1$: given network topology $\mat{A}^{(t+1)}$ and node attributes $\mat{X}^{(t+1)}$, and intermediate embedding results at time step $t$; output attributed network embedding $\mat{Y}^{(t+1)}$ for all nodes.}
\label{problem:problem2}
\end{problem}
\section{The Proposed Framework - DANE}
In this section, we first present an offline model that works in a static setting to tackle the Problem~\ref{problem:problem1} in finding a consensus embedding representation. Then to tackle the Problem~\ref{problem:problem2}, we introduce an online model that provides a fast solution to update the consensus embedding on the fly. At the end, we analyze the computational complexity of the online model and show its superiority over the offline model.
\subsection{DANE: Offline Model}
Network topology and node attributes in attributed networks are presented in different representations. Typically, either of these two representations could be \emph{incomplete} and \emph{noisy}, presenting great challenges to embedding representation learning. For example, social networks are very sparse as a large amount of users only have a limited number of links~\cite{adamic2000power}. Thus, network embedding could be jeopardized as links are inadequate to provide enough node proximity information. Fortunately, rich node attributes are readily available and could be potentially helpful to mitigate the network sparsity in finding better embeddings. Hence, it is more desired to make these two representations compensate each other for a consensus embedding. However, as mentioned earlier, both representations could be noisy and the existence of noise could degenerate the learning of consensus embedding. Hence, it motivates us to reduce the noise of these two raw data representations before learning consensus embedding.
Let $\mat{A}^{(t)}\in\mathbb{R}^{n\times n}$ be the adjacency matrix of the attributed network at time step $t$ and $\mat{D}_{\mat{A}}$ be the diagonal matrix with $\mat{D}_{\mat{A}}^{(t)}(i,i)=\sum_{j=1}^{n}\mat{A}^{(t)}(i,j)$, then $\mat{L}_{\mat{A}}^{(t)}=\mat{D}_{\mat{A}}^{(t)}-\mat{A}^{(t)}$ is a Laplacian matrix. According to spectral theory~\cite{belkin2001laplacian,von2007tutorial}, by mapping each node in the network to a $k$-dimensional embedded space, i.e., $\mat{y}_{i}\in \mathbb{R}^{k}$ ($k\ll n$), the noise in the network can be substantially reduced. A rational choice of the embedding $\mat{Y}_{\mat{A}}^{(t)}=[\mat{y}_{1},\mat{y}_{2},...,\mat{y}_{n}]'\in\mathbb{R}^{n\times k}$ is to minimize the loss $\frac{1}{2}\sum_{i,j}\mat{A}^{(t)}(i,j)||\mat{y}_{i}-\mat{y}_{j}||_{2}^{2}$. It ensures that connected nodes are close to each other in the embedded space. In this case, the problem boils down to solving the following generalized eigen-problem $\mat{L}_{\mat{A}}^{(t)}\mat{a}=\lambda\mat{D}_{\mat{A}}^{(t)}\mat{a}$. Let $\mat{a}_{1},\mat{a}_{2},...,\mat{a}_{n}$ be the eigenvectors of the corresponding eigenvalues $0=\lambda_{1}\leq\lambda_{2}\leq...\leq\lambda_{n}$. It is easy to verify that $\mat{1}$ is the only eigenvector for the eigenvalue $\lambda_{1}=0$. Then the $k$-dimensional embedding $\mat{Y}_{\mat{A}}^{(t)}\in\mathbb{R}^{n\times k}$ of the network structure is given by the top-$k$ eigenvectors starting from $\mat{a}_{2}$, i.e., $\mat{Y}_{\mat{A}}^{(t)}=[\mat{a}_{2},...,\mat{a}_{k},\mat{a}_{k+1}]$. For the ease of presentation, in the following parts of the paper, we refer these $k$ eigenvectors and their eigenvalues as the top-$k$ eigenvectors and eigenvalues, respectively. Akin to the network structure, noise in the node attributes can be reduced in a similar fashion. Specifically, we first normalize attributes of each node and obtain the cosine similarity matrix $\mat{W}^{(t)}$. Afterwards, we obtain the top-$k$ eigenvectors $\mat{Y}_{\mat{X}}^{(t)}=[\mat{b}_{2},...,\mat{b}_{k+1}]$ of the generalized eigen-problem corresponding to $\mat{W}^{(t)}$.
The noisy data problem is resolved by finding two intermediate embeddings $\mat{Y}_{\mat{A}}^{(t)}$ and $\mat{Y}_{\mat{X}}^{(t)}$. We now take advantage of them to seek a consensus embedding. However, since they are obtained individually, these two embeddings may not be compatible and in the worst case, they may be independent of each other. To capture their interdependency and to make them compensate each other, we propose to maximize their correlations (or equivalently minimize their disagreements)~\cite{hardoon2004canonical}. In particular, we seek two projection vectors $\mat{p}_{\mat{A}}^{(t)}$ and $\mat{p}_{\mat{X}}^{(t)}$ such that the correlation of $\mat{Y}_{\mat{A}}^{(t)}$ and $\mat{Y}_{\mat{X}}^{(t)}$ is maximized after projection. It is equivalent to solving the following optimization problem:
\begin{equation}
\begin{split}
&\max_{\mat{p}_{\mat{A}}^{(t)},\mat{p}_{\mat{X}}^{(t)}}\mat{p}_{\mat{A}}^{(t)'}\mat{Y}_{\mat{A}}^{(t)'}\mat{Y}_{\mat{A}}^{(t)}\mat{p}_{\mat{A}}^{(t)}+\mat{p}_{\mat{A}}^{(t)'}\mat{Y}_{\mat{A}}^{(t)'}\mat{Y}_{\mat{X}}^{(t)}\mat{p}_{\mat{X}}^{(t)}\\
&+\mat{p}_{\mat{X}}^{(t)'}\mat{Y}_{\mat{X}}^{(t)'}\mat{Y}_{\mat{A}}^{(t)}\mat{p}_{\mat{A}}^{(t)}+\mat{p}_{\mat{X}}^{(t)'}\mat{Y}_{\mat{X}}^{(t)'}\mat{Y}_{\mat{X}}^{(t)}\mat{p}_{\mat{X}}^{(t)}.\\
&\mbox{s.t.}\quad \mat{p}_{\mat{A}}^{(t)'}\mat{Y}_{\mat{A}}^{(t)'}\mat{Y}_{\mat{A}}^{(t)}\mat{p}_{\mat{A}}^{(t)}+\mat{p}_{\mat{X}}^{(t)'}\mat{Y}_{\mat{X}}^{(t)'}\mat{Y}_{\mat{X}}^{(t)}\mat{p}_{\mat{X}}^{(t)}=1.
\end{split}
\end{equation}
Let $\gamma$ be the Lagrange multiplier for the constraint, by setting the derivative of the Lagrange function w.r.t. $\mat{p}_{\mat{A}}^{(t)}$ and $\mat{p}_{\mat{X}}^{(t)}$ to zero, we obtain the optimal solution for $[\mat{p}_{\mat{A}}^{(t)};\mat{p}_{\mat{X}}^{(t)}]$, which corresponds to the eigenvector of the following generalized eigen-problem:
\begin{equation}
\begin{split}
\begin{bmatrix}
\mat{Y}_{\mat{A}}^{(t)'}\mat{Y}_{\mat{A}}^{(t)} & \mat{Y}_{\mat{A}}^{(t)'}\mat{Y}_{\mat{X}}^{(t)} \\
\mat{Y}_{\mat{X}}^{(t)'}\mat{Y}_{\mat{A}}^{(t)} & \mat{Y}_{\mat{X}}^{(t)'}\mat{Y}_{\mat{X}}^{(t)} \\
\end{bmatrix}
\begin{bmatrix}
\mat{p}_{\mat{A}}^{(t)} \\
\mat{p}_{\mat{X}}^{(t)} \\
\end{bmatrix}
=
\gamma&
\begin{bmatrix}
\mat{Y}_{\mat{A}}^{(t)'}\mat{Y}_{\mat{A}}^{(t)} & \mat{0} \\
\mat{0} & \mat{Y}_{\mat{X}}^{(t)'}\mat{Y}_{\mat{X}}^{(t)} \\
\end{bmatrix}
\begin{bmatrix}
\mat{p}_{\mat{A}}^{(t)} \\
\mat{p}_{\mat{X}}^{(t)} \\
\end{bmatrix}.
\end{split}
\label{eq:embeddingfushion}
\end{equation}As a result, to obtain a consensus embedding representation from $\mat{Y}_{\mat{A}}$ and $\mat{Y}_{\mat{X}}$, we could take the top-$l$ eigenvectors of the above generalized eigen-problem and stack these top-$l$ eigenvectors together. Suppose the projection matrix $\mat{P}^{(t)}\in\mathbb{R}^{2k\times l}$ is the concatenated top-$l$ eigenvectors, the final consensus embedding representation can be computed as $\mat{Y}^{(t)}=[\mat{Y}_{\mat{A}}^{(t)},\mat{Y}_{\mat{X}}^{(t)}]\times\mat{P}^{(t)}$.
\subsection{Online Model of DANE}
More often than not, attributed networks often exhibit high dynamics. For example, in social media sites, social relations are continuously evolving, and user posting behaviors may also evolve accordingly. It raises challenges to the existing offline embedding methods as they have to rerun at each time step which is time-consuming and is not scalable to large networks. Therefore, it is important to build an efficient online embedding algorithm which gives an informative embedding representation on the fly.
The proposed online embedding model is motivated by the observation that most of real-world networks, with no exception for attributed networks, often evolve smoothly in the temporal dimension between two consecutive time steps~\cite{chi2007evolutionary,aggarwal2014evolutionary,wang2016recommending,li2016toward}. Hence, we use $\Delta\mat{A}$ and $\Delta\mat{X}$ to denote the perturbation of network structure and node attributes between two consecutive time steps $t$ and $t+1$, respectively. With these, the diagonal matrix and Laplacian matrix of $\mat{A}$ and $\mat{X}$ also evolve smoothly such that:
\begin{equation}
\begin{split}
\mat{D}_{\mat{A}}^{(t+1)} &= \mat{D}_{\mat{A}}^{(t)}+\Delta\mat{D}_{\mat{A}}, \quad \mat{L}_{\mat{A}}^{(t+1)} = \mat{L}_{\mat{A}}^{(t)}+\Delta\mat{L}_{\mat{A}},\\
\mat{D}_{\mat{X}}^{(t+1)} &= \mat{D}_{\mat{X}}^{(t)}+\Delta\mat{D}_{\mat{X}}, \quad \mat{L}_{\mat{X}}^{(t+1)} = \mat{L}_{\mat{X}}^{(t)}+\Delta\mat{L}_{\mat{X}}.
\end{split}
\end{equation}
As discussed in the previous subsection, the problem of attributed network embedding in an offline setting boils down to solving generalized eigen-problems. In particular, offline model focuses on finding the top eigenvectors corresponding to the smallest eigenvalues of the generalized eigen-problems. Therefore, the core idea to enable online update of the embeddings is to develop an efficient way to update the top eigenvectors and eigenvalues. Otherwise, we have to perform generalized eigen-decomposition each time step, which is not practical due to its high time complexity.
Without loss of generality, we use the network topology as an example to illustrate the proposed algorithm for online embedding. By the matrix perturbation theory~\cite{stewart1990matrix}, we have the following equation in embedding the network structure at the new time step:
\begin{equation}
(\mat{L}_{\mat{A}}^{(t)}+\Delta\mat{L}_{\mat{A}})(\mat{a}+\Delta\mat{a})=(\lambda+\Delta\lambda)(\mat{D}_{\mat{A}}^{(t)}+\Delta\mat{D}_{\mat{A}})(\mat{a}+\Delta\mat{a}).
\end{equation}For a specific eigen-pair $(\lambda_{i},\mat{a}_{i})$, we have the following equation:
\begin{equation}
(\mat{L}_{\mat{A}}^{(t)}+\Delta\mat{L}_{\mat{A}})(\mat{a}_{i}+\Delta\mat{a}_{i})=(\lambda_{i}+\Delta\lambda_{i})(\mat{D}_{\mat{A}}^{(t)}+\Delta\mat{D}_{\mat{A}})(\mat{a}_{i}+\Delta\mat{a}_{i}).
\end{equation}The problem now is how to compute the change of the $i$-th eigen-pair $(\Delta\mat{a}_{i}, \Delta\lambda_{i})$ by taking advantage of the small perturbation matrices $\Delta\mat{D}$ and $\Delta\mat{L}$.
\paragraph{\textbf{A - Computing the change of eigenvalue $\mat{\Delta}\mat{\lambda_{i}}$}}~\\
By expanding the above equation, we have:
\begin{equation}
\begin{split}
&\mat{L}_{\mat{A}}^{(t)}\mat{a}_{i}+\Delta\mat{L}_{\mat{A}}\mat{a}_{i}+\mat{L}_{\mat{A}}^{(t)}\Delta\mat{a}_{i}+\Delta\mat{L}_{\mat{A}}\Delta\mat{a}_{i}\\
=&\lambda_{i}\mat{D}_{\mat{A}}^{(t)}\mat{a}_{i}+\lambda_{i}\Delta\mat{D}_{\mat{A}}\mat{a}_{i}+\Delta\lambda_{i}\mat{D}_{\mat{A}}^{(t)}\mat{a}_{i}+\Delta\lambda_{i}\Delta\mat{D}_{\mat{A}}\mat{a}_{i}\\
+&(\lambda_{i}\mat{D}_{\mat{A}}^{(t)}+\lambda_{i}\Delta\mat{D}_{\mat{A}}+\Delta\lambda_{i}\mat{D}_{\mat{A}}^{(t)}+\Delta\lambda_{i}\Delta\mat{D}_{\mat{A}})\Delta\mat{a}_{i}.
\end{split}
\label{eq:expasion}
\end{equation}The higher order terms, i.e., $\Delta\lambda_{i}\Delta\mat{D}_{\mat{A}}\mat{a}_{i}$, $\lambda_{i}\Delta\mat{D}_{\mat{A}}\Delta\mat{a}_{i}$, $\Delta\lambda_{i}\mat{D}_{\mat{A}}^{(t)}\Delta\mat{a}_{i}$ and $\Delta\lambda_{i}\Delta\mat{D}_{\mat{A}}\Delta\mat{a}_{i}$ can be removed as they have limited effects on the accuracy of the generalized eigen-systems~\cite{golub2012matrix}. By using the fact that $\mat{L}_{\mat{A}}^{(t)}\mat{a}_{i}=\lambda_{i}\mat{D}_{\mat{A}}^{(t)}\mat{a}_{i}$, we have the following formulation:
\begin{equation}
\Delta\mat{L}_{\mat{A}}\mat{a}_{i}+\mat{L}_{\mat{A}}^{(t)}\Delta\mat{a}_{i}=\lambda_{i}\Delta\mat{D}_{\mat{A}}\mat{a}_{i}+\Delta\lambda_{i}\mat{D}_{\mat{A}}^{(t)}\mat{a}_{i}+\lambda_{i}\mat{D}_{\mat{A}}^{(t)}\Delta\mat{a}_{i}.
\label{eq:firstorder}
\end{equation}Multiplying both sides with $\mat{a}_{i}'$, we now have:
\begin{equation}
\mat{a}_{i}'\Delta\mat{L}_{\mat{A}}\mat{a}_{i}+\mat{a}_{i}'\mat{L}_{\mat{A}}^{(t)}\Delta\mat{a}_{i}=\lambda_{i}\mat{a}_{i}'\Delta\mat{D}_{\mat{A}}\mat{a}_{i}+\Delta\lambda_{i}\mat{a}_{i}'\mat{D}_{\mat{A}}^{(t)}\mat{a}_{i}+
\lambda_{i}\mat{a}_{i}'\mat{D}_{\mat{A}}^{(t)}\Delta\mat{a}_{i}.
\label{eq:transpose}
\end{equation}Since both the Laplacian matrix $\mat{L}_{\mat{A}}^{(t)}$ and the diagonal matrix $\mat{D}_{\mat{A}}^{(t)}$ are symmetric, we have:
\begin{equation}
\mat{a}_{i}'\mat{L}_{\mat{A}}^{(t)}\Delta\mat{a}_{i}=\lambda_{i}\mat{a}_{i}'\mat{D}_{\mat{A}}^{(t)}\Delta\mat{a}_{i}.
\end{equation}Therefore, Eq.~(\ref{eq:transpose}) can be reformulated as follows:
\begin{equation}
\mat{a}_{i}'\Delta\mat{L}_{\mat{A}}\mat{a}_{i}=\lambda_{i}\mat{a}_{i}'\Delta\mat{D}_{\mat{A}}\mat{a}_{i}+\Delta\lambda_{i}\mat{a}_{i}'\mat{D}_{\mat{A}}^{(t)}\mat{a}_{i}.
\end{equation}Through this, the variation of eigenvalue, i.e., $\Delta\lambda_{i}$, is:
\begin{equation}
\Delta\lambda_{i}=\frac{\mat{a}_{i}'\Delta\mat{L}_{\mat{A}}\mat{a}_{i}-\lambda_{i}\mat{a}_{i}'\Delta\mat{D}_{\mat{A}}\mat{a}_{i}}{\mat{a}_{i}'\mat{D}_{\mat{A}}^{(t)}\mat{a}_{i}}.
\label{eq:eigenvaluesolution}
\end{equation}
\begin{theorem} In the generalized eigen-problem $\mat{A}\mat{v}=\lambda\mat{B}\mat{v}$, if $\mat{A}$ and $\mat{B}$ are both Hermitian matrices and $\mat{B}$ is a positive-semidefinite matrix, the eigenvalue $\lambda$ are real; and eigenvectors $\mat{v}_{j}$ ($i\neq j$) are $\mat{B}$-orthogonal such that $\mat{v}_{i}'\mat{B}\mat{v}_{j}=0$ and $\mat{v}_{i}'\mat{B}\mat{v}_{i}=1$~\cite{parlett1980symmetric}.
\label{theorem:theorem1}
\end{theorem}
\begin{corollary}
$\mat{a}_{i}'\mat{D}_{\mat{A}}^{(t)}\mat{a}_{i}=1$ and $\mat{a}_{i}'\mat{D}_{\mat{A}}^{(t)}\mat{a}_{j}=0$ ($i\neq j$).
\label{corollary:corollary1}
\end{corollary}
\label{corollary:orthonormal}
\begin{proof}
Both $\mat{D}_{\mat{A}}^{(t)}$ and $\mat{L}_{\mat{A}}^{(t)}$ are symmetric and are also Hermitian matrices. Meanwhile, the Laplacian matrix $\mat{L}_{\mat{A}}^{(t)}$ is a positive-definite matrix, which completes the proof.
\end{proof}Therefore, the variation of the eigenvalue $\lambda_{i}$ is as follows:
\begin{equation}
\Delta\lambda_{i}=\mat{a}_{i}'\Delta\mat{L}_{\mat{A}}\mat{a}_{i}-\lambda_{i}\mat{a}_{i}'\Delta\mat{D}_{\mat{A}}\mat{a}_{i}.
\label{eq:eigenvaluefinalupdate}
\end{equation}
\paragraph{\textbf{B - Computing the change of eigenvector $\mat{\Delta}\mat{a}_{i}$}}~\\
As network structure often evolves smoothly between two continuous time steps, we assume that the perturbation of the eigenvectors $\Delta\mat{a}_{i}$ lies in the column space that is composed by the top-$k$ eigenvectors at time step $t$ such that $\Delta\mat{a}_{i}=\sum_{j=2}^{k+1}\alpha_{ij}\mat{a}_{j}$, where $\alpha_{ij}$ is a weight indicating the contribution of the $j$-th eigenvector $\mat{a}_{j}$ in approximating the new $i$-th eigenvector. Next, we show how to determine these weights such that the perturbation $\Delta\mat{a}_{i}$ can be estimated.
By plugging $\Delta\mat{a}_{i}=\sum_{j=2}^{k+1}\alpha_{ij}\mat{a}_{j}$ into Eq.~(\ref{eq:firstorder}) and using the fact that $\mat{L}_{\mat{A}}^{(t)}\sum_{j=2}^{k+1}\alpha_{ij}\mat{a}_{j}=\mat{D}_{\mat{A}}^{(t)}\sum_{j=2}^{k+1}\alpha_{ij}\lambda_{j}\mat{a}_{j}$, we obtain the following:
\begin{equation}
\small
\Delta\mat{L}_{\mat{A}}\mat{a}_{i}+\mat{D}_{\mat{A}}^{(t)}\sum_{j=2}^{k+1}\alpha_{ij}\lambda_{j}\mat{a}_{j}=\lambda_{i}\Delta\mat{D}_{\mat{A}}\mat{a}_{i}+\Delta\lambda_{i}\mat{D}_{\mat{A}}^{(t)}\mat{a}_{i}+\lambda_{i}\mat{D}_{\mat{A}}^{(t)}\sum_{j=2}^{k+1}\alpha_{ij}\mat{a}_{j}.
\label{eq:eigenvectornew2}
\end{equation}By multiplying eigenvector $\mat{a}_{p}'\,(2\leq p\leq k+1, p\neq i)$ on both sides of Eq.~(\ref{eq:eigenvectornew2}) and taking advantage of the orthonormal property from Corollary~\ref{corollary:orthonormal}, we obtain the following:
\begin{equation}
\begin{split}
&\mat{a}_{p}'\Delta\mat{L}_{\mat{A}}\mat{a}_{i}+\mat{a}_{p}'\mat{D}_{\mat{A}}^{(t)}\sum_{j=2}^{k+1}\alpha_{ij}\lambda_{j}\mat{a}_{j}\\
=\,&\lambda_{i}\mat{a}_{p}'\Delta\mat{D}_{\mat{A}}\mat{a}_{i}+\Delta\lambda_{i}\mat{a}_{p}'\mat{D}_{\mat{A}}^{(t)}\mat{a}_{i}+\lambda_{i}\mat{a}_{p}'\mat{D}_{\mat{A}}^{(t)}\sum_{j=2}^{k+1}\alpha_{ij}\mat{a}_{j}\\
\Rightarrow \quad &\mat{a}_{p}'\Delta\mat{L}_{\mat{A}}\mat{a}_{i}+\alpha_{ip}\lambda_{p}=\lambda_{i}\mat{a}_{p}'\Delta\mat{D}_{\mat{A}}\mat{a}_{i}+\alpha_{ip}\lambda_{i}.
\end{split}
\end{equation}Hence, the weight $\alpha_{ip}$ can be determined by:
\begin{equation}
\alpha_{ip}=\frac{\mat{a}_{p}'\Delta\mat{L}_{\mat{A}}\mat{a}_{i}-\lambda_{i}\mat{a}_{p}'\Delta\mat{D}_{\mat{A}}\mat{a}_{i}}{\lambda_{i}-\lambda_{p}}.
\label{eq:alphaip}
\end{equation}After eigenvector perturbation, we still need to make the orthonormal condition holds for new eigenvectors, thus we have $(\mat{a}_{i}+\Delta\mat{a}_{i})'(\mat{D}_{\mat{A}}+\Delta\mat{D}_{\mat{A}})(\mat{a}_{i}+\Delta\mat{a}_{i})=1$. By expanding it and removing the second-order and third-order terms, we obtain the following equation:
\begin{equation}
2\mat{a}_{i}'\mat{D}_{\mat{A}}^{(t)}\Delta\mat{a}_{i}+\mat{a}_{i}'\Delta\mat{D}_{\mat{A}}^{(t)}\mat{a}_{i}=0.
\label{eq:alphaiitmp}
\end{equation}Then the solution of $\alpha_{ii}$ is as follows:
\begin{equation}
\alpha_{ii}=-\frac{1}{2}\mat{a}_{i}'\Delta\mat{D}_{\mat{A}}\mat{a}_{i}.
\label{eq:alphaii}
\end{equation}
With the solutions of $\alpha_{ip}$ ($p\neq i$) and $\alpha_{ii}$, the perturbation of eigenvector $\mat{a}_{i}$ is given as follows:
\begin{equation}
\Delta\mat{a}_{i}=-\frac{1}{2}\mat{a}_{i}'\Delta\mat{D}_{\mat{A}}\mat{a}_{i}\mat{a}_{i}+\sum_{j=2,j\neq i}^{k+1}(\frac{\mat{a}_{j}'\Delta\mat{L}_{\mat{A}}\mat{a}_{i}-\lambda_{i}\mat{a}_{j}'\Delta\mat{D}_{\mat{A}}\mat{a}_{i}}{\lambda_{i}-\lambda_{j}})\mat{a}_{j}.
\label{eq:eigenvectorfinalupdate}
\end{equation}
Overall, the $i$-th eigen-pair ($\Delta\lambda_{i}, \Delta\mat{a}_{i}$) can be updated on the fly by Eq.~(\ref{eq:eigenvaluefinalupdate}) and Eq.~(\ref{eq:eigenvectorfinalupdate}), the pseudocode of the updating process is illustrated in Algorithm~\ref{alg:generalizedeigenupdate}. The first input is the top-$k$ eigen-pairs of the generalized eigen-problem, they can be computed by standard methods like power iteration and Lanczos method~\cite{golub2012matrix}. Another input is the variation of the diagonal matrix and the Laplacian matrix. For the top-$k$ eigen-pairs, we update eigenvalues in line 2 and update eigenvectors in line 3.
Likewise, the embedding of node attributes can also be updated in an online manner by Algorithm~\ref{alg:generalizedeigenupdate}. Specifically, let $\mat{Y}_{\mat{A}}^{(t)}$ and $\mat{Y}_{\mat{X}}^{(t)}$ denote the embedding of network structure and node attributes at time step $t$, then at the following time step $t+1$, we first employ the proposed online model to update their embedding representations, then a final consensus embedding representation $\mat{Y}^{(t+1)}$ is derived by the correlation maximization method mentioned previously.
\begin{algorithm}[!htbp]
\begin{algorithmic}[1]
\Require Top-$k$ eigen-pairs of the generalized eigen-problem $\{$($\lambda_{2},\mat{a}_{2}$),($\lambda_{3},\mat{a}_{3}$),...,($\lambda_{k+1},\mat{a}_{k+1}$)$\}$ at time $t$, variation of the diagonal matrix $\Delta\mat{L}_{\mat{A}}$ and Laplacian matrix $\Delta\mat{D}_{\mat{A}}$.
\Ensure Top-$k$ eigen-pairs $\{$($\lambda_{2}^{(t+1)},\mat{a}_{2}^{(t+1)}$),...,($\lambda_{k+1}^{(t+1)},\mat{a}_{k+1}^{(t+1)}$)$\}$ at time step $t+1$.
\For {$i=2$ to $k+1$}
\State {Calculate the variation of $\Delta\lambda_{i}$ by Eq.~(\ref{eq:eigenvaluefinalupdate});}
\State {Calculate the variation of $\Delta\mat{a}_{i}$ by Eq.~(\ref{eq:eigenvectorfinalupdate});}
\State {$\lambda_{i}^{(t+1)}=\lambda_{i}+\Delta\lambda_{i}$; $\mat{a}_{i}^{(t+1)}=\mat{a}_{i}+\Delta\mat{a}_{i}$;}
\EndFor
\end{algorithmic}
\caption{Updating of embedding results for the network}
\label{alg:generalizedeigenupdate}
\end{algorithm}
\paragraph{\textbf{C - Computational Complexity Analysis}}
We theoretically analyze the computational complexity of the proposed online algorithm and show its superiority over the offline embedding methods.
\begin{lemma}
The time complexity of the proposed online embedding algorithm over $T$ time steps is $\mathcal{O}(Tk^{2}(n+l+l_{a}+l_{x}+d_{x}+d_{x}))$, where $k$ is the intermediate embedding dimension for network (or attributes), $l$ is the final consensus embedding dimension, $n$ is the number of nodes, and $l_{a}$, $l_{x}$, $d_{a}$, $d_{x}$ are the number of non-zero entries in the sparse matrices $\mat{\Delta}\mat{L}_{\mat{A}}$, $\mat{\Delta}\mat{L}_{\mat{X}}$, $\mat{\Delta}\mat{D}_{\mat{A}}$, and $\mat{\Delta}\mat{D}_{\mat{X}}$, respectively.
\begin{proof}
In each time step, to update the top-$k$ eigenvalues of the network and node attributes in an online fashion, it requires $\mathcal{O}(k(d_{a}+l_{a}))$ and $\mathcal{O}(k(d_{x}+l_{x}))$, respectively. Also, the online updating of the top-$k$ eigenvectors for the network and attributes are $\mathcal{O}(k^{2}(d_{a}+l_{a}+n))$ and $\mathcal{O}(k^{2}(d_{x}+l_{x}+n))$, respectively. After that, the complexity for the consensus embedding is $\mathcal{O}(k^{2}l)$. Therefore, the computational complexity of the proposed online model over $T$ time steps are $\mathcal{O}(Tk^{2}(n+l+l_{a}+l_{x}+d_{x}+d_{x}))$.
\end{proof}
\end{lemma}
\begin{lemma}
The time complexity of the proposed offline embedding algorithm over $T$ time steps is $\mathcal{O}(Tn^{2}(k+l))$, where $k$ is the intermediate embedding dimension for network (or attributes), $l$ is the final consensus embedding dimension.
\begin{proof}
Omitted for brevity.
\end{proof}
\end{lemma}
As can be shown, since $\mat{\Delta}\mat{L}_{\mat{A}}$, $\mat{\Delta}\mat{L}_{\mat{X}}$, $\mat{\Delta}\mat{D}_{\mat{A}}$, and $\mat{\Delta}\mat{D}_{\mat{X}}$ are often very sparse, thus $l_{a}$, $l_{x}$, $d_{a}$, $d_{x}$ are usually very small, meanwhile we have $k\ll n$ and $l \ll n$. Based on the above analysis, the proposed online embedding algorithm for dynamic attributed networks is much more efficient than rerunning the offline method repeatedly.
\section{Experiments}
In this section, we conduct experiments to evaluate the effectiveness and efficiency of the proposed DANE framework for dynamic attributed network embedding. In particular, we attempt to answer the following two questions: (1) \emph{Effectiveness}: how effective are the embeddings obtained by DANE on different learning tasks? (2) \emph{Efficiency}: how fast is the proposed framework DANE compared with other offline embedding methods? We first introduce the datasets and experimental settings before presenting details of the experimental results.
\subsection{Datasets}
We use four datasets BlogCatalog, Flickr, Epinions and DBLP for experimental evaluation. Among them, BlogCatalog and Flickr are synthetic data from static attributed networks, and they have been used in previous research~\cite{li2015unsupervised,li2016robust}. We randomly add 0.1\% new edges and change 0.1\% attribute values at each time step to simulate its evolving nature. The other two datasets, Epinions and DBLP are real-world dynamic attributed networks. Epinions is a product review site in which users share their reviews and opinions about products. Users themselves can also build trust networks to seek advice from others. Node attributes are formed by the bag-of-words model on the reviews, while the major categories of reviews by users are taken as the ground truth of class labels. The data has 16 different time steps. In the last dataset DBLP, we extracted a DBLP co-author network for the authors that publish at least two papers between the years of 2001 and 2016 from seven different areas. Bag-of-words model is applied on the paper title to obtain the attribute information, and the major area the authors publish is considered as ground truth. It should be noted that in all these four datasets, the evolution of network structure and node attributes are very smooth. The detailed statistics of these datasets are listed in Table~\ref{table:datasets}.
\begin{table}
\centering
\begin{tabular}{c|c|c|c|c} \hline
& BlogCatalog & Flickr & Epinions & DBLP\\ \hline \hline
$\#$ Nodes & 5,196 & 7,575 & 14,180 & 23,393\\ \hline
$\#$ Attributes & 8,189 & 12,047 & 9,936 & 8,945 \\ \hline
$\#$ Edges & 173,468 & 242,146 & 227,642 & 289,478 \\ \hline
$\#$ Classes & 6 & 9 & 20 & 7\\ \hline
$\#$ Time Steps & 10 & 10 & 16 & 16 \\ \hline
\end{tabular}
\caption{Detailed information of the datasets.}
\label{table:datasets}
\end{table}
\subsection{Experimental Settings}
One commonly adopted way to evaluate the quality of the embedding representation~\cite{chang2015heterogeneous,jacob2014learning,perozzi2014deepwalk,tang2015line} is by the following two unsupervised and supervised tasks: network clustering and node classification. First, we validate the effectiveness of the embedding representations by DANE on the network clustering task. Two standard clustering performance metrics, i.e., \emph{clustering accuracy} (ACC) and \emph{normalized mutual information} (NMI) are used. In particular, after obtaining the embedding representation of each node in the attributed network, we perform K-means clustering based on the embedding representations. The K-means algorithm is repeated 10 times and the average results are reported since K-means may converge to the local minima due to different initializations. Another way to assess the embedding is by the node classification task. Specifically, we split the the embedding representations of all nodes via a 10-fold cross-validation, using 90\% of nodes to train a classification model by logistic regression and the rest 10\% nodes for the testing. The whole process is repeated 10 times and the average performance are reported. Three evaluation metrics, \emph{classification accuracy}, \emph{F1-Macro} and \emph{F1-Micro} are used. How to determine the optimal number of embedding dimensions is still an open research problem, thus we vary the embedding dimension as $\{10,20,...,100\}$ and the best results are reported.
\subsubsection{Baseline Methods}
DANE is measured against the following baseline methods on the two aforementioned tasks:
\begin{itemize}
\item \textbf{Deepwalk}: learns network embeddings by word2vec and truncated random walk techniques~\cite{perozzi2014deepwalk}.
\item \textbf{LINE}: learns embeddings by preserving the first-order and second-order proximity structures of the network~\cite{tang2015line}.
\item \textbf{DANE-N}: is a variation of the proposed DANE with only network information.
\item \textbf{DANE-A}: is a variation of the proposed DANE with only attribute information.
\item \textbf{CCA}: directly uses the original network structure and attributes for a joint low-dimensional representation~\cite{hardoon2004canonical}.
\item \textbf{LCMF}: maps network and attributes to a shared latent space by collective matrix factorization~\cite{zhu2007combining}.
\item \textbf{LANE}: is a label informed attributed network embedding method, we use one of its variant LANE w/o Label~\cite{huang2017label}.
\item \textbf{DANE-O}: is a variation of DANE that reruns the offline model at each time step.
\end{itemize}
It is important to note that Deepwalk, LINE, CCA, LCMF, LANE, and DANE-O can only handle static networks. To have a fair comparison with the proposed DANE framework, we rerun these baseline methods at each time step and report the average performance over all time steps\footnote{For baseline methods that cannot finish in 24hrs, we only run it once. As networks evolve smoothly, there is not much difference in terms of average performance.}. We follow the suggestions of the original papers to set the parameters of all these baselines.
\subsection{Unsupervised Task - Network Clustering}
To evaluate the effectiveness of embedding representations, we first compare DANE with baseline methods on network clustering which is naturally an unsupervised learning task. As per the fact that the attributed networks are constantly evolving, we compare the average clustering performance over all time steps. The average clustering performance comparison w.r.t. ACC and NMI are presented in Table~\ref{table:clustering}. We make the following observations:
\begin{table*}[!t]
\centering
\caption{Clustering results ($\%$) comparison of different embedding methods.}
\newcommand{\minitab}[2][l]{\begin{tabular}{#1}#2\end{tabular}}
\begin{tabular}{|c|c||c|c||c|c||c|c||c|c|}\hline
\multicolumn{2}{|c||}{Datasets} & \multicolumn{2}{|c||}{BlogCatalog} & \multicolumn{2}{|c||}{Flickr} & \multicolumn{2}{|c||}{Epinions} & \multicolumn{2}{|c|}{DBLP} \\ \hline\hline
\multicolumn{2}{|c||}{Methods} & ACC & NMI & ACC & NMI & ACC & NMI & ACC & NMI \\ \hline
\multirow{3}{*}{Network} & Deepwalk & 49.85 & 30.51 & 40.70 & 24.29 & 13.31 & 12.72 & 53.61 & 32.54 \\ \cline{2-10}
& LINE & 50.20 & 29.53 & 42.93 & 26.01 & 14.34 & 12.65 & 51.61 & 30.74 \\ \cline{2-10}
& DANE-N & 37.05 & 21.84 & 31.89 & 18.91 & 12.01 & 11.95 & 56.61 & 31.54 \\ \hline \hline
Attributes & DANE-A & 62.32 & 45.95 & 63.80 & 48.29 & 16.12 & 11.62 & 47.37 & 20.64 \\ \hline \hline
\multirow{5}{*}{Network+Attributes} & CCA & 33.42 & 11.86 & 24.39 & 10.89 & 10.85 & 8.61 & 26.42 & 18.60 \\ \cline{2-10}
&LCMF & 55.72 & 40.38 & 27.03 & 13.06 & 12.86 & 10.73 & 42.27 & 26.48 \\ \cline{2-10}
&LANE & 65.06 & 48.89 & 65.45 & 52.58 & 32.18 & 22.09 & 55.80 & 31.84 \\ \cline{2-10}
&DANE-O & 80.31 & 59.46 & 67.33 & 53.04 & 34.11 & 23.07 & 59.14 & 35.31 \\ \cline{2-10}
&DANE & 79.69 & 59.32 & 67.24 & 52.19 & 34.52 & 22.36 & 57.68 & 34.87 \\ \hline
\end{tabular}
\label{table:clustering}
\end{table*}
\begin{itemize}
\item DANE and its offline version DANE-O consistently outperform all baseline methods on four dynamic attributed networks by achieving better clustering performance. We also perform pairwise Wilcoxon signed-rank test~\cite{demvsar2006statistical} between DANE, DANE-O and these baseline methods and the test results show that DANE and DANE-O are significantly better (with both 0.01 and 0.05 significance levels).
\item DANE, DANE-O and LANE achieve better clustering performance than network embedding methods such as Deepwalk, LINE and DANE-N and attribute embedding method DANE-A. The improvements indicate that attribute information is complementary to pure network topology and can help learn more informative embedding representations. Meanwhile, DANE also outperforms the CCA and LCMF which also leverage node attributes. The reason is that although these methods learn a low-dimensional representation by using both sources, they are not explicitly designed to preserve the node proximity. Also, their performance degenerates when the data is very noisy.
\item Even though DANE leverages matrix perturbation theory to update the embedding representations, its performance is very close to DANE-O which reruns at each time step. It implies that the online embedding model does not sacrifice too much informative information in terms of embedding.
\end{itemize}
\subsection{Supervised Task - Node Classification}
\begin{table*}[!t]
\centering
\caption{Classification results ($\%$) comparison of different embedding methods.}
\newcommand{\minitab}[2][l]{\begin{tabular}{#1}#2\end{tabular}}
\begin{tabular}{|c|c||c|c|c||c|c|c||c|c|c||c|c|c|}\hline
\multicolumn{2}{|c||}{Datasets} & \multicolumn{3}{|c||}{BlogCatalog} & \multicolumn{3}{|c||}{Flickr} & \multicolumn{3}{|c||}{Epinions} & \multicolumn{3}{|c|}{DBLP} \\ \hline\hline
\multicolumn{2}{|c||}{Methods} & AC & Micro & Macro & AC & Micro & Macro & AC & Micro & Macro & AC & Micro & Macro \\ \hline
\multirow{3}{*}{Network} & Deepwalk & 68.05 & 67.15 & 68.18 & 60.08 & 58.93 & 59.08 & 22.12 & 17.43 & 20.10 & 74.38 & 69.65 & 72.37 \\ \cline{2-14}
&LINE & 70.20 & 69.88 & 70.91 & 61.03 & 60.90 & 60.01 & 23.54 & 17.17 & 21.05 & 72.97 & 67.56 & 70.97 \\ \cline{2-14}
&DANE-N & 66.97 & 66.06 & 67.78 & 49.37 & 47.82 & 49.34 & 21.25 & 20.57 & 21.88 & 71.99 & 65.33 & 71.94 \\ \hline \hline
Attributes&DANE-A & 80.23 & 79.86 & 80.23 & 76.66 & 75.59 & 76.60 & 23.76 & 21.57 & 22.00 & 63.92 & 54.80 & 62.97 \\ \hline \hline
\multirow{5}{*}{Network+Attributes} &CCA & 48.63 & 49.96 & 49.63 & 27.09 & 26.54 & 26.09 & 11.53 & 9.43 & 10.56 & 45.67 & 42.08 & 43.83 \\ \cline{2-14}
&LCMF & 84.41 & 89.01 & 89.26 & 66.27 & 66.75 & 65.71 & 19.14 & 9.22 & 10.14 & 69.71 & 68.01 & 68.42 \\ \cline{2-14}
&LANE & 87.52 & 87.52 & 87.93 & 77.54 & 77.81 & 77.26 & 27.74 & 28.45 & 28.87 & 72.15 & 71.09 & 73.48 \\ \cline{2-14}
&DANE-O & 89.34 & 89.15 & 89.23 & 79.68 & 79.52 & 79.95 & 31.23 & 31.28 & 31.35 & 77.21 & 74.96 & 75.48 \\ \cline{2-14}
&DANE & 89.09 & 88.78 & 88.94 & 79.56 & 78.94 & 79.56 & 30.87 & 30.93 & 30.81 & 76.64 & 74.53 & 75.69 \\ \hline
\end{tabular}
\label{table:classification}
\end{table*}
Next, we assess the effectiveness of embedding representations on a supervised learning task - node classification. Similar to the settings of network clustering, we report the average classification performance over all time steps. The classification results in terms of three different measures are shown in Table~\ref{table:classification}. The following findings can be inferred from the table:
\begin{itemize}
\item Generally, we have the similar observations as the clustering task. The methods which only use link information or node attributes (e.g., Deepwalk, LINE, DANE-N, DANE-A) and methods which do not explicitly model node proximity (e.g., CCA, LCMF) give poor classification results.
\item The embeddings learned by DANE and DANE-O help train a more discriminative classification model by obtaining higher classification performance. In addition, pairwise Wilcoxon signed-rank test~\cite{demvsar2006statistical} shows that DANE and DANE-O are significantly better.
\item For the node classification task, the attribute embedding method DANE-A works better than the network embedding method in the BlogCatalog, Flickr and Epinions datasets. The reason is that in these datasets, the class labels are more closely related to the attribute information than the network structure. However, it is a different case for the DBLP dataset in which the labels of authors are more closely related to the coauthor relationships.
\end{itemize}
\subsection{Efficiency of Online Embedding}
To evaluate the efficiency of the proposed DANE framework, we compare DANE with several baseline methods CCA, LCMF, LANE which also use two data representations. Also, we include the offline version of DANE, i.e., DANE-O. As all these methods are not designed to handle network dynamics, we compare their cumulative running time over all time steps and plot it in a log scale. As can be observed from Figure~\ref{fig:runtime}, the proposed DANE is much faster than all these comparison methods. In all these datasets, it terminates within one hour while some offline methods need several hours or even days to run. It can also be shown that both DANE and DANE-O are much faster than all other offline methods. To be more specific, for example, DANE is 84$\times$, $21\times$ and 14$\times$ faster than LCMF, CCA and LANE respectively on Flickr dataset.
\begin{figure*}[!t]
\centering
\begin{minipage}{0.48\textwidth}
\centering
\subfigure[BlogCatalog\label{fig:blogcatalogcumulative}]
{\includegraphics[width=\textwidth]{cumulative-blogcatalog.eps}}
\end{minipage}
\begin{minipage}{0.48\textwidth}
\centering
\subfigure[Flickr\label{fig:flickrcumulative}]
{\includegraphics[width=\textwidth]{cumulative-flickr.eps}}
\end{minipage}
\begin{minipage}{0.48\textwidth}
\centering
\subfigure[Epinions\label{fig:epinionscumulative}]
{\includegraphics[width=\textwidth]{cumulative-epinions.eps}}
\end{minipage}
\begin{minipage}{0.48\textwidth}
\centering
\subfigure[DBLP\label{fig:dblpcumulative}]
{\includegraphics[width=\textwidth]{cumulative-dblp.eps}}
\end{minipage}
\vspace{-1\baselineskip}
\caption{Cumulative running time comparison.}
\label{fig:runtime}
\end{figure*}
To further investigate the superiority of DANE against its offline version DANE-O, we compare the speedup rate of DANE against DANE-O w.r.t. different embedding dimensions in Figure~\ref{fig:speedup}. As can be observed, when the embedding dimension is small (around 10), DANE achieves around 8$\times$, 10$\times$, 8$\times$, 12$\times$ speedup on BlogCatalog, Flickr, Epinions, and DBLP, respectively. When the embedding dimensionality gradually increases, the speedup of DANE decreases, but it is still significantly faster than DANE-O. With all the above observations, we can draw a conclusion that the proposed DANE framework is able to learn informative embeddings for attributed networks efficiently without jeopardizing the classification and the clustering performance.
\begin{figure*}[!t]
\centering
\begin{minipage}{0.475\textwidth}
\centering
\subfigure[BlogCatalog\label{fig:blogcatalogspeedup}]
{\includegraphics[width=\textwidth]{speedup-blogcatalog.eps}}
\end{minipage}
\begin{minipage}{0.475\textwidth}
\centering
\subfigure[Flickr\label{fig:flickrspeedup}]
{\includegraphics[width=\textwidth]{speedup-flickr.eps}}
\end{minipage}
\begin{minipage}{0.475\textwidth}
\centering
\subfigure[Epinions\label{fig:epinionsspeedup}]
{\includegraphics[width=\textwidth]{speedup-epinions.eps}}
\end{minipage}
\begin{minipage}{0.475\textwidth}
\centering
\subfigure[DBLP\label{fig:dblpspeedup}]
{\includegraphics[width=\textwidth]{speedup-dblp.eps}}
\end{minipage}
\vspace{-1\baselineskip}
\caption{Running time speedup of DANE against its offline version DANE-O.}
\label{fig:speedup}
\end{figure*}
\section{Related Work}
We briefly review related work from (1) network embedding; (2) attributed network mining; and (3) dynamic network analysis.
The pioneer of network embedding can be dated back to the 2000s when many graph embedding algorithms~\cite{belkin2001laplacian,roweis2000nonlinear,tenenbaum2000global} were proposed. These methods target to build an affinity matrix that preserves the local geometry structure of the data manifold and then embed the data to a low-dimensional representation. Motivated by the graph embedding techniques, Chen et al.~\cite{chen2007directed} proposed one of the first network embedding algorithms for directed networks. They used random walk to measure the proximity structure of the directed network. Recently, network embedding techniques have received a surge of research interests in network science. Among them, Deepwalk~\cite{perozzi2014deepwalk} generalizes the word embedding and employs a truncated random walk to learn latent representations of a network. Node2vec~\cite{grover2016node2vec} further extends Deepwalk by adding the flexibility in exploring node neighborhoods. LINE~\cite{tang2015line} carefully designs an optimized objective function that preserves first-order and second-order proximities to learn network representations. GraRep~\cite{cao2015grarep} can be regarded as an extension of LINE which considers high-order information. Most recently, some deep learning based approaches are proposed to enhance the learned embeddings~\cite{wang2016structural,yang2016revisiting}.
All the above mentioned approaches, however, are limited to deal with plain networks. In many cases, we are often faced with attributed networks. Many efforts have been devoted to gain insights from attributed networks. For example, Zhu et al.~\cite{zhu2007combining} proposed a collective matrix factorization model that learns a low-dimensional latent space by both the links and node attributes. Similar matrix factorization based methods are proposed in~\cite{yang2015network,zhang2016collective}. Chang et al.~\cite{chang2015heterogeneous} used deep learning techniques to learn a joint feature representation for heterogeneous networks. Huang et al.~\cite{huang2017label} studied whether label information can help learn better feature representation in attributed networks. Instead of directly learning embeddings, another way is to perform unsupervised feature selection~\cite{tang2012unsupervised,li2016robust,cheng2017feature}. Nevertheless, all these methods can only handle static networks; it is still not clear how to learn embedding representations efficiently when attributed networks are constantly evolving over time. The problem of attributed network embedding is also related to but distinct from multi-modality or multi-view embedding~\cite{xu2013survey,kumar2011co,zhang2017react}. In attributed networks, the network structure is more than a single view of data as it encodes other types of rich information, such as connectivity, transitivity, and reciprocity.
As mentioned above, many real-world networks, especially social networks, are not static but are continuously evolving. Hence, the results of many network mining tasks will become stale and need to be updated to keep freshness. For example, Tong et al.~\cite{tong2008colibri} proposed an efficient way to sample columns and/or rows from the network adjacency matrix to achieve low-rank approximation. In~\cite{tang2008community}, the authors employed the temporal information to analyze the multi-mode network when multiple interactions are evolving. Ning et al.~\cite{ning2007incremental} proposed an incremental approach to perform spectral clustering on networks dynamically. Aggarwal and Li~\cite{aggarwal2011node} proposed a random-walk based method to perform dynamic classification in content-based networks. In~\cite{chen2015fast,chen2017eigen}, a fast eigen-tracking algorithm is proposed which is essential for many graph mining algorithms involving adjacency matrix. Li et al.~\cite{li2016toward} studied how to perform unsupervised feature selection in a dynamic and connected environment. Zhou et al.~\cite{zhou2015rare} investigated the rare category detection problem on time-evolving graphs. A more detailed review of dynamic network analysis can be referred to~\cite{aggarwal2014evolutionary}. However, all these methods are distinct from our proposed framework as we are the first to tackle the problem of attributed network embedding in a dynamic environment.
\section{Conclusions and Future Work}
The prevalence of attributed networks in many real-world applications presents new challenges for many learning problems because of its natural heterogeneity. In such networks, interactions among networked instances tend to evolve gradually, and the associated attributes also change accordingly. In this paper, we study a novel problem: how to learn embedding representations for nodes in dynamic attributed networks to enable further learning tasks. In particular, we first build an offline model for a consensus embedding presentation which could capture node proximity in terms of both network topology and node attributes. Then in order to capture the evolving nature of attributed network, we present an efficient online method to update the embeddings on the fly. Experimental results on synthetic and real dynamic attributed networks demonstrate the efficacy and efficiency of the proposed framework.
There are many future research directions. First, in this paper, we employ first-order matrix perturbation theory to update the embedding representations in an online fashion. We would like to investigate how the high-order approximations can be applied to the online embedding learning problem. Second, this paper focuses on online embedding for two different data representations; we also plan to extend the current framework to multi-mode and multi-dimensional dynamic networks.
\section*{Acknowledgements}
This material is based upon work supported by, or in part by, the National Science Foundation (NSF) grant 1614576, and the Office of Naval Research (ONR) grant N00014-16-1-2257.
\balance
| {'timestamp': '2018-08-28T02:13:58', 'yymm': '1706', 'arxiv_id': '1706.01860', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01860'} | arxiv |
\section{Introduction}
In the recent past, devices such as desktop computers and laptops were our best means for staying connected to the Internet community and to have access to online services. However, with enhanced capabilities, low cost and user-friendly interfaces, smartphones have become people's first choice to stay connected to the Internet. This is equally credited to the publicly available Internet which facilitates users to access their device contents regardless of their location. According to a recent study~\cite{SMR2018}, over 80\% of cell phone users globally using smartphones furthermore 2.56 billion people are estimated to own smartphones by the end of 2018.
With this rapid growth trend in the usage of smartphones, device control, and data security have become extremely important. Not only personal and professional contact information is stored such as email IDs, passwords, banking details i.e. credit and debit card information, photos and videos, but users also store their sensitive and critical information in their smartphones~\cite{Zahid2009}. If the device is stolen, the stored information can be used to create many troubles not only for the user but also for the individuals in their contacts. In order to secure this access, it is important to develop fast and accurate methods for legitimate user identification and block-out impostors. Ideally, these methods should detect an impostor from the moment a device is stolen with acceptable accuracy within a minimum time span.
Current identification methods such as secret PIN number (SPN) or lock codes~\cite{Wang2003} are not only risky- since tools to extract SPNs are easily available on the Internet, but also difficult to use - particularly for the elderly and physically impaired users who find entering PIN codes or screen patterns difficult. Another factor which restricts the security of SPNs-based mechanisms is that smartphones are mostly used in public places with many other people around. This increases the chances for the codes to be found-out by potential attackers. To overcome these issues, fast and secure methods are required to intelligently verify the legitimate user and to block-out impostors.
In the literature hereby referred to, several solutions were proposed addressing implicit user identification without involving the user, such as keystroke-based user identification~\cite{Zahid2009}, touch screen biometrics~\cite{Holz2015, Feng2014}, application set fingerprints~\cite{Ahmad2018}, hybrid user identification methods-such as accelerometers and gyroscopes~\cite{Dandachi2013, Shi2011, Bo2013}, and gait based user identification~\cite{Boyle2011, Ahmad2016}. However, these solutions only discuss one aspect of user identification, either software or hardware.
The first thing attackers do after stealing a smartphone is to walk away from the actual user. Considering this fact, the gait-based legitimate user identification methods are most efficient, as they detect the impostor from their walking or running patterns at that same time and thus can trigger an alarm to keep the real user informed. This type of legitimate user identification method protects not only the smartphone itself, as well as the stored data when the device is stolen by swiftly triggering an alarm. However, due to several contributing factors, the implementation of such real-time identification is quite challenging. There are 2 key important features in a gait-based legitimate user identification system:
\begin{enumerate}
\item{The user can perform the same ambulatory sub-activity differently at different times.}
\item{Various users require a distinctive set of features for user identification: male and female have different physical characteristics, therefore, will have explicit identification processes.}
\end{enumerate}
This study focuses on the idea of identifying a smartphone user by applying different walking patterns, hereby referred to as sub-activities. Furthermore, it is assumed that the phone is freely placed without any particular orientation inside any of the user's pants pockets. Data on walking patterns are recorded using an embedded triaxial, where we intentionally limited the scope to just walking, in order to understand how fast and accurate can ambulatory sub-activity-based legitimate user identification be.
The aim of this research is to propose a semi-controlled environment system in which we overcome the limitations of users' age, gender, jeans style (loose or tight) and walking style (we intentionally asked users to walk differently in various times to investigate the ambulatory activity performed by each user). In this regard, the aim of our current work is to investigate several research questions relevant to building a walking-based legitimate user identification system in real life:
\begin{enumerate}
\item{Does the Extended Sammon Projection (ESP), a non-linear unsupervised feature selection method improve the identification accuracy more than the other existing and well-studied unsupervised feature selection methods such as Principal Component Analysis (PCA)?}
\item{Does kernel-based Extreme Learning Machine (KELM) an effective classifier for the non-linear signal-based user identification method?}
\item{How to achieve real-time user identification in practice? Since our goal is to develop an algorithm which identifies the user in real time, thus computation complexity is extremely important. System performance measurements ought to be considered to balance the trade-off between accuracy and computational cost.}
\item{Does the data variation affect the performance of the legitimate user identification process?}
\end{enumerate}
Our major research obligations are towards answering the above questions using ESP and KELM methods. In this work, we introduce a novel two-fold one-subject-cross-validation based legitimate user identification system, thus addressing the above questions within a sub-activity recognition-based legitimate user identification method on smartphones, in a real-time environment.
The remainder of this paper is organized as follows: Section 2 explains related works; Section 3 describes the system design; Section 4 presents the system validation and the discussion on results, and finally, section 5 concludes with possible future directions.
\section{Related Work}
The objective of this work is to provide convenience in using smartphones differently from explicit identification, by using sensor data information. Therefore, hereby we present some key related works on this field which can be categorized into two groups: implicit user identification and multiple modality biometrics. Shi, et al.~\cite{Shi2011} proposed a Sen-guard method for user identification, offering continuous and implicit user identification service for smartphone users. This method leverages the sensors available on smartphones, e.g. voice, multi-touch and location; these sensors are processed together in order to get the user's identification features implicitly. Explicit identification is performed only when there is an important evidence of change in the user activity, which is not real-time upto some extent.
In recent years, several other implicit identification approaches have been proposed leveraging smartphone's sensor devices such as accelerometer~\cite{Mantyjarvi2005}, touch screen~\cite{Sae-Bae2012}, GPS~\cite{Marcus2012} and microphone~\cite{Lu2011}. T. Feng, et al.~\cite{Feng2012} proposed to extract finger motion speed and acceleration of touch patterns as features. Luca, et al.~\cite{DeLuca2012} suggested to directly compute the distance between pattern traces using the dynamic time warping algorithm. Sae-Bae, et al.~\cite{NSae-Bae2012} present 22 special touch patterns for user identification, most of which involve all five fingers simultaneously. They then computed dynamic time warping distance and Freshet distance between multi-touch traces. Frank, et al.~\cite{Frank2013} studied the correlation between 22 analytic features from touch traces and classified them using k nearest neighbors and support vector machines. Shahzad, et al.~\cite{Shahzad2013} explained the use of touchscreen patterns as a secure unlocking mechanism at the login screen.
Moreover, the idea behind the behavior-based model is that the person's habits are a set of its attributes; therefore, each event (activity) has a correlation between two fundamental attributes: space and time. In addition, the architecture proposed in~\cite{Lima2011}, utilizes the resources found in the smartphone devices, such as user calls, user schedule, GPS, device battery level, user applications, and sensors. A similar methodology has also been adopted in~\cite{Rocha2011}. Clarke, et al.~\cite{Clarke2006} proposed smartphone's user perception of identification, in which results showed the system implicitly and continuously performing user identification in the background. Koreman, et al.~\cite{Sabharwal2017} recommended continuous multiple model-based approaches for user identification. Mantyjarvi, et al.~\cite{Mantyjarvi2005} used an accelerometer in television remote controls to identify individuals. Gafurov, et al.~\cite{Gafurov2009} and Cuntoor. et al.~\cite{Kale2002} suggested an experimented user identification using gait analysis and recognition. Jakobsson, et al.~\cite{Jakobsson2009} put forward another unique implicit user identification framework by using recorded phone call history and location for continuous user identification.
However, these approaches present several propositions for legitimate user identification, but to some extent, all required some additional information and source. Casale, et al.~\cite{Casale2012} proposed a user verification and authentication method using gait as a biometric unobtrusive pattern. A four-layer architecture was built around the geometric concept of a convex hull. This was a twofold method, in which first, a general activity identification based classifier is personalized for a specific user based on their walking patterns, and second, where the author verifies whether the user is authorized or not by using the one-class classification method. The proposed architecture is able to improve robustness to the outliers, account for temporal coherence information and most importantly for non-convex shapes. The most important fact about this system was not its non-user-friendliness, thus the user can only operate this system in specific and controlled environments. Mantyjarvi~\cite{Mantyjarvi2005} studied a user's identification utilizing portable devices from gait signals acquired with three-dimensional accelerometers. They originally proposed three approaches: data distribution statistics, correlation, and frequency domain to identify the subject while walking at different speeds: fast, normal and slow, where the accelerometer device was placed on the user's belt only at the back. The identification process by this method was novel but only limited to walking by the same users and with limited variations. Similar studies for user identification were proposed in~\cite{Rong2007, Derawi2010, Gafurov2010, MDerawi2010, Bours2010} using external accelerometers. To some extent, these studies are innovative but solely rely on external accelerometers with limited activity or sub-activities.
Conclusively, all previous works require users to either perform predefined touch patterns or for the data to be collected under controlled experimental environments, which might not be a real representation of common user interactions. For this situation, the proposed gait-based legitimate user identification work is an interesting application alternative for the process of identifying explicit and continuous legitimate user or impostor in a semi-controlled environment; hence, overcomes the smartphone's limitations in power consumption and cost. Moreover, today's research is towards the smartphone's emergence of these kinds of identification mechanisms.
We worked on combining different approaches to deliver a more reliable legitimate user identification model using a built-in accelerometer for different sub-activities in the semi-controlled environment. In short, several studies have experimented user identification using gait recognition as a possible identification method. Our proposed approach utilizes acceleration signals and detects users by their way of walking under different sub-activities in a semi-controlled environment, and for this, a motion-recording device is used in order to measure the acceleration according to the three axes outlined in~\cite{Dandachi2013, Gafurov2007}.
\section{System Design}
Nowadays, smartphones are equipped with a variety of motion sensors which are useful for monitoring the device movements such as, tilt, rotation, shaking, and swinging. Two of these are the accelerometer (ACC) and the linear acceleration (LACC) sensors. This work explores built-in sensors to validate the sensor's capacities for legitimate user identification processing. To this end, the first task of our proposed system is to collect data using two different enabled sensors, namely, ACC and LACC. The second task is the feature extraction and analysis based on both the time and frequency domain features. The third task is feature selection and the fourth task is the classification for legitimate user identification-based on performed sub-activities while walking. Finally, the fifth task is towards the evaluation of our proposed method on a publicly available dataset.
\subsection{Data Collection}
In this work, we have used two different datasets, the first data is collected using an Android smartphone. In this regards, we have collected raw signals from two different sensors, as the user performed daily sub-activities. These sub-activities included walking while the smartphone was intentionally placed in one of the subject's pants pockets, e.g. back right pocket (BRP), back left pocket (BLP), front right pocket (FRP) and front left pocket (FLP). We recorded these sub-activities without any constraints on the smartphone's orientation inside of any of the user's pockets.
The first dataset was gathered from four users each one performing individual sub-activities each day; each sub-activity was performed at least twice a day. Thus, the compiled data is from one same user, doing the same activity on different days, for an entire month. Initially, we stored these raw signals in a micro SD card, which we later transferred to a computer for further analysis. It is worth pointing out since different smartphone models have different sampling rates, therefore, in order to control the data collection process and better validation and generalization, we have used 50Hz sampling rate instead to use highest sampling rate within different smartphones~\cite{Saputri2014}. A sample raw signal representation of each sub-activity for both sensors are shown in Figure~\ref{Fig1}.
The second dataset was acquired from 16 healthy users between the ages of 19 to 48 years old. The dataset was gathered from all users by using a linear acceleration sensor (LACC) with a constant rate of 50Hz while they were wearing a smartphone on their waist. The dataset was pre-processed by applying noise filters, using 2.56 sec windows with a 50\% overlap. The second experimental dataset is an extended version of the UCI human activity recognition process using a smartphone dataset and can be freely downloaded from the UCI website~\cite{Ortiz2016}.
\subsection{Feature Extraction}
The accelerometer sensor generates time series signals which are highly fluctuating and oscillatory in nature~\cite{Saputri2014, Ortiz2016, Fahim2013}, thus making the legitimate user identification more difficult. Therefore, it is compulsory to gather the nontrivial signals from the raw data through the feature extraction process. Particularly, we divided the raw signal into several equal size windows to control the flow rate, hence passing fewer data to the system to be able to extract all meaningful information. Given a sampling rate of 50Hz, we initially chose a window size of 50 samples for both sensors as shown in Figure 1. The selected window size provides enough data to be able to extract the quality features while ensuring a fast response~\cite{Saputri2014}.
\begin{figure*}[!ht]
\centering
\subfigure[ACC: Back Left]{%
\includegraphics[scale=0.21]{Fig1A.eps}}%
\qquad
\subfigure[ACC: Back Right]{%
\includegraphics[scale=0.21]{Fig1B.eps}}%
\qquad
\subfigure[ACC: Front Left]{%
\includegraphics[scale=0.21]{Fig1C.eps}}%
\qquad
\subfigure[ACC: Front Right]{%
\includegraphics[scale=0.21]{Fig1D.eps}}%
\qquad
\subfigure[LACC: Back Left]{%
\includegraphics[scale=0.21]{Fig1E.eps}}%
\qquad
\subfigure[LACC: Back Right]{%
\includegraphics[scale=0.21]{Fig1F.eps}}%
\qquad
\subfigure[LACC: Front Left]{%
\includegraphics[scale=0.21]{Fig1G.eps}}%
\qquad
\subfigure[LACC: Front Right]{%
\includegraphics[scale=0.21]{Fig1H.eps}}%
\caption{Representative raw signals obtained by ACC and LACC sensors for one subject doing activity while the smartphone is freely placed in Back left, Back right, Front left, and Front right pockets.}
\label{Fig1}
\end{figure*}
\begin{figure*}[!ht]
\centering
\subfigure[ACC: Back Left]{%
\includegraphics[scale=0.21]{Fig2A.eps}}%
\qquad
\subfigure[ACC: Back Right]{%
\includegraphics[scale=0.21]{Fig2B.eps}}%
\qquad
\subfigure[ACC: Front Left]{%
\includegraphics[scale=0.21]{Fig2C.eps}}%
\qquad
\subfigure[ACC: Front Right]{%
\includegraphics[scale=0.21]{Fig2D.eps}}%
\qquad
\subfigure[LACC: Back Left]{%
\includegraphics[scale=0.21]{Fig2E.eps}}%
\qquad
\subfigure[LACC: Back Right]{%
\includegraphics[scale=0.21]{Fig2F.eps}}%
\qquad
\subfigure[LACC: Front Left]{%
\includegraphics[scale=0.21]{Fig2G.eps}}%
\qquad
\subfigure[LACC: Front Right]{%
\includegraphics[scale=0.21]{Fig2H.eps}}%
\caption{{Autocorrelation (AC) and Partial autocorrelation (PAC) coefficients from ACC and LACC sensors, respectively.}}
\label{Fig2}
\end{figure*}
Our research analyzed the individual's user data applying time series modeling techniques to understand the behavior in each of the user's physical patterns. Time series analysis reveals unusual observations as well as particular data patterns~cite{Wei1991}. There are three commonly used models to perform time series analysis: moving average~\cite{Haining1978}, auto-regressive~\cite{Cuomo1997} and a combination of both the moving average and the auto-regressive models~\cite{Saputri2014}. We explored with the use of auto-correlation (AC) and partial auto-correlation (PAC) coefficients to identify the model for our data. These coefficients revealed the pattern of each datum and indicated the best model for our data. Each data model is determined based on the characteristics of the theoretical AC and PAC. Samples of AC and PAC for both sensors are shown in Figure~\ref{Fig2}. The fitting process for the time series model is calculated by estimating the parameter values based on a previously selected model. Moving average and auto-regressive parameter estimations require an iteration process~\cite{chatfield2004}, and for that, we follow the "box Jenkins model estimation" due to its flexibility for the inclusion of both the moving average and the auto-regressive models~\cite{Box1990}. The parameters and the model need to be verified to ensure that the estimated results are statistically significant~\cite{Anderson1997, Ahmad2017}.
Detailed analysis revealed that the time domain features, including the coefficients from the time series model, provided the same accuracy as the frequency domain features~\cite{Ahmad2016, Khan2013}. Therefore, in this work, we have extracted both the time and frequency domain features. The extracted features are: mean, median, variance, standard deviation, inter-quartile, auto-correlation, partial correlation, coefficients of the auto-regressive model, coefficients of moving the average model, coefficient of moving average auto-regressive model and wavelet coefficients. These features are extracted from each axis of the three-dimensional acceleration signals. In total 72 features were extracted from each window. Prior to the feature extraction, a moving average filter of order three was employed for noise reduction purposes.
\subsection{Feature Selection}
The output of an embedded motion sensor depends upon the position of the smartphone while walking. This could result in a high within class variance~\cite{Adil2014}. Therefore, it is at the same time desirable to improve both the discriminatory power of the features and achieve dimensionality reduction, by employing an optimum method. Hence, our third important step towards legitimate user identification is feature selection. The advantages of the feature selection process are to avoid the curse of dimensionality~\cite{Li2017}, as well as to reduce the abundant, irrelevance, misleading and noisy features, but above all, to be able to reduce the system's cost pertaining to run-time applications~\cite{Chen2003}. In addition to the above, the main purpose is to increase the accuracy of the resulting model within a short time.
In recent years, several feature selection algorithms have been proposed, including the filter based approach, the wrapper method, the principal components analysis (PCA), the linear discriminant analysis (LDA)~\cite{Adil2010}, KLDA a kernelized version of the LDA~\cite{Adil2014} and SWLDA a stepwise linear discriminant analysis method~\cite{Ahmad2016}. Filter methods are based on discriminating criteria which are relatively independent of classification and use minimum redundancy and maximum relevance for feature selection. These methods are comparatively fast, scalable and provide good computational complexity, but ignore the interaction with the classifier. Alternatively, wrapper methods utilize the classifier as a black box to obtain a subset of features based on their predictive power. These methods interact with the classifier to optimize the feature's subset. The main disadvantages of these methods are their dependency on the classifier, who makes the classifier selection a key important process. In different prospects, the LDA seeks a linear combination of features and characterizes two or more types. Among the three different discriminant analysis approaches, the number of dimensions returned by both the LDA and KLDA depends on the number of classes, which limit the use of LDA and KLDA in user identification systems.
However, in this work, we consider only unsupervised non-linear feature selection methods. In this regard, the most commonly used method is PCA. Through this work, we have introduced an unsupervised and fully automatic feature selection method named extended Sammon projection (ESP) for the first for smartphone-based activity recognition and user identification. The ESP is one of the most successful non-linear metric multidimensional scaling methods and it projects the high dimensional space into a lower dimensional space while preserving the structure of inter-point distances in a high dimensional space within a lower dimensional space. Consequently, let us assume \(d_{i,j}\) be the distance between two adjacent samples \(x_i\) and \(x_j , i \neq j\) from the original space and \(d_{i,j}^*\) be the distance between two samples \(x_i^*\) and \(x_j^*\) in the mapped space; thus, the Sammon stress measure, which is also known as the Sammon error or simple error function E can be defined as;
\begin{eqnarray}
E = \frac{1}{\sum_{i=1}^{n-1} \sum_{j = i+1}^n d_{i,j}} \sum_{i=1}^{n-1} \sum_{j = i+1}^n \frac{d_{i,j}^* - d_{i,j}}{d_{i,j}^*}
\end{eqnarray}
where \(d_{i,j}\) is the Euclidean distance and this error measurement is minimized by using the steepest and gradient decent methods, respectively.
\begin{eqnarray}
x_{ik}^* (t + 1) = x_{ik}^*(t) - \alpha \frac{\partial E(t) \setminus \partial x_{ik}^* (t)}{\mid \partial^2 E(t) \setminus \partial^2 x_{ik}^*(t) \mid}
\end{eqnarray}
\begin{eqnarray}
x_{ik}^* (t + 1) = x_{ik}^*(t) - \alpha \frac{\partial E(t)}{\partial x_{ik}^* (t)}
\end{eqnarray}
In both cases \(x_{ik}^*\) is the \(k^{th}\) coordinate of the position of point \(x_i^*\) in the lower dimensional space. Since the Steepest descent method has issues at the inflection points, where the second-order derivative appears to quite small~\cite{Kohonen2001}, therefore, we set \(\alpha\) between 0.3~0.4 as the optimal value using a grid operation between [0, 1], but there is no reason to expect this given range to be optimal for all problems and datasets.
\subsection{Classifier}
Neural networks have quite diverse real-life applications and among different neural network approaches, extreme learning machines (ELM) have better generalization capabilities and a fast learning speed~\cite{Jeroudi2015}. An ELM is a single hidden layer feed-forward neural network which randomly determines the initial parameters of weights input and hidden biases with simple activation functions~\cite{Ding2015}. Among the factors influencing learning performance, the hidden neurons are very important to improve generalization capabilities.
Moreover, ELMs with a tune-able activation function were proposed to handle the data dependency on hidden neurons. However, the selection of suitable combinations for activation functions is still a big question within the research community. Therefore, kernelized ELMs are known to improve the generalization capabilities, when the feature mapping function of hidden neurons is unknown. However, the parameters for the kernel function need to be selected carefully and in order to improve the generalization performance for real-time applications, such as smartphone-based legitimate user identification, the kernel parameters need to be tuned carefully. In our work, the said parameters are optimized through the swarm optimization based method~\cite{Eberhart1995}.
In ELMs, the initial parameters of the hidden layer need not be tuned and almost all nonlinear, piece-wise continuous functions can be used as hidden neurons. Therefore, for \(N\) distinct samples {\((x_i, t_i) \mid x_i \in R^n, t_i \in R^m, i \in 1,2,3,..., N\)}, and the output function with L hidden neurons can be expressed as;
\begin{eqnarray}
f_L(x) = \sum_{i=1}^L \beta_i h_i(x) = h(x)\beta
\end{eqnarray}
where \(\beta = [\beta_1, \beta_2, . . . , \beta_L]\) be the output weights between the hidden layer and the output neurons; \(h(x) = [h_1(x), h_2(x), . . . , h_L(x)]\) be the output vector of the hidden layer that maps the input space to the feature space~\cite{Huang2012}. The output weights and training error should be minimized to enhance the generalization capabilities. The least square solution to the minimization problem can be expressed as:
\begin{eqnarray}
\beta = H^T \Big(\frac{1}{C} + HH^T \Big)^{-1}T
\end{eqnarray}
where \(H\) be the hidden layer output matrix, T is the expected output matrix, and \(C\) is the regularization coefficient. Thus, the training model output can be expressed as:
\begin{eqnarray}
f(x) = h(x) H^T \Big(\frac{1}{C} + HH^T \Big)^{-1} T
\end{eqnarray}
For an unknown mapping \(h(x)\), the kernel and the output function \(f(x)\) can be defined as;
\begin{eqnarray}
M = HH^T ; m_{i,j} = h(x_i)h(x_j) = \kappa(x_i, x_j)
\end{eqnarray}
\begin{eqnarray}
f(x) = \Big[\kappa (x, x_1) , . . . , \kappa (x, x_N)\Big]\Big(\frac{1}{C} +M\Big)^{-1} T
\end{eqnarray}
where \(\kappa(x,y)\) is the kernel function and can be expressed as in expression (9), where \(a\) and \(b\) are adjustable kernel parameters, which play an important role in generalization performance and are updated using the cross-validation process.
\begin{eqnarray}
\kappa (x, y) = cos \bigg(\frac{\|x - y\|^2}{a}\bigg) exp \bigg(\frac{\|x - y\|^2}{b}\bigg)
\end{eqnarray}
\section{Experimental Settings, Results, and Discussion}
To validate our proposed user identification system, we conducted different experiments on two different datasets as explained in the previous section. Based on first (our-own) dataset, the first experiment aims to show the sub-activities-based legitimate user identification system, in which we conducted detailed comparison (with and without feature selection) on two different unsupervised feature selection methods namely PCA and ESP. Our second experiment explains the identification behavior with different numbers of windows within the best settings obtained from our first experiment. Finally, our third experiment shows the computational cost for our proposed legitimate user identification system. Based on second (publicly available smartphone-based physical activity recognition) dataset, our first experiment presents a user identification method using one-subject-leave-out-cross-validation process during a walking activity, with different numbers of windows, in which the features are processed through ESP method. The second experiment explains the confidence interval for the computational cost of our proposed legitimate user identification system.
\subsection{Experimental Settings}
The values utilized for the different parameters pertaining to the ESP, PCA, and KELM methods were optimized using the cross-validation process. These optimized setting were used during each case of user identification considering each sub-activity, as they provided the best results. In all cases, the wavelet kernel is used and the kernel parameters updated according to the practical swarm method. For the feature selection process, and in order to keep both methods consistent, the same numbers of PCs are selected as the number of features selected by the ESP. The intention behind to select the same number of features was to make this model reliable and consistent. Prior to the classification, all obtained features were normalized and bounded within [0, 1].
\subsection{Experimental Results and Discussion}
In the introduction part we have stated four important research questions for legitimate user identification on smartphone and based on our findings; yes, it is possible to identify a smartphone's legitimate user by analyzing their walking patterns when the device is freely placed in any of their pants pocket. Furthermore, the unsupervised ESP feature selection method significantly boosts identification performance. The KELM method uses 72 features for user identification when the case is without feature selection; both feature selection methods are thus able to reduce this number down to a different number of features ({5, 10, 15, 20, 25, 30, 35, and 40}) keeping always the most informative features. Based on our findings we observe that the ESP together with the KELM classifier is more robust and accurate than the existing well studied unsupervised feature selection method such as PCA.
Our first experiment details the process of our proposed scheme for analyzing the behavior of different numbers of samples per window (i.e. {25, 50, 75, 100, 125, 150, 175, and 200}), on a legitimate user identification process within each sub-activity without feature selection method. Figure~\ref{Fig3} shows the user identification accuracy of a legitimate user being identified with a different number of samples per window, for both sensors' data. From these results, we observe that the BR pocket produced better results with 25 samples per window (80\% to 88\% confidence interval with the LACC and ACC sensors respectively). On average, we can see that, the ACC sensor outperformed than the LACC for legitimate user identification within each sub-activity without feature selection.
\begin{figure}[!ht]
\centering
\subfigure[ACC: without Feature Selection]{%
\includegraphics[scale=0.21]{Fig3A.eps}}%
\qquad
\subfigure[LACC: without Feature Selection]{%
\includegraphics[scale=0.21]{Fig3B.eps}}%
\caption{Average Accuracy for legitimate user identification. The data was collected by both sensors (ACC and LACC) and processed without selecting any features.}
\label{Fig3}
\end{figure}
In our second experiment, we investigated the average identification for all users and each sub-activity within a fixed size window (50 samples per window), for both feature selection methods with a different number of features. Table~\ref{Tab1} lists the results (user identification accuracy across all users and each sub-activity with a 99\% confidence interval) for the case of the PCA-KELM and ESP-KELM. According to the results obtained in Table~\ref{Tab1}, the best performance was obtained by the KELM when the normalized features were extracted by both sensors and processed with the ESP method. The PCA performed slightly better than without the feature selection process, but on average, there was no such difference with and without the feature selection process for the PCA case. All these results were obtained by using 50 samples per window during the feature extraction process.
\begin{table*}[!ht]
\captionsetup{justification=centering}
\caption{Average Accuracy, Confidence Intervals and Time taken for Legitimate User Identification for \(50\) Sample Per Window With Different Feature Selection Methods and Different Number of Features on Both Sensors Data}
\centering
\resizebox{\textwidth}{!}{\begin{tabular}{l |l| l l l l l l l l l l l l l l l l}
\hline
\multirow{3}{*}{\bf Features}& \multirow{3}{*}{\bf Metric} & \multicolumn{4}{|c}{\bf Back Left Pocket} & \multicolumn{4}{|c}{\bf Back Right Pocket} & \multicolumn{4}{|c}{\bf Front Left Pocket}& \multicolumn{4}{|c}{\bf Back Right Pocket} \\ [1.0ex]
&& \multicolumn{2}{|c}{\bf ACC}&\multicolumn{2}{|c}{\bf LACC}&\multicolumn{2}{|c}{\bf ACC}& \multicolumn{2}{|c}{\bf LACC}&\multicolumn{2}{|c}{\bf ACC}&\multicolumn{2}{|c}{\bf LACC}&\multicolumn{2}{|c}{\bf ACC}&\multicolumn{2}{|c}{\bf LACC} \\ [1.0ex]
&& \multicolumn{1}{|c}{\bf PCA}&\multicolumn{1}{|c}{\bf ESP}&\multicolumn{1}{|c}{\bf PCA}&\multicolumn{1}{|c}{\bf ESP}&\multicolumn{1}{|c}{\bf PCA}&\multicolumn{1}{|c}{\bf ESP}&\multicolumn{1}{|c}{\bf PCA}&\multicolumn{1}{|c}{\bf ESP}&\multicolumn{1}{|c}{\bf PCA}& \multicolumn{1}{|c}{\bf ESP}&\multicolumn{1}{|c}{\bf PCA}&\multicolumn{1}{|c}{\bf ESP}&\multicolumn{1}{|c}{\bf PCA}&\multicolumn{1}{|c}{\bf ESP}&\multicolumn{1}{|c}{\bf PCA}& \multicolumn{1}{|c}{\bf ESP}
\\ [2.5ex]
\hline
& \bf Accuracy &55\(\pm\)5.1&50\(\pm\)3.2&50\(\pm\)4.5&53\(\pm\)5.7&52\(\pm\)4.9&53\(\pm\)3.8&51\(\pm\)3.6&50\(\pm\)2.7&54\(\pm\)3.6&55\(\pm\)2.9&57\(\pm\)2.9&54\(\pm\)3.9&54\(\pm\)4.6&63\(\pm\)2.9&54\(\pm\)3.8&52\(\pm\)4.5 \\[-1ex]
\raisebox{1.5ex}{\bf 5} \raisebox{1.5ex} & \bf Time
&0.140&0.138&0.209&0.243&0.265&0.261&0.553&0.527&0.175&0.173& 0.268&0.270&0.164& 0.133&0.201&0.202\\ [1.0ex]
\hline
& \bf Accuracy &74\(\pm\)6.3&85\(\pm\)3.3&67\(\pm\)4.8&85\(\pm\)3.8&63\(\pm\)4.5 &77\(\pm\)2.3 &63\(\pm\)3.4 &84\(\pm\)3.9 &66\(\pm\)2.9 &90\(\pm\)4.6 &72\(\pm\)4.1 &81\(\pm\)3.9 &69\(\pm\)3.8 &74\(\pm\)5.9 &64\(\pm\)4.7 &77\(\pm\)4.8\\[-1ex]
\raisebox{1.5ex}{\bf 10} \raisebox{1.5ex} & \bf Time
&0.140 &0.142 &0.209 &0.214 &0.255 &0.252 &0.535 &0.523 &0.177 &0.178 &0.270 &0.271 &0.131 &0.131 &0.194 &0.188\\[1ex]
\hline
& \bf Accuracy &72\(\pm\)6.2& 98\(\pm\)1.1& 75\(\pm\)4.6& 89\(\pm\)4.1& 76\(\pm\)5.5& 99\(\pm\)0.9& 78\(\pm\)3.9& 96\(\pm\)2.0& 70\(\pm\)5.8& 95\(\pm\)3.4& 77\(\pm\)4.1& 95\(\pm\)2.1& 74\(\pm\)4.1& 98\(\pm\)1.3& 71\(\pm\)5.7& 98\(\pm\)1.0\\[-1ex]
\raisebox{1.5ex}{\bf 15} \raisebox{1.5ex} & \bf Time
&0.142 &0.142 &0.211 &0.238 &0.255 &0.254 &0.536 &0.517 &0.177 &0.178 &0.269 &0.273 &0.135 &0.132 &0.197 &0.203\\[1ex]
\hline
& \bf Accuracy &73\(\pm\)6.1& 97\(\pm\)1.4& 73\(\pm\)4.9& 97\(\pm\)2.0& 76\(\pm\)4.6& 99\(\pm\)0.4& 82\(\pm\)2.5& 98\(\pm\)1.6& 76\(\pm\)3.6& 99\(\pm\)0.7& 76\(\pm\)6.7& 98\(\pm\)2.6& 71\(\pm\)7.1& 95\(\pm\)2.4& 73\(\pm\)5.8& 94\(\pm\)4.2\\[-1ex]
\raisebox{1.5ex}{\bf 20} \raisebox{1.5ex} & \bf Time
&0.142 &0.142 &0.216 &0.219 &0.259 &0.256 &0.538 &0.529 &0.178 &0.189 &0.269 &0.281 &0.132 &0.132 &0.194 &0.212\\[1ex]
\hline
& \bf Accuracy &78\(\pm\)3.8& 99\(\pm\)0.5& 74\(\pm\)4.9& 98\(\pm\)2.7& 72\(\pm\)4.4& 96\(\pm\)3.4& 80\(\pm\)4.6& 98\(\pm\)1.6& 75\(\pm\)6.7& 98\(\pm\)1.2& 76\(\pm\)4.9& 94\(\pm\)2.3& 73\(\pm\)6.7& 96\(\pm\)3.9& 73\(\pm\)8.3& 90\(\pm\)4.9\\[-1ex]
\raisebox{1.5ex}{\bf 25} \raisebox{1.5ex} & \bf Time
&0.148 &0.140 &0.221 &0.219 &0.258 &0.257 &0.532 &0.528 &0.180 &0.179 &0.254 &0.270 &0.134 &0.133 &0.200 &0.203 \\[1ex]
\hline
& \bf Accuracy & \bf 78\(\pm\)3.8& \bf 97\(\pm\)0.4& \bf 76\(\pm\)4.3& \bf 98\(\pm\)1.8& \bf 73\(\pm\)6.9& \bf 98\(\pm\)1.5& \bf 76\(\pm\)3.6& \bf 98\(\pm\)1.4& \bf 76\(\pm\)6.7& \bf 94\(\pm\)3.2& \bf 76\(\pm\)6.4& \bf 99\(\pm\)0.3& \bf 74\(\pm\)3.7& \bf 99\(\pm\)0.5& \bf 68\(\pm\)7.8& \bf 91\(\pm\)4.1\\[-1ex]
\raisebox{1.5ex}{\bf 30} \raisebox{1.5ex} & \bf Time
& \bf 0.148 & \bf 0.143 & \bf 0.216 & \bf 0.217 & \bf 0.260 & \bf0.258 & \bf 0.539 & \bf 0.532 & \bf 0.179 & \bf 0.179 & \bf 0.268 & \bf 0.284 & \bf 0.132 & \bf 0.149 & \bf 0.197 & \bf 0.181 \\[1ex]
\hline
& \bf Accuracy &77\(\pm\)5.4& 99\(\pm\)0.5& 71\(\pm\)6.2& 94\(\pm\)4.7& 72\(\pm\)4.5& 99\(\pm\)0.3& 74\(\pm\)5.9& 87\(\pm\)6.2& 75\(\pm\)4.5& 97\(\pm\)1.7& 73\(\pm\)5.5& 97\(\pm\)3.6& 76\(\pm\)7.2& 99\(\pm\)0.8& 69\(\pm\)7.9& 54\(\pm\)4.9\\[-1ex]
\raisebox{1.5ex}{\bf 35} \raisebox{1.5ex} & \bf Time
&0.143 &0.143 &0.216 &0.208 &0.258 &0.259 &0.536 &0.548 &0.180& 0.179& 0.267 &0.275 &0.134& 0.133 &0.194 &0.201 \\[1ex]
\hline
& \bf Accuracy & \bf 74\(\pm\) \bf 5.9& \bf 98\(\pm\) \bf 0.6& \bf 70\(\pm\) \bf 6.4& \bf 99\(\pm\) \bf 0.4& \bf 71\(\pm\) \bf 4.2& \bf 98\(\pm\) \bf 0.8& \bf 72\(\pm\) \bf 5.9& \bf 99\(\pm\) \bf 0.4& \bf 73\(\pm\) \bf 4.6& \bf 50\(\pm\) \bf 2.8& \bf 71\(\pm\) \bf 4.9& \bf 75\(\pm\) \bf 5.9& \bf 69\(\pm\) \bf 8.2& \bf 98\(\pm\) \bf 1.1& \bf 69\(\pm\) \bf 6.3& \bf 99\(\pm\) \bf 0.4\\[-1ex]
\raisebox{1.5ex}{\bf 40} \raisebox{1.5ex} & \bf Time
& \bf 0.144& \bf 0.142& \bf 0.216& \bf 0.212& \bf 0.262& \bf 0.259& \bf 0.537& \bf 0.532& \bf 0.180& \bf 0.172& \bf 0.276& \bf 0.278& \bf 0.133& \bf 0.148& \bf 0.196& \bf 0.196 \\[1ex]
\hline
\end{tabular}}
\label{Tab1}
\end{table*}
\begin{figure}[!ht]
\centering
\subfigure[ACC: with Feature Selection]{%
\includegraphics[scale=0.21]{Fig4A.eps}}%
\qquad
\subfigure[LACC: with Feature Selection]{%
\includegraphics[scale=0.21]{Fig4B.eps}}%
\caption{Average Accuracy for legitimate user identification. The data was collected by both sensors (ACC and LACC) and processed through ESP-KELM.}
\label{Fig4}
\end{figure}
Figure~\ref{Fig4} shows the average accuracy obtained through ESP using a different number of windows as explained earlier and 30 number of selected features as 30 number of features provide best average results in our previous experiments for all pockets data. For all subsequent experiments, we have fixed 30 number of features selected by the ESP method. From Figure~\ref{Fig4}, we can observe that the performance has significantly improved for the legitimate user identification for both sensors, each with a different number of samples. The average accuracy increased from 70\% to 98\% for 50 samples per window, which is a significant improvement for any legitimate user identification system. From these results, we conclude that the BLP and FRP have some variations according to the number of samples per window; however, this variation is not enough to exclude these sub-activities from our experimental setup, except the ones with 75 and 100 numbers of samples per window. This degradation happens due to the sudden change in the users walking patterns. In future research, we will further investigate legitimate user behaviors, while performing the same sub-activity to minimize the ambiguity to the legitimate user identification method.
\begin{figure}[!ht]
\centering
\subfigure[ACC: With Feature Selection]{%
\includegraphics[scale=0.21]{Fig5A.eps}}%
\qquad
\subfigure[ACC: Without Feature Selection]{%
\includegraphics[scale=0.21]{Fig5B.eps}}%
\caption{Computational Time for Legitimate User Identification using \textbf{ACC} Sensor Data, with and without feature selection.}
\label{Fig5}
\end{figure}
\begin{figure}[!ht]
\centering
\subfigure[LACC: with Feature Selection]{%
\includegraphics[scale=0.21]{Fig6A.eps}}%
\qquad
\subfigure[LACC: Without Feature Selection]{%
\includegraphics[scale=0.21]{Fig6B.eps}}%
\caption{Computational Time for Legitimate User Identification using \textbf{LACC} Sensor Data, with and without feature selection.}
\label{Fig6}
\end{figure}
In our third experiment, we discussed the computational cost in terms of time comparison, pertaining to our previous experiments presented in Figures~\ref{Fig3} and~\ref{Fig4}. Figures~\ref{Fig5} and~\ref{Fig6} show the computational time for KELM with and without using the ESP method; with different numbers of samples per window for each sub-activity and sensor individually.
As shown in above results, the different number of samples per window (25 to 50 samples per window) for both sensors, the computational cost exhibits the huge difference, thus, indicating that identification has a strong influence on the computational time of KELM with the number of samples. However, when we increased the size of samples from 50 to 75 or even to 100, 125, 150, 175, and 200, both systems took almost the same time to complete the legitimate user identification process.
\begin{figure}[!ht]
\centering
\subfigure[ACC: Feature Extraction]{%
\includegraphics[scale=0.21]{Fig7A.eps}}%
\qquad
\subfigure[LACC: Feature Extraction]{%
\includegraphics[scale=0.21]{Fig7B.eps}}%
\caption{Computational Time for \textbf{feature extraction} process for both sensors.}
\label{Fig7}
\end{figure}
\begin{figure}[!ht]
\centering
\subfigure[ACC: Feature Selection]{%
\includegraphics[scale=0.21]{Fig8A.eps}}%
\qquad
\subfigure[LACC: Feature Selection]{%
\includegraphics[scale=0.21]{Fig8B.eps}}%
\caption{Computational Time for \textbf{feature selection} process for both sensors.}
\label{Fig8}
\end{figure}
\begin{table*}[!ht]
\captionsetup{justification=centering}
\caption{Average Accuracy and Confidence Intervals for Legitimate User Identification on Publicly Available Dataset With Different Number of Sample Per Window}
\centering
\resizebox{\textwidth}{!}{\begin{tabular}{l c c c c c c c c c}
\hline
\multirow{2}{*}{\bf User} & \multirow{2}{*}{\bf Metric} & \multicolumn{8}{|c}{\bf Samples Per Window} \\ [0.5ex]
&& \multicolumn{1}{|c}{\bf 25}&\multicolumn{1}{|c}{\bf 50}&\multicolumn{1}{|c}{\bf 75}&\multicolumn{1}{|c}{\bf 100}&\multicolumn{1}{|c}{\bf 125}&\multicolumn{1}{|c}{\bf 150}&\multicolumn{1}{|c}{\bf 175}&\multicolumn{1}{|c}{\bf 200} \\ [0.5ex]
\hline
& \bf Accuracy &97.343\(\pm\)0.133&98.134\(\pm\)0.262& 98.725\(\pm\)0.256& 97.471\(\pm\)0.427& 98.029\(\pm\)0.412& 98.662\(\pm\)0.272& 98.407\(\pm\)0.294& 98.881\(\pm\)0.486 \\[-1ex]
\raisebox{1.5ex}{\bf User 1} \raisebox{1.5ex} & \bf Time
&26.369\(\pm\)0.524&9.968\(\pm\)0.031& 6.290\(\pm\)0.127& 4.776\(\pm\)0.081& 4.025\(\pm\)0.233& 3.188\(\pm\)0.081& 2.634\(\pm\)0.033& 2.435\(\pm\)0.036 \\[1ex]
\hline
& \bf Accuracy &97.162\(\pm\)0.189 &97.848\(\pm\)0.219 &97.572\(\pm\)0.166 &98.350\(\pm\)0.345 &99.085\(\pm\)0.213 &99.317\(\pm\)0.164 &98.984\(\pm\)0.153 &98.784\(\pm\)0.221 \\[-1ex]
\raisebox{1.5ex}{\bf User 2} \raisebox{1.5ex} & \bf Time
&37.635\(\pm\)1.684 &21.510\(\pm\)0.646 &11.758\(\pm\)0.081 &8.326\(\pm\)0.057 &9.055\(\pm\)0.789 &5.711\(\pm\)0.0937 &5.007\(\pm\)0.173 &4.311\(\pm\)0.137 \\[1ex]
\hline
& \bf Accuracy &97.302\(\pm\)0.135& 97.652\(\pm\)0.189& 97.686\(\pm\)0.257& 98.394\(\pm\)0.189& 99.364\(\pm\)0.193& 98.849\(\pm\)0.341& 98.719\(\pm\)0.261& 98.229\(\pm\)0.389 \\[-1ex]
\raisebox{1.5ex}{\bf User 3} \raisebox{1.5ex} & \bf Time
&27.128\(\pm\)0.494 &11.413\(\pm\)0.478 &6.881\(\pm\)0.052 &4.896\(\pm\)0.047& 3.916\(\pm\)0.025 &3.104\(\pm\)0.009 &2.702\(\pm\)0.060& 2.551\(\pm\)0.061 \\[1ex]
\hline
& \bf Accuracy &96.955\(\pm\)0.129 &97.906\(\pm\)0.224 &98.522\(\pm\)0.216 &98.492\(\pm\)0.251 &98.661\(\pm\)0.204 &98.420\(\pm\)0.334 &98.250\(\pm\)0.218 &98.301\(\pm\)0.544 \\[-1ex]
\raisebox{1.5ex}{\bf User 4} \raisebox{1.5ex} & \bf Time
&26.321\(\pm\)0.759& 11.244\(\pm\)0.207& 6.172\(\pm\)0.025& 4.554\(\pm\)0.014& 3.568\(\pm\)0.031& 3.265\(\pm\)0.147& 2.673\(\pm\)0.027& 2.529\(\pm\)0.087\\[1ex]
\hline
& \bf Accuracy &97.906\(\pm\)0.123 &98.529\(\pm\)0.250 &98.268\(\pm\)0.168 &98.822\(\pm\)0.219 &98.504\(\pm\)0.315 &99.090\(\pm\)0.145& 98.609\(\pm\)0.349& 98.909\(\pm\)0.274 \\[-1ex]
\raisebox{1.5ex}{\bf User 5} \raisebox{1.5ex} & \bf Time
&22.744\(\pm\)0.054& 9.908\(\pm\)0.036& 7.089\(\pm\)0.045& 6.436\(\pm\)0.229& 3.945\(\pm\)0.025& 3.322\(\pm\)0.061& 2.907\(\pm\)0.036 &2.603\(\pm\)0.028\\[1ex]
\hline
& \bf Accuracy &97.607\(\pm\)0.124 &98.180\(\pm\)0.165 &97.926\(\pm\)0.125& 97.939\(\pm\)0.203& 98.426\(\pm\) 0.245& 98.327\(\pm\)0.266 &98.578\(\pm\)0.334 &98.372\(\pm\)0.332 \\[-1ex]
\raisebox{1.5ex}{\bf User 6} \raisebox{1.5ex} & \bf Time
&24.464\(\pm\)0.183 &10.699\(\pm\)0.355 &6.619\(\pm\)0.147 &4.911\(\pm\)0.152 &3.994\(\pm\)0.143 &3.138\(\pm\) 0.039 &2.729\(\pm\)0.036 &2.356\(\pm\)0.009 \\[1ex]
\hline
& \bf Accuracy &96.953\(\pm\)0.195 &97.718\(\pm\)0.241 &98.107\(\pm\)0.168 &98.617\(\pm\)0.175 &98.984\(\pm\)0.161 &98.193\(\pm\)0.235 &98.453\(\pm\)0.260 &98.354\(\pm\)0.489 \\[-1ex]
\raisebox{1.5ex}{\bf User 7} \raisebox{1.5ex} & \bf Time
&24.884\(\pm\)0.746 &9.903\(\pm\)0.089 &6.281\(\pm\)0.101& 4.646\(\pm\)0.123 &3.736\(\pm\)0.109 &3.107\(\pm\)0.028 &2.827\(\pm\)0.057 &2.459\(\pm\)0.037 \\[1ex]
\hline
& \bf Accuracy &97.672\(\pm\)0.158 &97.803\(\pm\)0.141 &97.418\(\pm\)0.254 &98.769\(\pm\)0.194& 98.259\(\pm\)0.231 &98.246\(\pm\)0.339& 98.516\(\pm\)0.391 &99.016\(\pm\)0.344 \\[-1ex]
\raisebox{1.5ex}{\bf User 8} \raisebox{1.5ex} & \bf Time
&23.326\(\pm\)0.052 &10.892\(\pm\)0.489 &6.509\(\pm\)0.201 &4.629\(\pm\)0.135 &3.591\(\pm\)0.028 &3.212\(\pm\)0.074 &2.660\(\pm\)0.018 &2.359\(\pm\)0.012 \\[1ex]
\hline
& \bf Accuracy &97.233\(\pm\)0.135 &97.598\(\pm\)0.230 &98.087\(\pm\)0.208 &98.243\(\pm\)0.346 &99.754\(\pm\)0.149 &98.046\(\pm\)0.254 &98.109\(\pm\)0.352 &98.837\(\pm\)0.438 \\[-1ex]
\raisebox{1.5ex}{\bf User 9} \raisebox{1.5ex} & \bf Time
&23.169\(\pm\)0.179 &9.925\(\pm\)0.064 &6.508\(\pm\)0.237 &4.614\(\pm\)0.052 &3.573\(\pm\)0.011 &3.130\(\pm\) 0.006 &2.828\(\pm\)0.029 &2.444\(\pm\)0.028 \\[1ex]
\hline
& \bf Accuracy &97.358\(\pm\)0.139 &97.701\(\pm\)0.201 &97.98\(\pm\)0.253 &98.145\(\pm\)0.345& 98.560\(\pm\)0.197 &98.139\(\pm\)0.390 &98.406\(\pm\)0.269 &98.766\(\pm\)0.344 \\[-1ex]
\raisebox{1.5ex}{\bf User 10} \raisebox{1.5ex} & \bf Time
&24.652\(\pm\)0.698 &10.447\(\pm\)0.333 &6.305\(\pm\)0.034 &4.542\(\pm\)0.037 &3.709\(\pm\)0.012& 3.055\(\pm\)0.012 &2.808\(\pm\)0.113 &2.485\(\pm\)0.058 \\[1ex]
\hline
& \bf Accuracy &97.331\(\pm\)0.106&97.785\(\pm\)0.268 &97.371\(\pm\)0.241 &97.743\(\pm\)0.208& 98.471\(\pm\)0.149& 98.527\(\pm\)0.253 &98.578\(\pm\)0.443 &98.497\(\pm\)0.240 \\[-1ex]
\raisebox{1.5ex}{\bf User 11} \raisebox{1.5ex} & \bf Time
&23.785\(\pm\)0.125& 11.418\(\pm\)0.287 &6.889\(\pm\)0.169 &4.900\(\pm\)0.114 &3.810\(\pm\)0.029& 3.257\(\pm\)0.031 &2.892\(\pm\)0.115& 2.464\(\pm\)0.013 \\[1ex]
\hline
& \bf Accuracy &98.193\(\pm\)0.135 &98.088\(\pm\)0.159 &98.054\(\pm\)0.185 &98.519\(\pm\)0.252& 98.929\(\pm\)0.157 &97.912\(\pm\)0.361 &98.688\(\pm\)0.426 &98.784\(\pm\)0.303 \\[-1ex]
\raisebox{1.5ex}{\bf User 12} \raisebox{1.5ex} & \bf Time
& 25.832\(\pm\)0.332 &10.129\(\pm\)0.127& 6.239\(\pm\)0.135 &4.424\(\pm\)0.022 &3.568\(\pm\)0.026& 2.998\(\pm\)0.005 &2.886\(\pm\)0.037 &2.481\(\pm\)0.019 \\[1ex]
\hline
& \bf Accuracy &98.071\(\pm\)0.165 &97.442\(\pm\)0.171 &98.033\(\pm\)0.177 &98.234\(\pm\)0.206& 98.583\(\pm\)0.201 &98.434\(\pm\)0.332 &98.625\(\pm\)0.312 &98.873\(\pm\)0.335 \\[-1ex]
\raisebox{1.5ex}{\bf User 13} \raisebox{1.5ex} & \bf Time
& 22.773\(\pm\)0.214 &11.175\(\pm\)0.043 &7.054\(\pm\)0.310 &4.891\(\pm\)0.093 &3.913\(\pm\)0.055 &3.448\(\pm\)0.098& 2.972\(\pm\)0.065& 2.473\(\pm\)0.017 \\[1ex]
\hline
& \bf Accuracy &97.331\(\pm\)0.167 &97.963\(\pm\)0.183 &98.328\(\pm\)0.199 &97.806\(\pm\)0.262& 98.471\(\pm\)0.284 &98.005\(\pm\)0.229 &98.563\(\pm\)0.257 &97.567\(\pm\)0.536 \\[-1ex]
\raisebox{1.5ex}{\bf User 14} \raisebox{1.5ex} & \bf Time
&23.38\(\pm\)0.444 &11.361\(\pm\)0.167& 6.584\(\pm\)0.252 &4.812\(\pm\)0.095& 3.818\(\pm\)0.018& 3.296\(\pm\)0.067 &2.809 \(\pm\)0.016 &2.513\(\pm\)0.034 \\[1ex]
\hline
& \bf Accuracy &97.607\(\pm\)0.102 &98.837\(\pm\)0.122& 98.662\(\pm\)0.239& 98.805\(\pm\)0.221& 98.672\(\pm\)0.256& 98.554\(\pm\)0.284 &98.953\(\pm\)0.277 &98.426\(\pm\)0.442 \\[-1ex]
\raisebox{1.5ex}{\bf User 15} \raisebox{1.5ex} & \bf Time
&23.563\(\pm\)0.259& 9.801\(\pm\)0.029 &8.238\(\pm\)0.128 &4.999\(\pm\)0.111 &3.543\(\pm\)0.026& 3.234\(\pm\)0.032 &2.888\(\pm\)0.045 &2.517\(\pm\)0.020 \\[1ex]
\hline
& \bf Accuracy & 97.603\(\pm\)0.192 &98.476\(\pm\)0.157 &97.766\(\pm\)0.209 &98.689\(\pm\)0.147& 98.281\(\pm\) 0.318 &98.876\(\pm\)0.245 &98.484\(\pm\)0.278 &98.623\(\pm\)0.384 \\[-1ex]
\raisebox{1.5ex}{\bf User 16} \raisebox{1.5ex} & \bf Time
&24.384\(\pm\)0.752& 10.9\(\pm\) 0.037 &6.077\(\pm\)0.033 &4.649\(\pm\)0.068 &3.679\(\pm\)0.064& 3.122\(\pm\)0.016 &2.815\(\pm\)0.056 &2.385\(\pm\)0.008 \\[1ex]
\hline
\end{tabular}}
\label{Tab2}
\end{table*}
As shown in Figures~\ref{Fig7} and~\ref{Fig8}, the computational cost gradually increases as the size of the windows decrease. Therefore, dealing with such high computational time becomes an important issue. There are certain possibilities which can be used to overcome this problem. One way is to use a lightweight feature selection method such as PCA, although the problem with the PCA is its incompetency for statistical results. There is another immediate solution for such problems, and it is to further divide each window into other sub-windows. However, this presents another challenge, how to conduct the windowing process, so that it does not decrease the performance of the legitimate user identification process.
We conducted our last experiment on a publicly available LACC sensor-based dataset, hereby this experiment, we investigated the one-subject-leave-out-cross-validation within the different size of windows. Table~\ref{Tab2} lists the results of user identification and computational time to identify individual users where features are selected through the ESP method and the selected features are classified through the KELM method. The obtained results corroborate the effectiveness of our proposed methodology for real-time applications. From these results, we observe that the feature selection and classification methods significantly increases the accuracy for legitimate user identification within each sub-activity for both sensors; additionally, outperforming on publicly available smartphone-based physical activity recognition datasets.
Figures~\ref{Fig3} and~\ref{Fig4} presents the 99\% confidence intervals, pertaining to the average legitimate user identification by using the pairwise T-test between groups with and without feature selection data at the 99\% confidence level. Looking at Figure~\ref{Fig4}, significant statistical results are clearly seen, showing that the KELM method performs much better when selected features of data are used in all cases: an 80\% and 88\% to 99\% performance increase. This leads us to prefer the use of the feature selection method in future applications.
The KELM method provides acceptable performance and has numbers of other attractive features to its applicability. In term of the applicability within a smartphone system, the KELM has smaller confidence intervals, implying it has more reliability in training models. Since the structure of the network in the KELM is fixed, it has a better training and lower variance. This implies that systems using a connected network should keep a fixed connective structure, in order to increase its reliability. Holding a constant connective structure is a good feature for the network due to hardware constraints. Any potential manufacturer to capture this method into a chip, as a trainable network, needs such a constant size structure. These chips could take away from the phone's main CPU, thus increasing the speed of the legitimate user identification process. This would allow for greater device security, by not allowing for software-based attacks on this method, only hardware based manipulations. These hardware operations would require access to the smartphone, hence making such attacks subject to the device's defense.
\section{Conclusion and Future Work}
This study substantiates the idea to be able to detect a legitimate smartphone user-based on their walking patterns through various sub-activities in a semi-controlled environment. Having used a commonly available mass-market consumer hardware, such as our experimental platform, we have demonstrated the global applicability of our proposed method with minimal accuracy variations. The KELM requires minimal battery consumption, and in order for us to run it as a practical application, we need to limit the number of required samples; and based on our results we observed that the KELM together with the ESP is the best methods in terms of accuracy and computational cost to a certain extent. However, the KELM is found to be the best examination method, in order to reduce battery consumption when performing checks to the sensor array.
A key advantage of our proposed system is that the data for each user is collected on different days with different orientations and locations, different jeans styles which significantly helps to understand the characteristic behavior of individual user, and significantly improves the training and testing accuracy within a short time intervals, which is an important feature for any real-time legitimate user identification system.
There are many ways to extend our current work. This work demonstrated that accelerometer data is more useful than linear accelerometer data, but it is possible that a fusion of accelerometer and linear accelerometer data will yield improved results. We have also been experimenting with more realistic features, which capture specific elements of a user's gait, and plan to investigate if these features can yield additional improvements.
Another one of our goals for future work is to expand the evaluation of the proposed system so that it is applied to more real-life situations. Thus, we plan to expand our user base significantly, increase the diversity of the users (especially with respect to gender and age), and evaluate how the system operates when the training and test samples are collected over lower window size, which is an important future direction for our current work, in which we will split the size of the smallest windows (25 or 50 samples per window) in to even smaller windows within the classification process, but for this, there is another challenge: how to maintain performance, within each sub-window, and how to control the computational complexity during real-time deployment. One final goal is to incorporate this technology into a real-time system.
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2018-12-03T02:23:13', 'yymm': '1706', 'arxiv_id': '1706.01739', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01739'} | arxiv |
\section{Introduction}
Coreference Resolution is the task of identifying groups of
phrases in a text that refer to the same discourse entity.
Such referring phrases are called mentions, a set of
mentions that all refer to the same discourse entity
is called a \revb{coreference }chain.
Annotated corpora are important resources
for developing and evaluating automatic coreference resolution methods.
Turkish is an agglutinative language and
Turkish coreference resolution poses several challenges
different from many other languages,
in particular the absence of grammatical gender,
the possibility of null pronouns in subject and object position,
possessive pronouns that can be expressed as suffixes,
and ambiguities among possessive and number morphemes,
e.g., \quo{çocukları} can be analysed as
\quo{their children} or as \quo{his/her children},
depending on context \cite{Oflazer1994}.
No coreference resolution corpus exists for Turkish so far.
We here describe the result of an effort
to create such a corpus based on the
METU-Sabanci Turkish Treebank
(Say, Zeyrek, Oflazer, and \"{O}zge, 2004;
Atalay, Oflazer, and Say, 2003;
Oflazer, Say, Hakkani-T{\"{u}}r, and T{\"{u}}r, 2003)
which is, to the best of our knowledge,
the only publicly available Turkish Treebank.
Our contributions are as follows.
\bi
\item
We describe two stages of annotation:
in \phaseone, annotators created mentions and \revb{coreference }chains,
which did not yield sufficient inter-annotator agreement.
In \phasetwo, mentions were given to annotators who created only \revb{coreference }chains.
We collected on average more than ten independent annotations per document
for each document in the METU-Sabanci Turkish Treebank.
\item
We describe annotator profiles and adjudication,
which was done semi-automatically in \phaseone\ and
fully automatically in \phasetwo.
We describe the principles of our automatic adjudication tool
which uses a voting-like approach.
Such an automatic approach is possible because we collected
enough %
annotations per document.
\item
We describe the XML format used to address documents,
sentences, and tokens in the METU-Sabanci Turkish Treebank.
We provide a public version of the corpus as XML,
including tools to convert the corpus to CoNLL format.
(For licensing reasons we cannot re-publish the Turkish Treebank data.)
\item
We describe and provide a baseline method
for mention detection
and coreference resolution, compatible with the format
of the corpus.
We evaluate this baseline method on the corpus with
leave-one-out cross-validation.
\ei
Section~\ref{secPrelimsRelated} gives preliminaries of
coreference resolution and the Turkish language
and describes related work.
Section~\ref{secCorpus}
explains the annotation and adjudication process
and discusses properties of the corpus,
annotator profiles,
and supporting tools.
Section~\ref{secBaseline} describes the baseline system
and its evaluation on the corpus.
Section~\ref{secConclusion} concludes and gives an outlook
on future work.
We provide the Marmara Turkish Coreference Corpus,
tools, and the baseline system, in the following public repository:
\mbox{{\tt\small{}https://bitbucket.org/knowlp/marmara-turkish-coreference-corpus}\,}.
\section{Preliminaries and Related Work}
\label{secPrelimsRelated}
Next, we give background information and related work on coreference resolution,
the Turkish language, and specific challenges
of coreference resolution in Turkish.
\subsection{Coreference Resolution}
Coreference resolution is the task of marking phrases
that refer to the same discourse entity as coreferent.
Mention detection, which identifies such phrases,
is usually included in that task.
Coreference resolution is not limited to resolving pronouns:
in \revb{computational }linguistics it was first introduced as a benchmark
for \emph{deep semantic understanding} of text in the
message understanding conference \revb{(MUC) }series \cite{Grishman1995muc6,Hirschman1998muc7coref}.
After MUC, the Automatic Content Extraction (ACE)
program
(Doddington, Mitchell, Przybocki, Ramshaw, Strassel, and Weischedel, 2004)
required English coreference resolution
as foundation for all tasks of years 2000--2004.
The SemEval competition series followed ACE
and featured the first multilingual coreference
resolution challenge in 2010~%
(Recasens, M{\`{a}}rquez, Sapena, Mart{\'{i}}, Taul{\'{e}}, Hoste, Poesio, and Versley, 2010).
The %
freely available, large, and multilingual
OntoNotes corpus
(Hovy, Marcus, Palmer, Ramshaw, and Weischedel, 2006)
was used in the multilingual coreference task in CoNLL-2012~%
(Pradhan, Moschitti, Xue, Uryupina, and Zhang, 2012)
and contains coreference annotations for English, Arabic, and Mandarin
(Pradhan, Ramshaw, Weischedel, MacBride, and Micciulla, 2007).
{\revbmark
The above mentioned corpora differ with respect to their coreference annotation principles.
MUC and ACE corpora include only noun phrases while OntoNotes also includes heads of verb phrases (and elided subjects/objects for Chinese and Arabic).
The ACE corpus includes only certain types of (military relevant) entities.
The ACE corpus includes singleton mentions while the MUC and OntoNotes corpora do not include singletons.
Predication is annotated only in the ACE corpus,
without discriminating it from identity coreference.
Appositions are annotated in all three corpora;
however, only in OntoNotes the annotation distinguishes
apposition from identity coreference.
The MUC corpus, moreover, includes for each mention a minimal sub-span that is relevant for scoring overlapping mentions.
For more details about these corpora and their differences,
we refer to Poesio, Pradhan, Recasens, Rodriguez, and Versley~\shortcite{Poesio2016annotatedcorpora}.}
Coreference resolution has been surveyed
by Ng~\shortcite{Ng2010coref15}.
Approaches are manifold
and \revb{based on unsupervised and supervised machine learning methods},
rule-based systems, and combinations.
\revb{An example for an unsupervised noun phrase coreference resolution approach
based on clustering is the work of Cardie and Wagstaff~\shortcite{Cardie1999corefcluster}.}
In most \revb{supervised }approaches,
equivalence relations of \revb{coreference }chains
are assembled from
predictions of the relatedness of pairs of mentions.
\revb{An early }machine learning approach \revb{of that kind}
is due to
Soon, Ng, and Lim~\shortcite{Soon2001},
methods for building \revb{coreference }chains from link predictions
include local greedy heuristics
as done by
Bengtson and Roth~\shortcite{Bengtson2008}
or Stoyanov and Eisner~\shortcite{Stoyanov2012},
global optimization formulations
such as relaxation labelling
(Sapena, Padro, and Turmo, 2012)
or ranking with ILP or Markov Logic~%
(Culotta, Wick, and McCallum, 2007;
Denis and Baldridge, 2009)
and representations of trees of links~%
(Fernandes, dos Santos, and Milidi{\'{u}}, 2012;
Chang, Samdani, and Roth, 2013).
The first rule-based algorithm for anaphora resolution
was done by Hobbs~\shortcite{Hobbs1978}.
More recent rule-based systems merge \revb{coreference }chains based on
several sets of rules in a multi-stage filtering approach~%
(Lee, Chang, Peirsman, Chambers, Surdeanu, and Jurafsky, 2013);
moreover, there are hybrid systems combining rules and machine learning such as the one by Chen and Ng~\shortcite{Chen2012conll}.
Other approaches use curated or distributed knowledge sources
such as WordNet, Google distance, and Wikipedia~%
(Poesio, Mehta, Maroudas, and Hitzeman, 2004;
Zheng, Vilnis, Singh, Choi, and McCallum, 2013).
\revb{%
Recently, several coreference resolution approaches
based on word embeddings were introduced.
Word embeddings
are vector representations of words
that are learned in an unsupervised way from an text corpus.
Embedding vectors are motivated by the idea that a word should be known
by the company it keeps.
These vectors are learned with the goal of making them
similar if the respective words occur in similar contexts
(for example if they co-occur with similar words in a neighbourhood of limited distance).
Embeddings vectors capture semantic properties of words
and have been shown to be useful for many NLP tasks.
Prominent word embedding approaches are
word2vec (Mikolov, Sutskever, Chen, Corrado, and Dean, 2013),
\nocite{Mikolov2013word2vec}%
GloVe (Pennington, Socher, and Manning, 2014),
\nocite{Pennington2014glove}%
and FastText (Bojanowski, Grave, Joulin, and Mikolov, 2017).
\nocite{Bojanowski2017fasttext}
Coreference resolution approaches based on word vectors
are often based on neural networks,
for example those
by Lee, He, Lewis, and Zettlemoyer~\shortcite{Lee2017neuralcoref}
and by Wu and Ma~\shortcite{Wu2017deepcoref},
but there are also approaches based on Support Vector Machines (SVM) \cite{Cortes1995svm}
such as the one by \cite{Simova2017embeddingscoref}.
Importantly, these methods
do not require preprocessing with a parser or named entity recognizer,
although Wu et al.~structure the neural network into components
that are reminiscent of parsing and named entity recognition modules.
}%
Note, that anaphora resolution \cite{Hirst1981,Mitkov2002}
is a problem orthogonal to coreference resolution
\cite{VanDeemter2000},
because anaphora resolution focuses on referring expressions
that point to previous expressions in the text.
Cataphora (i.e., pronouns pointing to later occurrences in the text)
are excluded.
On the other hand, different from most works on coreference,
anaphora resolution includes bound pronouns
that do not refer to concrete entities
because they are quantified using, e.g., \quo{some} or \quo{none}.
\subsubsection{Coreference Resolution System Evaluation Metrics}
\label{secCorefMetrics}
{\revamark%
We next recall several evaluation metrics that have been
defined for evaluating the output of a system
that predicts mentions and coreference chains
for a given input document.
\revb{Note, that these metrics are suitable for evaluating \emph{systems} only.
For the equally important task of
evaluating the \emph{reliability of human annotators},
inter-annotator agreement metrics exist
(see Section~\ref{secIAAMetrics}).}
Formally, a document $D$ is a sequence of tokens $D = t_1,\ldots,t_n$,
a mention is a span $(f,t)$ with $1 \les f \les t \les n$ over $D$,
and an entity (also called coreference chain)
is a set of mentions over $D$.
Given a set $K$ of \emph{key} entities
and a set $R$ of \emph{response} entities
over the same document $D$,
an evaluation metric defines a score between 0 and 1
over $K$ and $R$.
The coreference scoring metrics used in the reference
coreference scorer
(Pradhan, Luo, Recasens, Hovy, Ng, and Strube, 2014)
and used in our evaluation are
MUC by Vilain, Burger, Aberdeen, and Connolly~%
\shortcite{Vilain1995muc6coref},
B$^3$ by Bagga and Baldwin~\shortcite{Bagga1998},
CEAF$_m$ and CEAF$_e$ by Luo~\shortcite{Luo2005},
and BLANC by Recasens and Hovy~\shortcite{Recasens2010blanc}.
These metrics have in common
that partially overlapping mentions
and non-overlapping mentions are treated the same:
two mentions are either counted as equal
or as inequal.
For that reason, we describe the above mentioned metrics
in the following simplified manner:
we leave the document $D$ unspecified,
we consider a set $K$ of key entities
and a set $R$ of response entities,
and we let the set $M$ of mentions be defined implicitly
as $M = \bigcup K \cup \bigcup R$.
We follow
Pradhan et al.~\shortcite{Pradhan2014scorer}
and
Sapena, Padr\'{o}, and Turmo \shortcite{Sapena2008corefsurvey}
for the following description of metrics
and denote by $K_1,\ldots,K_{n_k}$ the entities in $K$,
and by $R_1,\ldots,R_{n_r}$ the entities in $R$.
{\revbmark
A \emph{link} is a pair $(m_1,m_2)$
of distinct mentions, $m_1, m_2 \ins M$.
If the mentions are in the same coreference chain,
the link is called a \emph{coreference} link,
otherwise it is called a \emph{non-coreference link}.}
MUC
(Vilain, Burger, Aberdeen, and Connolly, 1995)
is a \emph{link-based metric}
based on the \revb{minimum }number of links between mentions
that are required for defining an entity.
MUC Recall and Precision are defined as
\begin{align*}
R &= \frac{
\sum_{i=1}^{n_k} \left( |K_i| - |p(K_i)| \right)
}{
\sum_{i=1}^{n_k} \left( |K_i| - 1 \right)
}
&&\text{and}
&
P &= \frac{
\sum_{j=1}^{n_r} \left( |R_j| - |p'(R_j)| \right)
}{
\sum_{i=1}^{n_r} \left( |R_j| - 1 \right)
}
\end{align*}
where $p(K_i)$ is the set of partitions
created by intersecting $K_i$ with response entities,
and, \revb{conversely, }$p'(R_j)$ is the set of partitions
created by intersecting $R_j$ with key entities.
F1-score is defined as
the harmonic mean of Precision and Recall.
MUC gives the same score reduction for \revb{incorrectly }merging two big coreference chains
and for \revb{incorrectly placing one mention into the wrong coreference chain},
which is counterintuitive.
Because it is link-based,
MUC \revb{cannot handle singleton mentions}.
The B$^3$ metric aims to overcome these drawbacks
by giving a score based on \emph{mentions}.
The B$^3$ metric~\cite{Bagga1998}
defines Precision and Recall
for each key mention and accumulates a score over the whole document.
B$^3$ Recall and Precision are defined as
\begin{align*}
R &= \frac{
\sum_{i=1}^{n_k} \sum_{j=1}^{n_r}
\frac{|K_i \caps R_j|^2}{|K_i|}
}{
\sum_{i=1}^{n_k} |K_i|
}
&&\text{and}
&
P &= \frac{
\sum_{j=1}^{n_r} \sum_{i=1}^{n_k}
\frac{|K_i \caps R_j|^2}{|R_j|}
}{
\sum_{i=1}^{n_r} |R_j|
}.
\end{align*}
\revb{Because the B$^3$ metric intersects key and response entities,
one mention can contribute to the score multiple times,
leading to counterintuitive scores.
To overcome this limitation,
the CEAF metrics were proposed.}
The family of \revb{Constrainted Entity-Alignment F-Measures (CEAF)} by
Luo~\shortcite{Luo2005}
is centred around \emph{entities}:
given a similarity measure
$\Phi : M \times M \to \mathbb{R}$
that determines how \revb{well }two entities match,
CEAF first finds the best \emph{one-to-one} mapping
$g^\star : \{1,\ldots,n_k\} \to \{1,\ldots,n_r\}$
between key and response entity indexes,
i.e., the mapping such that
$\sum_{(i,j) \in g^\star} \Phi(K_i,R_j)$
becomes maximal among all possible mappings.
Because of this mapping,
\revb{each key and each response mention
contributes exactly once to the overall CEAF score,}
which \revb{produces more realistic scores than }MUC and B$^3$.
CEAF Recall and Precision are defined as
\begin{align*}
R &= \frac{
\sum_{(i,j) \in g^\star} \Phi_\alpha(K_i,R_j)
}{
\sum_{i \in \{1,\ldots,n_k\}} \Phi_\alpha(K_i,K_i)
}
&&
\text{and}
&
P &= \frac{
\sum_{(i,j) \in g^\star} \Phi_\alpha(K_i,R_j)
}{
\sum_{j \in \{1,\ldots,n_r\}} \Phi_\alpha(R_j,R_j)
}
\end{align*}
where $\alpha \in \{ m, e \}$
specifies one of two metrics:
CEAF$_m$ computes entity-entity similarity
according to the size of the intersection of entities,
formally $\Phi_m(K_i,R_j) = |K_i \caps R_j|$;
CEAF$_e$ normalizes this similarity
according to the size of both entities,
formally $\Phi_e(K_i,R_j) = \frac{2|K_i \caps R_j|}{|K_i|+|R_j|}$.
\revb{Both the B$^3$ and the CEAF metrics
evaluate an assignment of a mention to a coreference chain
independent from the size of the chain.
To overcome this limitation, the BLANC metric was proposed.}
\newcommand{\mylinks}[1]{\mi{\revbmark{}crlinks}(#1)}
The \revb{BiLateral Assessment of Noun-phrase Coreference (BLANC)} metric \cite{Recasens2010blanc}
gives equal importance to \revb{coreference }links
and \revb{non-coreference links}.
The motivation for creating BLANC was to correctly handle
singleton mentions and to handle \revb{coreference }chains with many mentions
and with few mentions more fairly than possible with B$^3$ and CEAF.
We here show the BLANC extension by
Luo, Pradhan, Recasens, and Hovy \shortcite{Luo2014blanc2}
which is able to process spurious as well as missing response mentions.
Given a set of entities $X$
we denote by $\mylinks{X}$
the set $\{ (m_1,m_2) \mids m_1, m_2 \in Y, Y \in X, m_1 \neq m_2 \}$
of all \revb{coreference }links \revb{that define }entities in $X$.
We denote by $C_k = \mylinks{K}$ and $C_r = \mylinks{R}$
the set of coreference links in key and response;
moreover, by $T_k = \mylinks{\{\bigcup K\}}$ and $T_r = \mylinks{\{\bigcup R\}}$
the set of all possible key and response links;
and finally, by $N_k = T_k \setminus C_k$ and $N_r = T_r \setminus C_r$
the sets of non-coreference links in key and response, respectively.
Recall, Precision, and F-score of coreference links
are defined as
\begin{align*}
R_c &= \frac{|C_k \caps C_r|}%
{|C_k|}\text{ , }
%
%
%
&
P_c &= \frac{|C_k \caps C_r|}%
{|C_r|}\text{ , and}
%
%
%
&
F_c &= \frac{2 R_c P_c}{R_c + P_c}\text{ ,}
\intertext{
and the same metrics are also defined
for non-coreference links:
}
R_n &= \frac{|N_k \caps N_r|}%
{|N_k|}\text{ , }
%
%
%
&
P_n &= \frac{|N_k \caps N_r|}%
{|N_r|}\text{ , and}
%
%
%
&
F_n &= \frac{2 R_n P_n}{R_n + P_n}\text{ .}
\end{align*}
Finally,
BLANC is the arithmetic mean of F-measure of
coreference and non-coreference \revb{links},
that is $\mi{BLANC} = \frac{F_c+F_n}{2}$.}
{\revbmark
Moosavi and Strube \shortcite{Moosavi2016leametric}
propose the Link-based Entity-Aware (LEA) metric which overcomes
the \emph{mention identification effect}
of the B$^3$, CEAF, and BLANC metrics:
adding incorrect entities to the system output decreases Recall
of these metrics which makes them no longer reliable.
The LEA metric scores each coreference chain according to
its importance (in terms of its size)
and according to how well it is resolved
(in terms of coreference links reproduced in the response).
Given a coreference chain $C \subseteqs M$,
the number of links in $C$ is
$\mi{link}(C) \eqs \frac{|C|(|C|\,{-}\,1)}{2}$
and LEA Recall and Precision are defined as
\begin{align*}
\mi{R_{\mi{LEA}}} &= \frac{
\Sigma_{i \eqs 1}^{n_k} \left( |K_i| \cdot
\Sigma_{j \eqs 1}^{n_r} \frac{\mi{link}(K_i \cups R_j)}{\mi{link}(K_i)}
\right)
}{
\Sigma_{z \eqs 1}^{n_k} |K_z|
}\text{ and} \\
\mi{P_{\mi{LEA}}} &= \frac{
\Sigma_{i \eqs 1}^{n_r} \left( |R_i| \cdot
\Sigma_{j \eqs 1}^{n_k} \frac{\mi{link}(R_i \cups K_j)}{\mi{link}(R_i)}
\right)
}{
\Sigma_{z \eqs 1}^{n_r} |R_z|
}\text{ .}
\end{align*}
LEA F1-score is computed as the harmonic mean of LEA Precision and Recall.
}
\subsubsection{Coreference Inter-Annotator Agreement Metrics}
\label{secIAAMetrics}
{\revamark%
Inter-annotator agreement metrics are a tool
for quantifying the reliability of human annotators
who independently annotated the same document.
Different from system evaluation metrics,
inter-annotator agreement is computed without a gold standard
and for (potentially) more than two annotations at once.
\revb{For a detailed survey and justification of inter-annotator metrics,
in particular their difference to system evaluation metrics (see Section~\ref{secCorefMetrics}),
we refer to Artstein and Poesio~\shortcite{Artstein2008agreementmetrics}.}
Krippendorff~\shortcite{Krippendorff1980}
defined metric $\alpha$ for quantifying the reliability of
$r$ classification decisions of $m$ annotators:
\begin{align*}
\alpha &= 1 - \frac{rm-1}{m} \frac{
\sum_i \sum_b \sum_{c > b} n_{b_i} n_{c_i} \delta_{bc}
}{
\sum_b \sum_c n_b n_c \delta_{bc}
}
\end{align*}
where $i$ ranges over objects to be classified,
$b$ and $c$ range over classes,
\revb{$n_x$ is the number of %
objects that were put into class $x$ by annotators,}
$n_{x_i}$ is the number of times object $i$ was put into class $x$ by annotators,
and $\delta_{bc}$ is a distance function between classes $b$ and $c$.
An annotation process is considered reliable
if $\alpha > 0.67$.
When applying this metric to coreference annotation,
we consider mentions as objects,
and entities that were produced by annotators as classes.
It is useful to create a fine-grained distance function $\delta$
between entities,
for example putting mention $A$ into entity $E_1 = \{A,B,C,D\}$,
putting it into entity $E_2 = \{A,C,D\}$, and putting it into entity $E_3 = \{A,E\}$
intuitively is a mistake of varying severity.
In this work, we use the following coreference-specific variations of $\alpha$.
We denote by $\mi{IAA}_1$
the metric defined by Passonneau~\shortcite{Passonneau2004}
where $\delta_{bc} = 1 - M_{bc}$
where the match score $M_{bc}$ obtains a value of 1 for equality,
$\frac{2}{3}$ if $b$ is a subset of $c$ or $c$ is a subset of $b$,
$\frac{1}{3}$ if $b$ and $c$ are intersecting in more than a single mention,
and 0 otherwise.
We denote by $\mi{IAA}_2$
the metric defined by Passonneau, Habash, and Rambow~%
\shortcite{Passonneau2006masi}
where $\delta_{bc} = 1 - J_{bc} M_{bc}$,
and $J_{bc}$ is the Jaccard distance between sets $b$ and $c$.
Metric $\mi{IAA}_2$ has the advantage
that it normalizes over heterogeneous sizes of entities.}
\subsection{Turkish}
Turkish is a member of the family of Altaic languages,
it is an agglutinative language where suffixes
are attached to a root word.
Derivational and inflectional suffixes are very productive
(Oflazer, 1993;
Oflazer, G{\"{o}}{\c{c}}men, and Bozşahin, 1994)
\nocite{Oflazer1993turkishmorphologyposter}\nocite{Oflazer1994}%
and are subject to vowel harmony from the root word.
Morphological analysis is challenging
due to ambiguities between different types of suffixes,
for example \quo{izin} can mean
\quo{your trace} (iz+P2Sg+Nom),
\quo{trace} (iz+Pnon+Gen),
or \quo{permission} (izin+Pnon+Nom)
(Hakkani-T{\"{u}}r, Oflazer, and T{\"{u}}r, 2002).
\subsubsection{The Turkish Treebank}
The METU-Sabanci Turkish Treebank
(\revb{hereafter referred to as the }Turkish Treebank)
\cite{Atalay2003,Oflazer2003turkishtreebank}
contains a subset of the METU Turkish Corpus
\cite{Say2004}
in tokenized form.
Each token is analysed morphologically
and split into inflectional groups (IGs).
Sentences are annotated with dependency parse information,
where dependencies point to specific IGs within tokens.
The Turkish Treebank splits tokens
into IGs on derivational boundaries,
for example, \quo{evimdekiler}
(those in my house)
is analysed \cite{Oflazer2003turkishtreebank} as
\smallskip
\centerline{ev+Noun+A3sg+P1sg+Loc\textasciicircum{}DB+Adj\textasciicircum{}DB+Noun+Zero+A3pl+Pnon+Nom}
\smallskip
\noindent
where \textasciicircum{}DB indicates derivation boundaries and the token consists of three IGs
\quo{evimde} (in my house), \quo{ki} (adjectivization),
and \quo{ler} (nominalization+plural).
A CoNLL format that provides a CoNLL token
corresponding to each IG of a token has been created
for Turkish dependency parsing~\cite{Buchholz2006}.
Named entities in the Turkish Treebank are not marked specially,
but multiword named entities are represented as single tokens.
\subsubsection{Turkish Coreference Resolution}
\label{secTurkishCoref}
The following properties of Turkish \revb{and the Turkish Treebank}\
are particularly relevant for coreference resolution.
\emph{\revbmark{Accessibility of morphemes as markables.}}
In the above example,
\quo{those in my house} as well as \quo{my house} as well as
\quo{my} could be coreferent with mentions in the document.
However, neither \quo{my house} nor \quo{my} is available
as a separate unit of analysis: both are parts of the first IG (\quo{evimde}).
\emph{\revbmark{}Gender.}
Gender is not marked in Turkish
with the exception of the honorifics \quo{Bey} and \quo{Hanım}
which corresponds to English \quo{Mr} and \quo{Mrs}.
Moreover, several common first names
apply to both genders.
Hence, gender-based syntactic compatibility checks
for mentions are only possible in some cases.
\emph{\revbmark{}Personal pronoun subjects.}
In Turkish, these subjects are usually
realized as suffixes of the verb,
e.g., \quo{gidiyoruz} (we are going)
and \quo{gidiyorlar} (they are going)
but they can also be realized explicitly
as in \quo{biz gidiyoruz},
depending on discourse conditions \cite{Turan1996}.
\emph{\revbmark{}Proper noun suffixes.}
Suffixes of proper nouns in written Turkish
are systematically separated from the proper nouns
using a single quote,
e.g., \quo{Türkiye'den} (from Turkey)
and \quo{Türkiye'deki} (the thing in Turkey).
This rule simplifies the finding of
equal proper noun mentions in
coreference resolution for Turkish.
Most works about referring expressions in Turkish
focus on anaphora resolution and not on full coreference resolution.
One exception is the work of
Küçük and Yazıcı~\shortcite{Kucuk2008videocoref}
on political news texts extracted from videos:
they focus on Gazetteers for extracting mentions
(without considering general NPs or syntactic information),
provide a rule-based heuristic
based on recency for creating coreference chains,
and evaluate their approach on three documents
(which are not part of the Turkish Treebank).
\subsubsection{Turkish Anaphora Resolution}
\revb{%
Next, we describe work on Turkish anaphora resolution
which is related to coreference resolution.}
Erkan and Akman~\shortcite{Erkan1998}
describe an implementation of \revb{pronominal }anaphora resolution
in a framework for situation theory
which is based on knowledge representation
and logical reasoning.
Hobb's na\"{\i}ve pronoun resolution algorithm~%
\cite{Hobbs1978}
was realized for Turkish and tested
on 10 toy sentences~%
\cite{Tufekci2007}.
Centering theory~%
(Grosz, Joshi, and Weinstein, 1995)
is the foundation
of several works on Turkish pronouns.
Turan~\shortcite{Turan1996} performed
a study about discourse conditions for referring vs.~nonreferring expressions and null vs.~overt pronouns,
and evaluated the theory on 2500 annotated tokens.
Yüksel and Bozşahin~\shortcite{Yuksel2002}
created a system for generating referring expressions that was tested on a machine translation task.
Furthermore,
there is a theoretical model of anaphora resolution
based on Centering Theory
by Yıldırım, Kılı{\c{c}}aslan, and Ayka{\c{c}}~\shortcite{Yildirim2004}.
Küçük and Yöndem~\shortcite{Kucuk2007}
described a system for finding and resolving Turkish
pronominal anaphora and annotated
12266 anaphora candidate instances
in the METU Turkish Corpus to evaluate their candidate extractor and decision tree learner for anaphora resolution.
Kılıçaslan, G{\"{u}}ner, and Yıldırım~%
\shortcite{Kilicaslan2009} performed
a comprehensive study on pronoun resolution
and evaluated various machine learning methods
for resolving overt and null pronouns
in a corpus of 20 \revb{stories for }children.
\section{Marmara Turkish Coreference Corpus}
\label{secCorpus}
We next describe the annotation and adjudication process
including formal adjudication criteria,
key properties of the resulting corpus,
and supporting tools.
\subsection{Annotation Process}
\label{secProcess}
Annotations were collected from computer engineering
students participating in a lecture on natural language processing,
after educating them in basic linguistic analysis and coreference resolution.
To achieve reasonable annotation quality,
we aimed to keep the annotation principles simple and
therefore based them on few rules and examples.
We designed an annotation manual~\cite{Surmeli2015annotationmanualv1}
{\revamark%
and a revised version of this manual
(S{\"{u}}rmeli, Cıngıllı, Tun{\c{c}}er, and Sch{\"{u}}ller, 2016)}
for marking coreference according to the following principles:
\begin{itemize}
\item
all {\revamark specific} entities that are mentioned more than once
\revb{by a noun phrase, pronoun, or nominalized adjective, }shall be annotated,
\item
mentions shall be marked as the biggest possible
span of tokens that describes the entity,
\item
lists shall not be annotated (elements of lists can be annotated), and
\item
predications shall not be annotated.
\end{itemize}
By marking mentions as the biggest \revb{possible }spans,
\revb{a phrase and potentially existing appositive phrases become part of the same mention}.
\revb{This }is different from OntoNotes
where \revb{phrases and }appositives are \revb{separate mentions
which are put into }a special type of \revb{appositive }coreference \revb{chain}.
We do not mark predications because they are a different
type of coreference as argued by van Deemter and Kibble~\shortcite{VanDeemter2000}.
{\revamark%
Figure~\ref{figExampleOmurUzatma} shows an example of Turkish mentions
and coreference chains.}
\myfigureExampleOmurUzatma
{\revamark%
Specific entities introduce or refer to a specific discourse entity
while non-specific entities are variables over sets of potential discourse entities.
Non-specific entities are usually indicated by quantifier words
such as ``everybody'' or ``some''.
Figure~\ref{figExampleEv} shows an example from the annotation manual
\cite{Surmeli2016annotationmanualv2}
where ``Boş, kiralık apartman dairesi''
(an empty apartment flat that is for rent)
and ``o'' (it) has an anaphoric relationship
but we cannot pinpoint a specific empty flat;
therefore, no coreference shall be annotated.}
Figure~\ref{figProcess} visualizes the process that led to the final corpus.
Annotations were collected in two phases:
\phaseone\ took place in October--December 2015 and \phasetwo\ during October--December 2016.
{\revamark%
\phaseone\ used the initial version of the annotation manual \cite{Surmeli2015annotationmanualv1} and \phasetwo\ the revised version \cite{Surmeli2016annotationmanualv2}.
The final corpus resulting from this project contains
coreference annotations only from \phasetwo.}
\myfigureExampleEv
\myfigureprocess
In \phaseone, annotations were created by 19 annotators
with the
\revb{\quo{Co-reference Editor} that is part of the \quo{Language Resources} functionality
of }GATE\revb{ Developer}~%
(Gaizauskas, Cunningham, Wilks, Rodgers, and Humphreys, 1996;
Cunningham, Tablan, Roberts, and Bontcheva, 2013).
\revb{%
We preferred GATE because it provided
an XML interface (which was compatible with the Turkish Treebank format),
a well-structured website and documentation,
and a comfortable installation procedure that works on multiple platforms.}
\revb{\phaseone\ }yielded on average 6.5 annotations per document
for 21 documents in the Treebank.
Adjudication of these documents was done semi-automatically
(see Sections~\ref{secAdjudication} and~\ref{secTools}).
However, due to low inter-annotator agreement
about mention boundaries,
decisions often depended on the adjudicator.
\revb{Each unique annotated mention in \phaseone\ was annotated by only~1.9 annotators on average,
where perfect agreement would be 6.5, i.e., the number of annotators per document.}
Moreover, we identified several issues in the annotation manual.
{\revamark%
Therefore,
we created a revised version \cite{Surmeli2016annotationmanualv2}
of the annotation manual which included additional examples\revb{,
in particular about the difference between specific and non-specific mentions,
and about the difference between coreference and predication}.}
Moreover, in order to make the setting simpler,
we decided to perform a second annotation phase
where we collect annotations with \emph{given} mentions.
We used the list of mentions resulting from the adjudicated documents of \phaseone.
Mentions for those 12 documents that were not annotated in \phaseone\
were manually created in a collaboration of two annotators for each document.
{\revamark%
Mentions were annotated whenever there was doubt about them.
Therefore, they are available for coreference annotation
but can be omitted if no coreferent mention exists.
This coincides with the strategy used in mention prediction systems
which usually aim for high Recall and leave the elimination of spurious mentions
to the coreference resolution prediction system.}
In \phasetwo, 46 annotators were given CoNLL files
with token and coreference columns
where each mention was given in its own \revb{coreference }chain.
Annotators created \revb{339 individual annotation files }%
with equalities between \revb{coreference }chain IDs
and uploaded these files to a web service
where they were checked for syntactical correctness.
The submission file format is described by
S{\"{u}}rmeli et al. \shortcite{Surmeli2016annotationmanualv2}.
This method of collecting annotation as text files
might seem archaic; however, in practice,
annotators were more comfortable with such a system
than with the graphical user interface of GATE in \phaseone.
We were not able to use the BRAT~%
(Stenetorp, Pyysalo, Topic, Ohta, Ananiadou, and Tsujii, 2012)
annotation tool
because of difficulties
representing sentence and word addresses
in a way that they can be extracted from annotations.
\revb{The problem of disagreement on mention boundaries was successfully prevented in \phasetwo:
each unique mention was annotated as part of a coreference chain by 9.6 annotators on average,
where perfect agreement would be 10.3.
Therefore, }\phasetwo\ yielded
of sufficient inter-annotator agreement
to perform fully automatic adjudication (see next section).
\paragraph{Annotator Profiles.}
Anonymized learner profiles were collected from all students
in \phasetwo\ (written permission for using and publishing the data was also obtained).
Annotators are on average 23 years old university students
at Marmara University in Istanbul.
Out of 46 annotators, 29 are male and 17 are female.
One annotator indicated Azerbaijani as a native language,
all others indicated Turkish as one of their native languages.
(Azerbaijani is close to Turkish.)
Two annotators indicated Kurdish as further native language,
and one each Arabic, English, and Macedonian.
Primary and secondary school education was Turkish for 43 annotators, English for two and Azerbaijani for one.
Moreover, 43 annotators lived at least 20 years in predominantly Turkish-speaking communities,
the remaining annotators answered 4, 5, and 14 years, respectively, to this question.
According to this data we consider our annotators to be
capable of understanding and annotating the texts in the corpus
\revb{on the level of or close to the level of a native speaker}.
\subsection{\revb{Analysis of Annotations}}
\label{secAnnotationproperties}
\myannotationtable
Table~\ref{tblAnnotationMetrics} shows properties
\revb{of the annotations that were collected.}
Over all documents,
\revb{the inter-annotator agreement metric}
$\mi{IAA}_1$ is 76\% and $\mi{IAA}_2$ is 90\%,
which indicates reliability of our annotation process
{\revamark (see Section~\ref{secIAAMetrics})}.
We observe worse IAA for genres that are focused on writing as an art form,
i.e., for genres Short Story and Other (a first-person narrative).
\revb{These genres contain a high percentage of dialogues
with frequent changes between speaker and addressee,
which led to a higher number of annotator mistakes regarding personal pronouns.}
By comparing column $\mi{GM}$ and $\mi{AM}$ (\revb{given and }annotated mentions\revb{, respectively})
we see that annotators rarely use all mentions in the annotated \revb{coreference }chains.
Annotators were instructed to omit mentions from annotation
if there was no other specific mention referring to exactly the same discourse entity.
To reduce the chance that these mentions were omitted due to an oversight,
the annotation submission system indicated which mentions were left unused.
{\revamark%
Very few annotators asked for additional mentions
(and only in a single case, a mention was actually missing).
In summary, the difference between $\mi{GM}$ and $\mi{AM}$ indicates \revb{that}
our coreference annotators consciously omitted certain mentions from annotation.
This coincides with the strategy of annotating mentions with high Recall,
and relying on coreference annotators for obtaining high Precision of mentions.}
Column $\mi{Ph1}$ indicates how many of the documents
were annotated in both phases of the annotation process.
For example, the News genre contains 9 documents.
Mentions of 2 News documents were obtained from \phaseone,
the others from \phasetwo\ (see also Figure~\ref{figProcess}).
\subsection{\revb{Semi-automatic} Adjudication}
\label{secAdjudication}
We collected an average of 10.3 annotations per document
\revb{(see Table~\ref{tblAnnotationMetrics})}.
This high number of annotations,
combined with the observed IAA,
allows us to automatically adjudicate the corpus.
This is different from other coreference annotations,
in particular from OntoNotes where two annotators
created annotations followed by adjudication
done by a single human expert~%
(Weischedel, Pradhan, Ramshaw, Kaufman, Franchini, El-Bachouti, Xue, Palmer, Hwang,
Bonial, Choi, Mansouri, Foster, Hawwary, Marcus, Taylor, Greenberg, Hovy, Belvin,
and Houston, 2012).
Our automatic adjudication method is based on combinatorial optimization:
we search for a solution of \revb{coreference }chains that has overall minimal
divergence from all annotator inputs.
Divergence is measured in terms of links
given and omitted by annotators.
Formally, given a set $M$ of mentions in a document,
{\revamark%
annotators produce $k$ sets of entities
$A_1$, \ldots, $A_k$ over $M$,
that is each $A_i$, $1 < i < k$, contains a partition (disjoint subsets) of $M$.
A solution $G$ also contains a partition of $M$,}
and we search for $G$ such that the following objective becomes minimal:
\begin{equation}
\label{eqObj}
\sum_{\substack{
m, m' \ins M \\
%
i \ins \{1, \ldots, k\}}}
\big(
2 \cdot a\left(m,m',A_i\right)\cdot na\left(m,m',G\right)
+ na\left(m,m',A_i\right)\cdot a\left(m,m',G\right)
\big)
\end{equation}
where $a(m,m',A)$ indicates \revb{whether }%
$m$ and $m'$ are coreferent in $A$,
formally
\begin{equation*}
a(m,m',A) = \left\{\begin{array}{ll}
1 & \text{if $\exists C \in A: \{m,m'\} \subseteq C$} \\
0 & \text{otherwise.}
\end{array}\right.
\end{equation*}
{\revamark%
Similarly, $na(m,m',A)$ indicates \revb{whether }%
$m$ and $m'$ are not coreferent in $A$:
formally, $na(m,m',A) = 1 - a(m,m',A)$.
The left term of the sum in \eqref{eqObj} incurs a cost of $2 j$
for each \revb{link $(m,m')$ }%
that \revb{is non-coreferent }in the solution~$G$
contrary to the opinion of~$j$ annotators who annotated it as coreferent.
The right term of the sum incurs a cost of $l$
for each \revb{link $(m,m')$ }%
that \revb{is coreferent }in the solution~$G$
contrary to the opinion of~$l$ annotators who \revb{annotated it as non-coreferent}.
\revb{%
We additionally enforce the following hard constraints:
(i) mentions that overlap cannot be coreferent in the solution, and
(ii) the solution can only contain coreference links
that have been annotated by at least one annotator.
Constraint (i) is specific to our corpus
where we ask annotators to annotate the largest span of a mention,
constraint (ii) prevents the invention of coreference links
due to the merging of coreference chains
and is motivated by observations we made while inspecting annotations.}
Intuitively, the optimization criterion
is based on \revb{coreference and noncoreference }links,
similar to the BLANC evaluation metric \cite{Recasens2010blanc}.
Optimal solutions ignore as little as possible
information from annotators, where putting the mentions into the same entity
as well as not putting them into the same entity is used as information.
\revb{A link that is indicated as coreferent by an annotator but is adjudicated as non-coreferent }in the solution $G$ incurs twice the cost of \revb{a link that was annotated as non-coreferent and is coreferent in }$G$.}
\revb{We introduced this preference into the objective
because we made the following observation:
if fewer than half of the annotators put a mention into the same coreference chain
and the remaining annotators did not annotate the mention as coreferent with any other mention
then the annotation of the minority was correct according to our judgement:
the mention should have been annotated as part of the coreference chain.
From that observation, we concluded
that assigning a mention is more likely to be done intentionally
than omitting a mention from a coreference chain,
and this is reflected in the higher weight
of coreference links compared with non-coreference links in the objective function.}
{\revamark%
As an example, if we obtain entities $\{\{A,B\},$ $\{C,D\}\}$ from \revb{4 }annotators,
\revb{$\{\{A,B\}\}$} from \revb{3 }annotators, and $\{\{C,D,E\}\}$ from \revb{2 }annotators,
the optimal solution is $\{\{A,B\},\{C,D\}\}$\revb{:
coreference links $(A,B)$ and $(C,D)$ in this solution
were annotated as non-coreferent by 2 and 3 annotators, respectively,
which incurs a cost of $2\pluss 3 \eqs 5$;
non-coreference links $(C,E)$ and $(D,E)$ in this solution
were annotated as coreferent by 2 annotators,
which incurs a cost of $2\cdot(2\pluss 2) \eqs 8$.
Therefore, the cost of this solution is $5 \pluss 8 \eqs 13$.}
A link that is \revb{coreferent (respectively non-coreferent)} in all annotations and in the solution
does not incur any cost.
}
\revb{%
We inspected the adjudication result after automatic adjudication
to validate the results of automatic adjudication,
and we analyzed annotator mistakes (see Section~\ref{secAnnotatorMistakes}).
Our adjudication tool (see Section~\ref{secTools})
permits a manual specification of partial coreference chains;
however, performing such a manual override was not necessary,
as we did not encounter mistakes of the automatic adjudication method.
Additional details about the adjudication method and tool
have been described by our group \cite{Schuller2018adjudication}.}
\mycorpustable
\subsection{Corpus Properties}
\label{properties}
\revb{Table~\ref{tblCorpusMetrics} shows key properties
of the adjudicated gold standard.
The corpus contains 5170 mentions and 944 coreference chains.}
\emph{\revb{Mentions.}}
\revb{The a}verage number of tokens and mentions per genre
varies a lot. In particular, the Essay genre
contains texts discussing abstract concepts
like \quo{home} \revb{(see Figure~\ref{figExampleEv}) }and \quo{science} which are not annotated;
{\revamark
therefore, the average number of mentions \revb{per document ($M=89$)} %
is significantly lower than in other genres.
The genre Other contains \revb{a first-person }narrative
\revb{which repeatedly mentions }many person names;
therefore, the number of mention\revb{s (298)} is higher than in other genres.}
{\revbmark%
Figure~\ref{figMentiontypes} shows the distribution of mention types in the adjudicated corpus.
Mentions comprising a single token account for~76\% of all mentions,
with an equal distribution between pronouns, proper nouns, and other single-token mentions
such as \quo{babam} (\quo{my father}).
Figure~\ref{figMultiTokenMentionSizes} shows the distribution of mention length
for the remaining~24\% of mentions which span more than one token:
the majority of these mentions contain just two mentions,
for example the mention \quo{bu dağlara} (\quo{these mountains+Dat}).
There are a few long mentions such as
\quo{şeker, kahve, un, ayçiçeği yağı ve antibiyotiklerin bu dağlara ulaşmasından önceki durumu}
(\quo{the times before sugar, coffee, flour, sunflower seed oil, and antibiotics reached
[became available to the people that are living in] these mountains}).
Of all mentions, 5.7\% are a nested (i.e., contained) within another mention,
and no mention is nested within a nested mention.}
\myfigurehistogoldmentions
\emph{\revb{Coreference Chains.}}
{\revbmark%
Figure~\ref{figChainlengths} depicts the distribution of coreference chain lengths
in the gold standard (using a logarithmic scale to make single occurrences visible):
\revb{coreference }chains that connect just two mentions
occur more often (365 times) than longer chains.
\revb{Coreference }chains that connect more than ten mentions are rare in the corpus,
although there are also a few large \revb{coreference }chains.
Among those \revb{coreference }chains that contain ten or more mentions,
seven refer to the writer or to the first-person narrator and contain only pronouns,
while the others refer mainly to persons and contain mainly proper nouns mentions.}
\myfigurehistochainlengths
\subsubsection{\revb{Annotator Mistakes}}
\label{secAnnotatorMistakes}
{\revbmark
Overall, annotators produced 9,723 coreference chains containing 51,525 mentions.
Figure~\ref{figUseOmitStats} depicts the number of annotated coreference links
over the percentage of annotators that annotated
coreference of the same link.
The left side of the histogram mainly shows links
that are non-coreferent in the gold standard (due to adjudication),
while the right side shows links that are coreferent in the gold standard.
(To depict the agreement of annotators independent
from the number of annotations per document,
the histogram shows percentages:
for a documents with nine annotators, a single annotated coreference link contributes 11.1\%;
while for eleven annotators, a single annotated coreference link contributes 9.1\%.)
Nearly all links that were annotated as coreferent by fewer than 30\% of annotators are non-coreferent in the gold standard,
while nearly all links that were annotated as coreferent by at least 50\% of annotators are coreferent in the gold standard.
Between 30\% and 50\%, some links are coreferent and some are non-coreferent in the gold standard.
Whether a link occurs in the gold standard
depends on the global optimality of the solution
and on the satisfaction of structural constraints
as described in Section~\ref{secAdjudication}.
\myfigurehistomistakes
From 9,723 annotated coreference chains,
74\% directly correspond with a coreference chain in the gold standard,
and Figure~\ref{figMistakeStats} visualizes the annotator mistakes that can be measured over the remaining coreference chains.
For this analysis, we established a one-to-one matching between
annotated and gold standard coreference chains,
based on the greatest link overlap (similar to the CEAF metrics).
We then analysed deviations of annotators from the gold standard
relative to this matching.
The majority of mistakes (57\%) are coreference chains with missing mentions.
From these mistakes,
42\% are missing a single mention and 73\% are missing at most three mentions.
One third of mistakes (34\%) are coreference chains containing mentions
that are in distinct coreference chains in the gold standard.
In 66\% of these mistakes, a single mention belonged to another coreference chain
and in 95\% of these mistakes, at most three mentions belonged to another coreference chain.
A few mistakes are about mentions
that are not part of any coreference chain in the gold standard:
7\% of annotated chains contained such mentions (and no other mistakes),
and 2\% of annotated coreference chains contained only such mentions.
}%
\subsection{Tools}
\label{secTools}
For creating this corpus, we built several tools.
\paragraph{Document Extractor.}
The METU-Sabanci Turkish Treebank contains 1960 text fragments,
distributed over 33 documents. Most documents are split over several XML files;
however, there is also one XML file containing two distinct documents.
We provide a tool for extracting documents from the Turkish Treebank
and store each document in a single XML file.
The Turkish Treebank is licensed in a way
that it cannot be redistributed with the Marmara Turkish Coreference Corpus;
therefore, the tool generates document files
from a directory containing the unpacked Turkish Treebank.
Our tool not only creates one XML file for each document,
it also recodes all data to UTF-8 and fixes problematic (non-encoded)
attributes that are present in the original corpus.
\paragraph{Coreference XML format.}
For representing coreference information,
we created an XML format
that contains pointers to sentence and word IDs into documents
extracted from the Turkish Treebank.
A sample of such an XML file with two mentions and one \revb{coreference }chain is as follows.
\VerbatimInput[fontsize=\small]{sample.xml}
In this example, \quo{Prof.\_Dr.\_Semih\_Koray'ın}
is a mention with ID 0 \revb{(attribute \texttt{id="0"})}\ containing
the token with index 1 \revb{(attributes \texttt{fromWordIX="1"} and \texttt{toWordIX="1"})}
in sentence \quo{00016112313.1}
\revb{(attribute \texttt{sentenceNo="00016112313.1"})}\
of the document assembled from the Treebank.
Moreover, there is a \revb{coreference }chain containing that mention
and another mention that consists of the first token of sentence \quo{00016112313.2}.
\revb{%
A design goal for this XML format was to stay close to the XML format of the Turkish Treebank.
Therefore, tokens are indexed relative to sentence numbers,
and XML attribute names are equal to attributes names in the Turkish Treebank.%
\footnote{\revb{Tokens are }called \quo{word\revb{s}} in the Treebank XML format.}}
Note, that the text between the mention XML tags is used only for readability purposes;
the information about mention content is fully represented in the XML attributes.
\paragraph{CoNLL $\Leftrightarrow$ XML Converters.}
As the CoNLL reference coreference scorer~\cite{Pradhan2014scorer}
is based on CoNLL format,
we provide tools for converting a document and a coreference
XML file into a CoNLL file (and vice versa).
We use XML to be consistent with the Turkish Treebank
and because the Treebank license prevents redistribution.
\paragraph{(Semi-)automatic coreference adjudication tool.}
Merging several distinct coreference annotations
into a single gold standard is a complex task,
in particular if annotators do not agree on mentions.
To simplify this task, we created a tool that merges multiple annotations
into a single solution
according to objective~\eqref{eqObj} from Section~\ref{secAdjudication}.
{\revamark Technically, this optimization is performed with
the knowledge representation formalism Answer Set Programming
(Brewka, Eiter, and Truszczynski, 2011)
which yields provably optimal solutions to combinatorial problems in reasonable time.
Manual intervention for editing mentions and \revb{coreference }chains
is possible in our tool, details about
the file formats
and about how to represent the adjudication problem in a way that is
efficient enough for practical purposes
are described in a separate paper \cite{Schuller2018adjudication}.}
In \phasetwo\ we performed only automatic
adjudication and did not need manual intervention.
For the purpose of this project,
it was sufficient to use our tool
directly on CoNLL files without a GUI.
In the future,
to make the tool accessible to a wider part of the community,
we \revb{plan to integrate }it into an existing
software, \revb{in particular into MMAX2~\cite{Muller2006mmax2} or into }%
BART~(Broscheit, Poesio, Ponzetto, Rodriguez, Romano, Uryupina, Versley, and Zanoli, 2010).
\section{Baseline}
\label{secBaseline}
We have created a baseline for mention detection,
based on the work of Sapena et al.~\shortcite{Sapena2012},
and for coreference resolution,
inspired by Bengtson and Roth~\shortcite{Bengtson2008}.
The baseline \revb{was implemented using }Python and scikit-learn~%
(Pedregosa, Varoquaux, Gramfort, Michel, Thirion, Grisel, Blondel, Prettenhofer,
Weiss, Dubourg, Vanderplas, Passos, Cournapeau, Brucher, Perrot, and Duchesnay, 2011).
\revb{An optional module provides features using FastText word embedding vectors~\cite{Bojanowski2017fasttext}.}
We considered to integrate also the Named Entity Recognition (NER) module
of the ITU-pipeline~\cite{Eryigit2014} because \revb{named entities are }%
not annotated in the Turkish Treebank;
however, we found that the output \revb{of }the web service
changed significantly several times
during the development of the baseline.
To facilitate \revb{replicability }of \revb{our }results,
\revb{the baseline with deactivated FastText module
uses only features that are available in the gold standard of
the METU-Sabanci Turkish Treebank~\cite{Say2004}
and in the Marmara Turkish Coreference Corpus.}
\paragraph{Mention Detection.}
Our Mention Detection baseline {\revamark is rule-based and} marks all
\begin{enumerate}[(i)]
\item noun phrases,
\item pronouns,
\item \revb{named entities, }and
\item capitalized common nouns or proper names that occur two or more times in the document
\end{enumerate}
as mentions.
\revb{As the Turkish Treebank contains no named entity gold annotation,
we heuristically mark all nouns with capitalized lemmas as named entities.
Sentence-initial tokens are always capitalized
and (iv) helps to differentiate sentence-initial named entities
from sentence-initial noun phrase mentions.
The above set of rules (i)--(iv)
reproduces the approach that Sapena et al.~\shortcite{Sapena2012}
described for English mention detection.}
\paragraph{Coreference Resolution.}
Our baseline is similar to the approach described by Bengtson and Roth \shortcite{Bengtson2008}
{\revamark
where coreference chains were predicted with reasonable accuracy
using a small set of features and Support Vector Machines (SVM) \cite{Cortes1995svm}.
}
As input, the baseline uses a set of candidate mentions (either gold or predicted),
lemma information,
and dependency parsing information for obtaining mention heads.
The type of a mention is marked as \emph{pronoun} if the lemma of the
\revb{token is in the list of pronoun lemmas described by
Kılı{\c{c}}aslan et al.~\shortcite{Kilicaslan2009}.}
To separate \emph{proper noun} from \emph{noun phrase} mention types,
we realized our own heuristic which
\bipe{(i)}
\item collects all upper-case tokens not at sentence-initial position,
\item strips case markers, and
\item uses the resulting set of strings to mark all (including sentence-initial) tokens as {proper nouns}.
\eipe
All remaining mentions
\revb{are considered to be }noun phrases.
Based on mention types and head information,
we create the following features
for each \revb{link }$(m_1,m_2)$:
\begin{enumerate}[(i)]
\item \revb{the }type of $m_1$ and type of $m_2$ (2 features),
\item \revb{whether }both mentions are pronouns, proper nouns, or noun phrases (3 features),
\item \revb{whether the }heads of $m_1$ and $m_2$ match, and the same for \revb{the respective }head lemmas (2 features),
\item \revb{whether the }last part of a proper noun is equal in $m_1$ and $m_2$,
\item \revb{whether }$m_1$ is an acronym of $m_2$, and
\item \revb{whether the }head of $m_1$ is a sub-string of \revb{the }head of $m_2$, and the same for \revb{the respective }head lemmas (2 features).
\end{enumerate}
Features (v)\revb{ and (vi) }are asymmetric, that means exchanging $m_1$ and $m_2$ can change the feature value.
For these features we also add the respective reverse direction feature,
as well as the disjunction of features of both directions.
Moreover, we add all possible pairs of features (i)--(ii) and (iii)--(vi)
to allow the machine learning \revb{model }to give separate weight to features (iii)--(vi) per mention type.
{\revbmark
All the above features can be derived from the Turkish Treebank contents
without the need for additional predictions.
To integrate FastText~\cite{Bojanowski2017fasttext} word embedding features
we use ideas from the work of Simova and Uszkoreit (2017).
We use FastText because the vectors are learned from character n-grams of words
which makes them particularly suggestive for usage with the agglutinative morphology of Turkish.
We trained embeddings with default parameters
(100 dimensions, character n-grams of length 3--6, context window of size 5)
and the skip-gram representation on the lowercase dump of Turkish Wikipedia from 1.1.2018.%
\footnote{\protect\revb{\url{https://dumps.wikimedia.org/trwiki/20180101/}}}
The text in that dump contains 73 million tokens and 412459 types.
Word vectors for heads of mentions are looked up directly,
word vectors for mentions are computed as the average over all tokens in the mention.
We add the following embedding features for predicting coreference of a link $(m_1, m_2)$:
\begin{enumerate}[(i)]
\setcounter{enumi}{6}
\item
cosine similarity between vectors of heads of $m_1$ and $m_2$ (2 features),
\item
cosine similarity between vectors of mentions $m_1$ and $m_2$ (2 features),
\item
vectors of heads of $m_1$ and $m_2$ (200 features), and
\item
vectors of mentions $m_1$ and $m_2$ (200 features).
\end{enumerate}
As done by Simova and Uszkoreit,
we also experimented with Principal Component Analysis (PCA) to transform word vectors into 15 dimensions.
This explains 47\% of the variance in the learned dictionary of word vectors
and creates only 60 features in total for (ix) and (x).}
\smallskip
\subsection{\revb{Coreference Chain Prediction}}
\label{secCorefPrediction}
We implemented two methods for predicting coreference
based on classification (SVC) and regression (SVR).
\emph{SVC}
is based on classification with a linear-kernel SVM \cite{Cortes1995svm}.
Positive examples are mentions and their closest predecessors within all \revb{coreference }chains,
while negative examples are all \revb{non-coreference links }with less than 100 mentions distance.
For predicting \revb{coreference }chains,
we first generate candidate \revb{links }for all mentions
except for \revb{links where the first mention is a pronoun
and the second mention is not a pronoun,
as done by Bengtson and Roth~\shortcite{Bengtson2008}.}
Then, we predict whether \revb{a link is coreferent or not }using the SVM.
Finally, each mention starts in its own \revb{coreference }chain
and we go through mentions from the beginning of the document to the end,
and merge mentions to (potentially several) previous \revb{coreference }chains for all predicted \revb{coreference }links.
We prevent merges that lead to \revb{coreference }chains
with overlapping mentions.
\emph{SVR}
is based on support vector regression with a linear-kernel SVM~%
(Drucker, Burges, Kaufman, Smola, and Vapnik, 1997)
\nocite{Drucker1997svr}%
trained on the same examples as SVC.
For prediction, we generate the same candidate mentions as in SVC.
For building \revb{coreference }chains, we also start with one \revb{coreference }chain per mention,
but this time we use the Best-Link \cite{Bengtson2008} strategy:
we iterate over mentions in order of occurrence in the document,
and merge each mention with at most one predecessor \revb{coreference }chain
if its highest-scored candidate link to a predecessor mention is above 0.1
and if the resulting \revb{coreference }chain does not contain overlapping mentions.
\revb{This threshold was determined in preliminary experiments.
The optimal value can depend on the
difference between the ratio of coreference and non-coreference links
in the training set and in the testing set.)}
In addition to the above,
when predicting coreference on predicted mentions,
we include incorrect mentions predicted on the training documents
to generate negative examples.
We randomly sample as many incorrect mentions as already contained in the gold annotation.
When predicting coreference on gold mentions, we train only on gold mentions.
We balance example weight by class size
(we have significantly more negative examples),
and we use L2 regularization for both SVC and SVR.
\subsection{Evaluation}
We evaluate our baseline using the
CoNLL reference coreference scorer~\cite{Pradhan2014scorer}
and report MUC, B$^3$, CEAF$_m$, CEAF$_e$, BLANC\revb{, and LEA} scores
{\revamark
(see Section~\ref{secCorefMetrics}).
We also use the reference coreference scorer
for obtaining accumulated scores over multiple documents.}
Mention detection is done on the Turkish Treebank data
and does not require learning.
Coreference resolution is done either on gold mentions (GM) or on predicted mentions (PM).
Scores are obtained by leave-one-out cross-validation
on all 33 documents of the corpus, yielding 33 folds.
All scores are given \revb{as }percent\revb{ages}.
For mention detection we report Precision and Recall,
for coreference scores we report only F1.
{\revbmark
We experiment with three feature sets:
\begin{itemize}
\item T includes the features (i)--(vi) which are based on the Turkish Treebank;
\item TF adds to T the features (vii)--(x) with 100-dimensional vectors from FastText; and
\item TP adds to T the features (vii)--(x) with 15-dimensional vectors from applying PCA to FastText embeddings.
\end{itemize}
}
\mybaselinebygenres
Table~\ref{tblBaselineGenre} shows the results of performing mention detection
and coreference with SVC on gold mentions\revb{ (GM) using the T feature set.}
We obtain {\revbmark 88.2\%} Recall %
for mention detection over the whole Treebank.
As expected and as intended, Precision %
is much worse because we expect the coreference resolution step to
eliminate spurious mentions.
Coreference resolution on gold mentions yields a \revb{LEA }score of \revb{57.8\%},
\revb{the more permissive MUC, }B$^3$, CEAF, and BLANC scores are higher.
The worst scores are obtained from genre Other,
which contains a single first-person narrative.
As no other document contains such a narrative,
in cross-validation, the training set contains only documents
that are structurally different from the test set
and a low score is expected.
\revb{We analyse mistakes of the baseline in detail in Section~\ref{secBaselineErrorAnalysis}.}
\mybaselinebymethod
Table~\ref{tblBaselineMethod} shows
overall scores for \revb{predicting coreference on gold mentions using }SVC or SVR
and \revb{for predicting coreference on predicted mentions (PM) using }SVR.
\revb{We show results for all feature sets because for each of the three
sections of the table, the best result is achieved by another feature set.}
SVC/GM is the same setup as in
Table~\ref{tblBaselineGenre}.
\revb{Among the tested configurations,
feature set T yields the best LEA score on gold mentions.
Scores become worse when we add word embedding features;
moreover, high-dimensional embeddings (TF) yield worse scores than
low-dimensional embeddings (TP).}
SVR/GM yields scores \revb{slightly below those of }SVC.
\revb{Differently from SVC, embedding features do not deteriorate the scores.}
The reason for this difference between SVC and SVR is
\revb{the foundational difference for the chain building algorithm of SVC and SVR}:
SVC merges all coreference chains where a coreference link is predicted,
while SVR uses the Best-Link strategy (see Section~\ref{secCorefPrediction}).
\revb{As a consequence, with SVR uses only the highest scoring link
and is not sensitive to variations in scores of links with low confidence,
while SVC considers all links where coreference was predicted with some confidence.
SVC might therefore mistakenly merge many coreference chains.
This increases MUC score
but decreases all more reliable scoring metrics,
as can be observed in Table~\ref{tblBaselineMethod} lines SVC/GM/TF and SVC/GM/TP.}
Naturally, coreference prediction
\revb{yields significantly worse results on PM than on GM,
with a score difference around 30\%.
We analyze possible reasons for this performance difference in the Section~\ref{secBaselineErrorAnalysis}.}
{\revbmark
\paragraph{Further experiments.}
Apart from the results shown in Tables~\ref{tblBaselineGenre} and~\ref{tblBaselineMethod},
we conducted several further experiments.
When using SVC on predicted mentions,
nearly all mentions end up in a single coreference chain
because the presence of many superfluous mentions gives a lot of opportunity
for SVC to mistakenly connect chains.
As discussed above,
SVR does not suffer from this issue due to the Best-Link strategy.
Apart from the features discussed above,
we experimented with using the role of the head
of noun phrase mentions $m_1$ and $m_2$
in the dependency parse graph for predicting coreference of link $(m_1,m_2)$.
Adding this feature causes scores to decrease for all configurations discussed above.
We think this is due to overfitting to the small training corpus
and to the comparatively large number of 58 distinct dependency roles
in the Turkish Treebank.}
\subsection{Error Analysis}
\label{secBaselineErrorAnalysis}
{\revamark
An analysis of missing mentions in Mention Detection
uncovered several examples of problems with tokens that contain a derivation boundary.
Such tokens are, for example, adjectivised verbs,
which are not counted as being part of a noun phrase although they sometimes should be.
A concrete example is \quo{sona eren bin yıl}
(\quo{thousand years that are coming to an end})
where \quo{sona eren} (\quo{coming to an end}) is a single token in the Treebank
that is a modifier of \quo{bin yıl} (\quo{thousand years}).
This token is an adjectivised verb and contains a derivation boundary.
A possibility for improving mention detection
could be to split tokens with derivation boundaries into multiple tokens:
a base lexical token and potentially multiple virtual functional tokens
for deciding mention boundaries.
However, this effort would exceed the construction of a baseline
and we consider such improvements as future work.
{\revbmark
A quantitative analysis of mistakes with gold mentions showed
that 58\% of predicted coreference chains are missing at least one mention,
the remaining 42\% of wrongly predicted coreference chains
contain mentions from at least two gold standard coreference chains.
These mistakes show a balance between predicting too many links and too few links.
Improving predictions on gold mentions, therefore, likely requires new features
or more expressive (i.e., non-linear) combinations of existing features
in the machine learning model
which could be achieved by feature engineering or by applying deep learning methods.}
An \revb{inspection of }mistakes showed
that the genres Travel and Other obtain a worse score because there is a frequent
alternation between first and third person,
without an implicit change of the speaker,
such that often \quo{biz} (\quo{we}) and \quo{siz} (\quo{you}) corefer
although the person changes.
A frequent source of mistakes in the Novel genre is the usage of specific
family titles like \quo{hala} (\quo{aunt on the father's side})
and \quo{abi} (\quo{older brother})
which allow \revb{inferences about }specific coreferen\revb{tial mentions to be made }through reasoning about previously explained family situations.
However, our baseline system is not aware of the meaning of these words
and we consider the introduction of such reasoning into
Turkish coreference resolution as future work.}
{\revbmark
A quantitative analysis of mistakes with predicted mentions showed
that 58\% of predicted coreference chains contain only spurious mentions
which are not part of any coreference chain in the gold standard.
Moreover, 17\% of predicted coreference chains are missing some mention,
14\% of predicted coreference chains contain mentions that are not part of the gold standard,
and only 12\% of predicted coreference chains merge two or more gold standard chains.
For improving coreference prediction on predicted mentions,
we think that developing a predictor for distinguishing
between specific and generic mentions of a common noun will be important
to avoid superfluous mentions and therefore superfluous coreference links.
We think this is a promising future direction because superfluous mentions
account for 72\% (58\%+14\%) of mistakes in chains.}
As this is only a baseline,
we did not include more sophisticated features
described by Bengtson and Roth~\shortcite{Bengtson2008}.
For example, semantic features based on WordNet~%
(Miller, 1995;
Bilgin, {\c{C}}etinoğlu, and Oflazer, 2004)
could rule out certain predicted mentions as relevant
and thus could improve Precision of the baseline.
\section{Conclusion}
\label{secConclusion}
{\revbmark
We have presented the Marmara Turkish Coreference Corpus,
the first Turkish coreference corpus,
based on the de facto standard Turkish Treebank.
We also presented a baseline system for mention detection and coreference prediction.
Our corpus has coreference annotated on the token level.
This has several reasons:
the relevant possessive and personal pronoun suffixes
are not accessible as markables in the Turkish Treebank,
a morpheme-based coreference annotation would increase the complexity
of the annotation task,
and it would require annotators
with a higher level of expertise than available in our study.}
For a future annotation project it could be interesting to extend annotations to include coreference links\revb{ to morphemes}.
\revb{This would require to extend the Turkish Treebank so that inflectional groups
are structured further into morphemes to make them accessible as markables
(see Section~\ref{secTurkishCoref}).}
\revb{For }scoring with the reference scorer tool \revb{it would be necessary to }%
develop a CoNLL representation for Turkish where tokens are split within IGs.
{\revbmark
The (relative) simplicity of the annotation task
and the high number of annotators that were involved in this project
(i.e., at least eight annotators for each document)
allowed us to perform adjudication automatically.
Our analysis of the adjudication process shows,
that 74\% of all annotated coreference chains fully correspond to a
coreference chain in the gold standard,
and the majority of non-perfectly annotated chains either misses a few mentions
or contains a few spurious mentions (see Section~\ref{secAnnotatorMistakes}).
Therefore, we are confident that the annotation and adjudication process
has yielded a reliable coreference gold standard.}
{\revbmark
The baseline demonstrates,
that the created gold standard is consistent in itself
and permits prediction of mentions and coreference links
using existing methods from literature.
}
To improve the mention detection baseline,
information about appositives as well as finding a way
to filter out generic mentions would be useful.
To improve the coreference resolution baseline,
adding more complex features by
integrating Turkish WordNet~\cite{Bilgin2004wordnet},
Turkish NER~\cite{Seker2012},
and Turkish WSD~%
(İlgen, Adalı, and Tantuğ, 2012)
could be helpful.
For a full processing pipeline from plain text to coreference
annotations,
\revb{the baseline described here derives features from}\
morphological analysis and disambiguation~%
(Sak, G{\"{u}}ng{\"{o}}r, and Sara{\c{c}}lar, 2007),
and \revb{from }dependency parsing~%
(Eryiğit, Nivre, and Oflazer, 2008).
Available tools \revb{for these tasks }are the ITU-pipeline~\cite{Eryigit2014}
and the older Zemberek system~\cite{Akin2007zemberek}.
\revb{For providing a replicable evaluation of the baseline,
we use only features that are present in the Turkish Treebank
(and optionally word embedding vectors).}
{\revbmark
Orthogonal to our baseline,
it would be interesting to build a joint mention and coreference prediction system
based on deep learning with only word embeddings as the main input,
similar to the systems of Wu et al. \shortcite{Wu2017deepcoref}
and Lee et al. \shortcite{Lee2017neuralcoref}.}
\section*{Acknowledgements}
We are grateful to Kemal Oflazer and Bilge Say
for support about the METU-Sabanci Turkish Treebank,
and to Dilek Küçük and Savaş Yıldırım for support about their papers and datasets.
\revb{We are grateful to the reviewers for their constructive comments.}
This work has been supported by
The Scientific and Technological Research Council of Turkey
(TUBITAK) under grant agreements 114E430 and 114E777.
Author contributions are as follows (in chronological order):
creating documents from Treebank fragments~(B.G.S),
evaluating GATE and BRAT annotation software~(B.G.S., A.P.),
creating the annotation manual~(P.S., K.C., F.T., B.G.S.),
performing manual adjudication in \phaseone~(K.C., B.G.S., A.P., H.E.K.),
annotating mentions for those documents in \phasetwo\ that were
not annotated in \phaseone~(K.C., H.E.K.),
revising the manuscript as an English native-speaker~(A.H.K.),
writing the baseline software~(P.S., F.T., A.P.),
managing the project,
performing baseline experiments,
analysing data and results,
writing and revising the manuscript~(P.S).
\bibliographystyle{apalike}
\ifinlineref
\input{references.sty}
\else
| {'timestamp': '2018-08-01T02:12:08', 'yymm': '1706', 'arxiv_id': '1706.01863', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01863'} | arxiv |
\section{Introduction}
\IEEEPARstart{F}{ace} alignment, also known as facial landmark localization, is an essential step in many computer vision methods such as face verification \cite{Bayes} and facial motion capture \cite{Animation}. The majority of face alignment methods proposed in the last several years are based on Cascaded Shape Regression (CSR), which was first proposed in \cite{ESR}.
CSR is usually initialized by placing the average face shape in the location provided by the face detector. Starting from this initialization, the face shape is refined in a fixed number of iterations. In each iteration features are extracted from the regions around each landmark of the face shape. The extracted features are then used in a regression method to estimate a correction to the current positions of the landmarks.
In \cite{LBF} Ren et al. proposed Local Binary Features (LBF) where binary descriptors are created based on regression forests \cite{forests} built on simple pixel difference features. The proposed features were incorporated into the CSR framework, which lead to a very fast method, running at the speed of 3000 frames per second on standard desktop hardware.
Our face alignment method is based on LBF, but instead of standard regression forests with pixel features, we use novel K-cluster Regression Forests with Weighted Splitting (KRFWS) and Pyramid HOG (PHOG) features. PHOG features consist of HOG \cite{HOG} taken over the same area with progressively larger cell sizes, more details can be found in \cite{KRF}.
K-cluster Regressions Forests (KRF) were originally proposed in \cite{KRF} for head pose estimation and car orientation estimation. In KRF, at each split, the target space is divided into K clusters, which locally minimize the loss function of the tree. Each K-fold split is performed using a separate k-class linear SVM classifier. The advantage of this type of splitting is that it allows to split on multidimensional features such as HOG, whereas standard regression forest splitting uses only scalar, one dimensional features.
In this work we propose K-cluster Regression Forests with Weighted Splitting (KRFWS) by introducing weights on individual samples for classification at each split. We test KRFWS on the Pointing'04 dataset \cite{Pointing}, for which KRF was originally designed, and show improved accuracy.
Recently Li et al. proposed Affine-Transformation Parameter Regression for Face Alignment (APR) \cite{APR}, which estimates a 2D affine transform that refines the current face shape estimate. As opposed to the standard regression step in CSR, which refines the positions of the individual landmarks, APR applies a rigid transform. In \cite{APR} it was shown that embedding such alignment before and between standard cascaded shape regression iterations improves face alignment accuracy.
In this work we propose two major extensions to the APR method. First, we show that using KRFWS instead of linear regression improves the accuracy of the estimated transform. Second, we propose 3D-APR, where, we estimate a 3D transform of the current face shape estimate. The use of a 3D transform allows for the compensation of out-of-plane rotation of the head, which is not possible with standard APR.
\begin{figure}[!t]
\centering
\subfloat[]{\includegraphics[width=0.32\linewidth]{./imgs/drawings/1b.png}}
\quad
\subfloat[]{\includegraphics[width=0.32\linewidth]{./imgs/drawings/2.png}}\\
\subfloat[]{\includegraphics[width=0.32\linewidth]{./imgs/drawings/3b.png}}
\quad
\subfloat[]{\includegraphics[width=0.33\linewidth]{./imgs/drawings/4.png}}
\caption{An illustration of the weighting scheme used in KRFWS and its influence on classification results. Figures (a) and (c) show a set of samples in a 2 dimensional target space $y$, divided into two clusters using k-means clustering. The size of each point corresponds to its weight, (a) uses uniform weighting, while (c) uses the weighting scheme proposed in KRFWS. Figures (b) and (d) show classification results obtained from data in (a) and (c). The misclassified samples in (d) are more likely to be located close to the border between the two clusters and in consequence their influence on SSE is limited.}
\label{fig:drawing}
\end{figure}
\section{Methods}
\subsection{K-cluster Regression Forests with Weighted Splitting}
In this chapter we describe K-cluster Regression Forests with Weighted Splitting (KRFWS) which are an extension of K-cluster regression forests (KRF). Regression forests, like all other regression methods, map a point in the input space $\pmb{X}$ onto a point in the target space $\pmb{Y}$. KRF differ from other similar methods in the way splitting is performed and in the fact that in KRF each node has $K \geq 2$ child nodes, whereas in most methods each node has 2 children.
The aim of splitting is to find a rule that once applied to the input space $\pmb{X}$, partitions the target space $\pmb{Y}$ in a way that minimizes the loss function of the tree. KRF use the most common loss function, which is the sum of squared errors (SSE) of the child nodes. As explained in \cite{KRF}, the SSE of the child nodes of any given node is locally minimized by a partition defined by the result of k-means clustering on the target space of samples in that node.
In KRF, the problem of splitting is defined as a classification problem. To preserve the partition defined by the k-means clustering, a classifier is trained at each split. This is achieved by applying a $K$ class one-versus-rest linear SVM classifier on the input space of samples in each node. The advantage of this approach is that the splits can be performed on multidimensional features. This in turn facilitates the use of image features, for example PHOG, as the input space.
In most cases the separating hyperplane produced by the SVM does not partition the input set perfectly. In practice this means that some of the samples will not be forwarded to the correct child node. The misclassified samples increase the value of the loss function and make the splitting problem more difficult in the child nodes.
We propose to reduce the impact of this problem by giving more importance to the samples that, should they be misclassified, would have the largest impact on SSE. This is achieved by assigning each sample $i$ in the current node $T_j$ a weight $w_i\in [0, 1]$, where 0 would signify that the sample is of no importance. The weights are then used as an input to a weighted SVM classifier included in the LIBLINEAR \cite{LIBLINEAR} package. Below we describe our method for generating the sample weights for splits with $K=2$ clusters. While the method does generalize to any number of clusters, the description of the generalized procedure is beyond the scope of this short article.
Given a node $T_j$ divided into two clusters $C_1$ and $C_2$ with their respective centroids $c_1$ and $c_2$, the weights are defined as follows:
\begin{equation} \label{eq:projection}
v_i = \left(y_i - \frac{c_2 + c_1}{2}\right)^T \cdot \frac{c_2 - c_1}{\lVert c_2 - c_1 \rVert} ,
\end{equation}
\begin{equation} \label{eq:normalization}
w_i = \frac{\lvert v_i \rvert }{\max_{i\in T_j}[\lvert v_i \rvert]},
\end{equation}
where $i \in T_j = C_1 \cup C_2$ and $y_i\in\pmb{Y}$. Equation \eqref{eq:projection} transforms each point $y_i$ of the target space into a distance $v_i$ of that point from the hyperplane separating the two clusters. The distances are then normalized in equation \eqref{eq:normalization} so that $w_i\in [0, 1]$.
Effectively each weight is the normalized distance of a given sample from the hyperplane separating $C_1$ and $C_2$. The samples close to the boundary between the two clusters have a small weight as even if they are incorrectly classified, the SSE will not increase greatly. The samples that are far from the boundary on the other hand, have large weights as, should they be misclassified, the SSE would be heavily affected. The weighting scheme and its influence are illustrated in Figure \ref{fig:drawing}.
KRFWS is not the only decision forest method that utilizes sample weights, one other method is boosting with decision trees \cite{boosting}. There are however several key differences between the two methods. In boosting with decision trees, the learning of each tree is dependent upon its predecessors. The samples are weighted based on their error in previously trained trees. In KRFWS each tree is trained independently using a different subset of the training data (bagging). The sample weights are calculated independently at each split, and reflect the influence a given samples would have on the loss if it was misclassified.
\subsection{Affine Pose Regression}
Affine Pose Regression (APR) was recently proposed in \cite{APR} as a method for improving the performance of face alignment methods. In contrast to Cascaded Shape Regression (CSR), APR estimates a rigid transforms of the entire face shape:
\begin{equation} \label{eq:transform}
S' =
\begin{bmatrix}
a & b\\
c & d
\end{bmatrix}
S +
\begin{bmatrix}
t_x & \dots & t_x\\
t_y & \dots & t_y
\end{bmatrix},
\end{equation}
where $S$, a $2\times n$ matrix, is the current estimate of the face shape, $n$ is the number of landmarks in the face shape and $a, b, c, d, t_x, t_y$ are the parameters of the transform. The parameters are estimated by linear regression based on HOG features extracted at the facial landmarks. APR can be applied before CSR or in between CSR iterations to efficiently compensate for inaccurate initialization of the face shape in scale, translation and in-plane rotation.
In this work we propose to improve the original APR framework by using KRFWS instead of linear regression. We estimate all the transform parameters by creating separate KRFWS models for $a,b,c,d$ and a joint model for $t_x, t_y$. Instead of extracting features at individual landmarks we extract a single feature that covers the entire face. We show the effectiveness of our approach in experiments on the 300-W dataset \cite{300-W} in section \ref{sec:experiments}.
\subsection{3D Affine Pose Regression}
As mentioned in the previous section, APR can be applied before CSR to compensate for inaccuracy in scale, translation and in-plane rotation of the face shape estimate. In this section we propose a method to extend APR by taking into account out-of-plane rotation of the head, namely: yaw and pitch. Our method, which we call 3D-APR, fits an average 3D face shape to the face in the image and uses the 2D projection of that shape as an initialization for face alignment.
3D Affine Pose Regression (3D-APR) consists of two steps: first we fit an average 3D face shape $\bar{S}$ to the initial face shape estimate $S$. The fitting is accomplished using a scaled orthographic projection:
\begin{equation} \label{eq:scaledorto}
\bar{s} = k \cdot P \cdot \bar{S} +
\begin{bmatrix}
t_x & \dots & t_x\\
t_y & \dots & t_y
\end{bmatrix},
\end{equation}
where $\bar{s}$ is the projected shape, $k$ is a scaling factor, $P$ are the first two rows of a rotation matrix and $t_x$, $t_y$ are translation parameters. The values of the parameters $\Gamma=\{k,P,t_x,t_y\}$ for any shape are obtained by solving the following optimization problem:
\begin{equation} \label{eq:gauss}
\newcommand{\operatornamewithlimits{arg\min}}{\operatornamewithlimits{arg\min}}
\Gamma = \operatornamewithlimits{arg\min}_{\Gamma} \lVert \bar{s} - S \rVert^2.
\end{equation}
The optimization is performed using the Gauss-Newton method as in \cite{2Dvs3D}.
In the second step we estimate an update $\Delta$ to $\Gamma$ that refines the projected 3D shape $\bar{s}$ so that it is closer to the true shape of the face in the image. As in APR the estimation is performed using KRFWS based on a PHOG descriptor extracted at the face region. Separate KRFWS models are trained to estimate $k$ and $P$, a joint model is used for $t_x$ and $t_y$. The projection matrix $P$ is parametrized using euler rotations. In practice, the estimation of $P$ is equivalent to head pose estimation.
Learning is performed similarly to learning in APR and CSR. The training set consists of a set of images with corresponding ground truth landmark locations. For each image a number of initial shapes are generated from the ground truth shape. For each initial shape, the initial parameters $\Gamma$ and the ground truth parameters $\Gamma'$ are obtained using equation \eqref{eq:gauss} and the ground truth annotations. KRFWS learning is then applied to map the PHOG descriptor to the update $\Delta = \Gamma' - \Gamma$.
\section{Experiments} \label{sec:experiments}
In this section we test the effectiveness of the proposed methods in affine pose regression, face alignment and head pose estimation. The parameters we use for our methods in APR and face alignment have been established through cross-validation, with the exception of the number of children $K$. $K$ was set following \cite{KRF}, where the authors have found $K=2$ to be optimal for a target space similar to ours. We plan to investigate different values of $K$ in future experiments..
\subsection{Affine pose regression}
We test the effectiveness of APR and 3D-APR on the 300-W dataset \cite{300-W}, which consists of face images with corresponding ground truth annotations of 68 characteristic points and bounding boxes generated by a face detector. The images in 300-W are gathered from several other datasets: AFW \cite{AFW}, HELEN \cite{HELEN}, IBUG \cite{300-W} and LFPW \cite{LFPW}. For learning we use the AFW dataset and the training subsets of the HELEN and LFPW datasets, which together consist of 3148 face images. Our test dataset consists of two subsets: the challenging IBUG dataset (135 images) and the less challenging test subsets of the LFPW and HELEN datasets (554 images). Together the two datasets form what we refer to as the full set. This division of the 300-W dataset is a standard in face alignment testing, employed in many recent articles \cite{LBF, CFSS, TransferredDCNN}.
Each method is initialized with the face detector bounding box provided in the 300-W dataset. Similarly to \cite{LBF},\cite{CFSS} we use the inter-pupil distance normalized landmark error, all errors are expressed as the \% of the inter-pupil distance. The pupil locations are assumed to be the centroids of the landmarks located around each of the eyes.
Five different configurations of APR and 3D-APR are tested: (1) Linear APR with feature extraction at landmarks, (2) Linear APR with a single feature extracted at the face center, (3) KRF APR with a single feature extracted at the face center, (4) KRFWS APR with a single feature extracted at the face center, (5) KRFWS APR followed by 3D-APR with a single feature extracted at the face center (Combined APR, CAPR). In all of the configurations the images are rescaled so that the face size is approximately $64\times 64$ pixels. In all experiments APR is performed for two iterations, while 3D-APR is performed once.
In the first configuration Pyramid HOG \cite{KRF} features covering $32\times 32$ pixels are extracted at each landmark. The input descriptor for APR is formed by concatenating the descriptors from each of the landmarks.
In configurations (2), (3), (4) and (5) a single PHOG is extracted at the face center. As the feature size is not a concern in this scenario (only one feature is extracted instead of 68) we use the extended version of the HOG feature described in \cite{extHOG}. The descriptor covers an area of $64\times 64$ pixels.
The results of the experiments are shown in Table \ref{tab:APR}. KRFWS APR outperforms Linear APR on the challenging subset by 6\%. CAPR shows the best accuracy of all tested methods, reducing the error of Linear APR by 35\% on the full set.
\begin{table}[htbp]
\caption{Error of APR methods on the 300-W dataset.} \label{tab:APR}
\begin{tabularx}{\linewidth}{ >{\centering\arraybackslash}X c c c }
\Xhline{4\arrayrulewidth}
Methods & \makecell{Common \\ subset} & \makecell{Challenging \\ subset} & Full set\\
\hline
Linear APR & 12.70 & 26.00 & 15.29 \\
Linear APR single feature & 12.77 & 25.85 & 15.32 \\
KRF APR & 11.48 & 24.80 & 14.08 \\
KRFWS APR & 11.37 & 24.28 & 13.88 \\
KRFWS APR + 3D-APR (CAPR) & 8.61 & 15.26 & 9.90 \\
\Xhline{4\arrayrulewidth}
\end{tabularx}
\end{table}
\subsection{Face alignment}
\begin{figure}[!t]
\centering
\includegraphics[width=0.93\linewidth]{./imgs/faces.png}\\
\caption{A diagram showing the proposed face alignment pipeline. The images above, taken from the IBUG dataset, show the results at the consecutive stages of the pipeline. }
\label{fig:faces}
\end{figure}
In face alignment we use the same training and evaluation data as in the APR experiments. In order to facilitate comparison with other methods we report the results of our full pipeline for both inter-pupil normalisation \cite{LBF},\cite{CFSS} and inter-ocular normalisation \cite{MDM}. Our face alignment method uses the Local Binary Feature framework \cite{LBF}, where instead of standard regression forests we use KRFWS, and instead of pixel difference features we use PHOG. The forest generated for each landmark consists of 5 trees with a maximum depth of 7, the PHOG extracted at landmarks cover an area of $32\times 32$ pixels each, with a single block per pyramid level. Similarly to \cite{LBF}, our method is performed for 5 iterations.
We test the accuracy of our face alignment method with four different initialization configurations: (1) face detector bounding boxes provided in the 300-W dataset, (2) Linear APR, (3) KRFWS APR, (4) KRFWS APR + 3D-APR (CAPR).
The results of the experiments are shown in Table \ref{tab:alignment} along with the results of several state-of-the-art methods, all trained on the same datasets and all initialized as in configuration (1). The methods we compare to perform face alignment using a variety of machine learning tools, including: linear regression \cite{SDM}, decision trees \cite{LBF} and deep learning \cite{TransferredDCNN, MDM}.
The experiments we have performed show the effectiveness of our face alignment combined with KRFWS APR and 3D-APR. In configuration (1) the proposed face alignment method outperforms the original LBF in all cases by between 2\% and 8\%. The addition of KRFWS APR and CAPR for initialization leads to an improvement of 18\% and 20\% over the original LBF on the challenging IBUG dataset.
Our face alignment combined with CAPR initialization shows state-of-the-art results on all datasets. The addition of CAPR resulted in an error reduction of over 13\% on the challenging subset in comparison to face detector initialization.
Figure \ref{fig:faces} shows a diagram of our face alignment pipeline along with images at its consecutive stages.
\begin{table}[htbp]
\caption{Error of face alignment methods on the 300-W dataset.} \label{tab:alignment}
\begin{tabularx}{\linewidth}{ >{\centering\arraybackslash}X c c c }
\Xhline{4\arrayrulewidth}
Methods & \makecell{Common \\ subset} & \makecell{Challenging \\ subset} & Full set\\
\hline
\multicolumn{4}{c}{inter-pupil normalisation} \\
\hline
ESR \cite{ESR} & 5.28 & 17.00 & 7.58 \\
SDM \cite{SDM} & 5.60 & 15.40 & 7.52 \\
LBF \cite{LBF} & 4.95 & 11.98 & 6.32 \\
Transferred DCNN \cite{TransferredDCNN} & 4.73 & 12.37 & 6.23\\
CFSS \cite{CFSS} & 4.73 & 9.98 & 5.76 \\
\hline
\textbf{KRFWS LBF} & \textbf{4.84} & \textbf{10.96} & \textbf{6.03} \\
\textbf{Linear APR + KRFWS LBF} & \textbf{4.76} & \textbf{10.57} & \textbf{5.89} \\
\textbf{KRFWS APR + KRFWS LBF} & \textbf{4.65} & \textbf{9.82} & \textbf{5.66} \\
\textbf{CAPR + KRFWS LBF} & \textbf{4.62} & \textbf{9.48} & \textbf{5.57} \\
\hline
\multicolumn{4}{c}{inter-ocular normalisation} \\
\hline
MDM \cite{MDM} & - & - & 4.05\\
\textbf{CAPR + KRFWS LBF} & \textbf{3.34} & \textbf{6.56} & \textbf{3.97} \\
\Xhline{4\arrayrulewidth}
\end{tabularx}
\end{table}
\subsection{Head pose estimation} \label{sec:headpose}
In order to compare KRFWS to the original KRF we test our method on the head pose estimation task. We use the Pointing'04 \cite{Pointing} dataset, which was also used to test the original KRF. The Pointing'04 dataset consists of images of 15 subjects, each photographed in two separate sessions. During both sessions each subject had 93 photographs taken with pitch and yaw of the head both varying from -90$^{\circ}$ to +90$^{\circ}$. Each image in the dataset is accompanied by a manually annotated bounding box containing the head. \looseness=-1
For fair comparison we use experimental settings identical to those proposed in \cite{KRF}. From each image we extract a single Pyramid HOG feature, set K in KRFWS to 2 and have each forest consist of 20 trees. The splitting stops when a node has less than 5 samples.
We compare our method to the baseline KRF in two experiments, in both we use the Mean Absolute Error (MAE) measure. In the first experiment we perform 2-fold cross validation, where each fold consists only of images from a single session. In the second experiment we perform 5-fold cross validation, where the images in each fold are chosen at random. Our method shows an improvement of 4\% over the baseline KRF in the first test and a 3.7\% improvement in the second test. The results of both tests can be found in Table \ref{tab:pose} along with the results for KRF and Adaptive KRF (AKRF) \cite{KRF}. \looseness=-1
In MATLAB the training time for a single tree in the 5-fold cross validation test is 6.65 sec for KRF and 6.45 sec for KRFWS. This shows that the training of KRFWS is actually faster than training of KRF, despite the additional weight calculation step. We believe that this is because in KRFWS less splits are required to reach the stopping criterion.
\begin{table}[htbp]
\centering
\caption{Mean Absolute Error values for 2-fold and 5-fold cross validation on the Pointing'04 dataset.} \label{tab:pose}
\begin{tabular}{ | c || c | c | c | }
\hline
Method & yaw & pitch & average \\
\hline
\multicolumn{4}{|c|}{2-fold cross validation} \\
\hline
\textbf{KRFWS} & \textbf{4.95} & \textbf{3.35} & \textbf{4.15 $\pm$ 0.041} \\
\hline
KRF (baseline) & 5.06 & 3.59 & 4.32 $\pm$ 0.138\\
\hline
AKRF & 5.45 & 3.92 & 4.68 $\pm$ 0.072 \\
\hline
\multicolumn{4}{|c|}{5-fold cross validation} \\
\hline
\textbf{KRFWS} & \textbf{5.07} & \textbf{2.65} & \textbf{3.86 $\pm$ 0.177} \\
\hline
KRF (baseline) & 5.13 & 2.88 & 4.01 $\pm$ 0.171\\
\hline
AKRF & 5.57 & 3.39 & 4.48 $\pm$ 0.267 \\
\hline
\end{tabular}
\end{table}
\section{Conclusion}
In this article we have proposed a face alignment pipeline based on novel K-cluster Regression Forests with Weighted Splitting. Our pipeline consists of two separate stages: face shape initialization and face alignment. The first step performs APR and novel 3D-APR to improve the initial shape, provided by the face detector, in terms of translation, scale and in and out of plane rotation. The second step performs face alignment using an adapted version of the LBF framework. The proposed face alignment pipeline shows state-of-the-art results on the entire 300-W dataset.
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
| {'timestamp': '2017-06-07T02:07:55', 'yymm': '1706', 'arxiv_id': '1706.01820', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01820'} | arxiv |
\section{Introduction}
Animation tools are considered as a basic construct of programming languages. They are used to visualize the execution of a program. They provide users with a simple and intuitive method to debug and trace programs.
This paper presents an extension to Constraint Handling Rules (\textsf{CHR}). The extension adds new visual features to \textsf{CHR}.
It thus enables users to have executions of \textsf{CHR} programs animated.
CHR \cite{chrbook,Fru98} has evolved over the years into a general purpose language. Originally, it was proposed for writing constraint solvers. Due to its declarativity, it has, however, been used with different algorithms such as sorting algorithms, graph algorithms, ... etc. \textsf{CHR} lacked tracing and debugging tools. Users were only able to use SWI-Prolog's textual trace facility as shown in Figure \ref{fig:textualtrace} which is hard to follow especially with big programs.
\begin{figure}[!ht]
\subfloat[Using the normal trace option]{\hbox{\hspace{0cm}\includegraphics[width=100mm]{new_trace.png}}}
\\\subfloat[Using the chr\_trace option]{\hbox{\hspace{0cm}\includegraphics[width=100mm]{chr_trace_new.png}}}
\caption{Current Tracing Facilities in SWI-Prolog.}
\label{fig:textualtrace}
\end{figure}
{Two types of visual facilities are important for a \textsf{CHR} programmer/beginner. Firstly, the programmer would like to get a visual trace showing which \textsf{CHR} rule gets applied at every step and its effect.
Secondly, since \textsf{CHR} has developed into a general purpose language, it has been used with different types of algorithms such as sorting and graph algorithms. It is thus important to have a visual facility to animate the execution of the algorithms rather than just seeing the rules being executed.}
{\textsf{CHR} lacked such a tool. The tool should be able to adapt with the execution nature of \textsf{CHR} programs where constraints are added and removed continuously from the constraint store.}
Several approaches have been devised for visualizing \textsf{CHR} programs and its execution. In \cite{Abdennadher01avisualization}, a tool called \emph{VisualCHR} was proposed. VisualCHR allows its users to visually debug constraint solving. The compiler of JCHR \cite{schmauss_jack:jchr_1999} (on which VisualCHR is based) was modified. The visualization feature was thus not available for Prolog versions, the more prominent implementation of CHR.
\cite{DBLP:conf/iclp/AbdennadherS12} introduced a tool for visualizing the execution of \textsf{CHR} programs. It was able to show at every step the constraint store and the effect of applying each \textsf{CHR} rule in a step-by-step manner. The tool was based on the SWI-Prolog implementation of CHR. Source-to-source transformation was used in order to eliminate the need of doing any changes to the compiler. The tool could thus be deployed directly by any user. Source-to-source transformation is able to convert an original program automatically to a new one with the new features.
Despite of the availability of such visualization tools, \textsf{CHR} was still missing on a system for animating algorithms. The available tools were able to show at each point in time the executed rule and the status of the constraint store. However, the algorithm implemented had no effect on the produced visualization.
Existing algorithm animation tools were either not generic enough or could not be adopted with \textsf{CHR}. For example, one of the available tools is XTANGO \cite{Stasko:xtango} which is a general purpose animating system supporting the development of algorithm
animations. However, the algorithm should be implemented in C or another language
such that it produces a trace file to be read by a C program driver making it difficult to use with \textsf{CHR}.
Due to the wide range of algorithms implemented through \textsf{CHR}, an algorithm-based animation was needed. Such animation should show at each step in time the changes to the data structure affected by the algorithm.
{The paper presents a different direction for animating \textsf{CHR} programs.
It allows users to animate any kind of algorithm implemented in \textsf{CHR}.
This direction thus augments \textsf{CHR} with an animation extension.
As a result, it allows a \textsf{CHR} programmer to trace the program from an algorithmic point of view independent of the details of the execution of its rules.
The formal analysis of the new extension is presented in the paper.
The paper thus presents a new operational semantics of \textsf{CHR} that embeds visualization into its execution.
The formalism is able to capture not only the behavior of the \textsf{CHR} rules, it is also able to represent the graphical objects associated with the animation.
It is used to prove the correctness of the programs extended with animation features.
To eliminate the need of users learning the new syntax for using the extension, a transformation approach is also provided.
The correctness of the transformation approach is presented in the paper too.
}
The paper is organized as follows: Section \ref{sec:chr} introduces CHR. It starts with its syntax. It then shows two examples to show how \textsf{CHR} operates. The theoretical operational semantics is given in Section \ref{sec:theorsem}. The refined operational semantics is then introduced in Section \ref{sec:refined}. Section \ref{sec:chrvis} introduces the new extension. The section starts by giving a general introduction. The syntax of annotation rules is then discussed and two examples are given. Finally, in Section \ref{sec:form} the formalization is given by introducing $\omega_{vis}$, a new operational semantics for \textsf{CHR} that accounts for annotation rules. The basic transitions include ones for simple constraint annotations. Afterwards, a more general semantics including rule annotations is presented. The separation was done to build the general semantics in an easy to follow method. Proofs of soundness and completeness are given.
Section \ref{sec:trans} presents a transformation approach that is able to transform normal \textsf{CHR} programs to $CHR^{vis}$ programs.
Section \ref{sec:app} introduces some applications that were built using $CHR^{vis}$. Conclusions and directions for future work are presented at the end of the paper.
\section{Constraint Handling Rules}
\label{sec:chr}
CHR was initially developed for writing constraint solvers \cite{chrbook,Fru98}.
The rules of a \textsf{CHR} program keeps on rewriting the constraints in the constraint store until a fixed point is reached. At that point no \textsf{CHR} rules could be applied. The constraint store is initialized by the constraints in the query of ths user.
\textsf{CHR} has implementations in different languages such as Java, C and Haskell. The most prominent implementation, however, is the Prolog one. A \textsf{CHR} program has two types of constraints: user-defined/\textsf{CHR} constraints and built-in constraint. \textsf{CHR} constraints are defined by the user at the beginning of a program. Built-in constraints, on the other hand, are handled by (the constraint theory $\mycal{CT}$) of the host language.
A \textsf{CHR} program consists of a set of, ``simpagation rules". A simpagation rule has the following format:
\begin{Verbatim}
optional_rule_name @ H_k \ H_r <=> G | B.
\end{Verbatim}
\(H_{k}\) and \(H_{r}\) represent the head of the rule. The body of the rule is \(B\). The guard \(G\) represents a precondition for applying the rule. A rule is only applied if the constraint store contains constraints that match the head of the rule and if the guard is satisfied. As seen from the previous rule, the head has two parts: \(H_{k}\) and \(H_{r}\). The head of a rule could only contain \textsf{CHR} constraints. The guard should consist of built-in constraints. The body, on the other hand, can contain \textsf{CHR} and built-in constraints. On applying the rule, the constraints in \(H_{k}\) are kept in the constraint store. The constraints in \(H_{r}\) are removed from the constraint store. The body constraints are added to the constraint store.
There are two special kinds of \textsf{CHR} rules: propagation rules and simplification rules. A propagation rule has an empty \(H_{r}\) thus such a rule does not remove any constraint from the constraint store.
It has the following format:
\begin{Verbatim}[commandchars=\\\{\}]
optional\_rule\_name @ H_{k}\; ==> G | B.
\end{Verbatim}
A simplification rule on the other hand has an empty \(H_{k}\). A simplification rule removes all the head constraints from the constraint store.
A simplification rule has the following format:
\begin{Verbatim}[commandchars=\\\{\}]
optional\_rule\_name @ H_{r} <=> G | B.
\end{Verbatim}
\subsection{Examples}
This section introduces examples of \textsf{CHR} programs. Because of the declarativity of \textsf{CHR} and its rules, it is possible to implement different algorithms with single-ruled programs. The first program shows a sorting algorithm. The second program (consisting of two rules) aims at finding the minimum number out of a set of numbers.
\subsubsection{Extracting the Minimum Number}
\label{subsec:extractingmin}
\(\)\\The following program extracts the minimum number out of a set of numbers.
Each number is represented by a \verb+min/1+ The rule \verb+get_min+ is a simpagation \textsf{CHR} rule. It is applied whenever there are two numbers \verb+X+ and \verb+Y+ such that \verb+X+ is less than \verb+Y+.
The rule removes the bigger number, \verb+Y+, from the constraint store. The smaller number, \verb+X+, is kept in the constraint store. Thus, similar to the previous program, when the rule is no longer applicable, a fixed point is reached. By then, the constraint store would only contain the smallest number.
The rule \verb+remove_dup+ is used to remove identical copies of the same number. The rule is thus fired if the user entered a sequence of numbers that contains duplicates.
\begin{verbatim}
:-chr_constraint min/1.
remove_dup @ min(X) \ min(X) <> true.
get_min @ min(X) \ min(Y) <=> X<Y | true.
\end{verbatim}
The following example shows the steps taken to find the minimum number out of the set: \verb+8+, \verb+3+ and \verb+1+.
\begin{center}
\(\underline{min\left(8\right),min\left(3\right)}, min\left(1\right)\)
\\\(\Downarrow\)\\
\( \underline{min\left(3\right), min\left(1\right)}\)
\\\(\Downarrow\)\\
\(min\left(1\right)\)
\end{center}
\subsubsection{Sorting an Array}
\label{sec:sorting}
\(\)\\The program aims at sorting numbers in an array/list. Each number is represented by the constraint \verb+cell(I,V)+. \verb+I+ represents the index and \verb+V+ represents the value of the element. The program contains one rule: \verb+sort_rule+. It is applied whenever the constraint store contains two \verb+cell+ constraints representing two unsorted elements. The guard makes sure that the two elements are not sorted with respect to each other. The element at index \verb+I1+ has a value (\verb+V1+) that is greater than the value (\verb+V2+) of the element at index \verb+I2+. \verb+I1+ is less than \verb+I2+. Thus, \verb+V1+ precedes \verb+V2+ in the array despite of the fact that it is greater than it. Since \verb+sort_rule+ is a simplification rule, the two constraints representing the unsorted elements are removed from the constraint store. Two \verb+cell+ constraints are added through the body of the rule to represent the performed swap to sort the two elements. The program is shown below:
\begin{verbatim}
:-chr_constraint cell/2.
sort_rule @ cell(In1,V1), cell(In2,V2) <=> In1<In2,V1>V2 |
cell(In2,V1), cell(In1,V2).
\end{verbatim}
Successive applications of the rule makes sure that any two elements that are not sorted with respect to each other are swapped. The fixed point is reached whenever \verb+sort_rule+ is no longer applicable. At this point, the array is sorted.
\\The following shows how the query \verb+cell(0,7), cell(1,6), cell(2,4)+ affects the constraint store:\footnote{The examples in this section are running with the refined operational semantics $\omega_{r}$ explained later. For simplicity, Some details are omitted.}
\begin{center}
\(\underline{cell\left(0,7\right), cell\left(1,6\right)}, cell\left(2,4\right)\)
\\\(\Downarrow\)\\
\(cell\left((1,7\right), \underline{cell\left((0,6\right), cell\left((2,4\right)}\)
\\\(\Downarrow\)\\
\(\underline{cell\left((1,7\right), cell\left((2,6\right)}, cell\left((0,4\right)\)
\\\(\Downarrow\)\\
\(cell\left((2,7\right), cell\left((1,6\right), cell\left((0,4\right)\)
\end{center}
\subsection{Theoretical Operational Semantics $\omega_{t}$}
\label{sec:theorsem}
A \textsf{CHR} state is represented by the tuple $\langle G,S,B,T\rangle^{V}_{n}$ \cite{chrbook,TLP:7834577}. $G$ represents the goal store. It initially contains the query of the user. $S$ is the \textsf{CHR} constraint store containing the currently available \textsf{CHR} constraints. $B$, on the other hand, is the built-in store with the built-ins handled by the host language (Prolog in this case). The propagation history, $T$, holds the names of the applied \textsf{CHR} rules along with the IDs of the \textsf{CHR} constraints that activated the rules. $T$ is used to make sure a program does not run forever. Each \textsf{CHR} constraint is associated with an ID. $n$ represents the next available ID. $V$ represents the set of global variables. Such variables are the ones that exist in the initial query of the user. $V$ does not change during execution, it is thus omitted throughout the rest of the paper.
\\A variable $v \notin V$ is called a local variable \cite{raiserequiv}.
\begin{definition}
The function \verb+chr+ is defined such that \verb+chr(c#n)+ = \verb+c+. It is extended into sequences and sets of \textsf{CHR} constraints. Likewise, the function \verb+id+ is defined such that \verb+id(c#n)+ = \verb+n+. It is also extended into sequences and sets of \textsf{CHR} constraints.
\end{definition}
\begin{definition}
$vars\left(A\right)$ denote the variables occurring in $A$.
$\mathop{\exists}\limits^{-}{}_{A}F$ denotes $\exists X_1,\ldots \exists X_n F$ where vars(A) $\backslash$ vars(F) = $\{X_1,\ldots,X_n\}$ \cite{DBLP:conf/ppdp/KoninckSD07,DBLP:conf/iclp/DuckSBH04}
\end{definition}
Table \ref{table:omegat} shows the transitions of $\omega_{t}$ (from \cite{chrbook})
The transitions are presented below:
\setlength{\textfloatsep}{0cm}
\setlength{\abovecaptionskip}{0cm}
\begin{table}[ht]
\begin{tabular}{l}
\hline
1. \textbf{Solve}
: $\langle\{c\} \uplus G, S,B,T\rangle_{n} \mapsto_{solve} \langle G,S,B',T\rangle_{n}$
\\given that $c$ is a built-in constraint and $\mycal{CT} \models \forall((c\wedge B \leftrightarrow B'))$\\
\hline
2. \textbf{Introduce}
: $\langle\{c\} \uplus G, S,B,T>_{n} \mapsto_{introduce} \langle G,S \cup \{c\#n\},B,T\rangle_{n+1}$
\\given that $c$ is a \textsf{CHR} constraint.\\
\hline
3. \textbf{Apply}
: $\langle G, H_{k}\uplus H_{r}\uplus S,B,T\rangle_{n} \mapsto_{apply}$
\\$\langle C \uplus G , H_{k}\cup S ,$
%
{$chr\left(H_{k}\right)=(H'_{k})\wedge chr\left(H_{r}\right)=(H'_{r})
\wedge g \wedge B$} $,T \cup \{ \langle r,id\left(H_{k}\right) + id\left(H_{r}\right) \rangle \}\rangle_{n}$ \\
where
{there is a renamed rule in $P$ with variables $x'$ with the form}\\
$r\; @\; H'_{k}\;\backslash \; H'_{r} \Leftrightarrow \; g \; | \; C.$\\
such that
{$ \mycal{CT} \models \exists(B) \wedge \forall (B \implies \exists x'($
$chr\left(H_{k}\right)=(H'_{k})\wedge chr\left(H_{r}\right)=(H'_{r}) \wedge g))$}
\\{and $\langle r,id\left(H_{k}\right) + id\left(H_{r}\right) \rangle\notin T$}
\\\hline
\end{tabular}
\caption{Transitions of $\omega_{t}$}
\label{table:omegat}
\end{table}
\\\textbf{Solve}
\\The transition \emph{solve}, adds the built-in constraint $c$, in the goal store, to the built-in constraint store. The new built-in store is basically $B \wedge c$. The new store is also simplified.
\\\\\textbf{Introduce}
\\ Similarly, \emph{Introduce}, adds a \textsf{CHR} constraint ($c$) to the \textsf{CHR} constraint store. The ID of the constraint is $n$. The next available ID is $n+1$. The new \textsf{CHR} store is $S \cup \{c\#n\}$.
\\\\\textbf{Apply}
\\The \emph{Apply} transition executes an available \textsf{CHR} rule \verb+r+.
When a rule is used, its variables are renamed apart from the program and the current state \cite{chrbook}. The fresh variant of the rule with variables the new variables $x'$: $r\; @\; H'_{k}\;\backslash \; H'_{r} \Leftrightarrow \; g \; | \; C$ is executable under
the applicability condition: {$ \mycal{CT} \models \exists(B) \wedge \forall (B \implies \exists x'($
$chr\left(H_{k}\right)=(H'_{k})\wedge chr\left(H_{r}\right)=(H'_{r}) \wedge g))$}.
It first checks the built-in constraint store $B$ for satisfiablity. The rule is also only applied if the \textsf{CHR} constraint store contains matching constraints through the checks $chr\left(H_{k}\right)=(H'_{k})\wedge chr\left(H_{r}\right)=(H'_{r})$.
Under the matching, the guard $g$ is also checked. It has to be logically entailed by the built-in constraints $B$ under the constraint theory $\mycal{CT}$ \cite{chrbook}.
To apply the rule, the propagation history should not contain a tuple representing the same constraints associated with the same rule signifying that this is the first time this rule is applied with those constraint(s).
The constraints in the body are added to the goal. In addition, the propagation history is updated accordingly.
Table \ref{tab:tableexamplewt} shows the query $min\left(20\right),min\left(8\right),min\left(1\right)$ executed under $\omega_{t}$ for the program shown in Section \ref{subsec:extractingmin}
\begin{table}[h]
\begin{tabular}{ l l p{7cm} }
& $ \langle \{min\left(20\right),min\left(1\right),min\left(8\right)\},\phi \rangle_{1}$ & \(\) \\
$ \xmapsto[\text{introduce}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \{min\left(1\right),min\left(8\right)\},\{min\left(20\right)\#1\} \rangle_{2}$ & The constraint $min\left(20\right)$ is introduced to the constraint store. \\
$ \xmapsto[\text{introduce}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \{min\left(8\right)\},\{min\left(20\right)\#1,min\left(1\right)\#2\} \rangle_{3}$ & The constraint $min\left(1\right)$ is introduced to the store. \\
$ \xmapsto[\text{apply}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \{min\left(8\right)\},\{min\left(1\right)\#2\} \rangle_{3}$ & The rule \verb+remove_min+ is fired removing \verb+min(20)+ from the constraint store. \\
$ \xmapsto[\text{introduce}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \{\},\{min\left(1\right)\#2,min\left(8\right)\#3\} \rangle_{4}$ & The constraint $min\left(8\right)$ is introduced to the store. \\
$ \xmapsto[\text{apply}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \{\},\{min\left(1\right)\#2\} \rangle_{4}$ & The rule \verb+remove_min+ is fired removing \verb+min(8)+ from the constraint store. \\
\hline
\end{tabular}
\caption{Query $min\left(20\right),min\left(8\right),min\left(1\right)$ running under $w_t$}
\label{tab:tableexamplewt}
\end{table}
\subsection{Refined Operational Semantics $\omega_{r}$}
\label{sec:refined}
The refined operational semantics \cite{refined,chrbook} is adapted in most implementations of \textsf{CHR}. It removes some of the sources of the non-determinism that exists in $w_{t}$. In $w_{t}$ the order in which constraints are processed and the order of rule application in non-deterministic. However, in $w_{r}$, rules are executed in a top-down manner. Thus, in the case where there are two matching rules , $w_{r}$ ensures that the rule that appears on top in the program is executed. Details of how $w_{r}$ works are shown in this section.
Each atomic head constraint is associated with a number (occurrence). Numbering starts from $1$. It follows a top-down approach as well.
For example the previously shown program to find the minimum value is numbered as follows:
\begin{verbatim}
remove_dup @ min(X)_2\min(X)_1<=>true.
remove_min @ min(X)_4\min(Y)_3<=>X<Y | true.
\end{verbatim}
\begin{definition}
The active/occurrenced constraint c\#i:j refers to a numbered constraint that should only match with occurrence j of the constraint c inside the program. $i$ is the identifier of the constraint \cite{refined}.
\end{definition}
A state in $w_{r}$ is the tuple $<A,S,B,T>_{n}$. Unlike $w_{t}$, the goal $A$ is a stack instead of a multi-set. $S,B, T$ and $n$ have the same interpretation as an $w_{t}$ state.
In the refined operational semantics, constraints are executed similar to procedure calls. Each constraint added to the store is activated. An active constraint searches for an applicable rule. The rule search is done in a top-down approach. If a rule matches, the newly added constraints (from the body of the applied rule) could in turn fire new rules. Once all rules are fired, execution resumes from the same point.
Constraints in the constraint store are reconsidered/woken if a newly added built-in constraint could affect them (according to the wakeup policy).
An active constraint thus tries to match with all the rules in the program
Table \ref{table:omegaref} shows the transitions of $w_{r}$.
\setlength{\textfloatsep}{0cm}
\setlength{\abovecaptionskip}{0cm}
\begin{table}[!ht]
\begin{tabular}{l}
\hline
\\
1. \textbf{Solve+wakeup}
: $\langle \left[c|A\right], S_{0}\uplus S_{1},B,T\rangle_{n}
\mapsto_{solve+wake}
\langle S_{1}++A, S_{0}\uplus S_{1},B',T\rangle_{n}$
\\given that $c$ is a built-in constraint and $\mycal{CT} \models \forall((c\wedge B \leftrightarrow B'))$\\
and $wakeup\left(S_{0}\uplus S_{1} ,c,B\right) = S_{1}$ \\\\
\hline
\\2. \textbf{Activate}
$\langle \left[c|A\right], S,B,T\rangle_{n}
\mapsto_{activate}
\langle \left[c\#n:1|A\right], {c\#n} \cup S,B,T\rangle_{n+1}
$
\\given that $c$ is a \textsf{CHR} constraint.
\\
\\\hline
\\3. \textbf{Reactivate}
$\langle \left[c\#i|A\right], S,B,T\rangle_{n}
\mapsto_{reactivate}
\langle \left[c\#i:1|A\right], S,B,T\rangle_{n}
$
\\given that $c$ is a \textsf{CHR} constraint.
\\
\\\hline
\\4. \textbf{Apply}
$\langle \left[c\#i:j|A\right], H_1 \uplus H_2 \uplus S,B,T\rangle_{n}
\mapsto_{apply\;r}$
\\$\langle C + H + A, H_1 \cup S,$
{$chr\left(H_{1}\right)=(H'_{1})\wedge chr\left(H_{2}\right)=(H'_{2})
\wedge g \wedge B$} $,
T \cup \{\left(r,id\left(H_1\right)+id\left(H_2\right)\right)\}\rangle_{n}
$
\\given that the jth occurrence of $c$ is part of the head of the re-named apart rule with variables $x'$:
\\{\(r\; @\; H'_1\; \backslash \;H'_2 \; \Leftrightarrow \;g \;|\; C.\)}
\\{where $ \mycal{CT} \models \exists(B) \wedge \forall(B \implies \exists x'\left(\left(chr\left(H_1\right)=(H'_1) \wedge chr\left(H_2\right)=(H'_2)\wedge g\right)\right)$}
\\and $\left(r,id\left(H_1\right)+id\left(H_2\right)\right) \notin T$.
\\If $c$ occurs in $H'_1$ then $H=\left[c\#i:j\right]$ otherwise $H=\left[\right]$.
\\
\\\hline
\\5. \textbf{Drop}
\\
$\langle \left[c\#i:j|A\right], S,B,T\rangle_{n}
\mapsto_{drop}
\langle A, S,B,T\rangle_{n}
$
\\given that $c\#i:j$ is an occurrenced active constraint and $c$ has no occurrence $j$ in the program.
\\That could thus imply that all existing occurrences were tried before.
\\
\\\hline
\\
6. \textbf{Default}
$\langle \left[c\#i:j|A\right], S,B,T\rangle_{n}
\mapsto_{default}
\langle \left[c\#i:j+1|A\right], S,B,T\rangle_{n}
$
\\
in case there is no other applicable transition.
\\\\
\hline
\end{tabular}
\caption{Transitions of $\omega_{r}$}
\label{table:omegaref}
\end{table}
\subsubsection{Solve+Wake}
\(\)\\This transition introduces a built-in constraint $c$ to the built-in store. In addition, all constraints that could be affected by $c$ ($S{1}$) are woken up by adding them on top of the stack. These constraints are thus re-activated. A constraint where all its terms have become ground will not be thus woken up by the implemented wake-up policy since it is never affected by a new built-in constraint.
$vars\left(S_{0}\right) \subseteq fixed\left(B\right)$ where $fixed\left(B\right)$ represents the variables fixed by $B$.
\subsubsection{Activate}
\(\)\\This transition introduces a \textsf{CHR} constraint into the constraint store and activates it. The introduced constraint has the occurrence value $1$ as a start.
\subsubsection{Reactivate}
\(\)\\The reactivate transition considers a constraint that was already added to the store before. It became re-activated and was added to the stack. The transition activates the constraint by associating it with an occurrence value starting with $1$.
\subsubsection{Apply}
\(\)\\This transition applies a \textsf{CHR} rule $r$ if an active constraint matched a constraint in the head of $r$ with the same occurrence number.
If the matched constraint is part of the constraints to be removed, it is also removed from the stack. Otherwise, it is kept in the constraint store and the stack.
\subsubsection{Drop}
\(\)\\This transition removes the active constraint $c\#i:j$ from the stack when there no more occurrences to check. This occurs when the occurrence number of the active constraint does not appear in the program. In other words, the existing ones were tried
\subsubsection{Default}
\(\)\\This transition proceeds to the next occurrence of the constraint if the currently active one could not be matched with the associated rule. This transition ensures that all occurrences are tried.
\subsubsection{Running Example}
\(\)\\In the beginning of the section, a \textsf{CHR} program to find the minimum number among a set of numbers was given. The program was written with the numbered constraint occurrences as used by $\omega_{r}$. For the query min(20),min(1),min(8), the steps shown in Table \ref{tab:table1} take place.
\begin{table}[h]
\begin{tabular}{ l l p{5cm} }
& $ \langle \left[min\left(20\right),min\left(1\right),min\left(8\right)\right],\phi \rangle_{1}$ & \(\) \\
$ \xmapsto[\text{activate}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(20\right)\#1:1,min\left(1\right),min\left(8\right)\right],\{min\left(20\right)\#1:1\} \rangle_{2}$ & The constraint $min\left(20\right)$ is activated. \\
$ \xmapsto[\text{default}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(20\right)\#1:2,min\left(1\right),min\left(8\right)\right],\{min\left(20\right)\#1:1\} \rangle_{2}$ & The active constraint did not fire any rule so the occurrence number is incremented. \\
$ \xmapsto[\text{default}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(20\right)\#1:2,min\left(1\right),min\left(8\right)\right],\{min\left(20\right)\#1:1\} \rangle_{2}$ & The occurrence number is incremented. \\
$ \xmapsto[\text{default}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(20\right)\#1:3,min\left(1\right),min\left(8\right)\right],\{min\left(20\right)\#1:1\} \rangle_{2}$ & The occurrence number is incremented. \\
$ \xmapsto[\text{default}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(20\right)\#1:4,min\left(1\right),min\left(8\right)\right],\{min\left(20\right)\#1:1\} \rangle_{2}$ & The occurrence number is incremented. \\
$ \xmapsto[\text{default}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(20\right)\#1:5,min\left(1\right),min\left(8\right)\right],\{min\left(20\right)\#1:1\} \rangle_{2}$ & The occurrence number is incremented. \\
$ \xmapsto[\text{drop}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(1\right),min\left(8\right)\right],\{min\left(20\right)\#1:1\} \rangle_{2}$ & The occurrence $5$ does not appear in the program. Thus, $min\left(20\right)\#1:5$ is dropped. \\
$ \xmapsto[\text{activate}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(1\right)\#2:1,min\left(8\right)\right],\{min\left(20\right)\#1,min\left(1\right)\#2\} \rangle_{3}$ & The occurrence $5$ does not appear in the program. Thus, $min\left(20\right)\#1:5$ is dropped. \\
$ \xmapsto[\text{default}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(1\right)\#2:2,min\left(8\right)\right],\{min\left(20\right)\#1,min\left(1\right)\#2\} \rangle_{3}$ & The occurrence number is incremented. \\
$ \xmapsto[\text{default}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(1\right)\#2:3,min\left(8\right)\right],\{min\left(20\right)\#1,min\left(1\right)\#2\} \rangle_{3}$ & The occurrence number is incremented. \\
$ \xmapsto[\text{default}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(1\right)\#2:4,min\left(8\right) \right],\{min\left(20\right)\#1,min\left(1\right)\#2\} \rangle_{3}$ & The occurrence number is incremented. \\
$ \xmapsto[\text{apply}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(1\right)\#2:4,min\left(8\right)\right],\{min\left(1\right)\#2\} \rangle_{3}$ & Rule \verb+remove_min+ is applied \\
$ \xmapsto[\text{default}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(1\right)\#2:5,min\left(8\right)\right],\{min\left(1\right)\#2\} \rangle_{3}$ & The occurrence number is incremented. \\
$ \xmapsto[\text{drop}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(8\right)\right],\{min\left(1\right)\#2\} \rangle_{3}$ & $min\left(1\right)\#1:5$ is dropped since the occurrence $5$ is never used in the program. \\
$ \xmapsto[\text{activate}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(8\right)\#3:1\right],\{min\left(1\right)\#2,min\left(8\right)\#3\} \rangle_{4}$ & $min(8)$ is activated. \\
$ \xmapsto[\text{default}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(8\right)\#3:2\right],\{min\left(1\right)\#2,min\left(8\right)\#3\} \rangle_{4}$ & The occurrence number is incremented. \\
$ \xmapsto[\text{default}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[min\left(8\right)\#3:3\right],\{min\left(1\right)\#2,min\left(8\right)\#3\} \rangle_{4}$ & The occurrence number is incremented. \\
$ \xmapsto[\text{apply}]{}\mathrel{\vphantom{\to}^*} $ & $
\langle \left[\right],\{min\left(1\right)\#2\} \rangle_{4}$ & Rule \verb+remove_min+ is applied. \\
\hline
\end{tabular}
\caption{Query $min\left(20\right),min\left(8\right),min\left(1\right)$ running under $w_r$}
\label{tab:table1}
\end{table}
\section{$CHR^{vis}$: An Animation Extension for CHR}
\label{sec:chrvis}
The proposed extension aims at embedding visualization and animation features into \textsf{CHR} programs.
The basic idea is that some constraints, the interesting ones, are annotated by visual objects. Thus on adding (removing) such constraints to (from) the constraint store, the corresponding graphical object is added (removed) to (from) the graphical store.
These constraints are thus treated as interesting events.
Interesting constraints are those constraints that directly represent/affect the basic data structure used along the program. Visualizing such constraints thus leads to a visualization of the execution of the corresponding program. In addition, changes in the constraint store affects the data structure and its visualization. This results in an animation of the execution.
For example, in a program to encode the ``Sudoku'' game, the interesting constraints would be those representing the different cells in the board and their values. Another example is a program solving the $n$-queens problem. The program aims at placing $n$ queens on an $n$ $\times$ $n$ board so that the queens cannot attack each other horizontally, vertically or diagonally.
In this case, the interesting constraints are those reflecting the board and the current/possible locations for each of the $n$ queens \cite{DBLP:journals/corr/SharafAF14,DBLP:conf/lopstr/SharafAF14}.
The approach aims at introducing a generic animation platform independent of the implemented algorithm. This is achieved through two features. First, annotation rules are used. The idea of using interesting events for animating programs was introduced before in Balsa \cite{Brown:1984:SAA:800031.808596} and Zeus \cite{DBLP:conf/vl/Brown91}. Both system use the notion of interesting events. However, users need to know many details to be able to use them.
However, $CHR^{vis}$ eliminated the need of the user knowing any details about the animation.
The second feature is outsourcing the animation into an existing visual tool. For proof of concept, Jawaa \cite{DBLP:conf/sigcse/PiersonR98}, was used. Jawaa provides its users with a wide range of basic structures such as a circle, rectangle, line, textual node , ... etc. Users can also apply actions on Jawaa objects such as movement, changing a color , ... etc.
Users are able to write their own $CHR^{vis}$ programs with the syntax discussed later in this section.
However, users are also provided with an interface (as shown in Figure \ref{fig:ann}) that allows them to specify every interesting event/constraint.
In that case, the programs are automatically generated.
\begin{figure}[!ht]
\centering \includegraphics[width=100mm]{annotatinFrame3}
\caption{Annotating the cell/2 constraint}
\label{fig:ann}
\end{figure}
They are then able to choose the visual object/action (from the list of Jawaa objects/actions) to link the constraint to. Once they make a choice, the panel is populated with the corresponding parameters. Parameters represent the visual properties of the object such as: color, x-coordinate, ... etc. Users have to specify a value for each parameter. A value could be:
\begin{enumerate}
\item a constant value e.g. \verb+100+, \verb+blue+, ... etc.
\item the function \verb+valueOf/1+. valueOf(X) outputs the value of the argument \verb+X+ such that \verb+X+ is one of the arguments of the interesting constraint.
\item the function \verb+prologValue/1+. prologValue(Exp) outputs the value of the argument ``\verb+X+'' computed through the mathematical expression \verb+Exp+.
\item {The keyword} \verb+random+ {that generates a random number}.
\end{enumerate}
\subsection{Extended Programs}
This section introduces the syntax of the \textsf{CHR} programs that are able to produce animations on execution.
In addition to the basic constructs of a \textsf{CHR} program, the extended version needs to specify:
\begin{enumerate}
\item The graphical objects to be used throughout the programs.
\item The interesting constraints and their association with graphical objects.
\item {Whether the head constraints are to be communicated to the tracer.}
\\{In case, the head constraints are communicated, every time a constraint is removed from the store, its} \\{associated visual object is also removed. In some of the cases, this will not be necessary as seen in the below} \\{examples.}
\end{enumerate}
\subsubsection{Syntax of $CHR^{vis}$}
\(\)\\The annotation rules that associate \textsf{CHR} constraint(s) with objects have the following format:
\[
g\;optional\_rule\_name\;H_{vis}\;\Rightarrow\;condition\;|\;graphical\_obj\_name\left(par_{1},par_{2},\ldots,par_{n}\right).
\]
\(H_{vis}\) contains either one interesting constraint or a group of interesting constraints that are associated with a graphical object. Similar to normal \textsf{CHR} rules, graphical annotation rules could have a pre-condition that has to be satisfied for the rule to be applied. The literal $g$ is added at the beginning of the rule to differentiate between \textsf{CHR} and annotation rules.
A $CHR^{vis}$ program thus has two types of rules. There are the normal \textsf{CHR} rules and the annotation rules responsible for associating \textsf{CHR} constraint(s) with graphical object(s).
Moreover there are meta-annotation rules that associate \textsf{CHR} rules with graphical object(s).
In this case, instead of associating \textsf{CHR} constraint(s) with visual object(s), the association is for a \textsf{CHR} rule. In other words, once such rule is executed the associated visual objects are produced. The association is thus done with the execution of the rule rather than the generation of a new \textsf{CHR} constraint. The rule annotation is done through associating a rule with an auxiliary constraint. The auxiliary constraint has a normal constraint annotation rule with the required visual object.
Such meta-annotation rule has the following format:
\[
g\;optional\_rule\_name\;chr\_rule\_name\;\Rightarrow\;condition\;| \; aux\_constraint\left(par_{1_{aux}},\ldots, par_{m_{aux}}\right).
\]
\[
g\;aux\_constraint\left(par_{1_{aux}},\ldots, par_{m_{aux}}\right) \;\Rightarrow\ \;graphical\_obj\_name\left(par_{1},par_{2},\ldots,par_{n}\right).
\]
{In addition, a rule for} \verb+comm_head/1+ {has to be added in the} $CHR^{vis}$ {program.}
\\\verb+(comm_head(T) ==> T=true.)+ {means that head constraints are to be communicated to the tracer.}
\\\verb+(comm_head(T) ==> T=false.)+ {means that the removed head constraints should not affect the visualization.}
\subsubsection{Examples}
\(\)\\The program provided in Section \ref{sec:sorting} aims at sorting an array of numbers. In order to animate the execution, we need to visualize the elements of the array. Changes of the elements lead to a change in the visualization and thus animating the algorithm.
The interesting constraint in this case is the \verb+cell+ constraint. As shown in Figure \ref{fig:ann}, it was associated with a rectangular node whose height is a factor of the value of the element. The x-coordinate is a factor of the index. That way, the location and size of a node represent an element of the array.
\fvset{commandchars=\\\{\}}
The new $CHR^{vis}$ program is:
\begin{Verbatim}
:-chr_constraint cell/2.
:-chr_constraint comm_head/1.
{comm_head(T) ==> T=true.}
sort_rule @ cell(In1,V1), cell(In2,V2) <=> In1<In2,V1>V2 |
cell(In2,V1), cell(In1,V2).
g ann_rule_cell cell(Index,Value) ==> node(valueOf(Value),valueOf(Index)*12+2,
50,10,valueOf(Value)*5 ,1,valueOf(Value),
black, green, black, RECT).
\end{Verbatim}
Figure \ref{fig:sorting1} shows the result of running the query \verb+cell(0,7),cell(1,6),cell(2,4)+.
As shown from the taken steps, each number added to the array and thus to the constraint store adds a corresponding rectangular node.
Once \verb+cell(0,7)+ and \verb+cell(1,6)+ are added to the constraint store, the rule \verb+sort_rule+ is applicable. Thus, the two constraints are removed from the store. The rule adds \verb+cell(1,7)+ and \verb+cell(0,6)+ to the constraint store.
\begin{figure}[!ht]
\centering
\subfloat[adding cell(0,7), cell(1,6) to the store]{\hbox{\hspace{2cm}\includegraphics[width=10mm]{step1.png}}}
\subfloat[removing cell(0,7), cell(1,6) from the store]{\hbox{\hspace{2cm}\includegraphics[width=10mm]{step2.png}}}
\hbox{\hspace{2cm}\subfloat[adding cell(1,7), cell(0,6) to the store]{\includegraphics[width=10mm]{step3.png}}}
\hbox{\hspace{2cm}\subfloat[adding cell(2,4) to the store]{\includegraphics[width=10mm]{step4.png}}}
\hbox{\hspace{2cm}\subfloat[removing cell(0,6) and cell(2,4) to the store]{\includegraphics[width=10mm]{step5.png}}}
\hbox{\hspace{2cm}\subfloat[adding cell(2,6)]{\includegraphics[width=10mm]{step6.png}}}
\hbox{\hspace{2cm}\subfloat[removing cell(1,7),cell(2,6)]{\includegraphics[width=10mm]{step7.png}}}
\hbox{\hspace{2cm}\subfloat[adding cell(2,7),cell(1,6) and cell(0,4)]{\includegraphics[width=10mm]{step8.png}}}
\caption{Sorting an array of numbers.}
\label{fig:sorting1}
\end{figure}
Afterwards, \verb+cell(2,4)+ is added to the store. At this point \verb+cell(0,6)+ and \verb+cell(2,4)+ activate \verb+sort_rule+ and are removed from the constraint store. The rule first adds \verb+cell(2,6)+ to the store. At this point \verb+cell(1,7)+ and \verb+cell(2,6)+ activate \verb+sort_rule+ again. Thus they are both removed from the store. The constraints \verb+cell(2,7), cell(1,6)+ are added. Afterwards, the last constraint \verb+cell(0,4)+ is added to the store.
As seen from Figure \ref{fig:sorting1}, using annotations for constraints has helped animate the execution of the sorting algorithm. However, in some of the steps, it might not have been clear which two numbers are being swapped.
In that case it would be useful to use an annotation for the rule \verb+sort_rule+ instead of only annotating the constraint \verb+list+. The resulting program looks as follows:
\begin{Verbatim}
:-chr_constraint cell/2.
:-chr_constraint comm_head/1.
{comm_head(T) ==> T=false.}
sort_rule @ cell(In1,V1), cell(In2,V2) <=> In1<In2,V1>V2 |
cell(In2,V1), cell(In1,V2), swap(In1,V1,In2,V2).
g ann_rule_cell cell(Index,Value) ==> node(nodevalueOf(Value),valueOf(Index)*12+2,50,10,
valueOf(Value)*5 , 1, valueOf(Value), black,
green, black, RECT).
g swap(In1,V1,In2,V2) ==> changeParam(nodevalueOf(V1),bkgrd,pink)
g swap(In1,V1,In2,V2) ==> changeParam(nodevalueOf(V2),bkgrd,pink)
g swap(In1,V1,In2,V2) ==> moveRelative(nodevalueOf(V1),
(valueOf(I2)-valueOf(I1))*12,0)
g swap(In1,V1,In2,V2) ==> moveRelative(nodevalueOf(V2),
(valueOf(I2)-valueOf(I1))*(-12),0)
g swap(In1,V1,In2,V2) ==> changeParam(nodevalueOf(V1),bkgrd,green)
g swap(In1,V1,In2,V2) ==> changeParam(nodevalueOf(V2),bkgrd,green)
g sort_rule ==> swap(In1,V1,In2,V2).
\end{Verbatim}
The annotations make sure that once two numbers are swapped, they are first marked with a different color (pink in this case).
The two rectangular bars are then moved. The bar on the left is moved to the right. The bar on the right is moved to the left (negative displacement). The space between the start of one node and the start of the next node is 12 pixels. Thus the displacement is calculated as the difference between the two indeces multiplied by 12. After the swap is done, the two bars are colored back into green.
The result of executing the query: \verb+cell(0,7),cell(1,6),cell(2,4)+ is shown in Figure \ref{fig:sorting2}.
\begin{figure}[!ht]
\centering
\subfloat[after adding cell(0,7), cell(1,6) to the store, they are marked to be swapped]{\hbox{\hspace{2cm}\includegraphics[width=10mm]{pink5.png}}}
\subfloat[swapping 7 and 6]{\hbox{\hspace{2cm}\includegraphics[width=10mm]{pink6.png}}}
\subfloat[7 and 6 are swapped]{\hbox{\hspace{2cm}\includegraphics[width=10mm]{pink7.png}}}
\hbox{\hspace{2cm}\subfloat[cell(2,4) is added]{\includegraphics[width=10mm]{pink8.png}}}
\hbox{\hspace{2cm}\subfloat[6 and 4 are marked to be swapped]{\includegraphics[width=10mm]{pink9.png}}}
\hbox{\hspace{2cm}\subfloat[swapping 4 and 6]{\includegraphics[width=10mm]{pink10.png}}}
\hbox{\hspace{2cm}\subfloat[7 and 6 are marked to be swapped]{\includegraphics[width=10mm]{pink11.png}}}
\hbox{\hspace{2cm}\subfloat[swapping 7 and 6]{\includegraphics[width=10mm]{pink12.png}}}
\hbox{\hspace{2cm}\subfloat[final sorted list]{\includegraphics[width=10mm]{pink13.png}}}
\caption{Sorting an array of numbers through a rule annotation.}
\label{fig:sorting2}
\end{figure}
\subsection{Animation Formalization}
\label{sec:form}
The rest of the section offers a formalization of the animation to be able to run $CHR^{vis}$ programs and reason about their correctness. The basic idea is introducing a new ``graphical" store.
$CHR^{vis}$ adds, besides the classical constraint store of \textsf{CHR}, a new store called the graphical store. As implied by the name, the graphical store contains graphical/visual objects. Such objects are the visual mappings of the interesting constraints.
Over the course of the program execution, and as a result of applying the different rules, the constraint store as well as the graphical store change. As introduced before, the change of the visual objects leads to an animation of the program.
\begin{definition}
In $CHR^{vis}$, a state is represented by a tuple $\langle G,S,Gr,B,T,H\_ann \rangle_{n}$. $G$, $S$, $B$, $T$, and $n$ have the same meanings as in a normal \textsf{CHR} state (goal store, \textsf{CHR} constraint store, built-in store, propagation history and the next available identification number). $Gr$ is a store of graphical objects.
$H\_ann$ is the history of the applications of the visual annotation rules.
Each element in $H\_ann$ has the following format: $\langle rule\_name, Head\_ids, Object\_ids\rangle$ where
\begin{itemize}
\item $rule\_name$ represents the name of the fired annotation rule.
\item $Head\_ids$ contain the ids of the head constraints that fired the annotation rule.
\item $Object\_ids$ are the ids of the graphical objects added to the graphical store through firing $rule\_name$ using $Head\_ids$.
\end{itemize}
\end{definition}
\begin{definition}
For a sequence $Sq=\left(c_1\#id_1,\ldots,c_n\#id_n\right)$, the function $get\_constraints\left(Sq\right)=\left(c_1 \ldots,c_n\right)$.
\end{definition}
\begin{definition}
\label{def:seqequiv}
Two sequences $A$ and $B$ are equivalent: $A \;\doteq\;B$ if
\begin{enumerate}
\item For every $X$, if $X$ exists $N$ times in $A$ such that $N>0$, then $X$ exists $N$ times in $B$.
\item For every $Y$, if $Y$ exists $N$ times in $B$ such that $N>0$, then $Y$ exists $N$ times in $A$.
\end{enumerate}
\end{definition}
\begin{definition}
\(\)\\
{{The function} $output\_graphical\_object \left(c\left(Arg_0,\ldots,Arg_n\right), \{Arg'_0,\ldots,Arg'_n\},
output\left(Object,OArg_0,\ldots,
OArg_k \right) \right) \\=graphical\_object\left(Actual_0,\ldots,Actual_k\right)$ such that:}
\begin{itemize}
\item $graphical\_object = Object$.
\item Each parameter $Actual_n=get\_actual\left(OArg_n\right)$ such that
\begin{itemize}
\item if $OArg_n$ is a constant value then $get\_actual\left(OArg_n\right)=OArg_n$.
\item if {$OArg_n=valueOf\left(Arg_m\right)$ then $get\_actual\left(OArg_n\right)=(Arg'_n)$.}
\item if $OArg_n=prologValue\left(Expr\right)$ then $get\_actual\left(OArg_n\right)=X$ where $Expr$ is evaluated in SWI-Prolog and binds the variable $X$ to a value.
\item if $OArg_n=random$ , then $get\_actual\left(OArg_n\right)$ is a randomly computed number.
\end{itemize}
\end{itemize}
\end{definition}
\begin{definition}
\(\)\\The function $update\_graphical\_store\left(\{Obj_1\#id_1,\ldots,Obj_i\#id_i\}, graphical\_action\left(Actual_0,\ldots,Actual_k\right)\right)=$
\[ Each\;Obj_i' =
\begin{cases}
Obj_i' & \quad \text{if } Obj_i \text{ is affected by }graphical\_action\left(Actual_0,\ldots,Actual_k\right)\\
Obj_i & \quad \text{if } Obj_i \text{ is not affected by }graphical\_action\left(Actual_0,\ldots,Actual_k\right)\\
\end{cases}
\]
Any $Obj_i'$ could have a different graphical aspect such as its color, x-coordinate, ... etc.
\begin{comment}
\\$\{Obj_1'\#id_1,\ldots,Obj_i'\#id_i\}$
such that any $gra\_obj_i \; \in \; Gr$ is checked whether it is to be affected by \\$graphical\_action\left(Actual_0,\ldots,Actual_k\right)$ or not. In case, it is to be affected, the new $gra\_obj_i'$ is computed. $gra\_obj'$ could have a different parameter such as the x-coordinate, color, ... etc.
\end{comment}
\end{definition}
\begin{definition}
\(\)\\{The function} ${generate\_new\_ann\_history\left(Graph\_obj,Obj\_id,rule\_name,Head\_id,H\_ann\right)=H'\_ann}$ such that:
in the case where ${\langle rule\_name,Head\_id,Objects\_ids \rangle \in H\_ann}$,
\\${H'\_ann=H\_ann - \langle rule\_name,Head\_id,Objects\_ids \rangle \cup \langle rule\_name,Head\_id,Objects\_ids \cup Obj\_id \rangle }$,
\end{definition}
\begin{definition}
\(\)\\{The function} ${remove\_gr\_obj\left(G\_store,rem\_head\_id,H\_ann\right)=G'\_store}$ such that:
in the case where
\\${\langle rule\_name,head\_ids,Objects\_ids \rangle \in H\_ann} \wedge rem\_head\_id \subseteq head\_ids$,
\\${G\_store=G\_store - \cup_{i} \left(Obj_{i} \;where \;Obj_{i} \in Objects\_ids\right)}
$.
\end{definition}
\begin{definition}
\label{defcont}
\(\)\\The function $contains\left(H\_ann,\langle rule, Head_{ids}\rangle\right)$ is:
\begin{itemize}
\item $true$ in the case where $H\_ann$ contains a tuple of the form $\langle rule, Head_{ids}, Objects \rangle$.
\item $false$ in the case where $H\_ann$ does not contain a tuple of the form $\langle rule, Head_{ids}, Objects \rangle$.
\end{itemize}
\end{definition}
\begin{longtable}{l}
\hline\\
\begin{comment}
1. \textbf{Solve}
: $\langle\{c\} \uplus G, S,Gr,B,T,H\_ann\rangle_{n} \mapsto_{solve} \langle G,S,Gr,B',T,H\_ann\rangle_{n}$
\\given that $c$ is a built-in constraint and $\mycal{CT} \models \forall((c\wedge B \leftrightarrow B'))$\\
\end{comment}
1. \textbf{Solve+wakeup}
: $\langle \left[c|A\right], S_{0}\uplus S_{1},Gr,B,T,H\_ann\rangle_{n}
\mapsto_{solve+wake}
\langle S_{1}++A, S_{0}\uplus S_{1},Gr,B',T,H\_ann\rangle_{n}$
\\given that $c$ is a built-in constraint and $\mycal{CT} \models \forall\left(\left(c\wedge B \leftrightarrow B' \right)\right)$\\
and $wakeup\left(S_{0}\uplus S_{1} ,c,B\right) = S_{1}$ \\
\\\hline\\
2. \textbf{Activate}
$\langle \left[c|A\right], S,Gr,B,T,H\_ann\rangle_{n}
\mapsto_{activate}
\langle \left[c\#n:1|A\right], \{c\#n\} \cup S,Gr,B,T,H\_ann\rangle_{n+1}
$
\\given that $c$ is a \textsf{CHR} constraint.\\
\\\hline\\
3. \textbf{Reactivate}
$\langle \left[c\#i|A\right], S,Gr,B,T,H\_ann\rangle_{n}
\mapsto_{reactivate}
\langle \left[c\#i:1|A\right], S,Gr,B,T,H\_ann\rangle_{n}
$
\\given that $c$ is a \textsf{CHR} constraint.
\\
\\\hline\\
4. \textbf{Draw}
: $\langle \left[{\langle Obj\#
\langle r, id\left(H\right),Obj\_ids\rangle}|A\right], S,Gr,B,T,H\_ann\rangle_{n} \mapsto_{draw} \langle A,S ,Gr\cup {\{Obj\#n\}},B,T,H\_ann'\rangle_{n+1}$ \\given that {$Obj$} is a graphical object: $graphical\_object\left(Actual_0,\ldots,Actual_k\right)$.
\\and${H\_ann'=generate\_new\_ann\_history\left(Obj,n,r,id\left(H\right),H\_ann\right)}$
\\The actual parameters of $graphical\_object$ are used to visually render the object.\\
\\\hline\\
5. \textbf{Update Store}
: $\langle \left[{\langle Obj\#
\langle r, id\left(H\right),Obj\_ids\rangle}|A\right], S,Gr,B,T,H\_ann\rangle_{n} \mapsto_{update store} \langle A,S ,Gr',B,T,H\_ann \rangle_{n}$ \\given that {$Obj$} is a graphical action: $graphical\_action\left(Actual_0,\ldots,Actual_k\right)$.
\\$Gr'=update\_graphical\_store\left(Gr, graphical\_action\left(Actual_0,\ldots,Actual_k\right)\right)$
\\The actual parameters of $graphical\_action$ are used to update the graphical objects.\\
\\\hline\\
6. \textbf{{Apply\_Annotation}}:
\\$\langle \left[c\#i:j|G\right],H \uplus S,Gr,B,T,H\_ann\rangle_{n} \mapsto_{apply\_annotation}$ \\$\langle {\left[Obj\#
\langle r, id\left(H\right),\{\;\}\rangle,
c\#i:j|G\right],}
H \cup S ,Gr ,
B,$
$T , H\_ann \cup \{ \langle r, id\left(H\right),\{\} \rangle \} \rangle_{n}$
where there is:
\\a renamed, constraint annotation rule {with variables $y'$} of the form:
$g\; r\; @\; H'\;$
$==> Condition\; |\; Obj'$
\\where $c$ is part of $H'$ and
\\$\mycal(CT) \models \exists \left(B\right)
\wedge \forall \left(B \implies \exists y'\left(chr\left(H\right)=(H') \wedge Condition \wedge output\_graphical\_object \left(H',y', Obj'\right)=Obj\right) \right)$ \\and $\neg \left(contains\left(H\_ann,\left(r, id\left(H\right)\right)\right)\right)$
\\
\\\hline\\
7. \textbf{{Apply}}
: $\langle \left[c\#i:j|G\right], H_{k}\uplus H_{r}\uplus S,Gr,B,T,H\_ann\rangle_{n} \mapsto_{apply}$
\\$\langle C ++ H ++ G , H_{k}\cup S ,Gr',$
{$chr\left(H_{k}\right)=(H'_{k})\wedge chr\left(H_{r}\right)=(H'_{r})
\wedge g \wedge B$}
\\$T \cup \{ \langle r,id\left(H_{k}\right) + id\left(H_{r}\right) \rangle \},H\_ann\rangle_{n}$
where:
\\~~\llap{\textbullet}~~ there is no applicable constraint annotation rule that involves $c$.
\\(i.e. every applicable rule has already been applied). \\In other words, for renamed-apart every annotation rule with variables $y'$:
\\$g\; r\; @\; H'\; ==>\; Cond\; |\; Obj'$,
\\
{$c$ is part of $H'$}
{$\mycal(CT) \models \exists \left(B\right) \wedge \forall \left(B \implies \exists y' (chr\left(H\right)=(H') \wedge Condition)\right)$ }
\\It is already the case that:
$\left(contains\left(H\_ann,\left(r, id\left(H\right)\right)\right)\right)=true$
\\~~\llap{\textbullet}~~
There is a renamed rule in $P_{vis}$ with the form\\
$r\; @\; H'_{k}\;\backslash \; H'_{r} \Leftrightarrow \; g \; | \; C.$\\ with variables $x'$
and the jth occurrence of $c$ is part of the head of the renamed rule,
such that
\\where \( \mycal{CT} \models \exists \left(B\right) \wedge \forall(B \implies \exists x'\left((chr\left(H_k\right)=(H'_k) \wedge chr\left(H_r\right)=(H'_r)\wedge g)\right)\)
\\and \(\langle r,id\left(H_{k}\right) + id\left(H_{r}\right) \rangle\notin T\).
\\If $c$ occurs in $H'_k$ then $H=\left[c\#i:j\right]$ otherwise $H=\left[\right]$.
\\If the program communicates the head constraints (i.e. contains \verb+comm_head(T) ==> T=true+) then
\\${Gr'= remove\_gr\_obj\left(G,id\left(H'_{r}\right),H\_ann\right)}$
\begin{comment}
\\and $\left(r\_ann,id\left(Head\right)\right) \in H\_ann$ for any constraint annotation rule $ g\; r\_ann\; @\; H'\;==> Condition\; |\; Obj'$
\\where $\theta(H') \in chr(H_{k}) \cup chr(H_{r}) \wedge chr(Head)=\theta(H') \wedge Head \in H_{k} \cup H_{r}$
\end{comment}
\\\hline\\
8. \textbf{Drop}
\\
$\langle \left[c\#i:j|A\right], S,Gr,B,T,H\_ann\rangle_{n}
\mapsto_{drop}
\langle A, S,Gr,B,T,H\_ann\rangle_{n}
$
\\given that $c\#i:j$ is an occurrenced active constraint and $c$ has no occurrence $j$ in the program
\\and that there is no applicable constraint annotation rule for the constraint $c$.
\\That could thus imply that all existing ones were tried before.
\\
\\\hline\\
8. \textbf{Default}
$\langle \left[c\#i:j|A\right], S,Gr,B,T,H\_ann\rangle_{n}
\mapsto_{default}
\langle \left[c\#i:j+1|A\right], S,Gr,B,T,H\_ann\rangle_{n}
$
\\
in case there is no other applicable transition.
\\
\\\hline
\caption{Transitions of \(\omega_{vis}\)}
\label{table:omegavis}
\end{longtable}
Table \ref{table:omegavis} shows the basic transitions of $\omega_{vis}$. To make the transitions easier to follow, table \ref{table:omegavis} shows the transitions needed to run \textsf{CHR} programs with constraint annotation rules. Annotations of \textsf{CHR} rules are thus discarded from the first set of transitions.
$\omega_{vis}$ allows for running programs that contain constraint annotations.
The three transitions $apply\_annotation$ and $draw$ are responsible for dealing with the graphical store and its constituents. The transition, $apply\_annotation$, applies a constraint annotation rule. The rest of the transitions, such as solve, introduce and apply, have the same behavior as in $\omega_{r}$.
These transitions do not affect the graphical store or the application history of the annotation rules.
The transitions affecting the graphical store are:
\begin{enumerate}
\item \textbf{Draw}
\\The new transition \emph{draw} adds a graphical object ($g$) to the graphical store. Since multiple copies of a graphical object are allowed, each object is associated with a unique identifier.
\item \textbf{Apply\_Annotation}
\\The \emph{Apply\_Annotation} transition applies a constraint annotation rule (ann\_rule). An annotation rule is applicable if the \textsf{CHR} constraint store contains matching constraints. The condition of the rule has to be implied by the built in store under the matching. The built in constraint store B is also first checked for satisfiability. For the rule to be applied, it should not have appeared in the history of applied annotation rules with the same constraints i.e. it should be the first time the constraint(s) fire this annotation rule. Executing the rule adds to the goal the graphical object in the body of the executed annotation rule. The history of annotation rules is updated accordingly with the name of the rule in addition to the id(s) of the \textsf{CHR} constraint(s) in the head.
In fact, this transition has a higher precedence than the transition $apply$. Thus in the case where an annotation rule and a \textsf{CHR} rule are applicable, the annotation rule is triggered first
The precedence makes sure that graphical objects are added in the intended order. This ensures producing correct animations.
\end{enumerate}
\begin{comment}
\begin{definition}
\label{def:eqbuiltin}
Two built-in constraint stores $B_{1}$ and $B_{2}$ are equivalent if and only if:
\begin{enumerate}
\item $\forall_{X}(X\in B_{1} \wedge X \in B_{2}\wedge \exists_{\theta}\in B_{1})(\theta(X)=X'))$
\end{enumerate}
\end{definition}
\end{comment}
\begin{definition}[Built-In Store Equivalence]
\label{builtinequiv}
{
\(\)\\Two built-in constraint stores $B_{1}$ and $B_{2}$ are considered equivalent iff:
\\$\mycal(CT) \models \forall(\exists_{y1}(B_{1}) \leftrightarrow \exists_{y2}(B_{2}))$
where $y_1$ and $y_2$ are the local variables inside $B_1$ and $B_2$ respectively.
The equivalence thus basically ensures that there are no contradictions in the substitutions since local variables are renamed apart in every \textsf{CHR} program. The equivalence check thus ensures the logical equivalence rather than the syntactical equivalence.
}
\end{definition}
\begin{definition}
\label{def:eqchrvis}
A $CHR^{vis}$ state $St_{vis}=\langle G_{vis},S_{vis},Gr_{vis},B_{vis},T_{vis},T_{visAnn} \rangle_{n_{vis}}$ is equivalent to a \textsf{CHR} state $St=\langle G,S,B,T \rangle_{n}$ if and only if
\begin{enumerate}
\item $get\_constraints\left(G_{vis}\right) \doteq get\_constraints\left(G\right)$ according to Definition \ref{def:seqequiv}.
\item $get\_constraints\left(St_{vis}\right) \doteq get\_constraints\left(S\right)=C$ according to Definition \ref{def:seqequiv}.
\item {$B_{vis}$ and $B$ are equivalent according to Definition} \ref{builtinequiv}.
\item $T_{vis} = T$
\item $n_{vis} \geq n$
\end{enumerate}
The idea is that a $CHR^{vis}$ state basically has an extra graphical store. The correspondence check is effectively done through the \textsf{CHR} constraints since they are the most distinguishing constituents of a state. Thus, the constraint store and the stack should contain the same constraints. The propagation history should be also the same indicating that the same \textsf{CHR} rules have been applied. $n_{vis}$ could, however, have a value higher than $n$. This is due to the fact that graphical objects have identifiers.
{The definition of state equivalence described here follows the properties introduced in} \cite{raiserequiv}. {However, it is stricter.
}
\end{definition}
\begin{theorem}[Completeness]
\label{proof:pr1}
Given a \textsf{CHR} program $P$ (running under $\omega_{r}$) along with its user defined annotations and its corresponding $P_{CHR^{vis}}$ (running under $\omega_{vis}$) program,
for the same query $Q$, every derived state $S_{chr}$: $Q \mapsto_{\omega_{r}}^{*} S_{chr}$ has an equivalent state $S_{chr_{vis}}$: $Q \mapsto_{\omega_{vis}}^{*} S_{chr_{vis}}$.
\begin{proof}
\label{pr:pro1}
\(\)\\Base Case: For a given query $Q$, the initial state in $\omega_{r}$ $S_{chr}= \langle Q,\{\},\{\},\{\} \rangle_1$. The initial state in $\omega_{vis}$ is $S_{chr_{vis}}=\langle Q,\{\},\{\},\{\},\{\},\{\} \rangle_1$
\footnote{Throughout the different proofs, identifiers are omitted for brevity} According to Definition \ref{def:eqchrvis} $S_{chr}$ and $S_{chr_{vis}}$ are equivalent.\\
\\Induction Hypothesis:
Suppose that there are two equivalent derived states $S_{chr}=\langle A,S,B,T \rangle_n$ and $S_{chr_{vis}}=\langle A,S,Gr,B,T,H\_ann \rangle_m$ such that $Q \mapsto_{\omega_{r}}^{i} S_{chr}$ and $Q \mapsto_{\omega_{vis}}^{j} S_{chr_{vis}}$.\\
\\\emph{Induction Step}:
According to the induction hypothesis, $S_{chr}$ and $S_{chr_{vis}}$ are equivalent.
The rest of the proof shows that any transition applicable to $S_{chr}$ in $\omega_{r}$ produces a state that has an equivalent state produced by applying a transition to $S_{chr_{vis}}$ in $\omega_{vis}$.
Thus, no matter how many times the step is repeated, the output states are equivalent.
\begin{itemize}
\item \textbf{Case 1: (Applying Solve+wakeup):}
\\In this case, $S_{chr}\mapsto S_{chr}'$ such that:
\\$S_{chr}: \langle \left[c|A\right], S_{0}\uplus S_{1},B,T\rangle_{n}
\mapsto_{solve+wake}
\langle S_{1}++A, S_{0}\uplus S_{1},B',T\rangle_{n}$
\\Transition \emph{solve+wakeup} is applicable if:
\begin{enumerate}
\item $c$ is a built-in constraint
\item $\mycal{CT} \models \forall((c\wedge B \leftrightarrow B'))$
\item $wakeup\left(S_{0}\uplus S_{1} ,c,B\right) = S_{1}$
\end{enumerate}
$S_{chr_{vis}}(\langle Stack, S_{chr_{vis}},Gr,B_{vis},T_{vis},T_{ann}\rangle_{m})$ is equivalent to $S_{chr}(\langle \left[c|A\right], S_{0}\uplus S_{1},B,T\rangle_{n})$. Thus according to Definition \ref{def:eqchrvis},
$Stack = \left[c|A\right]$
$\wedge$ $S_{chr_{vis}}=S_{0}\uplus S_{1}$
$\wedge$ $B_{vis}=B$
$\wedge$ $T_{vis}=T$
$\wedge m \geq n$
Thus accordingly, the transition $solve+wakeup$ is applicable to $S_{chr_{vis}}$ under $\omega_{vis}$ producing $S_{chr_{vis}}'$:$\langle S_{1}++A, S_{0}\uplus S_{1},Gr,B\wedge c,T,H\_ann\rangle_{m}$. According to Definition \ref{def:eqchrvis}, $S'_{vis}$ is equivalent to $S_{chr}'$\\
\item \textbf{Case 2: (Applying Activate):}
\\In this case, $S_{chr}=\langle \left[c|A\right], S,B,T\rangle_{n}$ where $c$ is a \textsf{CHR} constraint. Thus $S_{chr}\mapsto_{activate} S_{chr}': \langle \left[c\#n:1|A\right], {c\#n} \cup S,B,T\rangle_{n+1}$.\\ Since $S_{chr_{vis}}(\langle Stack, S_{chr_{vis}},Gr,B_{vis},T_{vis},T_{ann}\rangle_{m})$ is equivalent to $S_{chr}(\langle \left[c|A\right], S_{0}\uplus S_{1},B,T\rangle_{n})$. Thus according to Definition \ref{def:eqchrvis}:
$Stack = \left[c|A\right]$
$\wedge$ $S_{chr_{vis}}=S$
$\wedge$ $B_{vis}=B$
$\wedge$ $T_{vis}=T$
$\wedge$ $m \geq n$\\
Accordingly, $S_{chr_{vis}} \mapsto_{activate} S_{chr_{vis}}':\langle \left[c\#n:1|A\right], \{c\#n\} \cup S,Gr,B,T,T_{ann}\rangle_{m+1}$ which is equivalent to $S_{chr}'$. (Since $m \geq n$, then $m+1 \geq n+1$).\\
\item \textbf{Case 3 (Applying Reactivate):}
\\The transition \emph{reactivate} is applicable if the stack has on top of it an element of the form $c\#i$ where $c$ is a \textsf{CHR} constraint. In this case $S_{chr}
=\langle \left[c\#i|A\right], S,B,T\rangle_{n} $. Accordingly, $S_{chr}
\mapsto_{reactivate}
S_{chr}':\langle \left[c\#i:1|A\right], S,B,T\rangle_{n}
$. Since $S_{chr_{vis}}$ and $S_{chr}$ are equivalent, then $S_{chr_{vis}}$ has the same stack. $S_{chr_{vis}}=\langle \left[c\#i|A\right], S,Gr,B,T,T_{ann}\rangle_{m}$ triggers the transition reactivate producing $S_{chr_{vis}}':\langle [c\#i:1|A], S,Gr,B,T,T_{ann}\rangle_{m}$ which is also equivalent to $S_{chr}'$.
{Since $c$ is not associated with an occurrence yet, no annotation rule is applicable at this point.}
\\
\item \textbf{Case 4: (Applying the transition Apply)}
\\The transition \emph{Apply} is triggered under $\omega_{r}$ in the case where $S_{chr}=\langle \left[c\#i:j|A\right], H_1 \uplus H_2 \uplus S,B,T\rangle_{n} $
such that the jth occurrence of $c$ is part of the head of the re-named apart rule {with variables $x'$}:
{\(r\; @\; H'_1\; \backslash \;H'_2 \; \Leftrightarrow \;g \;|\; C.\)}
\\
such that:
\\{$\mycal{CT} \models \exists(B) \wedge \forall
(B \implies \exists x'( chr\left(H_{1}\right)=(H'_{1})\wedge chr\left(H_{2}\right)=(H'_{2})
\wedge g)))$ }
and $\langle r,id\left(H_1\right)+id\left(H_2\right) \rangle \notin T$.
\\
{Thus in such a case $S_{chr} \mapsto_{apply\;r}$
$S_{chr}':\langle C ++ H ++ A, H_1 \cup S,$}
{$chr\left(H_{1}\right)=(H'_{1})\wedge chr\left(H_{2}\right)=(H'_{2}) \wedge g \wedge$} $B,
T \cup \{\langle r,id\left(H_1\right)+id\left(H_2\right)\rangle\}\rangle_{n}$
\[ H =
\begin{cases}
\left [c\#i:j\right] & \quad \text{if } c \text{ occurs in }H'_1\\
\left[\;\right] & \quad \text{otherwise}\\
\end{cases}
\]
\\Due to the fact that $S_{chr}$ and $S_{chr_{vis}}$ are equivalent, in the case where $S_{chr}$ triggers the transition \emph{Apply} under $\omega_{r}$, the same rule is also applicable under $\omega_{vis}$ to $S_{chr_{vis}}$.
However for $S_{chr_{vis}}$, one of two possibilities could happen:
\\~~\llap{\textbullet}~~ There is no applicable constraint annotation rule:
\\{This could be due to the fact that any applicable annotation rule was already executed or that there re no applicable} {annotation rules at this point.}
In this case,the transition $Apply$ is triggered right away under $\omega_{vis}$ producing a state
\\
{
($S_{chr_{vis}}':\langle C ++ H ++ A, H_1 \cup S,Gr,
chr\left(H_1\right) = H'_1 \wedge chr\left(H_2\right) = H'_2 \wedge g \wedge B,$
\\$T \cup \{\langle r,id\left(H_1\right)+id\left(H_2\right)\rangle, H\_ann\}\rangle_{m}$) equivalent to ($S_{chr}'$).
}
{The original states are equivalent and the same rule is applied in both cases. We can assume that,}
{without loss of generality}
{, in the $chr_{vis}$ program, the rule is renamed using the same variables $x'$ resulting in the same matching. This is because the same matching should happen to be able to apply the same rule using the given constraint stores}.
\\~~\llap{\textbullet}~~ There is an applicable annotation rule:
\\In this case an annotation rule ($r_{ann}$) for $c$ is applicable such that:
\\$S_{chr_{vis}}\langle \left[c\#i:j|A\right],H_1 \uplus H_2 \uplus S,Gr,B,T,H\_ann\rangle_{m} \mapsto_{apply\_annotation}$
\\$S_{chr_{vis}}':\langle \left[Obj\#\langle r,id\left(H\right),\{\} \rangle,c\#i:j|A\right],H_1 \uplus H_2 \uplus S ,Gr , B,$
$T , H\_ann \cup \{\langle r_{ann}, id\left(H\right),\{\;\}\rangle\} \rangle_{m}$
according to the previously mentioned conditions.
\\At this point either the transition \emph{Draw} or \emph{Update store} is applicable such that:
\\$S_{chr_{vis}}' \mapsto_{draw\big/update store} S_{chr_{vis}}'':\langle \left[c\#i:j|A\right], H_1 \uplus H_2 \uplus S ,Gr', B,$
$T , H'\_ann \rangle_{m'}$
\\In case $Obj$ is a graphical object, the transition \emph{Draw} is applied such that:
$Gr'=Gr\cup\{Obj\#m\}\;\wedge\;m'=m+1 \;\wedge\; H'\_ann = generate\_new\_ann\_history\left(Obj,m,r,id\left(H\right),\cup \{\langle r_{ann}, id\left(H\right),\{\;\}\rangle\}\right)$.
\\In case, $Obj$ is a graphical action, the transition \emph{Update Store} is applied such that:
\\$Gr'=update\_graphical\_store\left(Gr,Obj\right)\;m'=m\;H'\_ann=\cup \{\langle r_{ann}, id\left(H\right),\{\;\}\rangle\}$
\\Since the two transitions, could only change the graphical stores, annotation history and the next available identifier, the equivalence of the states is not affected.
\\At this point $\omega_{vis}$ fires the transition $Apply$ for the same \textsf{CHR} rule that triggered the same transition under $\omega_{r}$ earlier. The produced state $S_{chr_{vis}}'''$ has the format:
\\{$\langle C ++ H ++ A, H_1 \cup S, Gr',
chr\left(H_1\right) = H'_1 \wedge chr\left(H_2\right) = H'_2 \wedge B,
T \cup \{\langle r,id\left(H_1\right)+id\left(H_2\right)\rangle\},$}
\\{$H'\_ann\rangle_{m'}$.
}
{Similarly the same matching (local variable renaming $x'$) has to be applied for the rule to fire}.
\\Consequently, according to Definition \ref{def:eqchrvis}, the state $S_{chr_{vis}}'''$ is still equivalent to $S_{chr}'$
\\
\item \textbf{Case 5: Applying the transition Drop}
\\In the case where the top of the stack has an occurrenced active constraint $c\#i:j$ such that $c$ has no occurrence $j$ in the program, the transition drop is applied.
Thus, $S_{chr}:\langle\left[c\#i:j|A\right], S,B,T\rangle_{n}
\mapsto_{drop}
S_{chr}': \langle A, S,B,T\rangle_{n}
$
\\Since $S_{chr_{vis}}$ and $S_{chr}$ are equivalent, the stack of both states have to be equivalent.
\\Thus $S_{chr_{vis}}=\langle \left[c\#i:j|A\right], S,Gr,B,T,H\_ann\rangle_{m}$.
For $\omega_{vis}$ one of two possibilities is applicable:
\begin{enumerate}
\item No annotation rule is applicable.
This could be either because $c$ is not associated with any visual annotation rules or because all such rules have been already applied.
In this case \\$S_{chr_{vis}}:\langle\left[c\#i:j|A\right], S,Gr,B,T,H\_ann\rangle_{m} \mapsto_{drop} S_{CHR_{vis}}':\langle A, S,Gr,B,T,H\_ann\rangle_{m}$
\item The second possibility is the existence of an applicable annotation rule: transforming $S_{chr_{vis}}$ to $S_{chr_{vis}}':\langle\left[Obj\#\langle r,id\left(H\right),\{\;\}\rangle,c\#i:j|A\right], S,Gr,B,T,H'\_ann\rangle_{m}$.
At that point either \emph{draw} or \emph{update store} are to be applied transforming $S_{chr_{vis}}'$ to $S_{chr_{vis}}'':\langle \left[c\#i:j|A\right]$\\$, S,Gr',B,T,H''\_ann\rangle_{m'}$.
At that point, the transition drop is applicable converting $S_{chr_{vis}}''$ to $S_{chr_{vis}}''':
\\\langle A, S,Gr',B,T,H''\_ann\rangle_{m'}$. $S_{chr_{vis}}'''$ is equivalent to $S_{chr}'$
\end{enumerate}
\(\)\\
\item \textbf{Case 6: Applying the Default Transition}
\\If none of the previous cases is applicable, $S_{chr}:\langle \left[c\#i:j|A\right], S,B,T\rangle_{n}
\mapsto_{drop}
S_{chr}':\langle \left[c\#i:j+1|A\right], S,B,T\rangle_{n}.
$
\\For the equivalent $S_{chr_{vis}}$, one of two possible cases could happen:
\begin{enumerate}
\item \textbf{Apply annotation is not applicable:}
\\In that case, the \emph{Default} transition is directly applied transforming $S_{chr_{vis}} to S_{chr_{vis}}'$ such that \\$\langle \left[c\#i:j|A\right], S,Gr,B,T,H\_ann\rangle_{m} \mapsto_{drop} \langle A, S,Gr,B,T,H\_ann\rangle_{m}$.\\The produced state ($S_{chr_{vis}}'$) is equivalent to $S_{chr}'$ as well.
\item \textbf{Apply annotation is applicable:}
\\In this case an annotation rule for one of the existing constraints is applicable such that:
\\$S_{chr_{vis}}\langle \left[c\#i:j|A\right], S,Gr,B,T,H\_ann\rangle_{m} \mapsto_{apply\_annotation}$
\\$S_{chr_{vis}}':\langle \left[Obj\#\langle r,id(H), \{\;\}\rangle ,c\# i:j|A\right], S ,Gr , B,$
$T , H'\_ann \rangle_{m}$
according to the previously mentioned conditions.
\\At this point either the transition \emph{Draw} or the transition \emph{Update store} is applicable such that:
\\$S_{chr_{vis}}' \mapsto_{draw} S_{chr_{vis}}'':\langle \left[c\#i:j|A\right], S ,Gr' , B,$
$T , H''\_ann \rangle_{m'}$
\\$S_{chr_{vis}}''$ is still equivalent to $S_{chr}$.
\\At the point where the transition \emph{apply\_annotation} is no longer applicable, the only applicable transition is \emph{Default} transforming $S_{chr_{vis}}''$ to $S_{chr_{vis}}'''$ such that $S_{chr_{vis}}'''=\langle A, S ,Gr' , B,$
$T , H''\_ann \rangle_{m'}$. According to Definition \ref{def:eqchrvis}, $S_{chr_{vis}}'''$ is equivalent to $S_{chr}'$
\end{enumerate}
\(\)\\
Thus in all cases an equivalent state is produced under $\omega_{vis}$
\qed
\end{itemize}
\begin{comment}
\\According to $\omega_{vis}$, the rule $r$ would also be applicable.
The \emph{Apply} transition produces a new state $S'_{chr_{vis}}$ with the following form $\langle G \cup C,S\cup H_{k},Gr \rangle$.
According to Definition \ref{def:eqchrvis}, the two states are equivalent.
\\Afterwards, the transitions \emph{solve} and \emph{introduce} will begin to be applied to both $S'_{chr}$ and $S'_{chr_{vis}}$. The transitions add to the built-in and \textsf{CHR} constraint stores, the corresponding constraints in $C$ producing two new states $S''_{chr}: \langle G',S\cup H_{k} \cup C' \rangle$ and $S''_{chr_{vis}}=\langle G',S\cup H_{k}\cup C',Gr \rangle$. Since the initial states $S'_{chr}$ and $S'_{chr_{vis}}$ are equivalent and thus contain the same constraints, the resulting states $S''_{chr}$ and $S''_{chr_{vis}}$ will also be equivalent.
Moreover, in case any additional transitions in $\omega_{vis}$ is applicable to $S'_{chr_{vis}}$, the completeness results are unaffected.
One of two possible cases is possible at this point for $S''_{chr_{vis}}$.
\begin{enumerate}
\item No annotation rule is applicable for any of the \textsf{CHR} constraints in $S''_{chr_{vis}}$. The state thus remains unchanged.
\item The \textsf{CHR} constraint(s) $C\_ann \subset S\cup H_{k}\cup C'$ has an associated applicable annotation rule : $C\_ann\; ==>\; Condition\; |\; Graph\_Obj$.
In this case, the transition, \emph{apply\_annotation} is applied producing a new state $S'''_{chr_{vis}}: \langle G',S \cup H_{k}\cup C',Gr \cup Graph\_Obj \rangle$.
However, according to Definition \ref{def:eqchrvis}, $S'''_{chr_{vis}}$ and $S''_{chr_{vis}}$ are still equivalent.
\end{enumerate}
Thus in all cases an equivalent state is produced through $\omega_{vis}$
\end{comment}
\end{proof}
\end{theorem}
\begin{comment}
\begin{definition}
\label{def:soundchrvis}
Given a query $Q$, if $St_{vis}:(\langle G_{vis},S_{vis},Gr_{vis},B_{vis},T_{vis},T_{visAnn} \rangle)$ is a state derived from
$Q$ under $\omega_{vis}$: $Q$ $\xmapsto[]{\omega_{vis}}{}^{*}$ $S_{CHR_{vis}}$ in $P_{vis}$. $St_{vis}$ is sound if and only if there exists a state
$St_{chr}:(\langle G,S,B,T \rangle_{n})$ derived from
$Q$ under $\omega_{t}:$ $Q$ $\xmapsto[]{\omega_{t}}{}^{*}$ $St_{chr}$ such that $St_{vis}$ and $St_{chr}$ are equivalent.
\end{definition}
\end{comment}
\begin{theorem}[Soundness]
\label{pro:proof2}
\begin{comment}
For the same query $Q$, every derived state $S_{chr_{vis}}$:
$Q$ $\mapsto_{\omega_{vis}}^{*} $ $S_{chr_{vis}}$
has en equivalent state $S_{chr}$:
$Q$ $\mapsto_{\omega_{r}}^{*} $ $S_{chr}$
\end{comment}
Given a \textsf{CHR} program $P$ (running under $\omega_{r}$) along with its user defined annotations and its corresponding $P_{CHR^{vis}}$ program (running under $\omega_{vis}$),
for the same query $Q$, every derived state $S_{chr_{vis}}$:
$Q$ $\mapsto_{\omega_{vis}}^{*} $ $S_{chr_{vis}}$
has en equivalent state $S_{chr}$:
$Q$ $\mapsto_{\omega_{r}}^{*} $ $S_{chr}$
\begin{proof}
\label{pr:pro2}
\(\)\\\emph{Base Case}:
\\For the initial query the two states $Q$, $S_{chr_{vis}}=\langle Q,\{\},\{\} \rangle$ and $S_{chr} = \langle Q,\{\} \rangle$ are equivalent according to Definition \ref{def:eqchrvis}
\\\\\emph{Induction Hypothesis}:
Suppose that there are two equivalent derived states $S_{chr_{vis}}=\langle A,S,Gr,B,T,H\_ann \rangle_m$ and $S_{chr}=\langle A,S,B,T \rangle_n$ such that $Q \mapsto_{\omega_{vis}}^{i} S_{chr_{vis}}$ and $Q \mapsto_{\omega_{r}}^{j} S_{chr}$.\\
\begin{comment}
\\\emph{Induction Hypothesis}:
\\Assume that $S_{chr_{vis}}$ is a state derived from Q.
$Q$ $\mapsto_{\omega_{vis}}^{i} $ $S_{chr_{vis}}$ such that there is an equivalent state $S_{chr}$ such that $Q$ $\mapsto_{\omega_{r}}^{j} $ $S_{chr}$
\end{comment}
\\\emph{Induction Step}:
\\The proof shows that any transition applicable to $S_{chr_{vis}}$ under $\omega_{vis}$ produces a state $S_{chr}'$ such that under $\omega_{r}$ applying a transition to $S_{chr}$ (which is equivalent to $S_{chr_{vis}}$) produces a state $S_{chr}'$ that is equivalent to $S_{chr}$.\\
The different cases are enumerated below:
\begin{enumerate}
\item \textbf{Case 1: Applying solve+wakeup to $\mathbf{S_{chr_{vis}}}$:}
\\Under $\omega_{vis}$, solve+wakeup is applicable in the case where the stack has the form $\left[c|A\right]$ such that c is a built-in constraint and $\mycal{CT} \models \forall(\left(c\wedge B \leftrightarrow B'\right))$\\
and $wakeup\left(S_{0}\uplus S_{1} ,c,B\right) = S_{1}$ such that
\\$S_{chr_{vis}}
\mapsto_{solve+wake}
S_{chr_{vis}}':\langle S_{1}++A, S_{0}\uplus S_{1},Gr,B',T,H\_ann\rangle_{m}$.
Since $S_{chr_{vis}}$ and $S_{chr}$ are equivalent, $S_{chr}$ has an equivalent stack and built-in store according to Definition \ref{def:eqchrvis}. Thus the corresponding transition \emph{solve+wakeup} is applicable to $S_{chr}$ under $\omega_{r}$ producing a state $S_{chr}'$ such that: $S_{chr}'=\langle S_{1}++A, S_{0}\uplus S_{1},B',T\rangle_{n}$.
According to Definition \ref{def:eqchrvis}, the two states $S_{chr_{vis}}'$ and $S_{chr}'$ are equivalent.
\\
\item \textbf{Case 2: Applying Activate:}
\\Such a transition is applicable to $S_{chr_{vis}}$ under $\omega_{vis}$ in the case where the top of the stack of $S_{chr_{vis}}$ contains a \textsf{CHR} constraint $c$. In this case:
\\$S_{chr_{vis}}:\langle \left[c|A\right], S,Gr,B,T,H\_ann\rangle_{m}
\mapsto_{activate}
S_{chr_{vis}}': \langle \left[c\#n:1|A\right], \{c\#n\} \cup S,Gr,B,T,H\_ann\rangle_{m+1}
$
\\given that $c$ is a \textsf{CHR} constraint.\\
The equivalent state $S_{chr}$ has the same stack triggering the transition \emph{Activate} under $\omega_{r}$ producing a state $S_{chr}':\langle \left[c\#n:1|A\right], \{c\#n\} \cup S,Gr,B,T,H\_ann\rangle_{n+1}$ which is also equivalent to $S_{chr_{vis}}'$
\\
\item \textbf{Case 3: Applying Reactivate:}
\\In this case,
$S_{chr_{vis}}
\mapsto_{reactivate}
S_{chr_{vis}}' \langle \left[c\#i:1|A\right], S,Gr,B,T,H\_ann\rangle_{m}
$
\\such that $S_{chr_{vis}}= \langle \left[c\#i|A\right], S,Gr,B,T,H\_ann\rangle_{m}$
and $c$ is a \textsf{CHR} constraint.
\\
The equivalent state $S_{chr}$ has an equivalent stack triggering the transition \emph{reactivate} under $\omega_{r}$. The transition application produces $S_{chr}':\langle \left[c\#i:1|A\right], S,B,T\rangle_{n}$ which is also equivalent to $S_{chr_{vis}}'$.\\
\begin{comment}
\\given that $c$ is a built-in constraint and $\mycal{CT} \models \forall((c\wedge B \leftrightarrow B'))$\\
and $wakeup\left(S_{0}\uplus S_{1} ,c,B\right) = S_{1}$ \\
\end{comment}
\item According to Definition \ref{def:eqchrvis} and since $S_{chr_{vis}}$ is equivalent to $S_{chr}$, they both have the same stack. The transition \textbf{Draw} is only applicable if the top of the stack contains a graphical object. Since the stack of $S_{chr}$ never contains graphical objects and since it is equivalent to $S_{chr_{vis}}$, the stack of $S_{chr_{vis}}$ at this point does not contain graphical objects as well.
Thus, in this case, the transition \textbf{\emph{Draw}} is not applicable to $S_{chr_{vis}}$ under $\omega_{vis}$.
\\
\item Similarly, according to Definition \ref{def:eqchrvis} and since $S_{chr_{vis}}$ is equivalent to $S_{chr}$, the stack of $S_{chr_{vis}}$ at this point does not contain graphical actions since both states should have the same stack. The transition \textbf{Update store} is only applicable if the top of the stack contains a graphical action.
Thus, in this case, the transition \textbf{\emph{Update store}} is not applicable to $S_{chr_{vis}}$ under $\omega_{vis}$.
\\
\item \textbf{Case 4: \emph{Apply Annotation Rule} Transition}
\\The transition \emph{Apply Annotation} is triggered when the {stack} has on top a constraint associated with an annotation rule. The constraint store should contain constraints matching the head of the annotation rule such that this rule was not fired with those constraint(s) before and the pre-condition of the annotation rule is satisfied. {Thus, the rule could be associated with more than one constraint including} {the one on top of the stack.} \\{The constraint store should however, contain matching constraints for the rest of the constraints in the head of} \\{the annotation rule.}
\\$S_{chr_{vis}} \mapsto_{apply\_annotation}$ $S_{chr_{vis}}':\langle \left[Obj\#\langle r, id\left(H\right), \{\;\} \rangle|A\right], H \cup S ,Gr ,$
$B, T , H\_ann \cup \{\langle r, id\left(H\right),\{\;\}\rangle\} \rangle_{m}$ \\
such that $\neg contains\left(r,id\left(H\right)\right)$. The renamed annotation rule with variables $x'$ is :
\\$g\; r\; @\; H'\;$
$==> Condition\; |\; Obj'$
\\
{$\mycal(CT) \models \exists \left(B\right) \wedge \forall (B \implies \exists x' ((chr\left(H\right)=(H') \wedge Cond \wedge$} $output\_graphical\_object\left(H',x',Obj'\right)=Obj)))$
\\Either the transition \emph{Draw} or \emph{Update store} is applicable to $S'_{chr_{vis}}$. The output is $S''_{chr_{vis}}:\langle A, S ,Gr' ,$
$T , H'\_ann \rangle_{m'}$.
In case, $Obj$ is a graphical object, then $H'_ann=generate\_new\_ann_history\left(H\_ann \cup \{\langle r, id\left(H\right),\{\;\}\rangle\}\right)\wedge Gr'=Gr\cup\{Obj\#m\}\wedge m'=m+1$.
In case, $Obj$ is a graphical action, then $Gr'=update\_graphical\_store\left(Gr,Obj\right) \wedge Gr'=Gr \wedge m'=m$
Any transition applicable to $S_{chr_{vis}}''$ at this stage is covered through the rest of the cases. Thus the application of the transition $apply\_annotation$ is considered as not to affect the equivalence of the output state with $S_{chr}$.
\\
\item \textbf{Case 5: the Apply transition}
\\
In the case where a \textsf{CHR} rule is applicable to $S_{chr_{vis}}$, the transition
\emph{Apply} is triggered under $\omega_{vis}$. A \textsf{CHR} rule $r$ is applicable in the case where a renamed version of the rule $r$ with {variables $x'$}:
($r\; @\; H'_{k}\;\backslash \; H'_{r} \Leftrightarrow \; g \; | \; C.$) where $\langle r,id\left(H_{k}\right) + id\left(H_{r}\right) \rangle\notin T$ and
{$ \mycal{CT} \models \exists(B) \wedge \forall (B \implies \exists x'($
$chr\left(H_{k}\right)=(H'_{k})\wedge chr\left(H_{r}\right)=(H'_{r}) \wedge g))$}.
In this case, $S_{chr_{vis}}$ has the form: $\langle [c\#i:j|G], H_{k}\uplus H_{r}\uplus S,Gr,B,T,H\_ann\rangle_{m}$. The output state $S_{chr_{vis}}'$ has the form
\\{$\langle C ++ H ++ G , H_{k}\cup S ,Gr,B \wedge chr\left(H_{k}\right)=(H'_{k})\wedge chr\left(H_{r}\right)=(H'_{r}) \wedge g,$}
{$T \cup \{ \langle r,id\left(H_{k}\right) + id\left(H_{r}\right)\rangle\}, H\_ann \rangle_{m} $.}
Due to the fact that $S_{chr}$ is equivalent to $S_{chr_{vis}}$,it has the following form: $\langle G, H_{k}\uplus H_{r}\uplus S,B,T\rangle_{n}$. For the same program, the \textsf{CHR} rule $r$ is applicable
{producing $S_{chr}'$:}\\{$\langle C ++ G , H_{k}\cup S ,chr\left(H_{k}\right)=(H'_{k})\wedge chr\left(H_{r}\right)=(H'_{r}) \wedge g \wedge B,$}
$T \cup \{ \langle r,id\left(H_{k}\right) + id\left(H_{r}\right) \rangle_{n} \}$
\[ H =
\begin{cases}
\left[c\#i:j\right] & \quad \text{if } c \text{ occurs in }H'_k\\
\left [\;\right] & \quad \text{otherwise}\\
\end{cases}
\]
\\
{Due to the fact that the same \textsf{CHR} rule is applied for both states, the new built-in stores are equivalent according to Definition} \ref{builtinequiv}. {This is due to the fact that since the original states have equivalent constraint stores,} {we assume without loss of generality} {that the matchings in both cases are the same since the same rule was applied. Thus, the rule in the two programs $P_{chr}$ and $P_{chr_{vis}}$ are renamed similarly.}
\\At this point, for $S_{chr_{vis}}'$ one of two cases is possible:
\begin{itemize}
\item \textbf{An annotation rule is applicable:}
\\In this case, $S_{chr_{vis}}'$ has the form $\langle \left[cons\#id:occ|A\right] , Head \uplus St,Gra,Bu,T_H,H\_ann\rangle_{m}$ where there exists a renamed, constraint annotation rule {with the same variables $x'$} of the form:
$g\; ru\; @\; H'\;$
$==> Condition\; |\; Obj'$ where $cons$ is part of $H'$
\\such that
$\mycal(CT) \models \exists\left(B \right) \wedge \forall (B \implies \exists x' \wedge Condition \wedge chr \left(Head\right)=(H') \wedge output\_graphical\_object\left(H', x', Obj'\right)=Obj)$
and $ \neg contains\left(H\_ann ,\left( ru,
id\left(Head\right) \right)\right)$.
The output state $S_{chr_{vis}}''$ has the form:
\\$\langle \left[Obj\#\langle ru,id\left(Head\right),\{\;\} \rangle,cons\#id:occ|A\right],Head \uplus St,Gra,$
$Bu,$
$T\_H , H\_ann \cup \{\langle r, id\left(H\right) \{\;\} \rangle\} \rangle_{m}$.
\\Similar to the previous cases, $S_{chr_{vis}}''$ triggers the transition \emph{draw} or \emph{update store} producing $S_{chr_{vis}}''':\langle \left[cons\#id:occ|A\right],Head \uplus St,Gra',$
$Bu,$
$T\_H , H'\_ann \rangle_{m'}$.
According to Definition \ref{def:eqchrvis}, $S_{chr_{vis}}'''$ is equivalent to $S_{chr}'$ since the two stacks, constraint stores and propagation histories are not affected by the application of the annotation rule.
\item \textbf{No annotation rule is applicable}
\\At this point, $S_{chr_{vis}}'$ is still equivalent to $S_{chr}'$
\\
\end{itemize}
\item \textbf{Case 6: Applying Drop}
\\In the case where $S_{chr_{vis}}=$ $\langle\left[c\#i:j|A\right], S,Gr,B,T,H\_ann\rangle_{m}$
such that $c$ has no occurrence $j$ in the program and case 5 is not applicable, the transition \emph{Drop} is triggered. \emph{Drop} produces the state $S_{chr_{vis}}'=$
$
\langle A, S,Gr,B,T,H\_ann\rangle_{m}
$
\\given that $c\#i:j$ is an occurrenced active constraint and $c$ has no occurrence $j$ in the program.
\\
Since $S_{chr}$ is equivalent to $S_{chr_{vis}}$, they both have the same stack $\left[c\#i:j|A\right]$. Thus under $\omega_{vis}$, the same transition \emph{drop} is triggered producing $S_{chr}': \langle A, S,B,T\rangle_{n}$. According to Definition \ref{def:eqchrvis}, $S_{chr_{vis}}'$ and $S_{chr}'$ are equivalent as well.
\\
\item \textbf{Case 7: Applying Default}
\\In the case where none of the above cases hold, the transition \emph{Default} transforms $S_{chr_{vis}}$ to
\\$
S_{chr_{vis}}': \langle \left[c\#i:j+1|A\right], S,Gr,B,T,H\_ann\rangle_{m}
$.
Similarly the equivalent state $S_{chr}$ triggers the same transition \emph{Default} in this case. The output state $S_{chr}': \left[c\#i:j+1|A\right], S,Gr,B,T,H\_ann\rangle_{n} $ is still equivalent to $S_{chr_{vis}}'$
\end{enumerate}
\begin{comment}
in that has an equivalent state produced by applying a transition to $S_{vis}$ in $\omega_{vis}$
\\\\{Induction Step}:
\\Assume that (according to the hypothesis) the state $S_{chr_{vis}}$ has the form $\langle G,S\cup H_{k}\cup H_{r},Gr \rangle$. This implies that there is an equivalent state $S_{chr}$ derived through $\omega_{r}$ such that $S_{chr}$ = $\langle G,S\cup H_{k}\cup H_{r} \rangle$.
For a given applicable \textsf{CHR} rule $r @ H'_{k}\backslash H'_{r} \Leftrightarrow Gu | C $, $\omega_{vis}$ applies the
transition \emph{Apply} producing a new state $S'_{vis}= \langle G \cup C,S\cup H_{k},Gr \rangle$ given that there is a substitution $\theta$ such that $\theta(H'_{r})=H_{r} \wedge \theta(H'_{k})=H_{k}$ and the guard ($Gu$) holds.
$\omega_{r}$ also executes \emph{Apply} producing the new state $S'_{chr}= \langle G\cup C,S\cup H_{k} \rangle$. According to Definition \ref{def:eqchrvis} the two states are equivalent.
Similar to the previous proof, the transitions \emph{solve} and \emph{introduce} will be applied to both $S'_{chr}$ and $(S'_{chr_{vis}})$ adding to the built-in and \textsf{CHR} constraint stores, the corresponding constraints in $C$ producing new states $S''_{chr}: \langle G',S\cup H_{k} \cup C' \rangle$ and $S''_{chr_{vis}}=\langle G',S\cup H_{k}\cup C',Gr \rangle$. With the initial states $S'_{chr}$ and $S'_{chr_{vis}}$ being equivalent, the resulting states $S''_{chr}$ and $S''_{chr_{vis}}$ are also equivalent.
One of two possible cases is applicable at this point for $S''_{chr_{vis}}$.
\begin{enumerate}
\item No annotation rule is applicable for any of the \textsf{CHR} constraints in $S''_{chr_{vis}}$ keeping the state unchanged.
\item An associated and applicable annotation rule exists for $C\_ann \subset S\cup H_{k}\cup C'$ :
\\ $C\_ann\; ==>\; Condition\; |\; Graph\_Obj$.
\\In this case, $\omega_{vis}$ applies the transition \emph{apply\_annotation} producing $S'''_{chr_{vis}}: \langle G',S \cup H_{k}\cup C',Gr \cup Graph\_Obj \rangle$.
However, according to Definition \ref{def:eqchrvis}, $S'''_{chr_{vis}}$ and $S''_{chr_{vis}}$ are still equivalent.
In addition, every transition other than $apply\_annotation$ and $draw$ that exist in $\omega_{vis}$ exists in $\omega_{r}$. Thus the produced final states are equivalent. Since $draw$ does not affect the constraint store, every state reachable through $\omega_{vis}$ has a corresponding derivation through $\omega_{r}$
\end{enumerate}
\end{comment}
\end{proof}
\end{theorem}
\subsubsection{Operational Semantics including Rule Annotations}
\(\)\\Table \ref{table:omegavisruleann} shows the operational semantics of $\omega_{vis_{r}}$. $\omega_{vis_{r}}$ is basically $\omega_{vis}$ but taking rule annotations into account. A state of $\omega_{vis_{r}}$ is a tuple $\langle G,S,Gr,B,T, H\_ann,Cons\_r \rangle_{n}$. $G$, $S$, $Gr$, $B$, $T$, $H\_ann$, and $n$ have the same meanings as in an $\omega_{vis}$ state. However, $G$ {can hold ,in addition to the previously seen formats of constraints, the constraint in addition} {the name of the rule that added it}. $Cons\_r$ holds for each constraint, its ID in addition to the name of the rule used to add it. It is an extended form of the constraint store.
{If the constraint comes from the query of the user or if }{it is an auxiliary constraint,} {the keyword, \verb+aux+ is used for the rule name inside $G$ and $Cons\_r$}.
\begin{definition}
\label{def:rulename}
\(\\\)Similar to the previously defined functions,
for a $\omega_{vis_{r}}$state $\langle G, S,Gr,B,T,H\_ann,Cons\_r\rangle_{n}$, $rule\_name\left(H\right)$ is a function defined as: $rule\_name\left(c\#n\right)=r$ such that $c\#n\#r$ $\in$ $Cons\_r$
\end{definition}
\begin{definition}
\label{def:newget}
\(\\\)The definition of the function $get\_constraints\left(Sq\right)$ is modified such that:
for a sequence $Sq=\left(c_1\#r_1,\ldots,c_n\#r_n\right)$ the function $get\_constraints\left(Sq\right)=\cup_{i=1}^{n} c_{i}$ such that $c_{i}$ is not an auxiliary constraint.
{$r_1\ldots r_n$ could thus represent identifiers or rule names.}
{Definition \ref{def:newget} is thus reflected in the equivalence definition of states introduced in Definition \ref{def:eqchrvis}
}
\end{definition}
\begin{longtable}{l}
\hline
\\
1. \textbf{Solve+wakeup}:
\\$\langle \left[c|A\right], S_{0}\uplus S_{1},Gr,B,T,H\_ann,H\_cons\rangle_{n}
\mapsto_{solve+wake}
\langle S_{1}++A, S_{0}\uplus S_{1},Gr,B',T,H\_ann,H\_cons\rangle_{n}$
\\given that $c$ is a built-in constraint and $\mycal{CT} \models \forall((c\wedge B \leftrightarrow B'))$
and $wakeup\left(S_{0}\uplus S_{1} ,c,B\right) = S_{1}$ \\
\\\hline\\
2. \textbf{Activate}
$\langle\left[c\#rule\_name|A\right], S,Gr,B,T,H\_ann,H\_cons\rangle_{n}
\mapsto_{activate}$
\\$\langle \left[c\#n:1|A\right], \{c\#n\} \cup S,Gr,B,T,H\_ann,H\_cons\cup \{c\#n\#rule\_name\}\rangle_{n+1}
$
\\given that $c$ is a \textsf{CHR} constraint.\\
\\\hline\\
3. \textbf{Reactivate}
$\langle \left[c\#i|A\right], S,Gr,B,T,H\_ann,H\_cons\rangle_{n}
\mapsto_{activate}
\langle \left[c\#i:1|A\right], S,Gr,B,T,H\_ann,H\_cons\rangle_{n}
$
\\given that $c$ is a \textsf{CHR} constraint and $i$ is not a valid rule name.
\\
\\\hline\\
4. \textbf{Draw}
: $\langle \left[Obj\#\langle r, id\left(H\right),Obj\_ids \rangle|A\right], S,Gr,B,T,H\_ann,H\_cons\rangle_{n} \mapsto_{draw} \langle A,S ,Gr\cup \{Obj\#n\},B,T$\\$,H'\_ann,H\_cons\rangle_{n+1}$ given that $Obj$ is a graphical object: $graphical\_object\left(Actual_0,\ldots,Actual_k\right)$ and
\\$H'\_ann=generate\_new\_ann\_history\left(Obj,n,id\left(H\right),H\_ann\right)$
\\The actual parameters of $graphical\_object$ are used to visually render the object.\\
\\\hline\\
5. \textbf{Update Store}
: $\langle \left[Obj\#\langle r,id\left(H\right),Obj\_ids\rangle|A\right], S,Gr,B,T,H\_ann,H\_cons\rangle_{n} \mapsto_{update\;store} \langle A,S ,Gr'$
\\$,B,T,H\_ann,H\_cons\rangle_{n}$ given that $Obj$ is a graphical action: $graphical\_action\left(Actual_0,\ldots,Actual_k\right)$.
\\$Gr'=update\_graphical\_store\left(Gr,graphical\_action\left(Actual_0,\ldots,Actual_k\right)\right)$
\\The actual parameters of $graphical\_action$ are used to update the graphical objects.\\
\\\hline\\
6. \textbf{Apply\_Annotation}:
\\$\langle \left[c\#i:j|G \right],H \cup S,Gr,B,T,H\_ann, H\_cons\rangle_{n} \mapsto_{apply\_annotation}$ \\$\langle \left[Obj\#\langle r,id\left(H\right),\{\;\}\rangle,c\#i:j|G\right], H \cup S ,Gr ,
B, T , H\_ann \cup \{(ann\_name, id(H))\}, H\_cons\rangle_{n}$ \\
where there is a, renamed, constraint annotation rule {with variables $y'$} of the form:
\\$g\; ann\_name\; @\; H'$
$==> Condition | Obj'$
where $c$ is part of $H'$
such that
\\{$\mycal(CT) \models \exists\left(B\right) \wedge \forall (B \implies \exists y' $ $(chr\left(H\right)=(H') \wedge output\_graphical\_object\left(H',y', Obj'\right)=Obj))$
}
\\ and $rule\_name\left(H\right)$ does not have an associated annotation rule
and $\neg contains\left(H\_ann,\left(r,id\left(H\right)\right)\right)$
\\\hline\\
7. \textbf{Apply}
: $\langle \left[c\#i:j|A\right], H_{k}\uplus H_{r}\uplus S,Gr,B,T,H\_ann,$
$H\_cons\rangle_{n} \mapsto_{apply}$
\\
$\langle C' ++ H ++ A , H_{k}\cup S ,Gr',chr\left(H_{k}\right)=(H'_{k})\wedge chr\left(H_{r}\right)=(H'_{r}) \wedge g$
$\wedge B,T \cup \{ \langle r,id\left(H_{k}\right) + id\left(H_{r}\right) \rangle \},$
\\$H\_ann, H\_cons\rangle_{n}$ \\
there is and a renamed rule in $P_{vis}$ with variables $x'$ where the jth occurrence of $c$ is part of the head. \\The renamed rule has the form:\\
$r\; @\; H'_{k}\;\backslash \; H'_{r} \Leftrightarrow \; g \; | \; C.$\\
such that
{$ \mycal{CT} \models \exists(B) \wedge \forall (B \implies \exists x'$ $(chr\left(H_{k}\right)=(H'_{k})$ $\wedge$ $chr\left(H_{r}\right)=(H'_{r})$ $\wedge g$))}
\\and $\langle r,id\left(H_{k}\right) + id\left(H_{r}\right) \rangle\notin T$
and there are no associated and applicable annotation rule(s) to $c$
\\or any part(s) of it that are not executed yet.
\\$C'=C\#r$
if and only if there is no annotation rule associated with $r$
\\{otherwise if $r$ has an associated rule under the same variables (matching) $x'$:}
\\$g\;rule\_name\;r==> ann\_cond | Aux\_cons'$
\\such that :
\\{$\mycal(CT) \models \exists(B) \wedge \forall (B \implies (Aux\_cons') = Aux\_cons \wedge ann\_cond )$}
\\or\\
{$\mycal(CT) \models \exists(B) \wedge \forall (B \implies \exists x' ((chr(H_{k})=(H'_{k}) \wedge chr(H_{r})=(H'_{r}) \wedge g \wedge (Aux\_cons') = Aux\_cons \wedge ann\_cond ))$}
\\then $C'=\left[Aux\_cons\#aux | C\#r\right] $
\\If $c$ occurs in $H'_k$ then $H=\left[c\#i:j\right]$ otherwise $H=\left[\right]$.
\\If the program communicates the head constraints (i.e. contains \verb+comm_head(T) ==> T=true+) then
\\${Gr'= remove\_gr\_obj\left(G,id\left(H_{r}\right),H\_ann\right)}$ otherwise $Gr'=Gr$.
\\
\\\hline\\
8. \textbf{Drop}
\\
$\langle\left[c\#i:j|A\right], S,B,T,H\_ann,H\_cons\rangle_{n}
\mapsto_{drop}
\langle A, S,B,T,H\_ann,H\_cons\rangle_{n}$
\\given that $c\#i:j$ is an occurrenced active constraint and $c$ has no occurrence $j$ in the program
\\and that there is no applicable constraint annotation rule for the constraint c.
\\
\\\hline
\\
9. \textbf{Default}
$\langle\left[c\#i:j|A\right], S,B,T,H\_ann,H\_cons\rangle_{n}
\mapsto_{drop}
\langle \left[c\#i:j+1|A\right], S,B,T,H\_ann,H\_cons\rangle_{n}$
\\
in case there is no other applicable transition.
\\\\
\hline
\caption{Transitions of $\omega_{vis}$ taking rule annotations into account}
\label{table:omegavisruleann}
\end{longtable}
As seen through Table \ref{table:omegavisruleann}, the transition \emph{Apply} could activate a rule annotation (if applicable) associated with the applied \textsf{CHR} rule. In this case, the auxiliary constraint is added to the goal with the keyword $aux$.
Since the \textsf{CHR} rule is applied with the combination of constraints once, the rule annotation is also applied once and there is no risk of running infinitely. The rest of the transitions were modified only to include the newly added state parameter $H\_cons$.
In addition, the \emph{apply annotation} transition is only applied if the constraints activating it were not added by a rule that is associated with a rule annotation rule. This ensures the previously discussed property that whenever a rule is associated with a rule annotation, then the body constraints can never trigger their own visual annotation rules. Since the rule is annotated then the individual constraint annotations are discarded.
\subsubsection{Completeness and Soundness}
\(\)\\Since according to the modified definition shown in Definition \ref{def:newget}, the state equivalence will not take auxiliary constraints into account.
The proofs for completeness and soundness shown in Proof \ref{pr:pro1} and Proof \ref{pr:pro2} still hold.
As seen from the transitions in Table \ref{table:omegavisruleann}, the auxiliary constraint of the rule annotation is dealt with as a normal \textsf{CHR} constraint. Thus the only difference between these transitions and the previous ones is that sometimes, auxiliary constraints will exist in the constraint store of the final states. The states however remain equivalent.
Thus even if annotations of rules were applicable, $\omega_{vis_{r}}$ is still sound and complete.
Proof \ref{proof:pr1} introduced for the completeness check has the following amendment in the induction step:
\\\textbf{Case 4: (Applying the transition Apply)}
\\For $\omega_{r}$, the transition \emph{Apply} is triggered in the case where $S_{chr}=\langle \left[c\#i:j|A\right], H_1 \uplus H_2 \uplus S,B,T\rangle_{n} $
such that the jth occurrence of $c$ is part of the head of the re-named apart rule {with variables $x'$}:
{\(r\; @\; H'_1\; \backslash \;H'_2 \; \Leftrightarrow \;g \;|\; C.\)}
\\
$ (chr\left(H_1\right)=(H'_{1}) \wedge chr\left(H_{2}\right)=(H'_{2}) \wedge$
{ $ \mycal{CT} \models \exists(B) \wedge \forall (B \implies \exists x' (chr\left(H_1\right)=(H'_{1}) \wedge chr\left(H_{2}\right)=(H'_{2}) \wedge g))$ }
and $\left(r,id\left(H_1\right)+id\left(H_2\right)\right) \notin T$.
In this case, $S_{chr} \mapsto_{apply\;r}$
$S_{chr}':\langle C + H + A, H_1 \cup S,$
{$chr\left(H_1\right)=(H'_{1}) \wedge chr\left(H_{2}\right)=(H'_{2}) \wedge g \wedge B,$}
$T \cup \{\left(r,id\left(H_1\right)+id\left(H_2\right)\right)\}\rangle_{n}$
\[ H =
\begin{cases}
\left[c\#i:j\right] & \quad \text{if } c \text{ occurs in }H'_1\\
\left[\;\right] & \quad \text{otherwise}\\
\end{cases}
\]
\\Due to the fact that $S_{chr}$ and $S_{chr_{vis}}$ are equivalent, they both have the same goal stacks and constraint stores. However for $\omega_{vis}$ one of two possibilities could take place.
\\~~\llap{\textbullet}~~ It could be that there is no applicable constraint constraint annotation rule either because any applicable annotation rule was already executed or at this point there is no applicable annotation rule at this point.
The transition $Apply$ is thus triggered right away under $\omega_{vis}$.
\begin{comment}
producing a state
$S_{chr_{vis}}':\langle C' + H + A, H_1 \cup S,Gr,$
$chr\left(H_1\right) = H'_1 \wedge chr\left(H_2\right) = H'_2 \wedge g \wedge B,$
$T \cup \{\left(r,id\left(H_1\right)+id\left(H_2\right)\right), H\_ann, H\_cons\}\rangle_{m}$
\end{comment}
\\
\\~~\llap{\textbullet}~~ It could, however, be the case that there is an applicable constraint annotation rule.
\\In this case an annotation rule ($r_{ann}$) for $c$ is applicable such that:
\\$S_{chr_{vis}}\langle \left[c\#i:j|A\right],H_1 \uplus H_2 \uplus S,Gr,B,T,H\_ann,H\_cons\rangle_{m} \mapsto_{apply\_annotation}$
\\$S_{chr_{vis}}'':\langle \left[Obj\#\langle r,id\left(H\right),\{\} \rangle,c\#i:j|A\right],H_1 \uplus H_2 \uplus S ,Gr , B,$
$T , H\_ann \cup \{\langle r_{ann}, id\left(H\right),\{\;\}\rangle\},h\_cons \rangle_{m}$ .
\\At this point either the transition \emph{Draw} or \emph{Update store} should be applied.
Thus,
\\$S_{chr_{vis}}' \mapsto_{draw\big/update store} S_{chr_{vis}}':\langle \left[c\#i:j|A\right], H_1 \uplus H_2 \uplus S ,Gr', B,$
$T , H'\_ann, H\_cons \rangle_{m'}$
\\The transition \emph{Draw} is applicable in case $Obj$ is a graphical object such that:
$Gr'=Gr\cup\{Obj\#m\}\;\wedge\;m'=m+1 \;\wedge\; H'\_ann = generate\_new\_ann\_history\left(Obj,m,r,id\left(H\right),\cup \{\langle r_{ann}, id\left(H\right),\{\;\}\rangle\}\right)$.
\\In the case where $Obj$ is a graphical action, the transition \emph{Update Store} is applied such that:
\\$Gr'=update\_graphical\_store\left(Gr,Obj\right)\;m'=m\;H'\_ann=\cup \{\langle r_{ann}, id\left(H\right),\{\;\}\rangle\}$
\\\\\\The two transitions do not affect the constraint stores or goal stacks. Thus, the equivalence of the states is not affected.
\\Due to the fact that $S_{chr}$ and $S_{chr_{vis}}'$ are equivalent, in the case where $S_{chr}$ triggers the transition \emph{Apply} under $\omega_{r}$, $S_{chr_{vis_{r}}}$ also triggers the same transition for the same \textsf{CHR} rule, under $\omega_{vis}$ producing a state
($S_{chr_{vis}}'':\langle C' + H + A, H_1 \cup S,Gr'',$
{$chr(H_1) = H'_1 \wedge chr(H_2) = H'_2 \wedge g \wedge B,$}
$T \cup \{(r,id(H_1)+id(H_2))\}, H\_ann, H\_cons\rangle_{m}$)
where
\\{$ \mycal{CT} \models \exists(B) \wedge \forall (B \implies \exists x' (chr(H_1)=(H'_{1}) \wedge chr(H_{2})=(H'_{2}) \wedge g))$
}
and
\[ H =
\begin{cases}
\left[c\#i:j\right] & \quad \text{if } c \text{ occurs in }H'_1\\
\left[\;\right] & \quad \text{otherwise}\\
\end{cases}
\]
\\{Since the same rule is applied in both cases, the two resulting states
$S_{chr_{vis}}''$ and ($S_{chr}'$) are equivalent.}
{Similarly, the matchings in both cases are have to be the same since the original states have equivalent stores. Thus. without loss of generality, the applied rule is assumed to be renamed with the same variables in both programs.} {The two new built-in stores are still equivalent and the two resulting states are thus also equivalent.}
\\If the program communicates the head constraints (i.e. contains \verb+comm_head(T) ==> T=true+) then
\\${Gr''= remove\_gr\_obj\left(Gr',id\left(H'_{r}\right),H'\_ann\right)}$
There are however, two possibilities in this case,
\begin{itemize}
\item if $r$ is associated with an annotation rule {(renamed with variables $x'$)}
\\$r ==> ann\_cond | Aux\_cons'$.
\\where
$ \mycal{CT} \models \exists(B) \wedge \forall (B \implies (Aux\_cons')=Aux\_cons \wedge ann_cond$
\\In this case, $C'=[Aux\_cons\#aux|C]$.
\\$S_{chr_{vis}}'$ is thus still equivalent to $S_{chr}'$ since auxiliary constraints are disregarded in the equality check.
\item if $r$ is not associated with an annotation
or if the annotation is not applicable then $C'=C\#r$ making the two states $S_{chr_{vis}}'$ and $S_{chr}'$ equivalent as well.
\end{itemize}
As for the soundness proof (Proof \ref{pro:proof2}),
the only change is in the following case:
\\\textbf{Case 5: the Apply transition}
\\
In the case where a \textsf{CHR} rule is applicable to $S_{chr_{vis}}$, the transition
\emph{Apply} is triggered under $\omega_{vis}$. A \textsf{CHR} rule $r$ is applicable in the case where a renamed version of the rule $r$ {with variables $x'$} is
\\($r\; @\; H'_{k}\;\backslash \; H'_{r} \Leftrightarrow \; g \; | \; C.$) where $\langle r,id\left(H_{k}\right) + id\left(H_{r}\right) \rangle\notin T$
and
\\{$ \mycal{CT} \models \exists(B) \wedge \forall (B \implies \exists x' (chr\left(H_r\right)=(H'_{r}) \wedge chr\left(H_{k}\right)=(H'_{k}) \wedge g))$
}.
In this case, $S_{chr_{vis}}$ has the form: $\langle \left[c\#i:j|G\right], H_{k}\uplus H_{r}\uplus S,Gr,B,T,H\_ann,H\_cons\rangle_{m}$. The output state $S_{chr_{vis}}'$ has the form {$\langle C' + H + G , H_{k}\cup S ,Gr',$
\\$chr\left(H_r\right)=(H'_{r}) \wedge chr\left(H_{k}\right)=(H'_{k}) \wedge g \wedge B ,$}
$T \cup \{ \langle r,id\left(H_{k}\right) + id\left(H_{r}\right) \},H\_ann, H\_cons\rangle_{m}$.
Due to the fact that $S_{chr}$ is equivalent to $S_{chr_{vis}}$,it has the following form: $\langle G, H_{k}\uplus H_{r}\uplus S,B,T\rangle_{n}$. For the same program, the \textsf{CHR} rule $r$ is applicable producing $S_{chr}'$: \\{$\langle C ++ G , H_{k}\cup S ,
chr\left(H_r\right)=(H'_{r}) \wedge chr\left(H_{k}\right)=(H'_{k}) \wedge g \wedge B,$}
$T \cup \{ \langle r,id\left(H_{k}\right) + id\left(H_{r}\right) \rangle \}$
such that
\\ {$ \mycal{CT} \models \exists(B) \wedge \forall (B \implies \exists x' (chr\left(H_r\right)=(H'_{r}) \wedge chr\left(H_{k}\right)=(H'_{k}) \wedge g))$
}.
{Similarly, without loss of generarility the same variable renaming was used for both programs. Thus, the two new built-in stores are equivalent according to Definition} \ref{builtinequiv} {since only one possible matching would be possible since the original two states have equivalent stores.}
Moreover,
\[ H =
\begin{cases}
\left[c\#i:j\right] & \quad \text{if } c \text{ occurs in }H'_k\\
\left[\;\right] & \quad \text{otherwise}\\
\end{cases}
\].
In addition,
\[ Gr' =
\begin{cases}
remove\_gr\_obj\left(Gr,id\left(H'_{r}\right),H\_ann\right) & \quad \text{if the program communicates the head constraints to the visual tracer}\\
Gr & \quad \text{otherwise}\\
\end{cases}
\].
If a rule annotation ($r ==> ann\_cond | Aux\_cons'$) is applicable, then $C'=\left[Aux\_cons|C\right]$ where $(Aux\_cons')=Aux\_cons$ otherwise $C'=C\#r$.
\\ In both cases, the output states are still equivalent since the equivalence check neglects auxiliary constraints and the graphical store.
\begin{comment}
At this point, for $S_{chr_{vis}}'$ one of three cases is possible:
\begin{itemize}
\item \textbf{An annotation rule is applicable:}
\\In this case,
$S_{chr_{vis}}'$ has the form $\langle [cons\#id:occ|A] , Head \uplus St,Gra,Bu,T_H,H\_ann\rangle_{m}$.
However, if $cons\#id:occ$ was added to
where there exists a renamed, constraint annotation rule of the form:
$g\; ru\; @\; H'\;$
$==> Condition\; |\; Obj'$ where $cons$ is part of $H'$ and a substitution $\theta$
\\such that
$(chr(Head)=\theta(H')$
$\wedge Condition$ $\wedge$
\\$output\_graphical\_object(H', \theta, Obj')=Obj)$
and $ (ru, id(Head))\; \notin \;H\_ann $.
The output state $S_{chr_{vis}}''$ has the form: $\langle [Obj,cons\#id:occ|A],Head \uplus St,Gra,$
$Cond \wedge Bu,$
$T\_H , H\_ann \cup \{(r, id(H))\} \rangle_{m}$.
\\$S_{chr_{vis}}''$ triggers the transition \emph{draw} producing $S_{chr_{vis}}''':\langle [cons\#id:occ|A],Head \uplus St,Gra \cup \{Obj\#n\},$
$Bu,$
$T\_H , H\_ann \cup \{(r, id(H))\} \rangle_{m+1}$.
According to Definition \ref{def:eqchrvis}, $S_{chr_{vis}}'''$ is equivalent to $S_{chr}'$.
\item \textbf{No annotation rule is applicable}
\\At this point, $S_{chr_{vis}}'$ is still equivalent to $S_{chr}'$
\\
\end{itemize}
\end{comment}
\section{$CHR^{vis}$ to $CHR^{r}$ Transformation Approach}
\label{sec:trans}
The aim of the transformation is to eliminate the need of doing any compiler modifications in order to animate \textsf{CHR} programs.
A $CHR^{vis}$ program $P^{vis}$ is thus transformed to a corresponding $CHR^{r}$ program $P$ with the same behavior. $P$ is thus able to produce the same states in terms of \textsf{CHR} constraints and visual objects as well.
\begin{comment}
The transformation mainly aims at interfacing the \textsf{CHR} programs with the entered annotations to produce the needed visual states. Thus the original program $P$ is parsed and transformed into another program $P_{Trans}$. $P_{Trans}$ performs the same functionality as $P$. However, it is able to produce an animation for the executed algorithm for any input query.
\end{comment}
As a first step, the transformation adds for every constraint \verb+constraint/n+ a rule of the form:
\\\(
comm\_cons\_{constraint}\;@\;constraint\left(X_{1},X_{2},...,X_{n}\right)\; \Rightarrow\; check\left(status, false\right)\; |\; \)
\\\hspace*{3.7cm}\(communicate\_constraint\left(constraint\left(X_{1},X_{2},...,X_{n}\right)\right).\)
The extra rule ensures that every time a \verb+constraint+ is added to the store, the tracer (\emph{external module}) is notified. If \verb+constraint+ was annotated as an interesting constraint, its corresponding annotation rule is activated producing the corresponding visual object(s). The new rules communicate any \verb+constraint+ added to the constraint store.
The user can also choose to communicate to the tracer the head constraints since they could affect the animation. A removed head constraint could affect the visualization in case it is an interesting constraint. In this case, if the user chose to communicate head constraints, the associated visual object, produced before, should be removed from the visual trace.\footnote{The tracer is able to handle the problem of having multiple Jawaa objects with the same name by removing the old object having the same name before adding the new one. This is possible even if the removed head constraint was not communicated.}.
As a second step, the transformer adds for every compound constraint-annotation of the form:\\$cons_{1},\ldots,cons_{n}==>annotation\_constraint_{cons_{1},\ldots,cons_{n}}\left(Arg{1},\ldots,Arg_{m}\right)$, a new rule of the form:
\\$ compound_{cons_{1},\ldots,cons_{n}}\; @\; cons_{1}\left(Arg_{cons_{1_{1}}},\ldots,Arg_{cons_{1_{1x}}}\right), \ldots,cons_{n}\left(Arg_{cons_{n_{1}}},\ldots,Arg_{cons_{n_{ny}}}\right)$
\\$\Rightarrow check\left(status, false\right)\;|\; annotation\_constraint_{cons_{1},\ldots,cons_{n}}\left(Arg{1},\ldots,Arg_{m}\right)$.
By default, a propagation rule is produced to keep $cons_{1},\ldots,cons_{n}$ in the constraint store. However, the transformer could be instructed to produce a simplification rule instead. The annotation is triggered whenever $cons_{1},\ldots,cons_{n}$ exist in the constraint store. Whenever this is the case, the rule $compound_{cons_{1},\ldots,cons_{n}}$ is triggered producing the annotation constraint. Since the annotation constraint is a normal \textsf{CHR} constraint, it is automatically communicated to the tracer using the previous step.
As a third step, the \textsf{CHR} rules annotated by the user as interesting rules should be transformed. The idea is that the \textsf{CHR} constraints produced by such rules should be ignored. In other words, even if the rule produces an interesting \textsf{CHR} constraint, it should not trigger the corresponding constraint annotation. Instead, the rule annotation is triggered.
Hence, to avoid having problems with this case, a generic \emph{status} is used throughout the transformed program $P_{Trans}$.
Any rule annotated by the user as an interesting rule changes the \verb+status+ to $true$ at execution. However, the rules added in the previous two steps check that the status is set to $false$. In other words, if the interesting rule is triggered, no constraint is communicated to the tracer since the guard of the corresponding $communicate\_constraint$ rule fails.
Any rule $rule_{i} @ H_{K}\;\backslash\;H_{R}\; \Leftrightarrow\; G \;| \; B $ with the corresponding annotation $rule_{i}==>annotation\_constraint_{rule_{i}}$ is transformed to:
$rule_{i} @ H_{K}\;\backslash\;H_{R}\; \Leftrightarrow\; G \;|\;set\left(status,true \right),\; B,\;annotation\_constraint_{rule_{i}},\\\;set\left(status,false \right). $
In addition, the transformer adds the following rule to $P_{Trans}$:
\\$comm\_cons_{annotation\_constraint_{rule_{i}}}\;@\; annotation\_constraint_{rule_{i}} \;\Leftrightarrow$\\\hspace*{3.7cm}$\;communicate\_constraint\left(annotation\_constraint_{rule_{i}} \right)$.
\\The new rule thus ensures that the events associated with the rule annotation are considered and that all annotations associated with the constraints in the body of the rule are ignored.
\subsection{Correctness of Transformation Approach}
The aim of the transformation process is to produce a $CHR^{r}$ program ($P_{trans}$) that is able to perform the same behavior of the corresponding $CHR^{vis}$ program ($P_{vis}$) which basically contains the original \textsf{CHR} program $P$ along with the constraint(s) and rule annotations. This section shows that the transformed program, using the steps shown previously, is a correct one. In other words, for the same query $Q$, $P_{trans}$ produces an equivalent state to the one produced by $P$. As seen from the previous section $\omega_{vis}$ was proven to be sound and complete. This implies that any state reachable by $\omega_{r}$ is also reachable by $\omega_{vis}$. In addition, any state reachable by $\omega_{vis}$ is also reachable by $\omega_{r}$. The focus of this section is the initial \textsf{CHR} program provided by the user. The aim is to make sure that $P_{trans}$ produces the same \textsf{CHR} constraints that $P$ produces to make sure that the transformation did not change the behavior that was initially intended by the programmer. The focus is thus to compare how $P$ and $P_{trans}$ perform over $\omega_{r}$.
\begin{theorem}
Given a \textsf{CHR} program $P$ (along with its annotations) and its corresponding transformed program $P_{trans}$ and two states $S_{1} = \langle G, \phi \rangle$ and $S_{2} = \langle G, \phi \rangle$ where $G$ contains the initial goal constraints and $Aux'$ is a set of auxiliary constraints. Then the following holds:
\\If
\( S_{1} \xmapsto[\omega_{r}]{P} \mathrel{\vphantom{\to}^*} S_{1}^{'}\)
and \(S_{2}\xmapsto[\omega_{r}]{P_{trans}} \mathrel{\vphantom{\to}^*} S_{1}^{'} \cup Aux'\)
then $P_{trans}$ is equivalent to $P$
\end{theorem}
\begin{proof}(Sketch)
The below sketch shows how the constraint store changes over the course of running the same query $Q$ in $P$ and $P_{trans}$.
\\Executing a query in $P$ takes the following steps. The store at each step starts with the final value of the previous one
\begin{enumerate}
\item Step 1: The constraint store of $P$ ($S_{P}$) start off by being empty ($\phi$).
$S_{P_{step 1}}=\phi$.
\item Step2: The constraints in the query start to get activated and enter the constraint store $S_{P}$. $S_{P_{step 2}}$ starts off by being equal to $S_{P_{step 1}}$. Every time a constraint $c$ gets activated, it enters the store converting $S_{P_{step 2}}$ to $S_{P_{step 2}}\cup c$.
\begin{comment}
\item Step 2: The constraints in the query start to get activated and enter the constraint store $S_{P}$. $S_{P_{step 2}}$ starts off by being equal to $S_{P_{step 1}}$. Every time a constraint $c$ gets activated, it enters the store $S_{P_{step 2}}$ becomes $S_{P_{step 2}}\cup c$.
\end{comment}
\item Step 3:
Applying a rule $ r @ H_{k} \backslash H_{r}\; \Leftrightarrow \; Gu \; | \;B$, adds $B$ to $S_{P}$. The components of $H_{r}$ are also removed from it.
Thus after the rule application, $S_{P_{step 3}} = S_{P_{step 2}} \cup B - H_{r}$.
\item Step 4: Go Back to step 3. Any applicable rule is fired changing the constraint store. Step 3 keeps on repeating until no more rules are applicable reaching a fixed point.
\end{enumerate}
In $P_{trans}$ executing the same query undergoes the following steps. Similarly, the store at each step starts with the final value of the previous one
\begin{enumerate}
\item Step 1: Initially the constraints store is also empty. Thus, $S_{P_{trans_{step 1}}}=\phi$.
\item Step 2: The query constraints start to get activated and enter the constraint store $S_{P_{trans}}$. $S_{P_{trans_{step 2}}}$ starts off by being equal to $S_{P_{trans_{step 1}}}$. When a constraint $c$ gets activated, it enters the store. $S_{P_{trans_{step 2}}}$ thus is augmented with $c$ and the result is $S_{P_{trans_{step 2}}} = S_{P_{trans_{step 2}}}\cup c$.
\item Step 3: In $P_{trans}$, each time a constraint gets activated and enters the store, the corresponding rule: $comm\_cons\_{constraint}$ is triggered. $comm\_cons\_{constraint}$ is a propagation rule. Thus it does not remove any constraint from the store. The body of the rule communicates the constraint to the tracer, not adding anything to the store as well.
At this point $S_{P_{trans_{step 3}}}=S_{P_{trans_{step 2}}}$.
\item Step 4 (Optional): In $P_{trans}$, if there are any compound annotations for constraints ($cons_{1},\ldots,cons_{n}$) in $S_{P_{trans}}$, the corresponding rule $compound_{cons_{1},\ldots,cons_{n}}$ is fired adding to the $S_{P_{trans}}$ the auxiliary constraint: \\$annotation\_constraint_{cons_{1},\ldots,cons_{n}}\left(Arg{1},\ldots,Arg_{m}\right)$.
\\$annotation\_constraint_{cons_{1},\ldots,cons_{n}}\left(Arg{1},\ldots,Arg_{m}\right)$ fires the corresponding $comm\_cons\_{constraint}$ rule.
Thus, $S_{P_{trans_{step 4}}}=S_{P_{trans_{step 3}}}\cup Aux_{cons}$ where $Aux_{cons}=annotation\_constraint_{cons_{1},\ldots,cons_{n}}\left(Arg{1},\ldots,Arg_{m}\right)$.
\item Step 5: $P$ contains the same \textsf{CHR} rules as in $P_{trans}$. Consequently, whenever a rule is applicable in $P$, the same rule will be also applicable in $P_{trans}$.
Applying a rule $ r @ H_{k} \backslash H_{r}\; \Leftrightarrow \; Gu \; | \;B$, adds $B$ to $S_{P}$. The components of $H_{r}$ are also removed from the store.
Thus after the rule application, $S_{P_{trans_{step 5}}} = S_{P_{trans_{step 4}}} \cup B - H_{r}$.
In case $r$ has an associated annotation rule, Once the constraints in $B$ are added to the store, the corresponding rules $comm\_cons\_{constraint}$ are matched. However, since their guard fails (as the status is set to true in $P_{trans}$, the rules do not file.
In case $r$ has an associated annotation rule, the auxiliary constraint $annotation\_constraint_{r}$ is added to the store. Afterwards, $annotation\_constraint_{r}$ triggers the simplification rule $comm\_cons_{annotation\_constraint_{rule_{i}}}$ communicating the $annotation\_constraint_{r}$ constraint to the tracer. Since the rule is a simplification rule, $comm\_cons_{annotation\_constraint_{rule_{i}}}$ is then removed from the constraint store keeping $S_{P_{trans_{step 5}}} = S_{P_{trans_{step 4}}} \cup B - H_{r} $.
\item Step 3 and 4 could be applied for the new constraint store. As sen previously, step 3 does not change the constraint store. Step 4 could however add some auxiliary constraints to $S_{P_{trans_{step 5}}}$.
\end{enumerate}
\begin{comment}
\begin{enumerate}
\item Step2, the constraints in the query start to get activated and enter the constraint stores $S_{P}$ and $S_{P_{trans}}$. At this point $S_{P}=S_{P_{trans}}=S_{initial}$.
\item Step 3: In $P_{trans}$, each time a constraint gets activated, the corresponding rule: $comm\_cons\_{constraint}$ is triggered. $comm\_cons\_{constraint}$ is propagation rule, thus it does not remove any constraint from the store. The body of the rule communicates the constraint to the tracer, not adding anything to the store as well.
At this point $S_{P}=S_{P_{trans}}=S_{initial}$.
\item Step 4 (Optional): In $P_{trans}$, if there are any compound annotations for constraints ($cons_{1},\ldots,cons_{n}$) in $S_{P_{trans}}$, the corresponding rule $compound_{cons_{1},\ldots,cons_{n}}$ is fired adding to the $S_{P_{trans}}$ the auxiliary constraint: $annotation\_constraint_{cons_{1},\ldots,cons_{n}}\left(Arg{1},\ldots,Arg_{m}\right)$.
$annotation\_constraint_{cons_{1},\ldots,cons_{n}}\left(Arg{1},\ldots,Arg_{m}\right)$ fires the corresponding $comm\_cons\_{constraint}$ rule.
Thus, $S_{P_{trans_{step 4}}}=S_{initial}\cup Aux_{cons}$ where $Aux_{cons}=annotation\_constraint_{cons_{1},\ldots,cons_{n}}\left(Arg{1},\ldots,Arg_{m}\right)$.
\item Step 5:
$P$ contains the same \textsf{CHR} rules as in $P_{trans}$. Consequently, whenever a rule is applicable in $P$, the same rule will be also applicable in $P_{trans}$.
Applying a rule $ r @ H_{k} \backslash H_{r}\; \Leftrightarrow \; Gu \; | \;B$, adds $B$ to $S_{P}$. The components of $H_{r}$ are also removed from.
Thus after the rule application, $S_{P} = S_{initial} \cup B - H_{r}$.
The same rule is applied in $P_{trans}$. $S_{P_{trans_{step 5}}} \cup B - H_{r} $.
In case $r$ has an associated annotation rule, Once the constraints in $B$ are added to the store, the corresponding rules $comm\_cons\_{constraint}$ are matched. However, since their guard fails (as the status is set to true in $P_{trans}$, the rules do not file.
In case $r$ has an associated annotation rule, the auxiliary constraint $annotation\_constraint_{r}$ is added to the store. Afterwards, $annotation\_constraint_{r}$ triggers the simplification rule $comm\_cons_{annotation\_constraint_{rule_{i}}}$ communicating the $annotation\_constraint_{r}$ constraint to the tracer. Since the rule is a simplification rule, $comm\_cons_{annotation\_constraint_{rule_{i}}}$ is then removed from the constraint store keeping $S_{P_{trans_{step 5}}} \cup B - H_{r} $.
\item Keep on repeating from Step 3
\end{enumerate}
\end{comment}
\end{proof}
As seen before, in all the previous steps, either $S_{P_{trans}}= S_{P}$ or $S_{P_{trans}}= S_{P}\cup Aux$ where $Aux$ contains some extra auxiliary constraints. Thus, the transformation does not change in the intended application of $P$.
\begin{comment}
As a start, the constraints in the query start to get activated and enter the constraints store.
Table~\ref{tab:table1} shows the first step of executing $P$ under $\omega_{r}$.
The constraints inside the query start to get activated.
For $P_{trans}$, the first step is also activating the constraints in the query.
Each time a constraint gets activated, its corresponding $comm\_cons\_{constraint}$ is applied. $comm\_cons\_{constraint}$ is a propagation rule, thus the constraint store is not affected.
The case in which, a group of activated constraints are annotated with a compound constraint annotation is shown in Table~\ref{tab:table3}.
As a first step, one rule of the program $P$ under $w_r$ starting with $S_{1}$. On the other hand, ~\ref{tab:table2,tab:table3,tab:table4,tab:table5} show the steps of executing the transformed program $T(P)$ under $w_r$ starting with $S_{2}$.
rule application right away
previous state the same in both
new state in old kaza
in new one of four possible cases
no annotation
rule annotation
constraint annotation
compound constraint annotation
initial query constraints
one of three cases
no annotations
constraint annotation
compound constraint annotation
\begin{table}[ht]
\begin{tabular}{ l l p{8.25cm} }
\hline
\(\)& $ \langle [c|G], \phi \rangle_{n}$ & $[c|G]$ contains initial query constraints \\
$ \xmapsto[\text{activate}]{}\mathrel{\vphantom{\to}^*} $ & $ \langle [c\#n:1|G], [c\#n] \rangle$ & The constraints in the query start to get activated one by one \\
\hline
\end{tabular}
\caption{Running $P$ under $\omega_{r}$: activating the query constraints}
\label{tab:table1}
\end{table}
\begin{table}[ht]
\begin{tabular}{ l l p{6cm} }
\hline
\(\)& $ \langle [c|G], \phi \rangle_{n}$ & $[c|G]$ contains initial query constraints \\
$ \xmapsto[\text{activate}]{}\mathrel{\vphantom{\to}^*} $ & $ \langle [c\#n:1|G], [c\#n] \rangle$ & The constraints in the query start to get activated one by one \\
$ \xmapsto[\text{applying comm\_cons\_{constraint}}]{}\mathrel{\vphantom{\to}^*} $ & $ \langle [c\#n:1|G], [c\#n] \rangle$ & Each constraint gets communicated to the tracer.\\
\hline
\end{tabular}
\caption{Running $P_{trans}$ under $\omega_{r}$: activating the query constraints}
\label{tab:table2}
\end{table}
\begin{table}[ht]
\begin{tabular}{l l p{6cm}}
\hline
\(\)& $ \langle G, S \rangle_{n}$ & Some constraints were activated and entered to the store \\
$ \xmapsto[\text{activate}]{}\mathrel{\vphantom{\to}^*} $ & $ \langle [c\#n:1|G], [c\#n] \rangle$ & The constraints in the query start to get activated one by one \\
$ \xmapsto[\text{applying comm\_cons\_{constraint}}]{}\mathrel{\vphantom{\to}^*} $ & $ \langle [c\#n:1|G], [c\#n] \rangle$ & Each constraint gets communicated to the tracer.\\
\hline
\end{tabular}
\caption{Running $P_{trans}$ under $\omega_{r}$: Compound constraint annotation}
\label{tab:table3}
\end{table}
\begin{table}[!ht]
\begin{tabular}{ l l p{8.25 cm} }
\hline
& $ \langle G, \phi \rangle$ & $G$ contains the initial query constraints. \\
$ \xmapsto[\text{introduce}]{}\mathrel{\vphantom{\to}^*} $ & $ \langle \phi, S \rangle$ & The store $S$ contains all the activated goal constraints and the auxiliary constraints \\
$ \xmapsto[\text{apply comm\_cons\_{constraint}}]{}\mathrel{\vphantom{\to}^*} $ & $\langle \phi , S \rangle$ & $comm\_cons\_{constraint}$ are propagation rules. Thus, the constraint store is not affected by their application. \\
\hline
\end{tabular}
\caption{$P_{trans}$: Computation of step 1 (Constraints Communicated)}
\label{tab:table22}
\end{table}
\begin{table}[!ht]
\begin{tabular}{ l l p{8.25 cm} }
\hline
& $ \langle G, \phi \rangle$ & $G$ contains the initial query constraints. \\
$ \xmapsto[\text{introduce}]{}\mathrel{\vphantom{\to}^*} $ & $ \langle \phi, S \rangle$ & The store $S$ contains all the activated goal constraints and the auxiliary constraints \\
$ \xmapsto[\text{apply comm\_cons\_{constraint}}]{}\mathrel{\vphantom{\to}^*} $ & $\langle \phi , S \rangle$ & $comm\_cons\_{constraint}$ are propagation rules. Thus, the constraint store is not affected by their application. \\
\hline
\end{tabular}
\caption{$P_{trans}$: Computation of step 2 (Compound Constraint Application)}
\label{tab:table33}
\end{table}
\end{comment}
\section{Applications}
\label{sec:app}
This section introduces different applications of the proposed semantics.
The applications cover different fields were animations were useful.
\subsection{Animating Java Programs}
The idea of annotating constraints with visual objects was extended to Java programs in \cite{DBLP:conf/iv/SharafAF16}. The execution path of the new programs is shown in Figure \ref{fig:javaexecpath}.
\begin{figure}%
\centering
\includegraphics[width=70mm]{javaarchi.png}%
\caption{New Execution Path}%
\label{fig:javaexecpath}%
\end{figure}
Using visual annotation rules of \textsf{CHR} programs, Java programs could also be animated in a generic way.
The objective is to annotate method calls as interesting events. They are thus linked with visual objects. Thus, every time a method is invoked, its corresponding visual object is added. This results in animating the algorithm while it is running.
That way, the user does not have to get into any of the technical details of how the visualization is produced. They only need to state what they want to see.
For every interesting method $m\left(arg_1,\ldots,arg_n\right)$, one \textsf{CHR} rule is produced.
The rule simply communicates the fact the the method $m$ with the arguments $arg_1,\ldots,arg_n$ was called in the Java program.
The rule has the following format:
\begin{Verbatim}
m(arg_1,...,arg_n) ==> communicate_event(m(arg_1,...,arg_n)).
\end{Verbatim}
\begin{comment}
\[m(arg_1,\ldots,arg_n) ==> communicate\_event(m(arg_1,\ldots,arg_n)).\]
\end{comment}
For example, the below Java program performs the bubble sort algorithm:\footnote{The program uses the same algorithm provided in www.mathbits.com/MathBits/Java/arrays/Bubble.htm.}
\begin{lstlisting}[frame=single]
public class MySort {
public static void main(String[]args)
{
initializeAndSort();
}
public static void setValue(int[]num, int index, int newValue)
{
num[index]=newValue;
}
public static void initializeAndSort()
{
int[] numbers = new int[4];
setValue(numbers, 0, 20);
setValue(numbers, 1, 10);
setValue(numbers, 2, 5);
setValue(numbers, 3, 1);
boolean swapped = true;
int temp;
while (swapped==true) {
swapped=false;
for (int i = 0; i < numbers.length - 1; i++) {
if (numbers[i] > numbers[i + 1])
{
temp = numbers[i]; // swap elements
setValue(numbers,i,numbers[i+1]);
setValue(numbers, i+1, temp);
swapped = true;
}
}
}
}
}
\end{lstlisting}
As seen in Figure \ref{fig:javaann}, each Java method is annotated by linking it to an object. Similarly, the panel is populated with the corresponding visual aspects of the chosen object (node in the shown example).
The user can enter for every parameter a constant value. The value of the parameter could also be linked to one of the arguments of the annotated method through using the built-in function \verb+valueOf/1+.
\begin{figure}[!ht]%
\includegraphics[width=110mm]{newAnn.png}%
\caption{Annotating a Java method}%
\label{fig:javaann}%
\end{figure}
In the previous example, each time the method \verb+setValue/3+ is called, a node is generated. The position of the node is calculated through the argument $index$. Its height is a factor of the argument $value$.
Thus every time a value changes inside the array, the corresponding node is produced. This leads to visualizing the array and the changes happening to it.
The produced step-by-step animation is shown in Figure \ref{fig:animBubbleJava}.
Animating Java programs in the shown way is a generic one since it does not restrict the user to any specific visual data structure. It uses Jawaa providing the basic visual structures which could be used to do target animations. Such animations could also be prepared before or done while executing the code. In addition, since the system is built through SWI-Prolog, this makes it portable.
\begin{figure}
\centering
\begin{tabular}{ccc}
\subfloat{\includegraphics[width=20mm]{initial}} &
\subfloat{\includegraphics[width=20mm]{initial1}} &
{\subfloat{\includegraphics[width=20mm]{initial2}}} \\
{\subfloat{\includegraphics[width=20mm]{initial3}}} &
\subfloat{\includegraphics[width=20mm]{initial4}} &
\subfloat{\includegraphics[width=20mm]{initial5}}\\
\end{tabular}
\caption{Bubble Sort Animation}
\label{fig:animBubbleJava}
\end{figure}
\subsection{Building Platforms to teach Mathematics through Animation}
In \cite{DBLP:conf/ruleml/SharafAF16}, the concept of animating programs was used to build a platform to practice different mathematical concepts. The user is offered with different ways to specify what the mathematical rule is.
The specified definition is then transformed into \textsf{CHR} programs.
For a simple rule, the user specifies a name for the rule, its input(s) and output as seen in Figure \ref{fig:simplerulefigure}.
\begin{figure}[!ht]
\centering
\subfloat[Simple rule: Homepage]{\label{fig:fig2a}\includegraphics[width=60mm]{initalnew}}
~
\subfloat[Adding a new input]{\label{fig:fig2b}\includegraphics[width=60mm]{addinginputSimple}}
\\
\subfloat[Editing output]{\label{fig:fig2c}\includegraphics[width=60mm]{addingoutsimplenew}}
~
\subfloat[Summation rule defined]{\label{fig:fig2d}\includegraphics[width=60mm]{simplenewfinal}}
\caption{Simple rules: inputs and outputs.}
\label{fig:simplerulefigure}
\end{figure}
The user chooses how a number should be visualized. A number $n$ could be linked with any Jawaa object. It could be also linked to a number ($m$) of Jawaa objects as shown in Figure \ref{fig:linkmaths}. In that example, each number $n$ is linked to $n$ Jawaa image objects. Each image object has an x-coordinate and a y-coordinate and a path. An image object displays the image in the specified path.
\begin{figure}[!ht]
\centering
\includegraphics[width=90mm]{mathsnobj}
\caption{Link a number to a visual object}
\label{fig:linkmaths}
\end{figure}
The parameter $valueOf\left(N\right)$ has a value of $0$ for the first object, $1$ for the second, $\ldots$, etc.
Two applications were built using the animation.
The first one is shown in Figure \ref{fig:figmathapp1}. The inputs are shown to the user. A number $x$ was annotated with $x$ image objects with a path to an apple image. Thus each number $x$ is shown as $x$ apples. As seen from the figure, the actual y-coordinate shown to the user is a multiple of the value entered while annotation. Thus, every number is shown on one line. Users then click on ``Add Output'' to formulate their designated output. Since the output is a number, it is visualized in the same way. At any point, the user can choose to check their answer to get a corresponding message.
More details of the input generation is shown in \cite{DBLP:conf/ruleml/SharafAF16}. It is done randomly. However, it can also take into account some constraints/boundaries entered by the user.
\begin{figure}[!ht]
\centering
\subfloat[Inputs]{\label{fig:fig5a}\includegraphics[width=60mm]{inputsnewapp}}
~
\subfloat[Editing output I]{\label{fig:fig5b}\includegraphics[width=60mm]{newappout1}}
\\
\subfloat[Editing output II]{\label{fig:fig5c}\includegraphics[width=60mm]{finaloutnewapp}}
\caption{Quiz 1}
\label{fig:figmathapp1}
\end{figure}
Another possible animation (shown in Figure \ref{fig:figmaths2}) is to:
\begin{enumerate}
\item Link every input number with a normal Jawaa circular node. The text inside
the node is its value. Its background is blue.
\item Link the output with a random number of nObjects displaying a group of
nodes. Each node is placed in a random position. The text inside each node
is also a random number. Such nodes have green backgrounds
\item Link the output with a Jawaa circular node with the name (\verb+jawaanodeout+)
displaying the actual output of the rule. It is also placed at a random position.
Its background is green as well. The output thus has two groups of nodes associated to it.
\item Add an annotation rule linking the output constraint with an \verb+onclick+ command
for the object \verb+jawaanodeout+. Once it is clicked, the \verb+changeParam+
command is activated changing its color to red. Thus the only node whose color changes when clicked is the correct output node.
\end{enumerate}
\begin{figure}[!ht]
\centering
\subfloat[Randomly placed nodes]{\label{fig:fig6a}\includegraphics[width=75mm]{without111}}
\\\subfloat[Highlighted node after clicking]{\label{fig:fig6b}\includegraphics[width=75mm]{with1111}}
\caption{Quiz 2}
\label{fig:figmaths2}
\end{figure}
\subsection{Animating Cognitive Models}
Another application of animating \textsf{CHR} programs was using it to animate cognitive architectures and the execution of cognitive models through them as shown in \cite{DBLP:conf/gcai/Nada}.
A cognitive architecture includes the basic aspects of any cognitive agent. It consists of different correlated modules \cite{CBO9780511816772A008}.
Adaptive Control of Thought-Rational (ACT-R) is a well-known cognitive architecture. It was developed to deploy models in different fields including, among others, learning, problem solving and languages \cite{anderson_atomic_1998,Anderson04anintegrated}.
Through animating the execution, users get to see at each step not only details about the model. However, they are also able to visually see the modules of the architecture at all steps of execution.
The idea is to use the previously proposed \textsf{CHR} implementation of ACT-R \cite{Daniel:thesis}. The implementation represented the ACT-R architecture and how models are executed through \textsf{CHR} constraints and rules.
This section shows how animation was achieved through using annotation rules.
ACT-R \cite{anderson_atomic_1998,Anderson04anintegrated} is a cognitive architecture used to execute different type of models simulating human behavior.
ACT-R has different modules integrated together to simulate the different components of the mind that have to work together to reach plausible cognition. ACT-R has different types of buffers holding pieces of information/chunks. At each point in time, a buffer can have one piece of information.
A module can only access the contents of a buffer through issuing a request that is handled by the procedural module.
ACT-R chooses at each step an applicable production rule for execution.
In its \textsf{CHR} implementation, execution is triggered by the constraint \verb+run/0+. $run$ is associated with multiple annotation rules to produce the initial view of the architecture as shown in Figure \ref{fig:basicmodules}.
Figure \ref{fig:basicmodules} shows the basic ACT-R modules.
\begin{figure}[!ht]
\centering
\includegraphics[width=80mm]{basicmodules2.png}
\caption{A snapshot of the first panel the user gets. It shows the basic modules of ACT-R as described in \cite{Daniel:thesis,inbookcog}}
\label{fig:basicmodules}
\end{figure}
\subsubsection{Declarative Module}
\(\)\\This module holds the information humans are aware of. Its corresponding buffer is referred to as the retrieval buffer. Information is represented as chunks of data. Each chunk has a type.
In the \textsf{CHR} implementation, the information chunks are represented with the \textsf{CHR} constraints: \verb+chunk/2+ and \verb+chunk_has_slot/3+.
\verb+chunk(N,T)+ {represents a chunk named} $N$ with the type $T$. {For example}, \verb+chunk(d,count_order)+ represents a chunk named $d$ with type $count\_order$. On the other hand, \verb+chunk_has_slot/3+ represents the values in the slots of a chunk. {The two constraints} \verb+chunk_has_slot(d,first,3)+ and \verb+chunk_has_slot(d,second,4)+
represent that chunk $d$ has the values $3$ and $4$ in the slots $first$ and $second$ respectively. This represents the information that $3$ is less than $4$.
\subsubsection{Buffer System}
\(\)\\
\begin{figure}[!ht]
\centering
\subfloat[The retrieval buffer is empty. Its state is busy.]{
\label{subfig:fig1}
\includegraphics[width=95mm]{step1buffers} }
\subfloat[As a result of a request made, the retrieval buffer has $c$ and its state is free.]{
\label{subfig:fig2}
\includegraphics[width=95mm]{step2buffers} }
\subfloat[The buffer is performing a request. Its state is busy.]{
\label{subfig:fig3}
\includegraphics[width=95mm]{step3buffers}}
\subfloat[The buffer contains $d$ and it is free again]{
\label{subfig:fig4}
\includegraphics[width=95mm]{step4buffers}}
\caption{Buffer System Visualization}
\label{fig:buffers}
\end{figure}
The \textsf{CHR} constraint \verb+buffer(B,C)+ represents the fact that buffer \verb+B+ is holding the chunk $C$. The state $S$ of a buffer $B$ is represented by the constraint \verb+buffer_has_state(B,S)+.
A buffer has one of three states: either $free$, $busy$ or $error$. The buffer is $busy$ while completing a request.
The state of a buffer is set to $error$ if the request was not successful.
As shown in Figure \ref{fig:buffers}, each buffer is associated with several visual features.
First of all, \verb+buffer(B,C)+ is annotated with a textual object showing the content of the buffer. Each \verb+buffer(B,C)+ also produces a circular colored (initially green) node. \verb+buffer_has_state(B,S)+ is associated with annotation rules that change the color of the circular node according to the value of $S$.
\subsubsection{Procedural Module: Timing \& Prioritizing Actions in ACT-R}
\(\)\\
\begin{figure}
\captionsetup[subfloat]{farskip=2pt,captionskip=1pt}
\centering
\subfloat[][]{\includegraphics[width=55mm]{step2actr.png} \label{fig:step2}
\quad
\subfloat[][do\_conflict\_resolution is dequeued. The rule \emph{start} is a matching rule chosen to be applied.]{\includegraphics[width=55mm]{step3actr.png} \label{fig:step3}}
\quad
\subfloat[][apply\_rule(start) is dequeued]{\includegraphics[width=55mm]{step4actr.png} \label{fig:step4}}
\quad
\subfloat[][The action events of \emph{start} are added to the queue.]{\includegraphics[width=55mm]{step6newactr.png} \label{fig:step6}
\quad
\subfloat[][Starting requesting the declarative module]{\includegraphics[width=55mm]{step8actr.png} \label{fig:step8}
\subfloat[][]{\includegraphics[width=55mm]{step9newactr.png} \label{fig:step9}
\quad
\subfloat[][]{\includegraphics[width=55mm]{step12actr.png} \label{fig:step12}
\caption{Animating Scheduling}
\label{fig:cont4}
\end{figure}
The current timing of the ACT-R system is represented in its \textsf{CHR} implementation by a constraint \verb+now/1+.
The initial constraint $run$ produces a textual object. $now$ is associated with an annotation rule to change the value of the text.
The implementation has a central scheduling unit which keeps track of the events to be performed and their timings.
The \textsf{CHR} implementation uses a priority queue to keep track of the actions. The scheduler removes the first event in the queue from time to time.
Event $A$ precedes $B$ in the queue if $A$ has less timing than $B$. If they have the same timings, $A$ precedes $B$ if it has a higher priority.
The order of elements in the queue is represented by the constraint \verb+->/2+. \verb+A -> B+ means that $A$ precedes $B$.
The initial constraint $run$ produces a Jawaa queue object.
The constraint $A->B$ is associated with a rule that fires an action to insert in the queue $B$ after $A$. An example is shown in Figure \ref{fig:cont4}.
\section{Related Work}
In general, algorithm animation or software visualization produces abstractions
for the data and the operations of an algorithm. The different states of
the algorithm are represented as images that are animated according to the
different interactions between such states \cite{bookintro}. In \cite{DBLP:journals/vlc/HundhausenDS02}, some of the scenarios
in which Algorithm Visualization (AV) could be used were discussed. Such
scenarios include using AV technologies in lecture slides, or in practical laboratories,
or for in-class discussions, or in assignments where students could
for example produce their own visualizations or in office hours for instructors
to find bugs quickly. Moreover, such visualizations could be useful for
debugging and tracing the implementations of different algorithms.
In \cite{DBLP:journals/vlc/HundhausenDS02}, a meta-study of 24 experimental studies was performed. Through
the analysis done it was found that such visualizations are educationally
effective.
As introduced in \cite{DBLP:journals/vlc/HundhausenDS02}, eleven studies show significant difference between a
group of study using some configuration of AV technology and another group
that is either not using AV technology at all or using a different configuration.
In \cite{DBLP:journals/vlc/HundhausenDS02}, after performing the analysis, it was found out that the biggest impact
on educational effectiveness results from how students use AV technology
rather than what they see.
In \cite{developing}, a visualization tool for Artificial Intelligence (AI) searching algorithms
was introduced. Moreover, a study was performed in order to know
the effect of using the tool on students. According to \cite{developing}, students who have better visual representation of the changing data structures understood
the algorithms better. The results of the performed study suggest that using
visualization tools could help students in understanding such searching
algorithms.
Several systems and steps towards visualizing the execution of the different
types of algorithms have been made.
For example in \cite{Baec:98}, a 30-minute film designed to teach nine sorting algorithms
was used for algorithm animation as an alternative to doing such
demonstration manually on a board.
Some systems have also provided their users with the possibility to visualize
the execution of different algorithms. For example, XTANGO \cite{Stasko:xtango} is a general
purpose animating system that supports the development of algorithm
animations where the algorithm should be implemented in C or another language
such that it produces a trace file to be read by a C program driver.
The important operations and events that should be highlighted during the
execution of the program should also be portrayed.
Another system is BALSA \cite{Brown:1984:SAA:800031.808596}, in which the notion of interesting events was
used where the animator and the algorithm designer have to agree on a plan
for visualization to identify interesting events that could change the visualized
images.
Zeus \cite{DBLP:conf/vl/Brown91}, also uses the notion of interesting events and annotates the algorithm
with markers that identify the basic operations. In Zeus, its preprocessor
Zume, reads the event specifications and generates definitions for
algorithm and view classes.
In \cite{238854}, and \cite{Eisenstadt:1987:GDT:1625015.1625030}, visualization of logic programs was presented. In \cite{238854},
logic programs were graphically represented using a variation of cyclic AND/OR
graphs. The structure of logic programs was represented through static
graphs that show and correspond to the structure of the source code. Dynamic
graphs show steps of the solution. Finally, a set of binding dependency
graphs were used for showing how the values of the different variables were
generated.
In \cite{Eisenstadt:1987:GDT:1625015.1625030}, Augmented AND/OR trees (AORTA) were used for having a tracing
and debugging facility for Prolog. In the produced graphs all subgoals and
bindings are shown.
On the other hand some visualization tools were offered for constraint
programs specifically. For example, in \cite{debuggingcp}, the tool Grace, was offered as a
constraint tracing environment on top of ECLiPSe \cite{DBLP:citeseer_oai:CiteSeerX.psu:10.1.1.53.5817} where the focus is on
the search space and the domains. The main target of Grace is CLP(FD) programs specifically programs that use labeling of finite domains and backtracking
search. The FD variables and their domains are shown to users. In
addition, a variable stack is used to display the current position in the search
space where each row corresponds to a labeled variable. The variable's domain
in addition to the depth in the search space and the variable position
are also shown through the rows. The displayed domains also differentiate
between the current values, the values that are still be to be tried and the
values that have been tried and failed.
The Oz Explorer provided through \cite{ozexp} also supports the development of
constraint programs. This visual constraint programming tool is provided
for the language Oz \cite{kerneloz,Vol1000} which is a concurrent constraint language. The
visualized object in this tool is the search space. The search tree is visualized
as it is explored. Nodes carry information about corresponding constraints.
Users could interact with the visualized tree through expanding and collapsing
different parts.
Similarly, in \cite{Simonis:2000:SV:646018.678425}, the main focus is on search trees and the offered tool is used
for debugging and analyzing trees generated from different finite domain constraint
programs. The tool offers different views for the user through which
he/she is able to build up information regarding the variables and their domains,
in addition to the search tree and the constraints. Users are offered
information regarding search and constraint propagation. They could also
view and analyze the change of constraints and variables along a path of the
tree.
\section{Conclusions}
In conclusion, the paper presented a formalization for embedding animation features into \textsf{CHR} programs.
The new extension, $CHR^{vis}$ is able to allow for dynamic associations of constraints and rules with visual objects. The annotation rules are thus activated on the program's execution to produce algorithm animations.
Although the idea of using interesting events was introduced in earlier work, it was (to the best of the authors' knowledge) never formalized before. In fact, no operational semantics for animation was proposed before. The paper offered operational semantics for $CHR^{vis}$. It thus provides a foundation for formalizing the animation process in general and for \textsf{CHR} programs in particular.
In the future, with the availability of formal foundations through $\omega_{vis}$ and $\omega_{vis_{r}}$, the possibility of using $CHR^{vis}$ as the base of a pure a visual representation for \textsf{CHR} should be investigated.
\begin{comment}
| {'timestamp': '2017-06-07T02:06:39', 'yymm': '1706', 'arxiv_id': '1706.01755', 'language': 'en', 'url': 'https://arxiv.org/abs/1706.01755'} | arxiv |
\section{Introduction} \label{sec:intro}
Determinism versus randomization in algorithm design is a fundamental concern in computer science and is the topic of a great many works in complexity theory. In ``space-constrained'' models such as communication complexity and data streaming, basic results show that derandomization can entail an exponential or worse blow-up in cost. For instance, in the two-party communication setting, the very basic $n$-bit \textsc{equality} problem admits a bounded-error randomized protocol with only $O(1)$ communication ($O(\log n)$ if restricted to private coins), whereas its deterministic communication complexity is as large as it gets, namely $n+1$. In the data streaming setting, the similarly basic \textsc{distinct-elements} problem admits a one-pass bounded-error randomized algorithm that uses $O(\log n)$ space to provide a $(1+\varepsilon)$-approximation~\cite{KaneNW10-pods}, whereas a deterministic algorithm would require $\Omega(n)$ space, even if multiple passes and large approximation factors are allowed~\cite{ChakrabartiK16}. In this work, we explore such a price-of-determinism phenomenon in the \emph{query complexity} world, for a similarly basic search problem.
The focus of our study is a search problem that we call \textsc{element-extraction} (henceforth, $\elemx$), where the input is a set $Z \subseteq [n] := \{1,\ldots,n\}$, promised to be nonempty, and the goal is to extract any element from $Z$. Formally, this is a total search problem given by the relation $\elemx_n \subseteq 2^{[n]} \times [n]$, where
\begin{align} \label{eq:elemx-def-set}
\elemx_n = \left\{ (Z,i) : Z \subseteq [n],\, i \in [n],\, \text{and } |Z| > 0 \Rightarrow i \in Z \right\} \,.
\end{align}
As is often the case, the natural correspondence between sets in $2^{[n]}$ and vectors in $\b^n$ will be useful. Indeed, we shall freely switch between these two viewpoints, using the notational convention that uppercase letters denote sets and their corresponding lowercase boldface variants denote characteristic vectors. Thus, we can also formalize $\elemx$ as
\begin{align} \label{eq:elemx-def-vec}
\elemx_n = \left\{ (\mathbf{z},i) : \mathbf{z} = (z_1, \ldots, z_n) \in \b^n,\, i \in [n],\, \text{and } \mathbf{1}^\mathsf{T} \mathbf{z} > 0 \Rightarrow z_i = 1 \right\} \,.
\end{align}
The goal of an algorithm solving $\elemx$ is to produce an output $i$ such that $(Z,i) \in \elemx$: with certainty in the deterministic setting, and with probability $\ge 2/3$ (say) in the randomized setting. In other words, the algorithm must produce a \emph{witness} of the nonemptiness of $Z$. To do so, the algorithm may access $Z$ (equivalently, $\mathbf{z}$) using {\em linear queries}, as we shall now explain.
In a Boolean decision tree model, an algorithm may only access the input vector by querying its individual bits. In such a setting, there is not much to say about $\elemx$: even randomized algorithms are easily seen to require $\Omega(n)$ queries. But things get interesting if we allow more powerful queries: specifically, linear ones. Let us define a \emph{linear query protocol over domain $D$} (a $D$-LQP, for short) to be a query protocol wherein each query is an evaluation of a linear form $\sum_{i=1}^n a_i z_i$, where each $a_i \in D$. The domain $D$ should be thought of a ``reasonable'' subset of a ring containing $\b$---e.g., a finite field, or integers with bounded absolute value---and the linear functions will be evaluated in the underlying ring. The cost of an LQP is the number of linear form evaluations used.\footnote{Note that this is somewhat lower than the number of {\em bits} needed to encode the output of the queries.}
In this work we particularly care about the amount of {\em adaptivity} in an LQP, which quantifies the extent to which each query depends on the outcomes of previous queries.
To set the stage, we recall the problem of $\ell_0$\textsc{-sampling}~\cite{FrahlingIS08,CormodeF14}, from the world of sketching and streaming algorithms. The goal of $\ell_0$-sampling is to sample a pair $(i, x_i)$ from a nonzero input vector $\mathbf{x} \in \mathbb{R}^n$ (say), so that $x_i \ne 0$ and $i$ is distributed nearly uniformly on the support of $\mathbf{x}$. This is a fundamental primitive, used as a low-level subroutine in a wide range of applications in streaming and other ``big data'' algorithms. There are several solutions to this problem~\cite{CormodeF14}, most of which provide a linear {\em sketching} scheme, wherein one computes $\mathbf{y} = S\mathbf{x}$ for a certain random $d \times n$ matrix $S$ and then runs a recovery algorithm on the low-dimensional vector $\mathbf{y}$ to produce the desired sample. Notice that if the input is a vector $\mathbf{z} \in \b^n$, such a scheme provides a randomized LQP for $\elemx_n$ (allowing a small probability of error). In particular, using the optimal $\ell_0$-sampling sketch of Jowhari, Sağlam, and Tardos~\cite{JowhariST11}, we obtain a $\mathbb{Z}$-LQP that makes $O(\log n)$ queries, using coefficients in $\{0,1,\ldots,n\}$, and has the pleasing property of being {\em non-adaptive}. We can also obtain a $\mathbb{Z}_q$-LQP that makes $O(\log^2 n/\log q)$ queries;\footnote{Throughout this paper, ``$\log$'' denotes the base-$2$ logarithm.} details in \Cref{sec:upper-bounds}.
Turning to the deterministic setting---our main focus in this paper---it is easy to show that a non-adaptive $\mathbb{Z}$-LQP for $\elemx_n$ must make $\Omega(n/\log n)$ queries, for basic information-theoretic reasons. For completeness, we give the proof in \Cref{prop:int-one-round}. However, this heavy determinism penalty disappears upon moving to general deterministic LQPs, where we can use adaptivity. Indeed, a simple binary search strategy leads to a $\mathbb{Z}$-LQP that makes $O(\log n)$ queries, using coefficients in $\b$. We can refine this observation to trade off the query complexity for amount of adaptivity. This brings us to our central concept.
Define a {\em $k$-round LQP} to be one where the queries are made in batches that we call {\em rounds}: the collection of linear forms defining the queries in round $i$ depend only on the results of queries made in rounds $1,\ldots,i-1$ (a formal definition appears in \Cref{sec:prelim}). Then, a natural generalization of the binary search strategy provides a $k$-round $\mathbb{Z}$-LQP for $\elemx$, using coefficients in $\b$, making at most $k (\lceil n^{1/k} \rceil - 1)$ queries in total. When we are additionally promised that $\mathbf{1}^\mathsf{T} \mathbf{z} \ne 0$, where addition is performed in the ring $\mathbb{Z}_q$, then this algorithm also works as a $\mathbb{Z}_q$-LQP; details in \Cref{sec:upper-bounds}. Notice that $k$-round LQPs naturally interpolate between linear sketches at one extreme (when $k = 1$) and linear decision trees at the other (when $k = n$).
The most important message of this paper is that the above rounds-versus-queries tradeoff is asymptotically tight for deterministic linear query protocols for $\elemx$, in several natural settings. We state our results informally for now, with formal statements given after the necessary definitions and preliminaries.
\subsection{Our Results and Techniques} \label{sec:results}
We shall study $D$-LQPs for the domains $D = \mathbb{Z}_q$, the ring of integers modulo $q$ (with $q \ll n$) as well as $D = \mathbb{Z}$, but with coefficients of small magnitude (at most $\poly(n)$, say). Such restrictions on the coefficients are necessary, because allowing arbitrary integer coefficients makes it possible to recover the entire input $\mathbf{z}$ with the single query $\sum_{i=1}^n 2^{i-1} z_i$.
When $D = \mathbb{Z}_q$, for small $q$, solving $\elemx$ without the promise that $\mathbf{1}^\mathsf{T} \mathbf{z} \ne 0$ is hard, regardless of the number of rounds. Intuitively, there is no cheap way to deterministically verify that a subset $I \subseteq [n]$ indeed contains an index $i \in I$ where $z_i \ne 0$. Defining the ``cost'' of an LQP to be the number of queries it makes in the worst case (formally defined in \Cref{sec:prelim}), we obtain the following not-too-hard results.
\begin{proposition} \label{thm:z2-hard}
Every deterministic $\mathbb{Z}_2$-LQP for $\elemx_n$ has cost $\ge n-1$, which is optimal.
\end{proposition}
\begin{proposition} \label{thm:zq-hard}
For $q\ge 3$, every deterministic $\mathbb{Z}_q$-LQP for $\elemx_n$ has cost $\ge {n}/(2 q \ln q)$.
\end{proposition}
As noted earlier, adding the promise that $\mathbf{1}^\mathsf{T} \mathbf{z} \ne 0$ permits a more efficient $k$-round deterministic algorithm. For each integer $q \ge 2$, define $\elemxq_n$ to be the version of $\elemx_n$ where we are given the stronger promise that $\mathbf{1}^\mathsf{T} \mathbf{z} \ne 0$ under arithmetic in $\mathbb{Z}_q$. Equivalently, using set notation, we are promised that $|Z| \not\equiv 0 \pmod q$. We prove the following results, using similar round-elimination arguments.
\begin{theorem} \label{thm:z2-k-round}
Every deterministic $k$-round $\mathbb{Z}_2$-LQP for $\elemxodd_n$ has cost $\ge k (n^{1/k} - 1)$.
\end{theorem}
\begin{theorem} \label{thm:zq-k-round}
Every deterministic $k$-round $\mathbb{Z}_q$-LQP for $\elemxq_n$ has cost $\Omega\left( \frac{1}{q^{1 + 1/k} \ln^2 q} k (n^{1/k} - 1) \right)$.
\end{theorem}
Although \Cref{thm:zq-k-round} subsumes \Cref{thm:z2-k-round} in the asymptotic sense, we find it useful to present the former result in full, first, to lay the groundwork for our subsequent lower bound proofs. As we shall see, the fact that $\mathbb{Z}_2$ is a field leads to an especially clean execution of the round elimination strategy. Note also that a weaker form of \Cref{thm:z2-k-round} follows from existing work on formula size-depth tradeoffs (see \Cref{sec:kw-lb}); however, the resulting proof, once fully unrolled, is considerably more complex than our direct argument.
At a high level, a lower bound proof based on round elimination works as follows. We consider a hypothetical $k$-round protocol for $n_k$-dimensional instances of some problem $P$ that does not incur much cost in its first round. Based on this low cost, we extract a $(k-1)$-round protocol for $n_{k-1}$-dimensional instances of $P$ by ``lifting'' these smaller instances to special $n_k$-dimensional instances on which the $k$-round protocol essentially ``wastes'' its first round. If we can carry out this argument while ensuring that the shrinkage from $n_k$ to $n_{k-1}$ is not too drastic, then a too-cheap $k$-round protocol will eventually give us a $0$-round protocol for a nontrivial instance dimension, leading to a contradiction.
In the proofs of the above two theorems, this strategy is executed by identifying a large collection of pairwise disjoint sets that are treated identically in the protocol's first round. Viewing these sets as blocks of indices within $[n]$, we consider block-structured instances of $\elemx_n$ and proceed to lift general instances of $\elemx_{n'}$ into these block-structured ones. In \Cref{thm:z2-k-round}, these blocks arise from elementary linear algebraic considerations. In \Cref{thm:zq-k-round}, the fact that inputs are in $\b^n$ instead of $\mathbb{Z}_q^n$ necessitates a brief excursion into additive combinatorics.
Finally, we consider LQPs over $\mathbb{Z}$, the ring of all integers, but with bounds on the magnitude of coefficients (which, as we noted earlier, is necessary in order to have nontrivial results). To be precise, we consider domains of the form $\mathbb{Z}_{[b,c]} := \{a \in \mathbb{Z}:\, b \le a \le c\}$. While we are unable to prove a full tradeoff lower bound in this case, we do obtain a near-optimal result for $k=2$ rounds.
\begin{proposition} \label{prop:int-one-round}
Every deterministic $1$-round $\mathbb{Z}_{[-B,B]}$-LQP for $\elemx_n$
costs $\Omega({n}/\log(nB))$.
\end{proposition}
\begin{theorem} \label{thm:int-lower-bounds}
Every deterministic $2$-round $\mathbb{Z}_{[-B,B]}$-LQP for $\elemx_n$
costs $\Omega(\sqrt{n} / \log^{3/2}(nB) )$.
\end{theorem}
The former result is straightforward, based on the simple observation that such an LQP can extract the {\em entire} input $\mathbf{z}$ followed by basic information theoretic considerations. Incidentally, the problem of extracting all of $\mathbf{z}$ using $\mathbb{Z}_{[0,1]}$-LQPs has a long history as the {\em coin weighing} problem, for which a 1-round $O(n / \log n)$ algorithm exists; see \Cref{sec:related}
The significant result here is the latter. It again uses a round elimination strategy and, as before, the bird's-eye view is that we identify disjoint blocks of indices to engineer a suitable lifting. This time, the blocks arise out of extremal combinatorics considerations, specifically the sunflower lemma, in its recently strengthened form~\cite{Rao20}. Furthermore, upon carrying out this round elimination, we are left with a $1$-round LQP that solves $\elemx$ only under a cardinality constraint on the input set. To finish the proof, we must demonstrate hardness even for this special case. This is not as straightforward as \Cref{prop:int-one-round}: our argument to handle this hinges on the Frankl--Wilson theorem~\cite{FranklW81} on set systems with forbidden intersection sizes.
Attempts to extend the above proof outline to handle more than two rounds runs into technical issues of integer divisibility. We suspect that this is an artifact of our proof machinery and not inherent to the problem. We conjecture that every deterministic $k$-round $\mathbb{Z}_{[-B,B]}$-LQP requires cost $\widetilde{\Omega}(n^{1/k})$, suppressing polylogarithmic factors. Indeed, we believe that much more is true, and that a communication complexity analogue of such a tradeoff also holds. We shall take this up after a discussion of related work.
\subsection{Related Work and Connections} \label{sec:related}
Our work touches upon several themes with long histories of study in computer science: determinism versus randomization, adaptivity versus non-adaptivity, sublinear algorithms, and input access through structured queries. With these connections in mind, we recall a small number of works that are either close in spirit to ours or shed light on some aspect of this work.
The most basic query model is the Boolean decision tree. In this setting, deterministic and randomized complexities are polynomially related for total Boolean functions~\cite{BuhrmanW02,AmbainisBBLSS17}, whereas arbitrarily large gaps are possible for search problems~\cite{LovaszNNW95}. Parity decision trees---equivalent to our $\mathbb{Z}_2$-LQPs---have been studied in several works (e.g., \cite{ZhangS10,HatamiHL18} and the references therein), usually for Boolean functions and focusing on connections with communication complexity of XOR-composed functions. Beyond the Boolean---or indeed the discrete---setting lie {\em linear decision trees}, where the input is a {\em real} vector and one can query the {\em sign} of a linear form~\cite{DobkinL78,KaneLM19}. All such ``decision tree'' models are fully adaptive and the vast majority of works using them do not focus on amount of adaptivity as a resource.
At the other extreme is the (nonadaptive) linear sketching model, where a high-dimensional input is accessed through one batch of linear queries (equivalently, through a low-dimensional sketch of it produced by a sketching matrix). This paradigm is ubiquitous in data streaming algorithms and compressed sensing~\cite{Muthukrishnan05,Donoho06,Woodruff14,CormodeYi-book} and has connections to dimension reduction and metric embeddings. Some recent work carries the message that linear sketching might be a {\em complete} paradigm for a large class of data streaming algorithms~\cite{LiNW14} and certain communication protocols~\cite{KannanMSY18,HosseiniLY19}. Most work on linear sketching considers {\em randomized} sketches, since determinism often precludes sublinear cost.
Turning to determinism, the well-studied {\em coin weighing} problem, put in our terms, asks for a $\mathbb{Z}_{[0,1]}$-LQP that retrieves the entire input $\mathbf{z} \in \b^n$. It has long been known that $(2\pm o(1))n/\log n$ nonadaptive queries are necessary and sufficient. Special cases and variants of this problem have been studied over the years; see \cite{ErdosR63} for some early history and \cite{Bshouty09,MarcoK13} for recent history. While some of these works consider adaptive LQPs, there is no strong rounds-vs-queries tradeoff for this problem, which is harder than $\elemx$.
The body of work on round complexity under linear queries is much smaller. There is one recent work very close to ours: Assadi, Chakrabarty, and Khanna~\cite{AssadiCK20} studied a problem very similar to $\elemx$ that they called \textsc{single-element-recovery}, where the input is a vector $\mathbf{x} \in \mathbb{R}_{\ge0}^n$, and by applying $\mathbb{R}$-linear queries one wishes to recovery an arbitrary element from the support of $\mathbf{x}$. While their query model is much stronger than our $\mathbb{Z}$-linear or $\mathbb{Z}_q$-linear queries, it is balanced by the $\mathbb{R}_{\ge 0}$-valued inputs that prevent tricks to recover the entire input in one query. Their main theorem implies that the deterministic $k$-round search algorithm making roughly $k (n^{1/k} - 1)$ queries in total---very similar to \Cref{alg:det-protocol}---has cost exactly matching the lower bound.
Linear queries and adaptivity are also featured together in some work on {\em sparse recovery} problems. One such problem is to find an approximately closest $s$-sparse vector $\mathbf{x}^\star$ to an input $\mathbf{x}$,
using $\mathbb{R}$-linear queries to the input and $r$ rounds of adaptivity. For this, \cite{PriceW13} have proven near optimal lower bounds of $\Omega(r (\log n)^{1/r})$ when $s=1$ and \cite{KamathP19} have extended them to small $s$, proving $\Omega(\frac{1}{r} s (\log n)^{1/r})$ queries are needed when $\log s < (\log n)^{1/r}$.
\medskip
A number of works consider rounds of adaptivity in query models beyond linear queries. Recent examples include works on maximizing submodular functions through adaptive oracle queries~\cite{BalkanskiS18}; on adaptivity hierarchy theorems in property testing~\cite{CanonneG18}; on identifying biased coins through pairwise comparisons or in multi-armed bandit settings~\cite{AgarwalAAK17}; and on finding approximately maximum bipartite matchings through demand queries and OR-queries~\cite{Nisan21}. Other works have studied adaptivity in the massive parallel communication/computation (MPC) model~\cite{BeameKS13} and in various graph query models~\cite{AbasiB19,BeameHRRS20}.
A rich body of work on cost/adaptivity tradeoffs is found in {\em communication complexity}, where adaptivity manifests as rounds of interaction. An early work~\cite{NisanW93} gave exponential separations between $k$ and $k+1$ rounds for all $k$ and introduced a round elimination paradigm that remains ubiquitous to this day. This work also explains how an earlier result~\cite{KarchmerW90} connecting circuit and communication complexities can be used to relate bounded-round communication complexity for a specific problem to the size of bounded-depth, unbounded fan-in formulas. More work has been spurred by applications of bounded-round communication lower bounds in data structures, where they provide lower bounds in the cell-probe model~\cite{MiltersenNSW98,Sen03,ChakrabartiR04,PatrascuT07,LiuPY16}; and in streaming algorithms, where they translate naturally to tradeoffs between the number of passes made over the input stream and the working memory required~\cite{GuhaM09,EmekR14,GuruswamiOnak16,ChakrabartiCM16,ChakrabartiW16}. In much of this body of work, round elimination is performed using {\em information theoretic} arguments that naturally provide lower bounds against randomized algorithms.
In contrast, it is rare to see deterministic tradeoffs where corresponding randomized ones do not hold because randomization makes the problem ``too easy.'' This is exactly the situation with $\elemx$, as shown by this work in the context of the randomized upper bounds (\Cref{sec:upper-bounds}) via $\ell_0$-sampling~\cite{JowhariST11}. In light of the preceding discussion, our instantiations of round elimination must use techniques beyond Shannon-style information theory. They indeed do. Our techniques therefore have the potential for further use in separating determinism from randomization in this fine-grained (round aware) sense.
Our query complexity results on $\elemx$ suggest a tantalizing communication complexity analogue. Let $\textsc{ur}^\subset\xspace_n$ denote\footnote{The notation, due to Nelson and Yu~\cite{NelsonY19}, is to be read as ``universal relation with a subset constraint.''} the communication complexity problem where Alice and Bob receive sets $X, Y \subseteq [n]$ respectively with the promise that $Y \subset X$, and their goal is to produce an element in $X \smallsetminus Y$.
Clearly, a $k$-round query protocol for $\elemx$ making $q$ queries, with each answer lying in a set of size $M$, provides a $k$-round communication protocol for $\textsc{ur}^\subset\xspace$ using at most $q\log M$ bits. Therefore, our results here would be subsumed, in an asymptotic sense, if one could resolve the following conjecture positively.
\begin{conj}
Every deterministic $k$-round communication protocol for $\textsc{ur}^\subset\xspace$ costs $\widetilde{\Omega}(n^{1/k})$ bits, suppressing polylogarithmic factors.
\end{conj}
We find the above conjecture compelling because it would demonstrate a new phenomenon in communication complexity, where a problem is easy for one-round randomized {\em and} for interactive deterministic protocols, but exhibits a nontrivial tradeoff for bounded-round deterministic ones.
In passing, we note that the $\textsc{ur}^\subset\xspace$ problem was introduced in \cite{KapralovNPWWY17} where its randomized communication complexity was studied. The randomized lower bound was subsequently used by Nelson and Yu~\cite{NelsonY19} to prove the optimality of Ahn, Guha, and McGregor's graph sketching algorithm for graph connectivity~\cite{AhnGM12}. An outstanding open question about the latter problem (viewed as a communication problem where $n$ players, each holding a vertex neighborhood, talk to a coordinator who determines whether the graph is connected) is whether it admits a deterministic algorithm with sublinear communication. A better understanding of $\textsc{ur}^\subset\xspace$ in the deterministic setting could be key to addressing this question.
There are also two problems similar to $\textsc{ur}^\subset\xspace$ for which lower bounds have already been proven. The universal relation problem $\textsc{ur}\xspace$ gives Alice and Bob unequal sets $X,Y \subseteq [n]$ and asks them to produce an element $i \in (X \smallsetminus Y) \cup (Y \smallsetminus X)$. This has deterministic communication complexity $\ge n +1$~\cite{TardosZ97}. The Karchmer-Wigderson game for $\textsc{parity}_n$ is the problem $\textsc{ur}\xspace$ with the additional constraints that $|X|$ be even and $|Y|$ be odd; existing circuit complexity results~\cite{Hastad86,Rossman15} imply, as briefly explained in \Cref{sec:kw-lb}, that $k$-round deterministic communication protocols for this require $\Omega(k(n^{1/k}-1))$ bits of communication.
\section{Preliminaries} \label{sec:prelim}
Throughout the paper, we shall freely switch between the equivalent viewpoints of sets in $2^{[n]}$ and vectors in $\b^n$, using the notational convention that when an uppercase letter (e.g., $S,Z$) denotes a set, the corresponding lowercase boldface letter (e.g., $\mathbf{s},\mathbf{z}$) denotes the characteristic vector of that set and vice versa.
\subsection{Various Definitions} \label{sec:defs}
The search problem $\elemx_n$ was already formally defined in \cref{eq:elemx-def-set}. We shall also work with special cases of this problem, where the cardinality of the input set is further restricted in some way. These are formalized as follows: we define
\begin{align}
\elemxq_n &= \left\{ (Z,i) : Z \subseteq [n],\, i \in [n],\, \text{and } |Z| \not\equiv 0 \tpmod q \Rightarrow i \in Z \right\} \,; \label{eq:elemxq-def} \\
\elemxqh_n &= \left\{ (Z,i) : Z \subseteq [n],\, i \in [n],\, \text{and } |Z| \equiv h \tpmod q \Rightarrow i \in Z \right\} \,; \label{eq:elemxqh-def} \\
\elemxquarter_n &= \left\{ (Z,i) : Z \subseteq [n],\, i \in [n],\, \text{and } |Z| = n/4 \Rightarrow i \in Z \right\} \label{eq:elemxquarter-def} \,.
\end{align}
\begin{definition}[Protocol] \label{def:protocol}
Let $f \subseteq \b^n \times \mathcal{O}$ be a search problem with input space $\b^n$ and output space $\mathcal{O}$. A deterministic \emph{$k$-round $D$-linear query protocol} ($D$-LQP), $\Pi$, on this input space is a rooted tree of depth $k$ where each internal node $v$ is labeled with a matrix $A_v \in D^{d_v \times n}$; each leaf node with an output $o_\lambda \in \mathcal{O}$; and the edges from a node $v$ to its children are labeled with the elements of $\mathcal{M}_v := \{A_v \mathbf{z}:\, \mathbf{z} \in \b^n\}$ bijectively. The quantity $d_v$ of node $v$ is the \emph{cost} of the node, sometimes also denoted $\cost(v)$. Given an input $\mathbf{z} \in \b^n$, the \emph{measurement at} internal node $v$ is $A_v \mathbf{z}$. The transcript of $\Pi$ on $\mathbf{z}$ ---denoted $\Pi(\mathbf{z})$---is the unique root-to-leaf path obtained by walking along the edges determined by these measurements; the \emph{$j$th measurement} is the label of the $j$th edge on this path; and the \emph{output} is the label $o_\ell$ of the leaf $\ell := \ell(\Pi(\mathbf{z}))$ reached by this path. We say that $\Pi$ solves $f$ if $(\mathbf{z},o_\ell) \in f$ for every input $\mathbf{z}$.
Since this paper is largely focused on deterministic complexity, henceforth we shall assume that all LQPs are deterministic unless stated otherwise.
\end{definition}
\begin{definition}[Cost]
The \emph{query cost} of a protocol $\Pi$ is:
\begin{align*}
\cost(\Pi) &:= \max_{\mathbf{z} \in \b^n} \cost(\Pi;\mathbf{z}) \,,
\qquad \text{where} \quad
\cost(\Pi;\mathbf{z}) := \sum_{v \text{ internal node on } \Pi(\mathbf{z})} d_v \,,
\end{align*}
which is, informally, the number of linear queries performed when $\Pi$ executes on $\mathbf{z}$. While we do not focus on {\em bit} complexity in this paper, it is worth noting that to make an information-theoretically fair comparison between different domains, one should consider the number of bits returned in response to all the queries. This number may be larger than $\cost(\Pi)$, though only by an $O(\log n)$ factor for $D = \mathbb{Z}_{[-B,B]}$ with $B = \poly(n)$, and not at all for $D = \mathbb{Z}_2$.
\end{definition}
\begin{definition}[Complexity] \label{def:lq}
The {\em $D$-linear query complexity} and $k$-round $D$-linear query complexity of a search problem $f$ are defined, respectively, to be
\begin{align*}
\LQ_D(f) &= \min\{\cost(\Pi): \Pi \text{ is a $D$-LQP that solves } f\} \,; \\
\LQ_D^k(f) &= \min\{\cost(\Pi): \Pi \text{ is a $k$-round $D$-LQP that solves } f\} \,.
\end{align*}
\end{definition}
\subsection{Useful Results from Combinatorics} \label{sec:comb}
In the course of this paper, we will use several important theorems from combinatorics. For results on $\mathbb{Z}_q$-LQPs (proved in \Cref{sec:zq-linear-measurements}), we use the following result of van Emde Boas and Kruyswijk \cite{EmdeBoasK69} on zero sumsets, slightly reworded to use modern notation.
\begin{theorem}[\cite{EmdeBoasK69}] \label{thm:emdeboas}
Let $G$ be a finite abelian group with exponent\footnote{The exponent of a group is the least common multiple of the orders of its elements.} $\exp(G)$ and order $|G|$. Let $s(G)$ be the minimal positive integer $t$ for which any sequence of $t$ elements from $G$ has a nonempty subsequence which sums to zero. Then $s(G) \le \exp(G) (1 + \ln\frac{|G|}{\exp(G)})$. \qed
\end{theorem}
A stronger result that $s(G) = 1 + r (q-1)$ applies when $G = \mathbb{Z}_{q}^r$ and $q$ is a prime power~\cite{Olson69}; it is conjectured that the prime-power constraint is unnecessary~\cite[conjecture~3.5]{GaoG06}
When working over $\mathbb{Z}$ (in \Cref{sec:int-linear-measurements}), we use the well-known notion of a \emph{sunflower} and the following recent result of Rao~\cite{Rao20}, which refines the noted result of Alweiss, Lovett, Wu, and Zhang~\cite{AlweissLWZ20} that improved the classic sunflower lemma of Erd\H{o}s and Rado~\cite{ErdosR60}. The note~\cite{BellCW20} further improves Rao's bound by replacing the $\log(pt)$ factor with $\log t$, but this will not affect our proof. Tao~\cite{Tao20} gives an alternative presentation of Rao's result which may be simpler to follow.
In a different part of our argument, we will need a well known theorem of Frankl and Wilson~\cite{FranklW81}.
\begin{theorem}[Rao] \label{thm:sunflower}
There is a universal constant $c_1 > 1$ such that every family of more than $(c_1 p \log(pt))^t$ sets, each of cardinality $t$, must contain a \emph{$p$-sunflower}, defined as a family of $p$ distinct sets whose pairwise intersections are identical. \qed
\end{theorem}
\begin{theorem}[Frankl--Wilson] \label{thm:frankl-wilson}
Let $m(n,k,\overline{l})$ be the largest size of a collection $\mathcal{F}$ of subsets of $\binom{[n]}{k}$ for which no two elements $F,F' \in \mathcal{F}$ have intersection size $l$. Then, if $k - l$ is a prime power:
\begin{alignat*}{2}
m(n,k,\overline{l}) & \le \binom{n}{k - l -1} \,,
&\qquad& \text{ if } k \ge 2 l + 1 \,; \\
m(n,k,\overline{l}) & \le \binom{n}{l}\binom{2k - l - 1}{k} \Big/ \binom{2k - l -1}{l}\,,
&& \text{ if } k \le 2 l + 1 \,. \rlap{~~\qquad\qquad\qquad\qquad\qed}
\end{alignat*}
\end{theorem}
\subsection{Our Round Elimination Framework} \label{sec:framework}
We now describe a framework for our round elimination arguments. For this
section, we shall work over a general ring (with unity), $R$, and ``LQP'' will mean a $D$-LQP where $D \subseteq R$. Fix this ring $R$.
\begin{definition}[Homomorphism and shadowing]
A {\em protocol homomorphism} is a map $\varphi$ from a protocol $\Upsilon$ to a protocol $\Pi$ such that (i)~for any two nodes $u,v$ in $\varphi$, the node $\varphi(u)$ is a child of $\varphi(v)$ iff $u$ is a child of $v$, and (ii)~$\varphi$ maps leaves of $\Upsilon$ to leaves of $\Pi$. We say that $\varphi$ is {\em cost-preserving} for each internal node $v$ of $\Upsilon$, $\cost(v) = \cost(\varphi(v))$. We say that $\Upsilon$ {\em shadows $\Pi$ through $\varphi$} if $\varphi$ is injective, cost-preserving, and maps the root of $\Upsilon$ to a child of the root of $\Pi$. Notice that when this is the case, $\Upsilon$ is one round shorter than $\Pi$.
\end{definition}
Suppose we have an LQP $\Pi$ that operates on inputs in $\b^n$ and produces outputs in $[n]$. Further, suppose $S_1, \ldots, S_m \subseteq [n]$ is a collection of pairwise disjoint nonempty sets. We then define a certain LQP $\Pi^{(S_1,\ldots,S_m)}$ operating on inputs in $\b^m$ and producing outputs in $[m]$. To aid intuition, we describe the construction procedurally in \Cref{alg:lift-protocol}.
\begin{algorithm*}[!ht]
\caption{~Outline of protocol $\Pi^{(S_1,\ldots,S_m)}$}
\label{alg:lift-protocol}
\begin{algorithmic}[1]
\State Lift our input $W \subseteq [m]$ to $Z := \bigcup_{i \in W} S_i \subseteq [n]$ (this step is only conceptual). \label{line:pi-lift}
\State Mimic $\Pi$ by simulating the queries it would have made to its input $Z$. Emulate each such query by making the corresponding query to our own input $W$. This is indeed possible using linear queries to $W$. \label{line:pi-emu}
\State Suppose $\Pi$ wants to output $h$. If $h \in S_i$, then output that index $i$ (which must be unique); otherwise, output an arbitrary index. \label{line:pi-output}
\end{algorithmic}
\end{algorithm*}
To define $\Pi' := \Pi^{(S_1,\ldots,S_m)}$ formally, we first define the \emph{lifting matrix}
\begin{align} \label{eq:lift-mtx}
L = [\mathbf{s}_1 ~ \mathbf{s}_2 ~ \cdots ~ \mathbf{s}_m] \in R^{n \times m} \,,
\end{align}
whose entries lie in $\b$ and which maps the input space of $\Pi'$ to the input space of $\Pi$ according to \cref{line:pi-lift}, thanks to the pairwise disjointness of the sets $S_i$. At a given node $v$ of $\Pi$, labeled with $A_v \in \mathbb{Z}_q^{d_v \times n}$, the simulation in \cref{line:pi-emu} would retrieve the measurement $A_v \mathbf{z} = A_v L \mathbf{w}$. The protocol $\Pi'$ can get the same result by making the query $A_v L \in \mathbb{Z}_q^{d_v \times m}$.
Thus, the protocol tree for $\Pi'$ is formed as follows. Prepare a copy of $\Pi$ and let $\varphi \colon \Pi' \to \Pi$ be the natural bijection between their nodes. Label each internal node $v$ of $\Pi'$ with $A_v := A_{\varphi(v)} L$. Copy over all edge labels from $\Pi$ to $\Pi'$. For each leaf $\ell$ of $\Pi'$, if $o_{\varphi(\ell)} \in S_i$, then assign label $o_\ell := i$. If no such $i$ exists, assign $o_\ell := 1$ (say). This labeling is well defined because of the pairwise disjointness of the sets $S_i$.
\medskip
In the sequel, to perform round elimination, we shall use the construction of $\Pi'$ in a special way that we record in the lemma below. We also record a definition that will be relevant when invoking the lemma.
\begin{lemma} \label{lem:round-el-gen}
Suppose that $\Pi$ correctly solves $\elemx_n$ on inputs in $\mathcal{Z} \subseteq \b^n$.
Let $S_1,\ldots,S_m \subseteq [n]$ be pairwise disjoint and let $L$ be defined by \cref{eq:lift-mtx}.
Let $\rho$ be the root node of $\Pi$ and, for $\mathbf{r} \in R^{d_\rho}$, let $\mathcal{W}_\mathbf{r} := \{\mathbf{w} \in \b^m:\, L\mathbf{w} \in \mathcal{Z}$ and $A_\rho L\mathbf{w} = \mathbf{r}\}$.
Then, there is a protocol $\Upsilon$ that shadows $\Pi$ and correctly solves $\elemx_m$ on each input in $\mathcal{W}_\mathbf{r}$.
\end{lemma}
\begin{proof}
Using the above setup and terminology, construct $\Pi' := \Pi^{(S_1,\ldots,S_m)}$ as in \Cref{alg:lift-protocol}. The given conditions imply that on all inputs in $\mathcal{W}_\mathbf{r}$, the first measurement of $\Pi'$ is always $\mathbf{r}$ and thus leads an execution of $\Pi'$ to a particular child, $u$, of its root node. Thus, we can shrink $\Pi'$ to the subprotocol $\Upsilon$ rooted at $u$. Notice that the bijection $\varphi$ is a cost-preserving protocol homomorphism and so $\Upsilon$ shadows $\Pi$ through $\varphi|_{\Upsilon}$.
By construction, $\Upsilon$ on input $\mathbf{w} \in \mathcal{W}_\mathbf{r}$ simulates $\Pi$ on $\mathbf{z} := L\mathbf{w} = \sum_{i \in W} \mathbf{s}_i$, an input on which $\Pi$ correctly solves $\elemx_n$. Therefore, if $\Pi$ outputs $h$, then $h \in Z = \bigcup_{i \in W} S_i$. By the disjointness guarantee, there exists a unique $i \in W$ for which $h \in S_i$. As $\Upsilon$ reports precisely this $i$, it correctly solves $\elemx_m$ on $\mathbf{w}$.
\end{proof}
\begin{definition}[Uniform family]
Fix a matrix $A \in R^{d \times n}$. An {\em $A$-uniform family of size $m$} is a collection of $m$ pairwise disjoint sets $S_1, \ldots, S_m \subseteq [n]$ such that $A\mathbf{s}_1 = \cdots = A\mathbf{s}_m = \mathbf{r}$, for some vector $\mathbf{r} \in R^d$.
\end{definition}
\section{Linear Queries Modulo 2} \label{sec:z2-linear-measurements}
We begin our study of the {\sc element-extraction} problem by considering $\mathbb{Z}_2$-linear queries. As noted in \Cref{sec:results}, we shall later generalize the results to $\mathbb{Z}_q$, but we feel it is worth seeing our framework in action in the especially clean setting of $\mathbb{Z}_2$. We begin by showing that the additional promise of odd cardinality on the input set $Z$ is crucial, or else there is no interesting rounds-vs-queries tradeoff to be had.
\begin{proposition}[Restatement of \Cref{thm:z2-hard}]
$\LQ_{\mathbb{Z}_2}(\elemx_n) = n-1$.
\end{proposition}
\begin{proof}
The upper bound is achieved by the trivial $1$-round LQP (i.e., a sketch) that queries all but one of the individual bits of the input.
Now assume to the contrary that there is a $\mathbb{Z}_2$-LQP $\Pi$ with $\cost(\Pi) = d \le n-2$ that solves $\elemx_n$. Let $A \in \mathbb{Z}_2^{d \times n}$ be the matrix whose rows represent all queries along the path $\Pi(\mathbf{0})$. Then $\dim\,\ker A \ge n-d \ge 2$, whence there exist distinct nonzero vectors $\mathbf{y},\mathbf{z} \in \mathbb{Z}_2^n$ such that $A\mathbf{y} = A\mathbf{z} = \mathbf{0}$. Setting $\mathbf{x} = \mathbf{y} + \mathbf{z}$, we also have $A\mathbf{x} = \mathbf{0}$. Thus, the three nonzero inputs $\mathbf{x}, \mathbf{y}, \mathbf{z}$ lead to the same leaf, namely $\ell(\Pi(\mathbf{0}))$, and produce the same output $i$, say. By the correctness of $\Pi$, we have $x_i = y_i = z_i = 1$, which contradicts $\mathbf{x} = \mathbf{y} + \mathbf{z}$.
\end{proof}
Accordingly, for the rest of this section, we focus on the problem $\elemxodd_n$, as defined in \cref{eq:elemxq-def}. We shall prove \Cref{thm:z2-k-round} using a round elimination technique. As discussed in \Cref{sec:prelim}, this round elimination will be enabled by identifying a certain $A$-uniform family. The next lemma, establishing a useful fact about matrices over $\mathbb{Z}_2$, will provide us this family.
\begin{lemma} \label{clm:z2-partition}
Every matrix $A \in \mathbb{Z}_2^{d \times n}$, admits an $A$-uniform family $S_1, \ldots, S_m$ of size $m \ge \ceil{n/(d+1)}$ such that each cardinality $|S_i|$ is odd.
\end{lemma}
\begin{proof}\label{proof:z2-matrix-lemma}
Let $\mathbf{b}_1, \ldots, \mathbf{b}_n$ be the (nonzero) column vectors of the matrix
\[
B := \left[\begin{array}{c} A\\ \mathbf{1}^\mathsf{T} \end{array}\right] \in \mathbb{Z}_2^{(d+1) \times n}
\]
formed by appending the all-ones row to $A$. For each $Q \subseteq [n]$, let $B_Q$ be the collection of column vectors $\{\mathbf{b}_i:\, i \in Q\}$ and let $\gen{B_Q}$ be the linear subspace of $\mathbb{Z}_2^{d+1}$ spanned by the vectors in $B_Q$.
Partition $[n]$ into nonempty disjoint sets $T_1, \ldots, T_m$ iteratively, as follows. For each $i$, let $T_i$ be a {\em maximal} subset of $[n] \smallsetminus \bigcup_{j=1}^{i-1} T_j$ such that the vectors in $B_{T_i}$ are linearly independent. Since these vectors live in $\mathbb{Z}_2^{d+1}$, it follows that $|T_i| \le d+1$. We stop when $\bigcup_{j=1}^m T_m = [n]$, implying $m \ge \ceil{n/(d+1)}$.
We claim that, for each $i \in \{2,\ldots,m\}$, we have $\gen{B_{T_{i-1}}} \supseteq \gen{B_{T_i}}$. Indeed, if there exists an element $\mathbf{x} \in \gen{B_{T_i}}\smallsetminus \gen{B_{T_{i-1}}}$, then there is a set $Q \subseteq T_i$ for which $\mathbf{x} = \sum_{h \in Q} \mathbf{b}_j$. Since $\gen{B_{T_{i-1}}}$ is closed under linear combinations and does not contain $\mathbf{x}$, there exists $h \in Q$ with $\mathbf{b}_h \notin \gen{B_{T_{i-1}}}$. By construction, $h \notin \bigcup_{j=1}^{i-2} T_j$, so $h$ was not included in $T_{i-1}$ despite being available. This contradicts the maximality of $T_{i-1}$.
Let $k$ be an index in $T_m$. Then $\mathbf{b}_k \in \gen{B_{T_m}} \subseteq \gen{B_{T_{m-1}}} \subseteq \cdots \subseteq \gen{B_{T_1}}$, so there must exist subsets $S_1, \ldots, S_m$ of $T_1, \ldots, T_m$ for which $B \mathbf{s}_i = \mathbf{b}_k$. The sets $\{S_i\}_{i=1}^{m}$ are pairwise disjoint because the sets $\{T_i\}_{i=1}^{m}$ are. Let $\mathbf{r}$ be the first $d$ coordinates of $\mathbf{b}_k$; then for all $i \in [m]$, $A \mathbf{s}_i = \mathbf{r}$. Therefore, $\{S_i\}_{i=1}^{m}$ is $A$-uniform. Finally, since the last coordinate of $\mathbf{b}_k$ is $1$ and the last row of $B$ is $\mathbf{1}^\mathsf{T}$, for each $i \in [m]$, $\mathbf{1}^\mathsf{T} \mathbf{s}_i = 1$, so $|S_i|$ is odd.
\end{proof}
\begin{lemma}[Round elimination lemma] \label{lem:z2-round-elim}
Let $\Pi$ be a deterministic $k$-round $\mathbb{Z}_2$-LQP for $\elemxodd_n$, where $k \ge 1$. Then there exists a deterministic $(k-1)$-round $\mathbb{Z}_2$-LQP $\Upsilon$ for $\elemxodd_m$, such that
\begin{thmparts}
\item $\Upsilon$ shadows $\Pi$ through a (cost-preserving, injective) protocol homomorphism $\varphi_\Upsilon \colon \Upsilon \to \Pi$; \label{clm:z2-costs}
\item $m \ge \ceil{n/(d + 1)}$, where $d$ is the cost of the root of $\Pi$. \label{eq:z2-shrinkage}
\end{thmparts}
\end{lemma}
\begin{proof}
Let $A \in \mathbb{Z}_2^{d \times n}$ be the label of the root of $\Pi$.
Let $S_1, \ldots, S_m$ be an $A$-uniform family of size $m \ge \ceil{n/(d+1)}$ with each $|S_i|$ odd, as guaranteed by \Cref{clm:z2-partition}. Let the lifting matrix $L$ be as given by \cref{eq:lift-mtx} and let $\mathbf{r} = A\mathbf{s}_1$.
We know that $\Pi$ correctly solves $\elemxodd_n$ on inputs in $\mathcal{Z} := \{Z \subseteq [n]:\, |Z|$ odd$\}$.
Invoking \Cref{lem:round-el-gen}, we obtain a $(k-1)$-round $\mathbb{Z}_2$-LQP $\Upsilon$ that shadows $\Pi$ as required.
It remains to show that $\Upsilon$ solves $\elemxodd_m$. The guarantee of \Cref{lem:round-el-gen} is that $\Upsilon$ correctly solves $\elemx_m$ on the input set $\mathcal{W}_\mathbf{r}$ defined there. Thus, it suffices to show that if an input $W \subseteq [m]$ satisfies the promise of $\elemxodd_m$---i.e., $|W|$ is odd---then $W \in \mathcal{W}_\mathbf{r}$. We reason as follows:
\begin{alignat*}{2}
|W| \text{ odd}
&\implies |L\mathbf{w}| = \left|\sum_{i \in W} \mathbf{s}_i\right| \equiv 1 \tpmod 2 &\qquad& \lhd \text{ each $|S_i|$ is odd} \\
&\implies L\mathbf{w} \in \mathcal{Z} \,; && \lhd \text{ definition of $\mathcal{Z}$} \\
\intertext{and}
|W| \text{ odd}
&\implies A L\mathbf{w} = A \sum_{i \in W} \mathbf{s}_i = |W|\cdot A\mathbf{s}_1 = |W| \cdot \mathbf{r} = \mathbf{r} \,. && \lhd \text{ definition of $A$-uniformity}
\end{alignat*}
This completes the proof, by definition of $\mathcal{W}_\mathbf{r}$.
\end{proof}
The next step of the proof is to repeatedly invoke the above round elimination lemma and carefully control parameters. To perform a sharp analysis, we introduce the following concept.
\begin{definition} \label{def:division-seq}
A {\em division sequence} for $n$ is a finite sequence of positive integers $d_1 \ldots d_{j}$ for which
\begin{align}\label{eq:division-seq-precondition}
\left\lceil \cdots \left\lceil \left\lceil
n \cdot \frac{1}{d_1 + 1} \right\rceil \frac{1}{d_1 + 1} \right\rceil \cdots \frac{1}{d_{j} + 1}
\right\rceil = 1 \,.
\end{align}
\end{definition}
\begin{lemma}\label{lem:division-seq}
Let $d_1, \ldots, d_{j}$ be a division sequence for $n$ minimizing $\sum_{h=1}^{j} d_h$. Then
\begin{align*}
j n^{1/j} - j \le \sum_{h=1}^{j} d_h \le j \lceil n^{1/j} \rceil - j \,.
\end{align*}
\end{lemma}
\begin{proof}
For the upper bound, let $d_1 = \ldots = d_{j} = \lceil n^{1/j} \rceil - 1$. For the lower bound, remove the ceiling operations in \cref{eq:division-seq-precondition} to get
\begin{align*}
\frac{n}{\prod_{h=1}^{j} (d_h + 1)} \le 1 \,,
& \qquad \text{which implies} \quad n^{1/j} \le \smash{\left(\prod_{h=1}^{j} (d_h + 1)\right)^{1/j}} \,.
\end{align*}
By the AM-GM inequality,
\[
\sum_{h=1}^{j} d_h
= j \left(\frac{1}{j}\sum_{h=1}^{j} (d_h + 1) - 1\right)
\ge \smash{j \left( \left(\prod_{h=1}^{j} (d_h + 1)\right)^{1/j} - 1 \right)}
\ge j(n^{1/j} - 1) \,. \qedhere
\]
\end{proof}
This brings us to the main result of this section: a rounds-vs-queries tradeoff.
\begin{theorem}[Restatement of \Cref{thm:z2-k-round}]
$\LQ_{\mathbb{Z}_2}^k(\elemxodd_n) \ge k(n^{1/k} - 1)$.
\end{theorem}
\begin{proof}
Suppose that $\Pi$ is a deterministic $k$-round $\mathbb{Z}_2$-LQP for $\elemxodd_n$. Repeatedly applying \Cref{lem:z2-round-elim}, we obtain a sequence of protocols $\Pi=\Pi_1, \Pi_2, \ldots, \Pi_{j+1}$, which solve $\elemxodd$ on progressively smaller input sizes, until $\Pi_{j+1}$ is a degenerate depth-0 protocol (in which no queries occur).
Let $d_i$ be the cost of the root $\rho_i$ of $\Pi_i$, for $1 \le i \le j$. As \Cref{clm:z2-costs} gives protocol homomorphisms $\varphi_{\Pi_{i+1}} : \Pi_{i+1} \to \Pi_i$, we find the the roots of each $\Pi_i$ correspond to nodes $u_i = (\varphi_{\Pi_2} \circ \cdots \circ \varphi_{\Pi_i})(\rho_i)$ in $\Pi$. In fact, the vertices $u_1,u_1,\ldots,u_{j+1}$ form a path from the root $\rho = u_1$ of $\Pi$ to the leaf $u_{j+1}$. The inputs of $\Pi_{j+1}$ lift to inputs of $\Pi$ which reach $u_{j+1}$. Lower bounding the query cost of $\Pi$ using this branch gives
\begin{align} \label{eq:z2-lincost-sum}
\cost(\Pi) \ge \sum_{i=1}^{j} \cost(u_i) = \sum_{i=1}^{j} d_i \,.
\end{align}
Using \cref{eq:z2-shrinkage} repeatedly, $\Pi_{j+1}$ must solve $\elemxodd_m$, for some integer \begin{align*}
m \ge \left\lceil \cdots \left\lceil \left\lceil n \cdot \frac{1}{d_1 + 1} \right\rceil \frac{1}{d_2 + 1} \right\rceil \cdots \frac{1}{d_j + 1} \right\rceil \,.
\end{align*}
However, as $\Pi_{j+1}$ solves $\elemxodd_m$ without performing any queries, there must be a fixed index which is a valid output for all inputs $Z \in 2^{[m]}$ of odd size. This is only possible when $m = 1$; for any larger $m$, the inputs $Z = \{1\}$ and $Z' = \{2\}$ must produce different outputs.
Therefore, the integers $d_1, \ldots, d_j$ form a division sequence for $n$. Applying \Cref{lem:division-seq} to \cref{eq:z2-lincost-sum},
\begin{align*}
\cost(\Pi) \ge \sum_{i=1}^{j} d_i \ge j n^{1/j} - j \ge k(n^{1/k} - 1) \,,
\end{align*}
where the last inequality follows from the fact that $\frac{d}{dz} \left[z (n^{1/z} - 1)\right] \le 0$ for all $z\ge0$.
\end{proof}
\section{Linear Queries Modulo \textit{\textbf{q}}} \label{sec:zq-linear-measurements}
First, we use \Cref{thm:emdeboas} to show that $\elemx_n$ is hard for $\mathbb{Z}_q$-LQPs.
\begin{proposition}[Restatement of \Cref{thm:zq-hard}]
For every $q \ge 3$, we have $\LQ_{\mathbb{Z}_q}(\elemx_n) \ge n/(2q \ln q)$.
\end{proposition}
\begin{proof}
This is proven with the same strategy as for \Cref{thm:z2-hard}. Assume for sake of contradiction that $\cost(\Pi) \le \frac{n}{2 q \ln q}$. Let $\nu$ be the leaf $\ell(\Pi(\mathbf{0}))$. Let $A \in \mathbb{Z}_q^{d \times n}$ be the matrix containing all queries along the path from the root of $\Pi$ to $\nu$.
By \Cref{thm:emdeboas}, since the group $\mathbb{Z}_q^d$ has order $q^d$, and exponent $q$, any sequence of $D \le q \left(1 + \ln(\frac{q^d}{q}) \right)$ elements in $\mathbb{Z}_q^d$ has a nontrivial subsequence summing to $\mathbf{0}$. As $q \ge 3$, $d q \ln q \ge D$. Thus, since $n \ge 2 d q \ln q$, picking disjoint subsets $I$ and $J$ of sizes $d q \ln q$ each, and applying the theorem implies there exist disjoint nonempty subsets $Z_1$ and $Z_2$ of $[n]$ for which the corresponding columns of $A$ sum to $\mathbf{0}$. In other words, $\Pi$ reaches the same leaf given $\mathbf{z}_1$ and $\mathbf{z}_2$, but the leaf cannot be assigned an output consistent with both.
\end{proof}
A similar strategy proves a lemma analogous to \Cref{clm:z2-partition}:
\begin{lemma} \label{clm:zq-partition}
Every matrix $A \in \mathbb{Z}_q^{d \times n}$, admits an $A$-uniform family $S_1, \ldots, S_m$ where
\begin{thmparts}
\item $\displaystyle m \ge \frac{n}{(d+1) q \ln q} - 1$, and \label{clm:zq-m-size}
\item each cardinality $|S_i| \equiv -1 \pmod q$. \label{clm:zq-partitions-parity}
\end{thmparts}
\end{lemma}
\begin{proof}
To be able to enforce constraints on the values $|S_i|$, we define $B := \left[\mathbf{1} \mid A^\mathsf{T}\right]^\mathsf{T} \in \mathbb{Z}_q^{(d+1) \times n}$, and let $\mathbf{b}_1,\ldots,\mathbf{b}_n$ be its column vectors. We partition the columns of the matrix $B$ into disjoint subsets $D_1,\ldots,D_k$ of $[n]$ by the following iterative procedure. In the procedure, let $P$ be the set of indices of $[n]$ not yet chosen. Each set $D_i$ starts out as $\varnothing$; then beginning with $i=1$, each set $D_i$ is expanded by picking an index $j$ from $P$ for which no subset $H \subseteq (D_i \cup \{j\})$ has the property that $\sum_{h \in H} \mathbf{b}_h = \mathbf{0}$; adding $j$ to $D_i$ and removing $j$ from $P$; until no more such indices can be found. When $D_i$ is done, start filling $D_{i+1}$, etc.
When $q=2$, each $D_i$ corresponds to a basis of a subspace of $\mathbb{Z}_2^{d+1}$, so $|D_i| \le d+1 < (d+1) 2 \ln 2$. For $q \ge 3$, we apply \Cref{thm:emdeboas}, using the fact that the group $\mathbb{Z}_q^{d+1}$ has order $q^{d+1}$ and exponent $q$. The maximum possible size of each set $D_i$ is then $\le q \left(1 + \ln(\frac{q^{d+1}}{q}) \right) - 1$. The upper bound $(d+1) q \ln q$ also holds here. Consequently, the number $k$ of sets formed is $\ge \frac{n}{(d+1) q \ln q}$. Pick some $t \in D_k$; for any $i < k$, since $t$ was not picked when $D_i$ was constructed, it must be the case that there is a subset $S_i \subseteq D_i$ for which $\sum_{h \in S_i} \mathbf{b}_h + \mathbf{b}_t = \mathbf{0}$. This implies $B \mathbf{s}_i = \sum_{h \in S_i} \mathbf{b}_h = -\mathbf{b}_t$. Since the first row of $B$ is $\mathbf{1}$, we have $|S_i| \equiv \sum_{h \in S_i} 1 \equiv -1 \pmod q$, so all the sets $S_i$ have size $-1 \pmod q$. Let $\mathbf{r}$ be the last $d$ entries of $-\mathbf{b}_t$; then for all $i$, $B \mathbf{s}_i = \mathbf{r}$. There are $m = k - 1 \ge \frac{n}{(d+1) q \ln q} - 1$ sets in total.
\end{proof}
Compared to $\elemxodd$, there is a slight weakening of the main round elimination lemma, which is a direct consequence of the weakened \Cref{clm:zq-partition}. Instead of directly lower bounding the cost of $\elemxq_n$, we prove separate lower bounds for each $\elemxqh_n$, for all $h \in \{1,\ldots,q-1\}$, and take their maximum. The search problem $\elemxqh_n$ is $\elemx_n$ with the additional promise that the input set $Z$ has size $\equiv h \pmod q$.
\begin{lemma}[Round elimination lemma] \label{lem:zq-round-elim}
Let $\Pi$ be a $k$-round $\mathbb{Z}_q$-LQP for $\elemxqh_n$, where $k \ge 1$ and $h \in \{1,\ldots,q-1\}$. Then there exists a $(k-1)$-round $\mathbb{Z}_q$-LQP $\Upsilon$ for $\elemx_m^{(q, -h)}$, such that
\begin{thmparts}
\item $\Upsilon$ shadows $\Pi$ through a protocol homomorphism $\varphi_\Upsilon \colon \Upsilon \to \Pi$; \label{clm:zq-costs}
\item $\displaystyle m \ge \frac{n}{(d+1) q \ln q} - 1$, where $d$ is the cost of the root of $\Pi$. \label{eq:zq-m-size-lem}
\end{thmparts}
\end{lemma}
\begin{proof}
Let $A \in \mathbb{Z}_q^{d \times n}$ be the label of the root of $\Pi$. \Cref{clm:zq-partition} guarantees that there exists an $A$-uniform family of size $m$, where $m$ satisfies \cref{eq:zq-m-size-lem}, and $A \mathbf{s}_1 = \ldots = A \mathbf{s}_m = \mathbf{x}$, and $|S_1| \equiv \ldots \equiv |S_m| \equiv -1 \pmod q$. Let $L$ be the lifting matrix from \cref{eq:lift-mtx}, and $\mathbf{r} = -h \mathbf{x}$. Applying \Cref{lem:round-el-gen} to $\Pi$, $L$ and $\mathbf{r}$, we obtain a $(k-1)$-round $\mathbb{Z}_q$-LQP $\Upsilon$ that shadows $\Pi$, and solves $\elemx_m$ on all inputs $W \subseteq [m]$ for which $A L \mathbf{w} = \mathbf{r}$ and $|L \mathbf{w}| \equiv h \pmod q$. If $W$ fulfills the promise of $\elemx^{(q,-h)}_n$, that $|W| \equiv -h \pmod q$, then:
\begin{align*}
|L \mathbf{w}| &= \left|\bigcup_{i\in W} S_i\right| =\sum_{i \in W} |S_i| = |W| \cdot (-1) = h \pmod q \,, \\
A L \mathbf{w} &= \sum_{i\in W} A \mathbf{s}_i = |W| \mathbf{x} = -h \mathbf{x} = \mathbf{r} \,,
\end{align*}
which proves that $\Upsilon$ is correct on $W$.
\end{proof}
This brings us to the main result of this section, which essentially generalizes the modulo-$2$ result from the previous section.
\begin{theorem}[Restatement of \Cref{thm:zq-k-round}]
For each $q \ge 2$, we have
\[
\LQ_{\mathbb{Z}_q}^k(\elemxq_n) \ge \frac{1}{3.67 q^{1 + 1/k} \ln^2 q} k(n^{1/k} - 1)\,.
\]
\end{theorem}
\begin{proof}
Suppose that $\Pi$ is a deterministic $\mathbb{Z}_q$-LQP for $\elemxqh_n$. Repeatedly applying \Cref{lem:zq-round-elim}, we construct a sequence of protocols $\Pi = \Pi_1, \Pi_2, \ldots, \Pi_{j+1}$, which respectively solve $\elemxqh$, $\elemx_n^{(q, -h)}$, $\elemxqh, \ldots\,$ on progressively smaller input sizes, until $\Pi_{j+1}$ is a degenerate depth-0 protocol (in which no queries occur), for $\elemx_n^{(q, (-1)^j h)}$. As in \Cref{sec:z2-linear-measurements}, the roots $\rho_i$ of the protocols $\Pi_i$, $1 \le i \le j$, which have cost $d_i$, correspond to a branch of $\Pi$ formed by corresponding nodes $u_i$ and ending at a leaf corresponding to the root of $\Pi_{j+1}$. Then
\begin{align} \label{eq:zq-lincost-sum}
\cost(\Pi) \ge \sum_{i=1}^{j} \cost(u_i) = \sum_{i=1}^{j} d_i \,.
\end{align}
Let $\delta_i := (d_i + 1) q \ln q$. By \Cref{lem:zq-round-elim}, $\Pi_i$ solves $\elemx^{(q,(-1)^{i-1} h)}_{m_i}$, where $m_1 = n$, and:
\begin{align}
m_{i+1} & \ge \frac{m_i }{(d_i+1) q\ln q} - 1 = \frac{m_i - \delta_i}{\delta_i} \,. \label{eq:rel-step}
\end{align}
As $\Pi_{j+1}$ solves $\elemx^{(q,(-1)^j h)}_{m_i}$ without any queries, the problem must be trivial, necessitating $m_{j+1} \le q$. Combining \cref{eq:rel-step} for $i$ between $1$ and $j$ and rearranging:
\begin{align*}
q \ge \frac{n - \sum_{i=1}^{j}{\prod_{\ell=1}^{i}{\delta_\ell}}}{ \prod_{\ell=1}^{j}{\delta_\ell} } \quad\implies\quad n &\le q \prod_{\ell=1}^{j}{\delta_\ell} + \sum_{i=1}^{j}{\prod_{\ell=1}^{i}{\delta_\ell}} \le (q+j) \prod_{\ell=1}^{j}{\delta_\ell} \,.
\end{align*}
Further rearrangement lets us use AM-GM and an inequality derived from $(q+j) q^j \le (q+1)^j q$:
\begin{align}\label{eq:zq-lincost-amgm}
\left(\frac{1}{j} \sum_{i=1}^{j}{\delta_i}\right) \ge \left(\prod_{i=1}^{j}{\delta_i}\right)^{1/j} \ge \left(\frac{n}{q+j}\right)^{1/j} \ge \frac{q}{q+1} \left(\frac{n}{q}\right)^{1/j} \,.
\end{align}
We can now lower bound the query cost of $\Pi$:
\begin{alignat}{2}
\cost(\Pi) &\ge \sum_{i=1}^{j} (d_i+1) - j = \frac{1}{q \ln q} \sum_{i=1}^{j} \delta_i - j &\qquad\qquad & \lhd \text{ by \cref{eq:zq-lincost-sum}} \nonumber\\
&\ge j \left( \frac{1}{(q+1) \ln q} \left(\frac{n}{q}\right)^{1/j} -1 \right) && \lhd \text{ by \cref{eq:zq-lincost-amgm}} \nonumber\\
&\ge k \left( \frac{1}{(q+1) \ln q} \left(\frac{n}{q}\right)^{1/k} -1 \right) \,. && \lhd \text{ since $\frac{d}{ds} [s (r^{1/s} - 1)] \le 0$}
\label{eq:lb-for-zq-z-eq-h}
\end{alignat}
This lower bound becomes negative for sufficiently large $k$. To obtain a bound that remains positive for all $k$, we combine it with an unconditional lower bound. First, we note that \cref{eq:lb-for-zq-z-eq-h} also applies to protocols solving $\elemxq_n$, since $\elemxqh_n$ was an easier case. For $\elemxq_n$, the set of possible transcripts of any protocol $\Psi$ forms a $q$-ary prefix code of maximum length $d$. If $q^d < n$, then by the pigeonhole principle $\Psi$ must treat identically some pair of $\{1\},\{2\},\ldots,\{n\}$, which is a contradiction; thus $\cost(\Pi) \ge \ln n / \ln q$. Combining this lower bound with \cref{eq:lb-for-zq-z-eq-h} and applying \Cref{lem:knwk-lb}, we obtain
\[
\cost(\Pi)
\ge \max\left\{\frac{\ln n}{\ln q},\, k \left( \frac{1}{q^{1/k} (q+1) \ln q} n^{1/k} - 1 \right) \right\}
\ge \frac{k (n^{1/k} - 1)}{q^{1/k} (q+1) (\ln q + 1) \ln q} \ge \frac{k (n^{1/k} - 1)}{3.67 q^{1 + 1/k} \ln^2 q} \,. \qedhere
\]
\end{proof}
\section{Linear Queries Over the Integers} \label{sec:int-linear-measurements}
For $\mathbb{Z}$-LQPs, our main result is a 2-round lower bound for $\elemx_n$. We require a careful accounting of the query cost of a protocol, to adjust for the fact that the (bit) size of the query results
depends on the maximum entry value in a given query matrix. This motivates the following definition and observation.
\begin{definition}
A $\mathbb{Z}$-LQP is said to be {\em $M$-bounded} if each linear measurement can take at most $M$ distinct values. In particular, if the inputs to a $\mathbb{Z}_{[-B,B]}$-LQP $\Pi$ lie in $\b^n$, then $\Pi$ is $(B n + 1)$-bounded.
\end{definition}
Recall the problem $\elemxquarter_n$ defined in \cref{eq:elemxquarter-def}. For $n$ divisible by $4$, this is simply $\elemx_n$ under the additional promise that $|Z| = n/4$. We first prove a $1$-round lower bound for this problem, under a slight additional assumption on $n$.
\begin{lemma} \label{lem:int-quarter-oneround}
Let $n = 4 r$ where $r$ is a prime power. If $\Pi$ is an $M$-bounded one-round protocol for $\elemxquarter_n$,
\begin{align*}
\cost(\Pi) \ge 0.14 \frac{n}{\log M} \,.
\end{align*}
\end{lemma}
\begin{proof}
Let $d = \cost(\Pi)$ and let $A \in \mathbb{Z}^{d \times n}$ be the query performed by $\Pi$. We first consider what $\Pi$ does on inputs of cardinality $n/2$, even though such inputs lie outside the promise region of $\elemxquarter_n$. Soon, we shall see how this helps.
Since $\Pi$ is $M$-bounded, the mapping $\mathbf{z} \mapsto A \mathbf{z}$ from domain $\binom{[n]}{n/2}$ to $\mathbb{Z}^d$ has no more than $M^d$ possible output values. By the pigeonhole principle, there exists a vector $\mathbf{w} \in \mathbb{Z}^d$ for which
\begin{align*}
\mathcal{F}_\mathbf{w} := \left\{ \mathbf{z} \in \binom{[n]}{n/2}:\, A \mathbf{z} = \mathbf{w} \right\} \qquad\text{ has }\qquad |\mathcal{F}_\mathbf{w}| \ge \binom{n}{n/2} M^{-d} \,.
\end{align*}
If there exist two distinct vectors $\mathbf{x},\mathbf{y} \in \mathcal{F}_\mathbf{w}$ such that $|\mathbf{x} \cap \mathbf{y}| = n/4$, then we can construct two disjoint vectors which $\Pi$ can not distinguish, and thus cannot give a correct answer to $\elemxquarter_m$ in both cases. Specifically, $|\mathbf{x} \smallsetminus \mathbf{y}| = |\mathbf{y} \smallsetminus \mathbf{x}| = n/4$ and
\begin{align*}
A (\mathbf{x} \smallsetminus \mathbf{y}) = A \mathbf{x} - A (\mathbf{x} \cap \mathbf{y}) = \mathbf{w} - A (\mathbf{x} \cap \mathbf{y}) = A \mathbf{y} - A (\mathbf{x} \cap \mathbf{y}) = A (\mathbf{y} \smallsetminus \mathbf{x}) \,.
\end{align*}
By \Cref{thm:frankl-wilson}, if there does not exist such a pair $\mathbf{x},\mathbf{y}$, then we have an upper bound on $|\mathcal{F}|$, and can derive
\begin{align*}
\binom{n}{n/2} M^{-d} & \le |\mathcal{F}| \le \binom{n}{n/4 - 1} \,.
\end{align*}
Therefore, $\binom{n}{n/2} M^{-d} \le \binom{n}{n/4}$ and we obtain
\[
d \ge \frac{\log{\binom{n}{n/2}}- \log{\binom{n}{n/4}}}{\log M}
\ge \frac{\log{\binom{4}{2}} - \log \binom{4}{1}}{4} \frac{n}{\log M} \ge 0.14 \frac{n}{\log M} \,. \qedhere
\]
\end{proof}
It should be noted that without the promise that $|Z| = n/4$, a one-round lower bound would follow very easily. By a standard ``decoding'' argument, a one-round protocol for $\elemx$ can be used to recover the entire unknown input $\mathbf{z}$. For completeness, we give the easy proof below. The reason we needed the much more complicated argument in \Cref{lem:int-quarter-oneround} above is that the promise in $\elemxquarter_n$ prevents us from performing such a decoding.
\begin{proposition}[Essentially a restatement of \Cref{prop:int-one-round}]
If $\Pi$ is an $M$-bounded one-round protocol for $\elemx_n$, then $\cost(\Pi) \ge n/\log M - 1$.
\end{proposition}
\begin{proof}
Modify $\Pi$ to add the query $\mathbf{1}^\mathsf{T}$, which reports $|Z|$; this increases $\cost(\Pi)$ by one. Let $A \in \mathbb{Z}^{(d+1)\times n}$ be the modified query matrix. Since $\Pi$ is correct, $A \mathbf{z}$ determines an index $i_1 \in Z$. Let $\mathbf{e}_{i_1}$ be the indicator vector for $i_1$; since we know $\mathbf{e}_{i_1}$, we can compute $A (\mathbf{z} - \mathbf{e}_{i_1})$ without making another query; this is enough to find an index $i_2 \in Z \smallsetminus \{i_1\}$. Repeating this $|Z|$ times, we can reconstruct $Z$ from $A \mathbf{z}$ alone. (This works for all $Z \ne \varnothing$; since we query $\mathbf{1}^\mathsf{T}$, we can also detect when $|Z| = 0$.) By the pigeonhole principle, the number of possible values of $A \mathbf{z}$ must be at least the number of valid inputs, so $M^{d+1} \ge 2^n$, which implies $d \ge n/\log M - 1$.
\end{proof}
For our round elimination argument, we require the following claim, similar to \Cref{clm:z2-partition} and \Cref{clm:zq-partition}. Even though the claim looks similar, the round elimination argument will be subtly different from its $\mathbb{Z}_2$ and $\mathbb{Z}_q$ predecessors.
\begin{claim} \label{clm:zz-sunflower}
Every matrix $A \in \mathbb{Z}^{d \times n}$ admits an $A$-uniform family $S_1, \ldots, S_m$ of size $m \ge n / (c_0 d \log n \log M) - 1$, for some absolute constant $c_0$.
\end{claim}
\begin{proof}
Put $t = \ceil{d \log M}$. Since $\Pi$ is $M$-bounded, the mapping $\mathbf{x} \mapsto A\mathbf{x}$ sends the vectors in $\{\mathbf{x} \in \b^n:\, |\mathbf{x}| = t\}$ to vectors in $\mathbb{Z}^d$ where each entry comes from a set of cardinality $M$. By the pigeonhole principle, there exists a vector $\mathbf{\tilde{r}} \in \mathbb{Z}^d$ such that
\begin{align} \label{eq:pigeonhole}
\mathcal{F} := \{\mathbf{x} \in \b^n:\, |\mathbf{x}| = t \text{ and } A\mathbf{x} = \mathbf{\tilde{r}}\}
\text{~~has cardinality~~} |\mathcal{F}| \ge \dbinom{n}{t} M^{-d} \,.
\end{align}
We claim that $\mathcal{F}$ contains an $m$-sunflower for some integer $m$. Indeed, take $m$ to be the largest integer satisfying
\begin{align} \label{eq:m-constraint}
mt \log n < \frac{n}{2c_1} \,, \qquad \text{ which ensures that } \qquad m \ge \frac{n}{c_0 d \log n \log M} - 1 \,.
\end{align}
This satisfies the claimed bound upon taking $c_0 = 2c_1$ (say). Continuing from \cref{eq:pigeonhole},
\begin{alignat*}{2}
|\mathcal{F}|
&\ge \left(\frac{n}{t}\right)^t M^{-d} &\qquad\qquad & \lhd \text{ standard estimate} \\
&\ge \left(\frac{n}{2t}\right)^t && \lhd \text{ definition of $t$} \\
&\ge (c_1 m \log n)^t && \lhd \text{ by \cref{eq:m-constraint}} \\
&\ge (c_1 m \log(mt))^t \,, && \lhd \text{ by \cref{eq:m-constraint}, again}
\end{alignat*}
whence the required sunflower exists, by \Cref{thm:sunflower}.
Let $\widetilde{S}_1, \ldots, \widetilde{S}_m$ be sets constituting such an $m$-sunflower and let $V = \bigcap_{i=1}^m \widetilde{S}_i$ be the common pairwise intersection. Define $S_i = \widetilde{S}_i \smallsetminus V$, for each $i \in [m]$. We then have $A\mathbf{s}_i = A(\mathbf{\tilde{s}}_i - \mathbf{v}) = \mathbf{\tilde{r}} - A\mathbf{v}$ for each $i$, whence $S_1, \ldots, S_m$ is an $A$-uniform family.
\end{proof}
\begin{lemma}[Round elimination lemma] \label{lem:zz-round-elim}
Let $\Pi$ be a $k$-round $M$-bounded $\mathbb{Z}$-LQP for $\elemx_n$, where $k \ge 1$ and $n$ is an integer. Then there exists a $(k-1)$-round $M$-bounded $\mathbb{Z}$-LQP $\Upsilon$ for $\elemxquarter_m$, such that
\begin{thmparts}
\item $\Upsilon$ shadows $\Pi$ through a homomorphism $\varphi_\Upsilon \colon \Upsilon \to \Pi$; \label{clm:zz-costs}
\item $m / 4$ is a prime number and
\begin{align*}
m \ge \frac{n}{2 c_0 d \log n \log M} - 2 \,,
\end{align*}
where $d$ is the cost of the root of $\Pi$, and $c_0$ the constant from \Cref{clm:zz-sunflower}. \label{clm:zz-shrinkage}
\end{thmparts}
\end{lemma}
\begin{proof}
Let $A \in \mathbb{Z}^{d\times n}$ be the label of the root of $\Pi$. By \Cref{clm:zz-sunflower}, there is an $A$-uniform family $S_1,\ldots,S_{m'}$ of size $m'$. By Bertrand's postulate, there exists a prime number $p$ between between $m'/8$ and $m'/4$; let $m = 4 p$. Let $\mathbf{x} = A \mathbf{s}_1$, $\mathbf{r} = (m/4) \mathbf{x}$ and let $L$ be the lifting matrix defined from $\{S_i\}_{i=1}^{m}$ according to \cref{eq:lift-mtx}. Using \Cref{lem:round-el-gen} on $\Pi$, $L$, and $\mathbf{r}$, we obtain a $(k-1)$-round $\mathbb{Z}$-LQP $\Upsilon$ that shadows $\Pi$, and solves $\elemx_m$ on all inputs $W \subseteq [m]$ for which $L \mathbf{w} \ne \mathbf{0}$ and $A L \mathbf{w} = \mathbf{r}$. While the queries performed by $\Upsilon$ may have larger coefficients than those of $\Pi$, the construction of $\Upsilon$ described in \Cref{sec:framework} only restricts the possible results of each individual linear measurement performed, so $\Upsilon$ is still $M$-bounded. Finally, if $|W| = m/4$, then since $L$ has full rank, $L\mathbf{w} \ne \mathbf{0}$; and furthermore \begin{align*}
A L \mathbf{w} = \sum_{i \in W} A \mathbf{s}_i = |W| \mathbf{x} = \frac{m}{4} \mathbf{x} = \mathbf{r} \,.
\end{align*}
This implies that $\Upsilon$ gives the correct output for $W \subseteq [m]$ fulfilling the promise of $\elemxquarter_m$.
\end{proof}
The preceding round elimination lemma has a key limitation: it requires a protocol for $\elemx_n$ to create one for $\elemxquarter_m$. Because of this, it is not possible to apply the lemma to its own output, and thereby obtain a $k$-round lower bound. Say we were to try, and $A$ were the matrix at the root of the protocol $\Pi$ for $\elemxquarter_n$. Then if $A$ contained an all-ones row, \Cref{clm:zz-sunflower} might produce an $A$-uniform family with all set sizes $|S_i|$ equal to some constant $b$ which is not a factor of $n/4$. Then lifting inputs $W$ of size $m/4$ to inputs $Z$ of size $n/4$ would fail, because $n/4 = |Z| = b |W|$ would imply that $b$ divides $n/4$, a contradiction.
With that said, we now use our round elimination lemma in a one-shot fashion to obtain our main result for integer LQPs.
\begin{theorem}[Restatement of \Cref{thm:int-lower-bounds}]
$\LQ_{\mathbb{Z}_{[-B,B]}}^2(\elemx_n) = \Omega(\sqrt{n} / (\log^{3/2}(nB)) )$.
\end{theorem}
\begin{proof}
Suppose that $\Pi$ is a deterministic 2-round $\mathbb{Z}_{[-B,B]}$-LQP for $\elemx_n$, whose root has cost $d_1$. By \Cref{lem:zz-round-elim}, there is a one round $O(nB)$-bounded protocol for $\elemxquarter_m$ with cost $d_2$. Combining the following three equations:
\begin{alignat*}{2}
\cost(\Pi) &\ge d_1 + d_2 \\
d_2 & \ge \frac{0.14 m}{\log M} &\qquad& \lhd \text{ from \Cref{lem:int-quarter-oneround}}\\
m & \ge \frac{n}{2 c_0 d_1 \log n \log M} - 2 && \lhd \text{ from \Cref{lem:zz-round-elim}}
\end{alignat*}
gives
\[
\cost(\Pi) \ge 0.19 \sqrt{\frac{n}{c_0 \log n \log^2 M}} - 2 = \Omega\left(\frac{\sqrt{n}}{\log^{3/2}(nB)}\right) \,.
\qedhere
\]
\end{proof}
\section{Upper Bounds} \label{sec:upper-bounds}
For the sake of completeness, we provide details of the LQPs attaining various upper bounds referenced throughout the paper. For the most part, these upper bounds are simple observations or extensions of well-known existing results.
\subsection{Deterministic \emph{k}-round LQP for \elemx}
The following family of protocols works both when $D = \mathbb{Z}_{[0,1]}$ on the problem $\elemx_n$, and when $D = \mathbb{Z}_q$ on the problem $\elemxq_n$. The algorithm appears to be well known, and versions of it are described in Lemma 4.1 of \cite{AssadiCK20} and Section 2.2 of \cite{KarpUW88}.
Let $d_1, \ldots, d_{k}$ be a division sequence (see \Cref{lem:division-seq}) for $n$, which minimizes $\sum_{i=1}^{k} d_i$. \Cref{alg:det-protocol} makes no more than $d_r$ queries in each round $r$.
\begin{algorithm*}[!ht]
\caption{~Outline of deterministic query protocol on $\mathbf{z}$}
\label{alg:det-protocol}
\begin{algorithmic}[1]
\State $[u,v] \gets [1,n]$
\For{$r = 1, \ldots, k $}
\State Split the interval $[u,v]$ into $d_r+1$ intervals $J_1,\ldots,J_{d_r+1}$, each of size $\le \lceil \frac{v-u+1}{d_r + 1} \rceil$ \label{line:det-proto-split}
\State Query with matrix $A \in D^{d_r \times n}$, where $A_{i,j}$ is $1$ if $j \in J_i$ and $0$ otherwise.
\State If $A \mathbf{z}$ is not all zero, let $i \in [d_r]$ be the index of any nonzero entry; otherwise, let $i = d_r + 1$.
\State Update $[u,v] \gets J_i$.
\EndFor
\State Report $u$ as the index where $u \in Z$.
\end{algorithmic}
\end{algorithm*}
Since $d_1, \ldots, d_{k}$ is a division sequence for $n$, the final interval $[u,v]$ must have $u=v$. The total cost of the protocol is $\sum_{i=1}^{k} d_i$, which by \Cref{lem:division-seq} lies in the interval $[k (n^{1/k} - 1), k (\lceil n^{1/k} \rceil - 1)]$. Note that when $n = 2^k$, the algorithm cost is exactly $k$.
Write $\mathbf{1}_{S}$ to denote the indicator vector in $D^n$ for a given set $S \subseteq [n]$. To prove that the algorithm is correct, it suffices to verify that $\mathbf{1}^\mathsf{T}_{[u,v]} \mathbf{z} \ne 0$ in each round. Since $\mathbf{1}^\mathsf{T} \mathbf{z} \ne 0$, this is true at the start. For any given round, the matrix $A$ queries $\mathbf{1}_{J_1},\ldots,\mathbf{1}_{J_{d_r}}$. Since $\mathbf{1}_{[u,v]} = \sum_{i=1}^{d_r + 1} \mathbf{1}_{J_i}$, and $\mathbf{1}^\mathsf{T}_{[u,v]} \mathbf{z} \ne 0$, there must be some first index $i$ for which $\mathbf{1}^\mathsf{T}_{J_i} \mathbf{z} \ne 0$. If $i < d_r + 1$, the index is shown in the query response; if $i = d_r + 1$, then no other intervals $J_h$ have $\mathbf{1}^\mathsf{T}_{J_h} \mathbf{z} \ne 0$, so $A \mathbf{z}$ is all zeros. In either case, the algorithm correctly identifies the interval $J_i$ for which $\mathbf{1}^\mathsf{T}_{J_i} \mathbf{z} \ne 0$.
\subsection{Randomized 1-round LQP for \elemx}
The $\ell_0$-sampling algorithm from \cite{JowhariST11} relies on a standard result on the exact recovery of sparse vectors in $\mathbb{R}^n$, which (paraphrasing) states that $O(s)$ $\mathbb{R}$-linear queries suffice to exactly recover any $s$-sparse vector $\mathbf{v}$ in $\mathbb{R}^n$, or if $\mathbf{v}$ is not sparse, say that the output is \textsc{dense} with high probability. The $\ell_0$-sampling algorithm then chooses subsets $\{T_i\}_{i=1}^{\lceil \log n \rceil}$ where each $T_i$ is uniformly randomly drawn from the set of all subsets of $[n]$ of size $2^i$. To obtain a constant final error probability, for each set $T_i$, the $\ell_0$-sampler runs the sparse recovery method on the coordinates given by $T_i$ with $s = O(1)$. The sampler then returns a random index from the first sparse recovery instance to successfully recover a nonzero vector. With high probability, at least one of the sets $T_i$ will contain fewer than $O(1)$ entries of $Z$, and the algorithm succeeds.
Recovering $s$-sparse vectors in $\{0,1\}^n$ is easier than recovering general $s$-sparse vectors in $\mathbb{R}^{n}$ or $\mathbb{Z}^{n}$, so directly adapting \cite{JowhariST11}'s $\ell_0$-sampling algorithm to $\elemx$ means only $O(\log n)$ queries are needed for $\mathbb{Z}_{[-B,B]}$ with $B = O(\poly (n))$, and $O(\log ^2 n / \log q)$ for $\mathbb{Z}_q$. This follows from the costs of $s$-sparse recovery and detection with $D$-linear queries and $\b^n$, addressed in the following lemma. We spell out this result and its proof for the sake of completeness: though it may be folklore, it appears not to have been published in quite this form.
\begin{lemma}[Discrete $s$-sparse recovery]\label{lem:sparse-recovery}
There exists a query matrix $H \in \mathbb{Z}_{[-B,B]}^{r \times n}$ for $r = O(s \log n / \log B)$ for which the query $H v$ returns a unique value for all $V \subseteq [n]$ with $|V| \le s$. The same holds true for $\mathbb{Z}_q$ with $r = O(s \log n / \log q)$.
\end{lemma}
\begin{proof}
Call a matrix in $A \in D^{r \times t}$ full-$[-1,1]$-rank if there does not exist a nonzero vector $\mathbf{v} \in \{-1,0,1\}^t$ for which $A \mathbf{v} = \mathbf{0}$. If we choose a matrix $B \in D^{r \times t}$ uniformly at random, then it is full-$[-1,1]$-rank with probability $\ge 1 - 3^t/|D|^r$. One way to prove this is to consider columns the $\mathbf{b}_1 \ldots \mathbf{b}_t$ of $B$ one by one, and note that if each $\mathbf{b}_i$ is not contained in the set $F_i := \{ \sum_{j=1}^{i-1} a_i \mathbf{b}_i : a \in \{-1,0,1\}^{i-1}\} $, then $B$ has full-$[-1,1]$-rank. Since $B$ is chosen uniformly at random, each column is independent of the the earlier ones, so
\begin{align*}
\Pr[ \text{D doesn't have full $[-1,1]$-rank} ]
& \le \sum_{i=1}^{t} \Pr[\mathbf{b}_i \notin F_i ]
\le \sum_{i=1}^{t} \frac{3^{i-1}}{|D|^r}
\le \frac{3^t}{|D|^r} \,.
\end{align*}
Let $r$ be chosen later; if we pick $\hat{H} \in D^{ r \times n}$ uniformly at random, then the expected number of sets $T \subseteq [n]$ with $|T| = 2s$ for which $\hat{H}_T$ (the submatrix of $\hat{H}$ with columns in $T$) has full $[-1,1]$-rank is $\le \binom{n}{2s} 3^{2s} / |D|^n$. Letting $r = \lceil 2 s \log(3n) / \log(|D|) \rceil$ makes this less than $1$. Consequently, there must exist a specific matrix $H$ for which every such submatrix $H_T$ has full $[-1,1]$-rank. Then for any two distinct vectors $\mathbf{u},\mathbf{v} \in \{0,1\}^n$ with $|U|,|V| \le s$, we cannot have $H \mathbf{u} = H \mathbf{v}$, because that would imply there exists $T \supseteq U \cup V$ with $|T|=2s$ for which $H_T (bu - bv) = 0$, contradicting the full $[-1,1]$-rank assumption.
\end{proof}
Detecting whether a $\{0,1\}^n$ vector is not $s$-sparse is also easier than in $\mathbb{R}^n$. For $\mathbb{Z}_{[-B,B]}$-LQPs, querying with the vector $\mathbf{1} \in \mathbb{Z}^{d}$ suffices. For $\mathbb{Z}_q$, because \Cref{lem:sparse-recovery} ensures that if a vector $\mathbf{z}$ is s-sparse, it can be recovered exactly, it is enough to query $O(1)$ random vectors in $\mathbb{Z}_q^n$. Let $\mathbf{r}$ be such a random vector, and let $\mathbf{w}$ be the $s$-sparse vector in $\{0,1\}$ recovered using $H$; if $\mathbf{z}$ was s-sparse, then $\mathbf{z} = \mathbf{w}$ and $\mathbf{r}^\mathsf{T} \mathbf{z} = \mathbf{r}^\mathsf{T} \mathbf{w}$; otherwise, $\mathbf{r}^\mathsf{T} \mathbf{z}$ does not equal $\mathbf{r}^\mathsf{T} \mathbf{w}$ with probability $1 - 1/q$.
\section{Connections Between $\mathbb{Z}_2$-LQPs and Circuit Complexity} \label{sec:kw-lb}
A weaker version of \Cref{thm:z2-k-round} can be proven by combining existing results. As shown in the following lemma, a given $k$-round $\mathbb{Z}_2$-LQP $\Pi$ for $\elemxodd$ can be converted to a communication protocol $\Upsilon$ for the Karchmer-Wigderson game on $\textsc{parity}_n$, with the communication cost $C$ of $\Upsilon$ being $\le 2 \cost(\Pi)$. By a slight adaptation of the proof of Theorem 5 in~\cite{NisanW93}, we can convert $\Upsilon$ into an unbounded fan-in boolean formula with depth $k+1$ and no more than $2^C - 1$ AND/OR gates that computes $\textsc{parity}_n$. Relatively tight lower bounds on the size of such a formula date back to \cite{Hastad86}, but we use a result of \cite{Rossman15}, which says that a depth-$(k+1)$ unbounded fan-in formula computing $\textsc{parity}_n$ must have at least $2^{\Omega(k (n^{1/k}-1)}$ AND/OR gates. Thus $\cost(\Pi) \ge \frac{1}{2} C \ge \Omega(k (n^{1/k}-1))$.
\begin{lemma}
Consider the Karchmer-Wigderson game for $\textsc{parity}_n$, in which Alice has a set $X \in \b^n$ with $|X|$ even, and Bob has a set $Y \in \b^n$ with $|Y|$ odd, and they seek to identify an index $i\in[n]$ for which $\mathbf{x}_i \ne \mathbf{y}_i$. Let $\Pi$ be a $k$-round $\mathbb{Z}_2$-LQP for $\elemxodd_n$; then there exists $\Upsilon$ a $k$-round communication protocol for this game, with cost $\le 2 \cost(\Pi)$.
\end{lemma}
\begin{proof}
Let $\rho$ be the root of $\Pi$, with label $A_\rho \in \mathbb{Z}_2^{d_\rho \times n}$. In the first round of $\Upsilon$, Alice sends $A_\rho \mathbf{x}$ to Bob. Then Bob computes $A_\rho \mathbf{y}$, and uses Alice's message to determine $\mathbf{r}_1 = A_\rho (\mathbf{x} + \mathbf{y})$. The value $\mathbf{r}_1$ determines a child node $\nu$ of $\rho$. If this is a leaf, Bob outputs its label $o_\nu$. Otherwise, in the second round, Bob sends both $A_\rho \mathbf{y}$ and $A_\nu \mathbf{y}$ to Alice. Given $A_\rho \mathbf{y}$, Alice can determine $\nu$, and compute $A_\nu \mathbf{x}$. With this, Alice can compute $\mathbf{r}_2 = A_\nu (\mathbf{x} + \mathbf{y})$, and identify the child node $\mu$ of $\nu$. If this is a leaf, Alice outputs $o_\mu$; otherwise, in the third round, Alice sends $A_\nu \mathbf{x}$ and $A_\mu \mathbf{x}$ to Bob; the players continue in this fashion until a leaf is reached and the protocol ends; since $\Pi$ has depth $k$, this takes at most $k$ rounds.
This protocol is correct, because it finds the leaf of $\Pi$ associated to the input $\mathbf{x} + \mathbf{y}$. Since we are promised $\mathbf{x}$ has even parity, and $\mathbf{y}$ odd, $\mathbf{x} + \mathbf{y}$ has odd parity and thus fulfills the condition under which a protocol for $\elemxodd_n$ must be correct. The output value is an index $i$ where $\mathbf{x}_i + \mathbf{y}_i = 1$, hence where $\mathbf{x}_i \ne \mathbf{y}_i$, as required for the communication game.
Since $A_\rho \mathbf{x} \in \mathbb{Z}_2^{d_\rho}$, the round first message uses exactly $d_\rho$ bits. The second, $d_\rho + d_\nu$, the third, $d_\nu + d_\mu$, and so on. The communication needed on inputs ($\mathbf{x},\mathbf{y}$) is thus at most twice $\cost(\Pi,\mathbf{x}+\mathbf{y})$, so the worst-case communication cost of $\Upsilon$ is at most $2 \cost(\Pi)$.
\end{proof}
\section{Appendix} \label{sec:appendix}
The following estimate was used in \Cref{sec:zq-linear-measurements} during calculations in the proof of our $\mathbb{Z}_q$-LQP lower bound.
\begin{lemma}\label{lem:knwk-lb}
Let $C,D$ be constants with $2 C \le D$ and $D \ge 1$. Then
\begin{align}\label{eq:knwk-lb}
\max\left( \frac{\ln n}{C},k \left(\frac{1}{D} n^{1/k} -1 \right) \right) \ge \frac{1}{D (1 + C)} k \left( n^{1/k} -1 \right) \,.
\end{align}
\begin{proof}
Let $\gamma_n(k) = k(n^{1/k} - 1)$. We have $k \left(\frac{1}{D} n^{1/k} -1 \right) \ge \frac{1}{D} \gamma_n(k) - k$. Since $\gamma_n(k)$ is decreasing, let $k_\star$ be the unique solution to $\frac{1}{D} \gamma_n(k_\star) = \frac{1}{C}\ln n$. Since $\gamma_n(\ln n) = (e-1)\ln n \le 2\ln n \le \frac{D}{C} \ln n$, it follows $k_\star \le \ln n$. Let $k_\dagger$ be the unique solution to $\frac{1}{D} \gamma_n(k_\dagger) - k_\dagger = \frac{1}{C}\ln n$. Since $k_\dagger \le k_\star$, $k_\dagger \le \ln n$ as well. Evaluating the right hand side of \cref{eq:knwk-lb} at $k_\dagger$ gives:
\begin{align*}
\frac{1}{D (1+C)} \gamma_n(k_\dagger) &= \frac{1}{D (1+C)} \left(\frac{D \ln n}{C} + D k_\dagger \right) \\
&\le \frac{1}{D (1+C)} \left(\frac{D \ln n}{C} + D \ln n \right) \\
& = \frac{\ln n}{C} = \frac{1}{D} \gamma_n(k_\dagger) - k_\dagger \,.
\end{align*}
Because the derivative of $\frac{1}{D (1+C)} \gamma_n(k)$ is less that of $\frac{\ln n}{C}$ when $k \ge k_\dagger$, and greater than that of $\frac{1}{D} \gamma_n(k) - k$ for $k \le k_\dagger$, we can extend this inequality to all $k \in (0,\infty)$, proving \cref{eq:knwk-lb}.
\end{proof}
\end{lemma}
| {'timestamp': '2021-07-14T02:08:11', 'yymm': '2107', 'arxiv_id': '2107.05810', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05810'} | arxiv |
\section{Introduction}
\label{sec:intro}
Robust out-of-distribution (OOD) generalization is one of the key open challenges in machine learning. This is particularly relevant for the deployment of ML models to the real world, where we need systems that generalize beyond the i.i.d.\ (independent and identically distributed) data setting \cite{scholkopf2021towards, djolonga2020robustness, koh2020wilds, barbu2019objectnet, azulay2019deep, roy2018effects, gulrajani2020search, hendrycks2019robustness, michaelis2019benchmarking, funkbenchmark}. One instance of such models are agents that learn by interacting with a training environment and we would like them to generalize to other environments with different statistics~\cite{zhang2018study, pfister2019learning, cobbe2019quantifying, ahmed2020causalworld, ke2021systematic}.
Consider the example of a robot with the task of moving a cube to a target position: Such an agent can easily fail as soon as some aspects of the environment differ from the training setup, e.g.\ the shape, color, and other object properties, or when transferring from simulation to real world.
Humans do not suffer from these pitfalls when transferring learned skills beyond a narrow training domain, presumably because they represent visual sensory data in a concise and useful manner~\cite{marr1982vision,gordon1996s,lake2017building,anand2019unsupervised, spelke1990principles}.
Therefore, a particularly promising path is to base predictions and decisions on similar low-dimensional representations of our world~\citep{bengio2013representation,kaiser2019model,finn2016deep,barreto2017successor,dittadi2021planning,stooke2020decoupling,vinyals2019grandmaster}. The learned representation should facilitate efficient downstream learning~\cite{eslami2018neural, anand2019unsupervised,stooke2020decoupling,van2019disentangled} and exhibit better generalization~\cite{zhang2020learning,srinivas2020curl}.
Learning such a representation from scratch for every downstream task and every new variation would be inefficient. If we learned to juggle three balls, we should be able to generalize to oranges or apples without learning again from scratch. We could even do it with cherimoyas, a fruit that we might have never seen before. We can effectively reuse our generic representation of the world.
We thus consider deep learning agents trained from pretrained representations and ask the following questions:
To what extent do they generalize under distribution shifts similar to those mentioned above?
Do they generalize in different ways or to different degrees depending on the type of distribution shift, including sim-to-real?
Can we predict the OOD generalization of downstream agents from properties of the pretrained representations?
To answer the questions above, we need our experimental setting to be realistic, diverse, and challenging, but also controlled enough for the conclusions to be sound.
We therefore base our study on the robot platform introduced by \citet{wuthrich2020trifinger}. The scene comprises a robot finger with three joints that can be controlled to manipulate a cube in a bowl-shaped stage.
\citet{dittadi2020transfer} conveniently introduced a dataset of simulated and real-world images of this setup with ground-truth labels, which can be used to pretrain and evaluate representations.
To train downstream agents, we adapted the simulated reinforcement learning benchmark CausalWorld from \citet{ahmed2020causalworld} that was developed for this platform.
Building upon these works, we design our experimental study as follows (see \cref{fig:experimental_setup}):
First, we pretrain representations from static simulated images of the setup and evaluate a collection of representation metrics. Following prior work \cite{watter2015embed,van2016stable,ghadirzadeh2017deep,nair2018visual,ha2018recurrent,eslami2018neural}, we focus on autoencoder-based representations.
Then, we train downstream agents from this fixed representation on a set of environments.
Finally, we investigate the zero-shot generalization of these agents to new environments that are out of the training distribution, including the real robot.
The goal of this work is to provide the first systematic and extensive account of the OOD generalization of downstream RL agents in a robotic setup, and how this is affected by characteristics of the upstream pretrained representations.
We summarize our contributions as follows:
\begin{itemize}[topsep=0pt,itemsep=0pt,leftmargin=20pt]
\item We train 240 representations and 11,520 downstream policies,\footnote{Training the representations required approximately 0.62 GPU years on NVIDIA Tesla V100. Training and evaluating the downstream policies required about 86.8 CPU years on Intel Platinum 8175M.} and systematically investigate their performance under a diverse range of distribution shifts.\footnote{Additional results and videos are provided at \url{https://sites.google.com/view/ood-rl}.}
\item We extensively analyze the relationship between the generalization of our RL agents and a substantial set of representation metrics.
\item Notably, we find that a specific representation metric that measures the generalization of a simple downstream proxy task reliably predicts the generalization of downstream RL agents under the broad spectrum of OOD settings considered here. This metric can thus be used to select pretrained representations that will lead to more robust downstream policies.
\item In the most challenging of our OOD scenarios, we deploy a subset of the trained policies to the corresponding real-world robotic platform, and observe surprising zero-shot sim-to-real generalization without any fine-tuning or domain randomization.
\end{itemize}
\setlength{\belowcaptionskip}{-13pt}
\begin{figure}
\centering
\includegraphics[width=0.93\linewidth]{figures/figure1.png}
\caption{\small \textbf{Overview of our experimental setup for investigating out-of-distribution generalization in downstream tasks.} (1)~We train 240 $\beta$-VAEs on the robotic dataset from \citet{dittadi2020transfer}. (2)~We then train downstream policies to solve \textit{object reaching} or \textit{pushing}, using multiple random RL seeds per VAE. The input to a policy consists of the output of a pretrained encoder and additional task-related observable variables. Crucially, the policy is only trained on a subset of the cube colors from the pretraining dataset. (3)~Finally, we evaluate these policies on their respective tasks in four different scenarios: (a)~in-distribution, i.e. with cube colors used in policy training; (b)~OOD1, i.e. with cube colours previously seen by the encoder but OOD for the policy; (c)~OOD2-sim, having cube colours also OOD to the encoder; (d)~sim-to-real zero-shot on the real-world setup.}
\label{fig:experimental_setup}
\end{figure}
\setlength{\belowcaptionskip}{0pt}
\section{Background}
\label{sec:background}
In this section, we provide relevant background on the methods for representation learning and reinforcement learning, and on the robotic setup to evaluate out-of-distribution generalization.
\textbf{Variational autoencoders.}
VAEs \cite{kingma2013auto,rezende2014stochastic} are a framework for optimizing a latent variable model $p_{\theta}(\mathbf{x}) = \int_\mathbf{z} p_{\theta}(\mathbf{x} \,|\, \mathbf{z}) p(\mathbf{z}) d\mathbf{z}$ with parameters $\theta$, typically with a fixed prior $p(\mathbf{z})=\mathcal{N}(\mathbf{z}; \mathbf{0}, \mathbf{I})$, using amortized stochastic variational inference. A variational distribution $q_{\phi}(\mathbf{z} \,|\, \mathbf{x})$ with parameters $\phi$ approximates the intractable posterior $p_{\theta}(\mathbf{z} \,|\, \mathbf{x})$. The approximate posterior and generative model, typically called encoder and decoder and parameterized by neural networks, are jointly optimized by maximizing a lower bound to the log likelihood (the ELBO):
\begin{align}
\log p_{\theta}(\mathbf{x})
&\geq \mathbb{E}_{q_{\phi}(\mathbf{z} \,|\, \mathbf{x})} \left[ \log p_{\theta}(\mathbf{x} \,|\, \mathbf{z}) \right] - D_\mathrm{KL}\left( q_{\phi}(\mathbf{z} \,|\, \mathbf{x}) \| p(\mathbf{z})\right)
= \mathcal{L}^{ELBO}_{\theta,\phi} (\mathbf{x}) \ .
\end{align}
In $\beta$-VAEs, the KL term is modulated by a factor $\beta$ to enforce a more structured latent space \cite{higgins2016beta,burgess2018understanding}.
While VAEs are typically trained without supervision, we also employ a form of weak supervision \cite{locatello2020weakly} that encourages disentanglement.
\textbf{Reinforcement learning.}
A Reinforcement Learning (RL) problem is typically modeled as a Partially Observable Markov Decision Process (POMDP) defined as a tuple $(S, A, T, R, \Omega, O, \gamma, \rho_{0}, H)$ with states $s \in S$, actions $a \in A$ and observations $o \in \Omega$ determined by the state and action of the environment $O(o|s,a)$. $T(s_{t+1}|s_{t},a_{t})$ is the transition probability distribution function, $R(s_t,a_t)$ is the reward function, $\gamma$ is the discount factor, $\rho_{0}(s)$ is the initial state distribution at the beginning of each episode, and $H$ is the time horizon per episode.
The objective in RL is to learn a policy $\pi: S \times A \rightarrow [0, 1]$, typically parameterized by a neural network, that maximizes the total discounted expected reward $J(\pi)=\mathbb{E} \big[ \sum_{t=0}^{H}\gamma^t R(s_t, a_t) \big]$.
There is a broad range of model-free learning algorithms to find $\pi^*$ by policy gradient optimization or by learning value functions while trading off exploration and exploitation \cite{haarnoja2018soft, schulman2017proximal, sutton1999policy, schulman2015high, schulman2015trust, silver2014deterministic, fujimoto2018addressing}. Here, we optimize the objective above with \emph{Soft Actor Critic} (SAC), an off-policy method that simultaneously maximizes the expected reward and the entropy $H(\pi(\cdot|s_t))$, and is widely used in control tasks due to its sample efficiency \cite{haarnoja2018soft}.\looseness=-1
\textbf{A robotic setup to evaluate out-of-distribution generalization.}
Our study is based on a real robot platform where a robotic finger with three joints manipulates a cube in a bowl-shaped stage \cite{wuthrich2020trifinger}. We pretrain representations on a labeled dataset introduced by \citet{dittadi2020transfer} which consists of simulated and real-world images of this setup. This dataset has 7 underlying factors of variation (FoV): angles of the three joints, and position (x and y), orientation, and color of the cube.
Some of these factors are correlated \cite{dittadi2020transfer}, which may be problematic for representation learners, especially in the context of disentanglement \cite{trauble2020independence,chen2021boxhead}.
After training the representations, we train downstream agents and evaluate their generalization on an adapted version of the simulated CausalWorld benchmark \cite{ahmed2020causalworld} that was developed for the same setup. Finally, we test sim-to-real generalization on the real robot.
Our experimental setup, illustrated in \cref{fig:experimental_setup}, allows us to systematically investigate a broad range of out-of-distribution scenarios in a controlled way.
We pretrain our representations from this simulated dataset that covers 8 distinct cube colors. We then train an agent from this fixed representation on a subset of the cube colors, and evaluate it (1) on the same colors (this is the typical scenario in RL), (2) on the held-out cube colors that are still known to the encoder, or (3) OOD w.r.t. the encoder's training distribution, e.g. on novel colors and shapes or on the real world.
We closely follow the framework for measuring OOD generalization proposed by \citet{dittadi2020transfer}. In this framework, a representation is initially learned on a training set $\mathcal{D}$, and a simple downstream model is trained on a subset $\mathcal{D}_1 \subset \mathcal{D}$ to predict the ground-truth factors from the learned representation.
Generalization is then evaluated by testing the downstream model on a set $\mathcal{D}_2$ that differs distributionally from $\mathcal{D}_1$, e.g. containing images corresponding to held-out values of a chosen factor of variation (FoV).
\citet{dittadi2020transfer} consider two flavors of OOD generalization depending on the choice of $\mathcal{D}_2$:
First, the case when $\mathcal{D}_2 \subset \mathcal{D}$, i.e. the OOD test set is a subset of the dataset for representation learning. This is denoted by \textbf{OOD1} and corresponds to the scenario~(2) from the previous paragraph. In the other scenario, referred to as \textbf{OOD2}, $\mathcal{D}$ and $\mathcal{D}_2$ are disjoint and distributionally different. This even stronger OOD shift corresponds to case~(3) above.
The generalization score for $\mathcal{D}_2$ is then measured by the (normalized) mean absolute prediction error across all FoVs except for the one that is OOD. Following \citet{dittadi2020transfer}, we use a simple 2-layer Multi-Layer Perceptron (MLP) for downstream factor prediction, we train one MLP for each FoV, and report the \textit{negative} error.
This simple and cheap generalization metric could serve as a convenient proxy for the generalization of more expensive downstream tasks.
We refer to these generalization scores as GS-OOD1, GS-OOD2-sim, and GS-OOD2-real depending on the scenario.
The focus of \citet{dittadi2020transfer} was to scale VAE-based approaches to more realistic scenarios and study the generalization of these simple downstream tasks, with a particular emphasis on disentanglement. Building upon their contributions, we can leverage the broader potential of this robotic setup with many more OOD2 scenarios to study our research questions: To what extent can agents generalize under distribution shift? Do they generalize in different ways depending on the type of shift (including sim-to-real)? Can we predict the OOD generalization of downstream agents from properties of the pretrained representations such as the GS metrics from \citet{dittadi2020transfer}?\looseness=-1
\section{Study design}
\label{sec:study_design}
\textbf{Robotic setup.} Our setup is based on TriFinger \cite{wuthrich2020trifinger} and consists of a robotic finger with three joints that can be controlled to manipulate an object (e.g. a cube) in a bowl-shaped stage.
The agent receives a camera observation consistent with the images in \citet{dittadi2020transfer} and outputs a three-dimensional action.
During training, which always happens in simulation, the agent only observes a cube of four possible colors, randomly sampled at every episode (see \cref{fig:experimental_setup}, step 2).\looseness=-1
\textbf{Distribution shifts.} After training, we evaluate these agents in 7 environments: (1) the training environment, which is the typical setting in RL, (2) the OOD1 setting with cube colors that are OOD for the agent but still in-distribution for the encoder, (3) the more challenging OOD2-sim setting where the colors are also OOD for the encoder, (4-6) the OOD2 settings where the object colors are as in the 3 previous settings but the cube is replaced by a sphere (a previously unseen shape), (7) the OOD2-real setting, where we evaluate zero-shot sim-to-real transfer on the real robotic platform.
\textbf{Tasks.}
We begin our study with the \textit{object reaching} downstream control task, where the agent has to reach an object placed at an \textit{arbitrary} random position in the arena. This is significantly more challenging than directly predicting the ground-truth factors, as the agent has to learn to reach the cube by acting on the joints, with a scalar reward as the only learning signal.
Consequently, the compute required to learn this task is about 1,000 times greater than in the simple factor prediction case.
We additionally include in our study a \textit{pushing} task which consists of pushing an object to a goal position that is sampled at each episode. Learning this task takes one order of magnitude more compute than \textit{object reaching}, likely due to the complex rigid-body dynamics and object interactions. To the best of our knowledge, this is the most challenging manipulation task that is currently feasible on our setup. \citet{ahmed2020causalworld} report solving a similar pushing task, but require the full ground-truth state to be observable.\looseness=-1
\textbf{Training the RL agents.}
The inputs at time $t$ are the camera observation $o_t$ and a vector of observable variables $x_t$ containing the joint angles and velocities, as well as the target object position in \textit{pushing}. We then feed the camera observation $o_t$ into an encoder $e$ that was pretrained on the dataset in \citet{dittadi2020transfer}. The result is concatenated with $x_t$, yielding a state vector $s_t = [x_t, e(o_t)]$.
We then use SAC to train the policy with $s_t$ as input. The policy, value, and Q networks are implemented as MLPs with 2 hidden layers of size 256. When training the policies, we keep the encoder frozen.
\textbf{Model sweep.}
To shed light on the research questions outlined in the previous sections, we perform a large-scale study in which we train 240 representation models and 11,520 downstream policies, as described below. See \cref{app:implementation_details} for further implementation details.
\begin{itemize}[itemsep=0pt,topsep=0pt,leftmargin=20pt]
\item We train 120 $\beta$-VAEs \cite{higgins2016beta} and 120 Ada-GVAEs \cite{locatello2020weakly} with a subset of the hyperparameter configurations and neural architecture from \citet{dittadi2020transfer}. Specifically, we consider $\beta \in \{1, 2, 4\}$, $\beta$ annealing over $\{0, 50000\}$ steps, with and without input noise, and 10 random seeds per configuration. The latent space size is fixed to $10$ following prior work \cite{kim2018disentangling,chen2018isolating,locatello2020weakly,trauble2020independence}.
\item For \textit{object reaching}, we train 20 downstream policies (varying random seed) for each of the 240 VAEs. The resulting 4,800 policies are trained for 400k steps (approximately 2,400 episodes).
\item Since \textit{pushing} takes substantially longer to train, we limit the number of policies trained on this task: We choose a subset of 96 VAEs corresponding to only 4 seeds, and then use 10 seeds per representation. The resulting 960 policies are trained for 3M steps (about 9,000 episodes).
\item Finally, for both tasks we also investigate the role of regularization on the policy. More specifically, we repeat the two training sweeps from above (5,760 policies), with the difference that now the policies are trained with L1 regularization on the first layer.
\end{itemize}
\textbf{Limitations of our study.}
Although we aim to provide a sound and extensive empirical study, such studies are inevitably computationally demanding. Thus, we found it necessary to make certain design choices. For each of these choices, we attempted to follow common practice, in order to maintain our study as relevant, general, and useful as possible.
One such decision is that of focusing on autoencoder-based representations. To answer our questions on the effect of upstream representations on the generalization of downstream policies, we need a diverse range of representations.
How these representations are obtained is not directly relevant to answer our research question.
Following \citet{dittadi2020transfer}, we chose to focus on $\beta$-VAE and Ada-GVAE models, as they were shown to provide a broad set of representations, including fully disentangled ones. Although we conjecture that other classes of representation learning algorithms should generally reveal similar trends as those found in our study, this is undoubtedly an interesting extension.
As for the RL algorithm used in this work, SAC is known to be a particularly sample-efficient model-free RL method that is a popular choice in robotics \cite{haarnoja2018learning, kiran2021deep, singh2019end}.
Extensive results on pushing from ground-truth features on the same setup in \citet{ahmed2020causalworld} indicate that methods like TD3 \cite{fujimoto2018addressing} or PPO \cite{schulman2017proximal} perform very similarly to SAC under the same reward structure and observation space. Thus, we expect the results of our study to hold beyond SAC.
Another interesting direction is the study of additional regularization schemes on the policy network, an aspect that is often overlooked in RL.
We expect the potential insights from extending the study along these axes to not justify the additional compute costs and corresponding carbon footprint. However, with improving efficiency and decreasing costs, we believe these could become worthwhile validation experiments in the future.
\section{Results}
\label{sec:results}
We discuss our results in three parts: In \cref{subsec:results_training_and_indistrib_performance}, we present the training results of our large-scale sweep, and how policy regularization and different properties of the pretrained representations affect in-distribution reward.
\Cref{subsec:results_ood_generalization_simulation} gives an extensive account of which metrics of the pretrained representations predict OOD generalization of the agents in simulated environments. Finally, in \cref{subsec:results_ood_generalization_real_robot} we perform a similar evaluation on the real robot, in a zero-shot sim-to-real scenario.
\setlength{\belowcaptionskip}{-10pt}
\begin{figure}
\centering
\begin{minipage}{0.37\textwidth}
\centering
\includegraphics[width=\linewidth]{figures/moving_avg_object_reaching_success.png}
\includegraphics[width=\linewidth]{figures/fig2_reach.png}
\end{minipage}
\qquad
\begin{minipage}{0.37\textwidth}
\centering
\includegraphics[width=\linewidth]{figures/moving_avg_pushing_success.png}
\includegraphics[width=\linewidth]{figures/fig2_push.png}
\end{minipage}
\caption{\small Top: Average training success, aggregated over \emph{all} policies from the sweep (median, quartiles, 5th/95th percentiles). Bottom: Rank correlations between representation metrics and in-distribution reward (evaluated when the policies are fully trained), in the case without regularization. Correlations are color-coded in red (positive) or blue (negative) when statistically significant (p<0.05), otherwise they are gray.
}
\label{fig:results_on_training_env}
\end{figure}
\setlength{\belowcaptionskip}{0pt}
\subsection{Results in the training environment}
\label{subsec:results_training_and_indistrib_performance}
\cref{fig:results_on_training_env} shows the training curves of all policies for \textit{object reaching} and \textit{pushing} in terms of the task-specific success metric.
Here we use success metrics for interpretability, as their range is always $[0,1]$.
In \textit{object reaching}, the success metric indicates progress from the initial end effector position to the optimal distance from the center of the cube. It is 0 if the final distance is not smaller than the initial distance, and 1 if the end effector is touching the center of a face of the cube.
In \textit{pushing}, the success metric is defined as the volumetric overlap of the cube with the goal cube, and the task can be visually considered solved with a score around 80\%.
From the training curves we can conclude that both tasks can be consistently solved from pixels using pretrained representations. In particular, all policies on \textit{object reaching} attain almost perfect scores.
Unsurprisingly, the more complex \textit{pushing} task requires significantly more training, and the variance across policies is larger. Nonetheless, almost all policies learn to solve the task satisfactorily.
To investigate the effect of representations on the training reward, we now compute its Spearman rank correlations with various supervised and unsupervised metrics of the representations (\cref{fig:results_on_training_env} bottom). By training reward, we mean the average reward of a fully trained policy over 200 episodes in the training environment (see \cref{app:implementation_details}).
On \textit{object reaching}, the final reward correlates with the ELBO and the reconstruction loss.
A simple supervised metric to evaluate a representation is how well a small downstream model can predict the ground-truth factors of variation. Following \citet{dittadi2020transfer}, we use the MLP10000 and GBT10000 metrics (simply MLP and GBT in the following), where MLPs and Gradient Boosted Trees (GBTs) are trained to predict the FoVs from 10,000 samples. The training reward correlates with these metrics as well, especially with the MLP accuracy. This is not entirely surprising: if an MLP can predict the FoVs from the representations, our policies using the same architecture could in principle retrieve the FoVs relevant for the task.
Interestingly, the correlation with the overall MLP metric mostly stems from the cube pose FoVs, i.e. those that are not included in the ground-truth state $x_t$.
These results suggest that these metrics can be used to select good representations for downstream RL.
On the more challenging task of \textit{pushing}, the correlations are milder but most of them are still statistically significant.
\textbf{Summary.} Both tasks can be consistently solved from pixels using pretrained representations. Unsupervised (ELBO, reconstruction loss) and supervised (ground-truth factor prediction) in-distribution metrics of the representations are correlated with reward in the training environment.
\subsection{Out-of-distribution generalization in simulation}
\label{subsec:results_ood_generalization_simulation}
\begin{wrapfigure}[14]{r}{4.1cm}
\centering
\vspace{-17pt}
\includegraphics[width=\linewidth]{figures/fig3.png}
\vspace*{-5mm}
\caption{\small Correlations between training (in distrib.) and OOD rewards (p<0.05).}
\label{fig:OOD_correlations_reward_trasfer}
\end{wrapfigure}
\textbf{In- and out-of-distribution rewards.}
After training, the in-distribution reward correlates with OOD1 performance on both tasks (especially with regularization), but not with OOD2 performance (see \cref{fig:OOD_correlations_reward_trasfer}).
Moreover, rewards in OOD1 and OOD2 environments are moderately correlated across tasks and regularization settings.
\textbf{Unsupervised metrics and informativeness.}
In \cref{fig:sim_world_OOD_rank_correlations_reaching_no_reg} (left) we assess the relation between OOD reward and in-distribution metrics (ELBO, reconstruction loss, MLP, and GBT).
Both ELBO and reconstruction loss exhibit a correlation with OOD1 reward, but not with OOD2 reward. These unsupervised metrics can thus be useful for selecting representations that will lead to more robust downstream RL tasks, as long as the encoder is in-distribution.
While the GBT score is not correlated with reward under distribution shift, we observe a significant correlation between OOD1 reward and the MLP score, which measures downstream factor prediction accuracy of an MLP with the same architecture as the one parameterizing the policies. As in \cref{subsec:results_training_and_indistrib_performance}, we further investigate the source of this correlation, and find it in the pose parameters of the cube.
Correlations in the OOD2 setting are much weaker, thus we conclude that these metrics do not appear helpful for model selection in this case.
Our results on \textit{pushing} confirm these conclusions although correlations are generally weaker, presumably due to the more complicated nature of this task. An extensive discussion is provided in \cref{app:additional_results_ood_simulation}.
\setlength{\belowcaptionskip}{-10pt}
\begin{figure}
\begin{minipage}[t]{0.335\linewidth}
\vspace{0pt}
\includegraphics[width=\linewidth]{figures/fig4_metrics.png}
\end{minipage}
\hfill
\begin{minipage}[t]{0.65\linewidth}
\vspace{0pt}
\includegraphics[width=\linewidth]{figures/fig4_transfer.png}
\end{minipage}
\caption{\small Rank correlations of representation properties with OOD1 and OOD2 reward on \textit{object reaching} without regularization.
Numbering when splitting metrics by FoV: (1) cube color; (2--4) joint angles; (5--7) cube position and rotation. Correlations are color-coded as described in \cref{fig:results_on_training_env}.}
\label{fig:sim_world_OOD_rank_correlations_reaching_no_reg}
\end{figure}
\setlength{\belowcaptionskip}{0pt}
\textbf{Correlations with generalization scores.}
Here we analyze the link between generalization in RL and the generalization scores (GS) discussed in \cref{sec:background}, which measure the generalization of downstream FoV predictors \textit{out of distribution}, as opposed to the MLP and GBT metrics considered above. For both OOD scenarios, the distribution shifts underlying these GS scores are the same as the ones in the RL tasks in simulation.
We summarize our findings in \cref{fig:sim_world_OOD_rank_correlations_reaching_no_reg} (right) on the \textit{object reaching} task.
Reward in the OOD1 setting is significantly correlated with the GS-OOD1 metric of the pretrained representation.
We observe an even stronger correlation between the reward in the simulated OOD2 setting and the corresponding GS-OOD2-sim and GS-OOD2-real scores. On a per-factor level, we see that the source of the observed correlations primarily stems from the generalization scores w.r.t.\,the pose parameters of the cube.
The OOD generalization metrics can therefore be used as proxies for the corresponding form of generalization in downstream RL tasks.
This has practical implications for the training of RL downstream policies which are generally known to be brittle to distribution shifts, as we can measure a representation's generalization score from a few labeled images. This allows for selecting representations that yield more robust downstream policies.\looseness=-1
\textbf{Disentangled representations.}
\label{subsubsec:disentanglement_and_RL_reward}
Disentanglement has been shown to be helpful for downstream performance and OOD1 generalization even with MLPs \cite{dittadi2020transfer}. However, in \textit{object reaching}, we only observe a weak correlation with some disentanglement metrics (\cref{fig:disentanglement_and generalization_reaching}). In agreement with \cite{dittadi2020transfer}, disentanglement does not correlate with OOD2 generalization.
The same study observed that disentanglement correlates with the informativeness of a representation. To understand if these weak correlations originate from this common confounder, we investigate whether they persist after adjusting for MLP FoV prediction accuracy. Given two representations with similar MLP accuracy, does the more disentangled one exhibit better OOD1 generalization? To measure this we predict success from the MLP accuracy using kNN (k=5) \cite{locatello2019fairness} and compute the residual reward by subtracting the amount of reward explained by the MLP metric. \cref{fig:disentanglement_and generalization_reaching} shows that this resolves the remaining correlations with disentanglement. Thus, for the RL downstream tasks considered here, disentanglement per se does not seem to be useful for OOD generalization.
We present similar results on \textit{pushing} in \cref{app:additional_results_ood_simulation}.
\begin{figure}
\centering
\begin{minipage}{0.22\linewidth}
\includegraphics[width=\linewidth]{figures/fig5_graph.png}
\includegraphics[width=\linewidth]{figures/fig5_corr_reach.png}
\end{minipage}
\hfill
\begin{minipage}{0.7\linewidth}
\includegraphics[width=\linewidth]{figures/fig5_box_success_reg.png}
\end{minipage}
\vspace{-3mm}
\caption{\small \textbf{Box plots}: fractional success on \textit{object reaching} split according to low (blue), medium-high (orange), and almost perfect (green) disentanglement.
L1 regularization in the first layer of the MLP policy has a positive effect on OOD1 and OOD2 generalization with minimal sacrifice in terms of training reward (see scale).
\textbf{Correlation matrix} (left): although we observe a mild correlation between some disentanglement metrics and OOD1 (but not OOD2) generalization, this does not hold when adjusting for representation informativeness.
Correlations are color-coded as described in \cref{fig:results_on_training_env}. We use disentanglement metrics from \citet{eastwood2018framework, chen2018isolating, kumar2017variational, ridgeway2018learning}.}
\label{fig:disentanglement_and generalization_reaching}
\end{figure}
\textbf{Policy regularization and observation noise.}
It might seem unsurprising that disentanglement is not useful for generalization in RL, as MLP policies do not have any explicit inductive bias to exploit it. Thus, we attempt to introduce such inductive bias by repeating all experiments with L1 regularization on the first layer of the policy. Although regularization improves OOD1 and OOD2 generalization in general (see box plots in \cref{fig:disentanglement_and generalization_reaching}), we observe no clear link with disentanglement. Furthermore, in accordance with \citet{dittadi2020transfer}, we find that observation noise when training representations is beneficial for OOD2 generalization. See \cref{app:additional_results_ood_simulation} for a detailed discussion.
\textbf{Stronger OOD shifts: evaluating on a novel shape.}
On \textit{object reaching}, we also test generalization w.r.t. a novel shape by replacing the cube with a sphere. This corresponds to a strong OOD2-type shift, since shape was never varied when training the representations.
Surprisingly, the policies appear to be robust to the novel shape. In fact, when the sphere has the same colors that the cube had during policy training, \emph{all} policies get closer than 5 cm to the sphere on average, with a mean success metric of 95\%. On sphere colors from the OOD1 split, more than 98.5\% move the finger closer than this threshold, and on the strongest distribution shift (OOD2-sim colors, and cube replaced by sphere) almost 70\% surpass that threshold with an average success metric above 80\%.
\textbf{Summary.}
(1) In- and out-of-distribution rewards are correlated, as long as the representation remains in its training distribution (OOD1). (2) Similarly, in-distribution representation metrics (both unsupervised and supervised) predict OOD1 reward, but are not reliable when the representation is OOD (OOD2). (3) Disentanglement does not correlate with generalization in our experiments, while (4) input noise when training representations is beneficial for OOD2 generalization. (5) Most notably, the {GS metrics}, which measure generalization under distribution shifts, are {significantly correlated} with RL performance under similar distribution shifts. We thus recommend using these convenient proxy metrics for selecting representations that will yield robust downstream policies.
\subsection{Deploying policies to the real world}
\label{subsec:results_ood_generalization_real_robot}
We now evaluate a large subset of the agents on the real robot without fine-tuning, quantify their zero-shot sim-to-real generalization, and find metrics that correlate with real-world performance.
\setlength{\belowcaptionskip}{-10pt}
\begin{figure}
\centering
\includegraphics[width=0.38\linewidth]{figures/fig6_rank_correlation_mean.png}
\quad
\includegraphics[width=0.22\linewidth]{figures/fig6_violin_success_noise.png}
\quad
\includegraphics[width=0.26\linewidth]{figures/fig6_distrib_success.png}
\caption{\small \textbf{Zero-shot sim-to-real} on \textit{object reaching} on over 2,000 episodes. \textbf{Left:} Rank-correlations on the real platform with a red cube (color-coded as described in \cref{fig:results_on_training_env}). \textbf{Middle}: Training encoders with additive noise improves sim-to-real generalization. \textbf{Right}: Histogram of fractional success in the more challenging OOD2-real-\{green,blue\} scenario from 50 policies across 4 different goal positions.}
\label{fig:OOD2_evaluations_reaching}
\end{figure}
\setlength{\belowcaptionskip}{0pt}
\textbf{Reaching.}
We choose 960 policies trained in simulation, based on 96 representations and 10 random seeds, and evaluate them on two (randomly chosen, but far apart) goal positions using a red cube.
While a red cube was in the training distribution, we consider this to be OOD2 because real-world images represent a strong distribution shift for the encoder~\cite{dittadi2020transfer, djolonga2020robustness}.
Although sim-to-real in robotics is considered to be very challenging without domain randomization or fine-tuning \cite{tobin2017domain,finn2017generalizing,rusu2017sim}, many of our policies obtain a high fractional success without resorting to these methods.
In addition, in \cref{fig:OOD2_evaluations_reaching} (left) we observe significant correlations between zero-shot real-world performance and some of the previously discussed metrics.
First, there is a positive correlation with the OOD2-sim reward: Policies that generalize to unseen cube colors in simulation also generalize to the real world.
Second, repre\-sen\-tations with high GS-OOD2-sim and (especially) GS-OOD2-real scores are promising candidates for sim-to-real transfer.
Third, if no labels are available, the weaker correlation with the reconstruction loss on the simulated images can be exploited for representation selection. Finally, as observed by \citet{dittadi2020transfer}
\begin{wrapfigure}[14]{r}{7cm}
\vspace{-4pt}
\includegraphics[width=\linewidth]{figures/real_world_pushing_frames.png}
\vspace*{-1mm}
\caption{\small We select pushing policies with high GS-OOD2-real score. When deployed on the real robot without fine-tuning, they succeed in pushing the cube to a specified goal position (transparent blue cube).
\label{fig:pushing_real_robot_frames}
}
\end{wrapfigure}
for simple downstream tasks, input noise while learning representations is beneficial for sim-to-real generalization (\cref{fig:OOD2_evaluations_reaching}, middle).
Based on these findings, we select 50 policies with a high GS-OOD2-real score, and evaluate them on the real world with a green and a blue cube, which is an even stronger OOD2 distribution shift.
In \cref{fig:OOD2_evaluations_reaching} (right), where metrics are averaged over 4 cube positions per policy, we observe that most policies can still solve the task: approximately 80\% of them position the finger less than 5 cm from the cube.
Lastly, we repeat the evaluations on the green sphere that we previously performed in simulation, and observe that many policies successfully reach this completely novel object.
See \cref{app:additional_results_ood_real_world} and the project website for additional results and videos of deployed policies.
\textbf{Pushing.}
We now test whether our real-world findings on \textit{object reaching} also hold for \textit{pushing}. We again select policies with a high GS-OOD2-real score and encoders trained with input noise. We record episodes on diverse goal positions and cube colors to support our finding that pushing policies in simulation can generalize to the real robot. In \cref{fig:pushing_real_robot_frames}, we show three representative episodes with successful task completions and refer to the project site for video recordings and further episodes.
\textbf{Summary.}
Policies trained in simulation can solve the task on the real robot without domain randomization or fine-tuning. Reconstruction loss, encoder robustness, and OOD2 reward in simulation are all good predictors of real-world performance. For real-world applications, we recommend using GS-OOD2-sim or GS-OOD2-real for model selection, and training the encoder with noise.
\section{Other related work}
A key unsolved challenge in RL is the brittleness of agents to distribution shifts in the environment, even if the underlying structure is largely unchanged~\cite{cobbe2019quantifying,ahmed2020causalworld}.
This is related to studies on representation learning and generalization in downstream tasks \citep{gondal2019transfer,steenbrugge2018improving,dittadi2021generalization,esmaeili2019structured,chaabouni2020compositionality}, as well as domain generalization (see \citet{wang2021generalizing} for an overview).
More specifically for RL, \citet{higgins2017darla} focus on domain adaptation and zero-shot transfer in DeepMind Lab and MuJoCo environments, and claim disentanglement improves robustness. To obtain better transfer capabilities, \citet{asadi2020learning} argue for discretizing the state space in continuous control domains by clustering states where the optimal policy is similar.
\citet{kulkarni2015deep} propose geometric object representations by means of keypoints or image-space coordinates and \citet{wulfmeier2021representation} investigate the effect of different representations on the learning and exploration of different robotics tasks.
Transfer becomes especially challenging from the simulation to the real world, a phenomenon often referred to as the sim-to-real gap. This is particularly crucial in RL, as real-world training is expensive, requires sample-efficient methods, and is sometimes unfeasible if the reward structure requires accurate ground truth labels \cite{dulac2019challenges, kormushev2013reinforcement}.
This issue is typically tackled with large-scale domain randomization in simulation \cite{akkaya2019solving, james2019sim}.\looseness=-1
\section{Conclusion}
Robust out-of-distribution (OOD) generalization is still one of the key open challenges in machine learning.
We attempted to answer central questions on the generalization of reinforcement learning agents in a robotics context, and how this is affected by pretrained representations.
We presented a large-scale empirical study in which we trained over 10,000 downstream agents given pretrained representations, and extensively tested them under a variety of distribution shifts, including sim-to-real.
We observed agents that generalize OOD, and found that some properties of the pretrained representations can be useful to predict which agents will generalize better.
We believe this work brings us one step closer to understanding the generalization abilities of learning systems, and we hope that it encourages many further important studies in this direction.
\section*{Ethics statement} Our study is based on synthetic and real data of a robotic setup where a robotic finger interacts with a cube. Our study does therefore not involve any human subjects leading to discrimination, bias or fairness concerns, or privacy and security issues.
Representation learning and generalization is important across many disciplines and applications and could have harmful consequences without humans in the loop in safety-relevant settings. Having a sound understanding of the robustness of a given ML system based on such pretrained representations to distributions shifts is crucial to avoid harmful consequences in potential future high-stake applications to society, such as human-robot interaction (e.g. robotic surgery), autonomous driving, healthcare applications or other fairness-related settings. Here, we investigate a narrow aspect of this, that is, learning arguably harmless manipulation skills like reaching or pushing an object with a simple robotic finger. Our conclusions for OOD generalization are based on this setting and thus cannot be directly transferred to any given application setting of concern.
\section*{Reproducibility statement} To make sure our experiments are fully reproducible, we provided a full account of all required setup and implementation details in \cref{sec:study_design} and \cref{app:implementation_details}.
\section*{Acknowledgements}
We would like to thank Anirudh Goyal, Georg Martius, Nasim Rahaman, Vaibhav Agrawal, Max Horn, and the Causality group at the MPI for useful discussions and feedback. We thank the International Max Planck Research School for Intelligent Systems (IMPRS-IS) for supporting FT. Part of the experiments were generously supported with compute credits by Amazon Web Services.
\bibliographystyle{iclr2022_conference}
| {'timestamp': '2022-04-19T02:18:29', 'yymm': '2107', 'arxiv_id': '2107.05686', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05686'} | arxiv |
\section{Introduction}
Generative Adversarial Networks (GANs) have delivered tremendous success in learning to generate samples from high-dimensional distributions \citep{goodfellow2014generative, cao2018recent, jabbar2021survey}. In the GAN framework, two models are trained simultaneously: a generator \(G\) which attempts to generate data from the desired distribution, and a discriminator \(D\) which learns to distinguish between {\it real} data samples and the {\it fake} samples generated by generator. This problem is typically posed as a zero-sum game for which the generator and discriminator compete to optimize objective \(f\)
\begin{equation*}
p^* = \min_{G} \max_{D} f(G, D).
\end{equation*}
The ultimate goal of the GAN training problem is thus to find a saddle point (also called a Nash equilibrium) of the above optimization problem over various classes of $(G,D)$. By allowing the generator and discriminator to be represented by neural networks, great advances have been made in generative modeling and signal/image reconstruction \citep{isola2017image, karras2019style, radford2015unsupervised, wang2018esrgan,yang2017dagan}. However, GANs are notoriously difficult to train, for which a variety of solutions have been proposed; see e.g., \citep{nowozin2016f, mescheder2018training, metz2016unrolled, gulrajani2017improved}.
One such approach pertains to leveraging Wasserstein GANs (WGANs) \citep{arjovsky2017wasserstein}, which utilize the Wasserstein distance with the $\ell_1$ metric to motivate a particular objective \(f\). In particular, assuming that true data is drawn from distribution \(p_x\), and the input to the generator is drawn from distribution \(p_z\), we represent the generator and discriminator with parameters \(\theta_g\) and \(\theta_d\) respectively, to obtain the WGAN objective
\begin{equation}\label{eq:wgan_most_general}
p^* = \min_{\theta_g} \max_{\theta_d} \mathbb{E}_{\vec{x} \sim p_x}[D_{\theta_d}(\vec{x})] - \mathbb{E}_{\vec{z} \sim p_z}[D_{\theta_d}(G_{\theta_g}(\vec{z}))].
\end{equation}
When \(G\) and \(D\) are neural networks, neither the inner max, nor, the outer min problems are convex, which implies that min and max are not necessarily interchangeable. As a result, first, there is no guarantees if the saddle points exists. Second, it is unclear to what extent heuristic methods such as Gradient Descent-Ascent (GDA) for solving WGANs can approach saddle points. This lack of transparency about the loss landscape of WGANs and their convergence is of paramount importance for their utility in sensitive domains such as medical imaging. For instance, WGANs are commonly used for magnetic resonance image (MRI) reconstruction \citep{mardani2018deep, han2018gan}, where they can potentially hallucinate pixels and alter diagnostic decisions. Despite their prevalent utilization, GANs are not well understood.
To shed light on explaining WGANs, in this work, we analyze WGANs with two-layer neural network discriminators through the lens of convex duality and affirm that many such WGANs provably have optimal solutions which can be found with convex optimization, or can be equivalently expressed as convex-concave games, which are well studied in the literature \citep{vzakovic2003semi, vzakovic2000interior, tsoukalas2009global, tsaknakis2021minimax}. We further provide interpretation into the effect of various activation functions of the discriminator on the conditions imposed on generated data, and provide convex formulations for a variety of generator-discriminator combinations (see Table \ref{tab:results_summary}). We further note that such shallow neural network architectures can be trained in a greedy fashion to build deeper GANs which achieve state-of-the art for image generation tasks \citep{karras2017progressive}. Thus, our analysis can be extended deep GANs as they are used in practice, and motivates further work into new convex optimization-based algorithms for more stable training.
\begin{table}
\caption{\small Convex landscape and interpretation of WGAN with two-layer discriminator under different discriminator activation functions and generator architectures. Note that adding a linear skip connection to the discriminator imposes an additional mean matching constraint when using quadratic activation. }
\centering
\renewcommand\tabcolsep{6pt}
\vspace{2mm}
\centering
\resizebox{1\columnwidth}{!}{
\begin{tabular}[b]{|c|ccc|
\hline
\backslashbox{\textbf{Generator}}{\textbf{Discriminator}} & {\textbf{Linear Activation} } & {\textbf{Quadratic Activation}} & {\textbf{ReLU Activation}} \\
\hline
\hline
\textbf{{Linear}} & convex & convex, closed form & convex-concave \\
\textbf{{2-layer (polynomial)}} & convex & convex, closed form & convex-concave \\
\textbf{{2-layer (ReLU)}} & convex & convex & convex-concave \\
\hline
\hline
\textbf{Interpretation} & mean matching & covariance matching & piecewise mean matching \\
\hline
\end{tabular}
}
\label{tab:results_summary}
\end{table}
\noindent\textbf{Contributions. }All in all, the main contributions of this paper are summarized as follows:
\begin{itemize} [leftmargin=*]
\itemsep0em
\item For the first time, we show that WGAN can provably be expressed as a convex problem (or a convex-concave game) with polynomial-time complexity for two-layer discriminators and two-layer generators under various activation functions (see Table \ref{tab:results_summary}).
\item We uncover the effects of discriminator activation on data generation through moment matching, where quadratic activation matches the covariance, while ReLU activation amounts to piecewise mean matching.
\item For linear generators and quadratic discriminators, we find closed-form solutions for WGAN training as singular value thresholding, which provides interpretability.
\item Our experiments demonstrate the interpretability and effectiveness of progressive convex GAN training for generation of CelebA faces.
\end{itemize}
\subsection{Related Work}
The last few years have witnessed ample research in GAN optimization. While several divergence measures \citep{nowozin2016f, mao2017least} and optimization algorithms \citep{miyato2018spectral, gulrajani2017improved} have been devised, GANs have not been well interpreted and the existence of saddle points is still under question. In one of the early attempts to interpret GANs, \citep{feizi2020understanding} shows that for linear generators with Gaussian latent code and the \(2\)nd order Wasserstein distance objective, GANs coincide with PCA. Others have modified the GAN objective to implicitly enforce matching infinite-order of moments of the ground truth distribution \citep{li2017mmd, genevay2018learning}. Further explorations have yielded specialized generators with layer-wise subspaces, which automatically discover latent ``eigen-dimensions" of the data \citep{he2021eigengan}. Others have proposed explicit mean and covariance matching GAN objectives for stable training \citep{mroueh2017mcgan}.
Regarding convergence of Wasserstein GANs, under the fairly simplistic scenario of {\it linear} discriminator and a two-layer ReLU-activation generator with sufficiently large width, saddle points exist and are achieved by GDA \citep{balaji2021understanding}. Indeed, linear discriminators are not realistic as then simply match the mean of distributions. Moreover, the over-parameterization is of high-order polynomial compared with the ambient dimension. For more realistic discriminators, \citep{farnia2020gans} identifies that GANs may not converge to saddle points, and for linear generators with Gaussian latent code, and continuous discriminators, certain GANs provably lack saddle points (e.g., WGANs with scalar data and Lipschitz discriminators). The findings of \citep{farnia2020gans} raises serious doubt about the existence of optimal solutions for GANs, though finite parameter discriminators as of neural networks are not directly addressed.
Convexity has been seldomly exploited for GANs aside from \citep{farnia2018convex}, which studies convex duality of divergence measures, where the insights motivate regularizing the discriminator's Lipschitz constant for improved GAN performance. For supervised two-layer networks, a recent of line of work has established zero-duality gap and thus equivalent convex networks with ReLU activation that can be solved in polynomial time for global optimality \citep{pilanci2020neural, sahiner2020vector, ergen2021implicit, sahiner2020convex, bartan2021neural, ergen2022demystifying}. These works focus on single-player networks for supervised learning. However, extending those works to the two-player GAN scenario for unsupervised learning is a significantly harder problem, and demands a unique treatment, which is the subject of this paper.
\subsection{Preliminaries} \label{sec:prelim}
Throughout the paper, we denote matrices and vectors as uppercase and lowercase bold letters, respectively. We use $\vec{0}$ (or $\vec{1}$) to denote a vector and matrix of zeros (or ones), where the sizes are appropriately chosen depending on the context. We also use $\vec{I}_n$ to denote the identity matrix of size $n$. For matrices, we represent the spectral, Frobenius, and nuclear norms as $\|\cdot \|_2$, $\|\cdot \|_{F}$, and $\|\cdot\|_*$, respectively. Lastly, we denote the element-wise 0-1 valued indicator function and ReLU activation as $\mathbbm{1}[x\geq0]$ and $\relu{x}=\max\{x,0\}$, respectively.
In this paper, we consider the WGAN training problem as expressed in \eqref{eq:wgan_most_general}. We consider the case of a finite real training dataset \(\vec{X} \in \mathbb{R}^{n_r \times d_r}\) which represents the ground truth data from the distribution we would like to generate data. We also consider using finite noise \(\vec{Z} \in \mathbb{R}^{n_f \times d_f}\) as the input to the generator as fake training inputs. The generator is given as some function \(G_{\theta_g}: \mathbb{R}^{d_f} \rightarrow \mathbb{R}^{d_r}\) which maps noise from the latent space to attempt to generate realistic samples using parameters \(\theta_g\), while the discriminator is given by \(D_{\theta_d}: \mathbb{R}^{d_r} \rightarrow \mathbb{R}\) which assigns values depending on how realistically a particular input models the desired distribution, using parameters \(\theta_d\). Then, the primary objective of the WGAN training procedure is given as
\begin{equation}\label{eq:wgan_finite}
p^* = \min_{\theta_g} \max_{\theta_d} \vec{1}^\top D_{\theta_d}(\vec{X}) - \vec{1}^\top D_{\theta_d}(G_{\theta_g}(\vec{Z})) + \mathcal{R}_g(\theta_g) - \mathcal{R}_d(\theta_d),
\end{equation}
where \(\mathcal{R}_g\) and \(\mathcal{R}_d\) are regularizers for generator and discriminator, respectively. We will analyze realizations of discriminators and generators for the saddle point problem via convex duality. One such architecture is that of the two-layer network with \(m_d\) neurons and activation \(\sigma\), given by
\begin{equation*}
D_{\theta_d}(\vec{X}) = \sum_{j=1}^{m_d} \sigma(\vec{X}\vec{u}_j) v_j \footnote{In the case of networks with bias, one can write \(D_{\theta_d}(\vec{X}) = \sum_{j=1}^m \sigma(\vec{X}\vec{u}_j + \vec{1}b_j) v_j\).}.
\end{equation*}
Two activation functions that we will analyze in this work include polynomial activation \(\sigma(t) = at^2 + bt + c\) (of which quadratic and linear activations are special cases where \((a, b,c)= (1, 0, 0)\) and \((a, b,c)= (0, 1, 0)\) respectively), and ReLU activation \(\sigma(t) = (t)_+\). As a crucial part of our convex analysis, we first need to obtain a convex representation for the ReLU activation. Therefore, we introduce the notion of hyperplane arrangements similar to \citep{pilanci2020neural}.
\noindent\textbf{Hyperplane arrangements}.~We define the set of hyperplane arrangements as \(\mathcal{H}_{x} := \{\text{diag}(\mathbbm{1}[\vec{X}\vec{u} \geq 0]): \vec{u} \in \mathbb{R}^{d_r} \}\), where each diagonal matrix \(\vec{H}_{x} \in \mathcal{H}_{x}\) encodes whether the ReLU activation is active for each data point for a particular hidden layer weight \(\vec{u}\). Therefore, for a neuron \(\vec{u}\), the output of the ReLU activation can be expressed as \(\relu{\vec{X} \vec{u}}=\vec{H}_{x}\vec{X}\vec{u}\), with the additional constraint that \(\left(2\vec{H}_{x}-\vec{I}_{n_r}\right)\vec{X} \vec{u} \geq 0\). Further, the set of hyperplane arrangements is finite, i.e. \(|\mathcal{H}_{x}| \le \mathcal{O}(r(n_r/r)^r)\), where $r:=\mbox{rank}(\vec{X})\leq \min(n_r,d_r)$ \citep{stanley2004introduction, ojha2000enumeration}. Thus, we can enumerate all possible hyperplane arrangements and denote them as \(\mathcal{H}_{x} = \{\vec{H}_{x}^{(i)}\}_{i=1}^{|\mathcal{H}_{x}|}\). Similarly, one can consider the set of hyperplane arrangements from the generated data as \(\{\vec{H}_g^{(i)}\}_{i=1}^{|\mathcal{H}_{g}|}\), or of the noise inputs to the generator: \(\{\vec{H}_{z}^{(i)}\}_{i=1}^{|\mathcal{H}_{z}|}\). With these notions established, we now present the main results\footnote{All the proofs and some extensions are presented in Appendix.}.
\section{Overview of Main Results}
As a discriminator, we consider a two-layer neural network with appropriate regularization, \(m_d\) neurons, and arbitrary activation function \(\sigma\). We begin with the regularized problem
\begin{equation}\label{eq:wgan_twolayer_disc}
p^* = \min_{\theta_g} \max_{{v_j, \|\vec{u}_j\|_2 \leq 1}} \sum_{j=1}^{m_d} \Big[ \vec{1}^\top\sigma(\vec{X}\vec{u}_j)- \vec{1}^\top \sigma(G_{\theta_g}(\vec{Z})\vec{u}_j) \Big]v_j + \mathcal{R}_g(\theta_g) - \beta_d \sum_{j=1}^{m_d} |v_j|
\end{equation}
with regularization parameter \(\beta_d > 0\). This problem represents choice of \(\mathcal{R}_d\) corresponding to weight-decay regularization in the case of linear or ReLU activation, and cubic regularization in the case of quadratic activation (see Appendix) \citep{neyshabur_reg, pilanci2020neural, bartan2021neural}. Under this model, our main result is to show that with two-layer ReLU-activation generators, the solution to the WGAN problem can be reduced to convex optimization or a convex-concave game.
\begin{theo}\label{theo:relugen}
Consider a two-layer ReLU-activation generator of the form \(G_{\theta_g}(\vec{Z}) = (\vec{Z}\vec{W}_1)_+ \vec{W}_2\) with \(m_g \geq n_f d_r + 1\) neurons, where $\vec{W}_1 \in \mathbb{R}^{d_f \times m_g} $ and $\vec{W}_2 \in \mathbb{R}^{m_g \times d_r}$. Then, for appropriate choice of regularizer \(\mathcal{R}_g = \|G_{\theta_g}(\vec{Z})\|_F^2\), for any two-layer discriminator with linear or quadratic activations, the WGAN problem \eqref{eq:wgan_twolayer_disc} is equivalent to the solution of two successive convex optimization problems, which can be solved in polynomial time in all dimensions for noise inputs \(\vec{Z}\) of a fixed rank. Further, for a two-layer ReLU-activation discriminator, the WGAN problem is equivalent to a convex-concave game with coupled constraints.
\end{theo}
In practice, GANs are often solved with low-dimensional noise inputs \(\vec{Z}\), limiting \(\mathrm{rank}(\vec{Z})\) and enabling polynomial-time trainability. A particular example of the convex formulation of the WGAN problem in the case of a quadratic-activation discriminator can be written as
\begin{align}\label{eq:quad_disc_general}
\vec{G}^* = &\argmin_{\vec{G}} \|\vec{G}\|_F^2
~ \mathrm{ s.t.} ~ \|\vec{X}^\top \vec{X} - \vec{G}^\top \vec{G}\|_2 \leq \beta_d
\end{align}
\begin{align}\label{eq:relu_recovery_general}
\vec{W}_1^*, \vec{W}_2^* = &\argmin_{\vec{W}_1, \vec{W}_2} \|\vec{W}_1\|_F^2 + \|\vec{W}_2\|_F^2 ~ \mathrm{s.t.}~\vec{G}^* = (\vec{Z}\vec{W}_1)_+\vec{W}_2,
\end{align}
where the solution \(\vec{G}^*\) to \eqref{eq:quad_disc_general} can be found in polynomial-time via singular value thresholding, formulated exactly as \(\vec{G}^* = \vec{L}(\vec{\Sigma}^2 - \beta_d\vec{I})_+^{1/2} \vec{V}^\top \) for any orthogonal matrix \(\vec{L}\), where \(\vec{X} = \vec{U}\vec{\Sigma}\vec{V}^\top\) is the SVD of \(\vec{X}\). While \eqref{eq:relu_recovery_general} does not appear convex, it has been shown that its solution is equivalent to a convex program \citep{ergen2020convex, sahiner2020vector}, which for the norm \(\|\vec{S}\|_{\mathrm{K}_i,*}:=\min_{t \geq 0} t \text{ s.t. } \vec{S} \in t\mathrm{conv}\{\vec{Z}=\vec{h}\vec{g}^T : (2\vec{H}_{z}^{(i)}-\vec{I}_{n_f})\vec{Z}\vec{u} \geq 0,\, \|\vec{Z}\|_* \leq 1\}\) is expressed as
\begin{align}\label{eq:relu_recovery_general_convex}
\{\vec{V}_i^*\}_{i=1}^{|\mathcal{H}_z|} = &\argmin_{\vec{V}_i} \sum_{i=1}^{|\mathcal{H}_z|}\|\vec{V}_i\|_{\mathrm{K}_i, *} ~ \mathrm{s.t.}~\vec{G}^* =\sum_{i=1}^{|\mathcal{H}_z|} \vec{H}_z^{(i)}\vec{Z} \vec{V}_i,
\end{align}
The optimal solution to \eqref{eq:relu_recovery_general_convex} can be found in polynomial-time in all problem dimensions when \(\vec{Z}\) is fixed-rank, and can construct the optimal generator weights \(\vec{W}_1^*, \vec{W}_2^* \) (see Appendix \ref{sec:convex_generator_general}). This WGAN problem can thus be solved in two steps: first, it solves for the optimal generator output; and second, it parameterizes the generator with ReLU weights to achieve the desired generator output. In the case of ReLU generators and ReLU discriminators, we find equivalence to a convex-concave game with coupled constraints, which we discuss further in the Appendix \citep{vzakovic2003semi}. For certain simple cases, this setting still reduces to convex optimization.
\begin{theo} \label{theo:relu_1d_relugen}
In the case of 1-dimensional (\(d_r = 1\)) data $\{x_i\}_{i=1}^n $ where \(n_r = n_f = n\), a two-layer ReLU-activation generator, and a two-layer ReLU-activation discriminator with bias, with arbitrary choice of convex regularizer \(\mathcal{R}_g(\vec{w})\), the WGAN problem can be solved by first solving the following convex optimization problem
\begin{align}\label{eq:1d_reludisc_relugen}
\vec{w}^*=&\argmin_{\vec{w} \in \mathbb{R}^n} \mathcal{R}_{g}(\vec{w}) \text{ s.t. }
\left \vert \sum_{i =j}^{2n}s_i (\tilde{x}_i-\tilde{x}_j)\right\vert\leq \beta_d,\;\left \vert \sum_{i =1}^{j}s_i (\tilde{x}_j-\tilde{x}_i)\right\vert\leq \beta_d, \forall j \in [2n]
\end{align}
and then the parameters of the two-layer ReLU-activation generator can be found via
\begin{equation*}
\{(\vec{u}_i^*, \vec{v}_i^*)\}_{i=1}^{|\mathcal{H}_z|} = \argmin_{\substack{\vec{u}_i, \vec{v}_i \in \mathcal{C}_i}} \sum_{i=1}^{|\mathcal{H}_z|} \|\vec{u}_i\|_2 + \|\vec{v}_i\|_2 ~ \mathrm{s.t.}~\vec{w}^* =\sum_{i=1}^{|\mathcal{H}_z|} \vec{H}_z^{(i)}\vec{Z}(\vec{u}_i -\vec{v}_i),
\end{equation*}
where
\begin{align*}
\tilde{x}_{i}=\begin{cases} x_{\lfloor \frac{i+1}{2}\rfloor}, &\text{ if $i$ is odd }\\
w_{\frac{i}{2}}, &\text{ if $i$ is even }
\end{cases},\;
s_{i}=\begin{cases} +1, \text{ if $i$ is odd }\\
-1, \text{ if $i$ is even }
\end{cases},\; \forall i \in [2n]
\end{align*}
for convex sets \(\mathcal{C}_i\), given that the generator has \(m_g \geq n+1\) neurons and $\beta_d \leq \min_{i,j \in [n]: i\neq j}\vert x_i-x_j \vert$.
\end{theo}
This demonstrates that even the highly non-convex and non-concave WGAN problem with ReLU-activation networks can be solved using convex optimization in polynomial time when \(\vec{Z}\) is fixed-rank.
In the sequel, we provide further intuition about the forms of the convex optimization problems found above, and extend the results to various combinations of discriminators and generators. In the cases that the WGAN problem is equivalent to a convex problem, if the constraints of the convex problem are strictly feasible, the Slater's condition implies Lagrangian of the convex problem provably has a saddle point. We thus confirm the existence of equivalent saddle point problems for many WGANs.
\section{Two-Layer Discriminator Duality}
Below, we provide novel interpretations into two-layer discriminator networks through convex duality.
\begin{lem} \label{lem:disc_dual}
The two-layer WGAN problem \eqref{eq:wgan_twolayer_disc} is equivalent to the following optimization problem
\begin{align}\label{eq:wgan_twolayer_dual_generic}
p^* = &\min_{\theta_g} \mathcal{R}_g(\theta_g) ~
\mathrm{s.t.} \max_{\|\vec{u}\|_2 \leq 1} |\vec{1}^\top\sigma(\vec{X}\vec{u})- \vec{1}^\top \sigma(G_{\theta_g}(\vec{Z})\vec{u})| \leq \beta_d.
\end{align}
\end{lem}
One can enumerate the implications of this result for different discriminator activation functions.
\subsection{Linear-activation Discriminators Match Means}
In the case of linear-activation discriminators, the expression in \eqref{eq:wgan_twolayer_dual_generic} can be greatly simplified.
\begin{cor} \label{cor:linear_dual}
The two-layer WGAN problem \eqref{eq:wgan_twolayer_disc} with linear activation function \(\sigma(t) = t\) is equivalent to the following optimization problem
\begin{align}\label{eq:wgan_twolayer_dual_linear}
p^* = &\min_{\theta_g} \mathcal{R}_g(\theta_g) ~
\mathrm{s.t.} ~\|\vec{1}^\top\vec{X}- \vec{1}^\top G_{\theta_g}(\vec{Z})\|_2 \leq \beta_d.
\end{align}
\end{cor}
Linear-activation discriminators seek to merely match the means of the generated data \(G_{\theta_g}(\vec{Z})\) and the true data \(\vec{X}\), where parameter \(\beta_d\) controls how strictly the two must match. However, the exact form of the generated data depends on the parameterization of the generator and the regularization.
\subsection{Quadratic-activation Discriminators Match Covariances}
For a quadratic-activation network, we have the following simplification.
\begin{cor} \label{cor:quad_dual}
The two-layer WGAN problem \eqref{eq:wgan_twolayer_disc} with quadratic activation function \(\sigma(t) = t^2\) is equivalent to the following optimization problem
\begin{align}\label{eq:wgan_twolayer_dual_quad}
p^* = &\min_{\theta_g} \mathcal{R}_g(\theta_g) ~
\mathrm{s.t.} ~\|\vec{X}^\top \vec{X} - G_{\theta_g}(\vec{Z})^\top G_{\theta_g}(\vec{Z})\|_2 \leq \beta_d.
\end{align}
\end{cor}
In this case, rather than an Euclidean norm constraint, the quadratic-activation network enforces fidelity to the ground truth distribution with a spectral norm constraint, which effectively matches the empirical covariance matrices of the generated data and the ground truth data. To combine the effect of the mean-matching of linear-activation discriminators and covariance-matching of quadratic-activation discriminators, one can consider a combination of the two.
\begin{cor} \label{cor:quad_skip_dual}
The two-layer WGAN problem \eqref{eq:wgan_twolayer_disc} with quadratic activation function \(\sigma(t) = t^2\) with an additional unregularized linear skip connection is equivalent to the following problem
\begin{align}\label{eq:wgan_twolayer_dual_quad_skip}
p^* = \min_{\theta_g} \mathcal{R}_g(\theta_g) ~\mathrm{s.t.}\quad
\begin{split}
&\|\vec{X}^\top \vec{X} - G_{\theta_g}(\vec{Z})^\top G_{\theta_g}(\vec{Z})\|_2 \leq \beta_d \\
&\vec{1}^\top \vec{X} = \vec{1}^\top G_{\theta_g}(\vec{Z})
\end{split}.
\end{align}
\end{cor}
This network thus forces the empirical means of the generated and true distribution to match exactly, while keeping the empirical covariance matrices sufficiently close. Skip connections therefore provide additional utility in WGANs, even in the two-layer discriminator setting.
\subsection{ReLU-activation Discriminators Match Piecewise Means}
In the case of the ReLU activation function, we have the following scenario.
\begin{cor}\label{cor:relu_dual}
The two-layer WGAN problem \eqref{eq:wgan_twolayer_disc} with ReLU activation function \(\sigma(t) = (t)_+\) is equivalent to the following optimization problem
\begin{align}\label{eq:wgan_twolayer_dual_relu}
p^* = &\min_{\theta_g} \mathcal{R}_g(\theta_g) ~
\mathrm{s.t.}\max_{\substack{\|\vec{u}\|_2 \leq 1 \\ \left(2\vec{H}_{x}^{(j_1)}-\vec{I}_{n_r}\right)\vec{X} \vec{u} \geq 0 \\ \left(2\vec{H}_{g}^{(j_2)}-\vec{I}_{n_f}\right)G_{\theta_g}(\vec{Z}) \vec{u} \geq 0}} \left|\Big(\vec{1}^\top \vec{H}_{x}^{(j_1)} \vec{X}- \vec{1}^\top \vec{H}_{g}^{(j_2)}G_{\theta_g}(\vec{Z})\Big)\vec{u}\right| \leq \beta_d
,~ \forall j_1,j_2 .
\end{align}
\end{cor}
The interpretation of the ReLU-activation discriminator relies on the concept of hyperplane arrangements. In particular, for each possible way of separating the generated and ground truth data with a hyperplane \(\vec{u}\) (which is encoded in the patterns specified by \(\mathcal{H}_{x}\) and \(\mathcal{H}_{g}\)), the discriminator ensures that the means of the selected ground truth data and selected generated data are sufficiently close as determined by \(\beta_d\). Thus, we can characterize the impact of the ReLU-activation discriminator as \emph{piecewise mean matching}. Thus, unlike linear- or quadratic-activation discriminators, two-layer ReLU-activation discriminators can enforce matching of multi-modal distributions.
\section{Generator Parameterization and Convexity}
Beyond understanding the effect of various discriminators on the generated data distribution, we can also precisely characterize the WGAN objective for multiple generator architectures aside from the two-layer ReLU generators discussed in Theorem \ref{theo:relugen}, such as for linear generators.
\begin{theo} \label{theo:lingen}
Consider a linear generator of the form \(G_{\theta_g}(\vec{Z}) = \vec{Z}\vec{W}\). Then, for arbitrary choice of convex regularizer \(\mathcal{R}_g(\vec{W})\), the WGAN problem for two-layer discriminators can be expressed as a convex optimization problem in the case of linear activation, as well as in the case of quadratic activation provided \(\mathrm{rank}(\vec{Z})\) is sufficiently large and \(\mathcal{R}_g = \frac{\beta_g}{2} \|G_{\theta_g}(\vec{Z})\|_F^2\). In the case of a two-layer discriminator with ReLU activation, the WGAN problem with arbitrary choice of convex regularizer \(\mathcal{R}_g(\vec{W})\) is equivalent to a convex-concave game with coupled constraints.
\end{theo}
We can then discuss specific instances of the specific problem at hand. In particular, in the case of a linear-activation discriminator, the WGAN problem with weight decay on both discriminator and generator is equivalent to the following convex program
\begin{align}
p^* = &\min_{\vec{W}} \frac{\beta_g}{2}\|\vec{W}\|_F^2~
\mathrm{s.t.} ~ \|\vec{1}^\top \vec{X} - \vec{1}^\top \vec{Z}\vec{W}\|_2 \leq \beta_d.
\end{align}
In contrast, for a quadratic-activation discriminator with regularized generator outputs,
\begin{align}\label{eq:lingen_quaddisc}
p^* \geq d^*= &\min_{\vec{G}} \frac{\beta_g}{2}\|\vec{G}\|_F^2 ~
\mathrm{s.t.} ~ \|\vec{X}^\top \vec{X} - \vec{G}^\top \vec{G}\|_2 \leq \beta_d,
\end{align}
where \(\vec{G} = \vec{Z}\vec{W}\), with \(p^* = d^*\) under the condition that \(\mathrm{rank}(\vec{Z})\) is sufficiently large. In particular, allowing the SVD of \(\vec{X} = \vec{U}\vec{\Sigma}\vec{V}^\top\), we define \(k = \max_{k: \sigma_k^2 \geq \beta_d} k \), and note that if \(\mathrm{rank}(\vec{Z}) \geq k\), equality holds in (\ref{eq:lingen_quaddisc}) and a closed-form solution for the optimal generator weights exists, given by
\begin{equation}\label{eq:quad_disc_closed_form}
\vec{W}^* = (\vec{Z}^\top \vec{Z})^{-\frac{1}{2}} (\vec{\Sigma}^2 - \beta_d\vec{I})_+^{\frac{1}{2}} \vec{V}^\top.
\end{equation}
Lastly, for arbitrary convex regularizer \(\mathcal{R}_g\), the linear generator, ReLU-activation discriminator problem can be written as the following convex-concave game
{\small
\begin{align}\label{eq:lingen_reludisc}
p^*=&\min_{\substack{ \vec{W} }} \max_{\substack{\vec{r}_{j_1,j_2},\vec{r}_{j_1j_2}^\prime} } \mathcal{R}_g(\vec{W}) -\beta_d\sum_{j_1, j_2}(\|\vec{r}_{j_1 j_2}\|_2+\|\vec{r}_{j_1 j_2}^\prime\|_2) \\ \nonumber
&\hspace{4cm}+\sum_{j_1 ,j_2} \left(\vec{1}^\top \vec{H}_{x}^{(j_1)}\vec{X}- \vec{1}^\top\vec{H}_{g}^{(j_2)} \vec{Z}\vec{W}\right)(\vec{r}_{j_1 j_2}-\vec{r}_{j_1 j_2}^\prime) \\ \nonumber
\mathrm{s.t. }~\begin{split}
&(2\vec{H}_{x}^{(j_1)}-\vec{I}_n) \vec{X} \vec{r}_{j_1 j_2} \geq 0,\, (2\vec{H}_{g}^{(j_2)}-\vec{I}_n)\vec{Z}\vec{W} \vec{r}_{j_1 j_2} \geq 0\\\nonumber
&(2\vec{H}_{x}^{(j_1)}-\vec{I}_n) \vec{X} \vec{r}_{j_1 j_2}^\prime \geq 0,\, (2\vec{H}_{g}^{(j_2)}-\vec{I}_n)\vec{Z} \vec{W}\vec{r}_{j_1 j_2}^\prime \geq 0
\end{split}, \quad \forall j_1 \in [|\mathcal{H}_x|], \forall j_2 \in [|\mathcal{H}_g|],
\end{align}
}
where we see there are bi-linear constraints which depend on both the inner maximization and the outer minimization decision variables. We now move to a more complex form of generator, which is modeled by a two-layer neural network with general polynomial activation function.
\begin{theo}\label{theo:polygen}
Consider a two-layer polynomial-activation generator of the form \(G_{\theta_g}(\vec{Z}) = \sigma(\vec{Z}\vec{W}_1) \vec{W}_2\) for activation function \(\sigma(t) = at^2 + bt + c\) with fixed \(a, b, c \in \mathbb{R}\). Define \(\tilde{\vec{z}}_i = \begin{bmatrix} \mathrm{vec}(\vec{z}_i \vec{z}_i^\top)^\top & b\vec{z}_i^\top & c\end{bmatrix}^\top\) as the lifted noise data points, in which case \(G_{\theta_g}(\vec{Z}) = \tilde{\vec{Z}}\vec{W}\). Then, for arbitrary choice of convex regularizer \(\mathcal{R}_g(\vec{W})\), the WGAN problem for two-layer discriminators can be expressed as a convex optimization problem in the case of linear activation, as well as in the case of quadratic activation provided \(\mathrm{rank}(\tilde{\vec{Z}})\) is sufficiently large and \(\mathcal{R}_g = \|G_{\theta_g}(\vec{Z})\|_F^2\). In the case of a two-layer discriminator with ReLU activation, the WGAN problem with arbitrary choice of convex regularizer \(\mathcal{R}_g(\vec{W})\) is equivalent to a convex-concave game with coupled constraints.
\end{theo}
Under the parameterization of lifted noise features, a two-layer polynomial-activation generator behaves entirely the same as a linear generator. The effect of a polynomial-activation generator is thus to provide more heavy-tailed noise as input to the generator, which provides a higher dimensional input and thus more degrees of freedom to the generator for modeling more complex data distributions.
\section{Numerical Examples}
\subsection{ReLU-activation Discriminators}
\begin{figure*}[bht]
\centering
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[width=\textwidth]{Figures/1d_beta_0.1.pdf}
\caption{$ \beta_d=0.1$}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[width=\textwidth]{Figures/2d_beta_0.1.pdf}
\caption{Generator space}
\end{subfigure} \hfill
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[width=\textwidth]{Figures/1d_beta_1.pdf}
\caption{$ \beta_d=1$}
\end{subfigure} \hfill
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[width=\textwidth]{Figures/2d_beta_1.pdf}
\caption{ Generator space}
\end{subfigure}
\caption{Numerical illustration of Theorem \ref{theo:relu_1d_relugen} for ReLU generator/discriminator with 1D data $\vec{x}=[-1,1]^T$ and $\mathcal{R}_g(\vec{w})=\|\vec{w}\|_2^2$. For $\beta_d=0.1$, we observe that the constraint set of the convex program in \eqref{eq:gen_1d_convex_2samp_final} is a convex polyhedron shown in \textbf{(b)} and the optimal generator output is the vertex $w_1=(-1+\beta_d)$ and $w_2=1-\beta_d$. In contrast, for $\beta_d=1$, the constraint set in \textbf{(d)} is the larger scaled polyhedra and includes the origin. Therefore, the optimal generator output becomes $w_1=w_2=0$, which corresponds to the overlapping points in \textbf{(c)} and demonstrates mode collapse.}\label{fig:relu1d}
\vskip -0.1in
\end{figure*}
We first verify Theorem \ref{theo:relu_1d_relugen} to elucidate the power of the convex formulation of two-layer ReLU discriminators and two-layer ReLU generators in a simple setting. Let us consider a toy dataset with the data samples $\vec{x}=[-1,1]^T$\footnote{See Appendix for derivation, where we also provide an example with the data samples $\vec{x}=[-1,0,1]^T$.}. Then, the convex program can be written as
\begin{align*
&\min_{\vec{w} \in \mathbb{R}^2} \mathcal{R}_{g}(\vec{w}) ~\text{ s.t. }
\left \vert \sum_{i =j}^{4}s_i (\tilde{x}_i-\tilde{x}_j)\right\vert\leq \beta_d,\;\left \vert \sum_{i =1}^{j}s_i (\tilde{x}_j-\tilde{x}_i)\right\vert\leq \beta_d, \forall j \in [4].
\end{align*}
Substituting the data samples, the simplified convex problem becomes
\begin{align}\label{eq:gen_1d_convex_2samp_final}
&\min_{\vec{w} \in \mathbb{R}^2} \mathcal{R}_{g}(\vec{w}) ~\text{ s.t. }
~ \vert w_1+w_2\vert \leq \beta_d,\,\vert w_2-1\vert \leq \beta_d,\,\vert w_1+1\vert \leq \beta_d.
\end{align}
As long as \(\mathcal{R}_g(\vec{w})\) is convex in \(\vec{w}\), this is a convex optimization problem. We can numerically solve this problem with various convex regularization functions, such as \(\mathcal{R}_g(\vec{w}) = \|\vec{w}\|_p^p\) for \(p \geq 1\).
We visualize the results in Figure \ref{fig:relu1d}. Here, we observe that when $\beta_d=0.1$, the constraint set is a convex polyhedron and the optimal generator outputs are at the boundary of the constraint set, i.e., $\smash{w_1=(-1+\beta_d)}$ and $\smash{w_2=1-\beta_d}$. However, selecting $\beta_d=1$ enlarges the constraint set such that the origin becomes a feasible point. Thus, due to having $\smash{\mathcal{R}_g(\vec{w})=\|\vec{w}\|_2^2}$ in the objective, both outputs get the same value $\smash{w_1=w_2=0}$, which demonstrates the mode collapse issue.
\subsection{Progressive Training of Linear Generators and Quadratic Discriminators}
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{Figures/layerwise_diagram_2.png}
\caption{\small A modified architecture for progressive training of convex GANs (ProCoGAN). At each stage \(i\), a linear generator \(\vec{W}_i\) is used to model images at a given resolution \(\vec{X}_i\), attempting to fool quadratic-activation discriminator \(D_i\), for which the optimal solution can be found in closed-form via \eqref{eq:quad_disc_closed_form}. Once stage \(i\) is trained, the input to stage \(i+1\) is given as the output of the previous stage with learned weights \(\vec{W}_i^*\), which is then used to model higher-resolution images \(\vec{X}_{i+1}\). The procedure continues until high-resolution images can be generated from successive application of linear generators. }
\label{fig:layerwise_diagram}
\end{figure}
Here, we demonstrate a proof-of-concept example for the simple covariance-matching performed by a quadratic-activation discriminator for modeling complex data distributions. In particular, we consider the task of generating images from the CelebFaces Attributes Dataset (CelebA) \citep{liu2015faceattributes}, using \emph{only a linear generator and quadratic-activation discriminator}. We compare the generated faces from our convex closed-form solution in \eqref{eq:quad_disc_closed_form} with the ones generated using the original non-convex and non-concave formulation. GDA is used for solving the non-convex problem.
We proceed by progressively training the generators layers. This is typically used for training GANs for high-resolution image generation \citep{karras2017progressive}. The training operates in stages of successively increasing the resolution. In the first stage, we start with the Gaussian latent code \(\vec{Z} \in \mathbb{R}^{n_f \times d_f}\) and locally match the generator weight \(\vec{W}_1\) to produce samples from downsampled distribution of images \(\vec{X}_1\). The second stage then starts with latent code \(\vec{Z}_2\), which is the upsampled version of the network output from the previous stage \(\vec{Z}\vec{W}_1^*\). The generator weight \(\vec{W}_2\) is then trained to match higher resolution \(\vec{X}_2\). The procedure repeats until full-resolution images are obtained. Our approach is illustrated in Figure \ref{fig:layerwise_diagram}. The optimal solution for each stage can be found in closed-form using \eqref{eq:quad_disc_closed_form}; we compare using this closed-form solution, which we call Progressive Convex GAN (ProCoGAN), to training the non-convex counterpart with Progressive GDA.
In practice, the first stage begins with \(4 {\times} 4\) resolution RGB images, i.e. \(\smash{\vec{X}_1 \in \mathbb{R}^{n_r \times 48}}\), and at each successive stage we increase the resolution by a factor of two, until obtaining the final stage of \(64\times 64\) resolution. For ProCoGAN, at each stage \(i\), we use a fixed penalty \(\smash{\beta_d^{(i)}}\) for the discriminator, while GDA is trained with a standard Gradient Penalty \citep{gulrajani2017improved}. At each stage, GDA is trained with a sufficiently wide network with \(\smash{m_d^{(i)}\! =\! (192,192,768,3092,3092)}\) neurons at each stage, with fixed minibatches of size 16 for 15000 iterations per stage. As a final post-processing step to visualize images, because the linear generator does not explicitly enforce pixel values to be feasible, for both ProCoGAN and the baseline, we apply histogram matching between the generated images and the ground truth dataset \citep{shen2007image}. For both ProCoGAN and the baseline trained on GPU, we evaluate the wall-clock time for three runs. \textbf{While ProCoGAN trains for only 153 \(\pm\) 3 seconds, the baseline using Progressive GDA takes 11696 \(\pm\) 81 seconds to train.} ProCoGAN is much faster than the baseline, which demonstrates the power of the equivalent convex formulation.
We also visualize representative freshly generated samples from the generators learned by both approaches in Figure \ref{fig:generated_faces}. We keep \(\smash{(\beta_d^{(1)}, \beta_d^{(2)}, \beta_d^{(3)})}\) fixed, and visualize the result of training two different sets of values of \(\smash{(\beta_d^{(4)}, \beta_d^{(5)})}\) for ProCoGAN. We observe that ProCoGAN can generate reasonably realistic looking and diverse images. The trade off between diversity and image quality can be tweaked with the regularization parameter $\beta_d$. Larger \(\beta_d\) generate images with higher fidelity but with less degree of diversity, and vice versa (see more examples in Appendix \ref{sec:progressive_appendix}). Note that we are using a simple linear generator, which by no means compete with state-of-the-art deep face generation models. The interpretation of singular value thresholding per generator layer however is insightful to control the features playing role in face generation. Further evidence and more quantitative evaluation is provided in Appendix \ref{sec:progressive_appendix}. We note that the progressive closed-form approach of ProCoGAN may also provide benefits in initializing deep non-convex GAN architectures for improved convergence speed, which has precedence in the greedy layerwise learning literature \citep{bengio2007greedy}.
\section{Conclusions}
\begin{figure*}
\centering
\begin{subfigure}{\textwidth}
\includegraphics[width=\columnwidth]{Figures/procoganfaces_2.png}
\caption{\centering \textbf{ProCoGAN (Ours). Top:} \((\beta_d^{(4)}, \beta_d^{(5)}) \!=\! (7.2{\times}10^3, 1.0{\times}10^4)\) \newline \textbf{Bottom:} \((\beta_d^{(4)}, \beta_d^{(5)}) \!=\! (1.9{\times}10^4, 3.3{\times}10^4)\)}
\label{fig:ours_images}
\end{subfigure}%
\hfill
\begin{subfigure}{\textwidth}
\includegraphics[width=\columnwidth]{Figures/nonconvexfaces_beta100_diverse.png}
\caption{\textbf{Progressive GDA (Baseline)}}
\label{fig:baseline_images}
\end{subfigure}
\caption{\small Representative generated faces from ProCoGAN and Progressive GDA with stagewise training of \emph{linear} generators and quadratic-activation discriminators on CelebA (Figure \ref{fig:layerwise_diagram}). ProCoGAN only employs the closed-form expression \eqref{eq:quad_disc_closed_form}, where \(\beta_d\) controls the variation and smoothness in the generated images. } \vspace{-0.4cm}
\label{fig:generated_faces}
\end{figure*}
We studied WGAN training problem under the setting of a two-layer neural network discriminator, and found that for a variety of activation functions and generator parameterizations, the solution can be found via either a convex program or as the solution to a convex-concave game. Our findings indicate that the discriminator activation directly impacts the generator objective, whether it be mean matching, covariance matching, or piecewise mean matching. Furthermore, for the more complicated setting of ReLU activation in both two-layer generators and discriminators, we establish convex equivalents for one-dimensional data. To the best of our knowledge, this is the first work providing theoretically solid convex interpretations for non-trivial WGAN training problems, and even achieving closed-form solutions in certain relevant cases. In the light of our results and existing convex duality analysis for deeper networks, e.g., \cite{ergen2021deep,ergen2021deep2,wang2021parallel}, we conjecture that a similar analysis can also be applied to deeper networks and other GANs.
\section{Acknowledgements}
This work was partially supported by the National Science Foundation under grants ECCS-2037304, DMS-2134248, the Army Research Office, and the National Institutes of Health under grants R01EB009690 and U01EB029427.
\section{Ethics and Reproducibility Statements}
This paper aims to provide a complete theoretical characterization for the training of Wasserstein GANs using convex duality. Therefore, we believe that there aren't any ethical concerns regarding our paper. For the sake of reproducibility, we provide all the experimental details (including preprocessing, hyperparameter optimization, extensive ablation studies, hardware requirements, and all other implementation details) in Appendix \ref{sec:exps} as well as the source (\url{https://github.com/ardasahiner/ProCoGAN}) to reproduce the experiments in the paper. Similarly, all the proofs and explanations regarding our theoretical analysis and additional supplemental analyses can be found in Appendices \ref{sec:additional_theory}, \ref{sec:main_results}, \ref{sec:disc_duality}, and \ref{sec:gen_params}.
| {'timestamp': '2022-03-22T02:03:32', 'yymm': '2107', 'arxiv_id': '2107.05680', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05680'} | arxiv |
\section*{Acknowledgments}
This work was supported in part by National Science Foundation awards CCF-1919197 and CCF-1908504.
We would like to thank anonymous reviewers for their helpful comments and feedback.
We would like to thank Tim Rogers for his feedback during discussions of this work and also providing us AMD GPUs for the experiments. Furthermore, we would like to thank Rodrigo Rocha for sharing the source code for Function Merging.
\section{Artifact Appendix}
\subsection{Abstract}
This artifact contains the source code, python, shell scripts and instructions on how to run the experiments.
This artifact is expected to reproduce the main results in our paper (Figure~\ref{fig:real_benchmark}, \ref{fig:alu_util}, \ref{fig:mem_util}, \ref{fig:profit} and Table~\ref{tab:compile-time}).
Note that the artifact description given below assumes a machine with a {\em Radeon RX Vega 64} GPU with {\em ROCm-4.0.0}. However for the evaluation of our paper we used a newer machine with a {\em Radeon Pro VII} GPU with {\em ROCm-4.2.0}. Unfortunately, this latter machine is not available for remote access, so we provide artifact reviewers remote access to the first machine.
\subsection{Artifact check-list (meta-information)}
{\small
\begin{itemize}
\item {\bf Algorithm: } Branch Fusion~\cite{branch_fusion}, \textsc{darm}\xspace
\item {\bf Program: } HIP and C/C++ code
\item {\bf Compilation: } We use {\em gcc-7.5.0} to compile \textsc{darm}\xspace compiler. We use {\em hipcc-4.0.20496-4f163c68} to compile the benchmark programs.
\item {\bf Binary: } HIP executables
\item {\bf Data set: } Benchmark programs are either taken form Rodinia~\cite{rodinia}, GPGPU-sim~\cite{ispass2009gpgpusim}, CUDA-Samples~\cite{cu_samples}, GPU-quicksort~\cite{gpu_quicksort_cederman} suites or manually implemented.
\item {\bf Run-time environment: } {\em Ubuntu 18.04.5 LTS} with {\em ROCm-4.0.0} installed.
\item {\bf Hardware: } ROCm-compatible GPU. We have tested our approach on AMD {\em Radeon RX Vega 64} and {\em Radeon Pro VII} GPUs.
\item {\bf Output: } Speedups, ALU utilization, memory instruction counters, compilation times across benchmarks written into text files.
\item {\bf Experiment workflow} Download source code and benchmarks, compile the source code, run script to generate the results.
\item {\bf How much disk space required (approximately)?: } approximately 3.5 GB
\item {\bf How much time is needed to prepare workflow (approximately)?: } approximately 2 hours
\item {\bf How much time is needed to complete experiments (approximately)?: } approximately 4 hours
\item {\bf Publicly available?: } Yes
\end{itemize}
\subsection{Description}
\subsubsection{Hardware dependencies}
Our approach requires a GPU that is compatible with {\em ROCm}~\cite{HIPCC} compiler SDK and runtime. We provide artifact reviewers remote access to a machine with an AMD {\em Radeon RX Vega 64} GPU. We expect the reviewer to have a Unix-like environment in order to connect to our remote machine.
To connect to this machine run the following command on an {\em ssh} installed machine. Use the username and password provided by the authors.
\begin{lstlisting}[language=bash, numbers=none]
$ ssh <username>@tgrogers-pc05.ecn.purdue.edu
\end{lstlisting}
\subsubsection{Software dependencies}
Our approach requires {\em ROCm-4.0.0} driver and compiler SDK installed in the target machine. We use {gcc-7.5.0} and {cmake-3.21.4} for compilation of our source code. To generate the results and plots we use {\em Python 3.6.9} with {\em numpy, pandas, scipy, matplotlib} packages installed. Note that we have pre-installed all these software in our machine, so the reviewers are not required to install them again.
\subsubsection{Datasets}
All benchmarks we used are either publicly available or manual reference implementations. For the convenience of the reviewers we provide a repository with all the benchmarks that are ready to use. For benchmark inputs we use randomly generated data (with fixed random seed) with benchmark provided arguments.
\subsection{Source code}
Our source code and benchmarks repositories are hosted in following {\em gitub} repositories.
\url{https://github.com/charitha22/cgo22ae-darm-code.git}
\url{https://github.com/charitha22/cgo22ae-darm-benchmarks.git}
\subsection{Installation}
\noindent
\textbf{Important} : For the subsequent sections including this, please do not copy commands from the PDF. Instead, copy the commands from the README file available at following URL.
\url{https://github.com/charitha22/cgo22ae-darm-benchmarks}
Connect to the remote machine using provide IP address, username and password. Download and build the source code using following set of commands.
\begin{lstlisting}[language=bash, numbers=none]
$ export AE_HOME=$(pwd)
$ git clone https://github.com/charitha22/cgo22ae-darm-code.git
$ cd cgo22ae-darm-code && mkdir build build_install
$ export DARM_HOME=$(pwd)/build
$ . scripts/run_cmake.sh && make -j4
\end{lstlisting}
This compilation process will take approximately 1 hour. Make sure you use the same shell terminal to execute all the commands/scripts to preserve environment variables. Continue to use the same terminal when running evaluation scripts in the next section.
\subsection{Evaluation and expected result}
Download the benchmarks and evaluation scripts using,
\begin{lstlisting}[language=bash, numbers=none]
$ cd ${AE_HOME} && git clone https://github.com/charitha22/cgo22ae-darm-benchmarks.git
$ cd cgo22ae-darm-benchmarks && export BENCH_HOME=$(pwd)
\end{lstlisting}
To generate the speedups plot (Figure~\ref{fig:real_benchmark}) run following commands,
\begin{lstlisting}[language=bash, numbers=none]
$ . scripts/run_speedups.sh
$ . scripts/gen_speedups_plot.sh
\end{lstlisting}
Note that {\em speedups.pdf} is generated based on the current experiment results and {\em speedups\_paper.pdf} is generated from the raw numbers used for our paper.
To generate the ALU utilization plot (Figure~\ref{fig:alu_util}) and memory instruction counters plot (Figure~\ref{fig:mem_util}) use the following commands,
\begin{lstlisting}[language=bash, numbers=none]
$ . scripts/run_alu_memory_numbers.sh
$ . scripts/gen_alu_mem_plot.sh
\end{lstlisting}
{\em alu.pdf} and {\em mem.pdf} are generated based on current experiment results and {\em alu\_paper.pdf} and {\em mem\_paper.pdf} are generated using raw numbers used in the paper.
Following commands can be used to generate the melding profitability threshold plot (Figure~\ref{fig:profit}).
\begin{lstlisting}[language=bash, numbers=none]
$ . scripts/run_profitability_threshold.sh
$ . scripts/gen_profit_plot.sh
\end{lstlisting}
Similar to above, {\em profitability.pdf} is generated based on current experiment results and {\em profitability\_paper.pdf} is generated based on raw numbers.
Run following commands to obtain the compile times of benchmarks (Table~\ref{tab:compile-time}).
\begin{lstlisting}[language=bash, numbers=none]
$ . scripts/run_compile_times.sh
$ . scripts/print_compile_times.sh
\end{lstlisting}
This will print out the compile times for \textsc{darm}\xspace and baseline into the standard output.
You can use {\em scp} from your local machine to download the PDF files to your local machine.
\begin{lstlisting}[language=bash, numbers=none]
$ scp <username>@tgrogers-pc05.ecn.purdue.edu:<location_of_pdf_file> .
\end{lstlisting}
\subsection{Experiment customization and reusability}
\subsubsection{Using our method on a new GPU kernel}
Our compiler can be used on any GPU kernel written in {\em HIP} language. The following commands can be used to compile a GPU kernel with our transformation enabled.
\begin{lstlisting}[language=bash, numbers=none]
$ mkdir -p tmp
$ hipcc -### -O3 <kernel_name>.cpp -o <executable_name> 2>&1 | python3 ${DARM_HOME}/../scripts/gen_compile_command.py --llvm-home=/home/cgusthin/workspace/llvm-project-rocm/build \
--cfmelder-options="" \
--output-loc=./tmp > ./tmp/compile_command.sh
$ . ./tmp/compile_command.sh
\end{lstlisting}
These commands automatically generate and runs a sequence of compilation commands that is instrumented with our transformation pass. To demonstrate above compilation process we provide a synthetic {\em HIP} kernel ({\em gpu\_example.cpp}). To compile and run this kernel use the following command.
\begin{lstlisting}[language=bash, numbers=none]
$ cd ${BENCH_HOME}/customization/gpu_example
$ make && ./gpu_example
\end{lstlisting}
This kernel contains a divergent {\em if-then-else} branch inside a two-nested loop. {\em If} and {\em then} sections of the branch contain {\em if-then} regions with random computations. This control-flow structure provides multiple melding opportunities for our method.
You can visualize how \textsc{darm}\xspace changed the control-flow of the program using the following commands.
\begin{lstlisting}[language=bash, numbers=none]
$ ${DARM_HOME}/bin/opt -dot-cfg < ./tmp/gpu_example*.ll > /dev/null
$ mv .*foo*.dot before.dot
$ ${DARM_HOME}/bin/opt -dot-cfg < ./tmp/after_pass.ll > /dev/null
$ mv .*foo*.dot after.dot
\end{lstlisting}
These commands generate {\em .dot} files {\em before.dot} and {\em after.dot} that contains the control-flow graphs of the program before and after the \textsc{darm}\xspace transformation. You can view the {\em .dot} files using any online graph viewer\footnote{url{https://dreampuf.github.io/GraphvizOnline/}}.
Our compiler provides several options that can be used to customize the experiments.
\begin{itemize}[leftmargin=*]
\item \textbf{--cfmelder-analysis-only} : Only runs the \textsc{darm}\xspace analysis (Section~\ref{sec:design:melding_profitability}) and does not modify the program. Analysis can be used to see what parts of the control-flow graph has profitable melding opportunities.
\item \textbf{--cf-merging-similarity-threshold=$<$threshold$>$} : Adjusts the melding profitability {\em threshold} (Section~\ref{sec:melding_threshold}). {\em threshold} must be a value in the range $[0.0,0.5]$. Setting {\em threshold} to 0.0 will meld any meldable subgraphs (regardless of its profitability), and setting it to 0.5 will only meld subgraphs that are maximally profitable.
\item \textbf{--run-cfmelding-on-function=$<$function\_name$>$} : Runs the \textsc{darm}\xspace transformation on a specific function only.
\item \textbf{--run-cfmelding-once} : Disables applying melding recursively. When this option is enabled transformation terminates after performing only one melding.
\end{itemize}
You modify the \textbf{--cfmelder-options} field in the compilation compilation command above to use any of these options.
For example, following modified command will on meld control-flow subgrpahs only if they are maximally profitable (\textit{i.e.}~ {\em threshold} is 0.5).
\begin{lstlisting}[language=bash, numbers=none]
$ mkdir -p tmp
$ hipcc -### -O3 <kernel_name>.cpp -o <executable_name> 2>&1 | python3 ${DARM_HOME}/../scripts/gen_compile_command.py --llvm-home=/home/cgusthin/workspace/llvm-project-rocm/build \
--cfmelder-options="--cf-merging-similarity-threshold=0.5" \
--output-loc=./tmp > ./tmp/compile_command.sh
$ . ./tmp/compile_command.sh
\end{lstlisting}
You can also update the \textbf{--cfmelder-options} field in the provided {\em Makefile} to achieve the same.
\subsubsection{Using our method on a CPU program}
\textsc{darm}\xspace is implemented a general compiler transformation pass and integrated with {\em LLVM opt}. Therefore it can be used on CPU programs as well. To demonstrate this we provide a synthetic program written in {\em C}. Run compile this program run,
\begin{lstlisting}[language=bash, numbers=none]
$ cd ${BENCH_HOME}/customization/cpu_example
$ make
\end{lstlisting}
This will generate {\em LLVM-IR} files {\em cpu\_example.input.ll} and {\em cpu\_example.output.ll} that contains the program before and after applying \textsc{darm}\xspace transformation. To visualize the control-flow graphs of the two programs run,
\begin{lstlisting}[language=bash, numbers=none]
$ make dot_cfg
\end{lstlisting}
This will create two {\em .dot} files {\em before.dot} and {\em after.dot} that contains the control-flow graph structure of the original and transformed program. You can copy the content of the {\em .dot} files into an online graph visualizer to view them.
Following command will run the original and transformed programs using {\em LLVM-lli} and also prints the output of the two programs to {\em stdout}.
\begin{lstlisting}[language=bash, numbers=none]
$ make test
\end{lstlisting}
You can customize {\em cpu\_example.c} to inspect how \textsc{darm}\xspace transformation works on different contorl-flow graphs. For example, you can comment out lines $11-14$ and $23-27$ to get a program with different control-flow structure and use above commands to transform and run the programs.
\subsection{Notes}
\subsubsection{Performance deviation in NQU benchmark }
We observed that \textsc{darm}\xspace does not improve performance in NQU benchmark in the experimental setting provided to the artifact reviewers.
We attribute this performance deviation to the different {\em LLVM} versions used in {\em rocm-4.0.0} and {\em rocm-4.2.0}.
The input control-flow graphs provided to \textsc{darm}\xspace are different in the two versions and no profitable melding opportunities are available for \textsc{darm}\xspace in the case {\em rocm-4.0.0}. Therefore \textsc{darm}\xspace does not change the program resulting in identical performance to the baseline and branch fusion. However, with {\em rocm-4.2.0} (which we used for the evaluation of paper) \textsc{darm}\xspace does get opportunities for melding and therefore improves the performance. We are unable to change the {\em LLVM} or {\em rocm} version used in the machine because it requires updates to kernel modules and drivers. We provide raw numbers along with scripts to generate the plots used in the paper.
\subsubsection{Limitations of \textsc{darm}\xspace implementation}
Current implementation of \textsc{darm}\xspace requires that any basic block inside a meldable divergent region (Section~\ref{def:meld_div_region}) $R$ is post-dominted by $R$'s exit block. Therefore basic blocks inside $R$ can not contain {\em return} statements. In addition current implementation of \textsc{darm}\xspace does not officially support unstructured control-flow.
{\em single basic blocks, if-then region, if-then-else regions } and {\em structured loops} or any nesting of these structures are allowed inside a meldable divergent region.
\clearpage
\section{Background}
\label{sec:background}
\subsection{GPGPU Architecture}
Modern GPGPUs have multiple processing cores, each of which contains multiple parallel lanes (\textit{i.e.}~ SIMD units), a vector register file and
a chunk of shared memory. The unit of execution is called a warp (or wavefront). A warp is a collection of threads executed in lock-step on
a SIMD unit. Shared memory is shared among the warps executing on a core.
A branch unit takes care of control-flow divergence by maintaining a SIMT stack to enforce IPDOM based reconvergence, as discussed in Section~\ref{sec:intro}.
GPGPU programming abstractions like CUDA~\cite{cuda} or HIP~\cite{HIP} gives the illusion of data parallelism with independent threads.
However, during real execution, a group of program instances (\textit{i.e.}~ threads) are mapped to a warp and executed in lock-step. Therefore control-flow divergence in
SPMD programs is detrimental to the performance because of the SIMT execution limitations.
\subsection{LLVM SSA form and GPU Divergence Analysis}
LLVM~\cite{llvm} is a general framework for building compilers, optimizations and code generators. Most of the widely adopted GPGPU compilers~\cite{nvcc,HIPCC} are built on
top of the LLVM infrastructure.
LLVM uses a target-independent intermediate representation, LLVM-IR, that enables
implementing portable compiler optimizations. LLVM-IR uses static single assignment form~\cite{ssa_form} which requires that every program variable is assigned once and is defined before being used.
SSA form uses $\phi$ nodes to resolve data-flow when branches are present, selecting which definition should be chosen at a confluence of different paths.
In GPGPU compilers, a key step in identifying divergent control-flow regions is performing compiler analyses to identify divergent variables (or branches)~\cite{llvm_div_analysis,branch_fusion}.
A branch is divergent if the branching condition evaluates to a non-uniform value for different threads in a warp.
If the branching condition is divergent,
threads in a warp will have to take different control-flow paths at this point.
LLVM's divergence analysis tags a branch as divergent, if the branching condition is either data-dependent
or sync-dependent on a divergent variable (such as thread ID)~\cite{llvm_div_analysis}, though more sophisticated divergence
analyses have been proposed~\cite{divanalysispopl2021}.
\section{Conclusion}
\label{sec:conclusion}
Divergent control-flow in GPGPU programs causes performance degradation due to serialization.
We presented \textsc{darm}\xspace, a new compiler analysis and transformation framework for GPGPU programs implemented on LLVM, that can detect and meld similar control-flow regions in divergent paths to reduce divergence in control-flow.
\textsc{darm}\xspace generalizes and subsumes prior efforts at reducing divergence such as tail merging and branch fusion.
We showed that \textsc{darm}\xspace improves performance by improving ALU utilization and promoting coalesced shared memory accesses across several real-world benchmarks.
\section{Detailed Design}
\label{sec:design}
In this section we describe the algorithm used by \textsc{darm}\xspace to meld similar control-flow subgraphs.
First we define the following terms used in our
algorithm description.
\subsection{Preliminaries and Definitions}
\begin{definition}
\textbf{Simple Region} : A simple region is a subgraph of a program's CFG that is connected to the remaining CFG with only two edges, an entry edge and an exit edge.
\end{definition}
\begin{definition}
\textbf{Region} : A region of the CFG is characterized by two basic blocks, its entry and exit. All the basic blocks inside a region are dominated by its entry and post-dominated by its exit. Region with entry $E$ and
exit $X$ is denoted by the tuple $(E,X)$. LLVM regions are defined similarly~\cite{llvm_region,structure_tree}.
\end{definition}
\begin{definition}
\label{def:sese_subgraphs}
\textbf{Single Entry Single Exit Subgraph} : Single entry single exit (SESE) subgraph is either a simple region or a single basic block with a single predecessor and
a successor.
\end{definition}
\noindent
Note that a region with entry $E$ and exit $X$ can be transformed into a simple region by introducing a new entry and exit blocks $E_{new}$, $X_{new}$.
All successors of $E$ are moved to $E_{new}$ and $E_{new}$ is made the single successor of $E$. Similarly, all predecessors of $X$ are moved to $X_{new}$ and
a single exit edge is added from $X_{new}$ to $X$.
\begin{definition}
\textbf{Simplified Region} : A region with all its subregions transformed into simple regions is called a simplified region.
\end{definition}
We now turn to the steps the \textsc{darm}\xspace compiler pass takes to reduce control divergent code.
\subsection{Detecting Meldable Divergent Regions}
First \textsc{darm}\xspace needs to detect divergent branches in the CFG.
We use LLVM's built-in divergence analysis to decide if a branch is divergent or not (Section~\ref{sec:background}).
The smallest CFG region enclosing a divergent branch is called the {\em divergent region} corresponding to this branch.
Melding transformation is applied only to divergent regions of the CFG. The next step is to decide if a divergent region contains control-flow subgraphs
(definition~\ref{def:sese_subgraphs})
that can be safely melded.
\begin{definition}
\label{def:meld_div_region}
\textbf{Meldable Divergent Region}: A simplified region $R$ with entry $E$ and exit $X$ is said to be meldable and divergent if the following conditions are met,
\begin{enumerate}[leftmargin=*]
\item The entry block of $R$ has a divergent branch
\item Let $B_T$ and $B_F$ be the successor blocks of $E$. $B_T$ does not post-dominate $B_F$ and $B_F$ does not post-dominate $B_T$
\end{enumerate}
\end{definition}
\noindent
According to definition~\ref{def:meld_div_region}, a {\em meldable divergent region} has a divergent branch at its entry (condition 1). This makes sure that our melding transformation
is only applied to divergent regions, and non-divergent parts of the control-flow are left untouched. Condition 2 ensures
that paths $B_T \rightarrow X$ (\textit{i.e.}~ true path) and $B_F \rightarrow X$ (\textit{i.e.}~ false path) consists of at least one SESE subgraph and these subgraphs from the two paths can potentially be melded to reduce
control-flow divergence. Consider our running example in Figure~\ref{fig:bitonicsort_kernel}. When this kernel is compiled with {\em ROCm HIPCC} GPU compiler
~\cite{HIP} with {\em -O3}
optimization level into LLVM-IR, we get the CFG shown in Figure~\ref{fig:melding_flow_a}. Note that the compiler aggressively unrolls both the loops (lines 4 and 5)
in the kernel, and the resulting CFG consists of multiple repeated segments of the inner loop's body (lines 6-17). In Figure~\ref{fig:melding_flow_a}, only one unrolled
instantiation of the loop body is shown. As explained in Section~\ref{sec:overview}, this kernel contains a divergent branch, which is at the end of basic block $\%B$.
Also $\%B$'s two successors $\%C$ and $\%D$ do not post-dominate each other. Therefore the region $(\%B,\%G)$ is a meldable divergent region.
\subsection{Computing Melding Profitability}
\label{sec:design:melding_profitability}
Definition~\ref{def:meld_div_region} only allows us to detect regions that may contain meldable control-flow subgraphs. It does not tell us whether it is legal to meld them or melding them will improve performance.
First we need to define what conditions needs to be satisfied for two SESE subgraphs to be meldable.
\begin{definition}
\label{def:meldable_sese}
\textbf{Meldable SESE Subgraphs}: SESE subgraphs $S1$ and $S2$ where $S1$ belongs to the true path and $S2$ belongs to the false path are meldable if any
one of the following conditions are satisfied,
\begin{enumerate}[leftmargin=*]
\item Both $S1$ and $S2$ have more than one basic block and they are structurally similar \textit{i.e.}~ isomorphic.
\item $S1$ is a simple region and $S2$ consists of a single basic block or vice versa.
\item Both $S1$ and $S2$ consists of single basic block.
\end{enumerate}
\end{definition}
\begin{figure}[!t]
\centering
\includegraphics[width=0.48\textwidth,height=0.3\textwidth]{figures/sese_melding}
\caption{Examples showing the 3 cases considered by \textsc{darm}\xspace to detect meldable subgraphs}
\label{fig:sese_melding_cases}
\vspace{-1.5em}
\end{figure}
\noindent
Definition~\ref{def:meldable_sese} ensures that any two SESE subgraphs that meets any one of these conditions can be melded without introducing additional divergence
to the control-flow. Note that we do not consider subgraphs that contain {\em warp-level intrinsics}\cite{warp_primitives} for melding because melding such subgraphs
can cause deadlock.
Figure~\ref{fig:sese_melding_cases} shows three examples where each of the above conditions are applicable.
Assume in each example subgraphs $L$ and $M$ are in a divergent region $(E,X)$ and only one of the subgraphs are executed from any program path
from $E$ to $X$. (\textit{i.e.}~ any
thread in warp that executes $E$ must either go through $L$ or $M$ but not both).
\textbf{Region-Region Melding :}
In case \circled{1}, two SESE subgraphs $L$ and $M$
are isomorphic, therefore they can be melded to have the same control-flow structure (subgraph $N$ in Figure~\ref{fig:sese_melding_cases}-\circled{1}).
In the melded subgraph $N$, basic blocks $\%C\_P$ and $\%D\_R$ are
guaranteed to post-dominate $E$ and threads can reconverge at these points resulting in reduction in control-flow divergence. Also the structural similarity in
case \circled{1} ensures that we do not introduce any additional branches into the melded subgraph.
\textbf{Basic block-Region Melding :}
In case \circled{2}, basic block $\%A$ (in subgraph $L$) can potentially be melded with any basic block in CFG $M$. Assume that basic blocks $\%A$ and
$\%E$ have the most melding profitability (melding profitability described later). First we replicate the control-flow structure of $M$ to create a new CFG $L'$. Then
we place $\%A$ in $L'$ such that $\%A$ and $\%E$ are in similar positions in the the two CFGs $L'$ and $M$. We also ensure the correctness of the
program by concretizing the branch conditions in $L'$ to always execute $\%A$ and create $\phi$ nodes at dominance frontiers of $\%A$ to make sure values defined inside $\%A$ are reached to their users~\cite{ssa_form}. In this example branch at end of basic block $\%R1$ will always take the edge $\%R1-\%A$ (bold arrow in subgraph $L'$) and $\phi$ nodes will be added to $\%R2$. Now subgraphs $L'$ and $M$ are isomorphic and therefore can be melded similar to case \circled{1}. We refer to this process as {\em Region Replication}. Main benefit of region replication is that it allows us to
meld $\%A$ with any profitable basic block in subgraph $M$ and resultant subgraph $N$ has less divergence because threads can reconverge at basic blocks $\%R1\_C$ and $\%R2\_D$ in melded subgraph $N$.
\textbf{Basic block-Basic block Melding :}
Case \circled{3} is the simplest form where two SESE basic blocks are melded.
A meldable divergent region can potentially have multiple SESE subgraphs in its true and false paths. Therefore we need a strategy to figure out which subgraph pairs to
meld. We formulate this as a sequence alignment problem as follows. First, we obtain a ordered sequence of subgraphs in true path and false of the divergent region.
Subgraphs are ordered using the post-dominance relation of their entry and exit blocks. For example, if entry node of subgraph $S_2$ post-dominates exit node of
subgraph $S1$, then $S2$ comes after $S1$ in the order and denoted as $S1 \prec S2$.
A subgraph alignment is defined as follows,
\begin{definition}
\label{def:subgraph_align}
\textbf{Subgraph Alignment}: Assume a divergent region $(E,X)$ has ordered SESE subgraphs $\{S_1^T,S_2^T,\dots,S_m^T\}$ in its true path and ordered subgraphs $\{S_1^F,S_2^F,\dots,S_n^F\}$
in the false path. A subgraph alignment is an ordered sequence of tuples $A = \{(S_{i0}^T,S_{j0}^F),(S_{i1}^T,S_{j1}^F),\dots,(S_{ik}^T,S_{jk}^F)\}$ where,
\begin{enumerate}
\item if $(S_{p}^T,S_{q}^F) \in A$ then $S_p^T$ and $S_q^F$ are meldable subgraphs
\item if $(S_{p1}^T,S_{q1}^F) \prec (S_{p2}^T,S_{q2}^F)$ then $S_{p1}^T \prec S_{p2}^T$ and $S_{q1}^T \prec S_{q2}^T$
\end{enumerate}
\end{definition}
\noindent
According to definition~\ref{def:subgraph_align}, only meldable subgraphs are allowed in a alignment tuple and if the aligned subgraphs are melded, the resultant
control-flow graph does not break the original dominance and post-dominance relations of the subgraphs.
Given a suitable alignment scoring function $F$
and gap penalty function $W$, we can find an optimal subgraph alignment using a sequence alignment method such as Smith-Waterman~\cite{smith_waterman} algorithm.
The scoring function $F$ measures the profitability of melding two meldable subgraphs $S1$ and $S2$.
Prior techniques have employed instruction frequency to approximate the profit of merging two functions\cite{rocha19, rocha20}.
We use a similar method to define subgraph melding profitability.
First we define the melding profitability of two basic blocks $b1$ and $b2$ as follows,
{\small $$MP_B(b1,b2) = \frac{\sum_{i \in Q}min(freq(i,b1),freq(i,b2)) \times w_i}{lat(b1)+lat(b2)}$$ }
\noindent
Here $Q$ is set of all possible instruction types available in the instruction set (\textit{i.e.}~ LLVM-IR opcodes). $lat(b)$ is the static latency of
basic block which can be calculated
by summing the latencies of all instructions in $b$. $w_i$ is the latency of instruction type $i$. The idea here is to approximate the percentage of instruction
cycles that can be saved
by melding the instructions in $b1$ and $b2$ assuming a best-case scenario (\textit{i.e.}~ all common instructions in $b1$ and $b2$ are melded regardless of their order). For example, two basic blocks with identical opcode frequency profile will have a profitability value 0.5.
Because meldable subgraphs are isomorphic,
there is a one-to-one mapping between basic blocks (\textit{i.e.}~ corresponding basic blocks).
For example, in Figure~\ref{fig:sese_melding_cases} case \circled{1} the basic block mapping for CFGs $L$ and $M$ are $\{(\%C,\%P),(\%E,\%Q),(\%D,\%R)\}$. Assume the mapping of basic blocks in $S1$ and $S2$ is denoted by $O$.
Subgraph melding profitability $MP_S$ of subgraphs $S1$ and $S2$ is defined in terms of melding profitabilities of their corresponding basic blocks.
{\small $$MP_S(S1, S2) = \frac{\sum_{(b1,b2) \in O} MP_B(b1,b2) \times (lat(b1)+lat(b2))}{\sum_{(b1,b2) \in O} lat(b1)+lat(b2)}$$ }
Similar to $MP_B$, $MP_S$ measures the percentage of instruction cycles saved by melding two SESE subgraphs. This metric is an over-approximation,
however it provides a fast way of measure the melding profitability of two subgraphs that works well in practice.
We use $MP_S$ as the scoring function for subgraph alignment.
\noindent
\textbf{Instruction Alignment}: Notice that our subgraph melding profitability metric (\textit{i.e.}~ $MP_S$) prioritizes subgraph pairs that have many similar instructions in their corresponding
basic blocks. Therefore when melding two corresponding basic blocks we must ensure that maximum number of similar instructions are melded together.
This requires computing an alignment of two instruction sequences such that if they are melded using this alignment, the number of instruction
cycles saved will be maximal.
We use the approach used in Branch Fusion~\cite{branch_fusion} to compute an optimal alignment for two instructions sequences.
In this approach compatible instructions are aligned together and instructions with higher latency are prioritized to be aligned over lower latency instructions. Compatibility of two instructions for melding depends on
a number of conditions like having the same opcode and
types of the operands being compatible. We used the criteria described by Rocha et al.~\cite{rocha20} to determine this compatibility.
This instruction alignment model uses a gap penalty for unaligned instructions because extra branches needs to be generated to
conditionally execute these unaligned instructions.
Our melding algorithm does not depend on the sequence alignment algorithm used for instruction alignment computation.
We use Smith-Waterman algorithm~\cite{smith_waterman} to compute the instruction alignment because prior work~\cite{branch_fusion} has shown its effectiveness.
\begin{figure*}[ht]
\centering
\begin{subfigure}[b]{0.35\textwidth}
\centering
\includegraphics[width=1.0\textwidth,height=0.17\textheight]{figures/instr_align_example}
\caption{}
\label{fig:instr_align_example}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.25\textwidth}
\centering
\includegraphics[width=1.0\textwidth,height=0.16\textheight]{figures/instr_melding_example}
\caption{}
\label{fig:instr_melding_example}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.25\textwidth}
\centering
\includegraphics[width=1.0\textwidth,height=0.17\textheight]{figures/unpredication_example}
\caption{}
\label{fig:unpredication_example}
\end{subfigure}
\caption{
(a) Instruction alignment result for two basic blocks $A$ and $B$,
(b) Code generated by \textsc{darm}\xspace for aligned instructions \circled{a}, \circled{b} and \circled{c} in Figure~\ref{fig:instr_align_example},
(c) Unpredication applied to the unaligned instructions of basic block $B$ in figure~\ref{fig:instr_align_example}
}
\vspace{-1em}
\end{figure*}
Figure~\ref{fig:instr_align_example} shows the instruction alignment computed for two basic blocks $A$ and $B$. Aligned instructions are
shown in green and instructions aligned with a gap are in red.
\subsection{\textsc{darm}\xspace Code Generation}
\label{sec:design:codegen}
\setlength{\textfloatsep}{0pt
\setlength{\floatsep}{0pt
\begin{algorithm}[!htb]
\SetAlgoLined
\SetKwRepeat{Do}{do}{while}
\KwIn{SPMD function $F$}
\KwOut{Melded SPMD function $F_{out}$}
\Do{changed}
{
changed $\leftarrow$ false \\
\For{BB in F}
{
R, C $\leftarrow$ GetRegionFor(BB) \\
\If{IsMeldableDivergent(R)}
{
SimplifyRegion(R) \\
A $\leftarrow$ ComputeSubgraphAlignment(R) \\
\For{($S_T,S_F$, profit) in A}
{
\If{profit $\geq$ threshold}
{
Meld($S_T,S_F$, C) \\
changed $\leftarrow$ true
}
}
}
\If{changed}
{
SimplifyFunction(F) \\
RecomputeControlFlowAnalyses(F) \\
break
}
}
}
\caption{\textsc{darm}\xspace Algorithm}
\label{algo:main}
\end{algorithm}
\begin{algorithm}[!htb]
\SetAlgoLined
\KwIn{SESE subgraphs $S_T$,$S_F$, Condition C}
\KwOut{Melded SESE subgraph $S_{out}$}
\caption{SESE Subgraph melding Algorithm}
List blockPairs $\leftarrow$ Linearize($S_T,S_F$) \\
List A $\leftarrow$ empty \\
\For{($B_T,B_F$) in blockPairs}
{
List instrPairs $\leftarrow$ ComputeInstrAlignment($B_T,B_F$) \\
A.append(instrPairs)
}
PreProcess($S_T,S_F$) \\
Map operandMap $\leftarrow$ empty \\
\For{$P$ in A}
{
$I_{melded}$ $\leftarrow$ Clone($P$) \\
Update(operandMap, $I_{melded}$, $P$) \\
}
\For{$P$ in A}
{
SetOperands($P$, operandMap, C)
}
RunUnpredication() \\
RunPostOptimizations()
\label{algo:subgraph_melding}
\end{algorithm}
\textsc{darm}\xspace's control-flow melding procedure is shown in algorithm~\ref{algo:main}. This algorithm takes in a SPMD function $F$ and iterates over
all basic blocks in $F$ to check if the basic block is an entry to a meldable divergent region ($R$) according to the conditions in Definition~\ref{def:meld_div_region}.
We use $\mathit{Simplify}$ to convert all subregions inside $R$ in to simple regions.
We compute the optimal subgraph alignment for the two sequences of subgraphs in the true and false paths of $R$.
We meld each subgraph pair in the alignment if the melding profitability is greater than some threshold.
Subgraph melding changes the control-flow of
$F$. Therefore we first simplify the control-flow (using LLVM's {\em simplifycfg}) and then
recompute the control-flow analyses (\textit{e.g.}~ dominator, post-dominator and region tree) required for the melding pass. We apply the melding procedure
on $F$ again until no profitable melds can be performed.
Algorithm~\ref{algo:subgraph_melding} shows the procedure for melding two subgraphs $S_T$ and $S_F$.
$C$ is the branching condition of the meldable divergent region containing $S_T$ and $S_F$.
First the two subgraphs are linearized in pre-order to form a list of corresponding basic block pairs. Processing the basic blocks in pre-order
ensures that dominating definitions are melded before their uses. For each basic block pair in this list we compute
an optimal alignment of instructions.
Each pair in the alignment falls into two categories, {\em I-I} and {\em I-G}. I-I is a proper alignment with two instructions
and I-G is an instruction aligned with a gap. Our alignment makes sure that in a match the two instructions are always meldable into one instruction (\textit{e.g.}~ a {\em load}
is not allowed to align with a {\em store}).
First we traverse the alignment pair list and clone the aligned instructions. For I-I pairs, we clone a single instruction because they can be melded.
During cloning, we also update the $\mathit{operandMap}$, which maintains a mapping between aligned and melded LLVM values.
We perform a second pass over the instruction alignment to set the operands of cloned instructions ($\mathit{SetOperands}$).
Assume we are processing an I-I pair with instructions $I_T,I_F$ and cloned instruction is $I_{melded}$. For each operand of $I_{melded}$,
the corresponding operands from
$I_T$ and $I_F$ are looked up in $operandMap$ because an operand might be an already melded instruction.
If the resultant two operands from $I_T$ and $I_F$ are the same, we just use that value as the operand. If they are different, we generate a {\em select} instruction
to pick the correct operand conditioned by $C$. For an I-G pair, operands are first looked up in $operandMap$ and the result is copied to $I_{melded}$.
Consider the instruction alignment in figure~\ref{fig:instr_align_example}. Figure~\ref{fig:instr_melding_example} shows the generated code
for aligned instruction pairs \circled{a}, \circled{b} and \circled{c}. In case \circled{a}, two select instructions are needed because both operands maps to
different values ($\%0$, $\%4$ and $\%1$, $\%5$). In case \circled{b}, the first operand is the same ($\%2$) for both instructions, therefore only one select is needed.
In case \circled{c}, both first and second operands are different for the two instructions. However the second operands map to same melded instruction $\%7$, so only
one select is needed. Note that $\%cmp$ is the branching condition for the divergent region, and we use that for selecting the operands. \\
\noindent
\textbf{Melding Branch Instructions of Exit Blocks}: Setting operands for branch instructions in subgraph exit blocks is slightly different than that for other instructions.
Let $B_T^{E}$,$B_F^{E}$ be the exit blocks of $S_T$ and $S_F$. Successors $B_T^{E}$,$B_F^{E}$ can contain $\phi$ nodes.
Therefore we need to ensure that successors of $B_T^{E}$ and $B_F^{E}$ can distinguish values produced in true path or false path. To solve this we move the branch conditions of $B_T^{E}$ and $B_F^{E}$ in to newly created blocks $B_T^{'}$ and $B_F^{'}$. Now we can conditionally branch
to $B_T^{'}$ and $B_F^{'}$ depending on $C$.
For example, in Figure~\ref{fig:melding_flow_c}
basic blocks $\%M$ and $\%N$ are created when when melding the exit branches of $\%X1$ and $\%X2$ in figure~\ref{fig:melding_flow_b}. Any $\phi$ node in $\%G$
(figure~\ref{fig:melding_flow_c}) can distinguish the values produced in true or false path using $\%M$ and $\%N$.
\noindent
\textbf{Melding $\phi$ Nodes} : In LLVM SSA form $\phi$ nodes are always placed at the beginning of a basic block. Even if
the instruction alignment result contains two aligned $\phi$ nodes we can not meld them into a single $\phi$ node because {\em select} instructions
can not be inserted before them. Therefore we copy all $\phi$ nodes into the melded basic block and set the operands for them using the $\mathit{operandMap}$.
This can introduce redundant $\phi$ nodes which we remove during post-processing.
\subsection{Unpredication}
\label{sec:design:unpred}
\begin{figure*}[ht]
\centering
\begin{subfigure}[b]{0.12\textwidth}
\includegraphics[width=\textwidth]{figures/bitonic_orig}
\caption{}
\label{fig:melding_flow_a}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.11\textwidth}
\includegraphics[width=\textwidth]{figures/bitonic_region_simplify}
\caption{}
\label{fig:melding_flow_b}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.095\textwidth}
\includegraphics[width=\textwidth]{figures/bitonic_merged}
\caption{}
\label{fig:melding_flow_c}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.21\textwidth}
\includegraphics[width=\textwidth]{figures/bitonic_unpredicated}
\caption{}
\label{fig:melding_flow_d}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.15\textwidth}
\includegraphics[width=\textwidth]{figures/bitonic_optimized}
\caption{}
\label{fig:melding_flow_e}
\end{subfigure}
\vspace{-0.5em}
\caption{\textsc{darm}\xspace melding algorithm applied to bitonic sort (Figure~\ref{fig:bitonicsort_kernel})
(a) Original control-flow graph,
(b) Region simplification,
(c) \textsc{darm}\xspace subgraph melding,
(d) Unpredication,
(e) Final optimized control-flow graph}
\label{fig:melding_flow}
\vspace{-1em}
\end{figure*}
In our code generation process, unaligned instructions are inserted to the same melded basic block
regardless of whether they are from true or false paths (\textit{i.e.}~ fully predicated). This can introduce overhead due to several reasons. If the branching conditions $C$ is biased
towards the true or false path, it can result in redundant instruction execution.
Also full predication of unaligned store instructions require adding extra loads to makes sure correct value is written back to the memory.
{\em Unpredication} splits the melded basic blocks at gap boundaries and moves the unaligned instructions into new blocks.
Figure~\ref{fig:unpredication_example} shows unpredication applied to the unaligned instructions of basic block $B$ in Figure~\ref{fig:instr_align_example}.
The original basic block is split to two parts ($\%M$ and $\%M.tail$) and unaligned instructions ($\%8$ and $\%9$) are moved to a new basic block, $\%M.split$.
$\phi$ nodes (($\%10$ and $\%11$)) are added to $\%M.tail$ to ensure unaligned instructions dominate their uses.
$\%8$ and $\%9$ are never executed in the true path, therefore $\phi$ nodes' incoming values from block $\%M$ are undefined ({\em LLVM undef}).
Note that in region replication (Section~\ref{sec:design:melding_profitability}) we apply unpredication only to the melded basic blocks. Store instructions outside the melded blocks are fully predicated by inserting extra loads.
\subsection{Pre and Post Processing Steps}
\label{sec:design:pre_and_post}
\begin{figure}[!ht]
\vspace{-1.0em}
\centering
\includegraphics[width=0.35\textwidth,height=0.18\textheight]{figures/preprocess_example}
\vspace{-0.5em}
\caption{\textsc{darm}\xspace pre-processing example}
\label{fig:preprocess_example}
\end{figure}
In SSA form, any definition must dominate all its users. However \textsc{darm}\xspace's subgraph melding can break this property. Consider the two meldable subgraphs $S_T$, $S_F$ in figure~\ref{fig:preprocess_example} \circled{A}. Definition $\%a$ dominates
its use $\%x$ before the melding. However if $S_T$ and $S_F$ are melded naively then $\%a$ will no longer dominate $\%x$. To fix this we add a new basic block $\%P$ with
a $\phi$ node $\%m$. All uses of $\%a$ are replaced with $\%m$ (Figure~\ref{fig:preprocess_example} \circled{B}). Notice that value $\%m$ is never meant to be used in the true path execution. Therefore it is
undefined in true path ({\em undef}). We apply this preprocessing step before the melding ($\mathit{PreProcess}$ in Algorithm~\ref{algo:subgraph_melding}).
Subgraph melding can introduce branches with identical successors, $\phi$ nodes with identical operands and redundant $\phi$ nodes.
$\mathit{RunPostOptimizations}$ in Algorithm~\ref{algo:subgraph_melding} removes these redundancies.
\subsection{Putting All Together} Figure~\ref{fig:melding_flow} shows how each stage of the pipeline of subgraph-melding transforms the CFG of bitonicSort kernel.
The original CFG is shown in Figure~\ref{fig:melding_flow_a}.
Region ($\%B$, $\%G$) is a meldable divergent region.
Figure~\ref{fig:melding_flow_b} shows the CFG after region simplification. Subgraphs $(\%C, \%X1)$ and $(\%D, \%X2)$ are profitable to meld
according to our analysis.
Figure~\ref{fig:melding_flow_c} shows the CFG after subgraph-melding.
The result after applying unpredication is shown in
Figure~\ref{fig:melding_flow_d}.
Notice that the unpredication splits the basic block $\%C\_D$ (in Figure~\ref{fig:melding_flow_c}) into 5 basic blocks (zoomed in blue-dashed blocks in Figure~\ref{fig:melding_flow_d}).
Basic blocks $\%P.S.1$ and $\%P.S.2$ are the unaligned groups of instructions and they are executed conditionally.
Figure~\ref{fig:melding_flow_e} shows the final optimized CFG after applying post optimizations.
Note that {\em ROCm HIPCC} compiler applied {\em if-conversion} aggressively.
Therefore the effect of unpredication step is nullified in this case.
Figure~\ref{fig:melding_flow} only shows how \textsc{darm}\xspace transformation changes the CFG of our running example.
It does not show the change of instructions inside these basic blocks.
We use Figure~\ref{fig:llvmir_example} to explain the generation of melded instructions for the running example.
Figure~\ref{fig:llvmir_orig} shows the LLVM-IR of the meldable divergent region ($(\%B,\%G)$ in Figure~\ref{fig:melding_flow_b}) in our running example.
During \textsc{darm}\xspace code generation, basic blocks in subgraphs $(\%C, \%X1)$ and $(\%D, \%X2)$ are linearized to compute the instruction alignment. Computed instruction alignment is shown in Figure~\ref{fig:llvmir_seq_align}.
Notice that $[\%C,\%D],[\%E,\%F],[\%X1,\%X2]$ are the corresponding basic block pairs.
In this example all instructions perfectly align with each other except for the compare instructions in basic blocks $\%C$ and $\%D$ (shown in red in Figure~\ref{fig:llvmir_seq_align}).
Figure~\ref{fig:llvmir_after_darm} shows the LLVM-IR after applying subgraph melding and unpredication (similar to Figure~\ref{fig:melding_flow_d}).
Note that instructions $\%34$ and $\%31$ (compare instructions) are unaligned.
Therefore unpredication step introduced basic blocks $\%P.S.1$ and $\%P.S.2$ to execute them conditionally based on the divergent condition $\%16$.
Extra $\phi$ instructions $\%phi.1$ and $\%phi.2$ are inserted to ensure def-use chains are not broken during the unpredication step.
Out of the all aligned instructions only the branch instructions at the end of basic blocks $\%C$ and $\%D$ require select instructions during instruction-melding.
For example the store instructions in basic blocks $\%E$, $\%F$ use matching operands, therefore can be melded without adding selects.
On the other hand, conditional branch instructions uses values $\%34$ and $\%31$ and select instruction $\%37$ is inserted (Figure~\ref{fig:llvmir_after_darm}) to pick the branching condition {\em conditionally}.
Note that the values $\%34$ and $\$31$ will flow to their users via the $\phi$ nodes $\%phi.1$ and $\%phi.2$ respectively.
Therefore the select instruction (\textit{i.e.}~ $\%37$) uses these $\phi$ nodes as its operands.
\begin{figure}
\centering
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth]{figures/after_region_simplify_llvmir.pdf}
\caption{}
\label{fig:llvmir_orig}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth]{figures/instr_align_llvmir.pdf}
\caption{}
\label{fig:llvmir_seq_align}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth]{figures/melded_llvmir.pdf}
\caption{}
\label{fig:llvmir_after_darm}
\end{subfigure}
\caption{LLVM-IR before and after applying \textsc{darm}\xspace transformation to our running example (a) meldable divergent region (b) instruction alignment (b) LLVM-IR generated after subgraph melding and unpredication}
\label{fig:llvmir_example}
\end{figure}
\section{Discussion and Future Work}
\label{sec:discussion}
Most of the GPGPU benchmarks are heavily hand optimized by expert developers and this often include \textsc{darm}\xspace like transformations to remove control-flow divergence~\cite{branch_fusion}. We evaluate \textsc{darm}\xspace on limited set of real-world benchmarks mainly because of this reason. However we also emphasize that doing \textsc{darm}\xspace-like transformations by hand is time-consuming and error-prone.
For example, it took us several hours to manually apply control-flow melding to LUD kernel.
Therefore, offloading this to the compiler can save a lot of developer effort.
The benefits of \textsc{darm}\xspace is not limited to reducing control-flow divergence in GPGPU programs. \textsc{darm}\xspace can be used to reduce control-flow divergence in any hardware backends and programming models that employ SIMT execution (\textit{e.g.}~ intel/AMD processors with ISPC~\cite{ispc}). \textsc{darm}\xspace can be used to reduce branches in a program. This property can be exploited to accelerate software testing techniques such as symbolic execution~\cite{targeted_transformations}.
\textsc{darm}\xspace factor out common code segments within {\em if-the-else} regions of a program.
Therefore it can be used as an intra-function code size reduction optimization as well.
Aforementioned applications of \textsc{darm}\xspace suggest that it is useful as a general compiler optimization technique. We plan to explore some of these applications in our future work.
In Section~\ref{sec:eval}, we have shown that when shared memory is used to improve the baseline, it does not steal the opportunity from \textsc{darm}\xspace to meld, because melding shared memory instructions also results in better performance than the improved baseline.
Exploiting this opportunity requires maximizing the alignment of shared memory instructions which can be achieved by using a refined instruction cost model.
\section{Evaluation}
\label{sec:eval}
\subsection{Evaluation Setup and Benchmarks}
We evaluate the performance of \textsc{darm}\xspace on a machine with a {\em AMD Radeon Pro Vega 20} GPU.
This GPU has 16 {\em GB}s of global memory, 64 {\em kB} of shared memory (\textit{i.e.}~ Local Data Share (LDS)) and 1700 {\em MHz} of max clock frequency.
The machine consists of {\em AMD Ryzen Threadripper 3990X} 64-Core Processor with 2900 {\em MHz} max clock frequency.
We use two different sets of benchmarks.
First, to assess the generality of \textsc{darm}\xspace, we create several synthetic programs that exhibit control divergence of varying complexity.
While many real-world programs are hand-optimized to eliminate divergence, these synthetic programs both qualitatively demonstrate the generality of \textsc{darm}\xspace over prior automated divergence-control techniques, and show that \textsc{darm}\xspace can automate the control flow melding that would otherwise have to be done by hand.
\noindent
\textbf{Synthetic Benchmarks}
\begin{figure}[!ht]
\centering
\includegraphics[width=0.5\textwidth]{figures/sb_cases}
\caption{Control-flow patterns in synthetic benchmarks. Square: basic block and Circle: {\em if-then} region (shown on right)}
\label{fig:sb_cases}
\end{figure}
\begin{figure*}
\centering
\includegraphics[width=\textwidth, height=0.18\textheight]{plots/lmicro}
\caption{Micro Benchmark Performance. GM is geomean of \textsc{darm}\xspace's speedup over baseline.}
\label{fig:micro_benchmark}
\end{figure*}
\begin{figure*}[!ht]
\centering
\includegraphics[width=\textwidth, height=0.18\textheight]{plots/lreal}
\vspace{-1.5em}
\caption{Real-world Benchmark Performance. $+$ marks block size with best baseline runtime. GM is geo-mean of \textsc{darm}\xspace's speedup on all benchmarks; GM-Best is \textsc{darm}\xspace's speedup on $+$ configurations.}
\vspace{-1.5em}
\label{fig:real_benchmark}
\end{figure*}
Each synthetic kernel consists of two nested loops.
The inner loop contains a divergent region with different control-flow structures (SB1, SB2, SB3 and SB4 in Figure~\ref{fig:sb_cases}).
Every divergent path computes on different pieces of data from shared memory.
SB1 has simple diamond-shaped control-flow with basic blocks A2 and A3 performing identical computations.
In SB2 and SB3; circled regions are {\em if-then} sections.
{\em Then} blocks in region pairs B2-B3 (in SB2), C2-C3 and C6-C5 (in SB3) consist of identical computations.
In three-way divergent kernel SB4, basic blocks D2, D4, and D5 are performing identical computations.
Basic blocks/regions with identical computations have high melding profitability.
Synthetic benchmarks SB1-R, SB2-R, SB3-R and SB4-R have same control-flow structure as SB1-SB4 but contain non-identical computations in the
basic blocks.
Prior control-flow melding techniques (tail merging~\cite{gen_tail_merge_sas03} and branch fusion~\cite{branch_fusion})
cannot meld the full set of synthetic benchmarks.
Tail merging can combine the divergent {\em if-then-else} blocks in SB1 and SB4 but cannot fully merge divergent regions.
It cannot merge the -R variants due to the different instructions in the divergent paths.
Branch fusion subsumes tail merging, and can fully merge {\em if-then-else} blocks in SB1, SB4 and their -R variants.
However, it cannot be applied to the more complex control flow of SB2 and SB3, or their -R variants.
In SB4, iterative application of branch fusion can meld blocks D4,D5 and D2.
However its -R variant can not be fully melded by branch fusion due to non-identical computations being un-predicated ({\em cf} Section \ref{sec:design:unpred}).
In contrast, \textsc{darm}\xspace melds it by using {\em region replication} ({\em cf} Section~\ref{sec:design:melding_profitability}).
\noindent
\textbf{Real-world Benchmarks}
Second, to show \textsc{darm}\xspace's effectiveness on real-world programs, we consider 7 benchmarks written in {\em HIP}~\cite{HIP}. These benchmarks were taken from well-known highly hand-optimized GPU benchmark suites or optimized reference implementations of papers. We selected these benchmarks because they contain divergent if-then-else regions that present melding opportunities for DARM.
We do not consider benchmarks that do not present any melding opportunities for \textsc{darm}\xspace because they are not modified by \textsc{darm}\xspace in any way.
\textbf{Bitonic Sort (BIT)} Our running example is bitonic sort~\cite{bitonic}.
In this kernel, each thread block takes in a bucket and performs parallel sort.
We used an input of $2^{26}$ elements and varied the bucket (\textit{i.e.}~ block) size.
\textbf{Partition and Concurrent Merge (PCM)} PCM is a parallel sorting algorithm based on Batcher's odd-even merge sort~\cite{pcm}.
PCM performs odd-even merging of \textit{buckets} of sorted elements at every position of the array leading to loops with nested data-dependent branches.
We used an array of $2^{28}$ elements with different number of buckets.
\textbf{Mergesort (MS)} A parallel bottom-up merge sort implementation.
The kernel has data-dependent control-flow divergence in the merging step.
We used an input array with $2^{20}$ elements.
\textbf{LU-Decomposition (LUD)} LUD implementation from the Rodinia benchmark suite~\cite{rodinia}.
We focus our evaluation on the {\em lud\_perimeter} kernel in this benchmark.
{\em lud\_perimeter} contains multiple divergent branches that depend on thread ID and block size.
We use a randomly generated matrix of size $16384 \times 16384$ as the input.
\textbf{N-Queens (NQU)} N-Queens solver uses backtracking to find all different ways of placing N queens on a NxN chessboard without attacking each other.
We have used the kernel from the GPGPU-sim benchmark suite~\cite{ispass2009gpgpusim} with N is 15.
\textbf{Speckle Reducing Anisotropic Diffusion (SRAD)} SRAD is diffusion based noise removal method for imaging applications
from Rodinia benchmark suite~\cite{rodinia}.
We have used an image of size $4096 \times 4906$ as input.
\textbf{DCT Quantization (DCT)} An in-place quantization of a discrete cosine transformation (DCT) plane~\cite{cu_samples}.
The quantization process is different for positive and negative values resulting in data-dependent divergence.
We use a randomly generated DCT plane of size $2^{15} \times 2^{15}$ as input.
\noindent
\textbf{Baseline and Branch Fusion:}
Our baseline implementations of these kernels have been hand-optimized (except, obviously, for optimizations that manually remove control divergence by applying \textsc{darm}\xspace-like transformations).
This optimization includes using shared memory when needed to improve performance. The baseline implementations were compiled with \nobreakdash-O3.
Branch fusion~\cite{branch_fusion} was implemented in the Ocelot~\cite{gpuocelot} open-source CUDA compiler that is no longer maintained and does not support AMD GPUs. We implemented branch fusion by modifying \textsc{darm}\xspace to
apply melding for diamond-shaped control-flow ({\em if-then-else}). We use this for comparison against branch fusion.
Branch fusion cannot fully handle the control-flow of BIT, PCM, and NQU.
Loop unrolling enables successful branch fusion in LUD.
\noindent
\textbf{Block Size:}
Each of these kernels has a tunable {\em block size}---essentially, a tile size that controls the granularity of work in the inner loops.
Because the correct block size can be dependent on many parameters (though for a given input and GPU configuration, one is likely the best),
our evaluation treats block size as exogenous to the evaluation, and hence considers behavior at different block sizes for each kernel.
In other words, our evaluation asks: if a programmer has a kernel with a given block size, what will happen if \textsc{darm}\xspace is applied?
Note that of these kernels, only LUD exhibit divergence that depends on block size.
This means that all the other benchmarks will experience divergence regardless of block size.
LUD's divergence, on the other hand, is block size dependent. For some block sizes, the kernel will be divergent, while for others, it will be convergent.
\subsection{Performance}
Figure~\ref{fig:micro_benchmark} shows the speedups for the synthetic benchmarks with different block sizes.
\textsc{darm}\xspace can successfully meld all 4 control-flow patterns we consider in the synthetic benchmarks and gives a superior performance than the baseline and branch fusion
(geo-mean speedups of 1.36$\times$ for \textsc{darm}\xspace and 1.10$\times$ for branch fusion over the baseline).
The performance for random (-R) variants are slightly lower for each of the patterns.
This is because -R variants contain random instruction sequences and instructions do not align perfectly, causing \textsc{darm}\xspace to insert {\em select} instructions and branches to unpredicate unaligned instruction groups.
Speedups observed for SB3 and SB3-R are better than SB1, SB2 and their -R variants because \textsc{darm}\xspace melds multiple subgraph pairs in the SB3 control-flow pattern
(Figure~\ref{fig:sb_cases}) and control-flow divergence is reduced more in this case.
We observe the highest performance improvement for SB4 and SB4-R because \textsc{darm}\xspace melds basic blocks D2, D4, and D5 (Figure~\ref{fig:sb_cases}) using {\em region replication}.
SB4 and its -R variant have 3-way divergence because of the {\em if-else-if-else} branch. Applying {\em region replication} along with
subsequent simplification passes greatly reduces this original three-way divergence.
Figure~\ref{fig:real_benchmark} shows the speedups for real benchmarks
\textsc{darm}\xspace always improves the performance (1.15$\times$ geo-mean speedup over all benchmarks and 1.16$\times$ geo-mean speedup over the best baseline variants) except for SRAD (see below).
The highest relative improvement in performance can be seen in BIT and PCM for all block sizes.
This is because both these benchmarks are divergent regardless of the block size and they have complex control-flow regions with shared memory instructions.
\textsc{darm}\xspace successfully melds these regions and reduces divergence significantly. Branch fusion improves performance in
PCM by melding {\em if-then-else} blocks.
In LUD, the divergence is block size dependent, and the kernel is divergent only at block sizes 16, 32 and 64, where we see a visible performance improvement introduced by \textsc{darm}\xspace.
NQU contains a time-consuming loop with divergent {\em if-then-elseif-then} section. \textsc{darm}\xspace applies {\em region replication} to remove divergence,
achieving superior performance.
SRAD kernel has both block size-dependent and data-dependent divergent regions (say $R_B$ and $R_D$ respectively).
Both $R_B$ and $R_D$ consists of {\em if-then-else--if-then-else} chains.
$R_B$ contains no shared memory instructions and melding does not improve performance (for both \textsc{darm}\xspace and branch fusion).
However $R_D$ contains a 3-way divergent branch with shared memory instructions and the divergence is biased \textit{i.e.}~
execution only takes 2 of the 3 ways.
In this case branch fusion has better performance at block size 16, because blocks that get melded happen to be on the divergent paths.
However \textsc{darm}\xspace has more melding options than branch fusion, and it melds all 3 paths adding extra overhead.
At block size 32, the extra overhead introduced by melding $R_B$ becomes significant and both \textsc{darm}\xspace and branch fusion exhibit a performance drop.
Performance drop for \textsc{darm}\xspace can be avoided by prioritizing the melding order (\textit{i.e.}~ apply melding to divergent regions with most profitable subgraphs first).
However, prioritizing melding order is not considered in this paper.
In most cases (except SRAD), the block size for best performing baseline is also the one that gives the best absolute performance for \textsc{darm}\xspace.
Interestingly, for $4/7$ benchmarks (BIT, PCM, MS, and DCT), not only does this best baseline block size produce the best absolute \textsc{darm}\xspace performance, it also produces the best {\em speedup} relative to the baseline: the block size that makes the baseline perform the best, actually exposes more optimization opportunities to \textsc{darm}\xspace.
We use {\em rocprof}~\cite{rocprof} to collect ALU utilization and memory instruction counters to reason about performance.
We focus on the block sizes for each benchmark where \textsc{darm}\xspace has highest improvement over the baseline.
\subsection{ALU Utilization}
\textsc{darm}\xspace's melding transformation enables the ALU instructions in divergent paths to be issued in the same cycle.
This effectively improves the SIMD resource utilization.
Figure~\ref{fig:alu_util} shows the ALU utilization ($\%$).
As expected \textsc{darm}\xspace improves the ALU utilization significantly for most benchmarks.
In BIT, divergent paths does not have common comparison operators ($>$ and $<$ comparisons in lines 9 and 13 in Figure~\ref{fig:bitonicsort_kernel}).
Even though \textsc{darm}\xspace unpredicates these instructions, later optimization passes decide to fully-predicate them resulting in lower ALU utilization.
\begin{figure}[!b]
\centering
\includegraphics[width=0.45\textwidth, height=0.13\textheight]{plots/alu}
\caption{ALU Utilization.}
\label{fig:alu_util}
\end{figure}%
\begin{figure}[!b]
\centering
\includegraphics[width=0.45\textwidth, height=0.13\textheight]{plots/mem}
\caption{Normalized Memory Instruction Counters.}
\label{fig:mem_util}
\end{figure}
\subsection{Melding of Memory Instructions}
\label{sec:eval:memory}
Figure~\ref{fig:mem_util} shows the normalized number of
global and shared memory (\textit{i.e.}~ local data share) instructions issued after applying \textsc{darm}\xspace.
In LUD, there are many common shared memory instructions in divergent paths.
However these instructions do not have different memory alignments, therefore cannot be melded into a single instruction.
Unpredicated shared memory instructions are predicted by other optimization passes in LLVM resulting in higher instruction count.
Melding reduces the global memory instruction count in LUD.
DCT does not have any memory instructions in the divergent region and does not use shared memory.
In BIT and PCM, the melded regions contain a lot of shared memory instructions. Therefore the reduction in shared memory instructions is significant and correlate with the performance gain.
We find that melding shared memory instructions is more beneficial than melding ALU instructions because shared memory instructions have higher latency than most ALU instructions, though lower latency than global memory instructions.
Therefore there is 2$\times$ improvement in cycles spent if
two divergent shared memory instructions are issued in the same cycle.
In contrast, melding global memory instructions does not always improve performance.
This is because the data requested by divergent memory instructions might be on different cache lines and
these requests are serialized by the memory controller even if they are issued in the same cycle.
\subsection{Melding Profitability Threshold}
\label{sec:melding_threshold}
\begin{figure}[!t]
\centering
\includegraphics[width=0.45\textwidth, height=0.13\textheight]{plots/profitability}
\caption{Variation of melding profitability thresholds.}
\label{fig:profit}
\end{figure}
Figure~\ref{fig:profit} shows the performance of \textsc{darm}\xspace for different melding profitability thresholds on the real-world benchmarks considering \textsc{darm}\xspace's best performing block sizes.
For all benchmarks, we observe that \textsc{darm}\xspace's speedup reduces as we increase the threshold due to lost opportunities
When we reduce the threshold, increment in the improvement of the performance of \textsc{darm}\xspace becomes insignificant (after 0.2).
But we cannot reduce it to zero because every possible pair would be melded and the subsequent CFG simplification passes would unpredicate them.
As a result, \textsc{darm}\xspace may become non-convergent.
\subsection{Compile Time}
\begin{table}[!ht]
\centering
\caption{Average Compile Time (s)}
\label{tab:compile-time}
\small
\resizebox{0.25\textwidth}{!}{
\begin{tabular}{lrrr}\toprule
Benchmark &O3 &DARM &Normalized \\\midrule
BIT &0.4804 &0.5018 &1.0444 \\
PCM &0.5690 &0.5942 &1.0443 \\
MS &0.8037 &0.8064 &1.0035 \\
LUD &0.5993 &0.6294 &1.0502 \\
NQU &0.4687 &0.4738 &1.0109 \\
SRAD &0.4999 &0.5121 &1.0244 \\
DCT &0.4398 &0.4439 &1.0093 \\
\bottomrule
\end{tabular}}
\end{table}
Table~\ref{tab:compile-time} shows the device code compilation times for the baseline and \textsc{darm}\xspace.
We omit the time for compiling host code and linking because it is constant for
both the baseline and \textsc{darm}\xspace.
Since we perform the analysis and the instruction alignment -- the most costly parts -- at the basic block level rather than performing at a higher level (\textit{i.e.}~ function or region level), we incur negligible compilation overhead. Compilation time overhead introduced by \textsc{darm}\xspace is a small fraction of total compilation time (including host code) for all cases.
\textsc{darm}\xspace's compile time depends on the size of basic blocks that get melded and the structure of the program since it determines different types of melding opportunities.
A slight overhead in compilation time of LUD is caused by sequence alignment overhead on large basic blocks (created by loop unrolling).
PCM and BIT have divergent regions inside an unrolled loop, therefore \textsc{darm}\xspace's meldable subgraph detection incurs overhead.
Only BIT and PCM has opportunities for Region-Region melding, and only PCM, NQU, and SRAD have opportunities for Basic block-Region melding.
Presence of Basic block-Region melding opportunity results in {\em region replication}.
\section{Implementation}
\label{sec:impl}
We implemented the \textsc{darm}\xspace algorithm described in Section~\ref{sec:design} as an LLVM-IR analysis and transformation pass
on top of the {\em ROCM HIPCC}\footnote{LLVM version 12.0.0, ROCm version 4.2.0} GPU compiler~\cite{HIPCC}.
Both the analysis and transformation are function passes that operate on GPGPU functions.
The analysis pass first detects meldable divergent regions using LLVM's divergence analysis.
Then it finds all the profitable subgraph pairs that can be melded.
We use a default melding profitability threshold of 0.2 (algorithm~\ref{algo:main}). We also provide
a sensitivity analysis on this threshold in Section~\ref{sec:melding_threshold}.
We use modified version of LLVM cost model~\cite{llvm_cost_model} to obtain instruction latencies for melding profitability
and instruction alignment computations.
The transformation uses the output of analysis to perform \textsc{darm}\xspace's code generation procedure (Section~\ref{sec:design:codegen}).
The transformation pass also performs the unpredication, pre- and post-processing steps described in Sections~\ref{sec:design:unpred} and~\ref{sec:design:pre_and_post}.
LLVM pass is implemented in $\sim 2500$ lines of C++ code.
In order to produce the program binary with our pass, we had to include our pass in the {\em ROCM HIPCC} compilation pipeline.
Most GPGPU compilers (\textit{e.g.}~ CUDA nvcc, ROCm HIPCC) use {\em separate compilation} for GPU device and CPU host codes.
Final executable contains the device binary embedded in the host binary.
In the modified workflow, we first compile the device code into LLVM-IR and run \textsc{darm}\xspace on top of that to produce a transformed IR module.
Our pass runs only on device functions and avoids any modifications to host code.
After that, we use the LLVM static compiler ({\em llc})~\cite{llc} to generate an object file for the transformed device code.
The rest of the compilation flow is as same as the one without any modification.
\section{Introduction}
\label{sec:intro}
General Purpose Graphics Processing Units (GPGPU) are capable of executing thousands of threads in parallel, efficiently.
Advancements in the programming models and compilers for GPUs have made it much easier to write data-parallel applications.
Unfortunately, exploiting data parallelism does not immediately translate to better performance.
One key reason for the lack of performance portability is that GPGPUs are not capable of executing all the threads independently. Instead threads are grouped together
into units called \textit{warps}, and threads in a warp execute instructions in lockstep. This is commonly referred to as the Single Instruction Multiple Thread (SIMT)
execution model.
The SIMT model suffers performance degradation when threads exhibit {\em irregularity} and can no longer execute in lockstep.
Irregularity comes in two forms, irregularity in memory accesses patterns (\textit{i.e.}~ memory divergence) and irregularity in the control-flow of
the program (\textit{i.e.}~ control-flow divergence). Memory divergence occurs when GPGPU threads needs to access memory at non-uniform locations, which
results in un-coalesced memory accesses. Un-coalesced memory accesses are bad for GPU performance because memory bandwidth can not be fully
utilized to do useful work.
Control-flow divergence occurs when threads in a warp diverge at branch instructions.
At the {\em diverging} branch, lockstep execution can not be maintained because threads in a warp may want to execute different basic bocks (\textit{i.e.}~ diverge).
Instead, when executing instructions along a diverged path, GPGPUs mask out the threads that do not want to take that path. The threads {\em reconverge} at the Immediate Post-DOMinator (IPDOM) of a divergent branch---the instruction that all threads from both branches want to execute. This style of IPDOM-based reconvergence is implemented in hardware in most GPGPU architectures to maintain SIMT execution.
Even though IPDOM-based reconvergence can handle arbitrary control-flow, it imposes a significant performance penalty if a program has
a lot of divergent branches. In the IPDOM reconvergence model, instructions executed on divergent branches necessarily cannot utilize the full width of a SIMD unit. If the code has a lot of nested divergent branches or divergent branches inside loops, this style of execution causes significant under-utilization
of SIMD resources.
For some GPGPU applications divergent branches are unavoidable, and there have been many techniques proposed to address this issue both in hardware and software.
Proposals such as Dynamic warp formation~\cite{dynamicwarp}, Thread block compaction~\cite{compact_thblk} and Dual-path execution~\cite{dualpath}
focus on mitigating the problem at the hardware level by changing how threads are scheduled for execution and making sure that
threads following the same path are grouped together. Unfortunately, such approaches are not useful on commodity GPGPUs.
\begin{table}[tb]
\centering
\caption{Comparison of techniques for divergence reduction}
\begin{tabular}{|c|c|c|c|}
\hline
\multirow{2}{*}{\textbf{\begin{tabular}[c]{@{}c@{}}Control-flow and instruction\\ Pattern\end{tabular}}} & \multicolumn{3}{c|}{\textbf{Technique}} \\ \cline{2-4}
& \begin{tabular}[c]{@{}c@{}}Tail \\ Merging\end{tabular} & \begin{tabular}[c]{@{}c@{}}Branch \\ Fusion\end{tabular} & \textsc{darm}\xspace \\ \hline
\begin{tabular}[c]{@{}c@{}}Diamond control-flow with \\ identical instruction sequences\end{tabular} & \cmark & \cmark & \cmark \\ \hline
\begin{tabular}[c]{@{}c@{}}Diamond control-flow with \\ distinct instruction sequences\end{tabular} & \xmark & \cmark & \cmark \\ \hline
Complex control-flow & \xmark & \xmark & \cmark \\ \hline
\end{tabular}
\label{tab:related_work}
\vspace{-2.0em}
\end{table}
There have also been efforts to reduce divergence through compiler approaches that leverage the observation that different control-flow paths often contain similar instruction (sub)sequences. {\em Tail merging}~\cite{gen_tail_merge_sas03} identifies branches that have identical sequences of code and introduces early jumps to {\em merged} basic blocks, with the effect of reducing divergence. {\em Branch fusion} generalizes tail merging to work with instruction sequences that may not be identical~\cite{branch_fusion}.
However, branch fusion cannot analyze complex control-flow and hence it is restricted to simple {\em if-then-else} branches where each path has a single basic block (\textit{i.e.}~ diamond-shaped control-flow).
This paper introduces a more general, software-only approach of exploiting similarity in divergent paths, called {\em control-flow melding}.
Control-flow melding is a general control-flow transformation which can meld similar
control-flow \textit{subgraphs} inside a {\em if-then-else} region (not just individual basic blocks).
By working hierarchically, recursively melding divergent control-flow at the level of subgraphs of the CFG, control-flow melding can handle substantially more general control structures than prior work. This paper describes \textsc{darm}\xspace, a realization of control-flow melding for general GPGPU programs. Table~\ref{tab:related_work} compares the capabilities of \textsc{darm}\xspace with branch fusion and tail merging.
\textsc{darm}\xspace works in several steps. First, it detects divergent {\em if-then-else} regions and splits the divergent regions into Single Entry Single Exit (SESE) control-flow subgraphs. Next it uses a hierarchical sequence alignment technique to \textit{meld} profitable
control-flow subgraphs, repeatedly finding subgraphs whose control-flow structures and constituent instructions can be aligned.
Once a fixpoint is reached, \textsc{darm}\xspace uses this hierarchical alignment to generate code for the region with reduced control-flow divergence.
The main contributions of the paper are,
\begin{itemize}[leftmargin=*]
\item \textbf{D}ivergence-\textbf{A}ware-\textbf{R}egion-\textbf{M}elder (\textsc{darm}\xspace), a realization of control-flow melding that identifies profitable melding opportunities in divergent {\em if-then-else}
regions of the control-flow using a hierarchical sequence alignment approach and then melds these regions to reduce control-flow divergence.
\item An implementation of \textsc{darm}\xspace in LLVM~\cite{llvm} that can be applied to GPGPU programs written in HIP~\cite{HIP} or CUDA~\cite{cuda}. Our implementation of \textsc{darm}\xspace is publicly available as an archival repository\footnote{https://doi.org/10.5281/zenodo.5784768} and up-to-date version is available in GitHub\footnote{https://github.com/charitha22/cgo22ae-darm-code}.
\item An evaluation of \textsc{darm}\xspace on a set of synthetic GPU programs and a set of real-world GPU applications showing its effectiveness
\end{itemize}
\section{Motivating Example}
\label{sec:overview}
\begin{figure}[tb]
\begin{lstlisting}[language=c, basicstyle=\small, frame=single]
__global__ static void bitonicSort(int *values) {
// copy data from global memory to shared memory
__syncthreads();
for (unsigned int k = 2; k <= NUM; k *= 2) {
for (unsigned int j = k / 2; j > 0; j /= 2) {
unsigned int ixj = tid ^ j;
if (ixj > tid) {
if ((tid & k) == 0) {
if (shared[ixj] < shared[tid])
swap(shared[tid], shared[ixj]);
}
else {
if ( shared[ixj] > shared[tid])
swap(shared[tid], shared[ixj]);
}
}
__syncthreads();
}
} // write data back to global memory
}
\end{lstlisting}
\vspace{-0.5em}
\caption{Bitonic sort kernel}
\vspace{-2.0em}
\label{fig:bitonicsort_kernel}
\end{figure}
Bitonic sort is a kernel used in many parallel sorting algorithms such as bitonic merge sort and Cederman's quicksort~\cite{bitonic, gpu_quicksort_cederman}.
Figure~\ref{fig:bitonicsort_kernel} shows a CUDA implementation of bitonic sort.
This kernel is our running example for describing \textsc{darm}\xspace's control-flow melding algorithm.
In this kernel, the branch condition at line 8 depends on the {\em thread ID}. Therefore it is divergent.
Since the divergent branch is located inside a loop, the execution of the two sides of the branch needs to be serialized many times,
resulting in high control-flow divergence.
However the code inside the {\em if} (line 9-10) and {\em else} (line 13-14) sections of the divergent branch are similar in two ways.
First, both code sections have the same control-flow structure (\textit{i.e.}~ {\em if-then} branch). Second, instructions along the two paths are
also similar. Both conditions compare two elements in the {\em shared} array and perform a {\em swap} operation.
Therefore the contents of the {\em if} and {\em else} sections can be melded to reduce control-flow divergence.
Both code sections consists of shared memory loads and store operations. In the unmelded version of the code these shared memory
operations will have to be serialized due to thread-divergence. However, if the two sections are melded threads can issue the memory instructions
in the same cycle resulting in improved performance.
Existing compiler optimizations such as tail merging and branch fusion cannot be applied to this case.
Tail merging is applicable only if two basic blocks have a common destination and have identical instruction sequences at their tails.
However in bitonic sort, the {\em if} and {\em then} sections of the divergent branch have multiple basic blocks, and the compiler cannot apply
tail merging. Similarly branch fusion requires diamond shaped control-flow and does not work if the {\em if} and {\em else}
sections of the branch contain complex control-flow structures.
\textsc{darm}\xspace solves this problem in two phases.
In the analysis phase (Section~\ref{sec:design:melding_profitability}),
\textsc{darm}\xspace analyzes the control-flow region dominated by a divergent branch to find isomorphic sub-regions that are in the true and false paths of the divergent branch. These isomorphic sub-region pairs are aligned based on their
melding profitability using a sequence alignment strategy.
Melding profitability is a compile-time approximation of the percentage of thread cycles that can be saved by melding two control-flow regions.
Next, \textsc{darm}\xspace choses profitable sub-region pairs in the alignment (using a threshold) and computes an instruction alignment for corresponding basic blocks in the two regions.
In the code generation phase (Section~\ref{sec:design:codegen}), \textsc{darm}\xspace uses this instruction alignment to meld corresponding basic blocks in the sub-region pair.
This melding is applied iteratively until no further profitable melding can be performed.
\textsc{darm}\xspace's melding transformation is done in SSA form, therefore the resulting CFG can be optimized further using other compiler optimizations (Sections~\ref{sec:design:unpred} and~\ref{sec:design:pre_and_post}).
\section{Related Work}
\label{sec:related_work}
\paragraph{Divergence Analysis}
Impact of control-flow divergence has extensively studied in different contexts~\cite{taco2015hack,wholefuncv2011,pldi2018hack,gpucheck}.
Reducing control-flow divergence requires finding the source of divergence in a program.
Coutinho~\textit{et al.}~ constructed a divergence analysis to statically identify variables with the same value for every SIMD unit and used this analysis to drive {\em Branch Fusion}~\cite{branch_fusion}.
A divergence analysis of similar fashion based on data and sync dependences has been integrated to the LLVM framework~\cite{llvm_div_analysis}.
Recently, Rosemann~\textit{et al.}~ has presented a precise divergence analysis based on abstract interpretation for reducible CFGs~\cite{divanalysispopl2021}.
Using a precise divergence analysis improves the opportunities of melding for \textsc{darm}\xspace.
\paragraph{Code Compaction}
\emph{Tail Merging} is a standard, but restrictive, compiler optimization used to reduce the code size by merging identical sequences of instructions.
Chen~\textit{et al.}~ used generalized tail merging to compact matching \emph{Single-Entry-Multiple-Exit} regions~\cite{gen_tail_merge_sas03}.
Recently, Rocha~\textit{et al.}~ has presented \emph{Function Merging}, an advanced sequence-alignment based technique for code size reduction~\cite{rocha20, rocha19}.
Even though parts of \textsc{darm}\xspace has some similarities with function merging, it does not tackle divergence.
\paragraph{Compiler Techniques}
In addition to branch fusion, Anantpur and Govindarajan proposed to structure the unstructured CFGs and then linearize it with predication~\cite{linearcfg2014}.
More recently, Fukuhara and Takimoto proposed \emph{Speculative Sparse Code Motion} to reduce divergence in GPU programs~\cite{codemotion20},
which preserves the CFG and it is orthogonal to \textsc{darm}\xspace.
\emph{Collaborative Context Collection} copies registers of divergent warps to shared memory and restores them when those warps become non-divergent~\cite{ccc2015}.
\emph{Iteration Delaying} is a complementary compiler optimization to \textsc{darm}\xspace that delays divergent loop iterations~\cite{iterdelay2011} and can be applied following \textsc{darm}\xspace.
Recently, Damani~\textit{et al.}~ has presented a speculative reconvergence technique for GPUs similar to iteration delaying~\cite{spec_reconv_cgo20}.
\emph{Common Subexpression Convergence (CSC)}~\cite{common_subexpression_convergence} works similar to branch fusion but uses {\em branch flattening} (\textit{i.e.}~ predication) to handle complex control-flow.
In contrast, \textsc{darm}\xspace does not require predication to meld complex control-flow, thus more general than CSC.
\paragraph{Architectural Techniques}
Thread Block Compaction~\cite{tblockcompact} and Dynamic Warp Formation~\cite{dynamicwarp} involve repacking threads into non-divergent warps.
Variable Warp Sizing~\cite{varwarp} and Dynamic Warp Subdivision~\cite{warpsubdivision} depend on smaller warps to schedule divergent thread groups in parallel.
Independent Thread Scheduling helps to hide the latency in divergent paths by allowing to switch between divergent threads inside a warp~\cite{dualpath,multipath}. | {'timestamp': '2022-01-17T02:07:53', 'yymm': '2107', 'arxiv_id': '2107.05681', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05681'} | arxiv |
\section{Introduction}
\label{sec:Intro}
The relationship between amenities in or near residential, work or school–neighborhood environments and health is receiving increasing attention, given that these environments can influence health-related behaviors and subsequent outcomes.
Where spatial proximity to supermarkets is associated with diet, so too are recreational facilities associated with physical activity and fast food restaurants near schools associated with child obesity \citep{baek2016distributed,baek2017methods,kaufman2019neighborhood,kern2017neighborhood}.
Work in this area has been limited by the lack of knowledge of what geographic units are most relevant for exposure assessment, i.e. the well known modifiable unit areal problem (MAUP) \citep{fotheringham1991modifiable,spielman2009spatial,wong2009modifiable,guo2004modifiable,ji2009spatial,james2014effects}.
Additionally, there may also be measured or unmeasured person-level behaviors or characteristics that give rise to the ``uncertain geographic context problem'' (UGCP) \citep{MACINTYRE2002125,kwan2013beyond,kwan2018limits}.
Whereas the former establishes that using different spatial units or spatial scales to define exposure measures will yield different estimates of association, the latter acknowledges that the most relevant spatial unit may differ from place to place or subject to subject due to place or person characteristics such as predominant transport modes in a given area or vehicle ownership, among others.
\par
Recent work has begun addressing these issues by foregoing the pre-specification of the spatial unit used to construct exposure metrics \citep{baek2016distributed,peterson2018rstap}. Instead, the association between proximity to amenities of interest, broadly referred to as built environment features (BEFs), and subjects' outcomes is estimated as a continuous function of distance between subjects and amenities. Whereas typical models regress the outcome on a BEF metric that depends on a pre-defined scale, these new methods use all the pair-wise distances between subjects and BEFs as inputs to the model. Specifically,
in order to address the MAUP, an idealized smooth function $f(d)$ is used to represent the association between the health outcome of interest and a single BEF placed at distance $d>0$ from the subject.
Having $f(d)$ as the objective of inference enables the visualization of whether and how the association between availability of amenities and outcomes dissipates with distance, as well as estimation of the spatial scale, defined as the distance at which the association is negligible, i.e. $d: f(d) =0$.
\par
The function $f(d)$ has been modeled in different ways:
\cite{baek2016distributed} estimated $f(d)$ non-parametrically by first discretizing the distances into a grid, and using the count of distances within bins defined by the grid as predictors in a Distributed Lag Model (DLM), i.e., the count of distances within each bin are conceptualized as distributed lag predictors, indexed by the corresponding value of the grid. The coefficients corresponding to each distributed lag predictor are smoothed using splines, yielding estimates of $f(d)$ at the values of $d$ used to construct the grid. Alternatively, \cite{peterson2021spatial} modeled $f(d)$ parametrically, typically using exponential functions to enforce the substantive belief that the association between health outcomes and spatial availability of amenities monotonically decays across distance, e.g. $f(d) \propto \exp(-\frac{d}{\theta})$.
However, the estimation of $f(d)$ at the population level, as the previous methods propose, fails to account for the concerns the UGCP raises regarding unmeasured person-level behaviors or place-level factors that may determine subject – or location – specific spatial association.
\par Building upon their work in DLMs, \cite{baek2016hierarchical,baek2017methods} constructed a hierarchical DLM (HDLM) allowing for the estimated $f(d)$ to vary between subjects and or locations, according to pre-specified groups (e.g., different $f(d)$ by sex), as well as unexplained variation in the association (i.e., using the idea of random coefficients to estimate $f(d)$ for individual subjects).
However, the HDLM approach, has some disadvantages: (1) it uses discretized distances to estimate association across space, unnecessarily coarsening the exposure information; (2) it requires pre-specifying the groups where heterogeneity in the association may occur (covariates and or subjects); and (3) by enforcing that heterogeneity in the association estimates to occur at the subject-level through random effects, it loses possible gains in precision that could result from pooling subjects with similar levels of association.
\par
Motivated by the desire to identify schools where pupils may be at greater risk of obesity related to the proximity of fast food restaurants (FFRs), we propose a model that clusters schools-specific association curves, $f(d)$ according to the strength of association between the spatial proximity of nearby FFRs and child obesity. Clustering provides investigators and policymakers with a greater understanding of the kinds of relationships that exist between students and their environment as well as identifies schools where students may be at greater risk, as
identifying risk groups may help prioritize population level interventions.
The data for this motivating study consists of body weight status of children nested within schools across Los Angeles County during academic years 2001-2008.
Distances between schools and FFRs are calculated from geocoded school addresses, supplied by the California Department of Education, and geocoded FFR business addresses from the National Establishment Time Series Database\citep{walls2013national}
\par Our method uses the Dirichlet Process Mixture (DPM) prior and a spline basis function expansion to non-parametrically estimate both the number of cluster-BEF effects, and the nonlinear association functions across space, respectively. We name our method the Spatial Aggregated Predictor - Dirichlet Process, to reflect this dual non parametric estimation, but refer to it more generally as STAP-DP, given its potential for also modeling temporal exposures. Our approach is inspired by the work of \cite{rodriguez2014functional} and \cite{ray2006functional} on clustering functions using DPM family priors.
We use the penalized spline approach developed by \cite{o1986statistical} and further popularized by \citep{wahba1990spline,mgcv_wood} to construct the estimates of the association functions, and use the DPM to cluster the spline coefficients.
\par Section 2 describes the model that estimates homo- and heterogeneous BEF effects.
Section 3 studies the performance of the STAP-DP model in a variety of simulated data settings and discusses how the results may inform normative practice.
Section 4 describes the application of the STAP-DP model to the motivating study on child obesityin Los Angeles.
We conclude our work with a discussion of the model and future directions to explore.
\section{Model}
\label{sec:Model}
We now introduce the STAP-DP framework, describing how we incorporate the estimation of heterogeneous BEF effects into a regression framework. We limit our discussion to the estimation of only one BEF's effects in space, FFRs for example, as the extension to multiple BEFs is straightforward. We organize our discussion into four parts. First, we build intuition for our approach by defining the STAP estimated via spline basis functions at the population level, i.e., homogeneous effect. Then, we define how to extend the STAP model to estimate heterogeneous effects -- at the latent cluster level -- for a univariate outcome. In the final two sections we generalize the clustering framework for repeated outcome measures and discuss estimation.
\subsection{The STAP Model}
\label{sec:Model_Univariate}
Suppose a continuous outcome $Y_i$ ($i=1,...N$) and corresponding covariates $\bm{X}_i \in \mathbb{R}^{n \times p}$ are observed for a sample of $N$ subjects. Additionally, spatial data, $\mathcal{D}_i$ which contains distances, $d$, between subject $i$ and all FFRs within some substantively determined radius $R$, are also measured. The inferential objective is to estimate function $f(d)$, which represents the expected difference in the outcome associated with placing a single FFR at distance $d$ after adjusting for covariates $\bm{X}_i$. Defining $F(\mathcal{D}_i) := \sum_{d \in \mathcal{D}_i} f(d)$, as the aggregated FFR effect under the assumption of additivity, we complete the initial STAP model formulation:
\begin{align*}
Y_i &= \bm{X}_i^{T}\bm{\gamma} + F(\mathcal{D}_i) + \epsilon_i, \tag{1} \label{eqn:stap_general} \\
\epsilon_i &\stackrel{iid}{\sim} N(0,\sigma^2),
\end{align*}
\noindent where $\epsilon_i$ is the residual error, with variance $\sigma^2$.
As mentioned in Section \ref{sec:Intro}, there are a number of approaches to model $f(d)$. In this work, we propose to model $f(d)$ as a linear combination of basis functions, $\{\phi\}_{l=1}^L$, which allows us to rewrite $F(\mathcal{D}_i)$ as follows:
\begin{align*}
F(\mathcal{D}_i)&= \sum_{d \in \mathcal{D}_i} f(d) = \sum_{d \in \mathcal{D}_i} \sum_{l=1}^{L} \beta_l\phi_l(d), \label{eqn:f_def} \tag{2}
\end{align*}
where $\phi_l(d)$ is the evaluation of the distance through the $l$th basis function and $\beta_l$ is the corresponding regression coefficient.
In this work we use $L$ spline basis functions defined across a set of equally spaced knots, though other knot placements or basis functions could be used.
In order to avoid over fitting when $L$ is large, the regression coefficients are regularized through the use of a quadratic penalty on $\bm{\beta}$ implemented through a smoothing matrix $S$ and tuned by penalty parameter $\tau$.
We use the difference penalty matrices of \cite{eilers1996flexible}, a widely used spline penalty formulation.
\par Within a Bayesian paradigm, this penalty is equivalent to specifying a multivariate normal prior with improper precision matrix $\tau S$.
We adopt a variant of this Bayesian approach and, to improve computational efficiency in our more complex model formulations discussed in the next subsection, we first transform the spline basis function expansion matrix, $\Phi(d)$, such that the transformed coefficients can have independent normal priors \citep{wood2004stable,wood2016just}. While centering constraints are often imposed on $\Phi(d)$ to avoid collinearity with the intercept in $\bm{X}$, this constraint is not needed in our model (see supplementary material).
Given that $r_S =$rank($S)<L$, two precision parameters for the priors are used, one for the first $r_S$ coefficients and a second for the last $L-r_S$ coefficients:
\begin{align*}
\bm{\beta}_1 &\sim MVN_{r_S} \left (\bm{0},\sigma^2 \tau_1^{-1} \bm{I}_{r_S} \right ) \quad \bm{\beta}_2 \sim MVN_{L-r_S}(\bm{0},\sigma^2 \tau_2^{-1}\bm{I}_{L-r_S}) \tag{3} \label{eqn:prior}\\
\tau_z &\stackrel{iid}{\sim} \text{Gamma}(a_{\tau},b_{\tau}) \quad z = 1,2.
\end{align*}
In $(\ref{eqn:prior})$ we denote $\bm{\beta}_z$, $z=1,2$, as the regression coefficients in the penalty range and null space, respectively. Correspondingly, $\tau_1$ and $\tau_2$ are the respective precisions for these separate subsets of $\bm{\beta}$.
For ease of further exposition we define $\bm{\Lambda}$ as the diagonal covariance matrix which has $\tau_1^{-1}$ as the first $r_S$ diagonal elements and $\tau_2^{-1}$ as the last $L-r_S$ diagonal elements, so that the prior in (\ref{eqn:prior}) can be written simply as $\bm{\beta} \sim MVN_L(\bm{0},\sigma^2\bm{\Lambda})$.
We place independent conjugate Gamma priors on $\bm{\tau}= (\tau_1,\tau_2)$ so that both $\bm{\beta}$'s and $\bm{\tau}$'s conditional posterior distributions are available in closed form.
\subsection{STAP-DP with Univariate Outcomes}
In alignment with this work's goal to estimate heterogeneous effects, we replace $F_i(\mathcal{D}_i)$ with $F_i(\Dset)$ in (\ref{eqn:stap_general}) while allowing for clustering in the $f_i(d)$. Given that $f_i(d)$ is represented by the fixed spline functions and random coefficients $\bm{\beta}$, we implement this clustering goal by placing a DP prior on the vector of regression coefficients, $\bm{\beta}$, and associated penalty parameter, $\bm{\tau}$:
\begin{align*}
(\bm{\beta},\bm{\tau}) &\sim P \label{eqn:stapdp1} \tag{4}\\
P &\sim DP(\alpha,P_0)\\
P_0 &\equiv MVN_{L} \left(\bm{0},\sigma^2 \bm{\Lambda} \right )\times \prod_{z=1}^{2} \text{Gamma}(a_{\tau},b_{\tau}).
\end{align*}
In (\ref{eqn:stapdp1}), $P$ is a random measure drawn from Dirichlet Process $DP(\alpha,P_0)$, where $\alpha>0$ is a concentration parameter reflecting the variability of distribution $P$ around base measure $P_0$ \citep{ferguson1973bayesian,gelman2013bayesian}.
$P_0$ is chosen to retain the prior previously discussed in (\ref{eqn:prior}).
\par By placing the DP prior on $(\bm{\beta},\bm{\tau})$, clustering is induced on the $f_i(d)$ as can be seen from the stick breaking construction of the DP: $P = \sum_{k=1}^{\infty} \pi_k \delta_{(\bm{\beta}^\star,\bm{\tau}^\star)}(\cdot)$. In this representation $\pi_k$ represents the probability the $i$th observation is assigned to the $k$th exposure function and $\delta(\cdot)$ is the dirac-delta function. Each $\pi_k$, itself is composed of the ``broken sticks'' created from variables drawn from a Beta distribution: $\pi_k = v_k \prod_{u<k} (1-v_u); v_k \sim \text{Beta}(1,\alpha) $.
\par Combining all these pieces together, our proposed STAP-DP model for univariate outcome $Y_i$ takes the following form:
\begin{align*}
Y_i &= \bm{X}_i\bm{\gamma} + \sum_{d \in \mathcal{D}_i} \sum_{l=1}^{L} \beta_{il}\phi_l(d) + \epsilon_i \label{eqn:mod1} \tag{5}\\
\epsilon_i &\stackrel{iid}{\sim} N(0,\sigma^2)\\
(\bm{\beta},\bm{\tau}) &\sim P\\
P &\sim DP(\alpha,P_0) \\
P_0 &\equiv MVN_L\left(\bm{0}, \sigma^2 \bm{\Lambda} \right )\times \prod_{z=1}^{2}\text{Gamma}(a_{\tau},b_{\tau}).
\end{align*}
A final comment is warranted regarding the choice of the number and placement of the $L$ knots in constructing the splines. While our approach follows previous work in placing a sufficient number of knots equally across the domain of observed distances, deciding what number of knots is ``sufficient'' requires greater statistical judgement than in standard applications.
Clusters may be more difficult to detect when the dimension on which clusters are formed (i.e., number of coefficients) is large and the between-cluster differences are small (low signal effects).
Conversely, more clusters may be identified in a setting with a stronger signal and greater number of knots.
Thus, $L$ must be chosen to balance accuracy in both function estimation \textit{and} cluster discrimination.
\subsection{STAP-DP with Repeated Measurements}
\label{sec:Model_Multivariate}
Extending (\ref{eqn:mod1}) to correlated outcomes,
we consider the setting in which subjects are measured repeatedly over time, for $j=1,...,n_i$ occasions.
This results in outcome $Y_{ij}$ ($i=1,...,N,j=1,...,n_i)$ modeled as a function of covariates $\bm{X}_{ij}$, and their corresponding coefficients $\bm{\gamma}$. The distance set adopts the new visit-specific index as well, i.e., $\mathcal{D}_{ij}$, indicating it may vary over time; for instance FFRs may open and close between measurement occasions. Finally, a subset of $\bm{X}_{ij}$, $\bm{Z}_{ij}$, is included in the model, along with subject-specific coefficients $\bm{b}_i \sim MVN(0,\Sigma)$ to account for within subject variability in standard fashion \citep{fitzmaurice2008longitudinal}. Augmenting (\ref{eqn:stapdp1}) accordingly, we arrive at our final model:
\begin{align*}
\tag{6} \label{eqn:long1}
Y_{ij} &= \bm{X}_{ij}^{T}\bm{\gamma} + \sum_{d\in\mathcal{D}_{ij}}\sum_{l=1}^{L}\beta_{il}\phi_l(d) + \bm{Z}_{ij}^{T}\bm{b}_i + \epsilon_i\\
\bm{b}_i & \stackrel{iid}{\sim} N(\bm{0},\Sigma)\\
\epsilon_i &\stackrel{iid}{\sim} N(0,\sigma^2)\\
(\bm{\beta},\bm{\tau}) &\sim P\\
P &\sim DP(\alpha,P_0) \\
P_0 &\equiv MVN_L \left ( \bm{0}, \sigma^2 \bm{\Lambda} \right )\times \prod_{z=1}^{2}\text{Gamma}(a,b).
\end{align*}
\subsection{Estimation}
\label{sec:Model_Estimation}
In order to fit models of the form described in (\ref{eqn:stapdp1}) and (\ref{eqn:long1}), we truncate the DP so that a blocked Gibbs sampler can be used to draw samples from the posterior \citep{gelman2013bayesian}.
While this sampler is fairly straightforward, it bears mentioning that $\Phi(d)$ has to be adjusted at each iteration of sampling so that any DP components associated with 0 or some small number of observations are not included in the usual matrix inversion used to estimate the mean of the conditional posterior distribution for the regression coefficients, $\bm{\beta}^{*} = [\bm{\gamma},\bm{\beta}]^{T}$.
Instead, coefficients for those low-member cluster components are sampled with draws from the prior. For example, if on the $m$th iteration, none of the $N$ observations are assigned to the $k$th DP component, then the samples of the spline regression coefficients for that iteration, $\bm{\beta}_k^{(m)}$, are drawn from a $MVN_L(\bm{0},\sigma^2\bm{\Lambda}_k)$ prior, where $\bm{\Lambda}_k$ is the cluster specific covariance matrix, and the columns of zeros that would otherwise be included in $\Phi(d)$ are omitted.
\par We present the closed form conditional posteriors and associated algorithm in the Supplementary Material. Our algorithm is implemented in C++ which can be called from our R package \texttt{rstapDP} \citep{rstapDP,supp}.\par For both our simulations and California data we use \texttt{rstapDP} to fit the STAP-DP in \texttt{R} (v.4.0.2) \cite{Rlanguage} on a MacOS Catalina operating system with a 2.8 GhZ Quad-Core Intel Core i7 processor.
\section{Simulations}
\label{sec:Simulations}
\subsection{Simulation Design}
For a given sample size, the ability of the STAP-DP model to correctly classify subjects depends on (a) the proportion of subjects belonging to that cluster, (b) the difference in the $f_i(d)$ functional forms, and (c) the distribution of distances (i.e., exposure information) present within each cluster.
As the first of these three principles follows straightforward sample-size intuitions, in this section we study the STAP-DP's ability to correctly recover cluster specific functions,$f_i(d)$, and cluster partitions in the latter two settings. Using simulated data we vary: (i) cluster effect size and (ii) distance distributions in order to see how these may impact correct cluster classification.
We focus on evaluating cluster classification accuracy as it is the upstream predictor of all remaining model components, like the estimation of the $f_i(d)$, which are all standard Bayes estimators conditional on the correct cluster classification.
\par
We evaluate our method's ability to correctly classify subjects using a partition loss function developed by \citep{binder1978bayesian} and used regularly in DP and other mixture model applications where label-switching may be of concern \citep{lau2007bayesian,wade2018bayesian,rodriguez2008nested}. Our employment of the loss function equally weights correct and incorrect classification, using the subjects' true and estimated class indicators, $\zeta_i,\hat{\zeta}_i$, respectively:
\begin{align*}
\tag{7} \mathcal{\psi}(\bm{\zeta},\hat{\bm{\zeta}}) = \sum_{(i,i'); i< i' < N} I(\zeta_i = \zeta_{i'},\hat{\zeta}_i \neq \hat{\zeta}_{i'}) + I( \zeta_i \neq \zeta_{i'},\hat{\zeta}_i = \hat{\zeta}_{i'}).\label{eqn:loss}
\end{align*}
\noindent Conceptually, (\ref{eqn:loss}) tallies the number of times that observations $i$ and $i'$ are incorrectly assigned to different clusters, when they in fact belong in the same cluster, as well as tallies when they are incorrectly assigned to the same cluster.
\par In each simulation setting discussed below, we generate 25 datasets and then fit the STAP-DP model shown in (\ref{eqn:stapdp1}), truncating the DP at K= 50 and using weakly informative Gamma(1,1) priors on $\sigma^{-2},\alpha, \tau_1$ and $\tau_2$, respectively. We draw 2000 samples from the posterior distribution for inference via Gibbs Sampling using \texttt{rstapDP} after discarding 2000 initial samples for burn-in.
Across all 25 simulations we evaluate the loss (\ref{eqn:loss}) across all $M=2000$ iterations of the posterior samples drawn via Gibbs sampling.
Given that the loss function does not have a standard range, we normalize the loss results by the maximum loss across all simulation settings, so as to make the results more interpretable relative to one another. We have organized the files used to run the simulations in the STAPDPSimulations R package available via \href{ https://github.com/apeterson91/STAPDPSimulations}{Github}.
\subsection{Cluster Effect Size}
Our first simulation study focuses on model performance as a function of the difference between two clusters' $f(d)$, defined in (8) below, with each observation having a 50\% probability of being assigned to either of these clusters.
The cluster function set-up is intended to mimic a hypothetical high and low risk population scenario, in which subjects with equivalent exposure to the same BEFs experience different effects according to which risk population they belong.
For each subject we generate a random number of distances uniformly so that the average number of BEFs is 15. Conditional on the number of distances, the distances themselves are then generated according to the ``Skew'' distribution shown in Figure S1 in the Supplementary Information. This distribution was selected in order to test our model's performance under a ``worst case scenario'', given that with this distribution there is relatively less exposure information at the distances where the BEF effects are non-zero.
Specifically, the generative model takes the following form:
\begin{align*}
Y_i &= 26 + .5Z_i + \sum_{d \in \mathcal{D}_i} f_{\zeta_i}(d) + \epsilon_i \tag{8} \label{eqn:sim}\\
\epsilon_i &\sim N(0,\sigma^2=1) \qquad i = 1,...,200\\
f_1(d) &= \exp\left \{ \left (\frac{-d}{.5} \right)^5 \right\} \qquad \\
f_2(d) &= \nu \exp\left \{ \left (\frac{-d}{.5} \right)^5 \right\} \qquad \nu = (0,.25,.5,.75)\\
P(\zeta_i=1) &= P(\zeta_i=2)=.5;
\end{align*}
where $Z_i$ is a covariate generated as a fair Bernoulli random variable, $\zeta_i$ is the subject specific cluster label indicating the true BEF effect, $f(d)$, for the $i$th observation, and $\nu$ represents the varying effect size at $d=0$.
\par The relative loss as a function of the effect size $\nu$ is shown in Figure \ref{fig:effect_loss}. As expected, one can see a decrease in relative loss and consequently improved classification as the effect size increases.
\begin{figure}[H]
\centering
\includegraphics[width = .6
\textwidth]{Figures/CA_effectsize_loss.pdf}
\caption{Relative loss as a function of the difference in effect size: $(1-\nu)$; see (8) for more details. Point estimates and error lines represent median, 2.5 and 97.5 quantiles of loss across simulations, respectively.}
\label{fig:effect_loss}
\end{figure}
\subsection{Distance Distributions}
As our method non-parametrically estimates cluster functions $f_i(\mathcal{D}_i)$ across continuously measured space using a basis function expansion, correct estimation of the function requires there to be BEFs observed at the relevant distances, $d: f(d)\neq 0$, within the study area of interest. Of course these ``relevant'' distances are not known \textit{a priori} and so it is to the benefit of the investigator to err on the side of caution in specifying a larger study area if possible.
However, despite any preparatory work that may be done to ensure an adequate area is included at the level of the sample study, it is not clear how differing distributions of distances at the latent cluster level may impact inference. For example, will suburbanites' lower exposure to proximate FFRs impact the ability of the stapDP model to discern the impact of FFRs on their health relative to their more exposure rich urban counterparts? For this reason our second simulation study examines how exposure to different distance distributions may impact classification.
\par
We study this problem by considering three different generative distance distributions which we label ``Uniform'',``CA'' and ``Skew''.
The first, straightforwardly, refers to the idealistic - but unrealistic - scenario in which there is equivalent information available at all distances within the study area.
The second two cases refer to more realistic situations in which there are more likely to be a higher number of BEFs found further away from the subject than close by – a consequence of area's quadratic growth as a function of distance.
We create the first of these skewed distributions, ``CA'', by using maximum likelihood to fit a beta distribution to the distribution of distances in our motivating California data distance distribution and the second by altering a beta distribution to be a more extreme version of the first.
We generate distances under each distribution for each cluster in order to examine how differing exposure patterns between clusters impact cluster classification. The densities of each of these distributions can be found in Figure S1 in the supplementary material.
Since the exposure information depends both on the distribution of distances and the number of BEFs, we generate scenarios where the amount of information increases as a function of the number of BEFs within the same distribution. We simulate data under the same model as proposed in (\ref{eqn:sim}), with $\nu=0.25$, to illustrate how a substantial, but not obvious, difference in cluster functions manifest across the varying distance distribution settings. Fitting our STAP-DP model under the priors and sampler settings previously described, we plot the results below in Figure \ref{fig:ddist_loss}.
\begin{figure}[H]
\centering
\includegraphics[width = \textwidth]{Figures/CA_rel_loss.pdf}
\caption{Relative loss as a function of different distance distributions. Points and lines represent median, 2.5 and 97.5 quantiles of loss, respectively. Row labels represent the distance distribution of the lower effect size cluster and columns that of the higher effect size cluster.}
\label{fig:ddist_loss}
\end{figure}
Figure \ref{fig:ddist_loss} shows a number of patterns worth highlighting.
First, across all distance distributions we observe a decrease in loss as the number of built environment features increases.
This is as expected – more information or exposure results in a more easily detectable signal.
Further, distance distribution combinations that include more information result in lower levels of relative loss compared to more skewed distance distributions.
There are number of cases where this can be seen in Figure \ref{fig:ddist_loss}, the most obvious being the top-left diagonal panel where both clusters have Uniform distance distributions; this has the lowest loss values across all panels due to the relative abundance in exposure information.
This pattern holds when comparing to the more skewed distributions: The uniform-CA combination has higher error than the uniform-uniform combination when there are a relatively small number of built environment features present.
\section{Fast food restaurants near schools and child obesity among public school students in Los Angeles}
\label{sec:Results}
There is a pressing need to understand contextual determinants of child obesity, in order to implement population level strategies to reduce and prevent it\citep{IOM}. The food environment near schools has been proposed and studied as a contextual factor that influences children's diet, and thus obesity \citep{currie2010effect,davis2009proximity,sanchez2012differential,baek2016distributed}. We use data on body weight of children attending public schools in Los Angeles, CA, along with data on the locations of FFRs as a marker of the food environment near schools, and apply our proposed method to identify schools where children may be at higher risk of obesity, related to food environment exposures. Identifying these schools may help prioritize or tailor population-level interventions to address child obesity.
\subsection{Data Description}
\label{sec:Data}
Every year public schools in the State of California collect data on the fitness status of pupils in 5th, 7th and 9th grade, as part of a state mandate, using the Fitnessgram battery of tests \citep{fgram}.
Child-level data available for our analysis were collected during academic years 2001-2008 on 5th and 7th graders, and consists of children's weight (Kg) and height (m) and, and the following categorical covariates: sex, race-ethnicity, fitness status (unfit, fit, fit above standard), and grade level. Weight and height are transformed to body mass index (Kg/m$^2$), and standardized to BMIz scores according to age- and sex-specific growth curves published by the United States' Center for Disease Control. In contrast to adults, standardization is needed when analyzing data from children of different ages, given children's rapid growth.
To aid in managing the large database, and given that all child-level covariates are categorical, the dataset is ``collapsed'' so that each row represents a group of children within each school defined by the cross-classification of categorical child-level characteristics described above. The average BMIz of children in the group is the outcome of interest. Given the categorical nature of the covariates and our use of weighting by the size of the group represented by each row (below), this approach yields exactly the same results as would be obtained if data had not been grouped, thus avoiding biases in an ecological analysis \citep{schoenborn2002body}.
\par
Data on school-level characteristics are also available from the CDE website (see Table \ref{tbl:cluster}), and, importantly, so is the geocode of the school.
School geocodes were used for two purposes.
First, the geocodes were used to link schools to census tract level covariates. Second, the school geocodes were used to calculate the distances between the school and the geocoded location of each FFR in the LA area.
FFRs were identified from the National Establishment Time Series (NETS) database \citep{walls2013national}, using a published algorithm that classifies specific food establishments as FFRs \citep{auchincloss2012improving}.
Only FFRs within five miles of schools were kept for this analysis.
This distance was chosen to be a conservative as previous work estimated that the distance at which FFRs cease to have an effect on childhood obesity is approximately one mile \citep{baek2016distributed}.
\subsection{Los Angeles STAP-DP Model}
We fit models estimating both the population-level and latent cluster-level effects – STAP and STAP-DP models, respectively. Given the available data consisting of subgroups of children defined by the cross-classification of categorical covariates, we use the standardized average BMI within the subgroup as the outcome. The models adjust for the student group and school-level covariates listed in Table \ref{tbl:cluster}.
Denoting these covariates as $\bm{X}_{ijq}$ for student group $q=1,...,n_{ij}$, measured at year $j=2001,...,2008$, attending school $i=1,...,N$, and using notation as described in (\ref{eqn:long1}) our model for analyzing the Los Angeles data is:
\begin{align*}
\text{BMIz}_{ijq} &= \bm{X}_{ijq}^{T}\bm{\gamma} + F_i(\mathcal{D}_{ij}) + b_{i1} + b_{i2}\frac{\text{year}_{ij}}{10} + \epsilon_{ijq}, \tag{9} \label{eqn:LA}\\
\epsilon_{iqj} &\sim N\left(0,\frac{\sigma^2}{n_{iqj}}\right), \\
\bm{b}_i &\sim MVN_2(\bm{0},\Sigma),
\end{align*}
\noindent where $n_{ijq}$ represents the number of students in student group $q$ during year $j$ at school $i$. Given that FFRs may open or close during the study period, $\mathcal{D}_{ij}$ represents the distances between school $i$ and FFRs available within 5 miles during year $j$.
Similar to our simulations, we place a weakly informative Gamma(1,1) prior on each of the penalty parameters in $\bm{\tau}$, associated with each cluster regression coefficients, the residual precision $\sigma^{-2}$, and the concentration parameter $\alpha$.
The Gamma(1,1) prior on the concentration parameter is a common prior setting in the DP literature, reflecting the \textit{a priori} expectation that the concentration parameter is $1$, so that fewer clusters are favored \citep{rodriguez2008nested,gelman2013bayesian}.
Additionally, we place a non-informative Jeffrey's prior on the covariance matrix for the school specific $\bm{b}_i$ vector: $p(\Sigma^{-1}) \propto \mid \Sigma \mid^{\frac{3}{2}}$.
Estimation is conducted through \texttt{rstapDP}, drawing 2000 samples from each of 2 independent MCMC chains after 8000 samples have been iterated as ``burn-in'' on each chain. We check convergence via $\hat{R}$ diagnostic \cite{vehtari2020rank} and visually inspecting traceplots.
We use $L=7$ coefficients in our spline basis function expansion, and similarly use this basis to estimate the $f_i(d)$ on a grid of values, calculating the 95\% point-wise credible interval at each distance grid point.
We also calculate the posterior probability of co-clustering which can be arranged in a matrix $\bm{P} \in \mathbb{R}^{N\times N}$ so that $\bm{P}_{i,i'} = P($ school $i$ is co-clustered with school $i'$ across post burn-in iterations$)$. School cluster characteristics are tabulated using the cluster mode school assignment calculated using (\ref{eqn:loss}) as implemented in the \texttt{rstapDP} package via the \texttt{assign\_mode} function.
\par
For comparative purposes, we fit a model similar to (\ref{eqn:LA}) in all ways save for restricting the $f_i(d)$ to be estimated at the population level - $f(d)$. We fit this model using Hamiltonian Monte Carlo via the \texttt{rsstap} R package \citep{rsstap}, drawing 1000 samples after 1000 warm-up across 4 independent MCMC chains. Convergence is assessed via $\hat{R}$ diagnostic and we calculate the analogous posterior estimate for $f(d)$ across the same grid of distance values.
\subsection{Los Angeles Results}
Figure \ref{fig:f_estimates} shows four functions corresponding to the 3 estimated cluster functions from the STAP-DP model, as well as the 1 homogeneous effect estimate.
We name the three cluster effects ``Majority'', ``High Risk'' and ``Low Risk''. These names derive from the proportion of schools assigned to the cluster as well as the relative effect size associated with the function at and around distance 0 mi from the school: In the cluster labeled ``High Risk'', one additional FFR placed at distance 0 from a school is associated with an expected 0.46 higher BMIz among students attending those schools (95\% CI: 0.36, 0.58), all else equal. In contrast, placing one FFR at distance 0 from the schools assigned to the ``Low Risk'' cluster is associated with lower BMIz score, by -0.15 (95\% CI: -0.17,-0.12), all else equal. The analogous values for the ``Majority'' and homogeneous function estimates, are 0.01 (95\% CI: 0.00,0.02) and 0.01 (95\% CI: 0.01,0.0132), respectively. In all clusters, the estimated associations rapidly decay with increasing distance, with all association estimates effectively zero by 1 mile.
\begin{figure}[H]
\centering
\includegraphics[width = \textwidth]{Figures/risk_BMI.png}
\caption{Changes in student BMI associated with FFR exposure across 5 mi. Line and band represents median and 95\% posterior credible interval. The number following Each cluster label represents the median proportion of schools that are assigned to that cluster. Dotted line (colored red online) represents 0 reference line. Please note that the y-axis is different between the two rows.}
\label{fig:f_estimates}
\end{figure}
We now turn our attention to the matrix of co-clustering probabilities $\bm{P}$ which we visualize using a heat-map in Figure S2 in the Supplementary material, after applying \cite{rodriguez2008nested}'s hierarchical sorting algorithm to group schools with similar co-clustering probabilities together.
The estimate of co-clustering probabilities shows approximately 550 schools (90\%) are consistently co-clustered within one of the three clusters, reflecting a high degree of model certainty in cluster configurations for these schools.
The remaining $\approx$ 50 schools show a greater uncertainty between being classified in the ``Majority'' or ``Low Risk'' cluster.
This uncertainty likely stems from an insufficient number of FFRs present within the relevant $\approx$ 1 mile distance from schools, where the cluster effects are most discernibly different.
\par Further examination of the school characteristics associated with each cluster details several suggestive, though not conclusive between-cluster differences (Table \ref{tbl:cluster}).
Differences between the three clusters of schools are fairly muted, with summary statistics across student- and school-level measures describing similar student populations and levels of median household income and education amongst the neighborhoods of schools in each cluster. The most noteworthy differences amongst the clusters are in the number of FFRs within $\frac{1}{2}$ mile of the school – lower in the high risk group as compared to the other two clusters – and the total enrollment – higher in the low and high risk groups as compared to the majority cluster.
\begin{table}[H]
\resizebox{\textwidth}{!}{\begin{tabular}{lrrrr}
\toprule
& \textbf{Overall} & \textbf{Majority} & \textbf{Low Risk} & \textbf{High Risk} \\
\hline
\# Students & 752,529 & 655,017 & 62,573 & 34,939 \\
\% Obese & 52 & 52 & 51 & 46 \\
Average BMIz & 0.84 & 0.85 & 0.78 & 0.71 \\
\% Female & 49 & 49 & 49 & 49 \\
Race/Ethnicity & & & & \\
\quad \% Asian & 3 & 2 & 2 & 7 \\
\quad \% Black & 10 & 10 & 14 & 13 \\
\quad \% Hispanic & 79 & 80 & 73 & 62 \\
\quad \% White & 8 & 8 & 10 & 18 \\
\textbf{School Characteristic}$^{1}$ & N = 593 & N = 535 & N = 36 & N = 22\\
\midrule
Total Enrollment (100's of students) & 7.7 (5.0, 13.0) & 7.5 (4.9, 12.8) & 10.7 (6.3, 15.4) & 10.7 (6.2, 12.7)\\
\# FFRs within 1/2 mile & 23 (8, 45) & 23 (8, 46) & {24} (8, 48) & 14 (5, 24)\\
\# FFRs within 1 mile & 101 (69, 143) & 103 (68, 144) & 92 (70, 126) & 89 (74, 115)\\
\% Free or Reduced Price Meals & 0.86 (0.69, 0.94) & 0.86 (0.69, 0.94) & 0.85 (0.75, 0.93) & 0.80 (0.58, 0.95)\\
Education$^{2}$ & 14 (5, 27) & 14 (5, 28) & 13 (7, 25) & 13 (5, 23)\\
Income$^{3}$ (1000 USD) & 34 (25, 49) & 34 (25, 49) & 33 (28, 52) & 32 (25, 55)\\
School Type & & & & \\ \hline
\quad Elementary & 468 (79\%) & 427 (80\%) & 26 (72\%) & 15 (68\%)\\
\quad K-12 & 7 (1.2\%) & 7 (1.3\%) & 0 (0\%) & 0 (0\%)\\
\quad Middle & 90 (15\%) & 75 (14\%) & 9 (25\%) & 6 (27\%)\\
\quad High School & 12 (2.0\%) & 11 (2.1\%) & 1 (2.8\%) & 0 (0\%)\\
\quad Other & 16 (2.7\%) & 15 (2.8\%) & 0 (0\%) & 1 (4.5\%)\\
Urbanicity & & & & \\ \hline
\quad Suburban & 75 (13\%) & 66 (12\%) & 6 (17\%) & 3 (14\%)\\
\quad Urban & 518 (87\%) & 469 (88\%) & 30 (83\%) & 19 (86\%)\\
\bottomrule
\end{tabular}}
\caption{Characteristics of children and schools in each cluster, assigned using the mode cluster\\
\textsuperscript{1}Statistics presented: Median (IQR); n (\%) \\
\textsuperscript{2} Percent of individuals 25 years or older within the school's census tract with at least a bachelors degree.\\
\textsuperscript{3} Median Household Income among residents in the census tract where the school is located.}
\label{tbl:cluster}
\end{table}
\par The lack of substantial differences in measured characteristics between these two clusters is noteworthy, suggesting that none of the observed characteristics appear to modify the obesity risk associated with FFR exposure. Although prior research shows that area-level education and income modify the effects of child obesity interventions, for instance, the protective effects of socioeconomic factors do not appear to extend to children's risk of obesity as due to proximate FFR exposure – at least within this population. This lack of difference in socioeconomic characteristics suggests that there are unmeasured variables that account for the heterogeneous FFR effects. One potential unmeasured factor could be the type of FFRs proximal to the schools, e.g. chains vs non-chain FFR's. Another possibility could be unmeasured student-level measures of wealth – which may modify obesity risk – but we are not able to account for in our analysis.
\section{Discussion}
\label{sec:Discussion}
This work proposed a modeling approach to identify heterogeneity in distance-dependent BEF effects.
By allowing flexibility both across space and identifying subgroups of subjects with different effects, this modeling framework addresses two problems raised in the built environment literature, namely the MAUP and the UGCP, respectively. The modeling approach was shown to work well in both simulated data, as well as the data that motivated this work, concerning children's BMI and proximity to FFRs near their schools.
While spatial point pattern built environment data are the primary motivation for this methodology, it could be also be applied to temporal or spatio-temporal data, the latter which we discuss in greater detail below.
\par
Similar to the HDLM proposed by \cite{baek2016hierarchical}, we seek to allow for differences across subjects, or other substantively defined groups like schools, in the BEF associations across space.
In contrast to that work, we pool subjects with similar association effects through the DPM, allowing us to identify latent risk subject groups.
\par
In simulations our model demonstrated classification robustness to differing distributions of distances and expected improvement in classification due to increased information through BEF exposure or effect size.
Our analysis of Fitnessgram data illustrated how one can analyze these data in terms of the spatial effects estimated as well as the characteristics associated with each latent cluster.
The software to fit this model and perform the necessary auxiliary functions is freely available through our R package \texttt{rstapDP} \citep{rstapDP}.
\par
There are a number of future directions with which to take this work.
One obvious direction would be to extend the modeling framework for more general exponential family error distributions, though this makes estimation more difficult, as the posterior distribution of $\bm{\beta}$ is no longer available in closed form.
Work by \cite{ferrari2020modeling} has used a Riemann Hamiltonian Monte Carlo sampler in this context for models similar to ours, without smooth functional terms. This could provide one avenue to pursue. Another direction to explore would be to incorporate temporally indexed BEF data to enable spatio-temporal function estimation via tensor product of the spline basis function expansion used here. This approach would allow for cluster estimates across space and time, increasing the dimensionality and consequently, relevancy, of this work to more precisely target and understand how environments shape health and health behaviors across both time and space.
\par
Finally, while there have been numerous methods to identify associations between subjects and BEF exposure we believe this to be the first to utilize techniques in both the Bayesian and functional non-parametric literature to identify heterogeneous BEF effects across a population.
\section*{Acknowledgements}
This research was partially supported by NIH grants R01-HL131610 (PI: S\'anchez) and R01-HL136718 (MPIs: Sanchez-Vaznaugh and S\'anchez).\vspace*{-8pt}
\bibliographystyle{unsrtnat}
| {'timestamp': '2021-07-14T02:07:46', 'yymm': '2107', 'arxiv_id': '2107.05805', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05805'} | arxiv |
\section{Introduction}
\label{intro}
Healthcare is an extremely promising area for applying machine learning solutions -- clinical support systems can aid physicians with decision making, text-based solutions can help match patients to relevant clinical trials, and ML systems can save lives by identifying patterns indicative of sepsis, stroke, or cancer. However, the healthcare domain also presents immense legal and ethical considerations, and model mistakes can cost patient lives. Clinical stakeholders not only need to know that models have been faithfully developed, but they also desire transparency in the output of the model so that they can more easily diagnose model failures. A lack of explainability in healthcare, especially clinical decision support models, has been criticized \cite{10.1001/jama.2018.17163}, leading to additional innovation and progress in the development of explainable solutions \cite{lauritsen2019explainable}.
Historically, a trade-off between model performance and explainability has been described, and lower performing yet explainable models are often preferred to more sophisticated black box models due to lack of trust or the presence of strict transparency requirements (e.g. regulatory constraints). To address this, model-agnostic \emph{post hoc} explainability methods such as LIME \cite{ribeiro2016why} and SHAP \cite{lundberg2017unified} were developed, where a second model is trained to explain the original predictions. However, there have been issues reported with these methods: they do not always faithfully describe the original model's behavior and can give different explanations for similar examples \cite{alvarezmelis2018robustness}. Recent efforts, namely \cite{article}, call for the use of inherently interpretable models in situations where human understanding is necessary -- especially when consequences from undue faith in model output can be dire. These methods generally produce sparse models which allow human stakeholders to gain understanding about the broader system in which the model operates, as well as understand precisely how the model produces each prediction.
Natural language processing (NLP) presents a unique modeling and interpretability challenge. Many traditional methods of text preparation are transparent in nature, but as Transformer-based models \cite{vaswani2017attention} have gained popularity, we continue to see the boundaries of black-box modeling pushed. This raises a pressing issue for data scientists and their stakeholders within the healthcare domain: how should we appropriately balance the need for well-performing models with the desire for human interpretability of models and their outputs?
With such a wide variety of available tools, it should also be noted that the use of these techniques should be tailored to the audience -- for example, data scientists may be interested in interactively exploring neuron activations, while a physician may be interested in the features present in a medical record that contributed to a clinical decision.
\subsection{Interpretability versus Explainability}
In Rudin's work \citeyearpar{article}, she defines ``interpretable" machine learning as the use of models which themselves are fully interpretable by human users, as opposed to using ``explainability" techniques to understand the behavior of non-interpretable models. We follow these definitions throughout, although we acknowledge that there is some degree of gray area with certain attribution methods.
Importantly, neither of these concepts are in any way causal -- all of the methods in this paper should be used to gain insight into how a specific model works, rather than providing any understanding of underlying causal structures of the broader system in which the models operate.
\subsection{Contributions}
The major contributions of this work are as follows:
\begin{itemize}
\itemsep=-.2em
\item Quantifying the quality of available explanation methods using infidelity \cite{yeh2019infidelity}, generalizing perturbation methods for local Lipschitz \cite{alvarezmelis2018robustness} on text classification, and making these methods available for use in open-source form
\item Comparing the performance of traditional algorithms with interpretable ML techniques and state-of-the-art methods in a practical case study in clinical text classification
\item Reaching state-of-the-art performance on the mortality prediction task (among models without additional MIMIC-specific pretraining) using BigBird \cite{zaheer2021big}
\item Discussing the distinction between \emph{interpretability} and \emph{explainability}, practical issues in measuring and implementing various explainable and interpretable algorithms, and particularly the challenges facing practitioners within the healthcare industry
\end{itemize}
\section{Experiment Setup}
\label{setup}
\subsection{Data}
Given the sensitive nature of healthcare data, few openly accessible datasets of clinical text exist for broad research use. In collaboration with Beth Israel Deaconess Medical Center, Johnson et al. introduced MIMIC-III \citeyearpar{Johnson2016} -- a database containing deidentified electronic medical record (EMR) output of Intensive Care Unit (ICU) stays, including structured data elements of medication and treatment as well as unstructured clinical text. Because MIMIC-III is the only publicly available data source of its type and scale, it frequently serves as the basis for peer reviewed studies which make use of EMR data. Here, we utilize the unstructured discharge summaries for our classification task.
\subsection{Classification Task}
We selected one task in order to compare interpretable features across model types and explainability methods within the context of a practically relevant use-case. We use the single-label, binary classification of in-hospital mortality prediction from simulated admissions notes. This benchmark was established in Van Aken et al. \citeyearpar{van-aken-etal-2021-clinical}, and we follow their process of data preparation. Details about this task dataset are provided in supplementary material\textsuperscript{\ref{supfoot}}.
\section{Methods}
\subsection{Classifiers}
We include several classifiers with varying levels of complexity and interpretability:
\begin{itemize}
\itemsep=-.2em
\item Logistic Regression (LR)
\item Random Forest (RF) \cite{breiman2001random}
\item Explainable Boosting Machine (EBM) \cite{nori2019interpretml}
\item DL8.5 \cite{Aglin_Nijssen_Schaus_2020}
\item Boosted Rule Sets \cite{FREUND1997119}
\item Bayesian Rule Lists \cite{yang2017scalable}
\item Optimal Classification Trees \cite{10.1007/s10994-017-5633-9}
\item CORELS \cite{angelino2018learning}
\item BigBird \cite{zaheer2021big}
\end{itemize}
\subsection{Explainability}
For our traditional models (LR, RF, EBM), we selected two popular \emph{post hoc} explainability methods: Local Interpretable Model-agnostic Explanations (LIME) \cite{ribeiro2016why} and SHapley Additive exPlanations (SHAP) \cite{lundberg2017unified}. Since some of our models are also inherently interpretable (LR and EBM), we were also able to compare \emph{post hoc} explanations to the true local explanations.
Transformer models are a rapidly evolving area of active research, and efforts are ongoing to develop explainability techniques for better understanding their underlying processes. Input attribution methods show importance of input tokens, illustrating the degree to which each token contributed to a given prediction. Several algorithms exist for performing input attribution with deep learning models: saliency \cite{simonyan2014deep} and integrated gradients \cite{sundararajan2017axiomatic} are somewhat agnostic methods which use various backpropagation features to perform attribution, while other methods exist for more specific purposes (e.g. deconvolution and GradCAM for computer vision). In addition to these methods, SHAP and LIME are compatible for \emph{post hoc} explainability with deep learning models -- however, both have been shown to possess worse qualities than techniques with properties native to deep learning \cite{alvarezmelis2018robustness}.
Along with the growing trend of Transformer interpretability features, researchers have created a number of visualization techniques to highlight various behaviors (self-attention weights, activations, etc.). BertViz \cite{vig-2019-multiscale} and Ecco\footnote{Accessed via \url{https://github.com/jalammar/ecco}} \cite{alammar2020explaining} are two libraries which provide useful front-ends for visualizing such behaviors within Transformer models, and LIT \cite{tenney2020language} is a more general framework for practitioners to visualize and perform behavioral testing on various NLP models.
\subsection{Explanation Quality Metrics}
With a variety of options available for input attribution and local explainability for ``black-box" models, a user will naturally wonder which method best represents the underlying mechanisms of the model. There are a handful of metrics which seek to quantify the quality of model explanations \cite{electronics10050593}, however there is no single metric which will adequately cover all aspects of interpretability and apply to all contexts. For example, parsimony of the global explanations (i.e. the inherent human interpretability of a model's structure) may be more important when developing clinical guidelines, while fidelity of prediction explanations might adequately capture the needs of a human-in-the-loop ML system.
For our case study, we searched for metrics which measure various components contributing to the quality of \emph{post hoc} explanations provided through input attribution methods (e.g. SHAP, integrated gradients, etc.).
\subsubsection{Generalizing Local Lipschitz}
Local Lipschitz \cite{alvarezmelis2018robustness} is an explanation quality metric which measures the relative change in attributions introduced by relatively small perturbations in the model input. This metric is closely related to the notion of a particular explanation method's sensitivity when slight changes are introduced -- if the input changes by some small amount, then we would presume that the explanations should not change drastically. The formula for local Lipschitz is given as follows:
$$ \hat{L}(x_i) = \argmax_{x_j \in B_\epsilon(x_i)}
\frac{||f(x_i) - f(x_j)||_2}{||x_i - x_j||_2}$$
One challenge came to light when applying this metric to text data: the concept of a \emph{local neighborhood} is difficult to define within the context of raw text -- we can measure the distance between vectorized documents through metrics such as $\ell2$ distance or cosine similarity, but there is no consistent radius ($\epsilon$ in the formula) which can be equivalently applied to models with different preparation types (e.g. TF-IDF document vectors and a sequence of word embeddings). We address this issue by introducing a text perturbation method based upon token replacement via nearest neighbor sampling. Pseudocode for our document perturbation method is given in Algorithm ~\ref{alg:perturbation}. Each token -- a single word in a document to be vectorized, or a single token ID to be fed into a language model -- has probability $\pi$ of being selected for replacement, and each selected token is replaced by sampling from its $k$ nearest neighbors in vector space. -- in this description, \verb+sample_neighbors+ is simply shorthand for sampling a replacement token from its closest neighbors. For traditional methods we use a word2vec model \cite{rehurek_lrec, mikolov2013efficient} trained on the mortality training set. For the BigBird model, we construct a distance matrix of tokens using pairwise $\ell2$ distance between entries within the language model's word embedding layer.
\begin{algorithm}[tb]
\caption{Text Perturbation}
\label{alg:perturbation}
\begin{algorithmic}
\STATE {\bfseries Input:} document $Doc$, sampling probability $\pi\in [0, 1]$, number of nearest neighbors to consider $k>0$
\STATE {\bfseries Output:} modified document $modifiedDoc$, with tokens randomly replaced
\STATE Initialize $modifiedDoc = [\ ]$.
\FOR{$token$ {\bfseries in} $Doc$}
\IF{$random.uniform() \leq \pi$}
\STATE $replacement = \operatorname{sample\_neighbors}(token, k)$
\STATE $modifiedDoc.append(replacement)$
\ELSE
\STATE $modifiedDoc.append(token)$
\ENDIF
\ENDFOR
\end{algorithmic}
\end{algorithm}
Once our perturbation method is defined, we can construct a neighborhood of perturbed documents for each document in our sample for local Lipschitz estimation. For our experiments, we used a token sampling probability of $\pi=0.1$ and sampled from the nearest $k=10$ neighbors. For each point in the neighborhood, we calculate new attributions based on the perturbed input -- the $\ell2$ distance between perturbed and original attributions serves as the numerator of the local Lipschitz ratio, and the denominator is given by the $\ell2$ distance between perturbed and original numericalized inputs (i.e., embedded sequence or vectorized document after perturbation). In order to enforce the neighborhood aspect of local Lipschitz, we apply a radius of $\epsilon=0.25$ for removing perturbed inputs which lie too far outside the local neighborhood.
\subsubsection{Infidelity}
Infidelity \cite{yeh2019infidelity} is another metric which seeks to measure the degree to which the explanations capture the change in true model output when ``significant" perturbations are introduced.
Infidelity is somewhat less exposed to the problem of neighborhood definition than local Lipschitz because it has no need for a common radius. It does, however, require that the perturbations introduced can be subtracted from the input, thus requiring that the perturbations and model inputs are both represented numerically. This is a less desirable aspect of infidelity as a metric to compare across modeling paradigms in NLP, so we account for this by using Gaussian noise with zero-mean and standard deviation proportional to the relevant preparation method (i.e., embedded tokens for LMs and TF-IDF vectors for traditional models).
\section{Experimental Results}
\subsection{Classifier Performance}
In keeping with the benchmark task \cite{van-aken-etal-2021-clinical}, models are evaluated using the mortality prediction test set and the AUC metric. While we built models with the intention of optimizing validation performance, reaching state-of-the-art test set performance on the benchmark leaderboard was not our primary goal -- our intention is to demonstrate various interpretability methods using a variety of realistic models, so we trained until reaching parity with the performance. For each model, test set performance is provided in Table~\ref{model-performance} along with its most comparable benchmark.
Transformer-based models outperformed both traditional methods and interpretable models. BigBird performed best, beating BioBERT \cite{DBLP:journals/corr/abs-1901-08746} and performing comparably to the benchmark models which were pretrained on additional MIMIC data: CORe and DischargeBERT \cite{alsentzer2019publicly} (also known as \emph{BioClinical BERT}).
Of the inherently interpretable methods, LR and EBM performed comparably to, if slightly better than, the established ``BOW" benchmark, while DL8.5 and Boosted Rule Sets performed significantly worse than any reasonable baseline. The fact that a decision tree performed poorly on a large-scale NLP task is somewhat unsurprising -- however, the DL8.5 algorithm given one hour to train failed to reach competitiveness with a baseline CART model with all else held constant (tree depth, feature representation, etc.). The final traditional model we used with success is random forest, which also slightly outperforms the ``BOW" benchmark AUC.
\subsubsection{Computational Challenges with Interpretable Methods}
In our experiments, we saw that many of the available interpretable and/or provably optimal techniques are too computationally complex to return the provably optimal solution within a reasonable time on the document-term matrices for our task. Under the category of optimal trees, we unsuccessfully attempted the methods introduced in \cite{10.1007/s10994-017-5633-9} and implemented in PyOptree\footnote{Accessed via \url{https://github.com/pan5431333/pyoptree}} -- this took several hours to complete single iterations on a single tree model. For rule lists, we attempted Bayesian Rule Lists \cite{yang2017scalable} and CORELS \cite{angelino2018learning}, neither of which could work due to the scale of the data for this task.
\begin{table}[t]
\caption{Classifier performance (AUC) on the mortality prediction test set along with most comparable benchmarks.
\newline---\textsuperscript{*}: Unable to execute within a reasonable time or compute limit.}
\label{model-performance}
\vskip 0.15in
\begin{center}
\begin{small}
\begin{sc}
\begin{tabular}{lcp{3cm}}
\toprule
Model & AUC & Benchmark AUC \\
\midrule
LR & 81.07 & 79.15 \\
\hline
RF & 79.30 & 79.15 \\
\hline
EBM & 76.50 & 79.15 \\
\hline
DL8.5 & 51.02 & 79.15 \\
\hline
Boosted & 73.49 & 79.15 \\
Rule Sets & & \\
\hline
BigBird & 83.59 & 81.13 (BERT) \newline 82.55 (BioBERT) \newline 84.51 (\emph{DischargeBert}) \\
\hline
PyOptree & ---\textsuperscript{*} & 79.15 \\
\hline
CORELS & ---\textsuperscript{*} & 79.15 \\
\hline
Bayesian & ---\textsuperscript{*} & 79.15 \\
Rule Lists & & \\
\bottomrule
\end{tabular}
\end{sc}
\end{small}
\end{center}
\vskip -0.1in
\end{table}
\subsection{Demonstrating Interpretability}
Input attribution is an obvious choice for visualizing the local explanations produced by both high-dimensional interpretable models (such as LR and EBM) and deep learning models. Such visualizations can be understood by less technical human users -- including clinicians -- and can easily be integrated into a workflow in which the users interact with the information being classified. A well designed attribution visualization will require minimal education or training for human stakeholders who are familiar with the model's task. In a text-based setting, this can be achieved simply by highlighting the terms within the document which contributed to a certain prediction. This level of information can help bolster trust in the model, while also helping clinical experts identify potential root causes of prediction errors.
We use input attribution for local explainability throughout our experiments -- while we focus on text classification for this work, this same concept is perfectly compatible with other NLP tasks, including named entity recognition (NER) and language modeling, and many of the libraries we use can be mapped directly to other tasks within and beyond NLP.
\subsubsection{Comparing Surrogate Attributions to True Local Explanations}
The \verb+interpret+ library \cite{nori2019interpretml} allowed us to directly compare the local explanations obtained by LIME and SHAP to the underlying truth obtained by enumerating the effects from the learned models for logistic regression and EBM.
Figure \ref{fig:lr-interpret} shows a comparison of actual local explanations from a logistic regression versus results from \emph{post hoc} explainability methods SHAP and LIME. SHAP features match actual LR features almost exactly, with only two exceptions: ``numbertoken" (our catch-all token for numeric values in the text) was found in LR but not SHAP, while ``coumadin" was found in SHAP but not LR. LIME features had very little overlap with the true LR features; only two features -- ``intubated" and ``unrespons" -- were found in both. This is unsurprising, as LIME has been reported to have low robustness \cite{alvarezmelis2018robustness}. EBM explainability follows a similar pattern where SHAP explains the feature importance more accurately than LIME, and additional comparisons can be found in our supplemental material. Between the two classification methods, there was also some feature overlap, such as ``intubated," ``neuro," and ``coumadin."
\begin{figure}[!htb]
\centering
\begin{subfigure}[True local explanations for logistic regression.]{
\centering
\includegraphics[width=0.5\textwidth]{images/interpret_LR_truth.png}
\label{fig:lr-interpret-truth}}
\end{subfigure}%
\qquad
\begin{subfigure}[SHAP-based explanations.]{
\centering
\includegraphics[width=0.5\textwidth]{images/interpret_LR_SHAP.png}
\label{fig:lr-interpret-shap}}
\end{subfigure}
\qquad
\begin{subfigure}[LIME-based explanations.]{
\centering
\includegraphics[width=0.5\textwidth]{images/interpret_LR_LIME.png}
\label{fig:lr-interpret-lime}}
\end{subfigure}
\caption{Comparison of true model features to \emph{post hoc} feature explanations on a single observation.}\label{fig:lr-interpret}
\vskip -0.1in
\end{figure}
\subsubsection{Global Interpretability}
Fully interpretable models generally include a method for global interpretability -- a set of coefficients, tree structure, or something similar indicating the ``important" features or an explicit decision path detailing the model's behavior under any conceivable permutation. Various options exist for displaying feature importance -- for example, a tree-based model can be plotted in graph form, raw feature importance for LR/EBM can be displayed similarly to the local explanations in the previous section, and individual feature effects can be plotted over the range of feature values as in a partial dependence plot (PDP). Figure \ref{fig:ebm-global} illustrates the global interpretability features provided by the ``glassbox" models in the \verb+interpret+ library: global feature importance for the EBM model can be seen in \ref{fig:ebm-global-importance}, and \ref{fig:ebm-intub} shows the individual modeled impact of the feature ``intub".
\begin{figure}[!htb]
\centering
\begin{subfigure}[Global feature importance for EBM]{
\centering
\includegraphics[width=0.5\textwidth]{images/ebm_global_ranking.png}
\label{fig:ebm-global-importance}}
\end{subfigure}%
\qquad
\begin{subfigure}[Impact of TF-IDF score of ``intub"]{
\centering
\includegraphics[width=0.5\textwidth]{images/ebm_intub_impact.png}
\label{fig:ebm-intub}}
\end{subfigure}
\caption{Global interpretability for an EBM model from the interpret library.}
\label{fig:ebm-global}
\end{figure}
\subsubsection{Interpretable Classifiers}
We chose two interpretable methods which are not commonly used in NLP problems: Boosted Rule Sets \cite{FREUND1997119} and DL8.5 \cite{Aglin_Nijssen_Schaus_2020}. These methods bring something slightly different to the conversation around interpretability than EBM and logistic regression, in that they produce models which are more sparse in nature and can easily be understood by a human user. In the case of DL8.5, there is the additional benefit of the final model being provably optimal for a given specification and dataset.
We used the implementation of Boosted Rule Sets in the \verb+imodels+ library \cite{Singh2021}, and our best model achieved test AUC of 73.49 -- considerably worse than the benchmark performance. This model learned an ensemble of 50 simple rules which indicate higher likelihood for in-hospital mortality, in the format of $token \leq score$, where $token$ is an n-gram found in the document term matrix, and $score$ is the TF-IDF score for that n-gram in the given document. A subset of these rules is included in supplementary material.
DL8.5 performed extremely poorly on this task due to the dimensionality of the dataset. Because of the length and diverse content of the admission notes, we retain as much of the information as possible through our document preprocessing. The high dimensionality of the design matrix -- in this case, both cardinality and volume -- overwhelms the search algorithm, which essentially cannot run without time limits. When this time limit is reached, a poor model is returned, achieving virtually no AUC lift. DL8.5 and Boosted Rule Sets would benefit from additional feature engineering; however, lexicons and hand-engineered features are expensive to develop and maintain, and other dimensionality reduction techniques (e.g. manifold learning for high-dimensional feature spaces) would sacrifice the level of interpretability. Both of these alternative approaches are beyond the scope of this work.
\subsubsection{Transformer Explainability: Input Attribution and Behavioral Visualization}
We explored a variety of visualization techniques for Transformer explainability, including input attribution and visualization of activations and attentional weights. The attribution methods produce results which are conceptually similar to those given by SHAP and LIME: they are designed to denote the degree to which a specific input token contributed to the model's output -- in this case, mortality prediction. Figure \ref{fig:captum-attribution} shows input attribution calculated via the saliency method, and visualized using the Captum library \cite{kokhlikyan2020captum} for a true positive prediction (a patient correctly predicted to expire while in the ICU). We can see that there are tokens such as ``unresponsive" and ``intubated" highlighted green, indicating a positive influence (pushing the model toward predicting patient expiration). Additionally, some tokens have a red highlight indicating an impact that suppresses predicted mortality, including ``clear" within a statement describing the patient's lungs.
\begin{figure*}
\centering
\includegraphics[width=0.7\textwidth]{images/captum_integrated_gradients.png}
\caption{Saliency-based local explanations from the Captum library.}
\label{fig:captum-attribution}
\end{figure*}
Beyond input attribution, other methods are tailored to gaining deeper understanding of the nuances within the representations learned by the language model. Alammar's Ecco library provides an interactive visualization to highlight the input tokens which produce similar neuron activations. Ecco uses non-negative matrix factorization to reduce the high-dimensional activation data into a user-specified number of factors, which are then displayed interactively.
Figure \ref{fig:ecco} shows Ecco's results for the same true positive case: neuron activations are reduced to 12 factors, and related tokens are highlighted. The sparklines on the left side of the image correspond to individual factors, along with their activations throughout the document. In this view, Factor 2 is highlighted alone, where we can see that it includes language relation to intubation, sedation, falling, and unresponsiveness. This is helpful for us to glean insights from potentially related terms. Additional views can be found in our supplemental material -- for example, in addition to this factor, switching to Factor 11 seems to highlight specific mentions of medication (Coumadin, Dilantin, Propofol) as well as generic treatments (hypertonic saline, Vitamin K).
\begin{figure}[htb]
\centering
\includegraphics[width=0.5\textwidth]{images/ecco-narrow.png}
\caption{Ecco's non-negative matrix factorization of neuron activations with component 2 highlighted.}\label{fig:ecco}
\end{figure}
We also explored libraries for visualizing full self-attention weights. BertViz \cite{vig-2019-multiscale} has nice built-in interactivity to allow users to explore results by layer and attention head. However, one drawback of this method is that it does not perform particularly well with relatively long input sequences: the task of visualizing full self-attention across 1,000 tokens is a difficult task, and existing tooling struggles to accommodate such sequences. We can instead use these techniques to visualize local effects by viewing self-attention weights within a smaller segment of a larger document. Figure \ref{fig:bertviz} shows BertViz's head view method on a small input sequence with similar language. In \ref{fig:bertviz-full}, the full connections are displayed with opacity representing the relative weight applied in all heads of the first encoder layer. In \ref{fig:bertviz-isolated}, a subword of ``unresponsive" is highlighted, and inbound self-attention weights are indicated from the other tokens in the sequence.
\begin{figure}[h!]
\centering
\begin{subfigure}[Full attention weights displayed.]{
\centering
\includegraphics[width=0.3\textwidth]{images/bertviz_short_full.png}
\label{fig:bertviz-full}}
\end{subfigure}%
\begin{subfigure}[Inbound attention weights for a subword of ``unresponsive" isolated.]{
\centering
\includegraphics[width=0.3\textwidth]{images/bertviz_short_isolated.png}
\label{fig:bertviz-isolated}}
\end{subfigure}
\vskip -0.05in
\caption{Attention weight visualization with BertViz.}\label{fig:bertviz}
\vskip -0.15in
\end{figure}
This view is perhaps more compelling for language modeling use-cases (e.g., masked language modeling), which focus more on the learned representations of each token. It is unclear whether these attention weights provide much practical value for gaining true understanding of a Transformer-based classifier's behavior.
\subsection{Evaluating the Quality of Explanations}
\begin{figure*}[th]
\centering
\begin{subfigure}[Distribution of local Lipschitz values.]{
\centering
\includegraphics[width=0.45\textwidth]{images/lipschitz-boxplot.png}
\label{fig:lipschitz-box}}
\end{subfigure}%
\begin{subfigure}[Distribution of infidelity values.]{
\centering
\includegraphics[width=0.45\textwidth]{images/infidelity-boxplot.png}
\label{fig:infidelity-box}}
\end{subfigure}
\caption{Evaluation metrics comparing models and attribution types.}
\label{fig:boxplots}
\vskip -0.1in
\end{figure*}
\subsubsection{Local Lipschitz}
We first explored the local Lipschitz measure \cite{alvarezmelis2018robustness} as a metric for quantifying the sensitivity of \emph{post hoc} input attribution.
For our experiment, we used a sample of 35 documents and required a neighborhood size of 15 perturbations for each document. For each document, we calculated local Lipschitz values for each of the perturbations and retained the maximizing perturbation. The distribution of these values by model and attribution type can be seen in Figure \ref{fig:lipschitz-box}, which shows a great deal of variation between models as well as attribution methods. According to Alvarez-Melis and Jaakkola \citeyearpar{alvarezmelis2018robustness}, there is no globally optimal value for the local Lipschitz -- we can, however, use it to compare the relative sensitivity of attributions methods across models and for attributions on the same model. We can see that both attributions for BigBird have higher local Lipschitz values than all traditional methods, indicating that the available attributions are more sensitive to slight changes in the model inputs. These results show that this is still the case when using a common perturbation method. The random forest model with SHAP attributions produces the lowest local Lipschitz values, indicating that it is relatively insensitive to small input changes.
\subsubsection{(In)Fidelity}
Since there is no need to repeatedly perturb inputs, we ran our infidelity experiment on a sample of 100 documents. The results are given in Figure \ref{fig:infidelity-box}, and it is clear that there is somewhat less pronounced variation between models than with local Lipschitz. BigBird's attribution methods have higher infidelity than any of the traditional methods, indicating that the features identified by the attribution methods have less of an impact on the model's output when Gaussian noise is introduced.
Another interesting property of infidelity can be seen in the truly interpretable models: for LR and EBM, we can compare the infidelity measures for LIME and SHAP to the infidelity for the true local explanations. In the case of EBM, the true local explanation has a slightly higher infidelity than both LIME and SHAP; for LR, the true explanations have an infidelity that lies between LIME and SHAP. This is a somewhat surprising and counterintuitive result, which suggests that future work should explore better ways to apply infidelity to NLP problems.
\subsubsection{Examining the Tradeoff between Explanation Quality and Model Performance}
With a common framework in place to evaluate the behavior of available explanations, we can now examine the trade-off between explainability and model performance. Table \ref{quantifying-explainability} illustrates this comparison for the models and explanations explored in the previous sections. As shown previously, it is clear that BigBird and LR have the highest AUC values; we can now also quantitatively compare their interpretability features through the quality metrics. In summary, LR has worse performance with substantially better explanations (in addition to the fact that it is fully interpretable). As in any practical setting, the ultimate decision will require weighing the relative importance of incremental model improvement against the fidelity of available explanations.
Multi-objective optimization is one potential approach for such a weighting scheme in a practical setting: practitioners could weight the relative importance of raw model performance (F-score, precision, recall, AUC, etc.) against any number of explanation quality metrics to identify the model which best balances the Pareto frontier between interpretability/explainability and performance. This framework would also allow users to place constraints on certain metrics (e.g. requiring a minimum precision of 80\%) as well as incorporating any other desired quality of the final model (e.g. model size or number of parameters).
\begin{table}[t]
\caption{AUC, Infidelity, and Lipschitz values for all tested algorithms and attribution methods.}
\label{quantifying-explainability}
\vskip -0.3in
\begin{center}
\begin{small}
\begin{sc}
\begin{tabular}{lccc}
\toprule
Model & AUC & Infidelity & Lipschitz \\
\midrule
EBM LIME & 76.50 & 0.003482 & 0.674207 \\
EBM SHAP & 76.50 & 0.003325 & 0.404805 \\
EBM Truth & 76.50 & 0.003591 & 2.097308 \\
BigBird IG & 83.59 & 0.034362 & 21.500845 \\
BigBird Saliency & 83.59 & 0.064262 & 32.830019 \\
LR LIME & 81.07 & 0.001947 & 1.07602 \\
LR SHAP & 81.07 & 0.001838 & 0.41027 \\
LR Truth & 81.07 & 0.001918 & 1.838809 \\
RF SHAP & 79.30 & 0.000613 & 0.105773 \\
\bottomrule
\end{tabular}
\end{sc}
\end{small}
\end{center}
\vskip -0.15in
\end{table}
\section{Conclusions}
In this work, we explored practical aspects of interpretable and explainable ML methods within a case study of clinical text classification. We demonstrated some of the interpretability tools available to healthcare NLP practitioners, discussed existing definitions for explainability and interpretability, and we introduced a framework which can evaluate the quality of explanations across text classification models, including the infidelity and relative sensitivity of the presented attributions. We showed that this evaluation framework can be used in conjunction with preferred model evaluation metrics to provide a Pareto frontier illustrating the trade-off between a model's test set performance and the quality of the explanation methods available to it. This can be a very useful tool for practitioners in many domains, including healthcare, in which the data scientist is tasked with building and identifying an optimal model based on the desired level of human interpretability, which varies from problem to problem. It will also be useful for developers of AutoML solutions -- the introduction of quantitative metrics for explanation quality presents an opportunity to jointly optimize for such metrics in addition to raw model performance.
We showed that the interpretable ML techniques which are not typically used for text classification perform suboptimally despite their interpretable properties. In some cases, a deterioration in model quality may be acceptable for the purpose of full model interpretability, although other methods for producing sparse models (e.g. LASSO regression) may provide better performance. Through direct comparison between LIME, SHAP, and true local explanations, we show that LIME falls short on such high-dimensional tasks, where sparse attributions do not necessarily reflect the true underlying behavior of the model. We also demonstrated current work in visualizing the underlying behavior of BERT-style models, which attempts to build progress toward a sense of interpretability for these black-box models.
\subsection{Future Work}
Future work in both explainable and interpretable ML will undoubtedly be a crucial factor in the effort to accelerate adoption within the healthcare sector. These efforts should include additional development across the spectrum of interpretability in addition to the goal of ever-improving model performance. Progress in this area will be aided by the development and use of common evaluation metrics, which seek to quantify the quality of explanations provided for black-box models. The essence of this effort is to NLP practitioners in answering the question, ``\emph{How much} better or worse are the SHAP attributions for a random forest compared to saliency for a BERT classifier?" We make progress in this direction by introducing and open-sourcing prototypical methods for preparation-agnostic document perturbation within local neighborhoods, but additional exploration and improvement will undoubtedly aid adoption.
In addition to better understanding of explanation quality, future work in reducing the computational complexity of purely interpretable and provably optimal ML solutions will allow for more competitive use in large-scale text classification.
\section*{Acknowledgements}
The authors would like to thank the organizers of the Interpretable ML in Healthcare workshop and ICML, as well as the anonymous reviewers for their feedback and advice. We also acknowledge Digital Reasoning / Smarsh, Inc. and our colleagues for their support.
\newpage
| {'timestamp': '2021-07-14T02:02:39', 'yymm': '2107', 'arxiv_id': '2107.05693', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05693'} | arxiv |
\section{Introduction}
The idea of an information bottleneck (IB)~\cite{tishby2000} is to learn a compressed representation $Z$ of an input $X$ that is predictive of a target $Y$. This leads to the following training objective involving two mutual information terms:
\begin{equation}
\label{eq:1}
\min_{Z} - I(Z, Y) + \beta I(Z, X).
\end{equation}
This objective favours a representation $Z$ that retains the minimum amount of information about $X$ while being maximally predictive of $Y$.
The hyper-parameter $\beta \ge 0$ controls the trade-off between the two losses.
To make this objective practical, \citet{alemi17} used variational techniques to construct the upper bound for the expression in Eq.~\ref{eq:1} -- also known as the Variational Information Bottleneck (VIB) loss:
\begin{equation}
\label{eq:2}
\min_{p(\bm z| \bm x)} \mathbb E_{p(\bm x,\bm y)p(\bm z|\bm x)} \big[-\log q(\bm y | \bm z) + \beta \log \frac{p(\bm z|\bm x)}{q(\bm z)}\big],
\end{equation}
where $p(\bm z|\bm x)$ is a stochastic encoder distribution, $q(\bm y|\bm z)$ is a variational approximation to $p(\bm y|\bm z)$, and $q(\bm z)$ is the variational approximation to the marginal $p(\bm z)$.
In a similar way to the Variational Auto-Encoder (VAE) setup~\cite{kingma14}, we can parameterize Gaussian densities $p(\bm z|\bm x)$ and $q(\bm y|\bm z)$ using neural networks, and fix $q(\bm z)$ to be a $K$-dimensional Gaussian $\mathcal N(\bm 0, \bm I)$, where $K$ is the size of the bottleneck layer. We can then use the reparameterization trick to learn the parameters of the neural networks when optimizing the stochastic estimate of the objective in Eq.~\ref{eq:2}.
A tighter bound on the IB objective is given by the Conditional Entropy Bottleneck (CEB)~\cite{fischer20}:
\begin{equation}
\label{eq:3}
\min_{p(\bm z|\bm x)} \mathbb E_{p(\bm x,\bm y)p(\bm z|\bm x)} \big[-\log q(\bm y | \bm z) + e^{-\rho} \log \frac{p(\bm z|\bm x)}{q(\bm z|\bm y)}\big],
\end{equation}
where the second term uses a class-conditional variational marginal $q(\bm z|\bm y)$, and $\rho$ is a hyper-parameter with the same role as $\beta$ in Eq.\ref{eq:2}. CEB parameterizes $q(\bm z|\bm y)$ by a linear mapping that takes a one-hot label $\bm y$ as input and outputs a vector $\bm \mu_y$ representing the mean of the Gaussian $q(\bm z|\bm y) = \mathcal N(\bm \mu_y, \bm I)$. CEB uses an identity matrix for the variance of $q(\bm z|\bm y)$ and $p(\bm z| \bm x)$, which is unlike VIB, where the variance of the encoder distribution is not fixed.
Multiple studies suggest that IBs can reduce overfitting and improve robustness to adversarial attacks~\cite{alemi17, fischer20, kirsch21}. For example, \citet{fischer20} showed that CEB models can outperform adversarially trained models under both $l_{\infty}$ and $l_2$ PGD attacks~\cite{madry19} while also incurring no drop in standard accuracy. However, no clear explanation has been found as to how IB models become more robust to adversarial examples. Previous works also failed to investigate possible effects of gradient obfuscation which could lead to a false sense of security~\cite{athalye18}. In this paper, we continue the analysis into the behaviour of IB models in the context of adversarial robustness.
Our experiments provide evidence of gradient obfuscation, which leads us to conclude that the adversarial robustness of IB models was previously overestimated.
\section{Adversarial robustness}
Since the discovery of adversarial examples for neural networks~\cite{szegedy,biggio2013evasion}, there has been a lot of interest in creating new attacks and defenses. In this section we briefly review methods for crafting norm-bounded adversarial examples. Later, we use these methods to assess the adversarial robustness of IB models.
The Fast Gradient Sign (FGS) attack~\cite{goodfellow15} is an $l_{\infty}$ bounded single-step attack that computes an adversarial example $\bm x_{adv}$ as $\bm x + \epsilon \text{sign}(\nabla_{\bm x} \mathcal L(\bm \theta, y ,\bm x))$, where $\bm x$ is the original image, $y$ is the true label, $\mathcal L$ is the cross-entropy loss, and $\epsilon$ is the perturbation size.
Projected Gradient Descent (PGD)~\cite{madry19} is the multi-step variant of FGS. The $l_{\infty}$ PGD attack finds an adversarial example by following iterative updates ${\bm x^{t+1} = \text{Proj}_{\mathcal B(\bm x, \epsilon)} \big(\bm x^t + \alpha \text{sign}(\nabla_{\bm x} \mathcal L(\bm \theta, y ,\bm x))\big)}$ for some fixed number of steps $T$. Here, $\text{Proj}_{\mathcal B(\epsilon, \bm x)}$ is a projection operator onto $\mathcal B(\epsilon, \bm x)$ -- the $l_{\infty}$ ball of radius $\epsilon$ around the original image $\bm x$. The attack starts from an initial $\bm x^0$ sampled randomly within $\mathcal B(\epsilon, \bm x)$.
The reliability of PGD attacks often depends on the choice of parameters such as the step size $\alpha$, or the type of loss $\mathcal L$. Recent PGD variants are designed to be less sensitive to these choices, and it is common to run an ensemble of attacks with different parameters and properties. AutoAttack~\cite{croce20} and MultiTargeted~\cite{gowal19} are examples of this strategy.
\section{Experiments}
In this section, we experiment with VIB and CEB models on MNIST and CIFAR-10.
We run a number of diagnostics, which indicate that gradient obfuscation is the main reason why IB models are seemingly robust. In trying to understand their failure modes, we also look at some toy problems. Our interpretation of the results is deferred to the next section. Hyperparameters of all our models and additional plots are included in the appendix.
\subsection{MNIST}\label{sec:mnist}
For VIB experiments on MNIST, we follow the setup of \citet{alemi17}. Namely, for the encoder network, we use a 3-layer MLP with the last bottleneck layer of size $K=256$. This bottleneck layer outputs the $K$ means and $K$ standard deviations (after a softplus transformation) of the Gaussian $p(\bm z|\bm x)$. The decoder distribution $q(\bm y|\bm z)$ over 10 classes is parameterized by a linear layer ending with a softmax. During training, we use the reparameterization trick~\cite{kingma14} with $S=12$ samples from the encoder $\bm z \sim p(\bm z | \bm x)$ when estimating the expectation over $p(\bm z | \bm x)$ in Eq.~\ref{eq:2}. At test time, we also collect $S$ samples of $\bm z$, and compute $p(\bm y|\bm x)$ as $\frac{1}{S}\sum_{s=1}^{S} q(\bm y|\bm z^s)$. We refer to this evaluation as \textit{\say{stochastic mode}}. In the \textit{\say{mean mode}}, we only use the mean of $p(\bm z|\bm x)$ as an input to the decoder. Our deterministic baseline is an MLP of the same overall structure as the VIB model. We train it with a cross-entropy loss without any additional regularization.
First, we evaluate our models using the FGS attack. Figure~\ref{fig:0} shows the robust accuracy of VIB models with varying $\beta$ under the FGS attack with different perturbation sizes $\epsilon$. For the rest of the paper, we assume that input images are in the $[0,1]$ range. Our results slightly differ from those of \citet{alemi17}. In particular, the performance of our VIB models peaks at $\beta=0.01$ instead of $\beta=0.1$ as reported previously, and the evaluation in the \say{mean mode} and \say{stochastic mode} does not lead to the same results.
Despite these differences, we can still achieve large gains in robust accuracy under the FGS attack for VIB models in comparison to the baseline.
One result that stands out is the unusually high robust accuracy under the attack with $\epsilon=0.5$.
Indeed, with this perturbation size, one can design an attack that makes all images solid gray and, as such, the classifier should not do better than random guessing~\cite{carlini17}. The obtained robust accuracy above 10\% indicates that gradients of VIB models do not always direct us towards stronger adversarial examples. To check if the improvements in robust accuracy generalize to stronger attacks, we evaluate VIB models with $\beta=0.01$ under the PGD attack with 40 steps, $\alpha=0.01$, $\epsilon=0.2$, and a different number of restarts. Figure~\ref{fig:1a} shows that we can drive the robust accuracy to zero as we increase the number of restarts.
It is an indication of gradient obfuscation, as the loss landscape cannot be efficiently explored by gradient-based methods~\cite{carlini17,croce20}.
\begin{figure*}[htb]
\includegraphics[scale=0.4]{img/mnist_fgs_02.png}
\includegraphics[scale=0.4]{img/mnist_fgs_035.png}
\includegraphics[scale=0.4]{img/mnist_fgs_05.png}
\vskip -1em
\caption{Robust accuracy under FGS attack with $\epsilon = 0.2, 0.35, 0.5$ on MNIST. VIB models are evaluated in two modes: stochastic and mean. For each $\beta$, we trained 10 models with different random seeds. Dots indicate the results of evaluating each individual model. For deterministic models, solid line plots the average robust accuracy over 10 models, while the hue gives the minimum-maximum range. The standard accuracy of all models is between 98.2\% and 98.9\%.}
\label{fig:0}
\end{figure*}
\begin{figure}[htb]
\vskip -1em
\begin{center}
\includegraphics[scale=0.4]{img/mnist_pgd_02.png}
\vskip -1em
\caption{Robust accuracy of MNIST VIB models with $\beta= 0.01$ under a PGD attack with 40 steps and a step size of 0.01 for different number of restarts. At each restart, the initial point $\bm x^0$ is sampled randomly within $\mathcal B(\epsilon, \bm x)$.}
\label{fig:1a}
\end{center}
\vskip -2em
\end{figure}
\subsection{CIFAR-10}\label{sec:cifar}
For CIFAR-10, as our encoder network we use a PreActivation-ResNet18~\cite{he16} followed by an MLP with the same architecture as the MNIST experiments. We train this network end-to-end, and only use random crops and flips to augment the data. As previously, we construct an analogous deterministic model that we do not regularize in any way, thus it overfits.
In Figure~\ref{fig:2a}, we evaluate the adversarial robustness of CEB models on $l_{\infty}$ PGD attack with 20 steps and ${\alpha=0.007}$~\cite{madry19}. It is surprising that some of our deterministic models can outperform an adversarially-trained ResNet from \citet{madry19} with a reported robust accuracy of 45.8\%. This result alone suggests that PGD attacks should be used with caution when evaluating models that might obfuscate the gradients. As with MNIST, we can again significantly reduce the robust accuracy by increasing the number of restarts as shown in Figure~\ref{fig:2b}.
To get a better estimate of the robust accuracy in the presence of gradient obfuscation, we use a set of stronger attacks: a mixture of AutoAttack (AA) and MultiTargeted (MT)~\citep{croce20,gowal19}. We execute the following sequence of attacks: AutoPGD on the cross-entropy loss with 5 restarts and 100 steps, AutoPGD on the difference of logits ratio loss with 5 restarts and 100 steps, MultiTargeted on the margin loss with 10 restarts and 200 steps. From Figure~\ref{fig:2c}, we see that deterministic models have zero robust accuracy, while the performance of CEB models varies across models with different random seeds. This dependence on the seed could be the consequence of sub-optimal network initialization and difficulties related to training IB models. Some part of the variance in the robust accuracy might still be attributed to having an imperfect attack due to the unreliable gradients.
Finally, in Figure~\ref{fig:5} and in the appendix, we show typical loss landscapes produced by the CEB model with $\rho=2$ that scored 15.8\% accuracy under the AA+MT ensemble of attacks. These plots are strikingly different from typical smooth non-flat loss landscapes obtained from adversarially trained models~\cite{qin19}. The flatness of the plotted landscapes explains why gradient-based attacks with cross-entropy loss are not as effective. Moreover, since IB losses do not explicitly penalize misclassification for perturbed inputs within a certain $l_p$-ball, the model is free to choose where to place decision boundaries.
Figure~\ref{fig:5} suggests that CEB models could be robust to much smaller perturbation radii.
\begin{figure*}
\centering
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[scale=0.4]{img/cifar_pgd_ceb_gpu_eval.png}
\caption{}
\label{fig:2a}
\end{subfigure}%
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[scale=0.4]{img/cifar_pgd_restart_ceb_stochastic.png}
\caption{}
\label{fig:2b}
\end{subfigure}%
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[scale=0.4]{img/cifar_aa_ceb.png}
\caption{}
\label{fig:2c}
\end{subfigure}%
\vskip -0.5em
\caption{ Robust accuracy of CEB and deterministic models on CIFAR-10
\textbf{(a)} Under the PGD attack with parameters from ~\citet{madry19} and a single restart
\textbf{(b)} Under the PGD attack with different number of restarts, where we evaluated CEB models with $\rho=3$.
\textbf{(c)} Under the ensemble of AutoAttack and MultiTargeted.
Each model was trained with 10 random seeds, and we excluded those runs where performance collapsed to a random chance, which happened mainly for the most regularized models with $\rho=1$. Standard accuracy of the remaining models was above $90\%$.
}
\label{fig:2}
\end{figure*}
\begin{figure}[htb]
\vskip -1em
\begin{center}
\includegraphics[width=0.7\columnwidth]{img/landscape_xid25208566_wid15_idx3_truck.png}
\caption{Cross-entropy loss surface produced by the highest-scoring CEB model (15.8\% under AA+MT) for a test image of a truck. The diamond-shape represents the projected $l_{\infty}$ ball of size $\epsilon$ = 8/255 around the original image. The surface is generated by varying the input to the model, starting from the original input image toward either the worst attack found using PGD or the one found using a random direction.}
\label{fig:5}
\end{center}
\vskip -2em
\end{figure}
\subsection{A toy problem}\label{sec:toy}
We established that gradient obfuscation makes it harder to understand the robustness properties of IB models on real datasets. Thus, analysing toy examples can be a useful alternative. A classification task from~\citet{tsipras19} is one example that can motivate the use of IBs, where their ability to ignore irrelevant features becomes helpful. We study this problem in the appendix. Here, we consider another simple setup where labels $y$ are sampled uniformly at random from $\{-1,1\}$, and two features have the following conditional distributions:
\begin{equation*}
\resizebox{\hsize}{!}{$
p(x_1|y=1) = \mathcal U(0,10), \; p(x_2|y=1) = \begin{cases}
\mathcal U(0,1) \text{ w.p. } 0.9\\
\mathcal U(-1,0)\text{ w.p. } 0.1
\end{cases}
$}
\end{equation*}
\begin{equation*}
\resizebox{\hsize}{!}{$
p(x_1|y=-1) = \mathcal U(-10, 0), \; p(x_2|y=-1) = \begin{cases}
\mathcal U(-1,0) \text{ w.p. } 0.9\\
\mathcal U(0,1)\text{ w.p. } 0.1
\end{cases}
$}
\end{equation*}
In this example, the label can be predicted from the sign of $x_1$, so in the optimal IB case, we need to communicate 1 bit of information about the input. The first feature is also more robust since it requires a larger perturbation before its sign gets flipped.
In practice, we found that a simple VIB classifier does not exclusively focus on $x_1$, and so it becomes prone to a rather trivial attack that substracts or adds $\epsilon=1$ to $x_2$ depending on the label, as shown in Figure~\ref{fig:toy}. This could be the consequence of SGD training, the approximate nature of the objective function, VIB's formulation as a combination of competing objectives or other reasons we do not yet understand.
\begin{figure}[htb]
\begin{center}
\includegraphics[scale=0.4]{img/toy_new.png}
\vskip -1.5em
\caption{Standard and robust accuracy of a VIB and a linear deterministic classifiers on the toy problem from Section~\ref{sec:toy}.}
\label{fig:toy}
\end{center}
\vskip -2em
\end{figure}
\section{Discussion}
By re-evaluating adversarial robustness of VIB and CEB models, we have shown that weak adversarial attacks are often unable to provide reliable robustness estimates as these models create highly non-smooth loss surfaces, which are harder to explore with gradients. Therefore, we believe that previous, as well as future results on the robustness of IB models should include basic checks for gradient obfuscation.
This is especially important when comparing different types of models, e.g. IBs versus adversarial training.
Our experiments were inconclusive as to whether IB models offer adversarial robustness gains relative to the undefended deterministic baseline. For MNIST, the results under the FGS attack seemed promising. However, looking at the performance under the PGD attack with multiple restarts and different perturbation sizes showed a different picture. For CIFAR-10, some of the CEB models were significantly better than the baseline under the strongest attack. However, we did not identify the exact cause for having excessive variance in the results of models with different random seeds. Thus, it would be interesting to find regimes where CEB can reliably converge to more robust models.
In this paper, we only considered IB models in discriminative settings. A generative model related to VIB is $\beta$-VAE~\cite{higgins17}. For auto-encoders, the adversarial attack amounts to finding inputs that would cause the decoder to reconstruct a visually distinct image, e.g. an object from a different class. \citet{camuto20} showed that $\beta$-VAE for larger values of $\beta$ is more robust to adversarial attacks. However, \citet{kuzina21} used a different set of evaluation metrics to challenge this claim. \citet{Cemgil2020Adversarially} attributes the lack of robustness of $\beta$-VAE models to the inability of their objective to control the behaviour of the encoder outside of the support of the empirical data distribution. Namely, without additionally forcing the encoder to be smooth, tuning $\beta$ alone is not enough for learning robust representations. Together with our observations for VIB and CEB models, the disagreement about $\beta$-VAE's results corroborates the need for more nuanced evaluation before adversarial robustness claims can be made.
Overall, we believe that using IBs in the context of adversarial robustness is an idea that deserves further exploration. In this paper, we focused on the empirical evaluation of IB models under standard robustness metrics and illustrating the caveats related to it. An interesting future research direction would be to understand the properties of IB models, especially in the stochastic regime, from both information-theoretic and adversarial robustness perspectives. Another promising direction would be to explore IBs with additional curvature regularization~\cite{moosavi19,qin19} or in combination with adversarial training.
\section*{Acknowledgements}
We would like to thank Taylan Cemgil, Lucas Theis, Hubert Soyer, Jonas Degrave, and the wonderful people from the robustness teams at DeepMind for their help with this project, interesting questions, valuable discussions, and feedback on the paper.
| {'timestamp': '2021-07-14T02:03:33', 'yymm': '2107', 'arxiv_id': '2107.05712', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05712'} | arxiv |
\section{Introduction}
Natural language is an ubiquitous communication medium between human interlocutors, and is shaped by the desire to efficiently cooperate and achieve communicative goals \cite{gibson2019efficiency}.
Because of this, there has been interest in creating artificial agents that mimic this communication process, with a wide variety of works examining communication between agents via either completely artificial \emph{emergent} language \cite{wagner2003progress, bouchacourt2018agents, li2019ease, kharitonov2020entropy}, or through \emph{natural} language such as English \cite{lazaridou2016multi,lowe2019interaction}.
In general, these methods model interaction between a pair of agents, a \emph{speaker} and a \emph{listener} that attempt to jointly achieve a goal where the language use is learned to optimize success with respect to a collaborative task (for example, in Fig. \ref{fig:demo} the speaker instructs an embodied agent to perform a task in an environment).
\begin{figure}[!t]
\includegraphics[width=\linewidth]{demo20.pdf}
\caption{A conversation between a speaker and a listener collaboratively solving a navigation task. (a) At the start of the task, a goal (bold font) is given to the speaker (purple robot head). The speaker first gives a task-level instruction. Without previous knowledge of the listener, the speaker thinks the listener (green robot) will proceed to the fridge after three correct actions (monospace font) in a row. Grey observations are given by the environment after each action. (b) shows the belief of the speaker about the listener's action after a few instruction candidates. Note that to keep instructions concise the speaker chooses ``no instruction'' over ``walk to fridge'' despite the higher probability of listener taking correct action given the latter instruction. (c) After the listener makes a mistake by going to the microwave, the speaker figures out that the listener cannot understand ``cool'' in the high-level instruction given, and gives low-level instruction ``walk to the fridge''. (d) shows the belief of speaker at this time step. Note that the probability of action ``\texttt{\color{blue}go to \color{red}fridge}'' without instruction decreases due to the wrong action of the listener.
}
\label{fig:demo}
\end{figure}
However, in contrast to this setup, human speakers interact with not a single listener, but many different conversational partners.
In doing so, they also adapt to each other's language within short conversations.
One of the representative phenomena is entrainment, in which interlocutors align their language on both acoustic-prosodic and lexical dimensions during communication \cite{brennan1996conceptual, levitan2018acoustic}.
These issues remain mostly unattested in previous work on multi-agent communication --- it remains an open question how to train an agent which can adapt to communicating with novel partners quickly.
We define this adaptive communication problem as \emph{few-shot language coordination}. As shown in Fig. \ref{fig:demo}, within a few rounds of the game, the speaker must adapt its language based on the responses from the listener to achieve the \emph{communicative goal} of helping the listener perform the correct actions as many times as possible. This few-shot coordination setting provides the agents with the pressure to adapt on-the-fly -- something that current models generally cannot achieve, even those that model pragmatics, e.g. the rational speech act model \cite{frank2012predicting}.
Developmental psychology argues for the importance of Theory of Mind (ToM), the understanding of others’ mental states, and also the ability of interlocutors to act upon others mental states to achieve desired effects \cite{tomasello2018children}.
In this paper, we study the importance of modeling the beliefs of one's conversational partner to achieve few-shot language coordination.
In particular, we train a model that quickly adapts to predict the actions of the listeners in real time. At each time step, the speaker predicts the listener's likely next action given all possible instructions and the listener's previous actions.
This is essentially a few-shot learning problem, which we attack with model-agnostic meta-learning (MAML) \cite{finn2017model}.
In order to achieve the communicative goal, the speaker chooses the best instruction to give so that the probability of the listener performing the correct actions is maximised.
We expect the resulting agent to not only mimic humans' ability to model a listener's mental state but also to leverage this estimate to choose better instructions. Through empirical evaluation, we aim to answer the question:
\begin{quote}
\it
Can an agent, equipped with a model of theory of mind, quickly adapt to a listener's language in a few-shot language coordination game?
\end{quote}
Our experiments answer in the affirmative in the both a referential game and a vision-language navigation setting.
\section{Few-shot Language Coordination}
Consider again the example depicted in Fig.~\ref{fig:demo}.
A speaker model observes the goal of the current task (``pick and cool wine bottle, place it on the dining table''), and sends messages to a listener model, in an attempt to help it finish the task.
The listener model chooses actions to take given the latest and previous instructions.
If the listener makes a mistake, such as going to the microwave instead of the refrigerator, the speaker should realize that the listener misunderstood some aspect of the high-level instructions in the first message. This misstep informs the speaker's model of the listener's ability, leading them to give lower-level instructions to help correct the trajectory. Through \emph{several games}, the speaker gathers enough data to provide customized messages for individual listeners.
This is only possible if a proper prior is provided to the speaker. The simplest prior can be hand-coded rules, e.g. if listener cannot understand abstract instructions, try simpler ones.
However, to pursue a more general and powerful communication model (e.g. knowing when to simplify vs. rephrase),
we study whether this kind of few-shot language coordination can be \emph{learned} by playing with a \emph{population} of listeners. This section proposes a method to construct meaningful populations.
\subsection{Asymmetric Speaker-Listener Games}
Following previous work on communicative agents \cite{lazaridou2016multi,cao2018emergent,lowe2019interaction}, we use goal-oriented language games
as the test bed for few-shot language coordination. A general goal-oriented language game provides an environment where the participants uses language to communicate with each other to achieve the given goal.
We consider the most basic setting of a simplified two-player shared-goal multi-round setup:
\begin{description}[align=left]
\item[Environment:] The environment is defined by $\mathcal{O}$bservation space, $\mathcal{A}$ction space, $\mathcal{G}$oal space and transition function $E:\mathcal{O}\times \mathcal{A}\rightarrow\mathcal{O}\times \mathcal{G}$. At the start of each game, the environment provides the speaker with a goal and both participants with observations after each action is taken by the listener. A new game starts after the previous one succeeds or reaches a maximum number of steps.
\vspace{-2pt}
\item[Participants:] The participants consist of a speaker and a listener sending and receiving natural language messages. After observing the goal, the speaker gives an instruction to the listener, and the listener performs an action in the environment. If the game is sequential, the speaker can also give an instruction after each action until the game is solved or the maximum number of steps is reached. The speaker is a message-and-action producing model defined by the \emph{vocabulary} $\Sigma$; the space of \emph{observations} $\mathcal{O}$; the space of \emph{actions} $\mathcal{A}$; and a \emph{model} $f:\mathcal{O}\times\mathcal{G}\rightarrow\Sigma^*\times \mathcal{A}$. The listener is an instruction-follower defined by the same vocabulary $\Sigma$, observation space $\mathcal{O}$, and space of \emph{actions} $\mathcal{A}$ as the speaker; and a \emph{model} $g: \Sigma^* \times \mathcal{O} \rightarrow \mathcal{A}$.
\item[Multi-round Games:] The pair of participants will play a \emph{session} of $N$ rounds of games, which are sampled independently. Different from single-round games ($N\!=\!1$) used in most previous work \cite{lazaridou2016multi, cao2018emergent, fried2018unified, lowe2019interaction}, the participants keep the memory of past games in the same session. Multi-round games are not only more general than
single-round games,
but are essential to few-shot language coordination, because participants have the opportunity to adapt to the interlocutors by learning from feedback during previous rounds.
\end{description}
Note that the listeners in this setting cannot directly observe the goal, so the speakers need to use instructions to inform the listeners about the final or intermediate goals of each game. Within $N$ rounds, the speaker needs to adapt to the listener's knowledge to provide the most effective instructions.
\begin{figure*}[!t]
\begin{small}
\begin{tcolorbox}[left=2pt,right=2pt,top=2pt,bottom=2pt]
\textbf{Training Theory-of-Mind Model for Few-shot Language coordination}
\vspace{5pt}
\begin{tabular}{@{}l@{\hspace{10pt}}ll}
Given & \textbullet\ $N$ training listeners & $L = \{l_i\}_{i=0}^{N-1}\in \mathcal{O}\times\mathcal{I}\rightarrow \mathcal{A} \text{ }(i=0, 1, \dots, N-1)$ sampled from $\mathcal{D}_{\text{listener}}$\\
& \textbullet\ Language game environment & $E$: $\mathcal{O}\times\mathcal{A}\rightarrow \mathcal{O}$\\
& \textbullet\ Speaker & $S$: $\mathcal{O}\times\mathcal{G}\rightarrow\mathcal{I}^+\times\mathcal{A}$\\
& \textbullet\ Message cost function & $C$: $\mathcal{I} \rightarrow \mathbb{R}$\\
& \textbullet\ Constants & cost coefficient $\kappa\in\mathbb{R}$, distribution coefficient $\sigma\in[0, 1]$,\\
&&maximum number of interactions $K \in \mathbb{N}$
\end{tabular}
\setlength{\abovedisplayskip}{0pt}
\setlength{\belowdisplayskip}{0pt}
\setlength{\abovedisplayshortskip}{0pt}
\setlength{\belowdisplayshortskip}{0pt}
While not converged:
\vspace{-5pt}
\begin{enumerate}
\item[1.] Define dataset $\mathcal{D}_{\theta_{\text{mind}}}(l_i) = \{(o_j, m_j, a_j)\}$ for each training listener $l_i$ and game. For a given game, the goal is $g$; the first observation is $o_1$; the message and action are\\[-5pt]
\begin{align}
M, a_j^g &= S(o_j, g)\\
\mathcal{Q}(M)\ &=\underset{m\in M}{\text{normalize}}(\mathcal{P}_{\text{ToM}}(a_j^g \mid o_j, m, \{(o_k, m_k, a_k)_{k=1}^{j-1}\}; \theta_{\text{mind}})\exp(-\kappa C(m))) \quad \label{eq:instruction_distribution} \\
m_j &\sim \sigma \mathcal{Q}(M) + (1-\sigma)\mathcal{U}(M) \quad a_j = l_i(o_j, m_j) \quad o_{j+1} = E(o_j, a_j)
\end{align}
where $a_j^g$ is the planned action of the speaker; $\underset{m\in M}{\text{normalize}}$ represents normalizing unnormalized probabilities.\\[-15pt]
\item[2.] Compute prediction loss \\
\vspace{-5pt}
\begin{align}
\mathcal{L}^{\text{pred}}(\mathcal{D}_{\theta_{\text{mind}}}) = -\mathbb{E}_{i\sim \mathcal{U}([N]),k \sim \mathcal{U}([K]), \mathcal{D}_{\text{supp}} \sim \mathcal{U} (\mathcal{D}_{\theta_{\text{mind}}}^k(l_i)), (o, m, a) \sim \mathcal{U}(\mathcal{D}_{\theta_{\text{mind}}}(l_i))} \log \mathcal{P}_{\text{ToM}}(a \mid o, m, \mathcal{D}_{\text{supp}};\theta_{\text{mind}})
\end{align}
where $i$ is the index of the listener, $k$ is the size of the support set which are uniformly sampled from $\{0, 1, \dots, N-1\}$ and $\{0, 1, \dots, K-1\}$, the support set $\mathcal{D}_{\text{supp}}$ and target sample $(o, m, a)$ are sampled from $\mathcal{D}_{\theta_{\text{mind}}}$ uniformly.
\item[3.] Update the ToM parameters: $ \theta_{\text{mind}} \leftarrow \argmin_{\theta} \mathcal{L}^{\text{pred}}(\mathcal{D}_{\theta_{\text{mind}}})
$
\end{enumerate}
\end{tcolorbox}
\end{small}
\renewcommand{\figurename}{Procedure}
\captionof{procedure}{General Theory-of-Mind (ToM) model training procedure.}
\label{proc:training_tom}
\end{figure*}
\subsection{Population}
\citet{rabinowitz2018machine} coined the notion of ``machine ToM'', which is a model for tracking agents' behaviors. To train and evaluate its ability to adapt to different agents, they create populations of subject agents by using different neural architectures and random seeds for parameter initialization.
Our design of populations draws inspiration from their work. However, to make the similarities and differences between agents controllable, we consider a population as a distribution over parameters neural listeners with the same architecture which have been trained on different datasets. A neural listener $f_{\theta}^L: \mathcal{O}\times\mathcal{I}\rightarrow\mathcal{A}$ is a mapping from $\mathcal{O}$bservations and $\mathcal{I}$nstructions to $\mathcal{A}$ctions with parameter $\theta$ of the neural networks. The parameters trained on dataset $\mathcal{D}$ are:
\begin{equation}
\theta_{\mathcal{D}} = \arg\min_{\theta} \mathcal{L}(f_L, \mathcal{D})
\end{equation}
In this way, the variation over listeners is mainly determined by the features of the dataset. By constructing datasets with different feature distributions, we control the listeners' language abilities.
In the example of Fig.~\ref{fig:demo}, the observations in language games are the items in the visual field, and the agent may perform any number of actions (e.g. ``\texttt{\color{blue}go to \color{red}cabinet}'').
The speaker may provide natural language instructions, which can range from high-level (e.g.~``cool the winebottle'') to low-level (e.g.~``get the wine bottle'', ``take it to the refrigerator'', ``put it in the refrigerator'').
A listener that has never been trained on a particular variety of (usually high-level) instruction would have trouble performing the appropriate actions.
This leads to an exponential population of listeners that are trained on datasets containing, or not containing, particular relevant instructions.
Because of this, in order to effectively and concisely communicate, an effective speaker will have to judge the language abilities of its various partners in the population and adjust appropriately; we explain how we do so in the following section.
\subsection{Theory-of-mind Model}
Theory-of-mind, the ability to build a model of one's conversational partners, is deemed to be crucial in socio-pragmatics theory \cite{premack1978does,tomasello2018children}.
Drawing inspiration from this, we build a theory-of-mind model to learn to mimic the behavior of the listener within a short time window.
\paragraph{Mental State} Modeling mental states is the central concept in building a theory-of-mind.
We define the mental state of the listener as the parameters of a neural model, the \emph{ToM model},
that produces the same output for the same inputs as the listener: $\forall x\in \Sigma^*, o \in \mathcal{O}, g_{\text{ToM}}(x, o;\theta_{\text{mind}}) \approx g(x, o;\theta)$. It should be noted that in the general case, particularly when different model architectures are used to represent the model itself and the ToM model, the mental state representations may not be unique or even exist.
In other words, for any model $\theta$ there may be more than one parameter setting $\theta_{\text{mind}}$ that satisfies this condition, or there may be no $\theta_{\text{mind}}$ that produces the exact same output
\paragraph{Building a Theory-of-mind}
Learning a ToM model is reduced to
inferring the mental state of the listener. For a given listener $g$ with parameters $\theta$ and ToM model $g_{\text{ToM}}$, we seek a mental state representation $\theta_{\text{mind}}$. In practice, we use identical neural architectures for both the listener and ToM Model. However, inferring the exact mental state is infeasible within few interactions. Therefore, we estimate $g_{\text{ToM}}$ such that
\begin{equation}
\theta_{\text{mind}} = \arg\min_{\theta'} \mathbb{E}_{o, m}\mathcal{L} (g_{\text{ToM}}(o, m;\theta'), g(o, m;\theta))
\end{equation}
It is straightforward to apply this definition of mental state in the psychological context for which it was originally proposed.
The mental state $\theta_{\text{mind}}$ is the representation of the listener's language abilities, which are not directly observable, and which are ultimately used for predicting the belief and behavior of the speaker \cite{premack1978does}.
For example, in our first set of experiments we focus on referential game where the speaker describes the target in order to let the listener pick it out from distractors. We construct a population in which neural listeners with LSTMs and word embeddings have different language comprehension abilities for different languages.
One of the possible representations controls the word embeddings in different languages: the mental state of a good language listener should have more meaningful word embeddings, while the one which cannot understand the language should have more random ones. Given that the speaker can acquire an accurate mental state for the listener, it can be used for predicting the probability of listener choosing the correct image when hearing descriptions in different languages. By choosing the one that yields the correct image with the highest probability, the speaker generates the descriptions which improve the referential game. On the other hand, high quality descriptions help the speaker better narrow down the language abilities of the listener. This is similar to the two-way interrelation between language and ToM in humans \cite{de2007interface}.
Following this direction, we present a dynamic view of ToM by putting the observer inside the conversation, instead of the static view of \citet{rabinowitz2018machine}, which uses ToM for tracking the behavior of the agent without interfering in the games. Our training procedure is presented in Proc.~\ref{proc:training_tom}.
We aggregate a dataset $D_{\theta_{\text{mind}}}$ at each epoch, and update the parameters by optimizing the ToM model on the dataset. To aggregate the dataset for each training listener, we randomly sample from the posteriors of the ToM model and uniform distributions over the candidates, which keeps a certain degree of exploration, modulated by distribution coefficient $\sigma$ (through the paper, we use $\sigma = 0.5$). In practice, parameters are updated with stochastic gradient descent by sampling listeners and using the history of each listener at each time step as a support set for predicting the next actions of the listener. Following the literature on speech acts, e.g.~\citet{monroe2015learning}, we also add exponential cost penalty $\exp(-\kappa C(m))$ as a prior to penalize long instructions. (We have not explored the space of penalty functions in this paper, but the exponential function is widely used in the pragmatics literature, e.g. \cite{monroe2015learning}, \cite{morris2019pressure}.) In Fig.~\ref{fig:demo} (a\&b), although ``go to fridge'' yields the highest probability of gold action, no instruction is given in order to express the goal concisely.
Similarly to the imitation learning algorithm DAgger \cite{ross2011reduction}, the dataset is collected using expert actions. However, there is a major difference between Proc. \ref{proc:training_tom} and DAgger --- we optimize the prediction of actions conditioned on the observations and instructions instead of the instruction probability directly.
The following theorem shows that our model will improve the instruction generation quality:
\begin{theorem}[informal]
\label{th:1}
Given a small enough distribution coefficient $\sigma$ and good enough bounded candidate pools, the instruction distribution produced by the ToM model becomes optimal as prediction loss goes to zero.
\end{theorem}
\paragraph{Discussion} The conditions of Theorem \ref{th:1} mean that the speaker model $S$ must be a well-trained model to produce good enough candidates pools. In practice, this condition is not hard to meet:
for instance, in our language navigation experiment the listeners can at least understand the lowest-level instructions, and the speaker generates four levels of instructions by rule-based experts. Therefore, the practical implication of this theorem is helpful -- our method reduces to DAgger without expert instructions. Different from DAgger, our training method doesn't directly optimize the instruction distribution against expert's instructions, but optimizes the action prediction loss instead, which upper-bounds the instruction loss.
\subsection{Meta-learning ToM Model}
To acquire an estimate of the mental state from very few interactions, the ToM model needs to quickly learn from a small support set. In theory, any model for parameterizing $\mathcal{P}_{\text{ToM}}(a \mid o, m, \mathcal{D}_{\text{supp}};\theta_{\text{mind}})$ could work in our framework.
As a general method applicable to all ToM models, we apply model-agnostic meta-learning (MAML; \citet{finn2017model}), a method that explicitly trains models to be easily adaptable in few-shot settings. Given support dataset $\mathcal{D}_{\text{supp}}$, the inner loop updates parameters for $N_{\text{inner}}$ steps:
\begin{equation}
\begin{aligned}
\theta^{(0)} &= \theta_{\text{mind}} \\
\theta^{(i+1)} &= \theta^{(i)} - \eta \nabla_{\theta} \mathcal{L}(\mathcal{D}_{\text{supp}}; \theta)|_{\theta=\theta^{(i)}}
\end{aligned}
\end{equation}
where $\eta$ is the inner loop learning rate, which, in practice, is not share across modules following \citet{antoniou2018train}. The loss function on the support set is the negative log-likelihood of listener's action given observations $o$ and the instructions $m$
\begin{equation}
\mathcal{L}(\mathcal{D}_{\text{supp}}; \theta) = - \mathbb{E}_{(o, m, a)\sim\mathcal{D}_{\text{supp}}} \log p_{\theta}(a\mid o, m)
\end{equation}
After $N_{\text{inner}}$ steps, we get the prediction on the target observation $o$ and instruction $m$
\begin{equation}
\mathcal{P}_{\text{ToM}}(a \mid o, m, \mathcal{D}_{\text{supp}};\theta_{\text{mind}}) = p_{\theta^{N_{\text{inner}}}}(a\mid o, m)
\end{equation}
Outer loop optimize $\theta_{\text{mind}}$ by mini-batch stochastic gradient descent
\begin{equation}
\theta_{\text{mind}} \leftarrow \theta_{\text{mind}} - \eta_{\text{outer}} \nabla_{\theta} \mathcal{L}^{\text{pred}} (\mathcal{D}_{\theta_{\text{mind}}})
\end{equation}
The outer loop also runs for a given $N_{\text{outer}}$ epochs.
\subsection{Deploying the ToM Model}
Similar to Proc.~\ref{proc:training_tom}, we evaluate ToM by using it to measure the probability of the gold action given the instructions. However, here we choose the best one instead of sampling from the posterior. Alg.~\ref{proc:test_tom} shows the evaluation procedure.
\begin{algorithm}
\small
\caption{Evaluate ToM Model}
\label{proc:test_tom}
\begin{algorithmic}
\REQUIRE Testing Listeners $L_{test}$, $E, S, C, \kappa, K$ as in Proc. \ref{proc:training_tom}
\STATE $pt \leftarrow 0$
\FORALL{$l_i$ in $L_{test}$}
\STATE $\mathcal{D}\leftarrow \emptyset$
\STATE $o, a \leftarrow$ \textsc{Restart}
\FOR{j in 1..K}
\STATE{$o, g\leftarrow E(o, a)$}
\IF{\textsc{Done}}
\STATE $pt \leftarrow pt + \bm{1}[\textsc{Success}]$
\STATE $o, g\leftarrow E(\textsc{Restart})$
\ENDIF
\STATE $M, a^g\leftarrow S(o, g)$
\STATE $m \leftarrow \argmax_m \mathcal{P}_{\text{ToM}}(a^g \mid o, m, \mathcal{D}\}; \theta_{\text{mind}})e^{-\kappa C(m)}$
\STATE $a \leftarrow l_i(o, m)$
\STATE $\mathcal{D} \leftarrow \mathcal{D} \cup \{(o, m, a)\}$
\ENDFOR
\ENDFOR
\STATE \textbf{Return} $pt$
\end{algorithmic}
\end{algorithm}
\subsection{Connection with Other Pragmatics Models}
It should be noted that using a listener model to help choose best utterance has been studied for almost a decade under the rational speech act model (RSA, \citet{frank2012predicting}; including recent more general models, e.g. \citet{Wang2020AMT}), a Bayesian framework that takes listener's choices in to account by
\begin{equation}
\begin{aligned}
P_{S^{n}} (m\mid a, o) &= \frac{P_{L^{n-1}}(a\mid m, o) P (m\mid o) }{\sum_{m'\in M}P_{L^{n-1}}(a\mid m', o) P(m'\mid o)}\\
P_{L^{n}} (a\mid m, o) &= \frac{P_{S^{n-1}}(m\mid a, o) P (a\mid o) }{\sum_{a'\in A}P_{L^{n-1}}(m\mid a', o) P(a'\mid o)}
\end{aligned}
\end{equation}
where $S^n$ denotes the $n$-level speaker and $L^{n-1}$ denotes the $(n-1)$-level listener, $M, A, o$ denotes the space of instructions, actions, and the observation shared by the speaker and listener respectively, $P(m\mid o)$ and $P(a\mid o)$ are the priors over instructions and actions. The base speaker $S^0$ and listener $L^0$ are often parameterized using neural networks directly \cite{fried2018unified}.
As a general framework for computational pragmatics, RSA models both language production and language comprehension in a recursive fashion, although the first and the second levels are predominantly used. In this paper, we focus on language production, while improving the listeners with more layers of reasoning is left for future work.
However, the most notable difference between our model and neural RSAs is the notion of few-shot coordination. RSA base speaker and listener models are often fixed after training, making them unable to adapt to new partners during testing. While our model has a similar formulation (Eq. \ref{eq:instruction_distribution}) to the first level speaker of RSA, our ToM listener's action probability conditions on the listener's previous behavior.
\section{Multilingual Referential Games}
We test the ability of the proposed ToM model to perform few-shot language coordination in two settings: the running example of vision-language navigation, and also in a simpler setting of \emph{referential games}, which we discuss first in this section.
In a referential game, the speaker gives a description for the target image as its instruction, and the listener's action is to choose the target from distractors, after which the listener either wins the game and gets one point or loses it.
Following \citet{lazaridou2016multi, lowe2019interaction}, we use 30k image-caption pairs from MSCOCO dataset \cite{lin2014microsoft}.
In each game, a target image sampled from the dataset uniformly, and nine distractors are sampled from 1,000 nearest images in terms of cosine similarity of outputs of second last layer of pretrained ResNet \cite{he2016deep}.
In contrast to previous work, which mainly deals with a pair of one speaker and one listener, we are interested in learning with a population of listeners.
In order to achieve this, we propose a setting of \emph{multilingual} referential games, where each listener has the ability to understand different languages at different levels of ability.
\paragraph{Listener distribution}
We first translate MSCOCO captions into nine languages, German, Lithuanian, Chinese, Italian, French, Portuguese, Spanish, Japanese and Greek, from English, using Google Translate\footnote{\url{https://translate.google.com}}. For each listener, we sample a vocabulary distribution $v_1,v_2,\dots,v_{10}$ from 10-dimensional Dirichlet distribution $Dir(0.5, 0.5, \dots, 0.5)$. The listener's vocabulary is built up with 5,000 words, where for each language $i$ we select the most frequent $5,000*v_i$ words in MSCOCO captions in that language to be added to the listener's vocabulary. The reason behind this design is cognitively motivated; word frequency has high correlation with age of acquisition (AoA) of words \cite{juhasz2005age}.
The dataset used to train the listener is finally created by filtering out sentences with more than one word outside the vocabulary. Given target image $x^*$, instruction $m$, and distractors $x_{i}, i=1, 2, \dots, 9$, the listener computes
\begin{equation}
\label{eq:listener}
\begin{aligned}
z_i &= \mathtt{ResNet}(x_i)\quad\text{for }i=1, 2, \dots, 9, *\\
z &= \mathtt{LSTM}(m)\\
\hat{y} &= \mathtt{softmax}(z^{\top} \{z_1, z_2,\dots,z_9, z^*\})
\end{aligned}
\end{equation}
The listener is trained to minimize the expected negative log-likelihood $-\log \hat{y}^*$ by stochastic gradient descent.
Following \citet{lowe2019interaction},
we train the listeners by randomly\footnote{We have also tried other schemes in their paper, but those do not yield significantly better performance.} interleaving between self-play (training with a companion speaker) and supervised training (with MSCOCO annotations or their translations). The companion speaker takes the representation of the target image as input:
\begin{equation}
\label{eq:speaker}
\begin{aligned}
z^* &= \mathtt{ResNet}(x^*)\\
l &= \mathtt{teacher\text{-}forcing} (\mathtt{LSTM}(z^*), m) \\
\hat{m} &= \mathtt{gumbel\text{-}softmax}(\mathtt{LSTM}(z^*))
\end{aligned}
\end{equation}
During supervised training, the model is trained to minimize the teacher-forcing NLL loss, while during self-play the sampled instruction is fed to the listener with Gumbel-softmax \cite{jang2016categorical}. This procedure produces 120 listeners, for which the average success rate with MSCOCO captions within the listener's vocabulary is 81.6\% and the average success rate with companion speakers is 83.3\%. These listeners are randomly divided into training, validation, and testing listeners (80/20/20).
\paragraph{Speaker training} Using the setup in Eqs.~\ref{eq:listener} and \ref{eq:speaker}, we equip the speaker with a vocabulary of 20K words equally distributed in ten languages. We use the same data filtering method and training scheme as described above. To produce a pool of candidates in all languages, we add a language marker at the front of each training caption, so that the languages of instructions are controllable. Using beam search (size of 10), we generate five instructions per language (i.e.~$N_M\!\!=\!50$). The speaker achieves an 87\% success rate with the listeners used to train the speaker
and a caption PPL of 23.7.
\paragraph{ToM Model} The ToM models uses the same architecture as Eq.~\ref{eq:listener}. We use penalty $\kappa=0$. In the referential game, the action space $\mathcal{A}=\{1, 2, \dots, 9, *\}$ and observation $o = (x_1, x_2, \dots, x_9, x^*)$, we have
\begin{equation}
p_{\theta}(a\mid o, m) = \hat{y}_{a}.
\end{equation}
The MAML hyper-parameters are $\eta=0.01, N_{\text{inner}} = 5, \eta_{\text{outer}} = 0.0001, N_{\text{outer}}=500$, and batch size is 2.
\vspace{-2pt}
\paragraph{Evaluation} We evaluate the ToM-assisted speaker and other baselines with the same set of testing listeners. For each pair of speaker and listener, we calculate the average success rate of 500 $K=20$-game sessions.
\begin{table}[!h]
\centering
\small
\begin{tabular}{lr}\\\toprule
Model & Ave success\\\midrule
Gold-standard speaker &91.20\%\\ \hline\hline
Non-ToM speaker &37.38\%\\ \hline
RSA speaker & 42.83\%\\ \hline
ToM-assisted speaker &\textbf{58.19}\%\\ \bottomrule
\end{tabular}
\caption{Models and their respective referential game accuracy.}\label{wrap-tab:referential-game}
\end{table}
The gold-standard speaker denotes the success rate of using the testing listener in place of the ToM listener. The score of over $90\%$ indicates that the candidate pool is of high quality, so a speaker with a well-modeled ToM listener has ample room for achieving high accuracy. The non-ToM speaker uses the instruction with the highest probability in the speaker model; the RSA speaker uses the listener for training the speaker in place of the ToM listener. Our model achieves a significantly higher success rate, demonstrating that the ToM model could help produce better instructions for this referential game.
\begin{figure}
\centering
\includegraphics[width=0.7\linewidth]{acc.pdf}
\caption{Average prediction accuracy of ToM model at each time step during evaluation. (95\% confidence interval)}
\label{fig:acc}
\end{figure}
However, does ToM model truly learn to adapt to individual listeners? We compute the accuracy of predicting the listener's behavior during the same session.
Fig.~\ref{fig:acc} shows that the prediction accuracy of listener's actions is significantly improved within sessions, which shows ToM indeed learns to adapt to individual test listeners.
\section{ALFWorld Task Navigation}
In the previous section, we have shown that ToM could help games with simple dynamics, and learn to adapt to listeners. This section will show its application in a more complex game: language navigation.
\begin{figure}[!t]
\centering
\includegraphics[width=0.8\linewidth, trim=0 5 0 0, clip]{plot.pdf}
\caption{Experimental results for the language navigation setting with average instruction length on the horizontal-axis and game points on the vertical. Colors represent different models.
}
\label{fig:language_navigation}
\end{figure}
We use the Alfworld \cite{shridhar2020alfworld} platform, which creates a natural language command action space upon the Alfred environment for vision-language navigation \cite{ALFRED20}. In each game, a household task is given by the environment. We generate expert trajectories for all tasks in Alfworld, and manually create four levels of instructions, from task-level to action-level, which are denoted as $\mathcal{I}_i, i=1, 2, 3, 4$. The differences between these four levels are the levels of abstraction. An action-level instruction corresponds to a single action in the Alfworld, while a task-level instruction corresponds to a whole trajectory which consists of more than eight commands. The two other levels are in between. The candidate pool at each time step consists of four instructions from each level ($N_M=4$). To create each listener, we draw an instruction distribution from $Dir(0.6, 0.4, 0.3, 0.2)$ for each of the six types of task in the environment. Listeners are of the same neural model as in \citet{shridhar2020alfworld}. While training the listeners, the instructions are randomly drawn from the instruction distributions according to the task type. This procedure produces 50 listeners. The average success rate of listeners is 83.6\%. These listeners are randomly divided into training, validation, and testing listeners (30/10/10). We define the cost as the average total length of the set of instructions, i.e.~repetitive instructions are only calculated once. The cost function is defined as $C(m) = 2^i \ \text{if } m \in \mathcal{I}_i$. Within one session, the maximum number of interactions between speaker and listener is $K=100$, and maximum number of interactions in a game is 20. Listeners' hyper-parameters are the same as the ones in \citet{shridhar2020alfworld}, while MAML hyper-parameters are the same as referential game.
In Fig.~\ref{fig:language_navigation}, we compare ToM-assisted speakers and random speakers. We didn't compare with an RSA speaker, because differently from the multilingual referential games, the speaker is rule-based and no listener is used for training the speaker. A random speaker draws an instruction distribution from $Dir(0.7, 0.7, 0.7, 0.7)$, and sample instructions from the candidate pools using the instruction distribution. The ToM speaker with $\kappa=0$ predominantly uses action-level instructions, while the ToM speaker with $\kappa=10$ uses task-level instructions most of the time. Comparing ToM speakers and random speakers, we find that for $\kappa = \{0, 1, 2\}$, ToM speakers achieve higher game points and lower cost than random ones; for $\kappa=10$, the ToM speaker does not have significant improvement over a random one, since only the listeners that have been trained on sufficient action-level instructions can succeed.
\section{Related Work}
\subsection{Language Games}
Language games have been the proving ground for various linguistics theories since their conception by \citet{wittgenstein1953philosophical}. Recently, the most widely used language game is the referential game, in which the speaker observes the target and distractors and uses language to instruct the listener on how to pick out the target.
\textbf{Emergent Communication} Without natural language annotations, this pressure for the speaker and listener enables language emergence. \citet{batali1998computational} first uses the same recurrent neural networks as the speaker and the listener to conduct emergent communication in referential game. Following this lead, \citet{lazaridou2016multi} study how emergent languages are grounded to the input images. \citet{cao2018emergent} studies multi-turn communication via negotiation. \citet{chaabouni2020compositionality,gupta-etal-2020-compositionality} study the compositionally and systematicity of emergent languages.
\textbf{Learning Common Languages} By using natural language annotations, agents learn a common language so that agents that are never trained together can be expected to communicate. \citet{lazaridou2016multi} studies using MSCOCO \cite{lin2014microsoft} annotations as gold labels for both speakers and listeners. \citet{lowe2019interaction} found that alternating between self-playing and supervised learning benefits communication performance. \citet{wang2016games} show that humans have the ability to adapt to the machine's capability in language games. \citet{bullard2020exploring} found that when language follows Zipf law, zero-shot communication is possible.
\textbf{Language Games with Community} \citet{tieleman2019shaping} learns representations by training with a community of encoders and decoders. The difference between our work and theirs is that our MAML listener learns to adapt to different listeners in the population in a few games. The performance of their model should be equivalent to our model's result at time step 1. \citet{lowe2019learning} considers the adaptation problem, which is definitely relevant. However, adapting their model to our settings is non-trivial, which is beyond the scope of this paper.
This referential game setting used in most previous work can be seen as a special case of our few-shot coordination formulation, where the number of games is one and the partners are mostly the same ones as in the training phase. These two differences prevent the previous models from learning to adapt due to the lack of pressure to do so.
\subsection{Machine Theory of Mind}
Computational and neural models of theory-of-mind have been studied for decades \cite{siegal2002neural,rescorla2015computational}. \citet{rabinowitz2018machine} are the first to present a successful modeling of the mental state of various species of agent. While we also train a ToM model with meta learning, we put the ToM model into use. The predictions provided by the ToM model serve as reranker in the speaker's model. The variety of models is also more diverse than the species used in this paper. Importantly, \citet{nematzadeh2018evaluating,le2019revisiting} find that neural models for question answering fail to keep track of inconsistent states of the world. \citet{moreno2021neural} extends machine ToM to neural recursive belief states. We expect improvement over our current model by modeling higher-order recursive belief, which is left for future work. \citet{yuan2020emergence} explicitly trains belief state prediction with supervised learning, while our model's belief state is latent.
\subsection{Similar Topics in Reinforcement Learning}
\textbf{Model-based Reinforcement Learning} Model-based reinforcement learning focuses on building a model of the environment to improve data efficiency \cite{kaelbling1996reinforcement}, which could be applied to the zero-shot coordination problem by treating the listener as a part of the environment. Recently, neural networks have been used widely for model-based RL \cite{gal2016improving, depeweg2016learning, nagabandi2018neural,chua2018deep,janner2019trust}. We should point out that despite their similarities to our model,
we focus on modeling different and unseen agents in the population within a few interactions.
\textbf{Alternatives to Self-play}
Zero-shot coordination has attracted much attention recently. \citet{hu2020other} propose other-play which maximizes the expected reward working with random partners. In contrast to their approach, we explicitly model the partner's ToM and focus on language coordination, which required more complicated modeling than the environments in their experiments.
\section{Implications and Future Work}
We have introduced few-shot language coordination task and proposed ToM model for tracking the listener's mental state. Different from previous work using single-round games and self-play training, we consider more general multi-round games and playing with novel listeners. ToM model shows its ability to adapt to novel listeners and assist speakers in choosing the best instructions in both multilingual referential games and the language navigation task. We attribute the success of ToM model to modeling socio-pragmatics process in an explicit way. Many interesting questions about modeling ToM in few-shot language coordination remain open. The most immediate is how to model ToM from the listener's perspective, leading to a dialog agent that can acquire new knowledge through conversation. One step further, similar to RSA, ToM can also be modeled in a recursive manner, which may further improve language games.
\section*{Acknowledgements}
This work was supported by the DARPA GAILA project (award HR00111990063). The views and conclusions contained in this document are those of the authors and should
not be interpreted as representing the official policies, either expressed or implied, of the U.S. Government. The U.S. Government is authorized to reproduce and distribute reprints for Government purposes notwithstanding any copyright notation here on.
\section{Introduction}
Natural language is an ubiquitous communication medium between human interlocutors, and is shaped by the desire to efficiently cooperate and achieve communicative goals \cite{gibson2019efficiency}.
Because of this, there has been interest in creating artificial agents that mimic this communication process, with a wide variety of works examining communication between agents via either completely artificial \emph{emergent} language \cite{wagner2003progress, bouchacourt2018agents, li2019ease, kharitonov2020entropy}, or through \emph{natural} language such as English \cite{lazaridou2016multi,lowe2019interaction}.
In general, these methods model interaction between a pair of agents, a \emph{speaker} and a \emph{listener} that attempt to jointly achieve a goal where the language use is learned to optimize success with respect to a collaborative task (for example, in Fig. \ref{fig:demo} the speaker instructs an embodied agent to perform a task in an environment).
\begin{figure}[!t]
\includegraphics[width=\linewidth]{demo20.pdf}
\caption{A conversation between a speaker and a listener collaboratively solving a navigation task. (a) At the start of the task, a goal (bold font) is given to the speaker (purple robot head). The speaker first gives a task-level instruction. Without previous knowledge of the listener, the speaker thinks the listener (green robot) will proceed to the fridge after three correct actions (monospace font) in a row. Grey observations are given by the environment after each action. (b) shows the belief of the speaker about the listener's action after a few instruction candidates. Note that to keep instructions concise the speaker chooses ``no instruction'' over ``walk to fridge'' despite the higher probability of listener taking correct action given the latter instruction. (c) After the listener makes a mistake by going to the microwave, the speaker figures out that the listener cannot understand ``cool'' in the high-level instruction given, and gives low-level instruction ``walk to the fridge''. (d) shows the belief of speaker at this time step. Note that the probability of action ``\texttt{\color{blue}go to \color{red}fridge}'' without instruction decreases due to the wrong action of the listener.
}
\label{fig:demo}
\end{figure}
However, in contrast to this setup, human speakers interact with not a single listener, but many different conversational partners.
In doing so, they also adapt to each other's language within short conversations.
One of the representative phenomena is entrainment, in which interlocutors align their language on both acoustic-prosodic and lexical dimensions during communication \cite{brennan1996conceptual, levitan2018acoustic}.
These issues remain mostly unattested in previous work on multi-agent communication --- it remains an open question how to train an agent which can adapt to communicating with novel partners quickly.
We define this adaptive communication problem as \emph{few-shot language coordination}. As shown in Fig. \ref{fig:demo}, within a few rounds of the game, the speaker must adapt its language based on the responses from the listener to achieve the \emph{communicative goal} of helping the listener perform the correct actions as many times as possible. This few-shot coordination setting provides the agents with the pressure to adapt on-the-fly -- something that current models generally cannot achieve, even those that model pragmatics, e.g. the rational speech act model \cite{frank2012predicting}.
Developmental psychology argues for the importance of Theory of Mind (ToM), the understanding of others’ mental states, and also the ability of interlocutors to act upon others mental states to achieve desired effects \cite{tomasello2018children}.
In this paper, we study the importance of modeling the beliefs of one's conversational partner to achieve few-shot language coordination.
In particular, we train a model that quickly adapts to predict the actions of the listeners in real time. At each time step, the speaker predicts the listener's likely next action given all possible instructions and the listener's previous actions.
This is essentially a few-shot learning problem, which we attack with model-agnostic meta-learning (MAML) \cite{finn2017model}.
In order to achieve the communicative goal, the speaker chooses the best instruction to give so that the probability of the listener performing the correct actions is maximised.
We expect the resulting agent to not only mimic humans' ability to model a listener's mental state but also to leverage this estimate to choose better instructions. Through empirical evaluation, we aim to answer the question:
\begin{quote}
\it
Can an agent, equipped with a model of theory of mind, quickly adapt to a listener's language in a few-shot language coordination game?
\end{quote}
Our experiments answer in the affirmative in the both a referential game and a vision-language navigation setting.
\section{Few-shot Language Coordination}
Consider again the example depicted in Fig.~\ref{fig:demo}.
A speaker model observes the goal of the current task (``pick and cool wine bottle, place it on the dining table''), and sends messages to a listener model, in an attempt to help it finish the task.
The listener model chooses actions to take given the latest and previous instructions.
If the listener makes a mistake, such as going to the microwave instead of the refrigerator, the speaker should realize that the listener misunderstood some aspect of the high-level instructions in the first message. This misstep informs the speaker's model of the listener's ability, leading them to give lower-level instructions to help correct the trajectory. Through \emph{several games}, the speaker gathers enough data to provide customized messages for individual listeners.
This is only possible if a proper prior is provided to the speaker. The simplest prior can be hand-coded rules, e.g. if listener cannot understand abstract instructions, try simpler ones.
However, to pursue a more general and powerful communication model (e.g. knowing when to simplify vs. rephrase),
we study whether this kind of few-shot language coordination can be \emph{learned} by playing with a \emph{population} of listeners. This section proposes a method to construct meaningful populations.
\subsection{Asymmetric Speaker-Listener Games}
Following previous work on communicative agents \cite{lazaridou2016multi,cao2018emergent,lowe2019interaction}, we use goal-oriented language games
as the test bed for few-shot language coordination. A general goal-oriented language game provides an environment where the participants uses language to communicate with each other to achieve the given goal.
We consider the most basic setting of a simplified two-player shared-goal multi-round setup:
\begin{description}[align=left]
\item[Environment:] The environment is defined by $\mathcal{O}$bservation space, $\mathcal{A}$ction space, $\mathcal{G}$oal space and transition function $E:\mathcal{O}\times \mathcal{A}\rightarrow\mathcal{O}\times \mathcal{G}$. At the start of each game, the environment provides the speaker with a goal and both participants with observations after each action is taken by the listener. A new game starts after the previous one succeeds or reaches a maximum number of steps.
\vspace{-2pt}
\item[Participants:] The participants consist of a speaker and a listener sending and receiving natural language messages. After observing the goal, the speaker gives an instruction to the listener, and the listener performs an action in the environment. If the game is sequential, the speaker can also give an instruction after each action until the game is solved or the maximum number of steps is reached. The speaker is a message-and-action producing model defined by the \emph{vocabulary} $\Sigma$; the space of \emph{observations} $\mathcal{O}$; the space of \emph{actions} $\mathcal{A}$; and a \emph{model} $f:\mathcal{O}\times\mathcal{G}\rightarrow\Sigma^*\times \mathcal{A}$. The listener is an instruction-follower defined by the same vocabulary $\Sigma$, observation space $\mathcal{O}$, and space of \emph{actions} $\mathcal{A}$ as the speaker; and a \emph{model} $g: \Sigma^* \times \mathcal{O} \rightarrow \mathcal{A}$.
\item[Multi-round Games:] The pair of participants will play a \emph{session} of $N$ rounds of games, which are sampled independently. Different from single-round games ($N\!=\!1$) used in most previous work \cite{lazaridou2016multi, cao2018emergent, fried2018unified, lowe2019interaction}, the participants keep the memory of past games in the same session. Multi-round games are not only more general than
single-round games,
but are essential to few-shot language coordination, because participants have the opportunity to adapt to the interlocutors by learning from feedback during previous rounds.
\end{description}
Note that the listeners in this setting cannot directly observe the goal, so the speakers need to use instructions to inform the listeners about the final or intermediate goals of each game. Within $N$ rounds, the speaker needs to adapt to the listener's knowledge to provide the most effective instructions.
\begin{figure*}[!t]
\begin{small}
\begin{tcolorbox}[left=2pt,right=2pt,top=2pt,bottom=2pt]
\textbf{Training Theory-of-Mind Model for Few-shot Language coordination}
\vspace{5pt}
\begin{tabular}{@{}l@{\hspace{10pt}}ll}
Given & \textbullet\ $N$ training listeners & $L = \{l_i\}_{i=0}^{N-1}\in \mathcal{O}\times\mathcal{I}\rightarrow \mathcal{A} \text{ }(i=0, 1, \dots, N-1)$ sampled from $\mathcal{D}_{\text{listener}}$\\
& \textbullet\ Language game environment & $E$: $\mathcal{O}\times\mathcal{A}\rightarrow \mathcal{O}$\\
& \textbullet\ Speaker & $S$: $\mathcal{O}\times\mathcal{G}\rightarrow\mathcal{I}^+\times\mathcal{A}$\\
& \textbullet\ Message cost function & $C$: $\mathcal{I} \rightarrow \mathbb{R}$\\
& \textbullet\ Constants & cost coefficient $\kappa\in\mathbb{R}$, distribution coefficient $\sigma\in[0, 1]$,\\
&&maximum number of interactions $K \in \mathbb{N}$
\end{tabular}
\setlength{\abovedisplayskip}{0pt}
\setlength{\belowdisplayskip}{0pt}
\setlength{\abovedisplayshortskip}{0pt}
\setlength{\belowdisplayshortskip}{0pt}
While not converged:
\vspace{-5pt}
\begin{enumerate}
\item[1.] Define dataset $\mathcal{D}_{\theta_{\text{mind}}}(l_i) = \{(o_j, m_j, a_j)\}$ for each training listener $l_i$ and game. For a given game, the goal is $g$; the first observation is $o_1$; the message and action are\\[-5pt]
\begin{align}
M, a_j^g &= S(o_j, g)\\
\mathcal{Q}(M)\ &=\underset{m\in M}{\text{normalize}}(\mathcal{P}_{\text{ToM}}(a_j^g \mid o_j, m, \{(o_k, m_k, a_k)_{k=1}^{j-1}\}; \theta_{\text{mind}})\exp(-\kappa C(m))) \quad \label{eq:instruction_distribution} \\
m_j &\sim \sigma \mathcal{Q}(M) + (1-\sigma)\mathcal{U}(M) \quad a_j = l_i(o_j, m_j) \quad o_{j+1} = E(o_j, a_j)
\end{align}
where $a_j^g$ is the planned action of the speaker; $\underset{m\in M}{\text{normalize}}$ represents normalizing unnormalized probabilities.\\[-15pt]
\item[2.] Compute prediction loss \\
\vspace{-5pt}
\begin{align}
\mathcal{L}^{\text{pred}}(\mathcal{D}_{\theta_{\text{mind}}}) = -\mathbb{E}_{i\sim \mathcal{U}([N]),k \sim \mathcal{U}([K]), \mathcal{D}_{\text{supp}} \sim \mathcal{U} (\mathcal{D}_{\theta_{\text{mind}}}^k(l_i)), (o, m, a) \sim \mathcal{U}(\mathcal{D}_{\theta_{\text{mind}}}(l_i))} \log \mathcal{P}_{\text{ToM}}(a \mid o, m, \mathcal{D}_{\text{supp}};\theta_{\text{mind}})
\end{align}
where $i$ is the index of the listener, $k$ is the size of the support set which are uniformly sampled from $\{0, 1, \dots, N-1\}$ and $\{0, 1, \dots, K-1\}$, the support set $\mathcal{D}_{\text{supp}}$ and target sample $(o, m, a)$ are sampled from $\mathcal{D}_{\theta_{\text{mind}}}$ uniformly.
\item[3.] Update the ToM parameters: $ \theta_{\text{mind}} \leftarrow \argmin_{\theta} \mathcal{L}^{\text{pred}}(\mathcal{D}_{\theta_{\text{mind}}})
$
\end{enumerate}
\end{tcolorbox}
\end{small}
\renewcommand{\figurename}{Procedure}
\captionof{procedure}{General Theory-of-Mind (ToM) model training procedure.}
\label{proc:training_tom}
\end{figure*}
\subsection{Population}
\citet{rabinowitz2018machine} coined the notion of ``machine ToM'', which is a model for tracking agents' behaviors. To train and evaluate its ability to adapt to different agents, they create populations of subject agents by using different neural architectures and random seeds for parameter initialization.
Our design of populations draws inspiration from their work. However, to make the similarities and differences between agents controllable, we consider a population as a distribution over parameters neural listeners with the same architecture which have been trained on different datasets. A neural listener $f_{\theta}^L: \mathcal{O}\times\mathcal{I}\rightarrow\mathcal{A}$ is a mapping from $\mathcal{O}$bservations and $\mathcal{I}$nstructions to $\mathcal{A}$ctions with parameter $\theta$ of the neural networks. The parameters trained on dataset $\mathcal{D}$ are:
\begin{equation}
\theta_{\mathcal{D}} = \arg\min_{\theta} \mathcal{L}(f_L, \mathcal{D})
\end{equation}
In this way, the variation over listeners is mainly determined by the features of the dataset. By constructing datasets with different feature distributions, we control the listeners' language abilities.
In the example of Fig.~\ref{fig:demo}, the observations in language games are the items in the visual field, and the agent may perform any number of actions (e.g. ``\texttt{\color{blue}go to \color{red}cabinet}'').
The speaker may provide natural language instructions, which can range from high-level (e.g.~``cool the winebottle'') to low-level (e.g.~``get the wine bottle'', ``take it to the refrigerator'', ``put it in the refrigerator'').
A listener that has never been trained on a particular variety of (usually high-level) instruction would have trouble performing the appropriate actions.
This leads to an exponential population of listeners that are trained on datasets containing, or not containing, particular relevant instructions.
Because of this, in order to effectively and concisely communicate, an effective speaker will have to judge the language abilities of its various partners in the population and adjust appropriately; we explain how we do so in the following section.
\subsection{Theory-of-mind Model}
Theory-of-mind, the ability to build a model of one's conversational partners, is deemed to be crucial in socio-pragmatics theory \cite{premack1978does,tomasello2018children}.
Drawing inspiration from this, we build a theory-of-mind model to learn to mimic the behavior of the listener within a short time window.
\paragraph{Mental State} Modeling mental states is the central concept in building a theory-of-mind.
We define the mental state of the listener as the parameters of a neural model, the \emph{ToM model},
that produces the same output for the same inputs as the listener: $\forall x\in \Sigma^*, o \in \mathcal{O}, g_{\text{ToM}}(x, o;\theta_{\text{mind}}) \approx g(x, o;\theta)$. It should be noted that in the general case, particularly when different model architectures are used to represent the model itself and the ToM model, the mental state representations may not be unique or even exist.
In other words, for any model $\theta$ there may be more than one parameter setting $\theta_{\text{mind}}$ that satisfies this condition, or there may be no $\theta_{\text{mind}}$ that produces the exact same output
\paragraph{Building a Theory-of-mind}
Learning a ToM model is reduced to
inferring the mental state of the listener. For a given listener $g$ with parameters $\theta$ and ToM model $g_{\text{ToM}}$, we seek a mental state representation $\theta_{\text{mind}}$. In practice, we use identical neural architectures for both the listener and ToM Model. However, inferring the exact mental state is infeasible within few interactions. Therefore, we estimate $g_{\text{ToM}}$ such that
\begin{equation}
\theta_{\text{mind}} = \arg\min_{\theta'} \mathbb{E}_{o, m}\mathcal{L} (g_{\text{ToM}}(o, m;\theta'), g(o, m;\theta))
\end{equation}
It is straightforward to apply this definition of mental state in the psychological context for which it was originally proposed.
The mental state $\theta_{\text{mind}}$ is the representation of the listener's language abilities, which are not directly observable, and which are ultimately used for predicting the belief and behavior of the speaker \cite{premack1978does}.
For example, in our first set of experiments we focus on referential game where the speaker describes the target in order to let the listener pick it out from distractors. We construct a population in which neural listeners with LSTMs and word embeddings have different language comprehension abilities for different languages.
One of the possible representations controls the word embeddings in different languages: the mental state of a good language listener should have more meaningful word embeddings, while the one which cannot understand the language should have more random ones. Given that the speaker can acquire an accurate mental state for the listener, it can be used for predicting the probability of listener choosing the correct image when hearing descriptions in different languages. By choosing the one that yields the correct image with the highest probability, the speaker generates the descriptions which improve the referential game. On the other hand, high quality descriptions help the speaker better narrow down the language abilities of the listener. This is similar to the two-way interrelation between language and ToM in humans \cite{de2007interface}.
Following this direction, we present a dynamic view of ToM by putting the observer inside the conversation, instead of the static view of \citet{rabinowitz2018machine}, which uses ToM for tracking the behavior of the agent without interfering in the games. Our training procedure is presented in Proc.~\ref{proc:training_tom}.
We aggregate a dataset $D_{\theta_{\text{mind}}}$ at each epoch, and update the parameters by optimizing the ToM model on the dataset. To aggregate the dataset for each training listener, we randomly sample from the posteriors of the ToM model and uniform distributions over the candidates, which keeps a certain degree of exploration, modulated by distribution coefficient $\sigma$ (through the paper, we use $\sigma = 0.5$). In practice, parameters are updated with stochastic gradient descent by sampling listeners and using the history of each listener at each time step as a support set for predicting the next actions of the listener. Following the literature on speech acts, e.g.~\citet{monroe2015learning}, we also add exponential cost penalty $\exp(-\kappa C(m))$ as a prior to penalize long instructions. (We have not explored the space of penalty functions in this paper, but the exponential function is widely used in the pragmatics literature, e.g. \cite{monroe2015learning}, \cite{morris2019pressure}.) In Fig.~\ref{fig:demo} (a\&b), although ``go to fridge'' yields the highest probability of gold action, no instruction is given in order to express the goal concisely.
Similarly to the imitation learning algorithm DAgger \cite{ross2011reduction}, the dataset is collected using expert actions. However, there is a major difference between Proc. \ref{proc:training_tom} and DAgger --- we optimize the prediction of actions conditioned on the observations and instructions instead of the instruction probability directly.
The following theorem shows that our model will improve the instruction generation quality:
\begin{theorem}[informal]
\label{th:1}
Given a small enough distribution coefficient $\sigma$ and good enough bounded candidate pools, the instruction distribution produced by the ToM model becomes optimal as prediction loss goes to zero.
\end{theorem}
\paragraph{Discussion} The conditions of Theorem \ref{th:1} mean that the speaker model $S$ must be a well-trained model to produce good enough candidates pools. In practice, this condition is not hard to meet:
for instance, in our language navigation experiment the listeners can at least understand the lowest-level instructions, and the speaker generates four levels of instructions by rule-based experts. Therefore, the practical implication of this theorem is helpful -- our method reduces to DAgger without expert instructions. Different from DAgger, our training method doesn't directly optimize the instruction distribution against expert's instructions, but optimizes the action prediction loss instead, which upper-bounds the instruction loss.
\subsection{Meta-learning ToM Model}
To acquire an estimate of the mental state from very few interactions, the ToM model needs to quickly learn from a small support set. In theory, any model for parameterizing $\mathcal{P}_{\text{ToM}}(a \mid o, m, \mathcal{D}_{\text{supp}};\theta_{\text{mind}})$ could work in our framework.
As a general method applicable to all ToM models, we apply model-agnostic meta-learning (MAML; \citet{finn2017model}), a method that explicitly trains models to be easily adaptable in few-shot settings. Given support dataset $\mathcal{D}_{\text{supp}}$, the inner loop updates parameters for $N_{\text{inner}}$ steps:
\begin{equation}
\begin{aligned}
\theta^{(0)} &= \theta_{\text{mind}} \\
\theta^{(i+1)} &= \theta^{(i)} - \eta \nabla_{\theta} \mathcal{L}(\mathcal{D}_{\text{supp}}; \theta)|_{\theta=\theta^{(i)}}
\end{aligned}
\end{equation}
where $\eta$ is the inner loop learning rate, which, in practice, is not share across modules following \citet{antoniou2018train}. The loss function on the support set is the negative log-likelihood of listener's action given observations $o$ and the instructions $m$
\begin{equation}
\mathcal{L}(\mathcal{D}_{\text{supp}}; \theta) = - \mathbb{E}_{(o, m, a)\sim\mathcal{D}_{\text{supp}}} \log p_{\theta}(a\mid o, m)
\end{equation}
After $N_{\text{inner}}$ steps, we get the prediction on the target observation $o$ and instruction $m$
\begin{equation}
\mathcal{P}_{\text{ToM}}(a \mid o, m, \mathcal{D}_{\text{supp}};\theta_{\text{mind}}) = p_{\theta^{N_{\text{inner}}}}(a\mid o, m)
\end{equation}
Outer loop optimize $\theta_{\text{mind}}$ by mini-batch stochastic gradient descent
\begin{equation}
\theta_{\text{mind}} \leftarrow \theta_{\text{mind}} - \eta_{\text{outer}} \nabla_{\theta} \mathcal{L}^{\text{pred}} (\mathcal{D}_{\theta_{\text{mind}}})
\end{equation}
The outer loop also runs for a given $N_{\text{outer}}$ epochs.
\subsection{Deploying the ToM Model}
Similar to Proc.~\ref{proc:training_tom}, we evaluate ToM by using it to measure the probability of the gold action given the instructions. However, here we choose the best one instead of sampling from the posterior. Alg.~\ref{proc:test_tom} shows the evaluation procedure.
\begin{algorithm}
\small
\caption{Evaluate ToM Model}
\label{proc:test_tom}
\begin{algorithmic}
\REQUIRE Testing Listeners $L_{test}$, $E, S, C, \kappa, K$ as in Proc. \ref{proc:training_tom}
\STATE $pt \leftarrow 0$
\FORALL{$l_i$ in $L_{test}$}
\STATE $\mathcal{D}\leftarrow \emptyset$
\STATE $o, a \leftarrow$ \textsc{Restart}
\FOR{j in 1..K}
\STATE{$o, g\leftarrow E(o, a)$}
\IF{\textsc{Done}}
\STATE $pt \leftarrow pt + \bm{1}[\textsc{Success}]$
\STATE $o, g\leftarrow E(\textsc{Restart})$
\ENDIF
\STATE $M, a^g\leftarrow S(o, g)$
\STATE $m \leftarrow \argmax_m \mathcal{P}_{\text{ToM}}(a^g \mid o, m, \mathcal{D}\}; \theta_{\text{mind}})e^{-\kappa C(m)}$
\STATE $a \leftarrow l_i(o, m)$
\STATE $\mathcal{D} \leftarrow \mathcal{D} \cup \{(o, m, a)\}$
\ENDFOR
\ENDFOR
\STATE \textbf{Return} $pt$
\end{algorithmic}
\end{algorithm}
\subsection{Connection with Other Pragmatics Models}
It should be noted that using a listener model to help choose best utterance has been studied for almost a decade under the rational speech act model (RSA, \citet{frank2012predicting}; including recent more general models, e.g. \citet{Wang2020AMT}), a Bayesian framework that takes listener's choices in to account by
\begin{equation}
\begin{aligned}
P_{S^{n}} (m\mid a, o) &= \frac{P_{L^{n-1}}(a\mid m, o) P (m\mid o) }{\sum_{m'\in M}P_{L^{n-1}}(a\mid m', o) P(m'\mid o)}\\
P_{L^{n}} (a\mid m, o) &= \frac{P_{S^{n-1}}(m\mid a, o) P (a\mid o) }{\sum_{a'\in A}P_{L^{n-1}}(m\mid a', o) P(a'\mid o)}
\end{aligned}
\end{equation}
where $S^n$ denotes the $n$-level speaker and $L^{n-1}$ denotes the $(n-1)$-level listener, $M, A, o$ denotes the space of instructions, actions, and the observation shared by the speaker and listener respectively, $P(m\mid o)$ and $P(a\mid o)$ are the priors over instructions and actions. The base speaker $S^0$ and listener $L^0$ are often parameterized using neural networks directly \cite{fried2018unified}.
As a general framework for computational pragmatics, RSA models both language production and language comprehension in a recursive fashion, although the first and the second levels are predominantly used. In this paper, we focus on language production, while improving the listeners with more layers of reasoning is left for future work.
However, the most notable difference between our model and neural RSAs is the notion of few-shot coordination. RSA base speaker and listener models are often fixed after training, making them unable to adapt to new partners during testing. While our model has a similar formulation (Eq. \ref{eq:instruction_distribution}) to the first level speaker of RSA, our ToM listener's action probability conditions on the listener's previous behavior.
\section{Multilingual Referential Games}
We test the ability of the proposed ToM model to perform few-shot language coordination in two settings: the running example of vision-language navigation, and also in a simpler setting of \emph{referential games}, which we discuss first in this section.
In a referential game, the speaker gives a description for the target image as its instruction, and the listener's action is to choose the target from distractors, after which the listener either wins the game and gets one point or loses it.
Following \citet{lazaridou2016multi, lowe2019interaction}, we use 30k image-caption pairs from MSCOCO dataset \cite{lin2014microsoft}.
In each game, a target image sampled from the dataset uniformly, and nine distractors are sampled from 1,000 nearest images in terms of cosine similarity of outputs of second last layer of pretrained ResNet \cite{he2016deep}.
In contrast to previous work, which mainly deals with a pair of one speaker and one listener, we are interested in learning with a population of listeners.
In order to achieve this, we propose a setting of \emph{multilingual} referential games, where each listener has the ability to understand different languages at different levels of ability.
\paragraph{Listener distribution}
We first translate MSCOCO captions into nine languages, German, Lithuanian, Chinese, Italian, French, Portuguese, Spanish, Japanese and Greek, from English, using Google Translate\footnote{\url{https://translate.google.com}}. For each listener, we sample a vocabulary distribution $v_1,v_2,\dots,v_{10}$ from 10-dimensional Dirichlet distribution $Dir(0.5, 0.5, \dots, 0.5)$. The listener's vocabulary is built up with 5,000 words, where for each language $i$ we select the most frequent $5,000*v_i$ words in MSCOCO captions in that language to be added to the listener's vocabulary. The reason behind this design is cognitively motivated; word frequency has high correlation with age of acquisition (AoA) of words \cite{juhasz2005age}.
The dataset used to train the listener is finally created by filtering out sentences with more than one word outside the vocabulary. Given target image $x^*$, instruction $m$, and distractors $x_{i}, i=1, 2, \dots, 9$, the listener computes
\begin{equation}
\label{eq:listener}
\begin{aligned}
z_i &= \mathtt{ResNet}(x_i)\quad\text{for }i=1, 2, \dots, 9, *\\
z &= \mathtt{LSTM}(m)\\
\hat{y} &= \mathtt{softmax}(z^{\top} \{z_1, z_2,\dots,z_9, z^*\})
\end{aligned}
\end{equation}
The listener is trained to minimize the expected negative log-likelihood $-\log \hat{y}^*$ by stochastic gradient descent.
Following \citet{lowe2019interaction},
we train the listeners by randomly\footnote{We have also tried other schemes in their paper, but those do not yield significantly better performance.} interleaving between self-play (training with a companion speaker) and supervised training (with MSCOCO annotations or their translations). The companion speaker takes the representation of the target image as input:
\begin{equation}
\label{eq:speaker}
\begin{aligned}
z^* &= \mathtt{ResNet}(x^*)\\
l &= \mathtt{teacher\text{-}forcing} (\mathtt{LSTM}(z^*), m) \\
\hat{m} &= \mathtt{gumbel\text{-}softmax}(\mathtt{LSTM}(z^*))
\end{aligned}
\end{equation}
During supervised training, the model is trained to minimize the teacher-forcing NLL loss, while during self-play the sampled instruction is fed to the listener with Gumbel-softmax \cite{jang2016categorical}. This procedure produces 120 listeners, for which the average success rate with MSCOCO captions within the listener's vocabulary is 81.6\% and the average success rate with companion speakers is 83.3\%. These listeners are randomly divided into training, validation, and testing listeners (80/20/20).
\paragraph{Speaker training} Using the setup in Eqs.~\ref{eq:listener} and \ref{eq:speaker}, we equip the speaker with a vocabulary of 20K words equally distributed in ten languages. We use the same data filtering method and training scheme as described above. To produce a pool of candidates in all languages, we add a language marker at the front of each training caption, so that the languages of instructions are controllable. Using beam search (size of 10), we generate five instructions per language (i.e.~$N_M\!\!=\!50$). The speaker achieves an 87\% success rate with the listeners used to train the speaker
and a caption PPL of 23.7.
\paragraph{ToM Model} The ToM models uses the same architecture as Eq.~\ref{eq:listener}. We use penalty $\kappa=0$. In the referential game, the action space $\mathcal{A}=\{1, 2, \dots, 9, *\}$ and observation $o = (x_1, x_2, \dots, x_9, x^*)$, we have
\begin{equation}
p_{\theta}(a\mid o, m) = \hat{y}_{a}.
\end{equation}
The MAML hyper-parameters are $\eta=0.01, N_{\text{inner}} = 5, \eta_{\text{outer}} = 0.0001, N_{\text{outer}}=500$, and batch size is 2.
\vspace{-2pt}
\paragraph{Evaluation} We evaluate the ToM-assisted speaker and other baselines with the same set of testing listeners. For each pair of speaker and listener, we calculate the average success rate of 500 $K=20$-game sessions.
\begin{table}[!h]
\centering
\small
\begin{tabular}{lr}\\\toprule
Model & Ave success\\\midrule
Gold-standard speaker &91.20\%\\ \hline\hline
Non-ToM speaker &37.38\%\\ \hline
RSA speaker & 42.83\%\\ \hline
ToM-assisted speaker &\textbf{58.19}\%\\ \bottomrule
\end{tabular}
\caption{Models and their respective referential game accuracy.}\label{wrap-tab:referential-game}
\end{table}
The gold-standard speaker denotes the success rate of using the testing listener in place of the ToM listener. The score of over $90\%$ indicates that the candidate pool is of high quality, so a speaker with a well-modeled ToM listener has ample room for achieving high accuracy. The non-ToM speaker uses the instruction with the highest probability in the speaker model; the RSA speaker uses the listener for training the speaker in place of the ToM listener. Our model achieves a significantly higher success rate, demonstrating that the ToM model could help produce better instructions for this referential game.
\begin{figure}
\centering
\includegraphics[width=0.7\linewidth]{acc.pdf}
\caption{Average prediction accuracy of ToM model at each time step during evaluation. (95\% confidence interval)}
\label{fig:acc}
\end{figure}
However, does ToM model truly learn to adapt to individual listeners? We compute the accuracy of predicting the listener's behavior during the same session.
Fig.~\ref{fig:acc} shows that the prediction accuracy of listener's actions is significantly improved within sessions, which shows ToM indeed learns to adapt to individual test listeners.
\section{ALFWorld Task Navigation}
In the previous section, we have shown that ToM could help games with simple dynamics, and learn to adapt to listeners. This section will show its application in a more complex game: language navigation.
\begin{figure}[!t]
\centering
\includegraphics[width=0.8\linewidth, trim=0 5 0 0, clip]{plot.pdf}
\caption{Experimental results for the language navigation setting with average instruction length on the horizontal-axis and game points on the vertical. Colors represent different models.
}
\label{fig:language_navigation}
\end{figure}
We use the Alfworld \cite{shridhar2020alfworld} platform, which creates a natural language command action space upon the Alfred environment for vision-language navigation \cite{ALFRED20}. In each game, a household task is given by the environment. We generate expert trajectories for all tasks in Alfworld, and manually create four levels of instructions, from task-level to action-level, which are denoted as $\mathcal{I}_i, i=1, 2, 3, 4$. The differences between these four levels are the levels of abstraction. An action-level instruction corresponds to a single action in the Alfworld, while a task-level instruction corresponds to a whole trajectory which consists of more than eight commands. The two other levels are in between. The candidate pool at each time step consists of four instructions from each level ($N_M=4$). To create each listener, we draw an instruction distribution from $Dir(0.6, 0.4, 0.3, 0.2)$ for each of the six types of task in the environment. Listeners are of the same neural model as in \citet{shridhar2020alfworld}. While training the listeners, the instructions are randomly drawn from the instruction distributions according to the task type. This procedure produces 50 listeners. The average success rate of listeners is 83.6\%. These listeners are randomly divided into training, validation, and testing listeners (30/10/10). We define the cost as the average total length of the set of instructions, i.e.~repetitive instructions are only calculated once. The cost function is defined as $C(m) = 2^i \ \text{if } m \in \mathcal{I}_i$. Within one session, the maximum number of interactions between speaker and listener is $K=100$, and maximum number of interactions in a game is 20. Listeners' hyper-parameters are the same as the ones in \citet{shridhar2020alfworld}, while MAML hyper-parameters are the same as referential game.
In Fig.~\ref{fig:language_navigation}, we compare ToM-assisted speakers and random speakers. We didn't compare with an RSA speaker, because differently from the multilingual referential games, the speaker is rule-based and no listener is used for training the speaker. A random speaker draws an instruction distribution from $Dir(0.7, 0.7, 0.7, 0.7)$, and sample instructions from the candidate pools using the instruction distribution. The ToM speaker with $\kappa=0$ predominantly uses action-level instructions, while the ToM speaker with $\kappa=10$ uses task-level instructions most of the time. Comparing ToM speakers and random speakers, we find that for $\kappa = \{0, 1, 2\}$, ToM speakers achieve higher game points and lower cost than random ones; for $\kappa=10$, the ToM speaker does not have significant improvement over a random one, since only the listeners that have been trained on sufficient action-level instructions can succeed.
\section{Related Work}
\subsection{Language Games}
Language games have been the proving ground for various linguistics theories since their conception by \citet{wittgenstein1953philosophical}. Recently, the most widely used language game is the referential game, in which the speaker observes the target and distractors and uses language to instruct the listener on how to pick out the target.
\textbf{Emergent Communication} Without natural language annotations, this pressure for the speaker and listener enables language emergence. \citet{batali1998computational} first uses the same recurrent neural networks as the speaker and the listener to conduct emergent communication in referential game. Following this lead, \citet{lazaridou2016multi} study how emergent languages are grounded to the input images. \citet{cao2018emergent} studies multi-turn communication via negotiation. \citet{chaabouni2020compositionality,gupta-etal-2020-compositionality} study the compositionally and systematicity of emergent languages.
\textbf{Learning Common Languages} By using natural language annotations, agents learn a common language so that agents that are never trained together can be expected to communicate. \citet{lazaridou2016multi} studies using MSCOCO \cite{lin2014microsoft} annotations as gold labels for both speakers and listeners. \citet{lowe2019interaction} found that alternating between self-playing and supervised learning benefits communication performance. \citet{wang2016games} show that humans have the ability to adapt to the machine's capability in language games. \citet{bullard2020exploring} found that when language follows Zipf law, zero-shot communication is possible.
\textbf{Language Games with Community} \citet{tieleman2019shaping} learns representations by training with a community of encoders and decoders. The difference between our work and theirs is that our MAML listener learns to adapt to different listeners in the population in a few games. The performance of their model should be equivalent to our model's result at time step 1. \citet{lowe2019learning} considers the adaptation problem, which is definitely relevant. However, adapting their model to our settings is non-trivial, which is beyond the scope of this paper.
This referential game setting used in most previous work can be seen as a special case of our few-shot coordination formulation, where the number of games is one and the partners are mostly the same ones as in the training phase. These two differences prevent the previous models from learning to adapt due to the lack of pressure to do so.
\subsection{Machine Theory of Mind}
Computational and neural models of theory-of-mind have been studied for decades \cite{siegal2002neural,rescorla2015computational}. \citet{rabinowitz2018machine} are the first to present a successful modeling of the mental state of various species of agent. While we also train a ToM model with meta learning, we put the ToM model into use. The predictions provided by the ToM model serve as reranker in the speaker's model. The variety of models is also more diverse than the species used in this paper. Importantly, \citet{nematzadeh2018evaluating,le2019revisiting} find that neural models for question answering fail to keep track of inconsistent states of the world. \citet{moreno2021neural} extends machine ToM to neural recursive belief states. We expect improvement over our current model by modeling higher-order recursive belief, which is left for future work. \citet{yuan2020emergence} explicitly trains belief state prediction with supervised learning, while our model's belief state is latent.
\subsection{Similar Topics in Reinforcement Learning}
\textbf{Model-based Reinforcement Learning} Model-based reinforcement learning focuses on building a model of the environment to improve data efficiency \cite{kaelbling1996reinforcement}, which could be applied to the zero-shot coordination problem by treating the listener as a part of the environment. Recently, neural networks have been used widely for model-based RL \cite{gal2016improving, depeweg2016learning, nagabandi2018neural,chua2018deep,janner2019trust}. We should point out that despite their similarities to our model,
we focus on modeling different and unseen agents in the population within a few interactions.
\textbf{Alternatives to Self-play}
Zero-shot coordination has attracted much attention recently. \citet{hu2020other} propose other-play which maximizes the expected reward working with random partners. In contrast to their approach, we explicitly model the partner's ToM and focus on language coordination, which required more complicated modeling than the environments in their experiments.
\section{Implications and Future Work}
We have introduced few-shot language coordination task and proposed ToM model for tracking the listener's mental state. Different from previous work using single-round games and self-play training, we consider more general multi-round games and playing with novel listeners. ToM model shows its ability to adapt to novel listeners and assist speakers in choosing the best instructions in both multilingual referential games and the language navigation task. We attribute the success of ToM model to modeling socio-pragmatics process in an explicit way. Many interesting questions about modeling ToM in few-shot language coordination remain open. The most immediate is how to model ToM from the listener's perspective, leading to a dialog agent that can acquire new knowledge through conversation. One step further, similar to RSA, ToM can also be modeled in a recursive manner, which may further improve language games.
\section*{Acknowledgements}
This work was supported by the DARPA GAILA project (award HR00111990063). The views and conclusions contained in this document are those of the authors and should
not be interpreted as representing the official policies, either expressed or implied, of the U.S. Government. The U.S. Government is authorized to reproduce and distribute reprints for Government purposes notwithstanding any copyright notation here on.
| {'timestamp': '2021-07-14T02:03:03', 'yymm': '2107', 'arxiv_id': '2107.05697', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05697'} | arxiv |
\section*{Acknowledgments}
We thank the anonymous reviewers for their valu-
able and constructive feedback. This research was partially funded by the
Development Bank of Saxony (SAB) under project
number 100335729.
\section*{Ethical Considerations}
Research on active learning improves the labeling of data, by efficiently supporting the learning algorithm with targeted information, so that overall less data has to be labeled. This could contribute to creating machine learning models, which would otherwise be infeasible, either due to limited budget, or time. Active learning can be used for good or bad, and our contributions would---in both cases--show how to make this process more efficient.
Moreover, we use pre-trained models, which can contain one or more types of bias. Bias, however, affects all approaches based on fine-tuning pre-trained language models, but therefore this has to be kept in mind and mitigated all the more.
\section{Introduction}
Collecting labeled data for machine learning can be costly and time-consuming. A key technique to minimize labeling costs has been active learning, where an oracle (e.g., a human expert) is queried to label problem instances selected that are deemed to be most informative to the learning algorithm's next iteration according to a query strategy.
Active learning is characterized by the real-world machine learning scenario in which large amounts of training data are unavailable, which may explain why comparably little research has investigated deep learning in this context. The recent widely successful transformer-based language models can circumvent the limitations imposed by small training datasets \citep{vaswani:2017,devlin:2019}. Pre-trained on large amounts of unlabeled text, they can be fine-tuned to a given task using far less training data than when trained from scratch. However, their high number of model parameters renders them computationally highly expensive, for query strategies that are targeted at neural networks or text classification \citep{settles:2007,zhang:2017}, resulting in prohibitive turnaround times between labeling steps.
In this paper, we systematically investigate uncertainty-based query strategies as a computationally inexpensive alternative. Despite their relative disadvantages in traditional active learning, when paired with transformers, they are highly effective as well as efficient. Our extensive experiments assess a multitude of combinations including state-of-the-art transformer models BERT \citep{devlin:2019} and DistilRoBERTa \citep{sanh:2019}, five well-known sentence classification benchmarks, and five query strategies.%
\footnote{Code: {\url{https://github.com/webis-de/ACL-22}}}
\section{Related Work}
\enlargethispage{\baselineskip}
Uncertainty-based query strategies used to be the most common choice in active learning, using uncertainty scores obtained from the learning algorithm \citep{lewis:1994}, estimates obtained via ensembles \citep{krogh:1994,raychaudhuri:1995}, or prediction entropy \citep{holub:2008}. More recently---predating transformers---neural network-based active learning predominantly employed query strategies that select problem instances according to
(1)~
the magnitude of their backpropagation-induced gradients \citep{settles:2007,zhang:2017}, where instances causing a high-magnitude gradient inform the model better, and
\Nii
representativity-based criteria (e.g., coresets \citep{sener:2018}), which select instances from a vector space to geometrically represent the full dataset.
\noindent For today's deep neural networks, ensembles are too computationally expensive, and prediction entropy has been observed to be overconfident \citep{guo:2017,lakshminarayanan:2017}. The exception are flat architectures, where, among others, \citet{prabhu:2019} showed fastText \citep{joulin:2017} to be effective, well-calibrated, and computationally efficient. Prior to transformers, query strategies relying on expected gradient length \citep{settles:2007} achieved the best results on many active learning benchmarks for text classification \citep{zhang:2017}. Gradients depend on the current model, which means, when used for a query strategy, they scale with the vast number of a transformer's parameters, and moreover, they need to be computed per-instance instead of batch-wise, thereby becoming computationally expensive.
The cost of ensembles, the adverse scaling of network parameters in gradient-based strategies, and a history of deeming neural networks to be overconfident effectively rule out the most predominantly used query strategies. This might explain why transformers, despite the success of fine-tuning them for text classification \citep{howard:2018,yang:2019,sun:2020}, have only very recently been considered at all in combination with active learning \citep{lu:2020,yuan:2020,ein-dor:2020,margatina:2021b}. All of the related works mitigate the computationally complex query strategies by subsampling the unlabeled data before querying \citep{lu:2020,ein-dor:2020,margatina:2021b}, by performing fewer queries with larger sample sizes \citep{yuan:2020,margatina:2021b}, or by tailoring to less expensive settings, namely binary classification \citep{ein-dor:2020}. Subsampling, however, introduces additional randomness which can aggravate comparability across experiments, and large sample sizes increase the amount of labeled data, which is contrary to minimizing the labeling effort.
Due to this computationally challenging setting, the uncertainty-based prediction entropy query strategy \citep{roy:2001,schohn:2000} is therefore a frequently used baseline and a lowest common denominator in recent work on active learning for text classification \citep{zhang:2017,lowell:2019,prabhu:2019,ein-dor:2020,lu:2020,yuan:2020,margatina:2021b,zhang:2021}. Apart from being employed as baselines, uncertainty-based query strategies have not been systematically analyzed in conjunction with transformers, and moreover, comparisons to the previous benchmarks by \citet{zhang:2017} have been omitted by the aforementioned related work. Our work not only closes this gap, but also reevaluates the relative strength of uncertainty-based approaches, including two recently largely neglected strategies, thereby challenging the status of prediction entropy as the most popular baseline.
\section{Transformer-based Active Learning}
\label{sec:transformer-based-active-learning}
The goal of active learning is to minimize the labeling costs of training data acquisition while maximizing a model's performance (increase) with each newly labeled problem instance. In contrast to regular supervised text classification (``passive learning''), it operates iteratively, where in each iteration
(1)~
a so-called query strategy selects new instances for labeling according to an estimation of their informativeness,
\Nii
an oracle (e.g., a human expert) provides the respective label, and
(3)~
a learning algorithm either uses the newly labeled instance for its next learning step, or a model is retrained from scratch using all previously labeled instances. This work considers pool-based active learning \citep{lewis:1994}, where the query strategies have access to all unlabeled data. Notation-wise, we denote instances by $x_1, x_2, \dots, x_n$, the number of classes by $c$, the respective label for instance $x_i$ by $y_i$ (where $\forall i: y_i \in \{1, \dots, c\}$), and $P(y_i|x_i)$ is a probability-like predicted class distribution.
\paragraph{Query Strategies}
{
\begingroup
\setlength{\abovedisplayskip}{5pt}
\setlength{\belowdisplayskip}{5pt}
\setlength{\abovedisplayshortskip}{5pt}
\setlength{\belowdisplayshortskip}{5pt}
We consider three well-known uncertainty-based query strategies, one recent state-of-the-art strategy that coincidentally also includes uncertainty, and a random baseline:\\
(1)~
Prediction Entropy (PE; \citealp{roy:2001,schohn:2000}) selects instances with the highest entropy in the predicted label distribution with the aim to reduce overall entropy:
\begin{equation*}
\argmax_{x_i}~\left[-\sum_{j=1}^{c} P(y_i = j|x_i)\log{}P(y_i = j|x_i)~\right]
\end{equation*}
\Nii
Breaking Ties (BT; \citealp{scheffer:2001,luo:2005}) takes instances with the minimum margin between the top two most likely probabilities:
\begin{equation*}
\argmin_{x_i}~\Big[P(y_i = k_1^{*}|x_i) - P(y_i = k_2^{*}|x_i)\Big]
\end{equation*}
where $k_1^{*}$ is the most likely label in the posterior class distribution $P(y_i|x_i)$, and $k_2^{*}$ the second most likely label respectively. {\em In the binary case}, this margin is small iff the label entropy is high, which is why BT and PE then select the same instances.\\
(3)~
Least Confidence (LC; \citealp{culotta:2005}) selects instances whose most likely label has the least confidence according to the current model:
\begin{equation*}
\argmax_{x_i}~\Big[1 - P(y_i = k_1^{*}|x_i)\Big]
\end{equation*}
(4)~
Contrastive Active Learning (CA; \citealp{margatina:2021b}) selects instances with the maximum mean Kullback-Leibler~(KL) divergence between the predicted class distributions (``probabilities'') of an instance and each of its $m$ nearest neighbors:
\begin{equation*}
\argmax_{x_i}~\left[~\frac{1}{m}\sum\limits_{j=1}^{m}\mathrm{KL}\kldivx{P(y_j|x_j^{knn})}{P(y_i|x_i)}~\right]
\end{equation*}
where the instances $x_j^{knn}$ are the $m$ nearest neighbors of instance $x_i$.\\
(5)~
Random Sampling (RS), a commonly used baseline, draws uniformly from the unlabeled pool.
\endgroup
}
\paragraph{Oracle}
The oracle is usually operationalized using the training datasets of existing benchmarks: To ensure comparability with the literature, we pick important standard text classification tasks.
\paragraph{Classification}
We fine-tune BERT \citep{devlin:2019} and DistilRoBERTa \citep{sanh:2019} on several natural language understanding datasets. BERT is well-researched as transformer and has recently also shown strong results in active learning \citep{yuan:2020,ein-dor:2020,margatina:2021b}. The model consists of 24 layers, hidden units of size 1024 and 336M~parameters in total. DistilRoBERTa, by contrast, is a more parameter-efficient alternative which has merely six layers, hidden units of size~768, and 82M~parameters.
We also trained a passive model on the full data.
\input{table-datasets}
The classification model consists of the respective transformer, on top of which we add a fully connected projection layer, and a final softmax output layer.
We use the ``[CLS]'' token that is computed by the transformer as sentence representation.
Regarding fine-tuning, we adopt the combination of discriminative fine-tuning and slanted triangular learning rates \citep{howard:2018}. The main active learning routine is then as follows:
(1)~
The query strategy, either using the model from the previous iteration, or sampling randomly, selects 25~instances from the unlabeled pool.
\Nii
The oracle provides labels for these instances.
(3)~
The next model is trained using all data labeled so far.
\paragraph{Baselines}
For comparison, we consider a linear SVM, and KimCNN \citep{kim:2014}, which have been used extensively in text classification, disregarding active learning. We adopted the KimCNN parameters from \citet{kim:2014} and \citet{zhang:2017}.
\section{Evaluation}
\input{table-results-summary}
We evaluate five query strategies in combination with BERT, {DistilRoBERTa} and two baselines.
\paragraph{Datasets and Experimental Setup}
In Table~\ref{table-datasets}, we show the five datasets employed, which have previously been used to evaluate active learning: AG's News (AGN; \citealp{zhang:2015}), Customer Reviews (CR; \citealp{hu:2004}), Movie Reviews (MR; \citealp{pang:2005}), Subjectivity (SUBJ; \citealp{pang:2004}), and {TREC-6} \citep{li:2002}. These datasets encompass binary and multi-class classification in different domains, and they are class-balanced, except for {TREC-6}. Where available, we employed the pre-existing test sets, or otherwise a random sample of~10\%.
We follow the experiment setup of \citet{zhang:2017}: 25~training instances are used to train the first model, followed by 20~active learning iterations, during each of which 25~instances are queried and labeled. Using 10\%~of the so far labeled data as validation set, we stop early \citep{duong:2018} when accuracy surpasses~98\%, or the validation loss does not increase for five epochs.
\begin{figure*}[t]
\centering
\includegraphics[width=0.77\textwidth]{plot-learning-curves}
\caption{Active learning curves of BERT and DistilRoBERTa when combined with five query strategies: Prediction Entropy (PE), Breaking Ties (BT), Least Confidence (LC), Contrastive Active Learning (CA), and Random Sampling (RS). The tubes around the lines represent standard deviation over five runs. For comparison, the horizontal line depicts a passive text classification for which BERT has been trained using the entire training set.}
\label{figure-learning-curves}
\end{figure*}
\paragraph{Results}
For each combination of dataset, model, and query strategy, Figure~\ref{figure-learning-curves} shows the respective learning curves. The horizontal line shows the best model's score when trained on the full dataset, which four out of five datasets approach very closely, or even exceed. As expected, BERT generally achieves steeper learning curves than DistilRoBERTa, but surprisingly, during later iterations DistilRoBERTa reaches scores only slightly worse than BERT for all datasets except MR. Regarding query strategies, RS is a strong contender during early iterations, e.g., as can be seen for the first few iterations of~CR. This is partly because all but one of the datasets are balanced, but nevertheless, RS is eventually outperformed by the other strategies in most cases. For imbalanced datasets, \citet{ein-dor:2020} have shown RS to be less effective, which we can confirm for \mbox{TREC-6}.
\input{table-comparison-acc}
While in terms of area under the learning curve (AUC) there seems to be no overall best strategy, PE/BT and CA often show very steep learning curves.
In Table~\ref{table-results-summary}, we rank the query strategies by their average accuracy and AUC results, ranging from 1 (best) to 5 (worst). We also report their average accuracy and AUC per model and query strategy. Surprisingly, we can see that PE, a commonly used and proven to be strong baseline, which has been a lowest common denominator in recent work on active learning for text classification \citep{zhang:2017,lowell:2019,prabhu:2019,ein-dor:2020,lu:2020,yuan:2020,margatina:2021b,zhang:2021}, is on average outranked by BT when using transformers. BT achieves the best AUC ranks and scores, and in many cases also the best accuracy ranks and scores. It seems to be similarly effective on the baselines as well. Moreover, LC also outperforms PE for DistilRoBERTa where it even competes with BT. Detailed accuracy and AUC scores including standard deviations are reported in Appendix Tables \ref{table-results-acc} \& \ref{table-results-auc}.
Table~\ref{table-comparison-acc} compares the best model trained via active learning per dataset against passive text classification, namely
(1)~
our own model trained on the full training set, and
\Nii
state-of-the-art results. The largest discrepancy between active learning and passive text classification is observed on AGN, which is also the largest dataset from which the active learning models use less than~1\% for training. Otherwise, all models are close to or even surpass the state of the art, using only between~0.4\% and~14\% of the data. Noteworthy, LC achieves the best accuracy result for two datasets, while the strong baseline PE and the state-of-the-art approach CA perform best on only one dataset each.
In Table~\ref{table-comparison-auc}, we report the best AUC scores per dataset, and compare them to previous work. BT ranks highest in two out of three cases with CA achieving the best result on the remaining two datasets. BERT achieves the best AUC scores on all datasets with a considerable increase in AUC compared to \citet{zhang:2017}.
\input{table-comparison-auc}
In summary, we use recent transformer models in combination with several query strategies to evaluate a previously established but lately neglected benchmark. We find that the PE baseline is outperformed by BT, which, as a reminder, selects the same instances as PE for binary classification, but shows superior results on multi-class datasets. We conclude that BT, which even outperforms the state-of-the-art strategy CA in many cases, is therefore a strong contender to become the new default uncertainty-based baseline. Finally, DistilRoBERTa, using less than 25\% of BERT's parameters, achieves results that are remarkably close to BERT at only a fraction of the overhead. Considering the computational burdens that motivated this work, this increase in efficiency is often preferable from a practitioner's perspective.
\section{Conclusions}
An investigation of the effectiveness of uncertainty-based query strategies in combination with BERT and DistilRoBERTa for active learning on several sentence classification datasets shows that uncertainty-based strategies still perform well. We evaluate five query strategies on an established benchmark, for which we achieve results close to state-of-the-art text classification on four out of five datasets, using only a small fraction of the training data. Contrary to current literature, prediction entropy, the supposedly strongest uncertainty-based baseline, is outperformed by several uncertainty-based strategies on this benchmark---in particularly by the breaking ties strategy. This invalidates the common practice of solely relying on prediction entropy as baseline, and shows that uncertainty-based strategies demand renewed attention especially in the context of transformer-based active learning.
\section*{Supplementary Material}
The experiments can be reproduced using the code that is referenced on the first page\footnote{\url{https://github.com/webis-de/ACL-22}}. In the following, we summarize important details for reproduction, including details on the results.
\input{table-results-acc}
\section{Technical Environment}
All experiments were conducted within a Python 3.8 environment. The system had CUDA 11.1 installed and was equipped with an {NVIDIA GeForce RTX 2080 Ti} (11GB VRAM). Computations for fine-tuning transformers and training KimCNN were performed on the GPU.
\section{Implementation Details}
Our experiments were built using well-known machine learning libraries: PyTorch\footnote{\url{https://pytorch.org/}, 1.8.0}, huggingface transformers\footnote{\url{https://github.com/huggingface/transformers}, 4.11.0}, scikit-learn\footnote{\url{https://scikit-learn.org/}, 0.24.0}, scipy\footnote{\url{https://www.scipy.org/}, 1.6.0}, and numpy\footnote{\url{https://numpy.org/}, 1.19.5}. For active learning and text classification, we used small-text\footnote{\url{https://github.com/webis-de/small-text}, 1.0.0a8} \citep{schroeder:2022}.
\section{Experiments}
Each experiment configuration represents a combination of model, dataset and query strategy, and has been run for five times. We used a class-balanced initial set to support the warm start of the first model for the imbalanced TREC-6 dataset, whose rarest class would otherwise only rarely be encountered if sampled randomly.
\subsection{Pre-Trained Models}
We fine-tuned DistilRoBERTa (\href{https://huggingface.co/bert-base-uncased}{distilroberta-base}) and BERT-large (\href{https://huggingface.co/bert-large-uncased}{bert-large-uncased}). Both of them are available via the \href{https://huggingface.co/models}{huggingface model repository}.
\input{table-sequence-length}
\input{table-results-auc}
\input{table-runtimes}
\subsection{Datasets}
Our experiments used datasets that are well-known benchmarks in text classification and active learning. All datasets have been made accessible to the Python ecosystem by several Python libraries that provide fast access to the raw text of those datasets. We obtain CR and SUBJ using \href{https://nlp.gluon.ai}{gluonnlp}, and AGN, MR, and TREC using \href{https://github.com/huggingface/datasets}{huggingface datasets}.
\subsection{Hyperparameters}
\paragraph{Maximum Sequence Lenght}
We set the maximum sequence length to the minimum multiple of ten for which 95\% of the respective dataset's sentences contain less than or an equal number of tokens for both KimCNN and transformers (shown in Table~\ref{table-sequence-length}).
\paragraph{Transformers}
AGN is trained for $50$~epochs and all other datasets for~$15$ epochs \citep{howard:2018}. For training, we use AdamW \citep{loshchilov:2019} with a learning rate of $\eta$~=~$\num{2e-5}$, beta coefficients of $\beta_1$~=~$0.9$ and $\beta_2$~=~$0.999$, and an epsilon of $\epsilon$~=~$\num{1e-8}$. Training is done in batches, with a batch size of $12$.
\paragraph{KimCNN}
We adopt the parameters by \citet{zhang:2017}, i.e., $50$ filters and filter heights of $(3, 4, 5)$. Training is done in batches with a batch size of 25, a learning rate of $\eta$~=~$\num{1e-3}$, and word embeddings from word2vec \citep{mikolov:2013}.
\section{Standard Deviations and Runtimes}
In Table~\ref{table-results-acc} and Table~\ref{table-results-auc} we report final accuracy and AUC scores including standard deviations, measured after the last iteration of active learning. Moreover, we report the runtimes of the query step per strategy in Table~\ref{table-runtimes}.
\subsection{Evaluation Metrics}
Active learning was evaluated using standard active learning metrics, namely accuracy und area under the learning curve. For both metrics, the respective scikit-learn implementation was used.
| {'timestamp': '2022-03-22T01:33:13', 'yymm': '2107', 'arxiv_id': '2107.05687', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05687'} | arxiv |
\section{Universal Approximation}\label{app:bigbird}
Here we show in \propref{prop:nobreak} that our Combiner\xspace-X achieves universal approximation property \citep{yun2020n} if the sparse transformer X achieves universal approximation property.
For approaches like BigBird~\citep{zaheer2020big}, they maintain the universal approximation property using the global tokens (CLS).
However, the global attention makes it hard to be applied to the unidirectional autoregressive modeling (LM). Besides, the random attention requires the \texttt{gather} operation, making it very slow on dense hardware like TPUs (\Figref{fig:memory-speed}).
\begin{proposition}\label{prop:nobreak}
The proposed~Combiner\xspace will not break the universal approximation property of the original sparse transformers.
\end{proposition}
Specifically, we consider the function class constructed by stacking the attention block with a two-layer fully connected network. Formally, following the notations in~\citep{yun2020n} we have the block as
\begin{eqnarray}\label{eq:block}
\texttt{SAttn}\rbr{X} &=& X +\texttt{MultiHeadAttn}\rbr{X},\\
Z &=& \texttt{SAttn}\rbr{X} + \texttt{relu}\rbr{\texttt{SAttn}\cdot W_1}\cdot W_2,
\end{eqnarray}
which denotes the $h$-head attentions with $X\in \RR^{L\times d}$, $W_1\in \RR^{d\times r}$, and $W_2\in \RR^{r\times d}$. The function class is denoted as
\begin{align}\label{eq:func_class}
\Scal\Tcal^{H,r}\defeq\{ X\rightarrow t\rbr{X+E} |& \,\,t\,\, \text{is a composition of block~\eqref{eq:block}}, \\
&\,\, E\,\, \text{is trainable position embedding} \}.
\end{align}
\citet{yun2020n} shows that the function class~\eqref{eq:func_class} is still universal approximation w.r.t. the norm defined as $d_p\rbr{f, g}\defeq \rbr{\int \nbr{f(X) - g(X)}_p^p dX}^{1/p}$ with \texttt{softmax} in~\eqref{eq:vanilla_att} and several requirements on the sparsity patterns in attention scheme.
\section{Combiner\xspace-Logsparse in MLM Case}\label{app:logsparse-mlm}
Here we extend the Combiner\xspace-logsparse introduced in \secref{sec:logsparse} to the MLM case.
Besides the $\lceil \log_2{i} \rceil$ non-overlapping supports in the LM case, we can define addtional $\lceil \log_2{i} \rceil$ non-overlapping supports to attend to the tokens after the current token in the sequence. We illustrate this design choice in \figref{fig:logsparse-and-learnable}.
\section{Combiner\xspace-Axial in MLM Case}\label{app:axial-mlm}
Besides the $\omega_{\text{axial-vertical}}^{\text{LM}}$, $\omega_{\text{axial-horizontal}}^{\text{LM}}$ and $\omega_{\text{axial-rowmajor}}^{\text{LM}}$ introduced in \secref{sec:axial}, here we introduce how we extend these three models to the MLM case.
\begin{itemize}[leftmargin=*,nolistsep,nosep]
\item $\omega_{\text{axial-vertical}}^{\text{MLM}}$: $\Omega_i^{0} = \Omega_i^{\text{sparse MLM}} = \cbr{j : j - 1 \equiv i - 1 (\text{mod } m)} \cup \cbr{j : j - 1 \equiv i - 1 (\text{div } m)}$, and $\Omega_i^{r} = \cbr{j: j \equiv r (\text{mod } m)}$, for $r \in [m] \setminus \cbr{\textit{col}_i}$. As depicted in~\Figref{fig:axial_variants}(A), $\Omega_i^{r}$ corresponds to the column $r$ above $\textit{row}_i$, where we use max pooling to obtain the abstraction. To obtain such abstraction for all the locations, we can leverage the \texttt{cummax} operator for each column to efficiently obtain the prefix-max.
\item $\omega_{\text{axial-horizontal}}^{\text{MLM}}$: similar as $\omega_{\text{axial-vertical}}^{\text{MLM}}$ except that each $\Omega_i^{r}$ summarizes all rows $r$ and excludes $\textit{col}_i$.
\item $\omega_{\text{axial-rowmajor}}^{\text{MLM}}$: $\Omega_i^{0} = \cbr{j : j - 1 \equiv i - 1 (\text{div } m)}$, \ie, elements in the same row are directly attended, while $\Omega_i^{r} = \cbr{j: j \equiv r (\text{div } m)}$ for $r \in [n] \setminus \cbr{\textit{row}_i}$ captures all the rows except $\textit{row}_i$.
\end{itemize}
It is trivial to see that the complexity remains ${\mathcal{O}}(L\sqrt{L})$ if $n,m={\mathcal{O}}(\sqrt{L})$.
\section{Combiner\xspace-Learnable}\label{app:learnable}
As discussed in \secref{sec:learnable}. we design Combiner\xspace-learnable as an extension to the routing transformer \cite{roy2021efficient}, which learns to cluster the tokens. Each token in the routing transformer only attends to the tokens in the same cluster. As shown in \figref{fig:logsparse-and-learnable}, our Combiner\xspace-learnable combines direct expectation with local expectation (yellow tokens), each of which summarizes one cluster (red, blue or green).
\begin{figure}[!h]
\centering
\includegraphics[width=0.4\textwidth]{figs/logsparse-mlm.pdf}
~
\includegraphics[width=0.4\textwidth]{figs/learnable.pdf}
\caption{Left: Combiner-logsparse in the MLM case. Right: Combiner-Learnable. Following the routing transformer \cite{roy2021efficient}, we apply the combiner principle, so that we can achieve full attention in each head with identical complexity with the routing transformer.}
\label{fig:logsparse-and-learnable}
\end{figure}
\section{Experimental Details}\label{app:experiment}
\subsection{CIFAR-10\xspace}
Here we list the hyperparameters we used on the CIFAR-10\xspace dataset. Our experiments include (1) an ablation study, where all the models share the exact same architecture; and (2) the main result, where our Combiner\xspace achieves the state-of-the-art result under the setting that no data augmentation is allowed.
For the ablation study, the embedding and hidden size is 512. We use 8 attention heads in each layer with in total 6 transformer layers. We train all the models for 400,000 steps with learning rate 1e-3 and batch size 32.
For the main result, we use the same architecture as introduced in \citet{child2019generating}, and we train our Combiner\xspace-Axial for 1,200,000 steps with cosine learning rate scheduling. We rerun the main result for 3 times and the standard deviation is 0.003.
\subsection{ImageNet-64\xspace}
Regarding the details of the ImageNet-64\xspace, we use the same setup with CIFAR-10\xspace, which consists of an ablation study and the main result. The architecture used in the ablation study is identical with the one we used in CIFAR-10\xspace. For the main result of Combiner\xspace-Axial, we used a 30-layer architecture with 768 hidden size and embedding dimension. We train this architecture for 1,200,000 steps with cosine learning rate scheduling. We also rerun the main result for 3 times and the standard deviation is 0.005.
\subsection{Wiki-40B Language Modeling}
\label{appsec:wiki40b}
The main purpose of this experiment is not to chase the state-of-the-art performance, as generally speaking, the more parameters/data, the better the perplexity would be for language modeling.
So instead, we let all the methods have the same neural network backbone, while only varying the attention implementations to compare their effectiveness.
This is similar in spirit to the ablation study in CIFAR-10\xspace and ImageNet-64\xspace.
Specifically, we use the word embedding size and hidden size of 768 for all the layers. We use 12 attention heads in each layer, with in total 12 transformer layers. We use the Pre-Norm architecture, and the MLP layers have hidden size equals to $4 \times 768$.
The maximum sequence length can vary in $\cbr{2048, 8192}$, depends on the memory limit of each methods. All the methods are trained for 125,000 stochastic gradient updates, with batch size equals to 128. We also enable the cosine learning rate scheduling, with 10,000 warm-up steps. The optimizer is Adam with gradient clipping.
\subsection{LRA Benchmark}
We mainly follow the guideline of LRA, where all the models should use roughly the same number of parameters and same hyperparameters like batchsize, number of iterations, \etc. We tried our best to reproduce the experimental results using the code in \url{https://github.com/google-research/long-range-arena}, and we found that we cannot reproduce the \texttt{pathfinder-32} results. We have communicated with the authors but didn't get the issue resolved. So instead, we rerun all the baselines using the same network configurations, on the \texttt{pathfinder-32-inter} setup. We found some of the methods favor the 'MEAN' pooling to get the sequence representation, while others favor the 'CLS' pooling. So we try both of them for each of the method, and report the best result.
\subsection{C4 Masked Language Modeling}
Similar to the purpose of \secref{appsec:wiki40b}, we perform masked language modeling task on C4 dataset, which is typically used for BERT pretraining. As the perplexity metric correlates with the down-stream task performance well, we thus perform the controlled experiments with all the methods using the same network architecture.
The architecture used and the hyperparameters are almost the same as in \secref{appsec:wiki40b}, except that we have maximum number of segments equal 2.
\section{Experimental Evaluation}\label{sec:exp}
We evaluate Combiner\xspace with different full attention patterns on both autoregressive and bidirectional sequence modeling tasks, covering a wide range of input data from images to texts. All tasks considered involve long sequences for up to 12,000 in length, some of which prevent the applicability of the vanilla transformer. We compare Combiner\xspace with state-of-the-art Transformers. We also perform a series of ablation studies where all of the models being compared use the \emph{exact same architecture} that only differ in the attention module, avoiding individual tricks employed in the original works (\eg, using both learnable and fixed patterns in Routing Transformer~\citep{roy2021efficient}). Details to reproducing all experimental results can be found in \appref{app:experiment}.
\subsection{Autoregressive Sequence Modeling}\label{sec:exp-causal}
In this subsection, we first perform density estimation on text and image using Combiner\xspace.
\input{tables/cifar}
\begin{wraptable}{r}{0.47\textwidth}
\begin{minipage}{0.47\textwidth}
\centering
\vspace{-12mm}
\caption{LM Perplexity on Wiki-40B (Main). \label{tab:lm_wiki40b}}
\vspace{-2mm}
\resizebox{0.98\textwidth}{!}{%
\begin{tabular}{cc}
\toprule
\bf Model & \bf Perplexity \\
\midrule
Transformer-2k~\citep{vaswani2017attention} & 17.26 \\
Performer-2k~\citep{choromanski2020rethinking} & 19.66 \\
Routing-2k~\citep{roy2021efficient} & 20.85 \\
\cmidrule(r){1-1} \cmidrule(l){2-2}
Fixed-2k~\citep{child2019generating} & 18.04 \\
Combiner\xspace-Fixed-2k (Ours) & 17.70 \\
\cmidrule(r){1-1} \cmidrule(l){2-2}
Axial-2k~\citep{ho2019axial} & 20.82 \\
Combiner\xspace-Axial-2k (Ours) & 17.56 \\
\midrule
Combiner\xspace-Fixed-8k (Ours) & 16.60 \\
Combiner\xspace-Axial-8k (Ours) & \textbf{16.49} \\
\bottomrule
\end{tabular}
}
\end{minipage}
\begin{minipage}{0.47\textwidth}
\centering
\vspace{2mm}
\caption{LM Perplexity on Wiki-40B (Ablation). \label{tab:lm_wiki40b_ablation}}
\vspace{-5mm}
\resizebox{0.98\textwidth}{!}{%
\begin{tabular}{cc}
\toprule
\bf Model & \bf Perplexity \\
\midrule
Transformer-2k~\citep{vaswani2017attention} & 17.26 \\
\midrule
Combiner\xspace-DeepSets-Max-8k (Ours) & \textbf{16.29} \\
Combiner\xspace-DeepSets-Mean-8k (Ours) & 16.48 \\
Combiner\xspace-Max-8k (Ours) & 16.60 \\
Combiner\xspace-Mean-8k (Ours) & 16.54 \\
\bottomrule
\end{tabular}
}
\end{minipage}
\vspace{-5mm}
\end{wraptable}
\subsubsection{Language Modeling}
For language modeling, we focus on the Wiki-40B-En dataset~\cite{guo2020wiki}, which consists of clean Wikipedia pages in English.
We use a sentence piece model with vocabulary size 32K to tokenize the text and measure the perplexity at the sentence piece level.
To ensure fair comparison, all models being compared again have the same number of layers and hidden sizes, are are implemented under the same code base.
Table \ref{tab:lm_wiki40b} shows the results of the comparison.
As we can see, under 2k sequence length, Combiner\xspace variants are consistently better than their corresponding baselines, and are very close to the standard Transformer. When sequence length goes to 8k, the standard Transformer runs out of memory, whereas Combiner\xspace continues to achieve improved perplexity, surpassing the result of Transformer-2k. If we further use DeepSets to calculate the summarization terms $q_{\Omega_i^r}$ and $k_{\Omega_i^r}$, we may further achieve lower perplexity as shown in Table \ref{tab:lm_wiki40b_ablation}.
\subsubsection{Image Generative Models}
\noindent\textbf{CIFAR-10\xspace.}
We first perform a sanity check where we compare sparse attention baselines against Combiner\xspace with full attention under the \emph{same architecture} on the CIFAR-10\xspace dataset. The sequence length is 3072. For all the methods, we use a same 6-layer transformer with 8 attention heads and 512 embedding dimensions. We train all models for 500k iterations using batch size 32 on TPU v2.
As shown in~\tabref{tab:image-ablation}, given the same model architecture, Combiner\xspace-X performs significantly better than the base model X under the bits per dimension (BPD) metric on the 10,000 test images. In particular, Combiner\xspace significantly decreases BPD by 0.887, 0.087, and 0.626 compared to the base models Logsparse\xspace, Fixed\xspace and Axial\xspace, respectively. Note that all of the Combiner\xspace variants achieve better performance than the best of the base models. This demonstrates the advantage of Combiner\xspace over the baselines given the same 6-layer architecture. We observe a similar trend under a 12-layer architecture.
Following the 128-layer architecture in~\citet{child2019generating}, we apply Combiner-Axial\xspace and achieve state-of-the-art performance, 2.77 BPD on CIFAR-10\xspace, as listed in~\tabref{tab:imagesota}. We run all of the models in~\tabref{tab:imagesota} without data augmentation~\citep{jun2020distribution}
\noindent\textbf{ImageNet-64\xspace.}
We also evaluate performance under the autoregressive setting on ImageNet-64\xspace, where sequence length is 12,288. We first perform the same analysis as CIFAR-10\xspace and compare Combiner\xspace-X with the baselines using the same model architecture. As shown in~\tabref{tab:image-ablation}, Combiner\xspace consistently outperforms the baselines with the same attention pattern. We further apply Combiner-Axial\xspace to a 30-layer Transformer, which achieves state-of-the-art performance on density estimation on ImageNet-64\xspace, demonstrating the effectiveness of full attention achieved by Combiner\xspace.
\input{tables/im_sota}
\subsection{Bidirectional Sequence Modeling}
Besides autoregressive tasks, we also evaluate Combiner\xspace on a set of standard bidirectional tasks to show the general applicability of the method.
\subsubsection{Long-Range Arena}
Long-Range Arena (LRA) is a unified benchmark~\citep{tay2020long} for probing the capability of efficient transformers on handling long sequences. We evaluate our models on five tasks from LRA: ListOps, Text Classification, Retrieval, Image Classification and Pathfinder. All of the tasks are sequence-level multi-class classification. Please refer to the original LRA paper for more details.
\input{tables/lra}
As shown in Table~\ref{tab:lra}, Combiner\xspace is able to match the performance of vanilla Transformer and achieves even better performance in some tasks. Following the protocol of LRA, all methods use the same architecture and hyperparameters for a controllable comparison. We use the numbers from~\citet{tay2020long} for all tasks except for Pathfinder. Since we were unable to reproduce the original Pathfinder results using the default setup in LRA Github repository, we rerun all the baselines using Pathfinder-inter configuration to conduct fair comparison. However, as the benchmark is still of small-scale and the LRA official website discourages hyperparameter tuning, Table~\ref{tab:lra} should be treated as results for the test bench of expressiveness compared to vanilla Transformer.
\begin{figure}[t]
\begin{minipage}{0.38\textwidth}
\captionof{table}{\small MLM perplexity on C4 dataset. \label{tab:mlm_c4}}
\resizebox{\textwidth}{!}{%
\begin{tabular}{cc}
\toprule
\bf Model & \bf Perplexity \\
\midrule
Transformer-2k~\citep{vaswani2017attention} & 4.552\\
BigBird-2k~\citep{zaheer2020big} & 4.696 \\
Performer-2k~\citep{choromanski2020rethinking} & 10.940 \\
\cmidrule(r){1-1} \cmidrule(l){2-2}
Fixed-2k~\citep{child2019generating} & 5.279 \\
Combiner\xspace-Fixed-2k (Ours) & 5.170 \\
\cmidrule(r){1-1} \cmidrule(l){2-2}
Axial-2k~\citep{ho2019axial} & 5.370 \\
Combiner\xspace-Axial-2k (Ours) & 4.809 \\
\cmidrule(r){1-1} \cmidrule(l){2-2}
Routing-2k~\citep{roy2021efficient} & 6.703 \\
Combiner\xspace-Routing-2k (Ours) & 6.539 \\
\midrule
BigBird-8k~\citep{zaheer2020big} & 4.542 \\
Combiner\xspace-Axial-8k (Ours) & 4.190 \\
Combiner\xspace-Fixed-8k (Ours) & \textbf{4.139} \\
\bottomrule
\end{tabular}
}%
\end{minipage}
\hfill
\begin{minipage}{0.62\textwidth}
\centering
\includegraphics[width=1.0\textwidth]{figs/mlm_memory_speed.pdf}
\captionof{figure}{We measure the inference runtime and memory usage for eight models. Overall Combiner\xspace has similar speed with Performer and its sparse counterpart but Vanilla Transformer quickly goes OOM when sequence length grows. \label{fig:memory-speed}}
\end{minipage}
\end{figure}
\subsubsection{Masked Language Modeling}
As the core element of BERT langauge pretraining~\cite{devlin2018bert}, masked language modeling (MLM) refers to the task of reconstructing tokens that are randomly masked out in the input sequence.
As with the LM task, we use perplexity as the main metric, which correlates relatively well with down-stream task performance.
Specifically, we use the large scale C4 dataset~\citep{raffel2019exploring} for training and evaluation, and consider different sequence lengths.
Following the original BERT setup, we mask out 15\% of the tokens in each input sequence.
The comparison is summarized in Table \ref{tab:mlm_c4}.
Similar to the LM result, different Combiner\xspace variants consistently outperform their corresponding baselines under 2k sequence length.
However, apart from the standard Transformer, Combiner\xspace-2k also falls behind BigBird-2k.
We conjecture that this is related to the special design in BigBird such as all tokens can always attend to the \texttt{<cls>} token directly, which is only applicable in non-causal problems.
That said, when we further increase sequence length to 8k, the standard Transformer runs into OOM issue, whereas Combiner\xspace not only outperforms BigBird but also substantially surpasses Transformer-2k.
This suggests that Combiner\xspace can truly benefit from scaling learning to longer sequence lengths.%
\subsection{Runtime and Memory Usage of Combiner\xspace}
Here we evaluate the inference runtime and memory usage of five baselines -- Transformer, Performer, BigBird, Sparse-Fixed and Sparse-Axial, as well as three variants of Combiner\xspace -- Combiner-Fixed\xspace, Combiner-Axial\xspace and Combiner-Mixture\xspace. We run inference of all the models on a TPU v3-16 (16 cores x 16GB) with batch size 16, and we test sequences of length from $2^{10}$ to $2^{14}$. As shown in \Figref{fig:memory-speed}, Combiner\xspace instantiations achieve comparable runtime and memory usage with their sparse counterpart and Performer. Note Combiner\xspace achieves much better empirical performance than the sparse models and Performer. Combiner-Mixture\xspace has the same asymptotic complexity with Combiner-Fixed\xspace and Combiner-Axial\xspace, however, since it requires running two partition plans, it is slower than Combiner-Fixed\xspace and Combiner-Axial\xspace. Due to the \texttt{gather} operation required by the random attention which is not very TPU/GPU friendly, BigBird is very computationally expensive. And the Transformer model quickly runs out of memory when sequence length increases.
\section{Combiner\xspace Instantiations}
\label{sec:instantiate}
\vspace{-1mm}
In this section we show several local factorization schemes satisfying the requirements in~\Secref{sec:chain_rule}. As we will see, Combiner\xspace is able to convert several sparse transformers~\citep{child2019generating,li2019enhancing,ho2019axial,kitaev2020reformer,roy2021efficient}
into full attention, with the same order of computation and memory consumption.
One can also design other factorization patterns, which can be easily instantiated in Combiner\xspace.
\subsection{Combiner\xspace-Fixed}
The Sparse Transformer~\citep{child2019generating} is one of the most representative variants that can achieve ${\mathcal{O}}(L\sqrt{L})$ computation and memory cost with sparse attention.
Here we show how to convert this fixed pattern proposed in~\citep{child2019generating} (\Figref{fig:attention_illustration}(A)) into a factorization plan, and instantiate a full attention variant named the \emph{Combiner\xspace-Fixed} (\Figref{fig:attention_illustration}(D)).
In the {fixed-sparse} attention, the support is $\Omega_i^{\text{sparse MLM}} = \cbr{j : j \text{ mod } s = 0} \cup \cbr{j : j \equiv i \rbr{\text{div } s} }$ where $s$ is a hyper-parameter, div is integer division, and $j \equiv i \rbr{\text{div } s}$ denotes that the quotients of $i$ and $j$ w.r.t. $s$ are the same. In the autoregressive case, $\Omega_i^{\text{sparse LM}} = \Omega_i^{\text{sparse MLM}} \cap [i]$.
Please refer to~\Figref{fig:attention_illustration}(A) for an illustration of the LM version.
Our design of $\omega_{\text{fixed}}^{\text{MLM}}$ has the following form:
\begin{equation}
\Omega_i^{0} = \cbr{j : j \equiv i \rbr{\text{div } s} }, \Omega_i^{r} = \cbr{j : j \text{ div } s = r, j \notin \Omega_i^{0}}, \forall r \in [L \text{ div } s], \: \forall i \in [L]
\end{equation}
where each \textit{local expectation} is performed in each span of size $s$, and there are totally $L \text{ div } s$ spans across all locations. For each position $i\in[L]$, there are $(s + (L \text{ div } s))$ terms in \eqref{eq:two_exp}
; the local expectation has $(L \text{ div } s)$ terms
. The overall complexity is ${\mathcal{O}}(L\cdot (s + 2(L \text{ div } s)))$.
The optimal $s$ is ${\mathcal{O}}(\sqrt{L})$, and we can achieve ${\mathcal{O}}(L\sqrt{L})$ computation and memory complexity, which is the same as~\citep{child2019generating} but here we gain full attention capability in each attention head. For the LM case, we can simply have $\omega_{\text{fixed}}^{\text{LM}}: \{\Omega_i^r\cap[i]\:|\: \Omega_i^r\in\omega_{\text{fixed}}^{\text{MLM}}\}$, which has the same ${\mathcal{O}}(L\sqrt{L})$ optimal complexity.
\subsection{Combiner\xspace-Logsparse}\label{sec:logsparse}
The Logsparse Transformer is proposed in~\citep{li2019enhancing} and can theoretically achieve ${\mathcal{O}}(L\log{L})$ cost. The general idea is to make the size of support $\Omega_i^{\text{sparse}}$ no larger than $\lceil \log_2{i} \rceil$. For the ease of notation, we first define $\text{bits}(n) = [b_1, b_2, \ldots, b_{\lceil \log_2{n} \rceil}]$ to be the binary representation of integer $n$, with $b_t \in \cbr{0, 1}$ the coefficient of basis $2^t$. Thus we have $n = \sum_{t=1}^{\lceil \log_2{n} \rceil}b_t * 2^t$. One of the possible design choices to make Logsparse in the LM case is $\Omega_i^{\text{sparse LM}} = \cbr{\text{suff}_t := \sum_{\tau=t}^{\lceil \log_2{i-1} \rceil} b_{\tau} * 2^{\tau} }_{t=1}^{\lceil \log_2{i-1} \rceil} \cup \cbr{i}$, \ie, attend to the location indices that equal to the suffix sum of the weighted $\text{bits}(i-1)$, as well as location $i$ itself. This serves as our base sparse version as shown in \Figref{fig:attention_illustration}(B).
To exploit this scheme in the Combiner\xspace framework, we can define $\lceil \log_2{n} \rceil$ non-overlapping supports, where $\Omega_i^{r} = [\text{suff}_r] \setminus [\text{suff}_{r+1}]$ with the boundary case $[\text{suff}_{\lceil \log_2{i-1} \rceil+1}] = \emptyset$. Note that for the ease of notation, some of the $\Omega_i^{r}$ are empty which will be ignored. In this case, the direct attention set $\Omega_i^{0}$ includes $\cbr{i}$, as well as $\cbr{i-1}$ when $i$ is an even number. Such a factorization leads to \emph{Combiner\xspace-Logsparse}, as shown in~\Figref{fig:attention_illustration}(E). From the Figure, we observe that in total we will have span summaries for every $2, 4, 8, \ldots, 2^{\lfloor \log_2{L} \rfloor}$ locations, resulting in total $\sum_{t=1}^{\lfloor \log_2{L} \rfloor} \lfloor \frac{L}{2^t} \rfloor$ or ${\mathcal{O}}(L)$ summaries. Each location $i$ will select at most ${\mathcal{O}}(\log(i))$ non-overlapping spans to cover the full support $\Omega_i$, and thus, the total cost will be ${\mathcal{O}}\rbr{L\log L}$. We leave the design of MLM case to \appref{app:logsparse-mlm}.
\subsection{Combiner\xspace-Axial}\label{sec:axial}
\begin{figure}[h]
\centering
\includegraphics[width=0.9\textwidth]{figs/axial_all}
\caption{Attention matrices and sequence being attended (e.g., a 3x4 image) of vertical and horizontal variants of Combiner\xspace-Axial. Blue and yellow correspond to direct and local attention respectively for location $i$ (purple). Locations connected by arrows correspond to the same support $\Omega^r$. \label{fig:axial_variants}}
\end{figure}
The Axial Transformer~\citep{ho2019axial} builds the attention along each axis of the input data.
Without loss of generality, we focus on 2D case where the input sequence is reshaped into a matrix of size $n \times m = L$. Specifically, the location $i$ in original sequence will be in $\textit{row}_i = (i-1) \text{ div } m + 1$ and $\textit{col}_i = (i-1) \text{ mod } m + 1$.
We show how to simply enable full attention with factorization on $2$D matrix, hence \emph{Combiner\xspace-Axial}.
The sparse axial has $\Omega_i^{\text{sparse MLM}} = \cbr{j : j - 1 \equiv i - 1 (\text{mod } m)} \cup \cbr{j : j - 1 \equiv i - 1 (\text{div } m)}$, and $\Omega_i^{\text{sparse LM}} = \Omega_i^{\text{sparse MLM}} \cap [i]$, which all have at most $O(m + n)$ entries for each $i$, as illustrated in~\Figref{fig:attention_illustration}(C). We propose several factorization schemes to make it an attention with full support.
\begin{itemize}[leftmargin=*]
\item $\omega_{\text{axial-vertical}}^{\text{LM}}$: $\Omega_i^{0} = \Omega_i^{\text{sparse LM}}$, and $\Omega_i^{r} = \cbr{j: j \equiv r (\text{mod } m)} \cap [i - \textit{col}_i]$, for $r \in [m] \setminus \cbr{\textit{col}_i}$. As depicted in~\Figref{fig:axial_variants}(A), $\Omega_i^{r}$ corresponds to the column $r$ above $\textit{row}_i$, where we use max pooling to obtain the abstraction. To obtain such abstraction for all the locations, we can leverage the \texttt{cummax} operator for each column to efficiently obtain the prefix-max.
\item $\omega_{\text{axial-horizontal}}^{\text{LM}}$: similar as $\omega_{\text{axial-vertical}}$ except that each $\Omega_i^{r}$ summarizes the row $r$ before $\textit{row}_i$ and excludes $\textit{col}_i$ (\Figref{fig:axial_variants}(B)).
\item $\omega_{\text{axial-rowmajor}}^{\text{LM}}$: $\Omega_i^{0} = \cbr{j : j - 1 \equiv i - 1 (\text{div } m)} \cap [i]$, \ie, elements in the same row are directly attended, while $\Omega_i^{r} = \cbr{j: j \equiv r (\text{div } m)} \cap [i - \textit{col}_i]$ captures the rows before $\textit{row}_i$. This structure is similar to Combiner\xspace-Fixed, except for the way that the \textit{abstraction} (and thus the \textit{local expectation}) is computed. Combiner\xspace-Fixed computes the \textit{abstraction} only based on $r$ of partition $\Omega_i^r$, where $\omega_{\text{axial-rowmajor}}$ depends on both $r$ and the column $\textit{col}_i$ (\Figref{fig:attention_illustration}(F)).
\end{itemize}
In all cases above, the cost is similar to the Axial Transformer~\cite{ho2019axial}, which is $O(L \sqrt{L})$ if we reshape the sequence to a 2D matrix with $n, m = O(\sqrt{L})$. We defer the MLM case to \appref{app:axial-mlm}.
\subsection{Combiner\xspace-Learnable}\label{sec:learnable}
Inspired by the Reformer~\citep{kitaev2020reformer} and Routing Transformer~\citep{roy2021efficient}, we can also learn the factorization plan $\omega$ from the data. We illustrate this with Routing Transformer and provide a way to enable full attention in Routing Transformer following the Combiner\xspace principle.
For a specific layer, suppose we have a learned disjoint region (or cluster in Routing Transformer) $\cbr{\Omega^r}_{r=1}^n$ where $\cup_{r} \Omega^r = [L]$. In Routing Transformer, we simply have $\Omega_i^{\text{sparse MLM}} = \Omega^{r_i}$ where $\Omega^{r_i}$ denotes the region where position $i$ belongs to. To define the Combiner factorization, we let
\begin{equation}
\omega_{\text{routing MLM}}: \Omega_i^0 = \Omega^{r_i}, \quad \Omega_i^{r} = \Omega^r \setminus \Omega_i^0, \quad \forall r \in [n_i].
\end{equation}
Note that $n_i = n$ (\ie, number of learned clusters) for all locations. The above factorization can only work for MLM. LM requires the following definition:
\begin{equation}
\omega_{\text{routing LM}}: \Omega_i^0 = \Omega^{r_i} \cap [i], \quad \Omega_i^{r} = \rbr{\Omega^r \setminus \Omega_i^0} \cap [i], \quad \forall r \in [n_i].
\end{equation}
In general, both LM and MLM can have sub-quadratic cost when $n = O(\sqrt{L})$. However, routing variants (including the Routing Transformer) require a \texttt{gather} operation, which can be slow on TPUs (see illustration in \appref{app:learnable}).
\section{Introduction}
The Transformer~\citep{vaswani2017attention} is a powerful neural network architecture that has demonstrated state-of-the-art performance in machine translation~\citep{chen2018best} and many other natural language processing (NLP) tasks via pretraining, using either unidirectional language modeling~\citep{brown2020language} or bidirectional language modeling~\citep{yang2019xlnet, devlin2018bert, lan2019albert, liu2019roberta, raffel2019exploring}. It has also achieved excellent results in other domains like image recognition~\citep{dosovitskiy2020image}, code understanding~\citep{kanade2020learning}, speech recognition~\citep{dong2018speech}, protein~\citep{madani2020progen}, music~\citep{huang2018music} and image~\citep{child2019generating} generative modeling. The core component of Transformer is the attention mechanism, which computes dependencies between all pairs of positions in a sequence. However, for a sequence of length $L$, the expressiveness of pairwise attention comes at a quadratic cost ${\mathcal{O}}(L^2)$ in both time and memory consumption.
This makes the vanilla Transformer~\cite{vaswani2017attention} prohibitive for applications that involve long sequences, including high-resolution images, protein sequences, or raw speech signals~\citep{oord2016pixel},
where the sequence length $L$ is often larger than $10,000$~\citep{child2019generating}.
Recently, there have been several attempts to scale up attention to long sequences. A popular class of methods sparsifies the attention matrix with different sparsity patterns, including local window~\citep{parmar2018image, rae2019compressive}, local+stride~\citep{child2019generating}, log-sparse~\citep{li2019enhancing}, axial~\citep{huang2019ccnet,ho2019axial}, or learnable patterns through hashing~\citep{kitaev2020reformer} or clustering~\citep{roy2021efficient}. Sparse attention enjoys sub-quadratic cost, but is lossy in capturing all-pair relationships. Generally, sparse attention requires more layers~\citep{child2019generating, ho2019axial, dai2019transformer} to achieve full autoregressive or bidirectional dependencies (or receptive fields~\citep{ho2019axial}) for each location in a long sequence.
Alternatively, another line of research has tried to achieve scalability with an explicit low-rank assumption~\citep{shen2018factorized, wang2020linformer} on the attention matrix or by using explicit feature maps of some kernels~\citep{katharopoulos2020transformers}. However these explicit low dimensional approximations might be too restricted for the potentially full rank attention matrix, which uses exponential kernels that are effectively infinite dimensional~\citep{si2017memory}.
The Performer~\citep{choromanski2020rethinking} is among the first works that attempts to approximate regular full-rank attention with the random feature trick~\citep{rahimi2007random}. However such random-feature based approaches~\citep{peng2021random} require many more bases to better approximate the exponential kernel~\citep{si2017memory}, and empirically we found it produces inferior results in some sequence modeling tasks, such as density estimation.
In this paper we propose \emph{Combiner\xspace}, a drop-in replacement for the vanilla quadratic attention mechanism with sub-quadratic computation and memory cost. Combiner\xspace still achieves full attention capability within each head of Multi-Head Attention, unlike approaches that adopt sparse or low-rank approximations. As we will discuss, the standard attention computed at each location can be seen as the conditional expectation of the value embeddings at all feasible locations given the current location. Based on such an understanding, Combiner\xspace explicitly approximates the conditional distribution in through a structured factorization of the probability space. Specifically, given a location $x$, the probability of attending to location $y$ can be either \emph{directly} calculated via the query vector of $x$ and key vector of $y$, or \emph{indirectly} through a local \emph{abstraction} where $x$ first attends to the key vector that represents a group of locations containing $y$, and multiplying the probability of choosing $y$ within that group. We refer to this model as Combiner\xspace since the conditional distributions in attention become a combination between several local attentions and direct attentions. This structured decomposition enables Combiner\xspace to take existing sparse attention patterns and convert them into corresponding design choices for probability factorizations that achieve full attention. As shown in~\Figref{fig:attention_illustration}, Combiner\xspace achieves full attention with the same asymptotic complexity as sparse variants. Combiner\xspace can be easily implemented in most existing deep learning frameworks without the need for specialized hardware implementation, and is GPU/TPU friendly. In fact, both the fixed and learnable sparse attention patterns from many existing Transformer variants~\citep{child2019generating, li2019enhancing, ho2019axial, roy2021efficient} can be enhanced with such structured factorizations, with \emph{the same order} of time or memory cost.
We validate Combiner\xspace on both autoregressive and bidirectional sequence modeling tasks over a variety of domains including text and images. We show that Combiner\xspace can achieve better perplexity and accuracy when using the same transformer architectures while being much faster in terms of runtime, and achieves state of the art performance on density estimation on standard datasets CIFAR-10\xspace (2.77 bits/dim) and ImageNet-64\xspace (3.42 bits/dim), as well as the Long-Range Arena~\cite{tay2020long}. The implementation of Combiner\xspace can be found at \url{https://github.com/google-research/google-research/tree/master/combiner}.
\section{Conclusion}\label{sec:conclusion}
Inspired by the conditional expectation view of attention mechanism, we propose Combiner\xspace, a drop-in replacement of the attention module. By introducing structured decomposition to the conditional probability, Combiner\xspace achieves full attention capability while maintaining sub-quadratic computational and memory cost. We instantiate several Combiner\xspace variants converting existing sparse transformers to full attention. Combiner\xspace achieves state-of-the-art performance on both autoregressive and bidirectional tasks for image and text modeling, showing benefits in both modeling effectiveness and runtime efficiency. Future work includes additional factorization pattern designs, as well as applications of Combiner\xspace in domains like bioinformatics and speech.
\begin{ack}
We would like to thank Richard Song and David Dohan for the help on introducing Performer codebase and experiment configurations, Yi Tay and Mostafa Dehghani for clarifications on the LRA benchmark, James Lee-Thorp, Joshua Ainslie, and Ilya Eckstein for clarification on their LRA experiment results, Adams Yu for performing internal paper review and helpful suggestions. We also gratefully acknowledge the support of
DARPA under Nos. HR00112190039 (TAMI), N660011924033 (MCS);
ARO under Nos. W911NF-16-1-0342 (MURI), W911NF-16-1-0171 (DURIP);
NSF under Nos. OAC-1835598 (CINES), OAC-1934578 (HDR), CCF-1918940 (Expeditions), IIS-2030477 (RAPID),
NIH under No. R56LM013365;
Stanford Data Science Initiative,
Wu Tsai Neurosciences Institute,
Chan Zuckerberg Biohub,
Amazon, JPMorgan Chase, Docomo, Hitachi, Intel, JD.com, KDDI, NVIDIA, Dell, Toshiba, Visa, and UnitedHealth Group.
Hongyu Ren is supported by the Masason Foundation Fellowship and the Apple PhD Fellowship. Jure Leskovec is a Chan Zuckerberg Biohub investigator.
\end{ack}
{
\section{Combiner\xspace: Full Attention via Structured Conditional Expectation}\label{sec:method}
The complexity of $p\rbr{j|i}$ is the bottleneck of the computation for $A\rbr{x_i}$.
Generally, in existing sparse transformers, the support of $p\rbr{j|i}$ is sparsified to reduce the computation and memory complexity, \eg, $\Omega_i^{\text{Sparse}} \subsetneq \Omega_i^{\text{LM}}$ for LM and $\Omega_i^{\text{Sparse}} \subsetneq \Omega_i^{\text{MLM}}$ for MLM,
but this can lead to either reduced capacity or limited applicability. We defer detailed discussion of the full capacity of the model to~\appref{app:bigbird}. In this section we introduce the Combiner\xspace, which achieves $\Omega_i^{\text{Combiner}} = \Omega_i^{\text{LM}}$ for LM and $\Omega_i^{\text{Combiner}} = \Omega_i^{\text{MLM}}$ for MLM, while still maintaining sub-quadratic computation and memory cost.
Below we denote $\Omega_i$ as the support for full attention if there is no ambiguity or need to distinguish between LM or MLM.
We introduce the main design framework in \Secref{sec:chain_rule} and possible parameterizations in \Secref{sec:summary_param}. Then in \Secref{sec:tradeoff} we analyze the trade-off of Combiner\xspace.
\begin{figure*}[t]
\centering
\includegraphics[width=0.9\textwidth]{figs/color_method.pdf}\\
%
\caption{Attention matrices of several instantiations of Combiner\xspace in the autoregressive setting. We transform several sparse attention patterns: Fixed (A)~\citep{child2019generating}, Logsparse (B)~\citep{li2019enhancing} and Axial (C)~\citep{ho2019axial} to Combiner-Fixed (D), Combiner-Logsparse (E) and Combiner-Axial (F). Combiner\xspace approximates the conditional expectation~\eqref{eq:cond_exp} with a combination of direct expectation (blue) and local expectation (yellow). Our instantiations (D)(E)(F) achieves full attention with the same sub-quadratic complexity. } \label{fig:attention_illustration}
%
\end{figure*}
\subsection{Local Factorization for Conditional Expectation}
\label{sec:chain_rule}
The main idea of Combiner\xspace is to exploit a hierarchical structure for conditional probability modeling in \eqref{eq:cond_exp}, which provides the opportunity for reducing computation complexity while maintaining the same support.
Specifically, we introduce support variables $\Omega_i^{r}$, for $r=0, \ldots, n_i$ and $i\in[L]$. The support variables are disjoint, \ie, $\Omega_i^{r} \cap \Omega_i^{s} = \emptyset, \forall r \neq s$, and $\cup_{r=0}^{n_i} \Omega_i^{r} = \Omega_i$. Then we can factorize $p(j|i)$ as
\begin{eqnarray}
p(j|i) = \sum_{r=0}^{n_i} p(j, \Omega_i^{r}|i)= \sum_{r=0}^{n_i} p(j| \Omega_i^{r}, i) p(\Omega_i^{r}|i) = {\color{red}p(j| \Omega_i^{r_j}, i)} p(\Omega_i^{r_j}|i),
\label{eq:factor_full}
\end{eqnarray}
where ${r_j}$ denotes the index of the support to which $j$ belongs. The last equation arises from the fact that the $\Omega_i^r$ are disjoint from each other ($\Omega_i^{r} \cap \Omega_i^{s} = \emptyset, \forall r \neq s$).
Therefore, there is only one support, $\Omega_i^{r_j}$, containing $j$. The remaining terms, where $j\not\in \Omega_i^r$ for $r\neq r_j$, are all zero since $p\rbr{j|\Omega_i^r, i} = 0$.
Furthermore, assume $\Omega_i^{r_j}$ is a sufficient statistic, \ie, $j$ and $i$ are independent given $\Omega_i^{r_j}$, we obtain
\begin{equation}\label{eq:factor}
p(j|i) = {\color{blue}p(j| \Omega_i^{r_j})} p(\Omega_i^{r_j}|i).
\end{equation}
Given the partition $\cbr{\Omega_i^r}_{r=0}^{n_i}$, the attention form in~\eqref{eq:cond_exp} can be rewritten as
\begin{eqnarray}
A\rbr{x_i} &=& \EE_{p\rbr{j|i}}\sbr{v_j} = \sum_{r=0}^{n_i} \sum_{j\in \Omega_i^r} p\rbr{j, \Omega_i^r|i} v_j\label{eq:intermediate}\\\
&= &
\textstyle
\underbrace{\sum_{j \in \Omega_i^{0}} \tilde{p}(j | i) v_j}_{\text{direct expectation}} + \sum_{r=1}^{n_i} p(\Omega_i^{r} | i) \underbrace{ \bigg( \sum_{j \in \Omega_i^{r}} p(j | \Omega_i^{r}) v_j \bigg) }_{\text{local expectation}},
\label{eq:two_exp}
\end{eqnarray}
where we consider direct attention in partition $\Omega^0_i$ and apply the local factorization~\eqref{eq:factor} to the partition $r=1,\ldots, n_i$. Here $\tilde{p}(j|i) \propto p(j|i)$ but with different normalization constants, which will be explained below.
We refer to this model as \emph{Combiner\xspace} since the structured attention~\eqref{eq:two_exp} combines the direct expectation of $\Omega^0_i$ and multiple local expectations via $p(j|\Omega_i^{r})$ and $p(\Omega_i^{r}|i)$ to form the final conditional expectation.
Equivalently, we can also rewrite the structured attention~\eqref{eq:two_exp} as
\begin{eqnarray}
\textstyle
A(x_i)
= \sum_{j \in \Omega_i} \underbrace{\sbr{ \II(j \in \Omega_i^{0}) \tilde{p}(j | i) + \sum_{r=1}^{n_i} \II(j \in \Omega_i^{r}) p(j | \Omega_i^{r}) p(\Omega_i^{r}|i) }}_{\text{the new effective conditional probability } q(j|i) } v_j,
\label{eq:effective_form}
\end{eqnarray}
where $\II(\cdot)$ is a binary indicator function. After reordering, one can see from \eqref{eq:effective_form} that we obtain the effective conditional probability $q(j|i)$ that tries to approximate the original $p(j|i)$. Each probability term depends on both current location $i$ and other location $j$, and the expectation is still obtained with respect to a valid conditional probability (non-negative and sums up to 1 over $\Omega_i$).
\textbf{Requirement for Sub-quadratic Cost.} We can immediately see the benefit of this formulation from the fact that the \textit{local expectation} in~\eqref{eq:two_exp} is independent of the position $i$. The full dependence is achieved via the multiplier $p(\Omega_i^{r}|i)$ where $j \in \Omega_i^{r}$. If we can design the local factorization such that:
\begin{enumerate}[leftmargin=*,nolistsep,nosep]
\item the order of number of terms in~\eqref{eq:two_exp} for $p(\cdot|i), \: \forall i\in[L]$: $\sum_{i=1}^L (n_i + |\Omega_i^{0}|)$ is sub-quadratic; and
\item let $\Ucal = \{ \Omega_i^{r} \}_{i \in [L], r \in [1,n_i]}$ be the unique set of partitions used for local expectation calculation, then the order of $|\Ucal|$ (\ie, the number of unique partitions in $\Ucal$) is sub-quadratic;
\item the order of total number of unique calculations of local expectation across all locations in~\eqref{eq:two_exp}, $\sum_{\Omega \in \Ucal} |\Omega|$ is sub-quadratic;
\end{enumerate}
then one can see that the overall computation and memory cost will be sub-quadratic with full attention support $\Omega_i^{\text{Combiner}}=\Omega_i,\:\forall i \in [L]$. We will discuss in detail in \Secref{sec:instantiate} how to instantiate such a principle by drawing inspiration from existing sparse transformers, and how to convert them into a full attention model almost for free with identical asymptotic complexity.
\textbf{Remark (Further Hierarchical Decomposition):} We introduce the local decomposition with a one layer partition of support of $p(\cdot|i)$ for simplicity. In fact, such local decompositions can be stacked further, which introduces a partition tree. Specifically, we can further partition $\Omega_i^r$ with disjoint subsets $\cbr{\Omega_i^{rk}}_{k=1}^{n_r}$, and consider local decomposition $p(j, \Omega_i^r|i) = p(j| \Omega_i^{rk_j}, i)p(\Omega_i^{rk_j}|\Omega_i^r, i)p(\Omega_i^{r}|i)$, where $k_j$ is the index of sub-region which $j$ belongs to. Thus, we obtain a hierarchical decomposition of $p(j|i)$, which can also be plugged to \eqref{eq:intermediate} and yield a new full attention formulation.
\subsection{Parameterizing Conditional Probabilities}
\label{sec:summary_param}
While we obtained a possible way to speed up the standard Transformer via a combination of direct expectation and local expectations, it is also important to have an efficient design choice for the probability terms in \eqref{eq:two_exp}, namely $\tilde{p}(j|i)$ from direct expectation, $p(j|\Omega_i^{r})$ from local expectation and $p(\Omega_i^{r}|i)$ for $r \in [1,n_i]$. For simplicity we use the scaled dot-product, which means that we will associate positions $i, j$ and variable sets $\Omega_i^{r}$ with the corresponding embedding representation, and thus the probability is proportional to the exponential of the embedding inner products. Specifically:
\begin{itemize}[leftmargin=*,nolistsep,nosep]
\item \textbf{$\tilde{p}(j|i)$:} As this term is for the direct expectation, we can let $\tilde{p}(j|i) \propto \exp(\frac{q_i}{\sqrt{d}} k_j^\top)$, which is the same as vanilla attention~\eqref{eq:cond_exp} but with different normalizations, which will be explained in \Eqref{eq:norm_const}.
\item \textbf{$p(\Omega_i^{r}|i)$:} This term aims to capture the joint event probability, \ie,
$
p(\Omega_i^{r}|i) \propto \exp \rbr{\frac{q_i}{\sqrt{d}} k_{\Omega_i^{r}}^\top }$.
Thus the design choice of $k_{\Omega_i^{r}}$ should make an \textit{abstraction} of the corresponding support $\Omega_i^{r}$. We find $k_{\Omega_i^{r}} = \text{max pooling}_{j \in \Omega_i^{r}}{k_j}$ already provides good empirical results without introducing additional parameters; we can also use DeepSets~\citep{zaheer2017deep} to obtain such abstraction.
\item \textbf{$p(j|\Omega_i^{r})$: } This term is the probability of getting $j$ within this local span $\Omega_i^{r}$. We make $p(j|\Omega_i^{r}) \propto \exp\rbr{\frac{q_{\Omega_i^{r}}}{\sqrt{d}} k_j^\top}$, where we use max pooling or DeepSets over $\cbr{q_j}_{j \in \Omega_i^{r}}$ to obtain $q_{\Omega_i^{r}}$ similarly.
\end{itemize}
\noindent \textbf{Normalizing Probability Terms.} The terms in each local expectation $p(j|\Omega_i^{r}), \:\forall j\in\Omega_i^{r}$ can be normalized within the local span; the direct expectation $\tilde{p}(j|i)$ and the terms in $p(\Omega_i^{r}|i)$ should be normalized together,
\begin{equation}
Z(x_i) = \sum_{j \in \Omega_i^{(0)}} \exp\rbr{\frac{q_i}{\sqrt{d}} k_j^\top} + \sum_{r=1}^{n_i} \exp \rbr{\frac{q_i}{\sqrt{d}} k_{\Omega_i^{r}}^\top },
\label{eq:norm_const}
\end{equation}
and $Z(x_i)$ is the normalizing constant when calculating $\tilde{p}(j|i)$ and $p(\Omega_i^{r}|i)$.
\subsection{Trade-offs in Combiner\xspace}
\label{sec:tradeoff}
Combiner\xspace achieves full attention with reduced cost without making explicit sparsity or low-rank assumptions over the attention matrix. However this efficiency gain is not free. In this section we discuss the limitations of the simplification made by Combiner\xspace, and provide a simple workaround.
\vspace{-2mm}
\paragraph{Structured Attention Approximation.}
We obtain the local decomposition~\eqref{eq:factor} under the \emph{conditional independence} assumption. Therefore, the \textit{local expectation} in \eqref{eq:two_exp} is independent of the position $i$, this suggests that any two locations $i_1$ and $i_2$ with $\Omega_{i_1}^{r} = \Omega_{i_2}^{r} = \Omega$ would have linearly dependent attention scores over the region $\Omega$. Formally,
the probabilities formed by the effective conditional distribution $\vec{a}(\Omega)_{i_1} = \sbr{q(j_1|i_1), q(j_2 | i_1), \ldots, q(j_{|\Omega_{i_1}^{r}|}|i_1)} = \frac{p(\Omega_{i_1}^{r}|i_1)}{p(\Omega_{i_2}^{r}|i_2)}\vec{a}(\Omega)_{i_2}$.
In other words, the rank of the sub-matrix over the same partition
in the resulting attention matrix is 1, therefore, the attention matrix is locally low-rank based on the partition. On the other hand, the \textit{direct expectation} fully attends to each position in sub-support $\Omega_0$, which ensures the full-rank block. These two attention schemes make the attention matrix of~Combiner\xspace structured.
Compared with the low-rank approximation for attention~\citep{katharopoulos2020transformers,choromanski2020rethinking,peng2021random}, which is inspired from random features~\citep{rahimi2007random} in the kernel community, a structured approximation that exploits both the locally low-rank and full-rank blocks has been proved more powerful theoretically and empirically in large-scale kernel machines~\citep{si2017memory}.
\vspace{-2mm}
\paragraph{Improving Expressiveness Using a Mixture Model.} One way to further improve the expressiveness of the local factorization is to use a mixture model. This idea is adapted from the mixture of softmaxs~\citep{yang2017breaking} to obtain high-rank softmax layer in language modeling. Let $\omega$ be a certain partition of the support (\ie, collection of $\Omega_i^{r}$) of $\Omega_i$, then one can easily use $A(x_i) = \frac{1}{M} \sum_{m=1}^M A(x_i; \omega_m)$ to compute the attention, where each component of the mixture $A(x_i; \omega_m)$ is the term \eqref{eq:two_exp} using a specific factorization plan $\omega_m$. Empirically we find two components are already sufficient to improve performance.
\section{Attention as Conditional Expectation}
\vspace{-1mm}
In this section, we revisit the formulation of the standard Transformer~\citep{vaswani2017attention} from the perspective of conditional expectation, which inspires the derivation of Combiner\xspace.
Without loss of generality, we use a single sequence in the self-attention scenario. Given a sequence of $L$ embeddings $X = [x_1, x_2, \ldots, x_L]$, where $X \in \RR^{L \times d}$ and each embedding $x_i \in \RR^d$ is a $d$-dimensional vector, the core component of Transformer is the multi-head attention, where each head $h$ is a scaled dot-product attention:
\begin{equation}
A_h(X) = \texttt{softmax}\rbr{\frac{Q_h}{\sqrt{d}} K_h^{\top}} V_h, \cbr{Q_h = XW^Q_h, K_h = XW^K_h, V_h = XW^V_h} \in \RR^{L \times d},
\label{eq:vanilla_att}
\end{equation}
and the attention vector from each head $A_h(X)$ is concatenated and projected:
\begin{equation}
\texttt{MultiHeadAttn}(X) = \sbr{A_1(X), A_2(X), \ldots, A_H(X)} W^o, W^o \in \RR^{Hd \times d}
.
\end{equation}
Here $H$ is the total number of heads per Transformer layer. In this paper, we focus on how to approximate full attention within \textit{each} head of multi-head attention. For ease of notation, we drop the head index $h$ whenever possible, and use lower-case letters $x_i, q_i, k_i, v_i \in \RR^d$ to denote rows in $X, Q, K, V$ respectively, which corresponds to a location $i$ in the original sequence of length $L$. We use $[n]$ to denote the set of positive integers $\cbr{1, 2, \ldots, n}$.
For a position $i \in [L]$, the attention formulation~\eqref{eq:vanilla_att} can be viewed as conditional expectation of rows in $V$. Specifically, since $\texttt{softmax}$ outputs a probability distribution, we can rewrite \eqref{eq:vanilla_att} as
\begin{equation}
A(x_i) = \EE_{p\rbr{j|i}}\sbr{v_j}, \quad \quad p(j | i) = \frac{1}{Z\rbr{x_i}} \exp \rbr{\frac{q_i}{\sqrt{d}} k_j^\top},
\label{eq:cond_exp}
\end{equation}
where $p(j|i)$ denotes the conditional probability at position $j$ given the token at position $i$ and
the partition function $Z\rbr{x_i} = \sum_{j\in \Omega_i} \exp \rbr{\frac{q_i}{\sqrt{d}} k_j^\top}$ over support $\Omega_i$.
The support $\Omega_i$ of $p\rbr{j|i}$ defines the set of valid locations that the $i$-th token can attend to.
For instance, the support set in autoregressive language modeling (LM) consists of all previous tokens, i.e., $\Omega_i^{\text{LM}} = [i]$\footnote{Following the conventional implementation, the input sequence will be ``\texttt{right-shifted}'' so that the position $i$ can attent to itself in LM setting.}; in masked language modeling (MLM) the support consists of all tokens in the sequence, i.e., $\Omega_i^{\text{MLM}} = [L]$.
That is, $\Omega_i^{\text{LM}}$ and $\Omega_i^{\text{MLM}}$ represent the full attention capability respectively in the LM and MLM setting.
| {'timestamp': '2021-10-29T02:12:55', 'yymm': '2107', 'arxiv_id': '2107.05768', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05768'} | arxiv |
\section{Conversation Intent Clarification}
\label{sec:methods}
In this section, we first introduce the definition of the conversation intent clarification task. To approach the task, we propose a two-step method to ask clarifying questions in the conversation. We illustrate the model for initial clarifying question selection in Section \ref{subsec:init_retrieval} and the model that selects the next question using negative feedback to previous questions in Section \ref{subsec:cq_negfeedback}.
\begin{figure}
\includegraphics[width=0.5\textwidth]{figures/FeedbackModel.pdf} %
\caption{Our Maximal Marginal Relevance based BERT Model (MMR-BERT). }
\label{fig:mmr-bert}
\end{figure}
\subsection{Task Formulation}
Suppose that a user has a specific information need about an ambiguous or faceted topic $t$. The user issues $t$ as a query to the system \footnote{We use topic and query interchangeably in the paper}. Let $h=((q_1, a_1), (q_2, a_2), \cdots, (q_{|h|}, a_{|h|}))$ be the conversation history between the user and the system, where the system asks the user $|h|$ clarifying questions $Q_h = \{q_i | 1\leq i \leq |h|\}$ about the potential intents behind the topic, and the user confirms or denies the corresponding intent indicated in $q_i$ with $a_i$. For any candidate question $q$, its label $y(q)=2$ if it covers the user's true intent, $y(q)=1$ if it covers other intents of $t$, and $y(q)=0$ if it is not relevant to $t$. The system's target is to identify the user's true intent within the fewest interactions, i.e., $\argmin(|Q^{\bigstar}=\{q|y(q)=2|)$.
Since it is not practical to ask too many questions, the system ends the conversation and returns the document retrieval results whenever the user's intent is confirmed or the limit of conversations turns $k$ ($|h|\leq k$) is reached.
\subsection{First Clarifying Question Selection}
\label{subsec:init_retrieval}
The first clarifying question is especially important to elicit user interactions as it will impact the effectiveness of all the future questions and user interactions.
The information available to select the initial question is the query itself. Thus it is essential to effectively measure the relevance of a candidate question by how it matches the user query.
\textbf{Query-question Matching.}
In recent years, BERT \cite{devlin2018bert} has shown impressive performance in short-text matching tasks by pre-training contextual language models with large external collections and fine-tuning the model based on a local corpus.
We leverage BERT to select questions in the intent clarification task. Specifically, we select the first question based on the relevance score of matching a candidate $q$ to topic $t$ calculated with BERT:
\begin{equation}
\label{eq:init_bert}
s(q,t) = MLP_0(\text{BERT-ENC}(q,t))
\end{equation}
where BERT-ENC$(S_A, S_B)$ is the output vector of matching sentence A ($S_A$) and sentence B ($S_B$) as shown in Figure \ref{fig:mmr-bert}, $MLP_0$ is a multilayer perceptron (MLP) with output dimension 1. Specifically, BERT-ENC$(S_A, S_B)$ inputs the token, segment, and position embeddings of the sequence (\textsl{[CLS], tokens in $S_A$, [SEP], tokens in $S_B$}) to the pre-trained BERT model \cite{devlin2018bert} and take the vector of [CLS] after the transformer encoder layers as output.
\textbf{Loss Function.}
We have two ways of calculating the training loss.
As a first option, assuming that we do not have any prior knowledge about each user's intent, the retrieval of the first question should simply focus on retrieving questions that are relevant to the initial query string $t$.
Thus we collect a set of query pairs $Q^P$ and each pair consists of a relevant and a non-relevant question, i.e., $Q^P=\{(q^+, q^-)| y(q^+)>0, y(q^-)=0 \}$. We consider all the questions with positive labels having the same label 1, i.e., $y'(q) = \mathcal{I}(y(q) > 0)$, where $\mathcal{I}$ is an indicator function and equals to 1 when the input condition is true otherwise it is 0.
The probability of question $q$ in the entry (pair) $E$ ($E\in Q^P$) being relevant to query topic $t$ is calculated with the softmax function:
\begin{equation}
\label{eq:prob}
Prob(y'(q)=1) = \frac{\exp(s(q,t))}{\sum_{q'\in E}\exp(s(q',t))}, E \in Q^P.
\end{equation}
Then the loss function $\mathcal{L}$ is the cross-entropy between the binary question labels $(1,0)$ of the pair and the probability distribution of $(Prob(y'(q^+)=1), Prob(y'(q^-)=1))$:
\begin{equation}
\label{eq:pair_loss}
\mathcal{L}_{\text{BERT-INIT}} = -\sum_{E \in Q^P} \sum_{q \in E} y'(q) \log Prob(y'(q)=1).
\end{equation}
In this case, the loss function is essentially pairwise loss. We refer to the model trained with $Q^P$ as \textit{BERT-INIT}.
Among the relevant questions of the same query, only questions that match user intents can receive positive feedback and have label 2. As a second option, when we further consider which relevant questions are more likely to receive positive feedback in a prior distribution, the multi-grade label of a question can be used for training.
We extend the set of question pairs $Q^P$ to question triplets $Q^T=\{(q^{\bigstar}, q^{*}, q^-)| y(q^{\bigstar})=2, y(q^{*})=1, y(q^-=0)\}$ and still use the cross-entropy loss to optimize the model. In other words, we train the model according to:
\begin{equation}
\label{eq:triplet_loss}
\mathcal{L}_{\text{MBERT-INIT}} = -\sum_{E \in Q^T} \sum_{q \in E} y(q) \log Prob(y(q)>0),
\end{equation}
where $Prob(y(q)>0)$ is calculated based on Equation \eqref{eq:prob} with $Q^P$ replaced by $Q^T$ and $E$ is an entry of triplet.
As in \cite{ai2018learning}, this loss function can be considered as a list-wise loss of the constructed triplets. Since the probability of each question to be a target question is normalized by the scores of all the three questions in the triplet, maximizing the score of question with label 2 will reduce the score of questions with label 1 and 0. Also, questions with larger labels have more impact to the loss. This ensures that the model is optimized to learn higher scores for questions that have larger labels. We refer to this model as \textit{MBERT-INIT}.
\subsection{Clarifying Intents Using Negative Feedback}
\label{subsec:cq_negfeedback}
While the only basis of the system's decision is topic $t$ in the first conversation turn, the system can refer to conversation history in the following interactions. As we assume that the system will terminate the conversation and return the documents when the user confirms the question with positive feedback, all the available information for selecting the next clarifying question besides the topic $t$ is negative feedback. It means that the next question should cover a different intent from previous questions while being relevant to topic $t$.
Inspired by the maximal marginal relevance (MMR) principle in search diversification studies \cite{carbonell1998use}, here we propose an MMR-based BERT model (MMR-BERT) to leverage negative feedback in the conversations.
In search diversification, the basic idea of MMR is to select the next document by maximizing its relevance to the initial query and dissimilarities to previously selected documents.
Similarly, in MMR-BERT, we select the next question by jointly considering the relevance of each candidate question with respect to the initial topic $t$ and their similarities to previous questions.
Let $Q$ be the question candidate set, and $Q_h=\{q_i|1\leq i \leq |h|\}$ be the set of questions in the conversation history $h$.
Let BERT-ENC$(S_A,S_B)$ be a matching function that takes two pieces of text (i.e., $S_A$ and $S_B$) as input and outputs an embedding/feature vector to model their similarities. \footnote{Here we use BERT encoder as our matching model because it has been shown to be effective in modeling the latent semantics of text data, which is important for our task since different facets of the same topic often have subtle semantic differences that cannot be captured by simple methods such as keyword matching.}
As shown in Figure \ref{fig:mmr-bert}, MMR-BERT first obtains the matching of the topic $t$ with candidate question $q$, i.e., BERT-ENC$(t,q)$ and the matching between each previous question $q_i (1\leq i \leq |h|$) and $q$, i.e., BERT-ENC$(q_i, q)$. Then it maps the obtained vectors to lower d-dimension space ($\mathbb{R}^d$) with a multilayer perceptron (MLP) $MLP_1$, where each layer is a feed-forward neural network followed by Rectified Linear Unit (ReLU) activation function. The parameters in $MLP_1$ are shared across multiple matching pairs to let the condensed vectors comparable. Formally, the final matching between $x$ and $q$ is:
\begin{equation}
\label{eq:matching}
\begin{split}
& o(x,q) = MLP_1(\text{BERT-ENC}(x,q)) \in \mathbb{R}^{d} \\
& x=t \text{ or } q_i, 1\leq i \leq |h|
\end{split}
\end{equation}
The final score of $q$ is computed as:
\begin{equation}
\label{eq:mmr-bert}
\!\! \text{MMR-BERT}(q,t,h) \! = \! MLP_2([o(t,q);\!MaxPool_{1\leq i \leq |h|}o(q_i, q)])\!\!
\end{equation}
where $MaxPool$ represents apply max pooling on a group of vectors, $[\cdot;\cdot]$ denotes the concatenation between two vectors, $MLP_2$ is another MLP for projection to $\mathbb{R}^1$.
Given the user's negative feedback to the asked questions in the conversation history $h$, the probability of a candidate $q$ covering user intent is calculated according to:
\begin{equation}
\label{eq:hist_prob}
Prob(y(q)\!=\!2|h) \!= \! \frac{\exp(\text{MMR-BERT}(q,t,h))}{\sum_{q'\in E}\exp(\text{MMR-BERT}(q',t,h))}, E \!\in\! Q^T \!,
\end{equation}
where $Q^T$ is a set of triplets, $E$ is a triplet of questions with label 2, 1, and 0, as in Section \ref{subsec:init_retrieval}.
To differentiate the questions that would receive positive feedback from users and questions that are relevant to the topic $t$ but do not match user intents, we use the multiple-grade labels in the loss function, as MBERT-INIT in Section \ref{subsec:init_retrieval}. Since $Prob(y(q)=2,h)=Prob(y(q)=2|h)Prob(h)$ and $Prob(h)$ is fixed for topic $t$ during training. The loss function is:
\begin{equation}
\label{eq:mmrbert_loss}
\mathcal{L}_{\text{MMR-BERT}} \propto -\sum_{E \in Q^T} \sum_{h \in H(E)} \sum_{q \in E} y(q) \log Prob(y(q)=2|h),
\end{equation}
where $H(E)$ is the history set of conversation turns of length 0, 1, 2, and so on, corresponding to triplet entry $E$. For example, if the questions $q_a$,$q_b$, and $q_c$ are already asked for topic $t$, $H(E)=\{\emptyset, \{q_a\}, \{q_a,q_b\}, \{q_a,q_b,q_c\}\}$. The answers in the history are omitted in the notation since they are all ``no".
In this way, questions that cover similar intents to historically asked questions $Q_h$ have lower labels than the questions that have target intents and thus will be punished.
\textbf{Differences from Other BERT-based Models.}
Most existing BERT-based models for clarifying question selection leverage the topic(query), questions, and answers in the conversation history and do not differentiate answers that are confirmation or denial \cite{aliannejadi2019asking, hashemi2020guided}. In contrast, MMR-BERT is specifically designed to leverage negative feedback from conversation history, which means it uses previously asked questions as input and does not use the answers in the history as they are all denial (we assume that the system would stop asking questions when it has identified the user intent).
From the perspective of model design, existing models typically use average BERT representations of each historical conversation turn \cite{aliannejadi2019asking} or concatenate the sequence of a query, question, and answer in each turn as input to BERT models \cite{hashemi2020guided}. When used in the intent clarification task, these methods either do not differentiate the effect of each asked question or do not consider the effect of the initial query should be modeled differently from the questions with negative feedback. Following the MMR principle, our MMR-BERT model takes the task characteristics into account and thus can more effectively use negative feedback.
\section{Related Work}
There are three threads of work related to our study: conversational search and question answering (QA), asking clarifying questions, and negative feedback.
\textbf{Conversational Search and QA.}
The concept of information retrieval (IR) through man-machine dialog dates back to 1977 \cite{oddy1977information}. Other early work in conversational IR includes an intelligent intermediary for IR, named as I$^3$R, proposed by \citet{croft1987i3r} in 1987, and an interactive IR system using script-based information-seeking dialogues, MERIT, built by \cite{belkin1995cases} in 1995.
In recent years, task-based conversational search based on natural dialogues has drawn much attention. \citet{radlinski2017theoretical} proposed a theoretical framework for conversational IR. \citet{vtyurina2017exploring} studied how users behave when interacting with a human expert, a commercial intelligent assistant, and a human disguised as an automatic system. \citet{spina2017extracting} studied how to extract audio summaries for spoken document search. \citet{trippas2018informing} suggested building conversational search systems based on the commonly-used interactions from human communication.
Most recently, \citet{yang2018response} conducted response ranking based on external knowledge given a conversation history. \citet{wang2021controlling} propose to control the risk of asking non-relevant questions by deciding whether to ask questions or show results in a conversation turn.
Conversational question answering defines the task of finding an answer span in a given passage based on the question and answers in the conversation history such as CoQA \cite{reddy2019coqa} and QuAC \cite{choi2018quac}. \citet{qu2020open} extended the task by introducing a step of retrieving candidate passages for identifying answer span. This is more practical in real scenarios where ground truth passages that contain the answers are often unavailable.
In this paper, we focus on the next clarifying question selection based on negative feedback to identify users' true intent in the fewest conversation turns, which differs from most existing work in conversational search. Also, our intent clarification task is fundamentally different from the objective of conversational QA.
\textbf{Asking Clarifying Questions.}
In the TREC 2004 HARD track \cite{allan2005hard}, systems can ask searchers clarification questions such as whether some titles seem relevant to improve the accuracy of IR.
\citet{rao2018learning} collected a clarifying question dataset from the posts in StackOverflow and proposed to select clarification questions based on the expected value of perfect information considering the usefulness of potential answers to a candidate question. Later, \citet{rao2019answer} extended the work by using the utility \cite{rao2018learning} in a reinforcement learning framework in product QA to handle cases where contexts such as product information and historical questions and answers are available.
\citet{zhang2018towards,sun2018conversational} proposed to ask users questions about their preferred values on aspects of a product for conversational product search and recommendation.
\citet{wang2018learning} observed that a good question is often composed of interrogatives, topic words, and ordinary words and devised typed encoders to consider word types when generating questions.
\citet{cho2019generating} proposed a task of generating common questions from multiple documents for ambiguous user queries. \citet{xu2019asking} studied whether a question needs clarification and introduced a coarse-to-fine model for clarification question generation in knowledge-based QA systems. \citet{zamani2020generating} extracted the facets of a query from query logs and generated clarifying questions through template or reinforcement learning with weak supervision.
To study how to ask clarifying questions in information-seeking conversations, \citet{aliannejadi2019asking} collected clarifying questions through crowd-sourcing in a dataset called Qualc based on the ambiguous or faceted topics in the TREC Web track \cite{clarke2009overview,clarke2012overview}. They proposed to select the next clarifying question based on BERT representations and query performance prediction.
Later, \cite{hashemi2020guided} extended the idea of pseudo relevance feedback and leveraged top-retrieved clarifying questions and documents for document retrieval and next clarifying question selection on Qulac.
\citet{aliannejadi2020convai3} then organized a challenge on clarifying questions for dialogue systems that raises the questions on when to ask clarifying questions during dialogues and how to generate the clarifying questions.
Most existing work evaluates models based on either the initial query or pre-defined conversation history, i.e., the models always select the next question based on static conversation turns instead of its previously selected questions. In contrast, we select the next questions dynamically considering previous questions, which is more practical.
Also, other studies do not differentiate responses that are confirmation or denial. In contrast, we address how to leverage negative feedback in the response.
\textbf{Negative Feedback.}
Existing work on negative feedback has been relatively sparse and mostly focuses on document retrieval for difficult queries. \citet{wang2007improve} proposed to extract a negative topic model from non-relevant documents from its mixture with the language model of the background corpus.
The Rocchio model \cite{rocchio1971relevance} considers both positive and negative feedback and can be used when only negative feedback is available.
\citet{wang2008study} compared various negative feedback methods in the framework of language model or vector space model. Later, \cite{karimzadehgan2011improving} proposed a more general negative topic model that further improved the performance of difficult queries. \citet{peltonen2017negative} designed a novel search interface where users can provide feedback on the keywords of non-relevant results.
Negative feedback has also been studied in recommendation and product search. \citet{zagheli2017negative} proposed a language model based method to avoid recommending texts similar to documents users dislike. \citet{zhao2018recommendations} considered skipped items as negative feedback and used it together with positive feedback to recommend items by trial and error.
\citet{bi2019conversational} leveraged user feedback on finer-grained aspect-value pairs extracted from non-relevant results in conversational product search.
Unlike these studies, we study how to leverage negative feedback to clarifying questions that are much shorter than documents in open-domain information-seeking conversations. Our model is based on pre-trained BERT \cite{devlin2018bert} models and the Max Marginal Relevance (MMR) \cite{carbonell1998use} principle.
\section{Conclusion}
In this paper, we propose an intent clarification task based on yes/no clarifying questions in information-seeking conversations. The task's goal is to ask questions that can uncover the true user intent behind an ambiguous or faced query within the fewest conversation turns.
We propose a maximal-marginal-relevance-based BERT model (MMR-BERT) that leverages the negative feedback to the previous questions using the MMR principle.
Experimental results on the refined Qulac dataset show that MMR-BERT has significantly better performance than the competing question selection models in both the intent identification task and the associated document retrieval task.
For future work, we plan to evaluate the effect of the asked clarifying questions on the associated document retrieval task with neural document retrieval models. We are also interested in studying how to effectively use negative feedback on the clarifying questions in the document retrieval model.
\begin{acks}
This work was supported in part by the Center for Intelligent Information Retrieval and in part by NSF IIS-1715095. Any opinions, findings and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect those of the sponsor.
\end{acks}
\section{Results and Discussion}
\label{sec:results}
Next, we show the experimental results of the clarifying question selection task and the associated document retrieval task. We analyze the model behaviors as well as success and failure cases.
\begin{table}
\centering
\caption{Model performance on intent clarification task evaluated using only label 2 or both label 1 \& 2. `*' indicates the best baseline results, and `$\dagger$' shows the statistically significant improvements over them. }
\scalebox{0.95}{
\begin{tabular}{l||l|l|l||l|l}
\hline
\multirow{2}{*}{Model}
& \multicolumn{3}{c||}{Label 2 only} & \multicolumn{2}{c}{Label 1\&2} \\
\cline{2-6}
& MRR & NDCG3 & NDCG5 & NDCG3 & NDCG5 \\
\hline
QL & 0.216 & 0.130 & 0.159 & 0.514 & 0.565 \\
BERT-INIT & 0.235 & 0.143 & 0.173 & 0.531 & 0.583 \\
MBERT-INIT & 0.235 & 0.144 & 0.173 & 0.532* & 0.584 \\
\hline
SingleNeg & 0.217 & 0.131 & 0.160 & 0.513 & 0.565 \\
MMR & 0.237 & 0.144 & 0.178 & 0.531 & 0.585* \\
BERT-NeuQS & 0.241 & 0.146 & 0.182* & 0.528 & 0.580 \\
BERT-GT & 0.242* & 0.148* & 0.178 & 0.530 & 0.580 \\
\hline
MMR-BERT & \textbf{0.248$^{\dagger}$} & \textbf{0.152$^{\dagger}$} & \textbf{0.189$^{\dagger}$} & \textbf{0.533} & \textbf{0.586$^{\dagger}$} \\
\hline
\end{tabular}
}
\label{tab:cq_results}
\end{table}
\subsection{Clarifying Question Selection Results}
\label{subsec:cq_results}
\textbf{Overall Performance.}
As shown in Table \ref{tab:cq_results}, MMR-BERT has achieved the best performance to identify the target questions that cover true user intents. It outperforms the best baselines significantly regarding almost all the metrics.
Note that the evaluation is based on 8,962 conversations and 8,200 of them have the same first negative question in the enlarged data so all the models can refine the question selection only from the second question for most conversations. This limits the improvements of MMR-BERT over the baselines. However, the improvements on about nine thousand data points are significant.
Word-based methods (QL and SingleNeg) are inferior to the other neural methods by a large margin. Also, SingleNeg hardly improves upon QL, indicating that word-based topic modeling methods are not effective to incorporate negative feedback in clarifying question selection, probably due to insufficient words to build topic models. The BERT-based methods using the feedback information can identify the first target questions earlier than BERT-INIT and MBERT-INIT.
With the similarity function provided by BERT-INIT, MMR can outperform BERT-INIT. The ability of BERT models to measure semantic similarity is essential for the MMR principle to be effective.
Moreover, while BERT-NeuQS and BERT-GT improve the metrics regarding label 2, their performance regarding questions with label 1 is harmed. BERT-NeuQS concatenates the topic representation with the average representations of each q-a pair and BERT-GT encode the sequence of the conversation history ($t,(q_1,a_1),\cdots, (q_{|h|},a_{|h|})$) as a whole. Thus it could be difficult for them to figure out which part a candidate question should be similar to and which part not. By matching a candidate question with the topic and each historical question individually, MMR-BERT can balance the similarity to the topic and dissimilarity to the historical questions better.
\begin{figure}
\includegraphics[width=0.4\textwidth]{figures/succ_conv_turns.pdf} %
\caption{Comparison of MMR-BERT and baselines in terms of the cumulative number of success conversations at each turn on the intent clarification task.}
\label{fig:succ_conv_turns}
\end{figure}
\textbf{Number of Success Conversations.}
Figure \ref{fig:succ_conv_turns} shows the cumulative number of success conversations of each method that correctly identifies user intents at the third, fourth, and fifth turns.
We focus more on how to leverage the negative feedback in the conversation so far rather than how to ask the first clarifying question without feedback information. As shown in the figure, among all the 8,962 conversations, MMR-BERT identifies user intents in 41.2\%, 52.2\%, and 59.2\% conversations by asking at most 3, 4, and 5 clarifying questions. The best baseline at each turn is different while MMR-BERT always has the overall best performance across various turns. This indicates that our MMR-BERT can leverage negative feedback more effectively than the baselines in identifying user intents.
\textbf{Impact of Topic Type.}
In Figure \ref{fig:mrr_topic_type}, we study how MMR-BERT performs on queries of different types compared with other methods. As we mentioned in Section \ref{subsec:data}, query topics in Qulac are faceted or ambiguous. An example of a faceted query is ``elliptical trainer'', which has the facets such as ``What are the benefits of an elliptical trainer compared to other fitness machines?'', ``where can I buy a used or discounted elliptical trainer?'', ``What are the best elliptical trainers for home use?'' and ``I'm looking for reviews of elliptical machines.'' An ambiguous query is a query that has multiple meanings, e.g., ``memory'', which can refer to human memory, computer memory, and the board game named as memory. From Figure \ref{fig:mrr_topic_type}, we have two major observations:
1) All the methods perform better on faceted queries than on ambiguous queries.
Since QL performs worse on ambiguous queries than on faceted queries by a large margin, the performance of other methods is limited by the quality of initial candidate clarifying questions retrieved by QL. It also indicates that questions for ambiguous queries in the corpus have less word matching than faceted queries.
2) The improvements of MMR-BERT over other methods are much larger on ambiguous queries than on faceted queries. It is essential to differentiate the semantic meanings of various clarifying questions relevant to the same query when leveraging the negative feedback. Clarifying questions of a faceted query are usually about subtopics under the small space of the query topic and the words co-occurring with the query in each subtopic have much overlap. Again for the ``elliptical trainer'' example, the latter associated 3 intents are all related to the purchase need, and the words such as ``buy'', ``best'', and ``reviews'' can co-occur often in the corpus. Thus it is difficult to differentiate these questions even for BERT-based models. In contrast, clarifying questions corresponding to each meaning of an ambiguous query usually consist of different sets of context words, e.g., human memory can have ``memory loss'' and ``brain'' in the related texts while computer memory always co-occurs with ``disk'', ``motherboard'', etc.
As BERT has seen various contexts in a huge corpus during pre-training, they have better capabilities to differentiate the meanings of an ambiguous query compared to the subtopics of a faceted query. However, BERT-NeuQS and BERT-GT cannot fully take advantage of BERT's ability to differentiate semantic meanings due to their architecture, either averaging the representations of historical questions or encoding the sequence of query and the asked questions.
\begin{figure}
\includegraphics[width=0.35\textwidth]{figures/mrr_by_topic_type.pdf} %
\caption{MRR of each method in the intent clarification task in terms of topic type. }
\label{fig:mrr_topic_type}
\end{figure}
\textbf{Impact of Facet Type.}
We compare each method in terms of their performance on different types of intent facets in Figure \ref{fig:mrr_facet_type}. Similar to the varied performance in terms of topic type, QL performs worse on navigational facets than on informational facets. The clarifying questions that ask about navigational intents sometimes do not match any of the query words such as ``are you looking for a specific web site?'' and ``any specific company on your mind?'' In such cases, the target questions are not included in the candidate pool for re-ranking, which leads to inferior performance on navigational queries.
In addition, we find that neural methods perform worse than word-matching-based methods on navigational queries. Questions that ask about navigational intents are usually in the format of ``do you need any specific web page about X (query)?'' rather than the typical format of questions about informational intents such as ``are you interested in Y (subtopics) of X (query)?'' Also, navigational facets are much fewer than informational facets (185 versus 577), which leads to a smaller amount of questions about navigational facets. The supervised neural models tend to promote questions asking about informational intents during re-ranking since they are semantically more similar to the query (talking about their subtopics) and they are more likely to be relevant in the training data. In contrast, word-matching-based methods treat navigational and informational questions similarly since they both hit query words and have similar length. By selecting the next question different from previous questions and relevant to the query, MMR-BERT does not demote questions about navigational facets and does not harm the performance on navigational facets.
\begin{figure}
\includegraphics[width=0.35\textwidth]{figures/mrr_by_facet_type.pdf} %
\caption{MRR of each method in the intent clarification task in terms of facet type. }
\label{fig:mrr_facet_type}
\end{figure}
\subsection{Document Retrieval Performance}
\label{subsec:conv_doc_perf}
\begin{table}
\centering
\caption{Document retrieval performance with conversations composed by each model. The best baseline results are marked with `*', and the statistically significant improvements over them are marked with`$\dagger$'.}
\scalebox{0.96}{
\begin{tabular}{l|l|l|l|l|l}
\hline
Model & MMR & P1 & NDCG1 & NDCG5 & NDCG20 \\
\hline
OriginalQuery & 0.267 & 0.181 & 0.121 & 0.128 & 0.131 \\
\hline
QL & 0.292 & 0.209 & 0.146 & 0.142 & 0.141 \\
BERT-INIT & 0.299 & 0.210* & 0.145 & 0.143 & 0.143 \\
MBERT-INIT & 0.298 & 0.209 & 0.143 & 0.142 & 0.144* \\
\hline
SingleNeg & 0.292 & 0.209 & 0.147* & 0.142 & 0.141 \\
MMR & 0.301* & 0.210* & 0.143 & 0.143 & 0.144* \\
BERT-NeuQS & 0.296 & 0.209 & 0.145 & 0.145* & 0.142 \\
BERT-GT & 0.294 & 0.206 & 0.141 & 0.145* & 0.143 \\
\hline
MMR-BERT & \textbf{0.306$^{\dagger}$} & \textbf{0.217$^{\dagger}$} & \textbf{0.151$^{\dagger}$} & \textbf{0.146} & \textbf{0.146$^{\dagger}$} \\
\hline
\end{tabular}
}
\label{tab:doc_results}
\end{table}
\begin{figure}
\includegraphics[width=0.35\textwidth]{figures/doc_turns_mrr.pdf} %
\caption{MRR at each turn on document retrieval. }
\label{fig:doc_turns_mrr}
\end{figure}
\label{subsec:doc_results}
Table \ref{tab:doc_results} and Figure \ref{fig:doc_turns_mrr} show the document retrieval performance of using the original query alone and using the conversations produced by each method. In Table \ref{tab:doc_results}, we observe that all the question selection methods can promote relevant documents significantly by asking clarifying questions. The questions asked by MMR-BERT achieve the best document retrieval performance, indicating that our model can find users' target information at higher positions by identifying user intents better.
Since the model for document retrieval is a simple word-based model, the advantage of asking correct questions may not be reflected in retrieving documents. The cases in Section \ref{subsec:cq_doc_mrr_case} show this point. Also, as mentioned in Section \ref{subsec:tech}, the methods can ask at most 5 questions when they cannot identify user intents. These questions could have more supplementary information than BERT-MMR in finding relevant documents if they are of label 1. Nonetheless,
MMR-BERT still achieves significant improvements on 8,962 conversations.
Figure \ref{fig:doc_turns_mrr} confirms the advantage of MMR-BERT by showing that it can retrieve documents relevant to user needs better at earlier turns as well. With more interactions allowed, MMR-BERT can identify more true user intents and thus achieve better document retrieval performance.
Among the baselines that select questions using negative feedback, MMR has the best evaluation results most of the time, probably due to its better overall performance in intent clarification, shown in Table \ref{tab:cq_results}. It boosts questions with label 2 without harming the performance of questions with label 1. Using revised QL for document retrieval, questions of label 1 can also be more helpful than a non-relevant question.
\begin{table*}
\centering
\footnotesize
\caption{Good and bad cases of MMR-BERT compared with the best baseline - BERT-GT in terms of their MRR differences($\Delta$MRR of CQ) in the intent clarification task. The maximal number of conversation turns is 5. $\Delta$MRR of Doc denotes the MRR difference of the associated document retrieval task after the conversation. Queries are shown in the format of \textit{query(facet description); topic type; facet type}. } %
\scalebox{0.935}{
\begin{tabular}{l|l|p{2.2cm}}
\hline
\multicolumn{3}{c}{Query: ``\textbf{diversity}''(``\textbf{How is workplace diversity achieved and managed}?''); \textbf{faceted}; \textbf{informational}} \\
\hline
\multirow{5}{*}{BERT-GT}
& are you looking for a definition of diversity? no & \multirow{7}{*}{\parbox{2.2cm}{$\Delta$MRR of CQ: +0.500 $\Delta$MRR of Doc: +0.667}} \\
& would you like the legal definition of diversity? no & \\
& would you like to know how diversity helps or harms an organization? no & \\
& do you need the definition of diversity? no & \\
& would you like to see results about diversity in a business setting? no & \\
\cline{1-2}
\multirow{2}{*}{MMR-BERT}
& are you looking for a definition of diversity? no \\
& are you looking for educational materials about diversity? yes, i need materials on achieving workplace diversity \\
\hline
\multicolumn{3}{c}{Query: \textbf{``flushing''}(``\textbf{Find information about Flushing, a neighborhood in New York City.}''); \textbf{ambiguous}; \textbf{informational} } \\
\hline
\multirow{5}{*}{BERT-GT}
& would you like to see diagrams of how a toilet flushes? no & \multirow{7}{*}{\parbox{2.2cm}{$\Delta$MRR of CQ: +0.500 $\Delta$MRR of Doc: +0.005}}\\
& would you like to know about the plumbing mechanisms of flushing? no \\
& what aspect of the flushing remonstrance would you like to learn more about? no \\%this is not what i want \\
& which battle would you like to learn about how the technique of flushing was used? no \\% it's not what i want \\
& what flushing are you interested in toilet or facial? no \\%this is not what i want \\
\cline{1-2}
\multirow{2}{*}{MMR-BERT}
& would you like to see diagrams of how a toilet flushes? no \\
& are you referring to flushing new york? yes \\
\hline
\multicolumn{3}{c}{Query: ``\textbf{the sun}''(``\textbf{Find the homepage for the U.K. newspaper, The Sun.}''); \textbf{ambiguous}; \textbf{navigational}} \\
\hline
\multirow{5}{*}{BERT-GT}
& are you interested in the suns size? no & \multirow{7}{*}{\parbox{2.2cm}{$\Delta$MRR of CQ: +0.500 $\Delta$MRR of Doc: +0.000}} \\
& are you interested in objects orbiting the sun? no \\
& do you want to know how far the sun is away from different planets? no \\
& are you looking for information about how big the sun is? no \\
& do you want to know facts about the sun? no \\
\cline{1-2}
\multirow{2}{*}{MMR-BERT}
& are you interested in the suns size? no \\
& are you looking for the news paper the sun? yes, the uk newspaper \\
\hline
\hline
\multicolumn{3}{c}{Query: ``\textbf{raised gardens}''(``\textbf{Find photos of raised garden beds.}''); \textbf{faceted}; \textbf{navigational}} \\
\hline
\multirow{2}{*}{BERT-GT}
& do you need information in different types that can be made? no & \multirow{7}{*}{\parbox{2.2cm}{$\Delta$MRR of CQ: -0.500 $\Delta$MRR of Doc: -0.166}}\\
& is your request related to raised garden beds? yes, find pictures of it \\
\cline{1-2}
\multirow{5}{*}{MMR-BERT}
& do you need information in different types that can be made? no \\
& what specific supply would you like to buy for your raised garden? no \\%, i don't want to buy supplies \\
& do you want to take a class about raised gardens? no \\
& do you want to buy a book about raised? no \\
& do you want to know how to create a raised garden? no \\
\hline
\multicolumn{3}{c}{Query: ``\textbf{rice}''(``\textbf{Find recipes for rice, for example fried rice or rice pudding.}''); \textbf{ambiguous}; \textbf{informational} } \\
\hline
\multirow{2}{*}{BERT-GT}
& are you looking for a specific type of rice? no & \multirow{7}{*}{\parbox{2.2cm}{$\Delta$MRR of CQ: -0.500 $\Delta$MRR of Doc: -0.000}}\\
& are you looking for recipes that include rice? yes, i want recipes for rice \\
\cline{1-2}
\multirow{5}{*}{MMR-BERT}
& are you looking for a specific type of rice? no \\
& are you looking for rice university? no \\
& do you want to know the nutritional content of rice? no \\
& are you referring to a person named rice? no \\
& what type of rice dish are you looking? no \\
\hline
\multicolumn{3}{c}{Query: ``\textbf{flushing}''(``\textbf{Find a street map of Flushing, NY.}''); \textbf{ambiguous}; \textbf{navigational}} \\
\hline
\multirow{2}{*}{BERT-GT}
& would you like directions to flushing new york? no & \multirow{7}{*}{\parbox{2.2cm}{$\Delta$MRR of CQ: -0.500 $\Delta$MRR of Doc: -0.167}}\\
& are you referring to flushing new york? yes, exactly \\
\cline{1-2}
\multirow{5}{*}{MMR-BERT}
& would you like directions to flushing new york? no \\
& would you like to know about the plumbing mechanisms of flushing? no \\
& do you want to know why your face is flushing? no \\
& are you looking for a directions to the new york hall of science in flushing meadows corona park? no \\
& which battle would you like to learn about how the technique of flushing was used? no \\% , this is not what i want \\
\hline
\end{tabular}
}
\label{tab:mmr_bert_cases}
\end{table*}
\subsection{Case Analysis}
\label{subsec:cq_doc_mrr_case}
We extract some representative successful and failure cases of MMR-BERT compared with the best baseline - BERT-GT in terms of MRR in the intent clarification task, shown in Table \ref{tab:mmr_bert_cases}. We include conversations of faceted and ambiguous queries as well as navigational and informational facets for both good and bad cases to show how the models perform on various types of queries and facets. In these cases, MMR-BERT and BERT-GT have the same initial clarifying questions with negative feedback. These cases show how MMR-BERT and BERT-GT select the next question based on the same previous negative feedback.
\textbf{Success Cases.}
MMR-BERT identifies the correct user intent by selecting questions that are relevant to the query while different from previous questions with negative feedback. In contrast, BERT-GT tends to select questions that are similar to both the query and the previous questions. For the example query ``diversity'', the initial clarifying question asks whether the intent is to find the definition of diversity. MRR-BERT asks the user whether he/she needs the educational materials about diversity in the second turn. However, BERT-GT still asks questions about the definition of diversity twice in the following four turns. For the ambiguous query ``flushing'', given negative feedback on the first question about toilet flushing, MMR-BERT asks about Flushing in New York in the next question while BERT-GT still asks about the flushing of the same meaning in the second question. For another ambiguous query ``the sun'', the first clarifying question is about sun size. Based on the negative response, MMR-BERT asks about another meaning of the sun - the newspaper named as the sun. In contrast, the next four questions BERT-GT asks are all about the sun as a star, and the question in the fourth turn is again about the size of the sun. Improvements in identifying the correct clarifying questions can lead to better performance in the associated document retrieval task but it is not always the case probably due to the simplicity of the document retrieval model.
\textbf{Failure Cases.}
The questions asked by MMR-BERT in each conversation are more diverse and tend to cover more intents. However, the questions that receive positive feedback sometimes are more semantically similar to the questions with negative feedback than the other questions. In such cases, MMR-BERT fails to identify the correct intents within fewer conversation turns by asking diverse questions. For the faceted query ``raised gardens'' with intent ``find photos of raised garden beds'', the initial question does not include any query words, so emphasizing the difference from this question is not helpful and could even be harmful to select next question by introducing noise. For the ambiguous query ``rice'', the first question asking whether the user wants a specific type of rice receives a negative response. In the following conversations, MMR-BERT asks about other meanings of rice such as Rice University and a person named Rice. BERT-GT selects the question that is also related to the meaning of rice as food in the next turn. Although referring to the same meaning, the aspect of the recipe is the true user intent. Similarly, for the query ``flushing'', while the user wants the street map of Flushing New York, the question that asks about the direction to Flushing New York receives negative feedback. MMR-BERT selects questions about other meanings of flushing in the next several turns including the mechanism or technique, face flushing, and Flushing meadows corona park. However, the true intent is another facet of the same meaning. These cases argue for other strategies to ask questions such as clarifying meanings for ambiguous queries first and then asking about the subtopics under the correct meaning. We leave this study as future work. The performance of MMR-BERT in these cases in the associated document retrieval task sometimes is not always worse than BERT-GT, due to some useful information contained in the conversations even though the questions do not receive positive feedback.
\section{Introduction}
\label{sec:introduction}
In traditional Web search, users with complex information needs often need to look through multiple pages or reformulate queries to find their target information. In recent years, intelligent assistants such as Google Now, Apple Siri, or Microsoft Cortana make it possible for the system to interact with users through conversations. By asking questions to clarify ambiguous, faceted, or incomplete queries,
conversational search systems could improve user satisfaction with better search quality. Thus, how to ask clarifying questions has become an important research topic.
There are two typical types of clarifying questions: \textit{special questions} beginning with what/why/how etc. and \textit{general (yes/no) questions} that can be answered with ``yes'' or ``no''. Special questions often let a user give specific information about a query such as ``What do you want to know about COVID-19?'' for the user query ``COVID-19''. This kind of question is usually more difficult and requires more user effort to answer than questions such as ``Do you want to know the symptoms of COVID-19?'' With an explicit option in the question, users can easily confirm or deny by saying ``yes'' or ``no''.
In addition to requiring less effort from users, yes/no clarifying questions make it easier for the system to decide when to show text retrieval results. Users' affirmative answers could enhance the system's confidence in the text retrieval performance.
\begin{figure}
\includegraphics[width=0.35\textwidth]{figures/neg_conv_flow.pdf} %
\caption{A workflow of the intent clarification task. }
\label{fig:neg_cq_conv_flow}
\end{figure}
Given these observations, we propose an intent clarification task based on yes/no questions where the target of the system is to select the correct questions about user intent within the fewest conversation turns, shown in Figure \ref{fig:neg_cq_conv_flow}. After the user issues an initial query, the system asks yes/no clarifying questions to the user. When the user provides negative feedback, the system asks another question to confirm the user's intent.
When the intent is confirmed or the limit of conversation turns is reached\footnote{Because it is impractical to ask unlimited number of questions to users, it is common for conversational search systems to set a limit to the number of asked questions.}, the system returns the results of document retrieval.
In the intent clarification task, it is essential to leverage negative feedback about the previously asked questions in the conversation history effectively to select the next question. The principle of using negative feedback is to find a candidate that is dissimilar to the negative results while keeping it relevant to the query. In Web search, documents with negative judgments have limited impact on identifying relevant results due to the large number of potential non-relevant results \cite{wang2007improve, wang2008study, karimzadehgan2011improving}. In contrast, the intent space of a query is much smaller, providing more opportunity to leverage negative feedback from previous clarifying questions.
In this paper, we train an initial model to select the first clarifying question based on the original query.
Then we propose a maximum-marginal-relevance (MMR) based BERT model (MMR-BERT) to leverage negative feedback in the conversation history for the next clarifying question selection.
Experiments on the Qulac \cite{aliannejadi2019asking} dataset show that MMR-BERT outperforms the state-of-the-art baselines significantly on the intent clarification task and the selected questions also achieve significantly better performance in the associated document retrieval tasks.
We then give a detailed analysis of each method's number of success conversations, the impact of topic/facet type on each model, and the success/failure cases of our model compared to the best baseline.
\section{Experimental Setup}
\label{sec:experiments}
This section introduces the data we use for experiments, how we evaluate the proposed models, the competing methods for comparison, and the technical details in the experiments.
\subsection{Data}
\label{subsec:data}
We use Qulac \cite{aliannejadi2019asking} for experiments. As far as we know, it is the only dataset with mostly yes/no clarifying questions in information-seeking conversations. Qulac uses the topics in the TREC Web Track 2009-2012 \cite{clarke2009overview, clarke2012overview} as initial user queries. These topics are either ``ambiguous'' or ``faceted'' and are originally designed for the task of search result diversification.
For each topic, Qulac has collected multiple clarifying questions for each facet (or intent) of the topic through crowd-sourcing; then for each facet of the topic, Qulac obtained the answers to all the questions of the topic from the annotators. The relevance judgments of documents regarding each topic-facet are inherited from the TREC Web track.
We refined Qulac for the intent clarification task by assigning labels 2 or 1 to the questions that receive positive or negative feedback in the answers and label 0 to questions not associated with the topic.
Many negative answers in Qulac also include the user's true intent, such as ``No. I want to know B.'' to the question ``Do you want to know A?''.
It is too optimistic to assume users always provide true intents in their answers. Also, in that case, negative feedback does not have difference from positive feedback or is even better.
To test how the models performs at incorporating negative feedback alone, we ignore the supplementary information and only keep ``no'' as user answers.
For questions that are not yes/no questions, we consider the answers are negative feedback.
To check whether a model can clarify user intents based on the negative feedback in the conversation history more sufficiently, we enlarge the dataset by including all the questions with label 1 as a 1-turn conversation for each topic-facet. In other words, besides letting the model select the first question, we also enumerate all the questions with label 1 as the first question to check how a model performs under various contexts. The original Qulac enumerates all the questions associated with a query to construct conversations of 1 to 3 turns and only select 1 more question based on the pre-constructed static conversation history. While we also enlarge the data similarly, we only construct conversations with 1 turn, and select questions based on previously selected questions.
The resulting data has 8,962 conversations in total, including 762 conversations of 0-turn (only initial query) and 8,200 1-turn (the added conversations). With the enlarged data, we have many more conversations with various contexts as feedback to test the models and to establish the effectiveness of the results. The statistics are shown in Table \ref{tab:statistics}.
\begin{table}
\centering
\small
\caption{Statistics of our revised version of Qulac.}
\scalebox{0.9}{
\begin{tabular}{l l}
\hline
\# topics & 198 \\
\# faceted/ambiguous topics & 141/57 \\
\hline
\# facets & 762 \\
Average/Median facet per topic & 3.85$\pm$1.05/4 \\
\# informational/navigational facets & 577/185 \\
\hline
\# questions/question-answer pairs & 2,639/10,277 \\
\# \textit{question with positive answers} & \textit{2,007} \\
Average words per question/answer & 9.49$\pm$2.53/8.21$\pm$4.42 \\
\hline
\# \textit{expanded conversations} & \textit{8,962} \\
\# conversations starting with 0/1 turns & 762/8,200 \\
\hline
\end{tabular}
}
\label{tab:statistics}
\end{table}
\subsection{Evaluation}
\label{subsec:evaluation}
We evaluate the models on two tasks: 1) the proposed intent clarification task to see whether it can ask the questions covering the true user intent within fewer conversation turns; 2) the associated document retrieval task to see whether the asked clarifying questions can improve the document retrieval performance. Following \cite{aliannejadi2019asking, hashemi2020guided}, we use 5-fold cross-validation for evaluation. We split the topics to each fold according to their id modulo 5. Three folds are used for training, one fold for validation, and one fold for testing. For the question ranking task, we use Query Likelihood (QL) \cite{ponte1998language} to retrieve an initial set of candidates and conduct re-ranking with BERT-based models. For the document retrieval task, as in \cite{aliannejadi2019asking, hashemi2020guided}, we use the revised QL model for retrieval: replacing the original query language model with a convex combination of the language models of the initial query ($t$) and all the question-answer pairs in the conversation ($h$).
For the intent clarification task, we \textit{concatenate the question asked in each conversation turn as a ranking list} for evaluation.
The primary evaluation metric is MRR calculated based on questions with label 2, which indicates \textbf{the number of turns} a model needs to identify true user intent. We also include NDCG@3 and NDCG@5 based on labels 2 and 0 to show how a model identifies the target questions in the first 3 or 5 interactions.
To evaluate the overall quality of the clarifying questions, we also use NDCG@3 and NDCG@5 computed using the multi-grade labels 2, 1, and 0 as metrics. These metrics also give rewards to the questions that receive negative feedback from users but are still relevant to the topic.
We exclude NDCG@1 since the focus of the evaluation is to see how a model leverages the negative feedback in the context, whereas the first question is ranked based on only the original query. Also, the initial question in most of the conversations is with label 1 in the enlarged dataset regardless of the model used.
For the document retrieval task, we use MRR, Precision(P)@1, NDCG@1, 5, and 20 as the evaluation metrics.
MRR measures the position of the first relevant documents. NDCG@1, 5, and 20 indicate the performance based on 5-level labels (0-4) at different positions.
Fisher random test \cite{smucker2007comparison} with $p<0.05$ is used to measure statistical significance for both tasks.
\subsection{Baselines}
\label{subsec:baseline}
We include seven representative baselines to select questions and compare their performance to MMR-BERT on both the intent clarification task and the associated document retrieval task:
\textbf{QL}: The Query Likelihood \cite{ponte1998language} (QL) model is a term-based retrieval model that ranks candidates by the likelihood of a query generated from a candidate, also serving to collect initial candidates.
\textbf{BERT-INIT}: A BERT-based model trained with label 1 and 0 in Section \ref{subsec:init_retrieval}.
\textbf{MBERT-INIT}: A BERT-based model trained with label 2, 1 and 0 as mentioned in Section \ref{subsec:init_retrieval}.
\textbf{SingleNeg}\cite{karimzadehgan2011improving}: A negative feedback method that extracts a single negative topic model from the mixture with the language model of background corpus built with the non-relevant results.
\textbf{MMR}: The Maximal Marginal Relevance (MMR) model \cite{carbonell1998use} ranks questions according to the original MMR equation proposed for search diversification as \begin{equation}
\label{eq:mmr}
\arg max_{q\in Q \setminus Q_h} \lambda f(t,q) - (1-\lambda) max_{q'\in Q_h}f(q', q),
\end{equation}
where we set $f(.,.) = sigmoid(\text{BERT-INIT}(.,.))$ to measure similarity, and $0\leq\lambda\leq1$ is a hyper-parameter.
\textbf{BERT-NeuQS}: BERT-NeuQS \cite{ai2018learning} uses the \textit{average BERT representations of questions and answers in each historical conversation turn} as well as features from query performance prediction (QPP) for next clarifying question selection. To see the effect of model architecture alone, we did not include the QPP features.
\textbf{BERT-GT}: The Guided Transformer model (BERT-GT) \cite{hashemi2020guided} encodes conversation history by inputting \textit{the concatenated sequence of a topic (query), clarifying questions and answers in the history} to a BERT model, guided by top-retrieved questions or documents to select next clarifying question.
QL, BERT-INIT, and MBERT-INIT only use the initial query for ranking while the other models also consider the conversation history. SingleNeg and MMR are based on heuristics. BERT-NeuQS and BERT-GT are state-of-the-art neural models for clarifying question selection.
We discard the numbers of other negative feedback methods such as MultiNeg \cite{karimzadehgan2011improving} and Rocchio \cite{rocchio1971relevance} due to their inferior performance.
BERT-NeuQS uses the query performance prediction scores of a candidate question for document retrieval to enrich the question representation. Our model significantly outperforms BERT-NeuQS if we also add this information. However, since we focus on studying which method is better at leveraging the negative feedback, for fair comparisons, we do not include this part for both BERT-NeuQS and our model. BERT-GT works better with questions than documents in our experiments so we only report the setting with questions. MMR-BERT uses the first question from BERT-INIT as its initial question.
\subsection{Technical Details}
\label{subsec:tech}
We first fine-tuned the ``bert-base-uncased'' version of BERT \footnote{\url{https://github.com/huggingface/transformers}} using our local documents with 3 epochs. Then we fine-tuned BERT-INIT with 5 epochs allowing all the parameters to be updated. All the other BERT-based models loaded the parameters of the trained BERT-INIT and fixed the parameters in the transformer encoder layers during training. This is because the tremendous amount of parameters in the BERT encoders can easily overwhelm the remaining parameters in different models on the data at Qulac's scale, which makes the model performance unstable. The variance of model performance is huge in multiple runs if we let all the parameters free, which leads to unconvincing comparisons.
The limit of conversation turns $k$ was set to 5.
We optimized these models with the Adam \cite{kingma2014adam} optimizer and learning rate 0.0005 for 10 epochs. The number of MLP layers that have output dimension 1 was set from $\{1,2\}$. The dimension of the hidden layer of the 2-layer MLPs was selected from $\{4,8,16,32\}$. $\lambda$ in Equation \eqref{eq:mmr} and the query weight in SingleNeg were scanned from 0.8 to 0.99. Feedback term count in SingleNeg was chosen from $\{10,20,30\}$. Top 10 questions were used in BERT-GT. The coefficient to balance the weight of initial query and conversation history in the document retrieval model was scanned from 0 to 1 for each method.
\section{Conclusion}
In this paper, we propose an intent clarification task based on yes/no clarifying questions in information-seeking conversations. The task's goal is to ask questions that can uncover the true user intent behind an ambiguous or faced query within the fewest conversation turns.
We propose a maximal-marginal-relevance-based BERT model (MMR-BERT) that leverages the negative feedback to the previous questions using the MMR principle.
Experimental results on the refined Qulac dataset show that MMR-BERT has significantly better performance than the competing question selection models in both the intent identification task and the associated document retrieval task.
For future work, we plan to evaluate the effect of the asked clarifying questions on the associated document retrieval task with neural document retrieval models. We are also interested in studying how to effectively use negative feedback on the clarifying questions in the document retrieval model.
\begin{acks}
This work was supported in part by the Center for Intelligent Information Retrieval and in part by NSF IIS-1715095. Any opinions, findings and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect those of the sponsor.
\end{acks}
\section{Experimental Setup}
\label{sec:experiments}
This section introduces the data we use for experiments, how we evaluate the proposed models, the competing methods for comparison, and the technical details in the experiments.
\subsection{Data}
\label{subsec:data}
We use Qulac \cite{aliannejadi2019asking} for experiments. As far as we know, it is the only dataset with mostly yes/no clarifying questions in information-seeking conversations. Qulac uses the topics in the TREC Web Track 2009-2012 \cite{clarke2009overview, clarke2012overview} as initial user queries. These topics are either ``ambiguous'' or ``faceted'' and are originally designed for the task of search result diversification.
For each topic, Qulac has collected multiple clarifying questions for each facet (or intent) of the topic through crowd-sourcing; then for each facet of the topic, Qulac obtained the answers to all the questions of the topic from the annotators. The relevance judgments of documents regarding each topic-facet are inherited from the TREC Web track.
We refined Qulac for the intent clarification task by assigning labels 2 or 1 to the questions that receive positive or negative feedback in the answers and label 0 to questions not associated with the topic.
Many negative answers in Qulac also include the user's true intent, such as ``No. I want to know B.'' to the question ``Do you want to know A?''.
It is too optimistic to assume users always provide true intents in their answers. Also, in that case, negative feedback does not have difference from positive feedback or is even better.
To test how the models performs at incorporating negative feedback alone, we ignore the supplementary information and only keep ``no'' as user answers.
For questions that are not yes/no questions, we consider the answers are negative feedback.
To check whether a model can clarify user intents based on the negative feedback in the conversation history more sufficiently, we enlarge the dataset by including all the questions with label 1 as a 1-turn conversation for each topic-facet. In other words, besides letting the model select the first question, we also enumerate all the questions with label 1 as the first question to check how a model performs under various contexts. The original Qulac enumerates all the questions associated with a query to construct conversations of 1 to 3 turns and only select 1 more question based on the pre-constructed static conversation history. While we also enlarge the data similarly, we only construct conversations with 1 turn, and select questions based on previously selected questions.
The resulting data has 8,962 conversations in total, including 762 conversations of 0-turn (only initial query) and 8,200 1-turn (the added conversations). With the enlarged data, we have many more conversations with various contexts as feedback to test the models and to establish the effectiveness of the results. The statistics are shown in Table \ref{tab:statistics}.
\begin{table}
\centering
\small
\caption{Statistics of our revised version of Qulac.}
\scalebox{0.9}{
\begin{tabular}{l l}
\hline
\# topics & 198 \\
\# faceted/ambiguous topics & 141/57 \\
\hline
\# facets & 762 \\
Average/Median facet per topic & 3.85$\pm$1.05/4 \\
\# informational/navigational facets & 577/185 \\
\hline
\# questions/question-answer pairs & 2,639/10,277 \\
\# \textit{question with positive answers} & \textit{2,007} \\
Average words per question/answer & 9.49$\pm$2.53/8.21$\pm$4.42 \\
\hline
\# \textit{expanded conversations} & \textit{8,962} \\
\# conversations starting with 0/1 turns & 762/8,200 \\
\hline
\end{tabular}
}
\label{tab:statistics}
\end{table}
\subsection{Evaluation}
\label{subsec:evaluation}
We evaluate the models on two tasks: 1) the proposed intent clarification task to see whether it can ask the questions covering the true user intent within fewer conversation turns; 2) the associated document retrieval task to see whether the asked clarifying questions can improve the document retrieval performance. Following \cite{aliannejadi2019asking, hashemi2020guided}, we use 5-fold cross-validation for evaluation. We split the topics to each fold according to their id modulo 5. Three folds are used for training, one fold for validation, and one fold for testing. For the question ranking task, we use Query Likelihood (QL) \cite{ponte1998language} to retrieve an initial set of candidates and conduct re-ranking with BERT-based models. For the document retrieval task, as in \cite{aliannejadi2019asking, hashemi2020guided}, we use the revised QL model for retrieval: replacing the original query language model with a convex combination of the language models of the initial query ($t$) and all the question-answer pairs in the conversation ($h$).
For the intent clarification task, we \textit{concatenate the question asked in each conversation turn as a ranking list} for evaluation.
The primary evaluation metric is MRR calculated based on questions with label 2, which indicates \textbf{the number of turns} a model needs to identify true user intent. We also include NDCG@3 and NDCG@5 based on labels 2 and 0 to show how a model identifies the target questions in the first 3 or 5 interactions.
To evaluate the overall quality of the clarifying questions, we also use NDCG@3 and NDCG@5 computed using the multi-grade labels 2, 1, and 0 as metrics. These metrics also give rewards to the questions that receive negative feedback from users but are still relevant to the topic.
We exclude NDCG@1 since the focus of the evaluation is to see how a model leverages the negative feedback in the context, whereas the first question is ranked based on only the original query. Also, the initial question in most of the conversations is with label 1 in the enlarged dataset regardless of the model used.
For the document retrieval task, we use MRR, Precision(P)@1, NDCG@1, 5, and 20 as the evaluation metrics.
MRR measures the position of the first relevant documents. NDCG@1, 5, and 20 indicate the performance based on 5-level labels (0-4) at different positions.
Fisher random test \cite{smucker2007comparison} with $p<0.05$ is used to measure statistical significance for both tasks.
\subsection{Baselines}
\label{subsec:baseline}
We include seven representative baselines to select questions and compare their performance to MMR-BERT on both the intent clarification task and the associated document retrieval task:
\textbf{QL}: The Query Likelihood \cite{ponte1998language} (QL) model is a term-based retrieval model that ranks candidates by the likelihood of a query generated from a candidate, also serving to collect initial candidates.
\textbf{BERT-INIT}: A BERT-based model trained with label 1 and 0 in Section \ref{subsec:init_retrieval}.
\textbf{MBERT-INIT}: A BERT-based model trained with label 2, 1 and 0 as mentioned in Section \ref{subsec:init_retrieval}.
\textbf{SingleNeg}\cite{karimzadehgan2011improving}: A negative feedback method that extracts a single negative topic model from the mixture with the language model of background corpus built with the non-relevant results.
\textbf{MMR}: The Maximal Marginal Relevance (MMR) model \cite{carbonell1998use} ranks questions according to the original MMR equation proposed for search diversification as \begin{equation}
\label{eq:mmr}
\arg max_{q\in Q \setminus Q_h} \lambda f(t,q) - (1-\lambda) max_{q'\in Q_h}f(q', q),
\end{equation}
where we set $f(.,.) = sigmoid(\text{BERT-INIT}(.,.))$ to measure similarity, and $0\leq\lambda\leq1$ is a hyper-parameter.
\textbf{BERT-NeuQS}: BERT-NeuQS \cite{ai2018learning} uses the \textit{average BERT representations of questions and answers in each historical conversation turn} as well as features from query performance prediction (QPP) for next clarifying question selection. To see the effect of model architecture alone, we did not include the QPP features.
\textbf{BERT-GT}: The Guided Transformer model (BERT-GT) \cite{hashemi2020guided} encodes conversation history by inputting \textit{the concatenated sequence of a topic (query), clarifying questions and answers in the history} to a BERT model, guided by top-retrieved questions or documents to select next clarifying question.
QL, BERT-INIT, and MBERT-INIT only use the initial query for ranking while the other models also consider the conversation history. SingleNeg and MMR are based on heuristics. BERT-NeuQS and BERT-GT are state-of-the-art neural models for clarifying question selection.
We discard the numbers of other negative feedback methods such as MultiNeg \cite{karimzadehgan2011improving} and Rocchio \cite{rocchio1971relevance} due to their inferior performance.
BERT-NeuQS uses the query performance prediction scores of a candidate question for document retrieval to enrich the question representation. Our model significantly outperforms BERT-NeuQS if we also add this information. However, since we focus on studying which method is better at leveraging the negative feedback, for fair comparisons, we do not include this part for both BERT-NeuQS and our model. BERT-GT works better with questions than documents in our experiments so we only report the setting with questions. MMR-BERT uses the first question from BERT-INIT as its initial question.
\subsection{Technical Details}
\label{subsec:tech}
We first fine-tuned the ``bert-base-uncased'' version of BERT \footnote{\url{https://github.com/huggingface/transformers}} using our local documents with 3 epochs. Then we fine-tuned BERT-INIT with 5 epochs allowing all the parameters to be updated. All the other BERT-based models loaded the parameters of the trained BERT-INIT and fixed the parameters in the transformer encoder layers during training. This is because the tremendous amount of parameters in the BERT encoders can easily overwhelm the remaining parameters in different models on the data at Qulac's scale, which makes the model performance unstable. The variance of model performance is huge in multiple runs if we let all the parameters free, which leads to unconvincing comparisons.
The limit of conversation turns $k$ was set to 5.
We optimized these models with the Adam \cite{kingma2014adam} optimizer and learning rate 0.0005 for 10 epochs. The number of MLP layers that have output dimension 1 was set from $\{1,2\}$. The dimension of the hidden layer of the 2-layer MLPs was selected from $\{4,8,16,32\}$. $\lambda$ in Equation \eqref{eq:mmr} and the query weight in SingleNeg were scanned from 0.8 to 0.99. Feedback term count in SingleNeg was chosen from $\{10,20,30\}$. Top 10 questions were used in BERT-GT. The coefficient to balance the weight of initial query and conversation history in the document retrieval model was scanned from 0 to 1 for each method.
\section{Introduction}
\label{sec:introduction}
In traditional Web search, users with complex information needs often need to look through multiple pages or reformulate queries to find their target information. In recent years, intelligent assistants such as Google Now, Apple Siri, or Microsoft Cortana make it possible for the system to interact with users through conversations. By asking questions to clarify ambiguous, faceted, or incomplete queries,
conversational search systems could improve user satisfaction with better search quality. Thus, how to ask clarifying questions has become an important research topic.
There are two typical types of clarifying questions: \textit{special questions} beginning with what/why/how etc. and \textit{general (yes/no) questions} that can be answered with ``yes'' or ``no''. Special questions often let a user give specific information about a query such as ``What do you want to know about COVID-19?'' for the user query ``COVID-19''. This kind of question is usually more difficult and requires more user effort to answer than questions such as ``Do you want to know the symptoms of COVID-19?'' With an explicit option in the question, users can easily confirm or deny by saying ``yes'' or ``no''.
In addition to requiring less effort from users, yes/no clarifying questions make it easier for the system to decide when to show text retrieval results. Users' affirmative answers could enhance the system's confidence in the text retrieval performance.
\begin{figure}
\includegraphics[width=0.35\textwidth]{figures/neg_conv_flow.pdf} %
\caption{A workflow of the intent clarification task. }
\label{fig:neg_cq_conv_flow}
\end{figure}
Given these observations, we propose an intent clarification task based on yes/no questions where the target of the system is to select the correct questions about user intent within the fewest conversation turns, shown in Figure \ref{fig:neg_cq_conv_flow}. After the user issues an initial query, the system asks yes/no clarifying questions to the user. When the user provides negative feedback, the system asks another question to confirm the user's intent.
When the intent is confirmed or the limit of conversation turns is reached\footnote{Because it is impractical to ask unlimited number of questions to users, it is common for conversational search systems to set a limit to the number of asked questions.}, the system returns the results of document retrieval.
In the intent clarification task, it is essential to leverage negative feedback about the previously asked questions in the conversation history effectively to select the next question. The principle of using negative feedback is to find a candidate that is dissimilar to the negative results while keeping it relevant to the query. In Web search, documents with negative judgments have limited impact on identifying relevant results due to the large number of potential non-relevant results \cite{wang2007improve, wang2008study, karimzadehgan2011improving}. In contrast, the intent space of a query is much smaller, providing more opportunity to leverage negative feedback from previous clarifying questions.
In this paper, we train an initial model to select the first clarifying question based on the original query.
Then we propose a maximum-marginal-relevance (MMR) based BERT model (MMR-BERT) to leverage negative feedback in the conversation history for the next clarifying question selection.
Experiments on the Qulac \cite{aliannejadi2019asking} dataset show that MMR-BERT outperforms the state-of-the-art baselines significantly on the intent clarification task and the selected questions also achieve significantly better performance in the associated document retrieval tasks.
We then give a detailed analysis of each method's number of success conversations, the impact of topic/facet type on each model, and the success/failure cases of our model compared to the best baseline.
\section{Conversation Intent Clarification}
\label{sec:methods}
In this section, we first introduce the definition of the conversation intent clarification task. To approach the task, we propose a two-step method to ask clarifying questions in the conversation. We illustrate the model for initial clarifying question selection in Section \ref{subsec:init_retrieval} and the model that selects the next question using negative feedback to previous questions in Section \ref{subsec:cq_negfeedback}.
\begin{figure}
\includegraphics[width=0.5\textwidth]{figures/FeedbackModel.pdf} %
\caption{Our Maximal Marginal Relevance based BERT Model (MMR-BERT). }
\label{fig:mmr-bert}
\end{figure}
\subsection{Task Formulation}
Suppose that a user has a specific information need about an ambiguous or faceted topic $t$. The user issues $t$ as a query to the system \footnote{We use topic and query interchangeably in the paper}. Let $h=((q_1, a_1), (q_2, a_2), \cdots, (q_{|h|}, a_{|h|}))$ be the conversation history between the user and the system, where the system asks the user $|h|$ clarifying questions $Q_h = \{q_i | 1\leq i \leq |h|\}$ about the potential intents behind the topic, and the user confirms or denies the corresponding intent indicated in $q_i$ with $a_i$. For any candidate question $q$, its label $y(q)=2$ if it covers the user's true intent, $y(q)=1$ if it covers other intents of $t$, and $y(q)=0$ if it is not relevant to $t$. The system's target is to identify the user's true intent within the fewest interactions, i.e., $\argmin(|Q^{\bigstar}=\{q|y(q)=2|)$.
Since it is not practical to ask too many questions, the system ends the conversation and returns the document retrieval results whenever the user's intent is confirmed or the limit of conversations turns $k$ ($|h|\leq k$) is reached.
\subsection{First Clarifying Question Selection}
\label{subsec:init_retrieval}
The first clarifying question is especially important to elicit user interactions as it will impact the effectiveness of all the future questions and user interactions.
The information available to select the initial question is the query itself. Thus it is essential to effectively measure the relevance of a candidate question by how it matches the user query.
\textbf{Query-question Matching.}
In recent years, BERT \cite{devlin2018bert} has shown impressive performance in short-text matching tasks by pre-training contextual language models with large external collections and fine-tuning the model based on a local corpus.
We leverage BERT to select questions in the intent clarification task. Specifically, we select the first question based on the relevance score of matching a candidate $q$ to topic $t$ calculated with BERT:
\begin{equation}
\label{eq:init_bert}
s(q,t) = MLP_0(\text{BERT-ENC}(q,t))
\end{equation}
where BERT-ENC$(S_A, S_B)$ is the output vector of matching sentence A ($S_A$) and sentence B ($S_B$) as shown in Figure \ref{fig:mmr-bert}, $MLP_0$ is a multilayer perceptron (MLP) with output dimension 1. Specifically, BERT-ENC$(S_A, S_B)$ inputs the token, segment, and position embeddings of the sequence (\textsl{[CLS], tokens in $S_A$, [SEP], tokens in $S_B$}) to the pre-trained BERT model \cite{devlin2018bert} and take the vector of [CLS] after the transformer encoder layers as output.
\textbf{Loss Function.}
We have two ways of calculating the training loss.
As a first option, assuming that we do not have any prior knowledge about each user's intent, the retrieval of the first question should simply focus on retrieving questions that are relevant to the initial query string $t$.
Thus we collect a set of query pairs $Q^P$ and each pair consists of a relevant and a non-relevant question, i.e., $Q^P=\{(q^+, q^-)| y(q^+)>0, y(q^-)=0 \}$. We consider all the questions with positive labels having the same label 1, i.e., $y'(q) = \mathcal{I}(y(q) > 0)$, where $\mathcal{I}$ is an indicator function and equals to 1 when the input condition is true otherwise it is 0.
The probability of question $q$ in the entry (pair) $E$ ($E\in Q^P$) being relevant to query topic $t$ is calculated with the softmax function:
\begin{equation}
\label{eq:prob}
Prob(y'(q)=1) = \frac{\exp(s(q,t))}{\sum_{q'\in E}\exp(s(q',t))}, E \in Q^P.
\end{equation}
Then the loss function $\mathcal{L}$ is the cross-entropy between the binary question labels $(1,0)$ of the pair and the probability distribution of $(Prob(y'(q^+)=1), Prob(y'(q^-)=1))$:
\begin{equation}
\label{eq:pair_loss}
\mathcal{L}_{\text{BERT-INIT}} = -\sum_{E \in Q^P} \sum_{q \in E} y'(q) \log Prob(y'(q)=1).
\end{equation}
In this case, the loss function is essentially pairwise loss. We refer to the model trained with $Q^P$ as \textit{BERT-INIT}.
Among the relevant questions of the same query, only questions that match user intents can receive positive feedback and have label 2. As a second option, when we further consider which relevant questions are more likely to receive positive feedback in a prior distribution, the multi-grade label of a question can be used for training.
We extend the set of question pairs $Q^P$ to question triplets $Q^T=\{(q^{\bigstar}, q^{*}, q^-)| y(q^{\bigstar})=2, y(q^{*})=1, y(q^-=0)\}$ and still use the cross-entropy loss to optimize the model. In other words, we train the model according to:
\begin{equation}
\label{eq:triplet_loss}
\mathcal{L}_{\text{MBERT-INIT}} = -\sum_{E \in Q^T} \sum_{q \in E} y(q) \log Prob(y(q)>0),
\end{equation}
where $Prob(y(q)>0)$ is calculated based on Equation \eqref{eq:prob} with $Q^P$ replaced by $Q^T$ and $E$ is an entry of triplet.
As in \cite{ai2018learning}, this loss function can be considered as a list-wise loss of the constructed triplets. Since the probability of each question to be a target question is normalized by the scores of all the three questions in the triplet, maximizing the score of question with label 2 will reduce the score of questions with label 1 and 0. Also, questions with larger labels have more impact to the loss. This ensures that the model is optimized to learn higher scores for questions that have larger labels. We refer to this model as \textit{MBERT-INIT}.
\subsection{Clarifying Intents Using Negative Feedback}
\label{subsec:cq_negfeedback}
While the only basis of the system's decision is topic $t$ in the first conversation turn, the system can refer to conversation history in the following interactions. As we assume that the system will terminate the conversation and return the documents when the user confirms the question with positive feedback, all the available information for selecting the next clarifying question besides the topic $t$ is negative feedback. It means that the next question should cover a different intent from previous questions while being relevant to topic $t$.
Inspired by the maximal marginal relevance (MMR) principle in search diversification studies \cite{carbonell1998use}, here we propose an MMR-based BERT model (MMR-BERT) to leverage negative feedback in the conversations.
In search diversification, the basic idea of MMR is to select the next document by maximizing its relevance to the initial query and dissimilarities to previously selected documents.
Similarly, in MMR-BERT, we select the next question by jointly considering the relevance of each candidate question with respect to the initial topic $t$ and their similarities to previous questions.
Let $Q$ be the question candidate set, and $Q_h=\{q_i|1\leq i \leq |h|\}$ be the set of questions in the conversation history $h$.
Let BERT-ENC$(S_A,S_B)$ be a matching function that takes two pieces of text (i.e., $S_A$ and $S_B$) as input and outputs an embedding/feature vector to model their similarities. \footnote{Here we use BERT encoder as our matching model because it has been shown to be effective in modeling the latent semantics of text data, which is important for our task since different facets of the same topic often have subtle semantic differences that cannot be captured by simple methods such as keyword matching.}
As shown in Figure \ref{fig:mmr-bert}, MMR-BERT first obtains the matching of the topic $t$ with candidate question $q$, i.e., BERT-ENC$(t,q)$ and the matching between each previous question $q_i (1\leq i \leq |h|$) and $q$, i.e., BERT-ENC$(q_i, q)$. Then it maps the obtained vectors to lower d-dimension space ($\mathbb{R}^d$) with a multilayer perceptron (MLP) $MLP_1$, where each layer is a feed-forward neural network followed by Rectified Linear Unit (ReLU) activation function. The parameters in $MLP_1$ are shared across multiple matching pairs to let the condensed vectors comparable. Formally, the final matching between $x$ and $q$ is:
\begin{equation}
\label{eq:matching}
\begin{split}
& o(x,q) = MLP_1(\text{BERT-ENC}(x,q)) \in \mathbb{R}^{d} \\
& x=t \text{ or } q_i, 1\leq i \leq |h|
\end{split}
\end{equation}
The final score of $q$ is computed as:
\begin{equation}
\label{eq:mmr-bert}
\!\! \text{MMR-BERT}(q,t,h) \! = \! MLP_2([o(t,q);\!MaxPool_{1\leq i \leq |h|}o(q_i, q)])\!\!
\end{equation}
where $MaxPool$ represents apply max pooling on a group of vectors, $[\cdot;\cdot]$ denotes the concatenation between two vectors, $MLP_2$ is another MLP for projection to $\mathbb{R}^1$.
Given the user's negative feedback to the asked questions in the conversation history $h$, the probability of a candidate $q$ covering user intent is calculated according to:
\begin{equation}
\label{eq:hist_prob}
Prob(y(q)\!=\!2|h) \!= \! \frac{\exp(\text{MMR-BERT}(q,t,h))}{\sum_{q'\in E}\exp(\text{MMR-BERT}(q',t,h))}, E \!\in\! Q^T \!,
\end{equation}
where $Q^T$ is a set of triplets, $E$ is a triplet of questions with label 2, 1, and 0, as in Section \ref{subsec:init_retrieval}.
To differentiate the questions that would receive positive feedback from users and questions that are relevant to the topic $t$ but do not match user intents, we use the multiple-grade labels in the loss function, as MBERT-INIT in Section \ref{subsec:init_retrieval}. Since $Prob(y(q)=2,h)=Prob(y(q)=2|h)Prob(h)$ and $Prob(h)$ is fixed for topic $t$ during training. The loss function is:
\begin{equation}
\label{eq:mmrbert_loss}
\mathcal{L}_{\text{MMR-BERT}} \propto -\sum_{E \in Q^T} \sum_{h \in H(E)} \sum_{q \in E} y(q) \log Prob(y(q)=2|h),
\end{equation}
where $H(E)$ is the history set of conversation turns of length 0, 1, 2, and so on, corresponding to triplet entry $E$. For example, if the questions $q_a$,$q_b$, and $q_c$ are already asked for topic $t$, $H(E)=\{\emptyset, \{q_a\}, \{q_a,q_b\}, \{q_a,q_b,q_c\}\}$. The answers in the history are omitted in the notation since they are all ``no".
In this way, questions that cover similar intents to historically asked questions $Q_h$ have lower labels than the questions that have target intents and thus will be punished.
\textbf{Differences from Other BERT-based Models.}
Most existing BERT-based models for clarifying question selection leverage the topic(query), questions, and answers in the conversation history and do not differentiate answers that are confirmation or denial \cite{aliannejadi2019asking, hashemi2020guided}. In contrast, MMR-BERT is specifically designed to leverage negative feedback from conversation history, which means it uses previously asked questions as input and does not use the answers in the history as they are all denial (we assume that the system would stop asking questions when it has identified the user intent).
From the perspective of model design, existing models typically use average BERT representations of each historical conversation turn \cite{aliannejadi2019asking} or concatenate the sequence of a query, question, and answer in each turn as input to BERT models \cite{hashemi2020guided}. When used in the intent clarification task, these methods either do not differentiate the effect of each asked question or do not consider the effect of the initial query should be modeled differently from the questions with negative feedback. Following the MMR principle, our MMR-BERT model takes the task characteristics into account and thus can more effectively use negative feedback.
\section{Related Work}
There are three threads of work related to our study: conversational search and question answering (QA), asking clarifying questions, and negative feedback.
\textbf{Conversational Search and QA.}
The concept of information retrieval (IR) through man-machine dialog dates back to 1977 \cite{oddy1977information}. Other early work in conversational IR includes an intelligent intermediary for IR, named as I$^3$R, proposed by \citet{croft1987i3r} in 1987, and an interactive IR system using script-based information-seeking dialogues, MERIT, built by \cite{belkin1995cases} in 1995.
In recent years, task-based conversational search based on natural dialogues has drawn much attention. \citet{radlinski2017theoretical} proposed a theoretical framework for conversational IR. \citet{vtyurina2017exploring} studied how users behave when interacting with a human expert, a commercial intelligent assistant, and a human disguised as an automatic system. \citet{spina2017extracting} studied how to extract audio summaries for spoken document search. \citet{trippas2018informing} suggested building conversational search systems based on the commonly-used interactions from human communication.
Most recently, \citet{yang2018response} conducted response ranking based on external knowledge given a conversation history. \citet{wang2021controlling} propose to control the risk of asking non-relevant questions by deciding whether to ask questions or show results in a conversation turn.
Conversational question answering defines the task of finding an answer span in a given passage based on the question and answers in the conversation history such as CoQA \cite{reddy2019coqa} and QuAC \cite{choi2018quac}. \citet{qu2020open} extended the task by introducing a step of retrieving candidate passages for identifying answer span. This is more practical in real scenarios where ground truth passages that contain the answers are often unavailable.
In this paper, we focus on the next clarifying question selection based on negative feedback to identify users' true intent in the fewest conversation turns, which differs from most existing work in conversational search. Also, our intent clarification task is fundamentally different from the objective of conversational QA.
\textbf{Asking Clarifying Questions.}
In the TREC 2004 HARD track \cite{allan2005hard}, systems can ask searchers clarification questions such as whether some titles seem relevant to improve the accuracy of IR.
\citet{rao2018learning} collected a clarifying question dataset from the posts in StackOverflow and proposed to select clarification questions based on the expected value of perfect information considering the usefulness of potential answers to a candidate question. Later, \citet{rao2019answer} extended the work by using the utility \cite{rao2018learning} in a reinforcement learning framework in product QA to handle cases where contexts such as product information and historical questions and answers are available.
\citet{zhang2018towards,sun2018conversational} proposed to ask users questions about their preferred values on aspects of a product for conversational product search and recommendation.
\citet{wang2018learning} observed that a good question is often composed of interrogatives, topic words, and ordinary words and devised typed encoders to consider word types when generating questions.
\citet{cho2019generating} proposed a task of generating common questions from multiple documents for ambiguous user queries. \citet{xu2019asking} studied whether a question needs clarification and introduced a coarse-to-fine model for clarification question generation in knowledge-based QA systems. \citet{zamani2020generating} extracted the facets of a query from query logs and generated clarifying questions through template or reinforcement learning with weak supervision.
To study how to ask clarifying questions in information-seeking conversations, \citet{aliannejadi2019asking} collected clarifying questions through crowd-sourcing in a dataset called Qualc based on the ambiguous or faceted topics in the TREC Web track \cite{clarke2009overview,clarke2012overview}. They proposed to select the next clarifying question based on BERT representations and query performance prediction.
Later, \cite{hashemi2020guided} extended the idea of pseudo relevance feedback and leveraged top-retrieved clarifying questions and documents for document retrieval and next clarifying question selection on Qulac.
\citet{aliannejadi2020convai3} then organized a challenge on clarifying questions for dialogue systems that raises the questions on when to ask clarifying questions during dialogues and how to generate the clarifying questions.
Most existing work evaluates models based on either the initial query or pre-defined conversation history, i.e., the models always select the next question based on static conversation turns instead of its previously selected questions. In contrast, we select the next questions dynamically considering previous questions, which is more practical.
Also, other studies do not differentiate responses that are confirmation or denial. In contrast, we address how to leverage negative feedback in the response.
\textbf{Negative Feedback.}
Existing work on negative feedback has been relatively sparse and mostly focuses on document retrieval for difficult queries. \citet{wang2007improve} proposed to extract a negative topic model from non-relevant documents from its mixture with the language model of the background corpus.
The Rocchio model \cite{rocchio1971relevance} considers both positive and negative feedback and can be used when only negative feedback is available.
\citet{wang2008study} compared various negative feedback methods in the framework of language model or vector space model. Later, \cite{karimzadehgan2011improving} proposed a more general negative topic model that further improved the performance of difficult queries. \citet{peltonen2017negative} designed a novel search interface where users can provide feedback on the keywords of non-relevant results.
Negative feedback has also been studied in recommendation and product search. \citet{zagheli2017negative} proposed a language model based method to avoid recommending texts similar to documents users dislike. \citet{zhao2018recommendations} considered skipped items as negative feedback and used it together with positive feedback to recommend items by trial and error.
\citet{bi2019conversational} leveraged user feedback on finer-grained aspect-value pairs extracted from non-relevant results in conversational product search.
Unlike these studies, we study how to leverage negative feedback to clarifying questions that are much shorter than documents in open-domain information-seeking conversations. Our model is based on pre-trained BERT \cite{devlin2018bert} models and the Max Marginal Relevance (MMR) \cite{carbonell1998use} principle.
\section{Results and Discussion}
\label{sec:results}
Next, we show the experimental results of the clarifying question selection task and the associated document retrieval task. We analyze the model behaviors as well as success and failure cases.
\begin{table}
\centering
\caption{Model performance on intent clarification task evaluated using only label 2 or both label 1 \& 2. `*' indicates the best baseline results, and `$\dagger$' shows the statistically significant improvements over them. }
\scalebox{0.95}{
\begin{tabular}{l||l|l|l||l|l}
\hline
\multirow{2}{*}{Model}
& \multicolumn{3}{c||}{Label 2 only} & \multicolumn{2}{c}{Label 1\&2} \\
\cline{2-6}
& MRR & NDCG3 & NDCG5 & NDCG3 & NDCG5 \\
\hline
QL & 0.216 & 0.130 & 0.159 & 0.514 & 0.565 \\
BERT-INIT & 0.235 & 0.143 & 0.173 & 0.531 & 0.583 \\
MBERT-INIT & 0.235 & 0.144 & 0.173 & 0.532* & 0.584 \\
\hline
SingleNeg & 0.217 & 0.131 & 0.160 & 0.513 & 0.565 \\
MMR & 0.237 & 0.144 & 0.178 & 0.531 & 0.585* \\
BERT-NeuQS & 0.241 & 0.146 & 0.182* & 0.528 & 0.580 \\
BERT-GT & 0.242* & 0.148* & 0.178 & 0.530 & 0.580 \\
\hline
MMR-BERT & \textbf{0.248$^{\dagger}$} & \textbf{0.152$^{\dagger}$} & \textbf{0.189$^{\dagger}$} & \textbf{0.533} & \textbf{0.586$^{\dagger}$} \\
\hline
\end{tabular}
}
\label{tab:cq_results}
\end{table}
\subsection{Clarifying Question Selection Results}
\label{subsec:cq_results}
\textbf{Overall Performance.}
As shown in Table \ref{tab:cq_results}, MMR-BERT has achieved the best performance to identify the target questions that cover true user intents. It outperforms the best baselines significantly regarding almost all the metrics.
Note that the evaluation is based on 8,962 conversations and 8,200 of them have the same first negative question in the enlarged data so all the models can refine the question selection only from the second question for most conversations. This limits the improvements of MMR-BERT over the baselines. However, the improvements on about nine thousand data points are significant.
Word-based methods (QL and SingleNeg) are inferior to the other neural methods by a large margin. Also, SingleNeg hardly improves upon QL, indicating that word-based topic modeling methods are not effective to incorporate negative feedback in clarifying question selection, probably due to insufficient words to build topic models. The BERT-based methods using the feedback information can identify the first target questions earlier than BERT-INIT and MBERT-INIT.
With the similarity function provided by BERT-INIT, MMR can outperform BERT-INIT. The ability of BERT models to measure semantic similarity is essential for the MMR principle to be effective.
Moreover, while BERT-NeuQS and BERT-GT improve the metrics regarding label 2, their performance regarding questions with label 1 is harmed. BERT-NeuQS concatenates the topic representation with the average representations of each q-a pair and BERT-GT encode the sequence of the conversation history ($t,(q_1,a_1),\cdots, (q_{|h|},a_{|h|})$) as a whole. Thus it could be difficult for them to figure out which part a candidate question should be similar to and which part not. By matching a candidate question with the topic and each historical question individually, MMR-BERT can balance the similarity to the topic and dissimilarity to the historical questions better.
\begin{figure}
\includegraphics[width=0.4\textwidth]{figures/succ_conv_turns.pdf} %
\caption{Comparison of MMR-BERT and baselines in terms of the cumulative number of success conversations at each turn on the intent clarification task.}
\label{fig:succ_conv_turns}
\end{figure}
\textbf{Number of Success Conversations.}
Figure \ref{fig:succ_conv_turns} shows the cumulative number of success conversations of each method that correctly identifies user intents at the third, fourth, and fifth turns.
We focus more on how to leverage the negative feedback in the conversation so far rather than how to ask the first clarifying question without feedback information. As shown in the figure, among all the 8,962 conversations, MMR-BERT identifies user intents in 41.2\%, 52.2\%, and 59.2\% conversations by asking at most 3, 4, and 5 clarifying questions. The best baseline at each turn is different while MMR-BERT always has the overall best performance across various turns. This indicates that our MMR-BERT can leverage negative feedback more effectively than the baselines in identifying user intents.
\textbf{Impact of Topic Type.}
In Figure \ref{fig:mrr_topic_type}, we study how MMR-BERT performs on queries of different types compared with other methods. As we mentioned in Section \ref{subsec:data}, query topics in Qulac are faceted or ambiguous. An example of a faceted query is ``elliptical trainer'', which has the facets such as ``What are the benefits of an elliptical trainer compared to other fitness machines?'', ``where can I buy a used or discounted elliptical trainer?'', ``What are the best elliptical trainers for home use?'' and ``I'm looking for reviews of elliptical machines.'' An ambiguous query is a query that has multiple meanings, e.g., ``memory'', which can refer to human memory, computer memory, and the board game named as memory. From Figure \ref{fig:mrr_topic_type}, we have two major observations:
1) All the methods perform better on faceted queries than on ambiguous queries.
Since QL performs worse on ambiguous queries than on faceted queries by a large margin, the performance of other methods is limited by the quality of initial candidate clarifying questions retrieved by QL. It also indicates that questions for ambiguous queries in the corpus have less word matching than faceted queries.
2) The improvements of MMR-BERT over other methods are much larger on ambiguous queries than on faceted queries. It is essential to differentiate the semantic meanings of various clarifying questions relevant to the same query when leveraging the negative feedback. Clarifying questions of a faceted query are usually about subtopics under the small space of the query topic and the words co-occurring with the query in each subtopic have much overlap. Again for the ``elliptical trainer'' example, the latter associated 3 intents are all related to the purchase need, and the words such as ``buy'', ``best'', and ``reviews'' can co-occur often in the corpus. Thus it is difficult to differentiate these questions even for BERT-based models. In contrast, clarifying questions corresponding to each meaning of an ambiguous query usually consist of different sets of context words, e.g., human memory can have ``memory loss'' and ``brain'' in the related texts while computer memory always co-occurs with ``disk'', ``motherboard'', etc.
As BERT has seen various contexts in a huge corpus during pre-training, they have better capabilities to differentiate the meanings of an ambiguous query compared to the subtopics of a faceted query. However, BERT-NeuQS and BERT-GT cannot fully take advantage of BERT's ability to differentiate semantic meanings due to their architecture, either averaging the representations of historical questions or encoding the sequence of query and the asked questions.
\begin{figure}
\includegraphics[width=0.35\textwidth]{figures/mrr_by_topic_type.pdf} %
\caption{MRR of each method in the intent clarification task in terms of topic type. }
\label{fig:mrr_topic_type}
\end{figure}
\textbf{Impact of Facet Type.}
We compare each method in terms of their performance on different types of intent facets in Figure \ref{fig:mrr_facet_type}. Similar to the varied performance in terms of topic type, QL performs worse on navigational facets than on informational facets. The clarifying questions that ask about navigational intents sometimes do not match any of the query words such as ``are you looking for a specific web site?'' and ``any specific company on your mind?'' In such cases, the target questions are not included in the candidate pool for re-ranking, which leads to inferior performance on navigational queries.
In addition, we find that neural methods perform worse than word-matching-based methods on navigational queries. Questions that ask about navigational intents are usually in the format of ``do you need any specific web page about X (query)?'' rather than the typical format of questions about informational intents such as ``are you interested in Y (subtopics) of X (query)?'' Also, navigational facets are much fewer than informational facets (185 versus 577), which leads to a smaller amount of questions about navigational facets. The supervised neural models tend to promote questions asking about informational intents during re-ranking since they are semantically more similar to the query (talking about their subtopics) and they are more likely to be relevant in the training data. In contrast, word-matching-based methods treat navigational and informational questions similarly since they both hit query words and have similar length. By selecting the next question different from previous questions and relevant to the query, MMR-BERT does not demote questions about navigational facets and does not harm the performance on navigational facets.
\begin{figure}
\includegraphics[width=0.35\textwidth]{figures/mrr_by_facet_type.pdf} %
\caption{MRR of each method in the intent clarification task in terms of facet type. }
\label{fig:mrr_facet_type}
\end{figure}
\subsection{Document Retrieval Performance}
\label{subsec:conv_doc_perf}
\begin{table}
\centering
\caption{Document retrieval performance with conversations composed by each model. The best baseline results are marked with `*', and the statistically significant improvements over them are marked with`$\dagger$'.}
\scalebox{0.96}{
\begin{tabular}{l|l|l|l|l|l}
\hline
Model & MMR & P1 & NDCG1 & NDCG5 & NDCG20 \\
\hline
OriginalQuery & 0.267 & 0.181 & 0.121 & 0.128 & 0.131 \\
\hline
QL & 0.292 & 0.209 & 0.146 & 0.142 & 0.141 \\
BERT-INIT & 0.299 & 0.210* & 0.145 & 0.143 & 0.143 \\
MBERT-INIT & 0.298 & 0.209 & 0.143 & 0.142 & 0.144* \\
\hline
SingleNeg & 0.292 & 0.209 & 0.147* & 0.142 & 0.141 \\
MMR & 0.301* & 0.210* & 0.143 & 0.143 & 0.144* \\
BERT-NeuQS & 0.296 & 0.209 & 0.145 & 0.145* & 0.142 \\
BERT-GT & 0.294 & 0.206 & 0.141 & 0.145* & 0.143 \\
\hline
MMR-BERT & \textbf{0.306$^{\dagger}$} & \textbf{0.217$^{\dagger}$} & \textbf{0.151$^{\dagger}$} & \textbf{0.146} & \textbf{0.146$^{\dagger}$} \\
\hline
\end{tabular}
}
\label{tab:doc_results}
\end{table}
\begin{figure}
\includegraphics[width=0.35\textwidth]{figures/doc_turns_mrr.pdf} %
\caption{MRR at each turn on document retrieval. }
\label{fig:doc_turns_mrr}
\end{figure}
\label{subsec:doc_results}
Table \ref{tab:doc_results} and Figure \ref{fig:doc_turns_mrr} show the document retrieval performance of using the original query alone and using the conversations produced by each method. In Table \ref{tab:doc_results}, we observe that all the question selection methods can promote relevant documents significantly by asking clarifying questions. The questions asked by MMR-BERT achieve the best document retrieval performance, indicating that our model can find users' target information at higher positions by identifying user intents better.
Since the model for document retrieval is a simple word-based model, the advantage of asking correct questions may not be reflected in retrieving documents. The cases in Section \ref{subsec:cq_doc_mrr_case} show this point. Also, as mentioned in Section \ref{subsec:tech}, the methods can ask at most 5 questions when they cannot identify user intents. These questions could have more supplementary information than BERT-MMR in finding relevant documents if they are of label 1. Nonetheless,
MMR-BERT still achieves significant improvements on 8,962 conversations.
Figure \ref{fig:doc_turns_mrr} confirms the advantage of MMR-BERT by showing that it can retrieve documents relevant to user needs better at earlier turns as well. With more interactions allowed, MMR-BERT can identify more true user intents and thus achieve better document retrieval performance.
Among the baselines that select questions using negative feedback, MMR has the best evaluation results most of the time, probably due to its better overall performance in intent clarification, shown in Table \ref{tab:cq_results}. It boosts questions with label 2 without harming the performance of questions with label 1. Using revised QL for document retrieval, questions of label 1 can also be more helpful than a non-relevant question.
\begin{table*}
\centering
\footnotesize
\caption{Good and bad cases of MMR-BERT compared with the best baseline - BERT-GT in terms of their MRR differences($\Delta$MRR of CQ) in the intent clarification task. The maximal number of conversation turns is 5. $\Delta$MRR of Doc denotes the MRR difference of the associated document retrieval task after the conversation. Queries are shown in the format of \textit{query(facet description); topic type; facet type}. } %
\scalebox{0.935}{
\begin{tabular}{l|l|p{2.2cm}}
\hline
\multicolumn{3}{c}{Query: ``\textbf{diversity}''(``\textbf{How is workplace diversity achieved and managed}?''); \textbf{faceted}; \textbf{informational}} \\
\hline
\multirow{5}{*}{BERT-GT}
& are you looking for a definition of diversity? no & \multirow{7}{*}{\parbox{2.2cm}{$\Delta$MRR of CQ: +0.500 $\Delta$MRR of Doc: +0.667}} \\
& would you like the legal definition of diversity? no & \\
& would you like to know how diversity helps or harms an organization? no & \\
& do you need the definition of diversity? no & \\
& would you like to see results about diversity in a business setting? no & \\
\cline{1-2}
\multirow{2}{*}{MMR-BERT}
& are you looking for a definition of diversity? no \\
& are you looking for educational materials about diversity? yes, i need materials on achieving workplace diversity \\
\hline
\multicolumn{3}{c}{Query: \textbf{``flushing''}(``\textbf{Find information about Flushing, a neighborhood in New York City.}''); \textbf{ambiguous}; \textbf{informational} } \\
\hline
\multirow{5}{*}{BERT-GT}
& would you like to see diagrams of how a toilet flushes? no & \multirow{7}{*}{\parbox{2.2cm}{$\Delta$MRR of CQ: +0.500 $\Delta$MRR of Doc: +0.005}}\\
& would you like to know about the plumbing mechanisms of flushing? no \\
& what aspect of the flushing remonstrance would you like to learn more about? no \\%this is not what i want \\
& which battle would you like to learn about how the technique of flushing was used? no \\% it's not what i want \\
& what flushing are you interested in toilet or facial? no \\%this is not what i want \\
\cline{1-2}
\multirow{2}{*}{MMR-BERT}
& would you like to see diagrams of how a toilet flushes? no \\
& are you referring to flushing new york? yes \\
\hline
\multicolumn{3}{c}{Query: ``\textbf{the sun}''(``\textbf{Find the homepage for the U.K. newspaper, The Sun.}''); \textbf{ambiguous}; \textbf{navigational}} \\
\hline
\multirow{5}{*}{BERT-GT}
& are you interested in the suns size? no & \multirow{7}{*}{\parbox{2.2cm}{$\Delta$MRR of CQ: +0.500 $\Delta$MRR of Doc: +0.000}} \\
& are you interested in objects orbiting the sun? no \\
& do you want to know how far the sun is away from different planets? no \\
& are you looking for information about how big the sun is? no \\
& do you want to know facts about the sun? no \\
\cline{1-2}
\multirow{2}{*}{MMR-BERT}
& are you interested in the suns size? no \\
& are you looking for the news paper the sun? yes, the uk newspaper \\
\hline
\hline
\multicolumn{3}{c}{Query: ``\textbf{raised gardens}''(``\textbf{Find photos of raised garden beds.}''); \textbf{faceted}; \textbf{navigational}} \\
\hline
\multirow{2}{*}{BERT-GT}
& do you need information in different types that can be made? no & \multirow{7}{*}{\parbox{2.2cm}{$\Delta$MRR of CQ: -0.500 $\Delta$MRR of Doc: -0.166}}\\
& is your request related to raised garden beds? yes, find pictures of it \\
\cline{1-2}
\multirow{5}{*}{MMR-BERT}
& do you need information in different types that can be made? no \\
& what specific supply would you like to buy for your raised garden? no \\%, i don't want to buy supplies \\
& do you want to take a class about raised gardens? no \\
& do you want to buy a book about raised? no \\
& do you want to know how to create a raised garden? no \\
\hline
\multicolumn{3}{c}{Query: ``\textbf{rice}''(``\textbf{Find recipes for rice, for example fried rice or rice pudding.}''); \textbf{ambiguous}; \textbf{informational} } \\
\hline
\multirow{2}{*}{BERT-GT}
& are you looking for a specific type of rice? no & \multirow{7}{*}{\parbox{2.2cm}{$\Delta$MRR of CQ: -0.500 $\Delta$MRR of Doc: -0.000}}\\
& are you looking for recipes that include rice? yes, i want recipes for rice \\
\cline{1-2}
\multirow{5}{*}{MMR-BERT}
& are you looking for a specific type of rice? no \\
& are you looking for rice university? no \\
& do you want to know the nutritional content of rice? no \\
& are you referring to a person named rice? no \\
& what type of rice dish are you looking? no \\
\hline
\multicolumn{3}{c}{Query: ``\textbf{flushing}''(``\textbf{Find a street map of Flushing, NY.}''); \textbf{ambiguous}; \textbf{navigational}} \\
\hline
\multirow{2}{*}{BERT-GT}
& would you like directions to flushing new york? no & \multirow{7}{*}{\parbox{2.2cm}{$\Delta$MRR of CQ: -0.500 $\Delta$MRR of Doc: -0.167}}\\
& are you referring to flushing new york? yes, exactly \\
\cline{1-2}
\multirow{5}{*}{MMR-BERT}
& would you like directions to flushing new york? no \\
& would you like to know about the plumbing mechanisms of flushing? no \\
& do you want to know why your face is flushing? no \\
& are you looking for a directions to the new york hall of science in flushing meadows corona park? no \\
& which battle would you like to learn about how the technique of flushing was used? no \\% , this is not what i want \\
\hline
\end{tabular}
}
\label{tab:mmr_bert_cases}
\end{table*}
\subsection{Case Analysis}
\label{subsec:cq_doc_mrr_case}
We extract some representative successful and failure cases of MMR-BERT compared with the best baseline - BERT-GT in terms of MRR in the intent clarification task, shown in Table \ref{tab:mmr_bert_cases}. We include conversations of faceted and ambiguous queries as well as navigational and informational facets for both good and bad cases to show how the models perform on various types of queries and facets. In these cases, MMR-BERT and BERT-GT have the same initial clarifying questions with negative feedback. These cases show how MMR-BERT and BERT-GT select the next question based on the same previous negative feedback.
\textbf{Success Cases.}
MMR-BERT identifies the correct user intent by selecting questions that are relevant to the query while different from previous questions with negative feedback. In contrast, BERT-GT tends to select questions that are similar to both the query and the previous questions. For the example query ``diversity'', the initial clarifying question asks whether the intent is to find the definition of diversity. MRR-BERT asks the user whether he/she needs the educational materials about diversity in the second turn. However, BERT-GT still asks questions about the definition of diversity twice in the following four turns. For the ambiguous query ``flushing'', given negative feedback on the first question about toilet flushing, MMR-BERT asks about Flushing in New York in the next question while BERT-GT still asks about the flushing of the same meaning in the second question. For another ambiguous query ``the sun'', the first clarifying question is about sun size. Based on the negative response, MMR-BERT asks about another meaning of the sun - the newspaper named as the sun. In contrast, the next four questions BERT-GT asks are all about the sun as a star, and the question in the fourth turn is again about the size of the sun. Improvements in identifying the correct clarifying questions can lead to better performance in the associated document retrieval task but it is not always the case probably due to the simplicity of the document retrieval model.
\textbf{Failure Cases.}
The questions asked by MMR-BERT in each conversation are more diverse and tend to cover more intents. However, the questions that receive positive feedback sometimes are more semantically similar to the questions with negative feedback than the other questions. In such cases, MMR-BERT fails to identify the correct intents within fewer conversation turns by asking diverse questions. For the faceted query ``raised gardens'' with intent ``find photos of raised garden beds'', the initial question does not include any query words, so emphasizing the difference from this question is not helpful and could even be harmful to select next question by introducing noise. For the ambiguous query ``rice'', the first question asking whether the user wants a specific type of rice receives a negative response. In the following conversations, MMR-BERT asks about other meanings of rice such as Rice University and a person named Rice. BERT-GT selects the question that is also related to the meaning of rice as food in the next turn. Although referring to the same meaning, the aspect of the recipe is the true user intent. Similarly, for the query ``flushing'', while the user wants the street map of Flushing New York, the question that asks about the direction to Flushing New York receives negative feedback. MMR-BERT selects questions about other meanings of flushing in the next several turns including the mechanism or technique, face flushing, and Flushing meadows corona park. However, the true intent is another facet of the same meaning. These cases argue for other strategies to ask questions such as clarifying meanings for ambiguous queries first and then asking about the subtopics under the correct meaning. We leave this study as future work. The performance of MMR-BERT in these cases in the associated document retrieval task sometimes is not always worse than BERT-GT, due to some useful information contained in the conversations even though the questions do not receive positive feedback.
| {'timestamp': '2021-07-14T02:05:50', 'yymm': '2107', 'arxiv_id': '2107.05760', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05760'} | arxiv |
\section{Analysis of Social Tie Evolution}
\subsection{Structural Balance with $W(t)$}\label{subsec:structural}
\thmconvergence*
\begin{proof}
Let all eigenvalues of $W(t)$ be $\beta_1, ..., \beta_n$ and $\beta_1$ be the unique largest eigenvalue. Then
\begin{equation*}
W(t) = H \cdot \diag(\beta_1(t), \cdots, \beta_n(t)) \cdot H^T,
\end{equation*}
for some time independent orthogonal matrix $H$ whose first column is the $\beta_1$ eigenvector. This implies that $w_{ij} = \sum_{k} H_{ik} \cdot \beta_k(t) \cdot H_{jk}$. Since all $\beta_i(t) < \beta_1(t)$ for $i\neq1$, the growth rate of $w_{ij}(t)$ as $t \to T$ is the same as $H_{i1}\beta_1(t) H_{j1}$.
Therefore, the sign of $w_{ij}$ is the same as the sign of $H_{i1} \cdot H_{j1}$. Thus,
\begin{equation*}
\sgn( w_{ij}w_{jk}w_{ki}) = \sgn(H_{i1}H_{j1}H_{j1}H_{k1}H_{k1}H_{i1}) = \sgn(H_{i1}^2H_{j1}^2H_{k1}^2) >0.
\end{equation*}
The same argument shows that above sign is non-negative if some component of the eigenvector is zero.
\end{proof}
\subsection{Solution to the General Riccati Equation}\label{subsec:general-Riccati}
We first focus on solving a general form of the matrix Riccati equation as stated below.
\begin{equation}
\label{eqn:Evolution}
\left\{
\begin{array}{rl}
W' & = W^2 + C \\
W(0) & = B.
\end{array}
\right.
\end{equation}
The equation in our co-evolution model, i.e., Equation~(\ref{eqn:Riccati}), satisfies $C+B^2=V(0)V(0)^T$. Notice that the right-hand side $V(0)V(0)^T$ is an $n
\times n$ matrix with rank one, which is a special condition. The analysis in this subsection applies for general matrices $B, C$.
By using a result in Reid~\cite{reid1972mathematics}, we can turn the matrix Riccati equation to a linear ODE system.
\begin{lemma}[\cite{reid1972mathematics}]\label{lemma:recatti}
The ODE system in Equation~(\ref{eqn:Evolution}) is equivalent to the following system
\begin{equation}
\label{eqn:Rccati}
\left\{
\begin{array}{ll}
Y' = Z & Y(0) = I\\
Z' = -CY & Z(0) = -B,
\end{array}
\right.
\end{equation}
where $Y' = -WY$ and $Z = -WY$, and $Y, Z, W \in \mathbb{R}^{n\times n}$.
\end{lemma}
\begin{proof}
First, we show that we can get Equations~(\ref{eqn:Rccati}) from Equations~(\ref{eqn:Evolution}), i.e., (\ref{eqn:Evolution}) $\Rightarrow$ (\ref{eqn:Rccati}).
We know that $Y$ exists and $Z = -WY$. Thus, $Y' = Z$. Then
\begin{equation*}
\begin{split}
Z' & = -W'Y - WY' \\
& = -(W^2+C)Y - W(-WY) \\
& = -W^2Y - CY + W^2Y \\
& = -CY.
\end{split}
\end{equation*}
At the same time, $Z(0) = -W(0)Y(0) =-W(0)= -B$. Thus, this direction is satisfied.
Second, let us prove that Equation~(\ref{eqn:Evolution}) can be obtained from Equation~(\ref{eqn:Rccati}).
Since $Y(0)=I$, by continuity, $Y(t)^{-1}$ exists for $t \in [0, \epsilon]$, for $
\epsilon>0$.
Since $Z=-WY$, we have $W = -ZY^{-1}$.
Note $(Y^{-1})' = -Y^{-1}\cdot Y' \cdot Y^{-1}$, since $Y\cdot Y^{-1} = I \Rightarrow Y'\cdot Y^{-1} + Y\cdot (Y^{-1})' = 0$.
Therefore:
\begin{equation*}
\begin{split}
W' & = -Z'\cdot Y^{-1} - Z \cdot (Y^{-1})' \\
& = CY\cdot Y^{-1} - Z (-Y^{-1}\cdot Y' \cdot Y^{-1}) \\
& = C + Z\cdot Y^{-1} \cdot (-WY) \cdot Y^{-1} \\
& = C - Z\cdot Y^{-1} \cdot W \\
& = C + W^2.
\end{split}
\end{equation*}
Clearly $W(0) = -Z(0) = B$. This completes the proof.
\end{proof}
From Lemma~\ref{lemma:recatti}, we can focus on solving the linear Ordinary Differential Equation (ODE) in Equation~(\ref{eqn:Rccati}), which can be written in a matrix form. The analysis below is new.
\begin{equation*}\label{eqn:matrix}
\left[ \begin{array}{c}
Y \\
Z
\end{array}
\right]' =
\left[ \begin{array}{cc}
0 & I \\
-C & 0
\end{array}
\right]
\left[ \begin{array}{c}
Y\\
Z
\end{array}
\right],
\end{equation*}
where we define $A = \left[ \begin{array}{cc}
0 & I \\
-C & 0
\end{array}
\right]\in \mathbb{R}^{2n \times 2n}$ in block form and $X = \left[ \begin{array}{c}
Y\\
Z
\end{array}
\right] \in \mathbb{R}^{2n \times n}$.
Now, let us solve the evolution equation $X' = AX$, where $X(0) = \left[ \begin{array}{c}
I\\
-B
\end{array}
\right]$. It is well known that the solution is,
\begin{equation}\label{eqn:X(t)}
X(t) = (\sum_{n=0}^{\infty}\frac{t^n A^n}{n!}) X(0).
\end{equation}
Let us compute $A^n$ using the block multiplication of matrices~\cite{eves1980elementary,anton2013elementary}.
\begin{equation*}
A^2 = \left[ \begin{array}{cc} 0 & I \\ -C & 0 \end{array} \right]
\left[ \begin{array}{cc} 0 & I \\ -C & 0 \end{array} \right] =
\left[ \begin{array}{cc} -C & 0 \\ 0 & -C \end{array} \right].
\end{equation*}
It implies:
\begin{equation*}
A^{2n} = \left[ \begin{array}{cc} (-1)^n C^n & 0 \\ 0 & (-1)^n C^n \end{array}, \right]
\end{equation*}
\begin{equation*}
A^{2n+1} = A^{2n}\cdot A = \left[ \begin{array}{cc} (-1)^n C^n & 0 \\ 0 & (-1)^n C^n \end{array} \right] \cdot
\left[ \begin{array}{cc} 0 & I \\ -C & 0 \end{array} \right] =
\left[ \begin{array}{cc} 0 & (-1)^n C^{n} \\ (-1)^{n+1}C^{n+1} & 0 \end{array} \right].
\end{equation*}
Recall that $W = -ZY^{-1}$. Now we are ready to solve for $W$.
\mainth*
\begin{proof}
According to Equation (\ref{eqn:X(t)}),
\begin{equation*}
\begin{split}
X(t) & = \sum_{n=0}^{\infty}\frac{t^{2n}A^{2n}}{(2n)!}\cdot X(0) + \sum_{n=0}^{\infty}\frac{t^{2n+1}A^{2n+1}}{(2n+1)!}\cdot X(0) \\
& = \sum_{n=0}^{\infty}\frac{(-1)^n t^{2n}}{(2n)!}\left[ \begin{array}{cc} C^n & 0 \\ 0 & C^n \end{array} \right] \left[ \begin{array}{c}1\\-B \end{array} \right] + \sum_{n=0}^{\infty}\frac{(-1)^n t^{2n+1}}{(2n+1)!} \left[ \begin{array}{cc} 0 & C^n \\ -C^{n+1} & 0 \end{array} \right] \left[ \begin{array}{c}1\\-B \end{array} \right] \\
& = \sum_{n=0}^{\infty} \frac{(-1)^n t^{2n}}{(2n)!} \left[ \begin{array}{c}C^{n}\\-C^{n}B \end{array} \right] + \sum_{n=0}^{\infty}\frac{(-1)^{n+1} t^{2n+1}}{(2n+1)!} \left[ \begin{array}{c}C^{n}B\\C^{n+1} \end{array} \right] \\
& = \left[ \begin{array}{c} \sum_{n=0}^{\infty} \frac{(-1)^n t^{2n} C^n}{(2n)!} + \sum_{n=0}^{\infty}\frac{(-1)^{n+1}t^{2n+1}C^nB}{(2n+1)!} \\
\sum_{n=0}^{\infty}\frac{(-1)^{n+1}t^{2n}C^nB}{(2n)!} + \sum_{n=0}^{\infty} \frac{(-1)^{n+1} t^{2n+1} C^{n+1}}{(2n+1)!} \end{array} \right] \\
& \triangleq \left[ \begin{array}{c} Y \\Z \end{array} \right].
\end{split}
\end{equation*}
\end{proof}
\subsection{When $B, C$ are both symmetric}\label{subsec:socialtie}
In our model, we assume that the initial tie matrix $W(0)$ is symmetric. Thus the social tie evolution follows $W' = W^2 + C$, where $W(0) = B$, both $B$ and $C$ are symmetric. We are able to derive more detailed closed form solutions for the matrix Riccati equation in this setting.
Since $C$ is symmetric, there exists an orthogonal matrix $U$ such that $U^TCU$ is a diagonal matrix:
$U^TCU=\diag\{a^2_1, \cdots, a^2_k, -d^2_1, \cdots, -d^2_l, 0, \cdots, 0\}$,
where $a_i>0, d_j>0$. Furthermore, if $BC=CB$, by the simultaneous diagonalization theorem, we may choose $U$ such that both $U^TCU$ and $U^TBU$ are diagonal.
By Lemma~\ref{conjugation}(1), without loss of generality, we are going to solve the equation with the initial opinion vector $U^TV(0)$ and initial weight matrix $U^TW(0)U$. This leads to a system as below
\begin{equation*}
\label{eqn:evolution-diagonalized}
\left\{
\begin{array}{rl}
(U^TWU)' & = (U^TWU)^2 + U^T C U \\
U^T W(0)U & = U^TB U.
\end{array}
\right.
\end{equation*}
The solution of this system can be easily transformed back to the solution to the original system by conjugation. For simplicity, the $(i,j)$-th entry of a matrix $M$ will be denoted by $M_{ij}$.
Define $\beta_{ii}$ the $i$th diagonal element of $U^TBU$, i.e., $\beta_{ii}=(U^TBU)_{ii}$.
Let us now work out explicitly the matrices $Y$ and $Z$ in Theorem~\ref{mainth}.
\begin{enumerate}
\item For the positive eigenvalue $a_i^2$ of $C$,
\begin{equation*}
\begin{split}
&\sum_{n=0}^{\infty}\frac{(-1)^n t^{2n} a_i^{2n}}{(2n)!} = \cos{(a_i t)} \\
&\sum_{n=0}^{\infty}\frac{(-1)^{n+1} t^{2n+1} a_i^{2n}}{(2n+1)!} = -\frac{1}{a_i}\sin{(a_i t)}.
\end{split}
\end{equation*}
Thus, $(U^TYU)_{ii} = \cos{(a_i t)} - \frac{1}{a_i} \sin{(a_i t)}\cdot \beta_{ii}$. Similarly, we have
\begin{equation*}
\begin{split}
& \sum_{n=0}^{\infty}\frac{(-1)^{n+1} t^{2n} a_i^{2n}}{(2n)!} = -\cos{(a_i t)} \\
& \sum_{n=0}^{\infty}\frac{(-1)^{n+1} t^{2n+1} a_i^{2n+2}}{(2n+1)!} = -a_i \sin{(a_i t)}.
\end{split}
\end{equation*}
So, $(U^TZU)_{ii} = -\cos{(a_i t)}\beta_{ii} - a_i \sin{(a_i t)}$.
\item For the zero eigenvalues of $C$, i.e., $c_i = 0$, we have $(U^TYU)_{ii} = 1 - t\cdot \beta_{ii}$ and $(U^TZU)_{ii} = -\beta_{ii}$.
\item For the negative eigenvalue $c_i = -d_i^2$, we have
\begin{equation*}
\begin{split}
(U^TYU)_{ii} = \sum_{n=0}^{\infty} \frac{t^{2n}d_i^{2n}}{(2n)!} + (-1)\sum_{n=0}^{\infty}\frac{t^{2n+1} d_i^{2n}}{(2n+1)!}\beta_{ii} = \cosh{(d_i t)} - \frac{1}{d_i}\sinh{(d_i t)}\beta_{ii} \\
(U^TZU)_{ii} = \sum_{n=0}^{\infty} (-1)\frac{t^{2n} d_i^{2n}}{(2n)!}\beta_{ii} + \sum_{n=0}^{\infty} \frac{t^{2n+1}d_i^{2n+2}}{(2n+1)!} = - \cosh{(d_i t)} \beta_{ii} + d_i \sinh{(d_i t)}.
\end{split}
\end{equation*}
\end{enumerate}
So we can summarize the above formulas as: $U^TYU = D_1 - D_2 U^T BU$ and $U^TZU = D_3 - D_1 U^TBU$, where
\begin{eqnarray*}
D_1&=&\diag\{\cos{(a_1 t)}, \cdots,\cos{(a_k t)}, \cosh{(d_1 t)}, \cdots, \cosh{(d_l t)}, 1, \cdots, 1 \}, \\
D_2&=&\diag\{\sin(a_1 t)/a_1, \cdots,\sin(a_kt)/a_k, \sinh(d_1 t)/d_1, \cdots, \sinh(d_l t)/d_l, 1, \cdots, 1 \},\\
D_3&=&\diag\{-a_1\sin(a_1 t), \cdots,-a_k\sin(a_kt), d_1\sinh(d_1 t), \cdots, d_l\sinh(d_l t), 0, \cdots, 0 \},
\end{eqnarray*}
\subsection{When both $B, C$ are symmetric and $BC=CB$}\label{subsec:BCequalCB}
Now, we consider the special case that $BC=CB$.
Using a basic fact that two commuting symmetric matrices can be simultaneously orthogonally diagonalized~\cite{Hoffman1971-bc}. Let $U$ be an orthogonal matrix such that
\begin{equation*}
\begin{split}
U^TCU & = \diag(a_1^2, \cdots, a_k^2, -d_1^2, \cdots, -d_l^2, 0, \cdots, 0)\\
U^TBU & = \diag(\lambda_1, \cdots, \lambda_k, \mu_1, \cdots, \mu_l, \delta_1, \cdots, \delta_h).
\end{split}
\end{equation*}
where $a_i, d_j > 0$.
In this case we can further simplify the solution.
\begin{equation}\label{eqn:WWW}
\begin{aligned}
W = & -Z \cdot Y^{-1} \\
= & U\diag(\frac{a_1 \sin{(a_1 t)} + \cos{(a_1 t)}\lambda_1}{\cos{(a_1 t)}-\frac{1}{a_1}\sin{(a_1 t)}\lambda_1}, \cdots, \frac{a_k \sin{(a_k t)}) + \cos{(a_k t)}\lambda_k}{\cos{(a_k t)}-\frac{1}{a_k}\sin{(a_k t)}\lambda_k},\\
& -\frac{d_1 \sinh{(d_1 t)}-\cosh{(d_1 t)}\mu_1}{\cosh{(d_1 t)} - \frac{1}{d_1}\sinh{(d_1 t)}\mu_1}, \cdots, -\frac{d_l \sinh{(d_l t)}-\cosh{(d_l t)}\mu_l}{\cosh{(d_l t)} - \frac{1}{d_l}\sinh{(d_l t)}\mu_l}, \\
& \frac{\delta_1}{1 - t\delta_1}, \cdots, \frac{\delta_h}{1 - t\delta_h})U^T.
\end{aligned}
\end{equation}
Note that above equation for $W(t)$ implies that $V(t)$ is an eigenvector of $W(t)$ for all time $t$.
Now we are ready to analyze the behavior of $W$ over time in the case of a symmetric initial condition matrix $W(0)$.
We start with a technical lemma.
\begin{lemma}\label{lemma:sin}
\begin{enumerate}
\item If $a > 0$, then there exists $T \in (0, \frac{\pi}{a})$, such that for all $\lambda$
\begin{equation*}
\lim_{t \rightarrow T} \frac{a \sin{(at)} + \lambda \cos(at)}{-\frac{\lambda}{a}\sin{(at)}+ \cos(at)} = + \infty.
\end{equation*}
\item If $d > 0$, then there exists $T \in (0, \infty]$, such that
\begin{equation*}
\lim_{t \rightarrow T} \frac{\cosh(dt)\mu-d\sinh(dt)}{\cosh(dt)-\frac{\mu}{d}\sinh(dt)} = + \infty,
\end{equation*}
if and only if $\mu >d$. In the case $\mu \leq d$, the limit for $T=\infty$ exists and is finite.
\item If $\delta > 0$, then there exists $T = \frac{1}{\delta}$, such that
$$\lim_{t \rightarrow T} \frac{\delta}{1 - t\delta} = + \infty.$$
\end{enumerate}
For all cases mentioned above, the convergence rate is $O(\frac{1}{|T-t|})$.
\end{lemma}
\begin{proof} For (1), we reorganize
$$\frac{a \sin{(at)} + \lambda \cos(at)}{-\frac{\lambda}{a}\sin{(at)}+ \cos(at)} =\lambda\frac{\cot{(at)} + \frac{a}{\lambda}}{\cot{(at)}-\frac{\lambda}{a}},$$
Since $\cot{(at)}$ is strictly decreasing from $\infty$ to $-\infty$ in the range $(0, \frac{\pi}{a})$, there exists a $T \in (0,\frac{\pi}{a})$, such that $\cot{(at)} = \frac{\lambda}{a}$. As $t$ approaches $T$ from the left, $\cot{(at)} - \frac{\lambda}{a} > 0$.
When $t \rightarrow T$ the numerator becomes $$\lambda(\frac{\lambda}{a} + \frac{a}{\lambda}) = \frac{\lambda^2 + a^2}{a}>0.$$
This confirms (i).
Then we consider the convergence rate as $t \rightarrow T$.
\begin{equation*}
\lambda\frac{\cot{(at)} + \frac{a}{\lambda}}{\cot{(at)}-\frac{\lambda}{a}} = \lambda \frac{\cot{(-a(T - t) + aT)} + \frac{a}{\lambda}}{\cot{(-a(T - t) + aT)} - \frac{\lambda}{a}} = \lambda \frac{(\frac{\lambda}{a}+\frac{a}{\lambda})\cot{(a(T-t))}}{1 + \frac{\lambda^2}{a^2}}.
\end{equation*}
The Taylor series of $\cot{(x)}$ is $\frac{1}{x} - \frac{x}{3} + o(x)$. Given that $(T-t) \rightarrow 0$, the convergence rate is $O(\frac{1}{|T-t|})$.
For (2), reorganize
$$\frac{\cosh(dt)\mu-d\sinh(dt)}{\cosh(dt)-\frac{\mu}{d}\sinh(dt)}=\frac{\coth(dt)\mu-d}{\coth(dt)-\frac{\mu}{d}}.$$
Since the function $\coth(dt)$ is strictly decreasing from $\infty$ to $1$, if $\mu>d$, there exists $T \in (0, \infty)$ such that $\coth(dT)=\mu/d$. Furthermore, as $t$ approaches $T$ from the left, the denominator is positive. But $\lim_{t \to T}\coth(dt)\mu-d = \frac{\mu^2-d^2}{d} >0 $.
It follows that $$\lim_{t \rightarrow T} \frac{\cosh(dt)\mu-d\sinh(dt)}{\cosh(dt)-\frac{\mu}{d}\sinh(dt)} = + \infty.$$ If $\mu \leq d$, the function is smooth on $[0, \infty)$ and the limit is finite as $t \to \infty$.
For convergence rate, we rewrite the function:
\begin{equation*}
\mu \frac{\coth{(dt)} - \frac{d}{\mu}}{\coth{(dt)} - \frac{\mu}{d}} =
\mu \frac{\coth{(-d(T - t) + dT)} - \frac{d}{\mu}}{\coth{(-d(T - t) + dT)} - \frac{\mu}{d}} = \mu \frac{(\frac{\mu}{d} - \frac{d}{\mu})\coth{(d(T-t))}}{\frac{\mu^2}{d^2} - 1}.
\end{equation*}
The Taylor series of $\coth{(x)}$ is $\frac{1}{x} + \frac{x}{3} - o(x)$. Given that $(T-t) \rightarrow 0$, the convergence rate is $O(\frac{1}{(T-t)})$.
The limit in case (3) is obvious when $\delta > 0$. Now we look at its convergence rate. Here $T = \frac{1}{\delta}$. Rewrite the function as
\begin{equation*}
\frac{\delta}{1 - t\delta} = \frac{1}{\frac{1}{\delta} - t} = \frac{1}{T - t} = \frac{1}{(T-t)}.
\end{equation*}
Thus, its convergence is $O(\frac{1}{(T-t)})$.
From the above analysis, we can know the convergence rate is $O(\frac{1}{(T-t)})$, which is an inverse proportional function, under any case.
\end{proof}
By Equation~(\ref{eqn:W}) and Lemma~\ref{lemma:sin}, we know that some diagonal entry of $W$ converges to the infinity at a finite time $T$ under some appropriate conditions.
\subsection{Structural Balance when $BC=CB$}\label{subsec:structural-commute}
In the following, we prove Theorem~\ref{thm:main} which characterizes the conditions for structural balance, when $BC=CB$.
\thmmain*
\begin{proof} Since the eigenvalues of $W(t)$ remains the same as $U^TWU$ for any orthogonal matrix $U$, we see the convergence of eigenvalues of $W(t)$ from Equation~(\ref{eqn:W}). Due to the convergence of the eigenvalues in $(-\infty, \infty]$, we see that $\lim_{t \to T} w_{ij}(t) \in [-\infty, \infty]$ exists for all $i,j$. This means that we have sign stability, that all weights $w_{ij}$, $\forall i, j$, have fixed signs, as $t \to T$.
To see structure balance, by Theorem~\ref{kl}, it suffices to check if the largest eigenvalue tends to infinity. We examine the solution $W$ as described in Equation~(\ref{eqn:W}) and use Lemma~\ref{lemma:sin}.
\begin{enumerate}
\item If there exists $\delta_i > 0$, structural balance occurs because $\lim_{t\rightarrow \frac{1}{\delta_i}}\frac{\delta}{1-t \delta_i} = +\infty$.
\item If there exists $a_i>0$, structural balance occurs because of Lemma~\ref{lemma:sin}(1).
\item If $\mu_j > d_j$, structural balance occurs because of Lemma~\ref{lemma:sin} (2).
\end{enumerate}
\end{proof}
Now we are ready to discuss our co-evolution model (Equation~(\ref{eqn:continuous-model})). First, the condition $BC=CB$ when $B=W(0)$ and $C=V(0)V(0)^T-W(0)W(0)^T$ means that $V(0)$ is an eigenvector of $W$. We finish the proof here.
\lemmaBCcommute*
\begin{proof} Clearly if $Av=\alpha v$, then $A$ and $vv^T$ commute. Conversely, if $A$ and $vv^T$ commute, we can find an orthogonal matrix $U$ such that $U^TAU$
and $U^Tvv^TU$ are diagonal. We may assume that the $(1,1)$ entry
$\lambda$ of
$U^Tvv^TU$ is not zero. This shows the first column $c$ of $U$ is an eigenvector for $vv^T$ associated to $\lambda$.
But $v$ is also an eigenvector of $vv^T$ associate to $\lambda$. Therefore $c$ is a
non-zero scalar multiplication of $v$. But we also know that $c$ is an eigenvector of $A$. Therefore, $v$ is an eigenvector of $A$.
\end{proof}
For Equation~(\ref{eqn:continuous-model}), we have an additional condition $B^2+C = V(0)V(0)^T$ which has rank one. In the discussion below, we need the following fact about the eigenvalues and eigenvectors of rank-1 symmetric matrices $H=uu^T$ where $u \in \mathbb {R}^n -\{0\}$. The matrix $H$ has eigenvalues $||u||^2$ and $0$ such that the associated eigenvectors are $u$ and $z$'s which are perpendicular to $u$, i.e., $u^Tz=0$. Therefore, the unique largest positive eigenvalue is $||u||^2$ with the associated eigenvector $u$.
\corcomute*
\begin{proof}
When $V(0)$ is not a zero vector, $V(0)V(0)^T$ is a symmetric matrix with one positive eigenvalue and $(n-1)$ zero eigenvalue. Furthermore, $V(0)$ is an eigenvector associated to the largest positive eigenvalue. Now, since $W(0)$ and $C$ commute, we may simultaneously orthogonally diagonalize both. Since $B^2+C=V(0)V(0)^T$ is diagonal with only one positive diagonal entry, using the same notation as above, we see that all numbers $a_1^2+\lambda_1^2, ...., a_k^2+\lambda_k^2, \mu_1^2-d_1^2, ..., \mu_l^2-d_l^2, \delta_1^2, ..., \delta_n^2$ are zero except one of them which is positive.
If $a_i^2+\lambda_i^2 > 0$, then $a_i > 0$ exists and the condition (2) holds. If $\mu_i^2 - d_i^2 > 0$, then $\mu_i > d_i$ exists and the condition (3) holds. If $\delta_i^2 + 0 > 0$, then $\delta_i > 0$ and the condition (1) holds. Thus, by Theorem~\ref{thm:main}, the structural balance must occur in the finite time for $W(t)$.
\end{proof}
\subsection{Extensions and Conjectures}
\label{subsec:general}
\noindent\textbf{General Graphs} The discussion so far has assumed a complete graph. For a connected graph $G$, with our evolution model, our conjecture is that all the weights and opinions will go to extreme values. This appears to be the case for all simulations we have run. The reason is that it is hard for the weights to converge to finite values. One exception is that all the opinions are $0$. But this is not a stable state. Any small perturbation on the opinion will break this stable state.
At convergence, however, there might be more than $2$ communities. The reason is that the edges with negative weights may not be in any triangle of the graph. Thus, multiple communities can be separated by the negative edges and it does not break the structure balance requirement.
\smallskip\noindent\textbf{High Dimensional Opinions} When each node has multiple opinions on different issues, its opinion can be represented as a $m$-dimensional vector, where $m$ is the number of opinions in one node. Each entry of the weight matrix is a $m\times m$ matrix instead of a real number.
For the high dimensional setting, our
equation for a general graph is:
\begin{equation}\label{eqn:derivation}
\left\{
\begin{array}{l}
V_i' = \sum_{j \sim i}W_{ij}V_j \\
W_{ij}' = V_i V_j^T, i \sim j
\end{array}
\right.
\end{equation}
where $i\sim j$ means that there exists an edge between nodes $i$ and $j$. Then, we have the following theorem:
\begin{theorem} If the graph has no self-loop and consider tie matrices $W$ to be symmetric, i.e., $W=W^T$, then
Equation~(\ref{eqn:derivation}) is the gradient flow of the dissonance function:
\begin{equation*}
F(V, W) = \frac{1}{2} \sum_{i\sim j} V_i^T \cdot W_{ij} \cdot V_j.
\end{equation*}
\end{theorem}
\begin{proof}
Since each opinion vector is $m$-dimensional, we can write it as $V_i = [(v_i)_a]\in \mathbb{R}^m$. Similarly, the edge weight $W_{ij}$ can be written as an $m\times m$ matrix $ [(w_{ij})_{ab}]\in \mathbb{R}^{m\times m}$. Note that $W = W^T$ means $(w_{ij})_{ab} = (w_{ji})_{ba}$.
Equation~(\ref{eqn:derivation}) is the same as:
\begin{equation*}\label{eqn:derivation_detail}
\left\{
\begin{array}{l}
(v_i)_a' = \sum_{j \sim i} \sum_{b=1}^m (w_{ij})_{ab} (v_j)_b \\
(w_{ij})_{ab}' = (v_i)_a (v_j)_b, i \sim j.
\end{array}
\right.
\end{equation*}
Due to $i \sim j$ implies $i \neq j$, the derivative of $F$ are:
\begin{equation*}
\frac{\partial F}{\partial (w_{ij})_{ab}} = \frac{1}{2}(v_i)_a(v_j)_b+\frac{1}{2} (v_j)_b(v_i)_a \triangleq (w_{ij})_{ab}'.
\end{equation*}
\begin{equation*}
\begin{split}
\frac{\partial F}{\partial (v_i)_a} & = \frac{1}{2} \sum_{j \sim i} (v_j)_b(w_{ji})_{ba} + \frac{1}{2} \sum_{ k\sim i} (w_{ik})_{ac}(v_k)_c \\
& = \sum_{j\sim i} (w_{ij})_{ab}(v_j)_b \triangleq (v_i)_a'.
\end{split}
\end{equation*}
\end{proof}
Based on our evolution equation and previous properties in the $1$-dimension opinion case, we make the following conjecture:
For a complete graph with self-loop edges, all the opinion vectors and the weight matrix will converge to extreme values. Any two adjacent nodes $V_i(t)$ and $V_j(t)$ have the same opinion or the complete opposite opinion, i.e., $V_i(t) = V_j(t)$ or $V_i(t) = -V_j(t)$ as time approaches $T_0$.
Based on the above conjecture, each entry of $\lim_{t \to T_0} W_{ij}(t)$ should have the same sign as that of $\lim_{t \to T_0} V_i(t)V_j(t)^T$.
\section{Introduction}
We live in a continuously changing world in which social interactions dynamically shape who we are, how we view the world and what decisions to make. Various social processes, naturally intertwined, operate on both the properties of individuals and social ties among them. Social influence, for example, describes how people's behaviors, habits or opinions are shifted by those of their neighbors.
Social influence leads to homophily ( similarity of node attributes between friends) and leaves traces in the network structure such as high clustering coefficient and triadic closure (there are likely social ties among one's friends).
Social influence and homophily, however, do not fully interpret the global network structure. One of the widely observed structural properties in social networks is the community structure. Nodes within the same community are densely connected and nodes from different communities are sparsely connected. Community detection is an important topic in social network analysis and has been investigated extensively~\cite{Pares2017-yq,Yang2016-gn,Newman2004-og,Newman2004-js,Newman2004-jn,Guimera2004-vm,Zhang2014-vs,Von_Luxburg2007-wb,Newman2006-sa,Hastings2006-sn,Karrer2011-ms}. But why does community structure emerge and become a persistent feature? Are there social processes that encourage or maintain the community structure?
In the literature, there have been a lot of studies of opinion dynamics, where people's behaviors, habits or opinions are influenced by those of their neighbors. Network models that capture social influence, such as French-DeGroot model~\cite{French1956-bk, Antal2005-lu}, Friedkin-Johnsen model~\cite
{Friedkin1990-wl},
Ku$\l$akowski et al. model~\cite{Kulakowski2005-is, Marvel2011-we} naturally converge to global consensus. Actually it seems to be non-trivial to create non-homogeneous outcomes in these models, while in reality social groups often fail to reach consensus and exhibit clustering of opinions and other irregular behaviors. Getting a model that may produce community cleavage~\cite{Friedkin2015-qc} or diversity~\cite{Kurahashi-Nakamura2016-ys} often requires specifically engineered or planted elements in a rather explicit manner. For example, bounded confidence models~\cite{Mas2010-za,Krause2000-no,Hegselmann2002-ud,Deffuant2000-pb}
limit social influence only within pairs with opinions sufficiently close.
Other models introduce stubborn nodes whose opinions remain unchanged throughout the process.
The extreme case of community structure is dictated by structural balance~\cite{Heider1946-bt, Heider1982-rg,Cartwright1956-fc, davis1967clustering}, a common phenomenon observed in many social relationships.
The notion was first introduced in a seminal paper by Heider in the 1940s in social psychology. It describes the stability of human relations among three individuals when there are only two types of social ties: positive ties describe friendship (or sharing common opinions) and negative ties describe hostility (or having opposite opinions).
Heider's axioms state that among three individuals, only two kinds of triangles are stable: the triangles where all three ties are positive, indicating all three individuals are mutual friends; and the triangle with two negative edges and one positive edge, describing the folklore that ``the enemy of your enemy is your friend.''
The other two types of triangles (e.g., a triangle of one negative tie and two positive ties, or three mutually hostile individuals) incur emotional stress or are not strategically optimal. See Figure~\ref{fig:structural-balance}.
Thus they are not socially stable -- over time, they break and change to the stable ones. In fact, the structural balance theory not only describes the local property in a signed complete network, but also predicts the global network behavior -- the only type of network in which all triangles are stable must have the nodes partitioned into two camps, inside each of which the edges are all positive and between them the edges are negative (one of the camps can be empty).
\begin{figure}[htbp]
\centering
\includegraphics[width=0.5\columnwidth]{structural-balance}\vspace*{-3mm}
\caption{Structural balance theory: the first two triangles are stable while the last two are not.}\label{fig:structural-balance}
\end{figure}
The structural balance theory only describes the equilibrium state and does not provide any model on evolution or dynamics -- what happens when a network has unstable triangles? Follow up work on structural balance dynamic models~\cite{Antal2005-lu,Marvel2011-we, Kulakowski2005-is,cisnerosvelarde2019structural, teixeira2017emergence} update the sign/weight of an edge $(i, j)$ towards a more balanced triangle by considering the sign/weights of neighboring edges $(i, k)$ and $(k, j)$ in a triangle $\triangle i j k$.
These two threads of research, opinion dynamics and structural balance dynamics,
are currently orthogonal to each other.
In opinion dynamics, opinions on vertices are influenced by each other through edges but researchers struggle to maneuver the model to create community cleavage. In structural balance dynamics, edge weights are dynamically updated to meet structural balance, which is explicitly coded as the projected outcome and optimization objective. In this paper, we propose co-evolution models for both dynamics of opinions (people's view on a variety of topics) and dynamics of social appraisals (the approval or disapproval towards each other). We show that by using two simple rules, node opinions evolve into opposing communities and structural balance naturally emerges.
\subsection{Our Contribution}
In this paper, we consider the co-evolution of opinions via social influence and tie strength/appraisal/sign updates by discrepancies of node opinions. We assume a set of $n$ individuals where individual $i$ has an opinion $v_i \in \mathbb{R} $, and an appraisal matrix $W=[w_{ij}]$, where $w_{ij}$ is interpreted as the influence from individual $j$ on individual $i$. Here $w_{ij}$ does not need to be non-negative and takes values in $\mathbb{R}$. We consider two update rules:
\begin{itemize}
\item \emph{Opinion dynamics:} The opinion of $i$ is updated as a linear combination of its current opinion and the weighted sum of neighbors' opinions with coefficients in matrix $W$.
\item \emph{Appraisal dynamics:} The appraisal $w_{ij}$ is updated as a linear combination of its current value and the agreement of the opinion of $i$ and $j$. The agreement of opinion $v_i$ and $v_j$ is taken as the dot product $v_i
\cdot v_j$.
\end{itemize}
The opinion dynamics model is similar to classical social influence models such as the DeGroot model~\cite{French1956-bk} and Friedkin-Johnsen model~\cite
{Friedkin1990-wl}, except that the edge weight matrix $W$ is dynamic as well. The model for appraisal dynamics is motivated by tie dynamics that can be traced back to Schelling's model of residential segregation~\cite{Schelling1971-eb}. In modern society, tie changes on Facebook~\cite{Sibona2014-ni} and Twitter~\cite{Xu:2013:SBT:2441776.2441875,kivran2011impact} can be easily triggered by disparities on their opinions~\cite{John2015-az,Sibona2014-ni}, especially among the users who are most politically engaged.
Our goal is to analyze the evolution and in particular, the conditions that lead to \emph{sign stability} and \emph{structural balance} -- for any triangle with individual $i, j, k$, $w_{ij}w_{jk}w_{ki}\geq 0$. We call a network to reach strictly structural balance if $w_{ij}w_{jk}w_{ki}> 0$, $\forall i, j, k$.
A structurally balanced network has two possible states: \emph{harmony}, when all edges are positive; and \emph{polarization}, when there are two communities with only positive ties within each community and negative ties across the two communities.
We show that with our dynamics model, $W(t)$ evolves by the following matrix Riccati Equation~\cite{Abou-Kandil2003-um} $W' = WW^T + C$, where $C= V(0)V(0)^T - W(0)W(0)^T$ is a symmetric constant $n \times n$ matrix if $W(0)$ is. Further the opinion vector $V(0)$ evolves by the differential equation $V''(t)=2|V|^2 \cdot V-C\cdot V$.
Our main result is to analyze the asymptotic behavior of $V(t)$ and $W(t)$ and prove structural balance at the limit. Our results can be summarized in the following:
\begin{enumerate}
\item By analyzing the evolving equation for $V(t)$, we show that either the network reaches strict structural balance or $|V(t)|\rightarrow 0$. To prove this limit behavior, one crucial observation is that the length of the opinion vector $|V(t)|^2$ is strictly convex, unless $V(t)\equiv 0$.
\item We show how to solve the general matrix Riccati equation $W'=W^2+C$, $W(0)=B$, for any parameter $B, C$. In particular, the eigenvector corresponding to the largest eigenvalue of $W(t)$ encodes the two communities formed in the network; those with a positive value in the eigenvector versus those with a negative value in the eigenvector. As a byproduct of the analysis of $W(t)$, we also show that when $V(0)$ is an eigenvector of the initial matrix $W(0)$, $V(t)$ remains to be an eigenvector of $W(t)$ for and structural balance must occur in finite time. In this case we can write down exact evaluations on the blowup time and the rate convergence.
\end{enumerate}
The evolving of $W(t)$ by $W' = WW^T + C$ is strictly a generalization of the dynamic structural balance model by Marvel et al. ~\cite{Marvel2009-lx}. Their model captures the dynamics of edge appraisals by $W' = W^2$ and does not consider user opinions. The behavior of our model becomes much more complex, as the initial user opinions are factored into the system dynamics through the matrix $C$.
We also performed extensive simulations with different initial conditions and graph topology. We examined the network evolution on the final convergence state (harmony v.s., polarization) and convergence rate. We observed that a higher network density or a higher initial opinion magnitude, empirically, speeds up the convergence rate.
We tested our dynamic model on two real world graphs (Karate club graph and a political blog graph~\cite{adamic2005political}). Both networks are known to have two communities with opposing opinions. A small number of seeds, randomly selected, are assigned with ground truth opinions and all other nodes start neural. The network evolution can successfully detect the final community structure and recover the ground truth with good accuracy. Apart from being a transparent and explainable label propagation algorithm, the model sheds lights on why community structure emerges and becomes a widely observed, sustainable property in complex networks.
\section{Related Work}
\subsection{Opinion Dynamics and Social Influence}
Opinions in a sociological viewpoint capture the cognitive orientation towards issues, events or other subjects, and mathematically represent signed attitudes or certainties of belief. Opinion dynamics is an extensively studied topic about how opinions change in a network setting with social influence from neighbors.
One of the first models of opinion dynamics, French-DeGroot model~\cite{French1956-bk, Antal2005-lu}, considers a discrete time process of opinion $\{v_1, v_2, \cdots, v_n\}$ for a group of $n$ individuals. An edge $(i, j)$ carries a non-negative weight $w_{ij}
\geq 0$. The opinion of node $i$ at time $t+1$ is updated by
$$v_i(t+1)=\sum_{j}w_{ij}v_j(t).$$
The weight matrix $W=[w_{ij}]$ is taken as a stochastic matrix. The dynamics can be written as $V(t+1)=WV(t)$.
The continuous-time counterpart is called the Abelson's model~\cite{Abelson1964-ny} where the dynamics is defined by
\begin{equation}\label{ref:eqn-abelson}
\frac{dV(t)}{dt}=-LV(t),
\end{equation}
where $V(t)=(v_1(t), v_2(t), \cdots v_n(t))^T$ and $L$ is the Laplacian matrix $L=I-W$.
Opinions following the French-DeGroot model or the Abelson's model typically converge unless the network is disconnected or there are stubborn nodes (with $w_{ii}=1$).
The most popular opinion dynamics model is probably the Friedkin-Johnsen model~\cite{Friedkin1990-wl}. It takes a stochastic matrix $W$ as the influence model, and a diagonal matrix $\Lambda=\diag(\lambda_1, \cdots, \lambda_n)$ where $\lambda_i\in [0, 1]$ is the susceptibility of individual $i$ to social influence. The opinions of the individuals are updated by the following process
$$V(t+1)=\Lambda W V(t)+(I-\Lambda)u,$$
where $u$ is a constant vector of the individuals' prejudices and is often taken as the initial opinion $V(0)$. When $\Lambda=I$ the model turns to French-DeGroot model.
Most of the literature on these two models assume a fixed weight matrix $W$ and prove asymptotic convergence under favorable assumptions~\cite{Friedkin2011-et}. There have been extensions when $W$ is a time-varying matrix, but $W(t)$ is still independent of $V(t)$ (e.g.,~\cite{Blondel2005-uz}).
A significant deviation from the above family considers a time-varying matrix $W$, by incorporating the principle of homophily, that similar individuals interact more than dissimilar ones.
This is called the bounded confidence model~\cite{Mas2010-za}. A few such models (Hegselmann-
Krause (HK) model~\cite{Krause2000-no,Hegselmann2002-ud}, Deffuant and Weisbuch~\cite{Deffuant2000-pb}) introduced a fixed range of confidence $d>0$: individual $i$ is insensitive to opinions that fall outside its confidence set $I_i=[v_i -d, v_i+d]$, and the opinion $v_i$ is only updated by the average opinion of those opinions within $I_i$. In other words, the matrix $W$ is derived from the set of opinions at time $t$ and thus co-evolves with the opinions. This model generates situations when the individuals converge to a set of different opinions, and has been extended to the multi-dimensional setting~\cite{Hegselmann2002-ud}.
All models above have only considered the case of positive influence, that the interactions of individuals change their opinions \emph{towards} each other. It has been argued in both social settings and many physical systems that there is negative or repulsive influence (repulsive interactions in biological systems~\cite{Coyte2015-ry} or collision avoidance in robot swarm formation~\cite{Romanczuk2012-sg}). Abelson~\cite{Abelson1967-nn} argued that any attempt to persuade a person may sometimes shift his or her opinion away from the persuader's opinion, called the boomerang effect~\cite{Allahverdyan2014-ja, Hovland1953-hc}. Bhawalkar et al.~\cite{bhawalkar2013coevolutionary} presented game-theoretic models of opinion formation in social networks by maximizing agreement with friends weighted by the strength of the relationships. Thus interactions between individuals with similar opinions move their opinions closer; interactions between individuals with opinions that are very different shift their opinions away from each other. Here the edge weights are fixed. Many models have included negative ties but they are still awaiting rigorous analysis~\cite{Salzarulo2006-ag, Baldassarri2007-zs, Macy2003-wq, Mark2003-it, he2018evolution}.
The most notable work in this direction is by Altafini~\cite{Altafini2013-kb, Altafini2012-lr}. The model starts to be similar to Abelson's model in Equation~(\ref{ref:eqn-abelson}) with a \emph{fixed} weight matrix $W$ except that the weights in $W$ do not need to be non-negative. The system is shown to be Lyapunov stable~\cite{Proskurnikov2016-hc} and studies have focused on the initial conditions of $W$ for the system to converge to harmony or polarization. The matrix $W$ is assumed to be either static or, in very recent studies~\cite{Proskurnikov2017-lr, Proskurnikov2016-hc,Hendrickx2014-qy}, time-varying (but independent of the opinion changes).
The negative influence is closely related to signed networks and structural balance theory, which will be discussed next.
\subsection{Structural Balance and Signed Networks}
Notice that the structural balance theory only describes the equilibrium state and does not provide any model on evolution or dynamics -- what happens when a network has unstable triangles? Follow up work proposed a few models, that can be categorized by discrete models or continuous models -- depending on whether the appraisal on a social tie takes binary values $\{+1, -1\}$ or a real number.
Antal et al.~\cite{Antal2005-lu} considered the discrete model where the sign of an edge is flipped if this produces more balanced triangles than unbalanced ones. The balanced graph is clearly a stable state but the dynamics also has many local optima called jammed states~\cite{Antal2005-lu,Marvel2009-lx}. A similar model is used in Andreida et al.~\cite{teixeira2017emergence}.
Samin et al.~\cite{aref2020modeling} considered removing the minimum number of edges to make the graph balanced, which is an NP-hard problem.
In the continuous setting, the influence-based model~\cite{Marvel2011-we, Kulakowski2005-is} describes an influence process on a complete graph, in which an individual $i$ updates her appraisal of individual $j$ based on what others positively or negatively think of $j$. In other words, let us use $w_{ij}$ to describe the type of the social tie between two individuals $i, j$. $w_{ij}>0$ if $i, j$ are friends and $<0$ if they feel negative about each other. The absolute value of $w_{ij}$ describes the magnitude of the appraisal. The update rule says that the update to $w_{ij}$ will take value
\begin{equation}\label{eq:dynamic-w}
\frac{d w_{ij}}{dt}=\sum_{k}w_{ik}\cdot w_{kj}.
\end{equation}
Specifically, when $w_{ik}$ and $w_{kj}$ have the same sign, the value of $w_{ij}$ is guided to the positive direction; when $w_{ik}$ and $w_{kj}$ have opposite signs, the value of $w_{ij}$ is guided to the negative direction. Both cases try to enforce a balanced triangle on $\{i, j, k\}$. Empirically, it has been observed that for essentially any initial value of $W$, as the matrix where the $(i, j)$ element is $w_{ij}$, the system reached a balanced pattern in finite time. In~\cite{Marvel2011-we}, Marvel et al. proved that for a random initial matrix $W$ the system reaches a balanced matrix in finite time with probability converging to $1$ as $n \rightarrow \infty$. They also characterized the converged value and its relationship to the initial value.
In a recent paper~\cite{cisnerosvelarde2019structural}, Cisneros-Velarde et al. considered a \emph{pure-influence} model, where the self-appraisal (such as $w_{ii}$) is taken out of Equation~(\ref{eq:dynamic-w}) to be a more faithful interpretation of Heider's structural balance.
They proved that when $W$ is symmetric their continuous-time dynamic model is exactly the gradient flow of an energy function called \emph{dissonance}~\cite{Marvel2009-lx}, defined as
\begin{equation*}
-\sum_{[ij],[jk],[ki] \in E} w_{ij} \cdot w_{jk} \cdot w_{ki}.
\end{equation*}
Dissonance characterizes the degree of violation to Heider's structural balance axioms in the current network. The global minimum of this energy function corresponds to signed networks that satisfy structural balance in the case of real-values appraisals.
When the initial matrix $W$ is symmetric the authors also provided characterizations of the critical points of the dissonance function (aka the equilibrium states of the dynamic model).
\medskip
The discussions of opinion dynamics and dynamics with structural balance, so far, have focused on node opinion changes or link appraisal changes, separately. Holme and Newman~\cite{holme2006nonequilibrium} presented a simple model combing the two but did not present theoretical analysis. There is little work on combining both dynamics into a co-evolving model, which is the focus of this paper.
\section{Co-Evolution Model}
Suppose there are $n$ individuals, each one with its own opinion $v_i \in \mathbb{R}$. Define the opinion vector $V = (v_1, v_2, \dots, v_n )^{T} \in \mathbb{R}^{n}$.
The influence model among the $n$ individuals is characterized as an $n\times n$ matrix $W = [w_{ij}]$ with entries taking real values. A positive value of $w_{ij}$ indicates a positive social influence between $i, j$, where the opinions under the influence become similar. A negative value of $w_{ij}$ means a negative influence and their opinions under influence become dissimilar. In our theoretical study, we consider the case of a complete graph. The evolution model that we introduce works for any network. In our simulations we also evaluate networks and opinion co-evolution on a general graph.
Both the opinions of individuals and the influence matrix are dynamically evolving. Assume that the initial opinion vector is $V(0)$ and the initial influence matrix is $W(0)$. In this paper we assume the initial weight matrix $W(0)$ is symmetric, i.e., $w_{ij}(0)=w_{ji}(0)$, $\forall i, j$.
Define the opinion vector and influence matrix at time $t$, in a discrete-time model, as $V(t)$ and $W(t)$ respectively. We propose the dynamic system governing the evolution of the relationship over integer time:
\begin{equation}\label{eq:discrete-model}
\left\{
\begin{array}{l}
V(t+1) = V(t) + W(t)V(t) \\
W(t+1) = W(t) + V(t) V(t)^T.
\end{array}
\right.
\end{equation}
In the first equation, the opinion of an individual $i$ is shifted by the weighted sum of its neighbors' opinions, with coefficients in the influence matrix $W$. In the second equation, the appraisal value $w_{ij}$ between two individuals $i, j$ is updated by the differences of opinions $v_i, v_j$. If $v_i, v_j$ generally agree (with a positive dot product), $w_{ij}$ moves in the positive direction; otherwise moves in the negative direction.
In a continuous-time model, the dynamics are driven by the following ODE:
\begin{equation}\label{eqn:continuous-model}
\left\{
\begin{array}{l}
V' = WV \\
W' = VV^T.
\end{array}
\right.
\end{equation}
where $V'$ and $W'$ is the coordinate-wise time derivative of $V$ and $W$.
From this point on, we focus on solving the continuous time model.
First we present a couple of basic properties of Equation~(\ref{eqn:continuous-model}). This means we can focus on solving the system defined by Equation~(\ref{eqn:continuous-model}) without losing generality. The detailed proof is provided in Appendix~\ref{subsec:model}.
\begin{restatable}{lemma}{conjugation}
\label{conjugation}
$ $
\begin{enumerate}
\item If $[V(t), W(t)]$ solves Equation~(\ref{eqn:continuous-model}) and $U$ is an orthogonal matrix, then $[U^TV, U^TWU]$ solves the same Equation~(\ref{eqn:continuous-model}) with initial condition $U^TV(0)$ and $U^TW(0)U$. In particular, $W(0)$ is symmetric if and only if $U^TW(0)U$ is.
\item If $W(0)$ is symmetric, then $W(t)$ remains symmetric for all $t$.
\item If $a,b>0$ are positive constants, then the equation
\begin{equation*} \label{modii}
\left\{
\begin{array}{l}
V_1' = aW_1V_1 \\
W_1' = bV_1V^T_1
\end{array}
\right.
\end{equation*}
can be reduced to Equation~(\ref{eqn:continuous-model}) by taking $V=\sqrt{ab}V_1$ and $W=aW_1$.
\end{enumerate}
\end{restatable}
The main objective of this paper is to analyze how this system evolves. In particular, we care about system evolution to reach \emph{sign stability} for $w_{ij}$, $\forall i, j$, and $v_i$, $\forall i$, as well as \emph{structural balance} --
$$\lim_{ t \to T} w_{ij}w_{jk}w_{ki} \geq 0,$$ for all indices $i,j,k$ where $[0, T)$ is the maximum interval on which the solution $W(t)$ exists.
Notice that in the classical structural balance theory, the two types of stable triangles -- with edge signs as either all positive ($+1$)
or have two negative ($-1$) and one positive -- satisfy this property.
The evolution of $W(t)$ and $V(t)$ is described in the following two lemmas.
\begin{lemma} \label{lemma22}
With the co-evolution model as in Equation~(\ref{eqn:continuous-model}), the dynamics of matrix $W$ follows the following Matrix Riccati Type Equation
\begin{equation*}\label{eqn:Riccati1}
W' = WW^T + C,
\end{equation*}
where $C= V(0)V(0)^T - W(0)W(0)^T$ is a symmetric constant $n \times n$ matrix. If $W(0)$ is symmetric, then $W(t)$ satisfies the Riccati equation
\begin{equation}\label{eqn:Riccati}
W' = W^2 + C.
\end{equation}
\end{lemma}
\begin{proof}
We look at $W''$:
\begin{equation*}
\begin{split}
W'' & = (W')' = (VV^T)' = V'V^T + V(V')^T = WVV^T + V(WV)^T = WVV^T + VV^TW^T \\
& =WW' + W'W^T = W(W^T)' + W'W^T = (WW^T)'.
\end{split}
\end{equation*}
In the second last step, we use the equation $W'=(W^T)'$. This is because $W'(t)=V(t)V(t)^T$ is always symmetric. Thus, $W' = WW^T + C$, where $C$ is a constant matrix $C=W'(0)-W(0)W(0)^T =V(0)V(0)^T-W(0)W(0)^T$. Notice that $C$ is always symmetric.
If $W(0)$ is symmetric, then $W(t)$ is always symmetric (by Lemma~\ref{conjugation} (2)) and $WW^T=W^2$.
\end{proof}
Remark that matrix $C$ in our setting is a special symmetric matrix. Specifically, $C+W(0)W(0)^T=V(0)V(0)^T$ has rank one. This property turns out to be useful for characterization of the system behavior.
\begin{lemma}
The evolution of $V(t)$ satisfies
\begin{equation}\label{eqn:opinion_evolution}
V''(t) = 2|V|^2\cdot V - C\cdot V
\end{equation}
\end{lemma}
\begin{proof}
Here, we use $W^2 = W' - C$ (Equation (\ref{eqn:Riccati})), $W' = VV^T$ and $ V' = WV$.
\begin{equation*}
\begin{split}
V'' & = (V')'= (WV)'= W'V+WV'= VV^TV+WWV = |V|^2V+ W^2V = |V|^2V+ (W'-C)V \\ & = |V|^2V + (VV^T-C)V = 2|V|^2V-CV.
\end{split}
\end{equation*}
\end{proof}
\section{Analysis of the Opinion and Social Tie Evolution}
Our analysis has two parts. First we focus on the opinion evolution model (Equation (\ref{eqn:opinion_evolution})). Here we provide analysis of the asymptotic behavior for $V(t)$. Then we study the social tie evolution (Equation (\ref{eqn:Riccati})) for $W(t)$. By solving Riccati equation explicitly for $W(t)$ we are able to provide more detailed characterization of the evolving behavior.
\subsection{Analysis of Opinion Evolution}
By analyzing the opinion evolution (Equation (\ref{eqn:opinion_evolution})), our main result is the following.
\begin{theorem}\label{thm:main_theorem}
Let $[0, T)$ be the maximum interval of existence for the solution $(V(t), W(t))$ of the differential equation in Equation~(\ref{eqn:continuous-model}). For generic initial values $V(0)$ and $W(0)$, either
\begin{enumerate}
\item structural balance condition $\lim_{t \rightarrow T} w_{ij}w_{jk}w_{ki}>0, \forall i,j,k$ holds, or
\item $T = +\infty$, $\lim_{t\rightarrow \infty}|V(t)| = 0$ and
$\lim_{t\rightarrow \infty}V'(t) = 0$.
\end{enumerate}
Furthermore, in the first case, the normalized opinion vector $\frac{V(t)}{|V(t)|}$ converges, i.e., $\lim_{t \to T} \frac{V(t)}{|V(t)|}$ exists.
\end{theorem}
The theorem says that structural balance is always achieved, unless the opinions converge to a zero vector, in which case the entire network becomes neutral. We can consider the second case as a boundary case of structural balance.
The rest of the subsection will focus on proving this theorem. An important observation is that the norm of $V$, $|V(t)|^2$, is a convex function. The detailed proof is in Appendix~\ref{app:opinion}.
\begin{restatable}{lemma}{lemmalength}
\label{lemma:length}
The length function $\varphi(t):= V^T V = |V(t)|^2$ is strictly convex and $\varphi''(t)>0$ unless $V(t)\equiv 0$.
\end{restatable}
Now, let us understand Equation (\ref{eqn:opinion_evolution}) using coordinates. Since the matrix $C$ is symmetric, by the orthogonal diagonalization theorem, there exists an orthogonal matrix
$$U = [\beta_1, \cdots, \beta_n]=[u_{ij}]_{ n \times n}$$
such that
$C\beta_i = a_i \beta_i, i=1, 2, \cdots, n,$
where $a_1, \cdots, a_n$ are eigenvalues of $C$.
By our assumption that $C = V(0)V(0)^T - W(0)W(0)^T$, the eigenvalues $a_1, \cdots, a_n$ are non-positive except for one. So we may assume $a_1 \geq 0$ and $a_2, \cdots, a_n \leq 0$. Because $\beta_1, \cdots, \beta_n$ form an orthonormal
basis of $\mathbb{R}^n$, we can write
\begin{equation*}
V(t) = \sum_{i=1}^n \lambda_i(t)\beta_i = U\lambda, \mbox{ where } \lambda = [\lambda_1, \cdots, \lambda_n]^T.
\end{equation*}
This implies that $V'(t) = \sum_{i=1}^n \lambda_i'(t)\beta_i$, $V''(t) = \sum_{i=1}^n\lambda_i''(t) \beta_i$, $|V(t)|^2 = \sum_{j=1}^n \lambda_j^2(t)$ and $C\cdot V = \sum_{i=1}^n a_i \lambda_i \beta_i$.
Therefore, Equation (\ref{eqn:opinion_evolution}) becomes
\begin{equation*}
\sum_{i=1}^{n} \lambda_i''(t) \cdot \beta_i = \sum_{i=1}^n (2(\sum_{k=1}^n \lambda_k^2) - a_i) \lambda_i \cdot \beta_i
\end{equation*}
Since $\beta_1, \cdots, \beta_n$ are independent, we obtain the system of ODE with $\lambda = [\lambda_1, \cdots, \lambda_n]^T$ in the form
\begin{equation}\label{eqn:lambda}
\lambda_i''(t) = (2\sum_{k=1}^n \lambda_k^2 - a_i) \lambda_i(t), i=1, 2, \cdots, n.
\end{equation}
Denote $W = [w_{ij}(t)]$. Then $W' = V\cdot V^T$ implies
$$W' = U\cdot \lambda \cdot \lambda^T \cdot U^T$$
Therefore, $w'_{ij}(t)=\sum_{k,l=1}^n u_{ik}u_{jl}\lambda_{k}\lambda_l$ and $w_{ij}(t) = \sum_{k,l=1}^n (\int_0^t \lambda_k(s)\cdot \lambda_l(s) ds) u_{ik}u_{jl} + w_{ij}(0)$.
Our next goal is to show the following proposition,
\begin{restatable}{proposition}{propgrowth}
\label{prop:growth}
If $T < + \infty$ or if $T = + \infty$ and $\lim_{t\rightarrow T} |V(t)| = L > 0$, then there exists one term $\psi_{hh}$ among $\psi_{kl}(t) = \int_{0}^t \lambda_k(s) \lambda_l(s) ds$ which has the maximum growth rate as $t \rightarrow T$ and $\lim_{t\rightarrow T} \psi_{hh}(t) = + \infty$.
\end{restatable}
Assuming the proposition~\ref{prop:growth}, Theorem~\ref{thm:main_theorem} follows. Indeed, the leading term in $w_{ij}(t)$ is $u_{ih}u_{jh}\psi_{hh}$ as $t \rightarrow T$. Therefore the sign of $w_{ij}$ is the same as the sign of $u_{ih}u_{jh}\psi_{hh}$. The leading term of $w_{ij}w_{jk}w_{ki}$ as $t \to T$ is
$$ u_{ih}^2 u_{jh}^2 u_{kh}^2 \psi_{hh}^2 \geq 0.$$
This shows that structural balance occurs eventually for generic initial values. Here the generic condition is used to ensure that all entries $u_{ij}$ of the orthogonal matrix $[u_{ij}]$ are not zero and $\psi_{hh}$ is the unique term with the maximum growth rate. Finally, if $T=\infty$ and $\lim_{t \to \infty} |V(t)|=0$, then by Corollary \ref{cor:v'}, $\lim_{t \to \infty} V'(t)=0$.
The proof for proposition~\ref{prop:growth} is fairly technical and can be found in Appendix~\ref{app:opinion}.
\subsection{Analysis of Social Tie Evolution}
The analysis on the evolution of $V$ in the previous section shows convergence. To further understand the community formed at the limit of convergence, we need to study the evolution of $W$.
The following theorem explains the reason behind the appearance of structure balance when at least one eigenvalue of $W(t)$ tends to infinity. This was proved in~\cite{Marvel2009-lx}. We include the statement here and the proof in Appendix~\ref{subsec:structural} for completeness.
\begin{restatable}[\cite{Marvel2009-lx}]{theorem}{thmconvergence}
\label{thm:convergence}
\label{kl} Suppose $W(t)$, $t \in [0, T)$, is a continuous family of symmetric matrices
such that
\begin{enumerate}
\item $W(t)$ has a unique largest eigenvalue, denoted by $\beta_1(t)$, which tends to infinity as $t \to T$,
\item all eigenvectors of $W(t)$ are time independent, and
\item all components of the $\beta_1(t)$ eigenvector are not zero.
\end{enumerate}
Then
$$ w_{ij}w_{jk}w_{ki} > 0,\, \forall i, j, k, i\neq j, j\neq k, i\neq k,$$
for all time $t$ close to $T$, i.e., the structural balance of the whole graph is satisfied.
If (2) does not hold, we have $$ w_{ij}w_{jk}w_{ki} \geq 0, \forall i, j, k, i\neq j, j\neq k, i\neq k. $$
\end{restatable}
Furthermore, the two antagonistic communities are given by $U^+=\{i \in V|u_i>0\}$ and $U^-=\{i \in V| u_i<0\}$ where $u=[u_1, ..., u_n]^T$ is a $\beta_1(t)$ eigenvector. All edges connecting vertices within the same community are positive while edges connecting two vertices in different communities are negative. When one of $U^+, U^-$ is empty, the network has only one community.
The model in \cite{Marvel2009-lx} is the Riccati equation $W'=W^2$, whose solution is $W(t)=W(0)(1-W(0)t)^{-1}$. As a consequence, Marvel et. al. \cite{Marvel2009-lx} showed that structure balance occurs in the Riccati equation $W'=W^2$ for generic initial parameter $W(0)$ with a positive eigenvalue at finite time. Our model strictly generalizes the previous model and consider how the initial opinions may influence the system evolution. In the following we show how to solve the general Riccati equation and also when an eigenvalue goes to infinity.
With most of the details in the Appendix, we carry out rigorous analysis of the general form of the matrix Riccati equation as stated below.
\begin{equation}
\label{eqn:Evolution}
\left\{
\begin{array}{rl}
W' & = W^2 + C \\
W(0) & = B.
\end{array}
\right.
\end{equation}
For general matrices $B, C$ we can solve for $W(t)$ as shown in the following theorem. The proof details can be found in Appendix~\ref{subsec:general-Riccati}.
\begin{restatable}{theorem}{mainth}
\label{mainth}
The solution $W(t)$ is given by the explicit formula that $W(t) = -Z(t)\cdot Y(t)^{-1}$, where
\begin{eqnarray}
Y(t) &= & \sum_{n=0}^{\infty} \frac{(-1)^n t^{2n} C^n}{(2n)!} + \sum_{n=0}^{\infty}\frac{(-1)^{n+1}t^{2n+1}C^nB}{(2n+1)!} \\
Z(t) &=& \sum_{n=0}^{\infty}\frac{(-1)^{n+1}t^{2n}C^nB}{(2n)!} + \sum_{n=0}^{\infty} \frac{(-1)^{n+1} t^{2n+1} C^{n+1}}{(2n+1)!}.
\end{eqnarray}
\end{restatable}
In our co-evolution model, $B=W(0)$ is assumed to be symmetric. Thus $C$ is also symmetric. This allows us to simplify the solution further, as shown in Appendix~\ref{subsec:socialtie}.
Then we analyze a special case when $BC=CB$. In this case we can characterize the conditions when structural balance is guaranteed to occur, with details in Appendix~\ref{subsec:structural}, \ref{subsec:BCequalCB}, and \ref{subsec:structural-commute}.
Specifically, using a basic fact that two commuting symmetric matrices can be simultaneously orthogonally diagonalized~\cite{Hoffman1971-bc}, we can get the following theorem where the conditions of the eigenvalues of $B, C$ for structural balance are characterized:
\begin{restatable}{theorem}{thmmain}
\label{thm:main}
Suppose $W(t)$ solves the Riccati equation $W'=W^2+C$, $W(0)=B$ where $B, C$ are symmetric with $BC=CB$.
Then eigenvalues of $W(t)$ converge to elements in $(-\infty, \infty]$ as $t \to T;$ meanwhile there is sign stability, i.e., $\lim_{t \to T} w_{ij}(t) \in [-\infty, \infty]$ exists for all $i,j$.
If $U$ is an orthogonal matrix such that
\begin{equation*}
\begin{split}
U^TCU & = \diag(a_1^2, \cdots, a_k^2, -d_1^2, \cdots, -d_l^2, 0, \cdots, 0)\\
U^TBU & = \diag(\lambda_1, \cdots, \lambda_k, \mu_1, \cdots, \mu_l, \delta_1, \cdots, \delta_h).
\end{split}
\end{equation*}
where $a_i, d_j > 0$,
then $W(t)$ is given by the following explicit function, \begin{equation}\label{eqn:W}
\begin{aligned}
W(t) = & U\cdot \diag(\frac{a_1 \sin{(a_1 t)} + \cos{(a_1 t)}\lambda_1}{\cos{(a_1 t)}-\frac{1}{a_1}\sin{(a_1 t)}\lambda_1}, \cdots, \frac{a_k \sin{(a_k t)}) + \cos{(a_k t)}\lambda_k}{\cos{(a_k t)}-\frac{1}{a_k}\sin{(a_k t)}\lambda_k},\\
& -\frac{d_1 \sinh{(d_1 t)}-\cosh{(d_1 t)}\mu_1}{\cosh{(d_1 t)} - \frac{1}{d_1}\sinh{(d_1 t)}\mu_1}, \cdots, -\frac{d_l \sinh{(d_l t)}-\cosh{(d_l t)}\mu_l}{\cosh{(d_l t)} - \frac{1}{d_l}\sinh{(d_l t)}\mu_l}, \\
& \frac{\delta_1}{1 - t\delta_1}, \cdots, \frac{\delta_h}{1 - t\delta_h}) \cdot U^T.
\end{aligned}
\end{equation}
Further, structural balance
$$ \lim_{t \to T} w_{ij}w_{jk}w_{ki} \geq 0$$
occurs in the finite time for $W(t)$ if $W(t)$ has an unique largest eigenvalue and one of the following conditions holds:
\begin{enumerate}
\item There exists some $\delta_i>0$,
\item There exists some $ a_i>0$,
\item there exists some $\mu_i > d_i$.
\end{enumerate}
\end{restatable}
In our co-evolution model, $BC=CB$ happens when $V(0)$ is a eigenvector of $W(0)$, an interesting initial condition.
To see that, recall $B=W(0)$, $C= V(0)V(0)^T - W(0)W(0)^T$, and $W(0)=W(0)^T$. To check if $BC=CB$, we just need to check if $W(0)V(0)V(0)^T=V(0)V(0)^TW(0)$ and apply the following Lemma (Proof in Section~\ref{subsec:structural-commute}).
\begin{restatable}{lemma}{lemmaBCcommute}
\label{lemma:BCcommute}
Suppose $A$ is a symmetric matrix and $v$ is a non-zero column vector. Then
$A vv^T=vv^TA$ is equivalent to $Av=\alpha v$, i.e., $v$ is an eigenvector of $A$.
\end{restatable}
Further, the equation in our co-evolution model, i.e., Equation~(\ref{eqn:Riccati}), satisfies $C+B^2=V(0)V(0)^T$. Notice that the right-hand side $V(0)V(0)^T$ is an $n
\times n$ matrix with rank one. This property actually ensures that the conditions characterized in Theorem~\ref{thm:main} are met and thus structural balance is guaranteed. At the same time, the convergence rate is $O(\frac{1}{|T - t|})$, which is proved by Lemma~\ref{lemma:sin} in Appendix~\ref{subsec:BCequalCB}.
\begin{restatable}{corollary}{corcomute}
\label{cor:comute}
For Equation~(\ref{eqn:continuous-model}), if $V(0)\neq 0$ is an eigenvector of $W(0)$, then $V(t)$ remains to be an eigenvector of $W(t)$ for all $t$ and structural balance must occur in finite time for $W(t)$.
\end{restatable}
If $V(0)=0$, the system stays at the fixed point with $V$ remaining zero and the weight matrix unchanged.
The case when $V(0)$ is an eigenvector of $W(0)$ includes a few interesting cases in practice. When $W(0)=0$ or $W(0)=I$, this models a group of individuals that start as complete strangers with uniform self-appraisals. Their non-homogeneous initial opinions $V(0)$ may drive the network to be segmented over time. Finally the fact that $V(t)$ remains an eigenvector of $W(t)$ for all $t$ follows from Equation (\ref{eqn:WWW}) in Appendix C.
We conjecture that even in the general case (when $V(0)$ is not necessarily an eigenvector of $W(0)$) the limit vector $\lim_{t \to T} V(t)/|V(t)|$ is an eigenvector of the limit tie relation matrix $\lim_{t \to T} W(t)/|V(t)|$. This is supported by our numerical evidences and Corollary \ref{cor:wv} which says that $\lim_{t \to T} V(t)/|V(t)|$ is an eigenvector of $\lim_{t \to T} (W(t)/|V(t)|)^2$.
\section{Simulations}
In this section, we provide simulation results to accompany our theoretical analysis of the co-evolution model.
We also present simulation results on general graphs and real world data sets to understand the behavior of network evolution.
Here is a brief summary of observations from simulations. The details can be found in the Appendix.
\begin{itemize}
\item Except a few carefully crafted cases\footnote{For example, if $W(0) = B = \diag(-\frac{1}{a}, -\frac{1}{a}, \cdots, -\frac{1}{a})$ and we use the dynamic update rule $v_i(1) = v_i(0) + a\cdot w_{ii}(0)v_i(0) = 0$, for all $1 \leq i \leq n$. After one iteration, all node opinions become $0$. After that, the opinions and weights do not change anymore. } that make the opinion vector to be zero, strict structural balance is always reached, regardless of whether the graph is complete or general, whether $B, C$ commute or not, or whether $W(0)$ is symmetric or as a general matrix. An example is shown in Figure~\ref{fig:heatmap}.
\item In general, we observed through simulations that the number of iterations to convergence is inversely proportional to the magnitude of initial opinions and the edge density in the graph.
\item In two real world data sets (the Karate club and a political blog data set), a few initially planted polarized opinions can successfully predict the ground truth community structure with high accuracy. See Figure~\ref{fig:application}.
\end{itemize}
\section{Conclusion and Future Work}
In this paper, we have provided a co-evolution model for both opinion dynamics and appraisal dynamics. We provided solutions to the system and rigorously characterized how the stable states depend on the initial parameters.
There are a few follow-up problems that remain open, for example,
when the social ties are directional/asymmetric, when the network is not a complete graph, and when each agent has an $m$-dimensional opinion vector. We include some discussion and conjectures on these cases in Appendix~\ref{subsec:general} and consider this as interesting future work.
\begin{figure}[h!]
\centering
\includegraphics[width=0.9\columnwidth]{Figure/heatmap_case0.pdf}
\caption{The weight matrix in evolution. The $x$ and $y$ axis show vertex indices. The cell at $(i, j)$ represents the edge weight between node $i$ and node $j$ with color showing edge weight. The first plot is the initial edge weights, which are assigned random values. The second plot shows the weight matrix after $15$ iterations. Patterns start to show up with two diagonal blocks showing positive values and the off-diagonal blocks with negative values. The last plots is the weight matrix at convergence where the first $6$ nodes are in one community and the other nodes are in a different community. Edges within communities have positive weights and edges between communities have negative weights. }
\label{fig:heatmap}
\end{figure}
\begin{figure}[h!]
\centering
\subfigure[Initial Karate club graph]{
\centering
\includegraphics[width=0.35\columnwidth]{Figure/Karate_Club_Initial.pdf}
\label{fig:karate_1}
}
\subfigure[Separated communities results]{
\centering
\includegraphics[width=0.35\columnwidth]{Figure/Karate_Club_Separate.pdf}
\label{fig:karate_2}
}
\subfigure[Initial political blogs network]{
\centering
\includegraphics[width=0.28\columnwidth]{Figure/blog_initial.pdf}
\label{fig:blog_1}
}
\hspace{1cm}
\subfigure[Separated communities results]{
\centering
\includegraphics[width=0.36\columnwidth]{Figure/blog_separated.pdf}
\label{fig:blog_2}
}
\caption{Community detection in two real-world data sets. The color of vertices represents their ground truth opinions. Initially, only a small number of seeds are assigned their true opinions and other nodes start with initial opinions of $0$. All edges start with a small positive weight. As the network converges, the edges with negative weights are removed. The communities discovered as shown in the right column faithfully reflect the ground truth. In the first experiment (a, b), the node $\#0$ and the node $\#33$ are assigned opposite initial opinions. It nearly predicts the same division as in the ground truth except for two nodes $\#8$ and $\#19$ which are somewhat ambiguous. In the second experiment (c, d), $20\%$ random nodes are assigned initial opinions according to the ground truth. The prediction achieves an average accuracy of $97.21\%$ compared with the ground truth.}
\label{fig:application}
\end{figure}
\newpage
\bibliographystyle{SIAM}
\section{Introduction}
We live in a continuously changing world in which social interactions dynamically shape who we are, how we view the world and what decisions to make. Various social processes, naturally intertwined, operate on both the properties of individuals and social ties among them. Social influence, for example, describes how people's behaviors, habits or opinions are shifted by those of their neighbors.
Social influence leads to homophily ( similarity of node attributes between friends) and leaves traces in the network structure such as high clustering coefficient and triadic closure (there are likely social ties among one's friends).
Social influence and homophily, however, do not fully interpret the global network structure. One of the widely observed structural properties in social networks is the community structure. Nodes within the same community are densely connected and nodes from different communities are sparsely connected. Community detection is an important topic in social network analysis and has been investigated extensively~\cite{Pares2017-yq,Yang2016-gn,Newman2004-og,Newman2004-js,Newman2004-jn,Guimera2004-vm,Zhang2014-vs,Von_Luxburg2007-wb,Newman2006-sa,Hastings2006-sn,Karrer2011-ms}. But why does community structure emerge and become a persistent feature? Are there social processes that encourage or maintain the community structure?
In the literature, there have been a lot of studies of opinion dynamics, where people's behaviors, habits or opinions are influenced by those of their neighbors. Network models that capture social influence, such as French-DeGroot model~\cite{French1956-bk, Antal2005-lu}, Friedkin-Johnsen model~\cite
{Friedkin1990-wl},
Ku$\l$akowski et al. model~\cite{Kulakowski2005-is, Marvel2011-we} naturally converge to global consensus. Actually it seems to be non-trivial to create non-homogeneous outcomes in these models, while in reality social groups often fail to reach consensus and exhibit clustering of opinions and other irregular behaviors. Getting a model that may produce community cleavage~\cite{Friedkin2015-qc} or diversity~\cite{Kurahashi-Nakamura2016-ys} often requires specifically engineered or planted elements in a rather explicit manner. For example, bounded confidence models~\cite{Mas2010-za,Krause2000-no,Hegselmann2002-ud,Deffuant2000-pb}
limit social influence only within pairs with opinions sufficiently close.
Other models introduce stubborn nodes whose opinions remain unchanged throughout the process.
The extreme case of community structure is dictated by structural balance~\cite{Heider1946-bt, Heider1982-rg,Cartwright1956-fc, davis1967clustering}, a common phenomenon observed in many social relationships.
The notion was first introduced in a seminal paper by Heider in the 1940s in social psychology. It describes the stability of human relations among three individuals when there are only two types of social ties: positive ties describe friendship (or sharing common opinions) and negative ties describe hostility (or having opposite opinions).
Heider's axioms state that among three individuals, only two kinds of triangles are stable: the triangles where all three ties are positive, indicating all three individuals are mutual friends; and the triangle with two negative edges and one positive edge, describing the folklore that ``the enemy of your enemy is your friend.''
The other two types of triangles (e.g., a triangle of one negative tie and two positive ties, or three mutually hostile individuals) incur emotional stress or are not strategically optimal. See Figure~\ref{fig:structural-balance}.
Thus they are not socially stable -- over time, they break and change to the stable ones. In fact, the structural balance theory not only describes the local property in a signed complete network, but also predicts the global network behavior -- the only type of network in which all triangles are stable must have the nodes partitioned into two camps, inside each of which the edges are all positive and between them the edges are negative (one of the camps can be empty).
\begin{figure}[htbp]
\centering
\includegraphics[width=0.5\columnwidth]{structural-balance}\vspace*{-3mm}
\caption{Structural balance theory: the first two triangles are stable while the last two are not.}\label{fig:structural-balance}
\end{figure}
The structural balance theory only describes the equilibrium state and does not provide any model on evolution or dynamics -- what happens when a network has unstable triangles? Follow up work on structural balance dynamic models~\cite{Antal2005-lu,Marvel2011-we, Kulakowski2005-is,cisnerosvelarde2019structural, teixeira2017emergence} update the sign/weight of an edge $(i, j)$ towards a more balanced triangle by considering the sign/weights of neighboring edges $(i, k)$ and $(k, j)$ in a triangle $\triangle i j k$.
These two threads of research, opinion dynamics and structural balance dynamics,
are currently orthogonal to each other.
In opinion dynamics, opinions on vertices are influenced by each other through edges but researchers struggle to maneuver the model to create community cleavage. In structural balance dynamics, edge weights are dynamically updated to meet structural balance, which is explicitly coded as the projected outcome and optimization objective. Holme and Newman~\cite{holme2006nonequilibrium} presented a simple model of this combination without any theoretical analysis. In this paper, we propose co-evolution models for both dynamics of opinions (people's view on a variety of topics) and dynamics of social appraisals (the approval or disapproval towards each other). We show that by using two simple rules, node opinions evolve into opposing communities and structural balance naturally emerges.
\subsection{Our Contribution}
In this paper, we consider the co-evolution of opinions via social influence and tie strength/appraisal/sign updates by discrepancies of node opinions. We assume a set of $n$ individuals where individual $i$ has an opinion $v_i \in \mathbb{R} $, and an appraisal matrix $W=[w_{ij}]$, where $w_{ij}$ is interpreted as the influence from individual $j$ on individual $i$. Here $w_{ij}$ does not need to be non-negative and takes values in $\mathbb{R}$. We consider two update rules:
\begin{itemize}
\item \emph{Opinion dynamics:} The opinion of $i$ is updated as a linear combination of its current opinion and the weighted sum of neighbors' opinions with coefficients in matrix $W$.
\item \emph{Appraisal dynamics:} The appraisal $w_{ij}$ is updated as a linear combination of its current value and the agreement of the opinion of $i$ and $j$. The agreement of opinion $v_i$ and $v_j$ is taken as the dot product $v_i
\cdot v_j$.
\end{itemize}
The opinion dynamics model is similar to classical social influence models such as the DeGroot model~\cite{French1956-bk} and Friedkin-Johnsen model~\cite{Friedkin1990-wl}, except that the edge weight matrix $W$ is dynamic as well. The model for appraisal dynamics is motivated by tie dynamics that can be traced back to Schelling's model of residential segregation~\cite{Schelling1971-eb}. In modern society, tie changes on Facebook~\cite{Sibona2014-ni} and Twitter~\cite{Xu:2013:SBT:2441776.2441875,kivran2011impact} can be easily triggered by disparities on their opinions~\cite{John2015-az,Sibona2014-ni}, especially among the users who are most politically engaged.
Our goal is to analyze the evolution and in particular, the conditions that lead to \emph{sign stability} and \emph{structural balance} -- for any triangle with individual $i, j, k$, $w_{ij}w_{jk}w_{ki}\geq 0$. We call a network to reach strictly structural balance if $w_{ij}w_{jk}w_{ki}> 0$, $\forall i, j, k$.
A structurally balanced network has two possible states: \emph{harmony}, when all edges are positive; and \emph{polarization}, when there are two communities with only positive ties within each community and negative ties across the two communities.
We show that with our dynamics model, $W(t)$ evolves by the following matrix Riccati Equation~\cite{Abou-Kandil2003-um} $W' = WW^T + C$, where $C= V(0)V(0)^T - W(0)W(0)^T$ is a symmetric constant $n \times n$ matrix if $W(0)$ is. Further the opinion vector $V(0)$ evolves by the differential equation $V''(t)=2|V|^2 \cdot V-C\cdot V$.
Our main result is to analyze the asymptotic behavior of $V(t)$ and $W(t)$ and prove structural balance at the limit. Our results can be summarized in the following:
\begin{enumerate}
\item By analyzing the evolving equation for $V(t)$, we show that either the network reaches strict structural balance or $|V(t)|\rightarrow 0$. To prove this limit behavior, one crucial observation is that the length of the opinion vector $|V(t)|^2$ is strictly convex, unless $V(t)\equiv 0$.
\item We show how to solve the general matrix Riccati equation $W'=W^2+C$, $W(0)=B$, for any parameter $B, C$. In particular, the eigenvector corresponding to the largest eigenvalue of $W(t)$ encodes the two communities formed in the network; those with a positive value in the eigenvector versus those with a negative value in the eigenvector. As a byproduct of the analysis of $W(t)$, we also show that when $V(0)$ is an eigenvector of the initial matrix $W(0)$, $V(t)$ remains to be an eigenvector of $W(t)$ for and structural balance must occur in finite time. In this case we can write down exact evaluations on the blowup time and the rate convergence.
\end{enumerate}
The evolving of $W(t)$ by $W' = WW^T + C$ is strictly a generalization of the dynamic structural balance model by Marvel et al. ~\cite{Marvel2009-lx}. Their model captures the dynamics of edge appraisals by $W' = W^2$ and does not consider user opinions. The behavior of our model becomes much more complex, as the initial user opinions are factored into the system dynamics through the matrix $C$.
We also performed extensive simulations with different initial conditions and graph topology. We examined the network evolution on the final convergence state (harmony v.s., polarization) and convergence rate. We observed that a higher network density or a higher initial opinion magnitude, empirically, speeds up the convergence rate.
We tested our dynamic model on two real world graphs (Karate club graph and a political blog graph~\cite{adamic2005political}). Both networks are known to have two communities with opposing opinions. A small number of seeds, randomly selected, are assigned with ground truth opinions and all other nodes start neural. The network evolution can successfully detect the final community structure and recover the ground truth with good accuracy. Apart from being a transparent and explainable label propagation algorithm, the model sheds lights on why community structure emerges and becomes a widely observed, sustainable property in complex networks.
\section{Related Work}
\subsection{Opinion Dynamics and Social Influence}
Opinions in a sociological viewpoint capture the cognitive orientation towards issues, events or other subjects, and mathematically represent signed attitudes or certainties of belief. Opinion dynamics is an extensively studied topic about how opinions change in a network setting with social influence from neighbors.
One of the first models of opinion dynamics, French-DeGroot model~\cite{French1956-bk, Antal2005-lu}, considers a discrete time process of opinion $\{v_1, v_2, \cdots, v_n\}$ for a group of $n$ individuals. An edge $(i, j)$ carries a non-negative weight $w_{ij}
\geq 0$. The opinion of node $i$ at time $t+1$ is updated by
$$v_i(t+1)=\sum_{j}w_{ij}v_j(t).$$
The weight matrix $W=[w_{ij}]$ is taken as a stochastic matrix. The dynamics can be written as $V(t+1)=WV(t)$.
The continuous-time counterpart is called the Abelson's model~\cite{Abelson1964-ny} where the dynamics is defined by
\begin{equation}\label{ref:eqn-abelson}
\frac{dV(t)}{dt}=-LV(t),
\end{equation}
where $V(t)=(v_1(t), v_2(t), \cdots v_n(t))^T$ and $L$ is the Laplacian matrix $L=I-W$.
Opinions following the French-DeGroot model or the Abelson's model typically converge unless the network is disconnected or there are stubborn nodes (with $w_{ii}=1$).
The most popular opinion dynamics model is probably the Friedkin-Johnsen model~\cite{Friedkin1990-wl}. It takes a stochastic matrix $W$ as the influence model, and a diagonal matrix $\Lambda=\diag(\lambda_1, \cdots, \lambda_n)$ where $\lambda_i\in [0, 1]$ is the susceptibility of individual $i$ to social influence. The opinions of the individuals are updated by the following process
$$V(t+1)=\Lambda W V(t)+(I-\Lambda)u,$$
where $u$ is a constant vector of the individuals' prejudices and is often taken as the initial opinion $V(0)$. When $\Lambda=I$ the model turns to French-DeGroot model.
Most of the literature on these two models assume a fixed weight matrix $W$ and prove asymptotic convergence under favorable assumptions~\cite{Friedkin2011-et}. There have been extensions when $W$ is a time-varying matrix, but $W(t)$ is still independent of $V(t)$ (e.g.,~\cite{Blondel2005-uz}).
A significant deviation from the above family considers a time-varying matrix $W$, by incorporating the principle of homophily, that similar individuals interact more than dissimilar ones.
This is called the bounded confidence model~\cite{Mas2010-za}. A few such models (Hegselmann-
Krause (HK) model~\cite{Krause2000-no,Hegselmann2002-ud}, Deffuant and Weisbuch~\cite{Deffuant2000-pb}) introduced a fixed range of confidence $d>0$: individual $i$ is insensitive to opinions that fall outside its confidence set $I_i=[v_i -d, v_i+d]$, and the opinion $v_i$ is only updated by the average opinion of those opinions within $I_i$. In other words, the matrix $W$ is derived from the set of opinions at time $t$ and thus co-evolves with the opinions. This model generates situations when the individuals converge to a set of different opinions, and has been extended to the multi-dimensional setting~\cite{Hegselmann2002-ud}.
All models above have only considered the case of positive influence, that the interactions of individuals change their opinions \emph{towards} each other. It has been argued in both social settings and many physical systems that there is negative or repulsive influence (repulsive interactions in biological systems~\cite{Coyte2015-ry} or collision avoidance in robot swarm formation~\cite{Romanczuk2012-sg}). Abelson~\cite{Abelson1967-nn} argued that any attempt to persuade a person may sometimes shift his or her opinion away from the persuader's opinion, called the boomerang effect~\cite{Allahverdyan2014-ja, Hovland1953-hc}. Bhawalkar et al.~\cite{bhawalkar2013coevolutionary} presented game-theoretic models of opinion formation in social networks by maximizing agreement with friends weighted by the strength of the relationships. Thus interactions between individuals with similar opinions move their opinions closer; interactions between individuals with opinions that are very different shift their opinions away from each other. Here the edge weights are fixed. Many models have included negative ties but they are still awaiting rigorous analysis~\cite{Salzarulo2006-ag, Baldassarri2007-zs, Macy2003-wq, Mark2003-it, he2018evolution}.
The most notable work in this direction is by Altafini~\cite{Altafini2013-kb, Altafini2012-lr}. The model starts to be similar to Abelson's model in Equation~(\ref{ref:eqn-abelson}) with a \emph{fixed} weight matrix $W$ except that the weights in $W$ do not need to be non-negative. The system is shown to be Lyapunov stable~\cite{Proskurnikov2016-hc} and studies have focused on the initial conditions of $W$ for the system to converge to harmony or polarization. The matrix $W$ is assumed to be either static or, in very recent studies~\cite{Proskurnikov2017-lr, Proskurnikov2016-hc,Hendrickx2014-qy}, time-varying (but independent of the opinion changes).
The negative influence is closely related to signed networks and structural balance theory, which will be discussed next.
\subsection{Structural Balance and Signed Networks}
Notice that the structural balance theory only describes the equilibrium state and does not provide any model on evolution or dynamics -- what happens when a network has unstable triangles? Follow up work proposed a few models, that can be categorized by discrete models or continuous models -- depending on whether the appraisal on a social tie takes binary values $\{+1, -1\}$ or a real number.
Antal et al.~\cite{Antal2005-lu} considered the discrete model where the sign of an edge is flipped if this produces more balanced triangles than unbalanced ones. The balanced graph is clearly a stable state but the dynamics also has many local optimals called jammed states~\cite{Antal2005-lu,Marvel2009-lx}. Andreida et al.~\cite{teixeira2017emergence} determine the sign of an edge according to the sign of the other two edges in the triangles to make more triangles balanced. Samin et al.~\cite{aref2020modeling} try to remove the minimum edges to make the graph balanced which is NP-hard problem.
In the continuous setting, the influence-based model~\cite{Marvel2011-we, Kulakowski2005-is} describes an influence process on a complete graph, in which an individual $i$ updates her appraisal of individual $j$ based on what others positively or negatively think of $j$. In other words, let us use $w_{ij}$ to describe the type of the social tie between two individuals $i, j$. $w_{ij}>0$ if $i, j$ are friends and $<0$ if they feel negative about each other. The absolute value of $w_{ij}$ describes the magnitude of the appraisal. The update rule says that the update to $w_{ij}$ will take value
\begin{equation}\label{eq:dynamic-w}
\frac{d w_{ij}}{dt}=\sum_{k}w_{ik}\cdot w_{kj}.
\end{equation}
Specifically, when $w_{ik}$ and $w_{kj}$ have the same sign, the value of $w_{ij}$ is guided to the positive direction; when $w_{ik}$ and $w_{kj}$ have opposite signs, the value of $w_{ij}$ is guided to the negative direction. Both cases try to enforce a balanced triangle on $\{i, j, k\}$. Empirically, it has been observed that for essentially any initial value of $W$, as the matrix where the $(i, j)$ element is $w_{ij}$, the system reached a balanced pattern in finite time. In~\cite{Marvel2011-we}, Marvel et al. proved that for a random initial matrix $W$ the system reaches a balanced matrix in finite time with probability converging to $1$ as $n \rightarrow \infty$. They also characterized the converged value and its relationship to the initial value.
In a recent paper~\cite{cisnerosvelarde2019structural}, Cisneros-Velarde et al. considered a \emph{pure-influence} model, where the self-appraisal (such as $w_{ii}$) is taken out of Equation~(\ref{eq:dynamic-w}) to be a more faithful interpretation of Heider's structural balance.
They proved that when $W$ is symmetric their continuous-time dynamic model is exactly the gradient flow of an energy function called \emph{dissonance}~\cite{Marvel2009-lx}, defined as
\begin{equation*}
-\sum_{[ij],[jk],[ki] \in E} w_{ij} \cdot w_{jk} \cdot w_{ki}.
\end{equation*}
Dissonance characterizes the degree of violation to Heider's structural balance axioms in the current network. The global minimum of this energy function corresponds to signed networks that satisfy structural balance in the case of real-values appraisals.
When the initial matrix $W$ is symmetric the authors also provided characterizations of the critical points of the dissonance function (aka the equilibrium states of the dynamic model).
\medskip
The discussions of opinion dynamics and dynamics with structural balance, so far, have focused on node opinion changes or link appraisal changes, separately. There is little work on combining both dynamics into a co-evolving model, which is the focus of this paper.
\section{Co-Evolution Model}
Suppose there are $n$ individuals, each one with its own opinion $v_i \in \mathbb{R}$. Define the opinion vector $V = (v_1, v_2, \dots, v_n )^{T} \in \mathbb{R}^{n}$.
The influence model among the $n$ individuals is characterized as an $n\times n$ matrix $W = [w_{ij}]$ with entries taking real values. A positive value of $w_{ij}$ indicates a positive social influence between $i, j$, where the opinions under the influence become similar. A negative value of $w_{ij}$ means a negative influence and their opinions under influence become dissimilar. In our theoretical study, we consider the case of a complete graph. The evolution model that we introduce works for any network. In our simulations we also evaluate networks and opinion co-evolution on a general graph.
Both the opinions of individuals and the influence matrix are dynamically evolving. Assume that the initial opinion vector is $V(0)$ and the initial influence matrix is $W(0)$. In this paper we assume the initial weight matrix $W(0)$ is symmetric, i.e., $w_{ij}(0)=w_{ji}(0)$, $\forall i, j$.
Define the opinion vector and influence matrix at time $t$, in a discrete-time model, as $V(t)$ and $W(t)$ respectively. We propose the dynamic system governing the evolution of the relationship over integer time:
\begin{equation}\label{eq:discrete-model}
\left\{
\begin{array}{l}
V(t+1) = V(t) + W(t)V(t) \\
W(t+1) = W(t) + V(t) V(t)^T.
\end{array}
\right.
\end{equation}
In the first equation, the opinion of an individual $i$ is shifted by the weighted sum of its neighbors' opinions, with coefficients in the influence matrix $W$. In the second equation, the appraisal value $w_{ij}$ between two individuals $i, j$ is updated by the differences of opinions $v_i, v_j$. If $v_i, v_j$ generally agree (with a positive dot product), $w_{ij}$ moves in the positive direction; otherwise moves in the negative direction.
In a continuous-time model, the dynamics are driven by the following ODE:
\begin{equation}\label{eqn:continuous-model}
\left\{
\begin{array}{l}
V' = WV \\
W' = VV^T.
\end{array}
\right.
\end{equation}
where $V'$ and $W'$ is the coordinate-wise time derivative of $V$ and $W$.
From this point on, we focus on solving the continuous time model.
First we present a couple of basic properties of Equation~(\ref{eqn:continuous-model}). This means we can focus on solving the system defined by Equation~(\ref{eqn:continuous-model}) without losing generality. The detailed proof is provided in Appendix~\ref{subsec:model}.
\begin{restatable}{lemma}{conjugation}
\label{conjugation}
$ $
\begin{enumerate}
\item If $[V(t), W(t)]$ solves Equation~(\ref{eqn:continuous-model}) and $U$ is an orthogonal matrix, then $[U^TV, U^TWU]$ solves the same Equation~(\ref{eqn:continuous-model}) with initial condition $U^TV(0)$ and $U^TW(0)U$. In particular, $W(0)$ is symmetric if and only if $U^TW(0)U$ is.
\item If $W(0)$ is symmetric, then $W(t)$ remains symmetric for all $t$.
\item If $a,b>0$ are positive constants, then the equation
\begin{equation*} \label{modii}
\left\{
\begin{array}{l}
V_1' = aW_1V_1 \\
W_1' = bV_1V^T_1
\end{array}
\right.
\end{equation*}
can be reduced to Equation~(\ref{eqn:continuous-model}) by taking $V=\sqrt{ab}V_1$ and $W=aW_1$.
\end{enumerate}
\end{restatable}
The main objective of this paper is to analyze how this system evolves. In particular, we care about system evolution to reach \emph{sign stability} for $w_{ij}$, $\forall i, j$, and $v_i$, $\forall i$, as well as \emph{structural balance} --
$$\lim_{ t \to T} w_{ij}w_{jk}w_{ki} \geq 0,$$ for all indices $i,j,k$ where $[0, T)$ is the maximum interval on which the solution $W(t)$ exists.
Notice that in the classical structural balance theory, the two types of stable triangles -- with edge signs as either all positive ($+1$)
or have two negative ($-1$) and one positive -- satisfy this property.
The evolution of $W(t)$ and $V(t)$ is described in the following two lemmas.
\begin{lemma} \label{lemma22}
With the co-evolution model as in Equation~(\ref{eqn:continuous-model}), the dynamics of matrix $W$ follows the following Matrix Riccati Type Equation
\begin{equation*}\label{eqn:Riccati1}
W' = WW^T + C,
\end{equation*}
where $C= V(0)V(0)^T - W(0)W(0)^T$ is a symmetric constant $n \times n$ matrix. If $W(0)$ is symmetric, then $W(t)$ satisfies the Riccati equation
\begin{equation}\label{eqn:Riccati}
W' = W^2 + C.
\end{equation}
\end{lemma}
\begin{proof}
We look at $W''$:
\begin{equation*}
\begin{split}
W'' & = (W')' = (VV^T)' = V'V^T + V(V')^T = WVV^T + V(WV)^T = WVV^T + VV^TW^T \\
& =WW' + W'W^T = W(W^T)' + W'W^T = (WW^T)'.
\end{split}
\end{equation*}
In the second last step, we use the equation $W'=(W^T)'$. This is because $W'(t)=V(t)V(t)^T$ is always symmetric. Thus, $W' = WW^T + C$, where $C$ is a constant matrix $C=W'(0)-W(0)W(0)^T =V(0)V(0)^T-W(0)W(0)^T$. Notice that $C$ is always symmetric.
If $W(0)$ is symmetric, then $W(t)$ is always symmetric (by Lemma~\ref{conjugation} (2)) and $WW^T=W^2$.
\end{proof}
Remark that matrix $C$ in our setting is a special symmetric matrix. Specifically, $C+W(0)W(0)^T=V(0)V(0)^T$ has rank one. This property turns out to be useful for characterization of the system behavior.
\begin{lemma}
The evolution of $V(t)$ satisfies
\begin{equation}\label{eqn:opinion_evolution}
V''(t) = 2|V|^2\cdot V - C\cdot V
\end{equation}
\end{lemma}
\begin{proof}
Here, we use $W^2 = W' - C$ (Equation (\ref{eqn:Riccati})), $W' = VV^T$ and $ V' = WV$.
\begin{equation*}
\begin{split}
V'' & = (V')'= (WV)'= W'V+WV'= VV^TV+WWV = |V|^2V+ W^2V = |V|^2V+ (W'-C)V \\ & = |V|^2V + (VV^T-C)V = 2|V|^2V-CV.
\end{split}
\end{equation*}
\end{proof}
\section{Analysis of the Opinion and Social Tie Evolution}
Our analysis has two parts. First we focus on the opinion evolution model (Equation (\ref{eqn:opinion_evolution})). Here we provide analysis of the asymptotic behavior for $V(t)$. Then we study the social tie evolution (Equation (\ref{eqn:Riccati})) for $W(t)$. By solving Riccati equation explicitly for $W(t)$ we are able to provide more detailed characterization of the evolving behavior.
\subsection{Analysis of Opinion Evolution}
By analyzing the opinion evolution (Equation (\ref{eqn:opinion_evolution})), our main result is the following.
\begin{theorem}\label{thm:main_theorem}
Let $[0, T)$ be the maximum interval of existence for the solution $(V(t), W(t))$ of the differential equation in Equation~(\ref{eqn:continuous-model}). For generic initial values $V(0)$ and $W(0)$, either
\begin{enumerate}
\item structural balance condition $\lim_{t \rightarrow T} w_{ij}w_{jk}w_{ki}>0, \forall i,j,k$ holds, or
\item $T = +\infty$, $\lim_{t\rightarrow \infty}|V(t)| = 0$ and
$\lim_{t\rightarrow \infty}V'(t) = 0$.
\end{enumerate}
Furthermore, in the first case, the normalized opinion vector $\frac{V(t)}{|V(t)|}$ converges, i.e., $\lim_{t \to T} \frac{V(t)}{|V(t)|}$ exists.
\end{theorem}
The theorem says that structural balance is always achieved, unless the opinions converge to a zero vector, in which case the entire network becomes neutral. We can consider the second case as a boundary case of structural balance.
The rest of the subsection will focus on proving this theorem. An important observation is that the norm of $V$, $|V(t)|^2$, is a convex function. The detailed proof is in Appendix~\ref{app:opinion}.
\begin{restatable}{lemma}{lemmalength}
\label{lemma:length}
The length function $\varphi(t):= V^T V = |V(t)|^2$ is strictly convex and $\varphi''(t)>0$ unless $V(t)\equiv 0$.
\end{restatable}
Now, let us understand Equation (\ref{eqn:opinion_evolution}) using coordinates. Since the matrix $C$ is symmetric, by the orthogonal diagonalization theorem, there exists an orthogonal matrix
$$U = [\beta_1, \cdots, \beta_n]=[u_{ij}]_{ n \times n}$$
such that
$C\beta_i = a_i \beta_i, i=1, 2, \cdots, n,$
where $a_1, \cdots, a_n$ are eigenvalues of $C$.
By our assumption that $C = V(0)V(0)^T - W(0)W(0)^T$, the eigenvalues $a_1, \cdots, a_n$ are non-positive except for one. So we may assume $a_1 \geq 0$ and $a_2, \cdots, a_n \leq 0$. Because $\beta_1, \cdots, \beta_n$ form an orthonormal
basis of $\mathbb{R}^n$, we can write
\begin{equation*}
V(t) = \sum_{i=1}^n \lambda_i(t)\beta_i = U\lambda, \mbox{ where } \lambda = [\lambda_1, \cdots, \lambda_n]^T.
\end{equation*}
This implies that $V'(t) = \sum_{i=1}^n \lambda_i'(t)\beta_i$, $V''(t) = \sum_{i=1}^n\lambda_i''(t) \beta_i$, $|V(t)|^2 = \sum_{j=1}^n \lambda_j^2(t)$ and $C\cdot V = \sum_{i=1}^n a_i \lambda_i \beta_i$.
Therefore, Equation (\ref{eqn:opinion_evolution}) becomes
\begin{equation*}
\sum_{i=1}^{n} \lambda_i''(t) \cdot \beta_i = \sum_{i=1}^n (2(\sum_{k=1}^n \lambda_k^2) - a_i) \lambda_i \cdot \beta_i
\end{equation*}
Since $\beta_1, \cdots, \beta_n$ are independent, we obtain the system of ODE with $\lambda = [\lambda_1, \cdots, \lambda_n]^T$ in the form
\begin{equation}\label{eqn:lambda}
\lambda_i''(t) = (2\sum_{k=1}^n \lambda_k^2 - a_i) \lambda_i(t), i=1, 2, \cdots, n.
\end{equation}
Denote $W = [w_{ij}(t)]$. Then $W' = V\cdot V^T$ implies
$$W' = U\cdot \lambda \cdot \lambda^T \cdot U^T$$
Therefore, $w'_{ij}(t)=\sum_{k,l=1}^n u_{ik}u_{jl}\lambda_{k}\lambda_l$ and $w_{ij}(t) = \sum_{k,l=1}^n (\int_0^t \lambda_k(s)\cdot \lambda_l(s) ds) u_{ik}u_{jl} + w_{ij}(0)$.
Our next goal is to show the following proposition,
\begin{restatable}{proposition}{propgrowth}
\label{prop:growth}
If $T < + \infty$ or if $T = + \infty$ and $\lim_{t\rightarrow T} |V(t)| = L > 0$, then there exists one term $\psi_{hh}$ among $\psi_{kl}(t) = \int_{0}^t \lambda_k(s) \lambda_l(s) ds$ which has the maximum growth rate as $t \rightarrow T$ and $\lim_{t\rightarrow T} \psi_{hh}(t) = + \infty$.
\end{restatable}
Assuming the proposition~\ref{prop:growth}, Theorem~\ref{thm:main_theorem} follows. Indeed, the leading term in $w_{ij}(t)$ is $u_{ih}u_{jh}\psi_{hh}$ as $t \rightarrow T$. Therefore the sign of $w_{ij}$ is the same as the sign of $u_{ih}u_{jh}\psi_{hh}$. The leading term of $w_{ij}w_{jk}w_{ki}$ as $t \to T$ is
$$ u_{ih}^2 u_{jh}^2 u_{kh}^2 \psi_{hh}^2 \geq 0.$$
This shows that structural balance occurs eventually for generic initial values. Here the generic condition is used to ensure that all entries $u_{ij}$ of the orthogonal matrix $[u_{ij}]$ are not zero and $\psi_{hh}$ is the unique term with the maximum growth rate. Finally, if $T=\infty$ and $\lim_{t \to \infty} |V(t)|=0$, then by Corollary \ref{cor:v'}, $\lim_{t \to \infty} V'(t)=0$.
The proof for proposition~\ref{prop:growth} is fairly technical and can be found in Appendix~\ref{app:opinion}.
\subsection{Analysis of Social Tie Evolution}
The analysis on the evolution of $V$ in the previous section shows convergence. To further understand the community formed at the limit of convergence, we need to study the evolution of $W$.
The following theorem explains the reason behind the appearance of structure balance when at least one eigenvalue of $W(t)$ tends to infinity. This was proved in~\cite{Marvel2009-lx}. We include the statement here and the proof in Appendix~\ref{subsec:structural} for completeness.
\begin{restatable}[\cite{Marvel2009-lx}]{theorem}{thmconvergence}
\label{thm:convergence}
\label{kl} Suppose $W(t)$, $t \in [0, T)$, is a continuous family of symmetric matrices
such that
\begin{enumerate}
\item $W(t)$ has a unique largest eigenvalue, denoted by $\beta_1(t)$, which tends to infinity as $t \to T$,
\item all eigenvectors of $W(t)$ are time independent, and
\item all components of the $\beta_1(t)$ eigenvector are not zero.
\end{enumerate}
Then
$$ w_{ij}w_{jk}w_{ki} > 0,\, \forall i, j, k, i\neq j, j\neq k, i\neq k,$$
for all time $t$ close to $T$, i.e., the structural balance of the whole graph is satisfied.
If (2) does not hold, we have $$ w_{ij}w_{jk}w_{ki} \geq 0, \forall i, j, k, i\neq j, j\neq k, i\neq k. $$
\end{restatable}
Furthermore, the two antagonistic communities are given by $U^+=\{i \in V|u_i>0\}$ and $U^-=\{i \in V| u_i<0\}$ where $u=[u_1, ..., u_n]^T$ is a $\beta_1(t)$ eigenvector. All edges connecting vertices within the same community are positive while edges connecting two vertices in different communities are negative. When one of $U^+, U^-$ is empty, the network has only one community.
The model in \cite{Marvel2009-lx} is the Riccati equation $W'=W^2$, whose solution is $W(t)=W(0)(1-W(0)t)^{-1}$. As a consequence, Marvel et. al. \cite{Marvel2009-lx} showed that structure balance occurs in the Riccati equation $W'=W^2$ for generic initial parameter $W(0)$ with a positive eigenvalue at finite time. Our model strictly generalizes the previous model and consider how the initial opinions may influence the system evolution. In the following we show how to solve the general Riccati equation and also when an eigenvalue goes to infinity.
With most of the details in the Appendix, we carry out rigorous analysis of the general form of the matrix Riccati equation as stated below.
\begin{equation}
\label{eqn:Evolution}
\left\{
\begin{array}{rl}
W' & = W^2 + C \\
W(0) & = B.
\end{array}
\right.
\end{equation}
For general matrices $B, C$ we can solve for $W(t)$ as shown in the following theorem. The proof details can be found in Appendix~\ref{subsec:general-Riccati}.
\begin{restatable}{theorem}{mainth}
\label{mainth}
The solution $W(t)$ is given by the explicit formula that $W(t) = -Z(t)\cdot Y(t)^{-1}$, where
\begin{eqnarray}
Y(t) &= & \sum_{n=0}^{\infty} \frac{(-1)^n t^{2n} C^n}{(2n)!} + \sum_{n=0}^{\infty}\frac{(-1)^{n+1}t^{2n+1}C^nB}{(2n+1)!} \\
Z(t) &=& \sum_{n=0}^{\infty}\frac{(-1)^{n+1}t^{2n}C^nB}{(2n)!} + \sum_{n=0}^{\infty} \frac{(-1)^{n+1} t^{2n+1} C^{n+1}}{(2n+1)!}.
\end{eqnarray}
\end{restatable}
In our co-evolution model, $B=W(0)$ is assumed to be symmetric. Thus $C$ is also symmetric. This allows us to simplify the solution further, as shown in Appendix~\ref{subsec:socialtie}.
Then we analyze a special case when $BC=CB$. In this case we can characterize the conditions when structural balance is guaranteed to occur, with details in Appendix~\ref{subsec:structural}, \ref{subsec:BCequalCB}, and \ref{subsec:structural-commute}.
Specifically, using a basic fact that two commuting symmetric matrices can be simultaneously orthogonally diagonalized~\cite{Hoffman1971-bc}, we can get the following theorem where the conditions of the eigenvalues of $B, C$ for structural balance are characterized:
\begin{restatable}{theorem}{thmmain}
\label{thm:main}
Suppose $W(t)$ solves the Riccati equation $W'=W^2+C$, $W(0)=B$ where $B, C$ are symmetric with $BC=CB$.
Then eigenvalues of $W(t)$ converge to elements in $(-\infty, \infty]$ as $t \to T;$ meanwhile there is sign stability, i.e., $\lim_{t \to T} w_{ij}(t) \in [-\infty, \infty]$ exists for all $i,j$.
If $U$ is an orthogonal matrix such that
\begin{equation*}
\begin{split}
U^TCU & = \diag(a_1^2, \cdots, a_k^2, -d_1^2, \cdots, -d_l^2, 0, \cdots, 0)\\
U^TBU & = \diag(\lambda_1, \cdots, \lambda_k, \mu_1, \cdots, \mu_l, \delta_1, \cdots, \delta_h).
\end{split}
\end{equation*}
where $a_i, d_j > 0$,
then $W(t)$ is given by the following explicit function, \begin{equation}\label{eqn:W}
\begin{aligned}
W(t) = & U\cdot \diag(\frac{a_1 \sin{(a_1 t)} + \cos{(a_1 t)}\lambda_1}{\cos{(a_1 t)}-\frac{1}{a_1}\sin{(a_1 t)}\lambda_1}, \cdots, \frac{a_k \sin{(a_k t)}) + \cos{(a_k t)}\lambda_k}{\cos{(a_k t)}-\frac{1}{a_k}\sin{(a_k t)}\lambda_k},\\
& -\frac{d_1 \sinh{(d_1 t)}-\cosh{(d_1 t)}\mu_1}{\cosh{(d_1 t)} - \frac{1}{d_1}\sinh{(d_1 t)}\mu_1}, \cdots, -\frac{d_l \sinh{(d_l t)}-\cosh{(d_l t)}\mu_l}{\cosh{(d_l t)} - \frac{1}{d_l}\sinh{(d_l t)}\mu_l}, \\
& \frac{\delta_1}{1 - t\delta_1}, \cdots, \frac{\delta_h}{1 - t\delta_h}) \cdot U^T.
\end{aligned}
\end{equation}
Further, structural balance
$$ \lim_{t \to T} w_{ij}w_{jk}w_{ki} \geq 0$$
occurs in the finite time for $W(t)$ if $W(t)$ has an unique largest eigenvalue and one of the following conditions holds:
\begin{enumerate}
\item There exists some $\delta_i>0$,
\item There exists some $ a_i>0$,
\item there exists some $\mu_i > d_i$.
\end{enumerate}
\end{restatable}
In our co-evolution model, $BC=CB$ happens when $V(0)$ is a eigenvector of $W(0)$, an interesting initial condition.
To see that, recall $B=W(0)$, $C= V(0)V(0)^T - W(0)W(0)^T$, and $W(0)=W(0)^T$. To check if $BC=CB$, we just need to check if $W(0)V(0)V(0)^T=V(0)V(0)^TW(0)$ and apply the following Lemma (Proof in Section~\ref{subsec:structural-commute}).
\begin{restatable}{lemma}{lemmaBCcommute}
\label{lemma:BCcommute}
Suppose $A$ is a symmetric matrix and $v$ is a non-zero column vector. Then
$A vv^T=vv^TA$ is equivalent to $Av=\alpha v$, i.e., $v$ is an eigenvector of $A$.
\end{restatable}
Further, the equation in our co-evolution model, i.e., Equation~(\ref{eqn:Riccati}), satisfies $C+B^2=V(0)V(0)^T$. Notice that the right-hand side $V(0)V(0)^T$ is an $n
\times n$ matrix with rank one. This property actually ensures that the conditions characterized in Theorem~\ref{thm:main} are met and thus structural balance is guaranteed. At the same time, the convergence rate is $O(\frac{1}{|T - t|})$, which is proved by Lemma~\ref{lemma:sin} in Appendix~\ref{subsec:BCequalCB}.
\begin{restatable}{corollary}{corcomute}
\label{cor:comute}
For Equation~(\ref{eqn:continuous-model}), if $V(0)\neq 0$ is an eigenvector of $W(0)$, then $V(t)$ remains to be an eigenvector of $W(t)$ for all $t$ and structural balance must occur in finite time for $W(t)$.
\end{restatable}
If $V(0)=0$, the system stays at the fixed point with $V$ remaining zero and the weight matrix unchanged.
The case when $V(0)$ is an eigenvector of $W(0)$ includes a few interesting cases in practice. When $W(0)=0$ or $W(0)=I$, this models a group of individuals that start as complete strangers with uniform self-appraisals. Their non-homogeneous initial opinions $V(0)$ may drive the network to be segmented over time. Finally the fact that $V(t)$ remains an eigenvector of $W(t)$ for all $t$ follows from Equation (\ref{eqn:WWW}) in Appendix C.
We conjecture that even in the general case (when $V(0)$ is not necessarily an eigenvector of $W(0)$) the limit vector $\lim_{t \to T} V(t)/|V(t)|$ is an eigenvector of the limit tie relation matrix $\lim_{t \to T} W(t)/|V(t)|$. This is supported by our numerical evidences and Corollary \ref{cor:wv} which says that $\lim_{t \to T} V(t)/|V(t)|$ is an eigenvector of $\lim_{t \to T} (W(t)/|V(t)|)^2$.
\section{Simulations}
In this section, we provide simulation results to accompany our theoretical analysis of the co-evolution model.
We also present simulation results on general graphs and real world data sets to understand the behavior of network evolution.
Here is a brief summary of observations from simulations. The details can be found in the Appendix.
\begin{itemize}
\item Except a few carefully crafted cases\footnote{For example, if $W(0) = B = \diag(-\frac{1}{a}, -\frac{1}{a}, \cdots, -\frac{1}{a})$ and we use the dynamic update rule $v_i(1) = v_i(0) + a\cdot w_{ii}(0)v_i(0) = 0$, for all $1 \leq i \leq n$. After one iteration, all node opinions become $0$. After that, the opinions and weights do not change anymore. } that make the opinion vector to be zero, strict structural balance is always reached, regardless of whether the graph is complete or general, whether $B, C$ commute or not, or whether $W(0)$ is symmetric or as a general matrix. An example is shown in Figure~\ref{fig:heatmap}.
\item In general, we observed through simulations that the number of iterations to convergence is inversely proportional to the magnitude of initial opinions and the edge density in the graph.
\item In two real world data sets (the Karate club and a political blog data set), a few initially planted polarized opinions can successfully predict the ground truth community structure with high accuracy. See Figure~\ref{fig:application}.
\end{itemize}
\section{Conclusion and Future Work}
In this paper, we have provided a co-evolution model for both opinion dynamics and appraisal dynamics. We provided solutions to the system and rigorously characterized how the stable states depend on the initial parameters.
There are a few follow-up problems that remain open, for example,
when the social ties are directional/asymmetric, when the network is not a complete graph, and when each agent has an $m$-dimensional opinion vector. We include some discussion and conjectures on these cases in Appendix~\ref{subsec:general} and consider this as interesting future work.
\begin{figure}[h!]
\centering
\includegraphics[width=0.9\columnwidth]{Figure/heatmap_case0.pdf}
\caption{The weight matrix in evolution. The $x$ and $y$ axis show vertex indices. The cell at $(i, j)$ represents the edge weight between node $i$ and node $j$ with color showing edge weight. The first plot is the initial edge weights, which are assigned random values. The second plot shows the weight matrix after $15$ iterations. Patterns start to show up with two diagonal blocks showing positive values and the off-diagonal blocks with negative values. The last plots is the weight matrix at convergence where the first $6$ nodes are in one community and the other nodes are in a different community. Edges within communities have positive weights and edges between communities have negative weights. }
\label{fig:heatmap}
\end{figure}
\begin{figure}[h!]
\centering
\subfigure[Initial Karate club graph]{
\centering
\includegraphics[width=0.35\columnwidth]{Figure/Karate_Club_Initial.pdf}
\label{fig:karate_1}
}
\subfigure[Separated communities results]{
\centering
\includegraphics[width=0.35\columnwidth]{Figure/Karate_Club_Separate.pdf}
\label{fig:karate_2}
}
\subfigure[Initial political blogs network]{
\centering
\includegraphics[width=0.28\columnwidth]{Figure/blog_initial.pdf}
\label{fig:blog_1}
}
\hspace{1cm}
\subfigure[Separated communities results]{
\centering
\includegraphics[width=0.36\columnwidth]{Figure/blog_separated.pdf}
\label{fig:blog_2}
}
\caption{Community detection in two real-world data sets. The color of vertices represents their ground truth opinions. Initially, only a small number of seeds are assigned their true opinions and other nodes start with initial opinions of $0$. All edges start with a small positive weight. As the network converges, the edges with negative weights are removed. The communities discovered as shown in the right column faithfully reflect the ground truth. In the first experiment (a, b), the node $\#0$ and the node $\#33$ are assigned opposite initial opinions. It nearly predicts the same division as in the ground truth except for two nodes $\#8$ and $\#19$ which are somewhat ambiguous. In the second experiment (c, d), $20\%$ random nodes are assigned initial opinions according to the ground truth. The prediction achieves an average accuracy of $97.21\%$ compared with the ground truth.}
\label{fig:application}
\end{figure}
\newpage
\bibliographystyle{ACM-Reference-Format}
\section{Model}~\label{subsec:model}
\conjugation*
\begin{proof}
Part (1) follows from standard computation and that $UU^T=U^TU=I$ for an orthogonal matrix $U$. Also, a matrix $A$ is symmetric if and only if $U^TAU$ is symmetric.
For part (2), note that the equation $W'=VV^T$ implies that $W'(t)$ is always symmetric, i.e., $W'(t) = W'(t)^T$. Now if $W(0)$ is symmetric, then $W(t)$ and $W^T(t)$ are solutions of the same differential equation $W'(t) =W'(t)^T$ with the same initial value. By the uniqueness theorem of the solution of ordinary differential equation, $W(t)=W^T(t)$.
Part (3) follows by rewriting Equation~(\ref{modii}) as
\begin{equation*}
\left\{
\begin{array}{l}
(\sqrt{ab} V_1)' = (aW_1) (\sqrt{ab} V_1) \\
(aW_1)' = (\sqrt{ab} V_1)(\sqrt{ab}V_1)^T.
\end{array}
\right.
\end{equation*}
Take $V=\sqrt{ab}V_1$ and $W=aW_1$. This becomes Equation~(\ref{eqn:continuous-model}).
\end{proof}
\section{Evolution of Opinion Dynamics}\label{app:opinion}
\lemmalength*
\begin{proof}
Recall that $\varphi(t)=|V(t)|^2$.
$$\varphi'(t) = (V')^TV + V^TV' = (WV)^TV+V^TWV = 2V^TWV.$$
Therefore,
\begin{equation}\label{eqn:length}
\begin{split}
\varphi''(t) & = 2((V')^TWV + V^TW'V+ V^TWV') = 2((WV)^TWV + V^TVV^TV + V^T WWV)\\
& = 2(|WV|^2 + |V|^4 + V^TW^TWV) = 2(2|WV|^2 + |V|^4) = 2(2|V'(t)|^2 + |V(t)|^4 ) \geq 0
\end{split}
\end{equation}
Now if $\varphi''(t_0) = 0$, then $V'(t_0) = V(t_0)=0$ by Equation (\ref{eqn:length}).
This shows that $V(t)$ is the solution of the ODE (Equation (\ref{eqn:opinion_evolution})) with the initial condition $V(t_0) = V'(t_0) = 0$. But $0$ is also the solution. Therefore, by the uniqueness of solution of ODE with initial value, $V(t)\equiv 0$. This ends the proof.
\end{proof}
\begin{corollary} \label{cor:v'} If $V(t)$ solves Equation (\ref{eqn:opinion_evolution}), then
\begin{equation} \label{v'}
|V'(t)|^2 =|V(t)|^4 -V^TCV. \end{equation}
In particular, if $\lim_{t \to T} V(t)=0$, then $\lim_{t \to T} V'(t)=0.$
\end{corollary}
Indeed, by $(|V(t)|^2)'=2V^TV'$ and Equation (\ref{eqn:opinion_evolution}) that $V''=2|V|^2V-CV$, we have $(|V(t)|^2)''=2 ( V')^T V' + 2V^T V'' = 2|V'(t)|^2 + 2V^T(2|V|^2V-CV) = 2|V'(t)|^2 +4|V|^4-2V^TCV.$ Comparing it with Equation (\ref{eqn:length}), we see the corollary holds. The last statement of the corollary follows from Equation (\ref{v'}).
We now prove Proposition~\ref{prop:growth} using several lemmas. For simplicity, if $f(t)$ is a function defined on an open internal $(a, b)$ (here $b$ may be $+\infty$), we say $f$ has property $P$ (e.g., positive, non-negative, monotonic, convex etc) near $b$ if there exists $\epsilon > 0$ such that the restriction of $f$ on the interval $(b-\epsilon, b)$ (if $b < +\infty$) or $(\frac{1}{\epsilon}, \infty)$ (if $b=+\infty$) has property $P$. For example, $t^4 + 3t^3 - 9 t^2 +t - 5$ is positive and convex near $+\infty$. The notation $C^{k}(a,b)$ stands for all functions $f(t)$ for which $f, f', \cdots, f^{(k)}$ are continuous on the interval $(a, b)$.
\begin{lemma}\label{lemma:f_property}
Suppose $f \in C^2(a, b)$ and $p(t)>0$ on $(a, b)$ such that
\begin{equation}\label{eqn:f''}
f''(t) = p(t)f(t) \mbox{ on }(a, b)
\end{equation}
and $f(t)$ is not identically zero on any sub-interval. Then
\begin{enumerate}
\item $f$ has at most one root in $(a, b)$.
\item $f$ has the same sign near $b$ (i.e., always positive or negative).
\item $f$ is monotonic near $b$.
\item the limit $\lim_{t \to b^-} f(t)$ exists (the limit may be $\pm \infty)$).
\end{enumerate}
Furthermore, if $g''(t) \geq q(t)g(t)$ and $q\geq 0$ on $(a, b)$, then either $g(t) > 0$ near $b$ or $g(t) \leq 0$ near b.
\end{lemma}
\begin{proof}
To see part (1), if $f$ has two roots in $(a,b)$, then since $f$ is not identically zero on any interval, there exist two adjacent roots $f(c) = f(d)$ where $c < d$ and $f$ has no roots in the open interval $(c, d)$. By replacing $f$ by $-f$ if necessary, we may assume that the restriction function $f|_{(c, d)} > 0$. Then by Equation~(\ref{eqn:f''}), $f''(t) = p(t)f(t)>0$ on $(c, d)$. Therefore $f|_{[c,d]}$ is a convex function which has two minimum values at $c, d$. This implies that $f|_{[c, d]}\equiv 0$ which contradicts the assumption.
Part (2) follows from the part (1) easily.
To see part (3), we first show that $f'(t)$ has at most two roots in the open interval $(a, b)$. Suppose otherwise that $f'(t)$ has three roots in $(a, b)$. Then by the Mean Value Theorem, $f''(t)$ has two roots in $(a, b)$, one in each interval bounded by roots of $f'(t)$.
But $f''(t)=p(t)f(t)$ with $p(t)>0$ says $f$ and $f''$ have the same roots. This implies that $f$ has two roots in $(a, b)$ which contradicts the part (1). Since $f'$ has only two roots, it follows that $f'(t) > 0$ near $b$ or $f'(t) < 0$ near $b$. Therefore $f$ is monotonic near $b$.
Part (4) follows from the well-known theorem that if $h(t)$ is monotonic in an open interval $(a, b)$, then the limit $\lim_{t\rightarrow b^{-}} h(t)$ always exists (limit value of the limit may be $\pm \infty$).
Finally, to prove the last statement, we consider two cases. In the first case, there are no sequence $\{r_m \}$ of roots of $g$ such that $\lim_{m \to \infty} r_m = b$. Then clearly $g(t) > 0$ or $g(t) <0$ near b. In the remaining case, we have an increasing sequence of roots, $r_1 < r_2< \cdots < r_m < \cdots$ of $f$ such that $\lim_{m\rightarrow \infty} r_m = b$. We claim that $g|_{[r_1, b)}\leq 0$. Suppose otherwise that $g(t_0) > 0$ for some $t_0 \in (r_1, b)$.
Let $c$ (respectively $d$) be the largest (respectively smallest) root of $g$ such that $c < t_0$ (respectively $d > t_0)$. By the assumption, both $c$ and $d$ exist. Furthermore $c < t_0 < d$ and $g$ has no root in the interval $(c, d)$. Therefore, due to $g(t_0) > 0$, $g|_{(c, d)} > 0$. By the condition $g'' = qg$, with $q \geq 0$, we see that $q''|_{(c, d)} \geq 0$. Therefore $g(t)$ is convex on $[c, d]$ and has two minimum values $0(=g(c) = g(d))$. But that implies $g|_{[c, d]} = 0$ and contradicts $g(t_0) > 0$.
\end{proof}
\begin{corollary}\label{corollary:sol}
Suppose $\lambda(t) = [\lambda_1(t), \cdots, \lambda_n(t)]^T$ solves the ODE Equation (\ref{eqn:lambda}) and $a_1 \geq 0$, $a_2, \cdots, a_n \leq 0$ on the maximum interval $[0, T)$. Then
\begin{enumerate}
\item $\lim_{t\rightarrow T} |V(t)|^2 = \lim_{t\rightarrow T} \sum_{k=1}^{n} \lambda_k^2(t)$ exists.
\item For all $i$, $\lim_{t\rightarrow T} \lambda_i^2(t)$ exists.
\item Assuming that $\lim_{t \to T} |V(t)|^2=\infty$, for $i\neq j$, either $\lambda_i^2(t) \geq \lambda_j^2(t)$ near $T$ or $\lambda_i^2(t) \leq \lambda_j^2 (t)$ near $T$.
\item For $\lim_{t \to T} |V(t)|^2 <\infty$, then all limits $\lim_{t \to T} \lambda_k^2(t)$ are finite and can be ordered.
\end{enumerate}
\end{corollary}
\begin{proof}
For (1), by Lemma~\ref{lemma:length}, $\phi(t) = |V(t)|^2$ is convex in $[0, T)$. Hence $\phi(t)$ is monotonic near $T$ and $\lim_{t\rightarrow T}\phi(t)$ exists.
For (2), let us assume $V(t)$ is not identically zero. Otherwise the result holds trivially. If $i \geq 2$, then by Equation~(\ref{eqn:lambda}), $a_i \leq 0$ and Lemma~\ref{lemma:length}, we have $2|V(t)|^2 - a_i > 0$ on $[0, T)$ and $\lambda_i''(t) = p_i(t)\lambda_i(t)$, where $p_i(t) = 2|V(t)|^2-a_i > 0$. Therefore by Lemma \ref{lemma:f_property}, $\lim_{t\rightarrow T}\lambda_i^2(t)$ exists. If $i = 1$, we have $\lambda_1^2(t) = |V(t)|^2 - \sum_{k=2}^n \lambda_k^2(t)$.
Now if $\lim_{t\rightarrow T}|V(t)|^2 < +\infty$, then $\lim_{t \rightarrow T} \lambda_k^2(t) < + \infty$, for $k = 2, \cdots, n$. Therefore, $\lim_{t \rightarrow T} \lambda_1^2(t) =\lim_{ t \to T}(|V(t)|^2 -\sum_{k_2}^n \lambda_{k}^2)$
exists and is finite. If $\lim_{t \rightarrow T}|V(t)|^2 = + \infty$, then $2|V(t)|^2 - a_1 > 0$ for $t$ near $T$. The equation $\lambda_1''(t) = (2|V(t)|^2 - a_1)\lambda_1(t)$ is of the form $\lambda_1''(t) = p_1(t) \lambda_1(t)$ where $p_1(t) > 0$ near $T$. Therefore by Lemma~\ref{lemma:f_property}(4), $\lim_{t\rightarrow T}\lambda_1^2(t)$ exists.
For (3), since $\lambda_i^2 \geq \lambda_j^2$ is the same as $|\lambda_i|\geq |\lambda_j|$ and if $\lambda_i$ solve Equation~(\ref{eqn:lambda}) so is $-\lambda_i(t)$. The assumption that $\lim_{t \to T} |V(t)|^2 =\infty$ implies $|V(t)|^2-a_k \geq 0$ for $t$ near $T$. We may assume, using Lemma~\ref{lemma:f_property}(2), that $\lambda_i(t) \geq 0$ and $\lambda_j(t)\geq 0$ near $T$. Our goal is to show, under the assumption that $\lambda_i, \lambda_j \geq 0$ near $T$, either $\lambda_i \geq \lambda_j$ or $\lambda_i \leq \lambda_j$ near $T$. Without loss of generality, we may assume that $a_j \geq a_i$ and $a_i \leq 0$ (Note $a_1 \geq 0$ and $a_2, \cdots, a_n \leq 0$). Then using Equation~(\ref{eqn:lambda}), we have
\begin{equation*}
\begin{split}
(\lambda_i - \lambda_j)'' & = \lambda_i'' - \lambda_j'' = (2|V(t)|^2 - a_i) \lambda_i - (2|V(t)|^2 - a_j) \lambda_j \\
& = (2|V(t)|^2 - a_i)(\lambda_i - \lambda_j) + (a_j - a_i)\lambda_j \geq (2|V(t)|^2 - a_i) (\lambda_i- \lambda_j).
\end{split}
\end{equation*}
Since $a_j - a_i \geq 0$ and $\lambda_j \geq 0$. Now due to $a_i \leq 0$, $2|V(t)|^2 - a_i \geq 0$. Therefore $(\lambda_i -\lambda_j)'' \geq q(t)(\lambda_i - \lambda_j)$ when $q \geq 0$ near $T$. By the last proof of Lemma~\ref{lemma:f_property}, we see either $\lambda_i > \lambda_j$ or $\lambda_i \leq \lambda_j$ near $T$. This ends the proof.
Part (4) follows from part (2) and the assumption which implies $\lim_{t \to T} \lambda_k^2$ are finite real numbers. Therefore, we can order them.
\end{proof}
Now, let us prove Proposition~\ref{prop:growth}.
\propgrowth*
\begin{proof}
There are two cases depending on the maximum interval of existence $[0, T)$ being finite, i.e., $T < +\infty$ or infinite $[0, + \infty)$, i.e., $T = + \infty$.
\medskip
\textbf{Case 1.} $T < + \infty$. Recall the basic global existence of solution to ODE~\cite{Walter1998ODE}.
\begin{theorem}~\label{thm:differential}
(Existence) Suppose $F(t, x) \in C^{1}(\mathbb{R}\times \mathbb{R}^{m})$ and $[t_0, T)$ is the maximum interval of existence of the solution $x(t)$ to $x'(t) = F(t, x(t))$ with $x(t_0) = x_0$. Then the path $\{(t, x(t)) | t \in [t_0, T) \}$ does not lie in any bounded set in $\mathbb{R} \times \mathbb{R}^{n}$.
\end{theorem}
Now, for $T < +\infty$, Theorem~\ref{thm:differential} implies $\lim_{t\rightarrow T} |V(t)| = +\infty$. Indeed, if $\lim_{t\rightarrow T} |V(t)| < + \infty$, then $V(t)$ is bounded on $[0, T)$. This implies $W'(t) = V(t)\cdot V(t)^T$ is bounded. but $W(t) = W(0) + \int_0^t W'(s) ds$. Therefore W(t) is bounded. This implies the solution $(V(t), W(t))$ for $t\in [0, T)$ lies in a bounded set in $\mathbb{R}^n \times \mathbb{R}^{n\times n}$ which contradicts Theorem~\ref{thm:differential}.
Now $\lim_{t\rightarrow T} |V(t)|^2 = \lim_{t \rightarrow T} \sum_{j=1}^n \lambda_j^2(t) = + \infty$ implies, by Corollary~\ref{corollary:sol}(2), there exists $i$ for which $\lim_{t \rightarrow T} \lambda_i^2(t) = + \infty$. Furthermore, by Corollary~\ref{corollary:sol}(3), there exists an index $h$ for which $\lambda_h^2(t) \geq \lambda_j^2(t)$ near $T$ for all $j$. Thus $\lambda_h^2(t)$ has the largest growth rate tending $+ \infty$ as $t\rightarrow T$.
For generic initial value $V(0)$ and $W(0)$, $\lambda_{h}^2(t)$ is the unique term of maximum growth rate. Therefore, we see that part (1) of Therem~\ref{thm:main_theorem} holds.
\medskip
\textbf{Case 2.} If $T = + \infty$, let us assume that the limit $\lim_{t \rightarrow T} |V(t)| = L > 0$ and show that structural balance occurs eventually.
By Corollary~\ref{corollary:sol}, we may assume that $\lambda_h^2(t) \geq \lambda_j^2(t)$ for $t$ near $\infty$ for all $j$ (if $\lim_{t \to T} |V(t)|^2=\infty$) or $\lim_{t \rightarrow T} \lambda_h^2(t) =\max\{ \lim_{ t \to T} \lambda^2(t) | i=1,..., n\} < \infty$. Let $L' =\lim_{t \rightarrow T} \lambda_h^2(t) $. Then $L'>0$ since $L>0$. In the case of $\lim_{t \to T} |V(t)|^2=\infty < \infty$, for generic initial value, we may assume that $\lim_{t \rightarrow T} \lambda_h^2(t)$ is the unique maximum value among all $\lim_{t \rightarrow T} \lambda_i^2(t)$, $i=1, ..., n$. Then we see that
\begin{equation*}
\int_0^t |\lambda_h^2(s)| ds \geq (t- t_0) L'' + c_0
\end{equation*}
for some constants $L''>0$ and $c_0$. It tends to $+ \infty$ as $t \rightarrow \infty$.
Furthermore, by the Cauchy inequality,
\begin{equation*}
(\int_{0}^t \lambda_i(s) \lambda_j(s) ds )^2 \leq \int_{0}^{t} \lambda_i^2(s) ds \cdot \int_0^{t} \lambda_j^2(s) ds
\end{equation*}
and
\begin{equation*}
\int_0^{t} \lambda_i^2(s) ds \leq \int_0^t \lambda_h^2(s) ds + c_1
\end{equation*}
for t large, we see the growth rate of
$\int_{0}^t \lambda_i(s) \lambda_j(s) ds$ is at most that of $\int_0^t \lambda_h^2(s) ds$ as $t \to \infty$.
This shows, by the same argument, that the growth rate of $w_{ij}(t)$ is dominated by $u_{ih} u_{jh}\int_0^t \lambda_h^2(s) ds$. Therefore, structural balance occurs again for generic initial values.
Finally, we prove that in Case 1 or in Case 2 that $T=\infty$ such that $\lim_{t \to \infty} |V(t)| =L >0$, the limit $\lim_{t \to \infty} V(t)/|V(t)|$ exists.
By corollary \ref{cor:v'} (2), $\lim_{t \to T} \lambda_i$ exists in $[-\infty, \infty]$. Therefore, if
$\lim_{t \to \infty} |V(t)| =L$ is a finite positive number, then $\lim_{t \to \infty} V(t)$ exists in $\mathbb{R}^n-\{0\}$. Hence $\lim_{t \to \infty} V(t)/|V(t)|$ exists. In the remaining cases, we have $\lim_{ t \to T} |V(t)|=\infty$. In this case, by the argument above, we see that $\lambda_i(t)$ has the same sign near $T$. We claim that the function
$\lambda_i/\lambda_j$ is monotonic near $T$. Indeed, by the quotient rule for derivative, the sign of derivative of $\lambda_i/\lambda_j$ is the same as that of $h(t)=\lambda_i'\lambda_j-\lambda_j'\lambda_i$. Now $h'(t) = \lambda_i''\lambda_j -\lambda_j''\lambda_i=
(2|V|^2-a_i)\lambda_i\lambda_j -(2|V|^2-a_j)\lambda_j\lambda_i=(a_j-a_i)\lambda_i\lambda_j$. Therefore, either $h'(t)$ has the same sign for $t$ near $T$ (when $a_i \neq a_j)$ or $h'(t)=0$ (when $a_i =a_j)$. If $h'(t)=0$, then $\lambda_i/\lambda_j$ is a constant near $T$ and the claim follows. If $h'(t)$ has the same sign near $T$, then $h(t)$ is strictly monotonic near $T$. Therefore, $h(t)$ has the same sign for $t$ near $T$. As a consequence we see that $\lambda_i/\lambda_j$ is a monotonic near $T$. In particular, the limit $\lim_{ t \to T} \lambda_i(t)/\lambda_j(t)$ exists. Since $\lim_{t \to T} \sum_{k=1}^n \lambda_k(t)^2=\infty$, this implies the limit $\lim_{t \to T}\frac{\lambda_i(t)}{\sqrt{\sum_{j=1}^n \lambda_j(t)^2}}=\lim_{t \to T} \frac{\pm 1}{\sqrt{\sum_{j=1}^n \lambda_j(t)^2/\lambda_i(t)^2}}$ exists for any index $i$. The last statement is the same as that $\lim_{t \to T} V(t)/|V(t)|$ exists.
This ends the proof of Theorem~\ref{thm:main_theorem}.
\end{proof}
\begin{corollary}\label{cor:wv} Suppose $\lim_{t \to T} |V(t)|=\infty$. Then $A:=\lim_{ t \to T} W(t)^2/|V(t)|^2$ exists and $\lim_{t \to T} V/|V|$ is an eigenvector of $A$ associated to the eigenvalue one.
\end{corollary}
To see this, let $v$ be $\lim_{t \to T} V/|V|$. From $W^2=VV^T -C$ and $\lim_{t \to T} |V(t)| =\infty$, we see that
$W^2/|V|^2 =(V/|V|) (V/|V|)^T -C/|V|^2$ implies $\lim_{ t \to T} W^2/|V|^2 =vv^T$. Since $vv^Tv=v$ due to $|v|^2=1$, the result follows.
\medskip
We end the appendix by making several remarks and a conjecture.
The 1-dimensional case of equation $V''(t) = (2|V(t)|^2 - C)\cdot V(t)$, $V(t) \in \mathbb{R}^n$ is $y''(t) = 2y^3(t) - cy(t)$. The function $f(t) = \frac{a}{\sinh{(at + b)}}$ solves $f'' = 2f^3 + a^2f$ and $g(t) = \frac{a}{\sin(at+b)}$ solves $g'' = 2g^3 - a^2g$. We may assume $a>0$. Therefore, if $b<0$, then both $f$ and $g$ exist only on a finite maximum interval (it is $[0, -\frac{b}{a})$ for $f(t)$), i.e., $T < + \infty$.
If $b > 0$, then the function $f(t)$ exists on $[0, + \infty)$ but the function $g(t)$ exists only on a finite interval $[0, T)$. It indicates that if $C$ has a positive eigenvalue $a_1>0$, then the solution $\lambda_1(t)$ may exist only on a finite interval.
This prompts us to conjecture that
\begin{conj}
If the initial value matrix $C = V(0)V(0)^T - W(0)W(0)^T$ has a positive eigenvalue (i.e., $a_1 > 0$), then the maximum interval $[0, T)$ of existence for the solution $(V(t), W(t))$ of the co-evolution equation $V'=WV$ and $W'=VV^T$ is finite, i.e., $T < +\infty$.
\end{conj}
If the conjecture holds, by Theorem~\ref{thm:main_theorem}, we see structural balance must occur eventually for generic initial value $C$ which has a positive eigenvalue. Therefore, it also justifies our experimental observation that structural balance occurs almost all the time.
\section{Simulation}
We use the discrete time model as described in Equation~(\ref{eq:discrete-model}). The convergence of the dynamic process defined by Equation~(\ref{eq:discrete-model}) is very fast. For visualization purposes, in the simulation, we set our evolution model using Equation~(\ref{modii}) with $a = b = 0.01$.
When a graph is said to satisfy structural balance, the multiplication of weights along all triangles is non-negative.
In addition, either all nodes have the same opinion (i.e., harmony) or the graph is partitioned into two antagonistic groups (i.e., polarization).
\subsection{Harmony vs Polarization}
In this section, we work with a complete graph and examine when structural balance and/or polarization appears.
\smallskip\noindent\textbf{$B$ and $C$ commute. } As mentioned in Theorem~\ref{thm:main}, when the matrices $B = W(0)$ and $C = V(0)V(0)^T - W(0)^2$ are symmetric with $BC=CB$, structural balance occurs in finite time for $W(t)$ if $W(t)$ has an unique largest eigenvalue. We take three special cases mentioned in the previous section, namely when $W(0) = I$, $W(0) = 0$, or $W(0) = V(0)V(0)^T$. The evolution process of these three cases are shown in Figure~\ref{fig:commute_evolution}. The initial opinions are selected uniformly at random in $[-1, 1]$. The dash curves represent the evolution of opinions and the solid ones shows the edge weights. The color of the curves represent the final sign of opinions and weights at convergence. In all three cases the network reaches polarization where the opinions of some vertices go to positive infinity and the opinion of the others go to negative infinity. In these cases, the node opinions do not change signs, because $v_iw_{ij}v_j \geq 0$ holds all the time. The gradient direction of opinions and weights are same with their signs.
Figure~\ref{fig:case0_C} shows a case when both opinions and edge weights converge to positive values. All the opinions are assigned initially as a positive value. The initial weight matrix is a diagonal matrix with the same diagonal entry. All final opinions and weights are positive.
\begin{figure}[tb]
\centering
\subfigure[$W(0) = I$]{
\centering
\includegraphics[width=0.23\columnwidth]{Figure/Case_0_Polarization.pdf}
\label{fig:case0_P}
}
\subfigure[$W(0) = 0$]{
\centering
\includegraphics[width=0.23\columnwidth]{Figure/Case_2_Polarization.pdf}
\label{fig:case1_P}
}
\subfigure[$W(0) = V(0)V(0)^T$]{
\centering
\includegraphics[width=0.23\columnwidth]{Figure/Case_3_Polarization.pdf}
\label{fig:case2_P}
}
\subfigure[$W(0) = -2I$]{
\centering
\includegraphics[width=0.23\columnwidth]{Figure/Case_0_Consensus.pdf}
\label{fig:case0_C}
}
\caption{The evolution process for a complete graph with $BC=CB$. In the first three plots, the network at the limit achieves structural balance and the network is also polarized. In the last example, the network reaches harmony. }
\label{fig:commute_evolution}
\end{figure}
\smallskip\noindent\textbf{$B$ and $C$ do not commute. } Next, we consider the case when the matrices $B$ and $C$ do not commute. We take different random initial cases and show the evolution process in Figure~\ref{fig:non_commute_evolution}. In the first two plots ~\ref{fig:case0_NC} and ~\ref{fig:case1_NC}, we select a symmetric random matrix as the initial weight matrix $W(0)$. The opinions are assigned random initial values. In simulation we observed both cases of harmony and polarization as the final state. Some edges and vertices change signs in the process. We also show an example of the evolution process in Figure~\ref{fig:heatmap} which shows how two communities emerge.
\smallskip\noindent\textbf{$W(0)$ is not symmetric. } In Figure~\ref{fig:case2_NC}, the initial weight matrix is not symmetric. Both vertex opinions and edge weights go to infinity after several iterations. Figure~\ref{fig:case3_NC} shows when all the entries in the matrix and opinions are initially negative. Some opinions and weights change signs in the evolution process. For all cases we have tested when $B$ and $C$ do not commute, structural balance is always satisfied in the limit.
\begin{figure}[tb]
\centering
\subfigure[Symmetric matrix $W(0)$]{
\centering
\includegraphics[width=0.23\columnwidth]{Figure/Non_Commute_case_1.pdf}
\label{fig:case0_NC}
}
\subfigure[Symmetric matrix $W(0)$]{
\centering
\includegraphics[width=0.23\columnwidth]{Figure/Non_Commute_case_2.pdf}
\label{fig:case1_NC}
}
\subfigure[Random matrix $W(0)$]{
\centering
\includegraphics[width=0.23\columnwidth]{Figure/Non_Commute_case_0.pdf}
\label{fig:case2_NC}
}
\subfigure[Negative matrix $W(0)$]{
\centering
\includegraphics[width=0.23\columnwidth]{Figure/Non_Commute_case_3.pdf}
\label{fig:case3_NC}
}
\caption{The evolution process for a complete graph with $BC\neq CB$. In both (a) and (b) we take a symmetric random matrix as $W(0)$ and a random initial vector $V(0)$. In (a) the network reaches a polarized state and in (b) the network reaches harmony. Figure~\ref{fig:non_commute_evolution}(c) shows the evolution when the initial weight matrix is a random non-symmetric matrix. Some edge weights and opinions change signs during the process. In Figure~\ref{fig:non_commute_evolution}(d), all the entries in the initial matrix and the opinion vector are negative. The network reaches a polarized state and reaches structural balance.}
\label{fig:non_commute_evolution}
\end{figure}
\subsection{Convergence Rate}
In section, we check the convergence rate in different settings. This helps us understand intuitively the factors that influence the convergence rate.
\smallskip\noindent\textbf{Magnitude of Initial Opinions.} Figure~\ref{fig:convergence_1} and ~\ref{fig:convergence_2} show two cases $W(0) = I$ and $W(0) = 0$ respectively. In both cases $BC=CB$. The initial opinions are randomly selected from $(-1, 1)$. We check the number of iterations until all entries in the opinion vector and weight matrix have absolute value larger than $10^{20}$. From the analysis in the previous section, the largest eigenvalue of $W(t)$ determines the convergence rate. Given that the initial weights are determined, we check the positive eigenvalue of $V(0)V(0)^T$. We can see that the number of iteration until convergence is inversely proportional to the magnitude of the positive eigenvalue of $V(0)V(0)^T$. The more extreme the initial opinions are, the faster the network reaches convergence. We also tested networks of different sizes, which seems to be generally oblivious to the convergence rate.
\smallskip\noindent\textbf{$W(0)$ as a Random Matrix.} In Figure~\ref{fig:convergence_3}, we compare the case of $W(0) = V(0)V(0)^T$ with $W(0)$ being a random symmetric matrix ($W(0)$ and $C$ are generally not commutative). The orange dots show the number of iterations till convergence when entries in $W(0)$ are selected uniformly in $(-1, 1)$. The green dots show the number of iterations until convergence when entries in $W(0)$ are selected uniformly in $(-5, 5)$. There are a few observations. 1) When $W(0)$ take random values, it requires more iterations to convergence compared to the case when $W(0) = V(0)V(0)^T$. Specifically, during the evolution when $W(0) = V(0)V(0)^T$ both opinions and weights do not change signs. 2) When the initial weights take greater absolute values in general, the system converges faster. Again the more extreme the opinions/weights are, the faster the system reaches structural balance.
\smallskip\noindent\textbf{On a General Graph.} We also test on graphs generated by social network models. In Figure~\ref{fig:convergence_4}, we show the convergence results on graphs generated by the Erd\H{o}s-Renyi Model $G(n, p)$, where $n$ is the number of nodes and $p$ is the probability of each pair of nodes connected by an edge. As $p$ increases from $0$ to $1$, the graph becomes denser and it requires fewer iterations to converge.
In Figure~\ref{fig:convergence_5} and ~\ref{fig:convergence_6}, we tested on Watts Strogatz model~\cite{Watts1998-gi} $G(n, k, p)$, where $n$ is the number of nodes, $k$ is the number of neighbors of each nodes and $p$ is the rewiring probability. The network starts as a regular ring lattice, where each node connects to $k$ nearest neighbors on the ring. Each neighbor has a probability $p$ to be `rewired' to another non-neighbor node. Thus, with a larger value of $k$, there are more edges in the graph. With a larger rewiring probability $p$, there is more randomness in the graph. In these simulations, the initial weight matrices are set as a zero matrix, i.e., $W(0) = 0$.
Similarly, with the same number of edges in the graph, the relationship between the positive eigenvalue and the number of iterations follows the similar trend. When there are more edges in the graph, the convergence speed increases. In all cases, the network reaches structural balance.
\begin{figure}[tb]
\centering
\subfigure[$W(0) = I$]{
\centering
\includegraphics[width=0.3\columnwidth]{Figure/case_0_Converge_Interation.pdf}
\label{fig:convergence_1}
}
\subfigure[$W(0) = 0$]{
\centering
\includegraphics[width=0.28\columnwidth]{Figure/case_1_Converge_Interation.pdf}
\label{fig:convergence_2}
}
\subfigure[Non-commutative cases]{
\centering
\includegraphics[width=0.3\columnwidth]{Figure/case_2_Converge_Interation.pdf}
\label{fig:convergence_3}
}
\subfigure[Erd\H{o}s-Renyi Model]{
\centering
\includegraphics[width=0.3\columnwidth]{Figure/Random_Graph_case_2_Converge_Interation.pdf}
\label{fig:convergence_4}
}
\subfigure[Watts-Strogatz Model ($p=0$)]{
\centering
\includegraphics[width=0.3\columnwidth]{Figure/WSmodel_p0_case_2_Converge_Interation.pdf}
\label{fig:convergence_5}
}
\subfigure[Watts-Strogatz Model ($p=0.5$)]{
\centering
\includegraphics[width=0.3\columnwidth]{Figure/WSmodel_p5_case_2_Converge_Interation.pdf}
\label{fig:convergence_6}
}
\caption{The number of iterations till network convergence.
When the initial opinions are small in magnitude, the number of iterations to converge is large. When the graph becomes denser, the convergence rate increases.}
\label{fig:converge_rate}
\end{figure}
\subsection{Emergence of Community Structure}
In this section, we ran experiments on real-world network data sets. We are particularly interested in the following question. Can a few planted seeds with opposite opinions influence the other nodes and drive the network into structural balance and polarization? Does the final state coincide with the community structure in the network?
Our first experiment is based on a study by Zachary~\cite{zachary1977information} who witnessed the breakup of a karate club into two small clubs. As shown in Figure~\ref{fig:karate_1}, the networks captures $34$ members, documenting links between pairs of members who interacted outside the club. During the study, a conflict arose between the administrator (label $0$) and the instructor (label $33$), which led to the split. The red and green nodes represent the choice of each individual in the end. In this experiment, we assign the administrator and the instructor opposite opinions as $1$ and $-1$. The other members start with opinion $0$. Given that the links represent interaction and positive friendship between members, each edge is assigned a small positive value in the initial matrix $W(0)$. We then run our co-evolution dynamics till convergence. The edges with negative weight are removed. The graph is separated into two communities, shown in Figure~\ref{fig:karate_2}. It nearly predicted the same division as in the ground truth except for two members ($\#8$ and $\#19$) which are somewhat ambiguous.
The second experiment is based on the political blogs network. It is a directed network of hyperlinks between weblogs on US politics, recorded in 2005 by Adamic and Glance~\cite{adamic2005political}. There are $1,490$ nodes and $19,025$ directed edges in the graph. Each node has its political preference ($-1$ as liberal, $1$ as conservative) shown in Figure~\ref{fig:blog_1}. We randomly select $20\%$ nodes and assign initial opinions according to their ground truth values. All edges are assigned initial weights as a small positive value. When the graph reaches convergence, two big communities appear, as indicated by their final opinions and the sign of edges.
Figure~\ref{fig:blog_2} shows the detected communities after negative edges are removed.
Compared with the ground truth, the predicted opinions by our dynamical model has an accuracy of $97.21\%$, averaged by $200$ simulation runs. If only $3\%$ nodes are assigned ground truth opinions in the initial state, the prediction accuracy for the final opinions of all nodes, on average, is as high as $82.12\%$.
Our dynamic model, as shown by these experiments, explains why community structures appear. It can also be understood as an algorithm for label propagation or node classification. Compared with other methods for the same task~\cite{Xie2013-hz, Jokar2019-km,Tang2016-vp, Bhagat2011-rt} that generally use data-driven machine learning approaches, our dynamic model has better transparency and interpretability. | {'timestamp': '2021-11-05T01:06:31', 'yymm': '2107', 'arxiv_id': '2107.05796', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05796'} | arxiv |
\section{Connecting the Two Algorithms}
In this paper, we described two algorithms for computing subspace embeddings for database joins. The first applied only to the case of two-table joins, and the second applied to general joins queries. However, one may ask whether there are theoretical of empirical reasons to use the latter over the former, even for the case of two-table joins. In this section, we briefly compare the two algorithms in the context of two-table joins to address this question.
\subsection{Theoretical Comparison}
By Theorem \ref{thm:subspace}, the total running time to obtain a subspace embedding is the minimum of $\Tilde{O}((n_1 + n_2)d/\epsilon^2 + d^3 / \epsilon^2)$ and $\Tilde{O}((\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2))/\epsilon^2 +(n_1 + n_2)/\epsilon^2 + d^5/\epsilon^2)$ using Algorithm \ref{alg:1}.
Now we consider the algorithm stated in Corollary \ref{corollary:general:join}. When running on the join of two tables, the algorithm is equivalent to applying the Fast Tensor-Sketch to each block and summing them up. Thus, the running time is $\Tilde{O}(\sum_{i\in\mathcal{B}}(\mathtt{nnz}(\mathbf{T}_1^{(i)})/\epsilon^2 + \mathtt{nnz}(\mathbf{T}_2^{(i)})/\epsilon^2 + d^2/\epsilon^2)) = \Tilde{O}((\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2))/\epsilon^2 + (n_1 + n_2)d^2/\epsilon^2)$.
The running time of the algorithm in Corollary \ref{corollary:general:join} is greater than the running time of Algorithm \ref{alg:1}. In the extreme case the number of blocks can be really large, and even if each block has only a few rows we still need to pay an extra $\Tilde{O}(d^2/\epsilon^2)$ time for it. This is the reason why we split the blocks into two sets ($\mathcal{B_{\text{big}}}$ and $\mathcal{B_{\text{small}}}$) and use a different approach when designing the algorithm for two-table joins.
\subsection{Experimental Comparison}
In our experiments we replace the Fast Tensor-Sketch with Tensor-Sketch. The theoretical analysis is similar since we still need to pay an extra $O(kd\log k)$ time to sketch a block for target dimension $k$.
We run the algorithm for the general case on joins $\mathbf{J}_1$ and $\mathbf{J}_2$ for different target dimensions. As shown in Table \ref{tab:Experiment:J_1,J_2-general}, in order to achieve the same relative error as Algorithm \ref{alg:1}, we need to set a large target dimension and the running time would be significantly greater than it is in Table \ref{tab:Experiment_two-table}, even compared with the FAQ-based algorithm. This experimental result agrees with our theoretical analysis.
\begin{table}
\centering
\caption{General Algorithm on Two-Table Joins}
\label{tab:Experiment:J_1,J_2-general}
\begin{tabular}{|c|c|c|c|}
\hline
& $k$ & running time & relative error\\
\hline
\multirow{5}{*}{$\mathbf{J}_1$} & 40 & 0.086 & 42.3\% \\
\cline{2-4}
& 80 & 0.10 & 9.79\% \\
\cline{2-4}
& 120 & 0.14 & 3.67\% \\
\cline{2-4}
& 160 & 0.16 & 0.87\% \\
\cline{2-4}
& 200 & 0.19& 1.05\% \\
\hline
\multirow{5}{*}{$\mathbf{J}_2$} & 400 & 1.25 & 5.79\% \\
\cline{2-4}
& 800 & 2.02 & 2.32\% \\
\cline{2-4}
& 1200 & 2.93 & 1.85\% \\
\cline{2-4}
& 1600 & 3.74 & 1.19\% \\
\cline{2-4}
& 2000 & 4.50 & 0.96\% \\
\hline
\end{tabular}
\end{table}
\subsection{Two-Table Joins}
In the experiments for two-table joins, we solve the regression problem $\min_x \Vert\mathbf{J}_U x - b\Vert_2^2$,
where $\mathbf{J} = T_1 \Join T_2 \in \mathbb{R}^{N\times d}$ is a join of two tables, $U\subset [d]$ and $b$ is one of the columns of $\mathbf{J}$. In our experiments, suppose column $p$ is the column we want to predict. We will set $U = [d] \setminus \{p\}$ and $b$ to be the $p$-th column of $\mathbf{J}$.
To solve the regression problem, the FAQ-based algorithm computes the covariance matrix $\mathbf{J}^T\mathbf{J}$ by running the FAQ algorithm for every two columns, and then solves the normal equations $\mathbf{J}^T\mathbf{J} x = \mathbf{J}^T b$. Our algorithm will compute a subspace embedding $\Tilde{\mathbf{J}}$, and then solve the regression problem $\min_x \Vert\Tilde{\mathbf{J}}_Ux - \Tilde{b}\Vert_2^2$, i.e., solve $\tilde{\mathbf{J}}^T\tilde{\mathbf{J}}x = \tilde{\mathbf{J}}^T \tilde{b}$.
We compare our algorithm to the FAQ-based algorithm on the LastFM and MovieLens datasets. The FAQ-based algorithm employs the FAQ-based algorithm to calculate each entry in $\mathbf{J}^T \mathbf{J}$.
For the LastFM dataset, we consider the join of \textbf{Userartists} and \textbf{Usertaggedartiststimestamps}:
$\mathbf{J}_1 = \mathbf{UA}\Join_{\mathbf{UA}.\text{user} = \mathbf{UTA}.\text{user}}\mathbf{UTA}.$
Our regression task is to predict how often a user listens to an artist based on the tags.
For the MovieLens dataset, we consider the join of \textbf{Ratings} and \textbf{Movies}:
$\mathbf{J}_2 = \mathbf{R}\Join_{\mathbf{R}.\text{movie} = \mathbf{M}.\text{movie}}\mathbf{M}.$
Our regression task is to predict the rating that a user gives to a movie.
In our experiments, we do the dataset preparation mentioned in \cite{SystemF}, to normalize the values in each column to range $[0,1]$. For each column, let $v_{\max}$ and $v_{\min}$ denote the maximum value and minimum value in this column. We normalize each value $v$ to $(v - v_{\min})/(v_{\max} - v_{\min})$.
\subsection{General Joins}
For general joins, we consider the ridge regression problem. Specifically, our goal is to find a vector $x$ that minimizes $\Vert \mathbf{J} x - b\Vert_2^2 + \lambda \Vert x\Vert_2^2$, where $\mathbf{J}=\mathbf{T}_1\Join \cdots\Join \mathbf{T}_m \in \mathbb{R}^{N\times d}$ is an arbitrary join, $b$ is one of the columns of $\mathbf{J}$ and $\lambda>0$ is the regularization parameter. The optimal solution to the ridge regression problem can be found by solving the normal equations $(\mathbf{J}^T \mathbf{J} + \lambda \mathbb{I}_{d})x = \mathbf{J}^Tb$.
The FAQ-based algorithm is the same as in the experiment for two-table joins. It directly runs the FAQ algorithm a total of $d(d+1)/2$ times to compute every entry of $\mathbf{J}^T \mathbf{J}$.
We run the algorithm described in Section \ref{section:general}, as well as the FAQ-based algorithm, on the MovieLens-25m dataset, which is the largest of the MovieLens\cite{10.1145/2827872} datasets. We consider the join of \textbf{Ratings}, \textbf{Users} and \textbf{Movies}:
$\mathbf{J}_3 = \mathbf{R}\Join_{\mathbf{R}.\text{user}=\mathbf{U}.\text{user}}\mathbf{U}\Join_{\mathbf{U}.\text{movie}=\mathbf{M}.\text{movie}}\mathbf{M}.$
Our regression task is to predict the rating that a user gives to a movie.
\subsection{Results}
\begin{table}\centering
\caption{Experimental Results for Two-Table Joins}
\label{tab:Experiment_two-table}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
& $n_1$ & $n_2$ & $d$ &$T_{\text{bf}}$ & $T_{\text{ours}}$ & \text{err}\\
\hline
$\mathbf{J}_{1}$ & 92834 & 186479 & 6 & .034 & .011 & 0.70\% \\
\hline
$\mathbf{J}_{2}$ & 1000209 & 3883 & 23 & .820 & .088 & 0.66\% \\
\hlin
\end{tabular}
\end{table}
We run the FAQ-based algorithm and our algorithm on those joins and compare their running times. To measure accuracy, we compute the relative mean-squared error, given by:
\[ \text{err} = \frac{\Vert \mathbf{J}_U x_{\text{ours}} - b\Vert_2^2 - \Vert\mathbf{J}_U x_{\text{bf}} - b\Vert_2^2}{\Vert\mathbf{J}_U x_{\text{bf}} - b\Vert_2^2}\]
in the experiments for two-table joins, where $x_{\text{bf}}$ is the solution given by the FAQ-based algorithm, and $x_{\text{ours}}$ is the solution given by our algorithm. All results (runtime, accuracy) are averaged over $5$ runs of each algorithm.
In our implementation, we adjust the target dimension in our sketching algorithm for each experiment, as in practice it appears unnecessary to parameterize according to the worst-case theoretical bounds when the number of features is small, as in our experiments. Additionally, for two-table joins, we replace the Fast Tensor-Sketch with Tensor-Sketch (\cite{ahle2020oblivious, pagh2013compressed}) for the same reason. The implementation is written in MATLAB and run on an Intel Core i7-7500U CPU with 8GB of memory.
We let $T_{\text{bf}}$ be the running time of the FAQ-based algorithm and $T_{\text{ours}}$ be the running time of our approach, measured in seconds. Table \ref{tab:Experiment_two-table} shows the results of our experiments for two-table joins. From that we can see our approach can give a solution with relative error less than $1\%$, and its running time is significantly less than that of the FAQ-based algorithm.
For general joins, due to the size of the dataset, we implement our algorithm in Taichi \cite{hu2019taichi, hu2019difftaichi} and run it on an Nvidia GTX1080Ti GPU. We split the dataset into a training set and a validation set, run the regression on the training set and measure the MSE (mean squared error) on the validation set. We fix the target dimension and try different values of $\lambda$ to see which value achieves the best MSE.
Our algorithm runs in 0.303s while the FAQ-based algorithm runs in 0.988s. The relative error of MSE (namely, $\frac{\text{MSE}_{\text{ours}} - \text{MSE}_{\text{bf}}}{\text{MSE}_{\text{bf}}}$, both measured under the optimal $\lambda$) is only $0.28\%$.
We plot the MSE vs. $\lambda$ curve for the FAQ-based algorithm and our algorithm in Figure \ref{fig:plot_sketch} and \ref{fig:plot_brute_force}. We observe that the optimal choice of $\lambda$ is much larger in the sketched problem than in the original problem. This is because the statistical dimension $d_{\lambda}$ decreases as $\lambda$ increases. Since we fix the target dimension, $\epsilon$ thus decreases. So a larger $\lambda$ can give a better approximate solution, yielding a better MSE even if it is not the best choice in the unsketched problem.
We also plot the relative error of the objective function in Figure \ref{fig:plot_obj}. For ridge regression it becomes
\[\frac{\left(\Vert \mathbf{J} x_{\text{ours}} - b\Vert_2^2 + \lambda \Vert x_{\text{ours}}\Vert_2^2\right)- \left(\Vert\mathbf{J} x_{\text{bf}} - b\Vert_2^2 + \lambda \Vert x_{\text{bf}}\Vert_2^2\right)}{\Vert\mathbf{J} x_{\text{bf}} - b\Vert_2^2 + \lambda \Vert x_{\text{bf}}\Vert_2^2}.\] We can see that the relative error decreases as $\lambda$ increases in accordance with our theoretical analysis.
\section{General Join Queries}\label{sec:general}
\label{section:general}
Below we introduce DB-Sketch as a class of algorithms, and show how any oblivious sketching algorithm that has the properties of DB-Sketch can be implemented efficiently for data coming from a join query. Since the required properties are very similar to the properties of linear sketches for Kronecker products, we will be able to implement them inside of a database. Given that the statistical dimension can be much smaller than the actual dimensions of the input data, our time complexity for ridge regression can be significantly smaller than that for ordinary least squares regression, which is important in the context of joins of many tables.
In the following we assume the join query is acyclic; nevertheless, for cyclic queries it is possible to obtain the hypergraph tree decomposition of the join and create a table for each vertex in the tree decomposition by joining the input tables that are a subset of the vertex's bag in the hypergraph tree decomposition. One can then replace the cyclic join query with an acyclic query using the new tables.
In our algorithm, we use FAQ and inside-out algorithms as subroutines. The definition of FAQ is given in Appendix \ref{appendix:database:background}. Let $\mathbf{J}'=\mathbf{T}_1 \Join \mathbf{T}_2 \Join \dots \Join \mathbf{T}_m$ be an acyclic join. Let $\rho$ be a binary expression tree that shows in what order the algorithm inside-out \cite{abo2016faq} multiplies the factors for an arbitrary single-semiring FAQ; meaning, $\rho$ has a leaf for each factor (each table) and $(m-1)$ internal nodes such that if two nodes have the same parent then their values are multiplied together during the execution of inside-out. We number the tables based on the order that a depth-first-search visits them in this expression tree. We let $\rho$ denote the multiplication order of $\mathbf{J}'$.
Now that the ordering of the tables is fixed, we reformulate the Join table $\mathbf{J}'$ so that it can be expressed as a summation of tensor products. Assign each column $c$ to one of the input tables that has $c$, and then let $E_i$ denote the columns assigned to table $\mathbf{T}_i$, $X_i$ be the projection of $X$ onto $E_i$, and $D_i$ be the domain of the tuples $X_i$ (projection of $\mathbf{T}_i$ onto $E_i$).
Letting $N=|D_1||D_2| \dots |D_m|$, we can reformulate $\mathbf{J}'$ as $\mathbf{J}\in \mathbb{R}^{N\times d}$ to have a row for any possible tuple $X \in D_1 \times \dots \times D_m$. If a tuple $X$ is present in the join, we put its value in the row corresponding to it, and if it is not present we put $0$ in that row. Note that $\mathbf{J}$ has all the rows in $\mathbf{J}'$ and also may have many zero rows; however, we do not need to represent $\mathbf{J}$ explicitly, and the sparsity of $\mathbf{J}$ does not cause a problem. One key property of this formulation is that by knowing the values of a tuple $x$, the location of $x$ in $\mathbf{J}$ is well-defined. Also note that since we have only added rows that are $0$, any subspace embedding of $\mathbf{J}$ would be a subspace embedding of $\mathbf{J}'$, and for all vectors $x$, $\norm{\mathbf{J} x}_2^2 = \norm{\mathbf{J}'x}_2^2$.
Given a join query $\mathbf{J}$ with $m$ tables and its multiplication order $\rho$, an oblivious sketching algorithm is an $(m,\rho)$-DB-Sketch if there exists a function $F:\mathbb{R}^{n \times d} \to R_F$ where $R_F$ is the range of $F$ and $F(\mathbf{A})$ represents the sketch of $\mathbf{A}$ in some form and has the following properties:
\begin{enumerate}
\item $F(\mathbf{A}_1 + \mathbf{A}_2) = F(\mathbf{A}_1) \oplus F(\mathbf{A}_2)$ where $\oplus$ is a commutative and associative operator.
\item For any $V$ resulting from a Kronecker product of matrices $\mathbf{A} = \mathbf{A}_1 \otimes \mathbf{A}_2 \otimes \dots \otimes \mathbf{A}_m \in \mathbb{R}^{n_1 \dots n_m}$, $F(\mathbf{A}) = F_1(\mathbf{A}_1) \odot F_2(\mathbf{A}_2) \odot \dots \odot F_m(\mathbf{A}_m)$ where $\odot$ is applied based on the ordering in $\rho$, and for all $i$, $F_i$ has the same range as $F$, and $F_i(X_1 + X_2) = F_i(X_1) \oplus F_i(X_2)$. Furthermore, it should be possible to evaluate $F_i(v_i)$ in time $O(T_f \mathtt{nnz}(v_i))$.
\item For any values $A,B,C$ in the range of $F$, $A \odot (B \oplus C) = (A \odot B) \oplus (A \odot C)$
\end{enumerate}
\begin{theorem}
\label{thm:dbsketch}
Given a join query $\mathbf{J}'=\mathbf{T}_1 \Join \mathbf{T}_2 \Join \dots \Join \mathbf{T}_m$ and a DB-Sketch algorithm, there exists an algorithm to evaluate $F(\mathbf{J}')$ in time $O(m (T_{\odot} + T_{\oplus}) T_{\text{FAQ}} + T_f mnd)$ where $n$ is the size of the largest table and $T_{\text{FAQ}}$ is the time complexity of running a single semiring FAQ, while $T_{\odot}$ and $T_{\oplus}$ are the time complexities of $\odot$ and $\otimes$, respectively.
\end{theorem}
\begin{corollary}
\label{corollary:general:join}
For any join query $\mathbf{J}$ with multiplication order $\rho$ of depth $m-1$ and any scalar $\lambda$, let $d_\lambda$ be the $\lambda$-statistical dimension of $\mathbf{J}$. Then there exists an algorithm that produces $\mathbf{S} \in \mathbb{R}^{k\times n}$ where $k=O(d_\lambda m^4/\epsilon^2)$ in time $O((mkd)T_{\text{FAQ}} + m^6 n d/\epsilon^2)$ such that with probability $1-\frac{1}{\mathtt{poly}(n)}$ simultaneously for all $x\in \mathbb{R}^d$
\[ \|\mathbf{S}\mathbf{J} x\|_2^2 + \lambda \|x\|_2^2 = (1 \pm \epsilon)(\|\mathbf{J} x\|_2^2 + \lambda \|x\|_2^2).\]
\end{corollary}
\begin{proof}
The proof follows by showing that the algorithm in Lemma \ref{lem:fastTenSketch} is a DB-Sketch. We demonstrate this by introducing the functions $F_i$ and the operators $\oplus$ and $\odot$.
The function $F_i(v_i)$ is an OSNAP transform (Lemma \ref{lem:OSNAP}) of $v_i$, $\mathbf{A} \odot \mathbf{B}$ is $\mathbf{S}(\mathbf{A} \otimes \mathbf{B})$ where $\mathbf{S}$ is the Tensor Subsampled Randomized Hadamard Transform as defined in \cite{ahle2020oblivious}, and $\mathbf{A} \oplus \mathbf{B}$ is a summation of tensors $\mathbf{A}$ and $\mathbf{B}$. Then it is easy to see that all the properties hold since Kronecker product distributes over summation.
Since $F_i$ needs to be calculated for all rows in each table $\mathbf{T}_i$, which takes $O(T_f mnd)$ time, the operator $\oplus$ takes $O(kd)$ time to apply since the size of the sketch is $k \times d$. The operator $\otimes$ takes at most $O(kd)$ time to apply using the Fast Fourier Transform (FFT) \cite{ahle2020oblivious}. Therefore, the total time complexity can be bounded by $O((mkd)T_{\text{FAQ}} + m^6 n d/\epsilon^2)$.
Lastly, we remark that the algorithm in \cite{ahle2020oblivious} requires that the $\odot$ operator be applied to the input tensors in a binary fashion; however, it is shown in a separate version \cite{ahle2019almost} of the paper \cite{ahle2020oblivious} that the sketching construction and results of \cite{ahle2020oblivious} continue to hold when the tensor sketch is applied linearly. See Lemma 6 and 7 in \cite{ahle2019almost} and Lemma 10 in \cite{ahle2020oblivious}.
\end{proof}
Corollary \ref{corollary:general:join} gives an algorithm for all join queries when the corresponding hypertree decomposition is a path, or has a vertex for which all other vertices are connected to it. Although the time complexity for obtaining an $\epsilon$-subspace embedding ($\lambda=0$) is not better compared to the exact algorithm for ordinary least squares regression, for ridge regression it is possible to create sketches with many fewer rows and still obtain a reasonable approximation.
In the following we explain the algorithm for DB-Sketch using the FAQ formulation and inside-out algorithm \cite{abo2016faq}. Let $\mathbf{J}_i$ denote the matrix resulting from keeping the column $i$ of $\mathbf{J}$ and replacing all other columns with $0$. Then we have $\mathbf{J} = \sum_i \mathbf{J}_i$. Using $\mathbf{J}_i$ we can define the proposed algorithm as finding $F(\mathbf{J}_i)$ for all tables $\mathbf{T}_i$ and then calculating $\oplus_i F(\mathbf{J}_i)$.
Therefore, all we need to do is to calculate $F(\mathbf{J}_i)$ for all values of $i$. In the following we introduce an algorithm for the calculation of $F(\mathbf{J}_i)$ and then $F(\mathbf{J})$ is just the summation of the results for the different tables.
Let $e(X_k)$ be the $D_k$-dimensional unit vector that is $1$ in the row corresponding to $X_k$, and let $v(X_k)$ be the $D_k \times d$ dimensional matrix that agrees with $X_k$ in the row corresponding to $X_k$, and is $0$ everywhere else.
\begin{lemma}
\label{lemma:matrix:and:kronocker:product}
For all tables,
$\mathbf{J}_i = \sum_{X \in \mathbf{J}'} e(X_1) \otimes \dots \otimes e(X_{i-1}) \otimes v(X_i) \otimes e(X_{i+1}) \otimes \dots \otimes e(X_{m})$, where $\otimes$ is the Kronecker product.
\end{lemma}
\begin{proof}
For each tuple $X$, the term inside the summation has $N=|D_1||D_2|\dots|D_m|$ rows and only $1$ non-zero row because all of the tensors have only one non-zero row. The non-zero row is the row corresponding to $X$, and its value is the value of the same row in $\mathbf{J}_i$; therefore, $\mathbf{J}_i$ can be obtained by summing over all the tuples of $\mathbf{J}$.
\end{proof}
\begin{lemma}
Let $F$ be a DB-Sketch. Then $F(\mathbf{J}_i)$ can be computed in time $O((T_{\odot} + T_{\oplus}) T_{\text{FAQ}} + T_f ndm)$
\end{lemma}
\begin{proof}
We define a FAQ for $F(\mathbf{J}_i)$ and then show how to calculate the result. Let $g_j(X_j) = F_j(e(X_j))$ for all $j \neq i$ and $g_i(X_i) = F_i(v(X_i))$. Note that the number of non-zero entries in $e(X_i)$ is at most $d$. Therefore, it is possible to find all values of $F_i(v(X_i))$ in time $O(T_f nd)$.
The claim is it is possible to use the inside-out \cite{abo2016faq} algorithm for the following query and find $\mathbf{S}\mathbf{J}_i$:
\begin{align*}
\label{equality:query}
\bigoplus_{X \in \mathbf{J}'} \bigodot_{j} g_j(X_j)
\end{align*}
The mentioned query would be a FAQ if $\bigodot$ were commutative and associative. However, since we defined the ordering of the tables based on the multiplication order $\rho$, the inside-out algorithm multiplies the factors exactly in the same order needed for the DB-sketch algorithm. Therefore, we do not need the commutative and associative property of the $\odot$ operator to run inside-out.
Now we need to show that the query truly calculates $F(\mathbf{J}_i)$. Based on Lemma \ref{lemma:matrix:and:kronocker:product} and the properties of $F$ we have:
\begin{flalign*}
F(\mathbf{J}_i) =&
F\Big(\sum_{X \in \mathbf{J}'} e(X_1) \otimes \dots
\\
&\ \ \ \otimes e(X_{i-1}) \otimes v(X_i) \otimes e(X_{i+1}) \otimes \dots
\\
&\ \ \ \otimes e(X_{m})\Big)
\\
=& \bigoplus_{X \in \mathbf{J}'}F(e(X_1) \otimes \dots
\\
&\ \ \ \otimes e(X_{i-1}) \otimes v(X_i) \otimes e(X_{i+1}) \otimes \dots
\\
&\ \ \ \otimes e(X_{m}))
\\
=&
\bigoplus_{X \in \mathbf{J}'}\Big(F_1(e(X_1)) \odot \dots
\\
&\ \ \ \odot F_{i-1}(e(X_{i-1})) \odot F_{i}(v(X_i)) \odot F_{i+1}(e(X_{i+1}))
\\
&\ \ \ \odot \dots \odot F_m(e(X_{m}))\Big)
\\
=&
\bigoplus_{X \in \mathbf{J}'} \bigodot_{j} g_j(X_j)
\end{flalign*}
as needed.
\end{proof}
\begin{proof}[Proof of Theorem \ref{thm:dbsketch}]
Finding the values of $F_i(X_i)$ for all $i$ and all tuples of $X_i$ takes $O(T_f ndm)$ time because $F_i$ can be calculated in time $O(T_f \mathtt{nnz}(\mathbf{T}_i))$, and the total number of non-zero entries can be bounded by $O(ndm)$. The calculation of $F(\mathbf{J}_i)$ can be done in time $O(m (T_{\odot} + T_{\oplus}) T_{\text{FAQ}} + T_f ndm)$ using $m$ rounds of the inside-out algorithm where $T_{FAQ} = O(md^2n^{\text{fhtw}} \log(n))$ \cite{abo2016faq}. After this step, we need to aggregate the results using the $\oplus$ operator to obtain the final result which takes $O(m T_\oplus)$ time.
\end{proof}
\subsection{Database Joins}\label{sec:databasenotation}
We first introduce the notion of a \textit{block} of a join, which will be important in our analysis.
Let $\mathbf{T}_1,\dots,\mathbf{T}_m$ be tables, with $\mathbf{T}_i \in \mathbb{R}^{n_i \times d_i}$.
Let $\mathbf{J}=\mathbf{T}_1 \Join \mathbf{T}_2 \Join \dots \Join \mathbf{T}_m \in \mathbb{R}^{N \times d}$ be an arbitrary join on the tables $\mathbf{T}_i$.
Let $Q$ be the subset of columns which are contained in at least two tables, e.g., the columns which are joined upon. For any subset $U$ of columns and any table $T$ containing a set of columns $U'$, let $T|_U$ be the projection of $T$ onto the columns in $U \cap U'$. Similarly define $r|_U$ for a row $r$. Let $C$ be the set of columns in $\mathbf{J}$, and let $C_j \subset C$ be the columns contained in $T_j$.
Define the set of \textit{blocks} $\mathcal{B} = \mathcal{B}(\mathbf{J}) \subset \mathbb{R}^{|Q|}$ of the join to be the set of distinct rows in the projection of $\mathbf{J}$ onto $Q$. In other words, $\mathcal{B}$ is the set of distinct rows which occur in the restriction of $\mathbf{J}$ to the columns being joined on.
For any $j \in [m]$, let $\hat{\mathbf{T}}_j \in \mathbb{R}^{n_j \times d}$ be the embedding of the rows of $\mathbf{T}_j$ into the join $\mathbf{J}$, obtained by padding $\mathbf{T}_j$ with zero-valued columns for each column not contained in $\mathbf{T}_j$, and such that for any column $c$ contained in more than one $\mathbf{T}_j$, we define the matrices $\hat{\mathbf{T}}_j$ so that exactly one of the $\hat{\mathbf{T}}_j$ contains $c$ (it does not matter which of the tables containing the column $c$ has $c$ assigned to it in the definition of $\hat{\mathbf{T}}_j$). More formally, we fix any partition $\{\hat{C}_j\}_{j \in [m]}$ of $C$, such that $C = \cup_j \hat{C}_j$ and $\hat{C}_j \subseteq C_j$ for all $j$.
For simplicity, given a block $\vec{i} \in \mathcal{B}$, which was defined as a row in $\mathbb{R}^{|Q|}$, we drop the vector notation and write $\vec{i} = i \in \mathcal{B}$.
For a given $i = (i_1,\dots,i_{|Q|}) \in \mathcal{B}$, let $s_{(i)}$ denote the \textit{size} of the block, meaning the number of rows $r$ of the join $\mathbf{J}$ such that $i_j$ is in the $j$-th column of $r$ for all $j \in Q$. For $i \in \mathcal{B}$, let $\mathbf{T}_j^{(i)}$ be the subset of rows $r$ in $\mathbf{T}_j$ such that $r|_Q =i|_{C_j}$, and similarly define $\hat{\mathbf{T}}_j^{(i)}, \mathbf{J}^{(i)}$ to be the subset of rows $r$ in $\hat{\mathbf{T}}_j$ (respectively $\mathbf{J}$) such that $r|_Q = i|_{\hat{C}_j}$ (respectively $r|_Q = i$).
For a row $r$ such that $r|_Q = i$ we say that $r$ ``belongs'' to the block $i \in \mathcal{B}$.
Let $s_{(i),j}$ denote the number of rows of $\mathbf{T}_j^{(i)}$, so that $s_{(i)} = \prod_{j=1}^m s_{(i),j}$.
As an example, considering the join $T_1(A,B) \Join T_2(B,C)$, we have one block for each distinct value of $B$ that is present in both $T_1$ and $T_2$, and for a given block $B=b$, the size of the block can be computed as the number of rows in $T_1$, with $B=b$, multiplied by the number of rows in $T_2$, with $B=b$.
Using the above notion of blocks of a join, we can construct $\mathbf{J}$ as a stacking of matrices $\mathbf{J}^{(i)}$ for $i \in \mathcal{B}$. For the case of two table joins $\mathbf{J} = \mathbf{T}_1 \Join \mathbf{T}_2$, we have $\mathbf{J}^{(i)} = \left(\hat{\mathbf{T}}_1^{(i)} \otimes \mathbf{1}^{s_{(i),2}} + \mathbf{1}^{s_{(i),1}} \otimes \hat{\mathbf{T}}_2^{(i)}\right) \in \mathbb{R}^{s_{(i)} \times d}$. In other words, $\mathbf{J}^{(i)}$ is the subset of rows of $\mathbf{J}$ contained in block $i$. Observe that the entire join $\mathbf{J}$ is the result of stacking the matrices $\mathbf{J}^{(i)}$ on top of each other, for all $i \in \mathcal{B}$. In other words, if $\mathcal{B} = \{i_1,i_2,\dots, i_{|\mathcal{B}|}\}$, the join $\mathbf{J} = \mathbf{T}_1 \Join \mathbf{T}_2$ is given by
$ \mathbf{J} = \left[
(\mathbf{J}^{(i_1)})^T ,
(\mathbf{J}^{(i_2)})^T,
\dots ,
(\mathbf{J}^{(i_{|\mathcal{B}|})})^T \right]^T$.
Figure \ref{fig:example_two_tables} illustrates an example of blocks in a two table join. In this example column $f_2$ is the column that we are joining the two tables on, and there are two values for $f_2$ that are present in both tables, namely the values$\{1,2\}$. Thus $\mathcal{B} = \{B_1,B_2\}$, where $B_1 =1$ and $B_2 = 2$. In other words, Block $B_1$ is the block for value $1$, and its size is $s_1 = 4$, and similarly $B_2$ has size $s_2 = 4$. Figure \ref{fig:example_two_tables} illustrates how the join $\mathcal{J}$ can be written as stacking together the block-matrices $\mathbf{J}^{(1)}$ and $\mathbf{J}^{(2)}$. Figure \ref{fig:example:partial_tables} shows the tables $T_i^{(j)}$ for different values of $i$ and $j$ in the same example.
\begin{figure}[t!]
\centering
\includegraphics[scale=0.65]{example.PNG}
\caption{Example of two table join blocks}
\label{fig:example_two_tables}
\end{figure}
\begin{figure}[t!]
\centering
\begin{tabular}{|c|c|}
\hline
\rowcolor[HTML]{FFFFC7}
\multicolumn{2}{|c|}{\cellcolor[HTML]{FFFFC7}$T_1^{(1)}$} \\ \hline
\rowcolor[HTML]{FFFFC7}
$f_1$ & $f_2$ \\ \hline
1 & 1 \\ \hline
2 & 1 \\ \hline
\end{tabular}
\quad
\begin{tabular}{|c|c|}
\hline
\rowcolor[HTML]{FFFFC7}
\multicolumn{2}{|c|}{\cellcolor[HTML]{FFFFC7}$T_1^{(2)}$} \\ \hline
\rowcolor[HTML]{FFFFC7}
$f_1$ & $f_2$ \\ \hline
3 & 2 \\ \hline
\end{tabular}
\quad
\begin{tabular}{|c|c|}
\hline
\rowcolor[HTML]{FFFFC7}
\multicolumn{2}{|c|}{\cellcolor[HTML]{FFFFC7}$T_2^{(1)}$} \\ \hline
\rowcolor[HTML]{FFFFC7}
$f_2$ & $f_3$ \\ \hline
1 & 1 \\ \hline
1 & 2 \\ \hline
\end{tabular}
\quad
\begin{tabular}{|c|c|}
\hline
\rowcolor[HTML]{FFFFC7}
\multicolumn{2}{|c|}{\cellcolor[HTML]{FFFFC7}$T_2^{(2)}$} \\ \hline
\rowcolor[HTML]{FFFFC7}
$f_2$ & $f_3$ \\ \hline
2 & 3 \\ \hline
\end{tabular}
\caption{Examples of $T_i^{(j)}$}
\label{fig:example:partial_tables}
\end{figure}
Finally, for any subset $U \subseteq [N]$, let $\mathbf{J}_{U}$ denote the set of rows of $\mathbf{J}$ belonging to $U$. If $L$ is a set of blocks of $J$, meaning $L \subseteq \mathcal{B}(\mathbf{J})$, then let $\mathbf{J}_L$ denote the set of rows of $\mathbf{J}$ belonging to some block $i \in L$ (recall that a row $r$ ``belongs'' to a block $i \in L \subseteq \mathcal{B}$ if $r|_Q = i$). A table of notation summarizing the above can be found in Figure \ref{tab:TableOfNotation}.
\begin{table}[h]\caption{Table of Notation}
\begin{center}
\begin{tabular}{r c p{6cm} }
\toprule
$T_{i}$ & $\triangleq$ & a $n_i \times d_i$ sized table\\
$\mathbf{J}$ & $\triangleq$ & join of all tables, i.e., $\mathbf{J} = T_1 \Join T_2 \Join \dots \Join T_m$ \\
$C$ & $\triangleq$ & set of columns of $\mathbf{J}$\\
$C_i$ & $\triangleq$ & set of columns of $T_i$\\
$\hat{C}_i$ & $\triangleq$ & Partition of $C$ such that $\hat{C}_i \subseteq C_i$ for $i \in [m]$. \\
$T|_U$ & $\triangleq$ & projection of $T$ onto columns $U \cap U'$, where $U'$ are the columns of $T$\\
$\hat{T}_{i}$ & $\triangleq$ & Result of padding $T_i|_{\hat{C}_i}$ with zero-valued columns in $C \setminus \hat{C}_i$\\
$\mathcal{B}$ & $\triangleq$ & set of \textit{blocks}, i.e., distinct rows of $\mathbf{J}|_Q$\\
$s_{(i)}$ & $\triangleq$ & size of block $i$, i.e., number of rows $r$ of $\mathbf{J}$ with $r|_q = i \in \mathcal{B}$\\
$T_j^{(i)}$ & $\triangleq$ & subset of rows $r$ in $\mathbf{T}_j$ such that $r|_Q =i|_{C_j}$ \\
$\hat{T}_j^{(i)}$ & $\triangleq$ & subset of rows $r$ in $\hat{T}_j$ such that $r|_Q =i|_{\hat{C}_j}$ \\
$\mathbf{J}_j^{(i)}$ & $\triangleq$ & subset of rows $r$ in $\mathbf{J}$ such that $r|_Q =i$ \\
\bottomrule
\end{tabular}
\end{center}
\label{tab:TableOfNotation}
\end{table}
\subsection{Background for General Database Joins}\label{appendix:database:background}
We begin with some additional definitions relating to database joins.
\begin{definition}[Join Hypergraph]
Given a join $\mathbf{J}=\mathbf{T}_1 \Join \dots \Join \mathbf{T}_m$, the hypergraph associated with the join is $H=(V,E)$ where $V$ is the set of vertices and for every column $c_i$ in $J$, there is a vertex $v_i$ in $V$, and for every table $\mathbf{T}_i$ there is a hyper-edge $e_i$ in $E$ that has the vertices associated with the columns of $\mathbf{T}_i$.
\end{definition}
\begin{definition}[Acyclic Join]
We call a join query \textbf{acyclic} if one can repeatedly apply one of the two operations and convert the query to an empty query:
\begin{enumerate}
\item remove a column that is only in one table.
\item remove a table for which its columns are fully contained in another table.
\end{enumerate}
\end{definition}
\begin{definition}[Hypergraph Tree Decomposition]
Let $H=(V,E)$ be a hypergraph and $T=(V',E')$ be a tree on a set of vertices, where each vertex $v' \in V'$ is called the \textbf{bag} of $v'$, denoted by $b(v')$, and corresponds to a subset of vertices of $V$. Then $T$ is called a \textbf{hypergraph tree decomposition} of $H$ if the following holds:
\begin{enumerate}
\item for each hyperedge $e \in E$, there exists $v' \in V'$ such that $e \subseteq b(v')$, and
\item for each vertex $v \in V$, the set of vertices in $V'$ that have $v$ in their bag is non-empty and they form a connected subtree of $T$.
\end{enumerate}
\end{definition}
\begin{definition}
Let $H=(V,E)$ be a join hypergraph and $T=(V',E')$ be its tree decomposition. For each $v' \in V'$, let $X^{v'} = \allowbreak (x_1^{v'},x_2^{v'}, \allowbreak \dots, x_m^{v'})$ be the optimal solution to the following linear program: $\texttt{min} \sum_{j=1}^{t} x_{j}$, $\text{subject to } \sum_{j:v_{i} \in e_{j} }x_{j} \geq 1, \forall v_i \in b(v')$ where $0 \leq x_{j} \leq 1$ for each $j \in [t]$.
Then the \textbf{width of $v'$} is $\sum_i x^{v'}_i$, denoted by $w(v')$, and the \textbf{fractional width of $T$} is $\max_{v' \in V'} w(v')$.
\end{definition}
\begin{definition}[fhtw]
Given a join hypergraph $H=(V,E)$, the \textbf{fractional hypertree width of $H$}, denoted by fhtw, is the minimum fractional width of its hypergraph tree decomposition. Here the minimum is taken over all possible hypertree decompositions.
\end{definition}
\begin{observation}
The fractional hypertree width of an \allowbreak acyclic join is $1$, and each bag in its hypergraph tree decomposition is a subset of the columns in some input table.
\end{observation}
\begin{definition}[FAQ]
Let $J=T_1\Join\dots \Join T_m$ be a join of $m$ input tables. For each table $T_i$, let $F_i: T_i \to S$ be a function mapping the rows of $T_i$ to a set $S$. For every row $X\in J$, let $X_i$ be the projection of $X$ onto the columns of $T_i$. Then the following is a SumProd Functional Aggregation Query (FAQ):
\begin{align}
\bigoplus_{X \in J} \bigotimes_i F_i(X_i)
\end{align}
where $(S,\oplus,\otimes)$ is a commutative semiring.
\end{definition}
\begin{theorem}[\cite{abo2016faq}]
\label{thm:inside_out}
Inside-out is an algorithm which computes the result of a FAQ in time $O(T md^2n^{\text{fhtw}}\log(n))$ where $m$ is the number of tables, $d$ is the number of columns in $J$, $n$ is the maximum number of rows in any input table, $T$ is the time to compute the operators $\oplus$ and $\otimes$ on a pair of operands, and $fhtw$ is the fractional hypertree width of the query.
\end{theorem}
In \cite{Indatabase:Linear:Regression}, given a join $J=T_1 \Join \dots \Join T_m$, it is shown that the entries of $J^T J$ can be expressed as a FAQ and computed using the inside-out algorithm.
\subsection{Linear Algebra}
We use boldface font, e.g., $\mathbf{A},\mathbf{B},\mathbf{J}$, throughout to denote matrices.
Given $\mathbf{A} \in \mathbb{R}^{n \times d}$ with rank $r$, we write $\mathbf{A} = \mathbf{U} \mathbf{\Sigma} \mathbf{V}^T$ to denote the singular value decomposition (SVD) of $\mathbf{A}$, where $\mathbf{U} \in \mathbb{R}^{n \times r}, \mathbf{V} \in \mathbb{R}^{d \times r}$, and $\mathbf{\Sigma} \in \mathbb{R}^{ r \times r}$ is a diagonal matrix containing the non-zero singular values of $\mathbf{A}$. For $i \in [d]$, we write $\sigma_i(\mathbf{A})$ to denote the $i$-th (possibly zero-valued) singular value of $\mathbf{A}$, so that $\sigma_1(\mathbf{A}) \geq \sigma_2(\mathbf{A}) \geq \dots \geq \sigma_d(\mathbf{A})$. We also use $\sigma_{\max(\mathbf{A})}$ and $\sigma_{\min}(\mathbf{A})$ to denote the maximum and minimum singular values of $\mathbf{A}$ respectively, and let $\kappa(\mathbf{A}) = \frac{\sigma_{\max}(\mathbf{A})}{\sigma_{\min}(\mathbf{A})}$ denote the condition number of $\mathbf{A}$. Let $\mathbf{A}^+$ denote the Moore-Penrose pseudoinverse of $\mathbf{A}$, namely $\mathbf{A}^+ = \mathbf{V} \mathbf{\Sigma}^{-1} \mathbf{U}^T$. Let $\|\mathbf{A}\|_F = (\sum_{i,j} \mathbf{A}_{i,j}^2 )^{1/2}$ denote the Frobenius norm of $\mathbf{A}$, and $\|\mathbf{A}\|_2 = \sigma_{\max}(\mathbf{A})$ the spectral norm. We write $\mathbb{I}_n \in \mathbb{R}^{n \times n}$ to denote the $n$-dimensional identity matrix. For a matrix $\mathbf{A} \in \mathbb{R}^{n \times d}$, we write $\mathtt{nnz}(\mathbf{A})$ to denote the number of non-zero entries of $\mathbf{A}$. We can assume that each row of the table $\mathbf{T}_j$ is non-zero, since otherwise the row can be removed, and thus $\mathtt{nnz}(\mathbf{T}_j) \geq n_i$. Given $\mathbf{A} \in \mathbb{R}^{n \times d}$, we write $\mathbf{A}_{i,*} \in \mathbb{R}^{1 \times d}$ to denote the $i$-th row (vector) of $\mathbf{A}$, and $\mathbf{A}_{*,i} \in \mathbb{R}^{n \times 1}$ to denote the $i$-th column (vector) of $\mathbf{A}$.
For values $a,b \in \mathbb{R}$ and $\epsilon >0$, we write $a = (1 \pm \epsilon)b$ to denote the containment $(1-\epsilon)b \leq a \leq (1+\epsilon) b$. For $n \in \mathbb{Z}_+$, let $[n] = \{1,2,\dots,n\}$. Throughout, we will use $\tilde{O}(\cdot)$ notation to omit poly$(\log N)$ factors.
\begin{definition}[Statistical Dimension]
For a matrix $\mathbf{A} \in \mathbb{R}^{n \times d}$, and a non-negative scalar $\lambda$, the $\lambda$-statistical dimension is defined to be $d_\lambda = \sum_i \frac{\lambda_i(\mathbf{A}^T \mathbf{A})}{\lambda_i(\mathbf{A}^T \mathbf{A}) + \lambda}$, where $\lambda_i(\mathbf{A}^T \mathbf{A})$ is the $i{\text{-th}}$ eigenvalue of $\mathbf{A}^T \mathbf{A}$.
\end{definition}
\begin{definition}[Subspace Embedding]
For an $\epsilon \geq 0$, we say that $\tilde{\mathbf{A}} \in \mathbb{R}^{m \times d}$ is an $\epsilon$-subspace embedding for $\mathbf{A} \in \mathbb{R}^{n \times d}$ if for all $x \in \mathbb{R}^d$ we have
\[ (1 - \epsilon)\|\mathbf{A} x\|_2 \leq \|\tilde{\mathbf{A}} x\|_2 \leq (1+\epsilon) \|\mathbf{A} x\|_2. \]
\end{definition}
Note that if $\tilde{\mathbf{A}} \in \mathbb{R}^{m \times d}$ is an $\epsilon$-subspace embedding for $\mathbf{A} \in \mathbb{R}^{n \times d}$, in particular this implies that $\sigma_i(\mathbf{A}) = (1 \pm \epsilon) \sigma_i(\tilde{\mathbf{A}})$ for all $i \in [d]$.
\subsubsection{Leverage Scores} \label{app:leverage}
The leverage score of the $i$-th row $\mathbf{A}_{i,*}$ of $\mathbf{A} \in \mathbb{R}^{n \times d}$ is defined to be $\tau_i(\mathbf{A}) = \mathbf{A}_{i,*} (\mathbf{A}^T \mathbf{A})^+ \mathbf{A}_{i,*}^T$.
Let $\tau(\mathbf{A}) \in \mathbb{R}^{n}$ be the vector such that $(\tau(\mathbf{A}))_i = \tau_i(\mathbf{A})$. Then $\tau(\mathbf{A})$ is the diagonal of $\mathbf{A} (\mathbf{A}^T \mathbf{A})^+ \mathbf{A}^T$, which is a projection matrix. Thus $\tau_i(\mathbf{A}) \leq 1$ for all $i \in [n]$. It is also easy to see that $\sum_{i=1}^n \tau_i(\mathbf{A}) \leq d$ \cite{cohen2015uniform}. Our algorithm will utilize the \textit{generalized leverage scores}. Given matrices $\mathbf{A} \in \mathbb{R}^{n \times d}$ and $\mathbf{B} \in \mathbb{R}^{n_1 \times d}$, the generalized leverage scores of $\mathbf{A}$ with respect to $\mathbf{B}$ are defined as
\[ \tau_i^{\mathbf{B}}( \mathbf{A}) = \begin{cases}
\mathbf{A}_{i,*} (\mathbf{B}^T \mathbf{B})^+ \mathbf{A}_{i,*}^T & \text{if } \mathbf{A}_{i,*} \bot \text{ker}(\mathbf{B}) \\
1 & \text{otherwise} \\
\end{cases}\]
We remark that in the case were $\mathbf{A}_{i,*}$ has a component in the kernel (null space) of $B$, denoted by $\text{ker}(\mathbf{B})$, $\tau_i^{\mathbf{B}}( \mathbf{A})$ is defined to be $\infty$ in \cite{cohen2015uniform}. However, as stated in that paper, this definition was simply for notational convenience, and the results would equivalently hold setting $\tau_i^{\mathbf{B}}( \mathbf{A}) =1$ in this case.
Note that for a matrix $\mathbf{A} \in \mathbb{R}^{n \times d}$ with SVD $\mathbf{B} = \mathbf{U} \mathbf{\Sigma} \mathbf{V}^T$, we have $(\mathbf{B}^T \mathbf{B})^+ = \mathbf{V} \Sigma^{-2} \mathbf{V}^T$. Thus, for any $x \in \mathbb{R}^d$, we have $x^T (\mathbf{B}^T \mathbf{B})^+ x = \|x^T \mathbf{V} \Sigma^{-1}\|_2^2$, and in particular $\tau_i^{\mathbf{B}}( \mathbf{A}) = \|\mathbf{A}_{i,*}^T \mathbf{V} \Sigma^{-1}\|_2^2$ if $\mathbf{A}_{i,*} \bot \text{ker}(\mathbf{B})$, where $\mathbf{A}_{i,*} \bot \text{ker}(\mathbf{B})$ means $\mathbf{A}_{i,*}$ is perpendicular to the kernel of $\mathbf{B}$.
\begin{proposition}\label{prop:tausubspace}
If $\mathbf{B}' \in \mathbb{R}^{n_1' \times d}$ is an $\epsilon$-subspace embedding for $\mathbf{B} \in \mathbb{R}^{n_1 \times d}$, and $\mathbf{A} \in \mathbb{R}^{n \times d}$ is any matrix, then $\tau_i^{\mathbf{B}'}(\mathbf{A}) = (1 \pm O(\epsilon)) \tau_i^{\mathbf{B}}(\mathbf{A})$
\end{proposition}
\begin{proof}
If $\mathbf{B}' $ is an $\epsilon$-subspace embedding for $\mathbf{B}$, then the spectrum of $(\mathbf{B}' (\mathbf{B}')^T)^+$ is a $(1 \pm \epsilon)^{-2}$ approximation to the spectrum of $(\mathbf{B} \mathbf{B}^T)^+$, so $x^T(\mathbf{B}' (\mathbf{B}')^T)^+x = (1 \pm \epsilon)^{-2} x^T(\mathbf{B} \mathbf{B}^T)^+x$ for all $x \in \mathbb{R}^d$, which completes the proof.
\end{proof}
Our algorithm will employ a mixture of several known oblivious subspace embeddings as tools to construct our overall database join SE. The first result we will need is an improved variant of \textit{Tensor-Sketch}, which is an SE that can be applied quickly to tensor products of matrices.
\begin{lemma}[Fast Tensor-Sketch, Theorem \allowbreak 3 of \cite{ahle2020oblivious}]\label{lem:fastTenSketch}
Fix any matrices $\mathbf{A}_1, \mathbf{A}_2, \dots, \mathbf{A}_m$, where $\mathbf{A}_i \in \mathbb{R}^{n_i \times d_i} $, fix $\epsilon >0$ and $\lambda \geq 0$. Let $n = n_1 \cdots n_m$ and $d = d_1 \cdots d_m$. Let $\mathbf{A} = \mathbf{A}_1 \otimes \mathbf{A}_2 \otimes \cdots \otimes \mathbf{A}_m$ have statistical dimension $d_\lambda$. Then there is an oblivious randomized sketching algorithm which produces a matrix $\mathbf{S} \in \mathbb{R}^{k \times n}$, where $k = O(d_\lambda m^4 / \epsilon^2)$, such that with probability $1-1/\mathtt{poly}(n)$, we have that for all $x \in \mathbb{R}^d$
\[ \|\mathbf{S} \mathbf{A} x\|_2^2 + \lambda \|x\|_2^2 = (1 \pm \epsilon)(\|\mathbf{A} x\|_2^2 + \lambda \|x\|_2^2).\]
Note for the case of $\lambda = 0$, this implies that $\mathbf{S}\mathbf{A}$ is an $\epsilon$-subspace embedding for $\mathbf{A}$. Moreover, $\mathbf{S}\mathbf{A}$ can be computed in time $\tilde{O}( \sum_{i=1}^m \mathtt{nnz}(\mathbf{A}_i)/\epsilon^2\cdot m^5 + kdm)$.\footnote{Theorem 3 of \cite{ahle2020oblivious} is written to be applied to the special case of the polynomial kernel, where $A_1 = A_2 = \dots = A_m$. However, the algorithm itself does not use this fact, nor does it require the factors in the tensor product to be non-distinct.}
\end{lemma}
For the special case of $\lambda=0$ in Lemma \ref{lem:fastTenSketch}, the statistical dimension is $d$, and Tensor-Sketch is just a standard SE.
\begin{lemma}[OSNAP Transform \cite{nelson2013osnap}]\label{lem:OSNAP}
Given any $\mathbf{A} \allowbreak \in \mathbb{R}^{N \times d}$, there is a randomized oblivious sketching algorithm that produces a matrix $\mathbf{W} \in \mathbb{R}^{t \times N}$ with $t = \tilde{O}(d/\epsilon^2)$, such that $\mathbf{W}\mathbf{A}$ can be computed in time $\tilde{O}(\mathtt{nnz}(\mathbf{A})/\epsilon^2)$, and such that $\mathbf{W} \mathbf{A}$ is an $\epsilon$-subspace embedding for $\mathbf{A}$ with probability at least $99/100$. Moreover, each column of $\mathbf{W}$ has at most $\tilde{O}(1)$ non-zero entries.
\end{lemma}
\begin{lemma}[Count-Sketch\cite{10.1145/2488608.2488620}]\label{lem:CountSketch}
For any fixed matrix $\mathbf{A}\in\mathbb{R}^{n\times d}$, and any $\epsilon>0$, there exists an algorithm which produces a matrix $\mathbf{S}\in\mathbb{R}^{k\times n}$, where $k = O(d^2/\epsilon^2)$, such that $\mathbf{S}\mathbf{A}$ is an $\epsilon$-subspace embedding for $\mathbf{A}$ with probability at least $99/100$. Moreover, each column of $\mathbf{S}$ contains exactly one non-zero entry, and therefore $\mathbf{S}\mathbf{A}$ can be computed in $O(\mathtt{nnz}(\mathbf{A}))$ time
\end{lemma}
\subsection{Analysis}\label{sec:twotableanalysis}
We will begin by proving our main technical sampling result, which proceeds in a series of lemmas, and demonstrates that the construction of the diagonal sampling matrix $\mathbf{S}_{\text{small}}$ in Algorithm \ref{alg:1} can be carried out extremely quickly.
\begin{proposition}\label{prop:nbound}
Let $\mathbf{J}_{\text{small}} \in \mathbb{R}^{n_{\text{small}} \times d}$ be the matrix constructed as in Algorithm \ref{alg:1}. Then we have $n_{\text{small}} \leq (n_1 + n_2) d \cdot \gamma$, where $\gamma=1$ in the dense case and $\gamma =d$ in the sparse case.
\end{proposition}
\begin{proof}
Recall that $\mathbf{J}_{\text{small}}$ consists of all blocks $i$ of $\mathbf{J}$ with $\max \{s_{(i),1}, \allowbreak s_{(i),2} \} < d \cdot \gamma $, and thus $s_{(i)} \leq d^2 \gamma^2$.
The total number $n_{\text{small}}$ of rows in $\mathbf{J}_{\text{small}}$ is then $\sum_{i \in \mathcal{B}_{\text{small}} } s_{(i),1}\cdot s_{(i),2} \leq \|s^1_{\text{small}}\|_2 \|s^2_{\text{small}}\|_2$ by the Cauchy-Schwarz inequality, where $s^j_{\text{small}}$ is the vector with coordinates given by the values $s_{(i),j}$ for $i \in \mathcal{B}_{\text{small}}$.
Observe that these vectors admit the $\ell_1$ bound of $\|s^j_{\text{small}}\|_1 \leq n_j$ since each table $\mathbf{T}_j$ has only $n_j$ rows. Moreover, they admit the $\ell_\infty$ bound of $\|s^j_{\text{small}}\|_\infty \leq d \gamma$.
With these two constraints, it is standard that the $\ell_2$ norm is maximized by placing all of the $\ell_1$ mass on coordinates with value given by the $\ell_\infty$ bound.
It follows that $\|s^j_{\text{small}}\|_2$ is maximized by having $n_i/(d\gamma)$ coordinates equal to $d \gamma$, giving $\|s^j_{\text{small}}\|_2^2 \leq n_j d \gamma$ for $j \in [2]$, so $n_{\text{small}} \leq \|s^1_{\text{small}}\|_2 \|s^2_{\text{small}}\|_2 \leq (n_1 + n_2) d \gamma$ as required.
\end{proof}
We now demonstrate how we can quickly $\ell_2$ sample rows from a join-vector or join-matrix product after input sparsity time pre-processing. This procedure is split into two algorithms, Algorithm \ref{alg:L2presample} and \ref{alg:L2sample}. Algorithm \ref{alg:L2presample} is an input sparsity time pre-processing step, which given $\mathbf{J} \in \mathbb{R}^{n \times d}$ and $\mathbf{Y} \in \mathbb{R}^{d \times t}$, constructs several binary tree data structures. Algorithm \ref{alg:L2sample} then uses these data structures to sample a row of the product $\mathbf{J} \mathbf{Y}$ with probability proportional to its $\ell_2$ norm, in time $O( \log N)$.
The following lemma shows we can compute $\mathbf{S}\mathbf{J}_{\text{small}}$ in input sparsity time using Algorithm \ref{alg:L2presample} and \ref{alg:L2sample}.
\begin{lemma} \label{lem:twotablemain} Set the value $\gamma = 1$ in the dense case, and $\gamma = d$ in the sparse case.
Let $\mathbf{J}_{\text{small}} \in \mathbb{R}^{n_{\text{small}} \times d}$ and let $\tilde{\mathbf{J}}_{\text{small}} \in \mathbb{R}^{m \times d}$ be the subset of rows of $\mathbf{J}_{\text{small}} $ constructed in Algorithm \ref{alg:1}, where $m = \Theta( (n_1 + n_2)/\gamma)$. Let $\mathbf{S}$ be the diagonal sampling matrix as constructed in Algorithm \ref{alg:1}. Then with probability $1-1/d$, we have that $\mathbf{S} \mathbf{J}_{\text{small}}$ is an $\epsilon$-subspace embedding for $\mathbf{J}_{\text{small}}$. Moreover, $\mathbf{S}$ has at most $\tilde{O}(d^2 \gamma^2 /\epsilon^2 )$ non-zero entries, and
$\mathbf{S}\mathbf{J}_{\text{small}}$ can be computed in time $\tilde{O}(\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2) + d^3 \gamma^2 /\epsilon^2 )$.
\end{lemma}
We defer the proof of the Lemma to Section \ref{app:twotablemain}, and first show how our main results follow given Lemma \ref{lem:twotablemain}.
\smallskip
\textbf{Theorem \ref{thm:subspace} }[In-Database Subspace Embedding] {\it
Suppose $\mathbf{J}=\mathbf{T}_1 \Join \mathbf{T}_2 \in \mathbb{R}^{n \times d}$ is a join of two tables, where $\mathbf{T}_1 \in \mathbb{R}^{n_1 \times d_1},\mathbf{T}_2 \in \mathbb{R}^{n_2 \times d_2}$. Then Algorithm \ref{alg:1} outputs a sketching matrix $\mathbf{S}^* \in \mathbb{R}^{k \times n}$ with $k = \tilde{O}(d^2 \gamma^2 /\epsilon^2)$ (where $\gamma$ is chosen as in Lemma \ref{lem:twotablemain}) such that $\tilde{\mathbf{J}} = \mathbf{S}^* \mathbf{J}$ is an $\epsilon$-subspace embedding for $\mathbf{J}$, meaning
\[\|\mathbf{S}^*\mathbf{J} x\|_2^2 = (1 \pm \epsilon)\|\mathbf{J} x\|_2^2 \]
for all $x \in \mathbb{R}^{d}$ with probability at least $9/10$. The runtime to return $\mathbf{S}^* \mathbf{J}$ is the minimum of $\tilde{O}((n_1 + n_2)d/\epsilon^2 + d^{3}/\epsilon^2 )$ and $\tilde{O}((\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2))/\epsilon^2 +d^5/\epsilon^2 )$.
}
\begin{proof}
Our algorithm partitions the rows of $\mathbf{J}$ into those from $\mathcal{B}_{\text{small}}$ and $\mathcal{B}_{\text{big}}$, and outputs the result of stacking sketches for $\mathbf{J}_{\text{small}}$ and $\mathbf{J}^{(i)}$ for each $i \in \mathcal{B}_{\text{big}}$. Thus it suffices to show that each sketch $\mathbf{S}^i \mathbf{J}^{(i)}$ is a subspace embedding for $\mathbf{J}^{(i)}$, and $\mathbf{S} \mathbf{J}_{\text{small}}$ is a subspace embedding for $\mathbf{J}_{\text{small}}$. The latter holds by Lemma \ref{lem:twotablemain}, and the former follows directly from applying Lemma \ref{lem:fastTenSketch} and a union bound over the at most $O(n)$ such $i$. Since each such $\mathbf{J}^{(i)}$ can be written as $\mathbf{J}^{i} = \left( \hat{\mathbf{T}}_1^{(i)} \otimes \mathbf{1}^{s_{(i),2} } + \mathbf{1}^{s_{(i),1} } \otimes \hat{\mathbf{T}}_2^{(i)} \right) \in \mathbb{R}^{s_{(i)} \times d}$, the Fast Tensor-sketch lemma can be applied to $\mathbf{J}^{(i)}$ in time $\tilde{O}((\mathtt{nnz}(\mathbf{T}_1^{(i)}) + \mathtt{nnz}(\mathbf{T}_2^{(i)}) + d^2)/\epsilon^2)$. Note that $|\mathcal{B}_{\text{big}}| \leq 2(n_1 + n_2)/(d\gamma)$, since there can be at most this many values of $s_{(i)}^1 +s_{(i)}^2 > d \gamma$. Thus the total running time is $\tilde{O}(\sum_{i \in \mathcal{B}_{\text{big}}} ( \mathtt{nnz}(\mathbf{T}_1^{(i)}) + \mathtt{nnz}(\mathbf{T}_2^{(i)}) + d^2)/\epsilon^2) = \tilde{O}( (\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2))/\epsilon^2 + (n_1 + n_2)d/(\gamma\epsilon^2))$. Finally, applying CountSketch will cost $\tilde{O}((n_1 + n_2)/(d\gamma)\cdot d/\epsilon^2\cdot d)$, which is $\tilde{O}((n_1 + n_2)d/\epsilon^2)$ for the dense case and $\tilde{O}((n_1 + n_2)/\epsilon^2)$ for the sparse case. The remaining runtime analysis follows from Lemma \ref{lem:twotablemain}, setting $\gamma$ to be either $1$ or $d$.
\end{proof}
We now demonstrate how our subspace embeddings can be easily applied to obtain fast algorithms for regression. To do this, we will first need the following proposition, which shows that $w^T \mathbf{J}^T \mathbf{J}$ can be computed in input sparsity time for any $w \in \mathbb{R}^d$. \\
\begin{proposition}\label{prop:fastprod}
Suppose $\mathbf{J}=\mathbf{T}_1 \Join \mathbf{T}_2 \in \mathbb{R}^{n \times d}$ is a join of two tables, where $\mathbf{T}_1 \in \mathbb{R}^{n_1 \times d_1},\mathbf{T}_2 \in \mathbb{R}^{n_2 \times d_2}$. Let $b \in \mathbb{R}^n$ be any column of the join $\mathbf{J}$. Let $U \subseteq [d]$ be any subset, and let $\mathbf{J}_U \in \mathbb{R}^{n \times |U|}$ be the subset of the columns of $\mathbf{J}$ contained in $\mathbf{U}$. Let $w \in \mathbb{R}^{d}$ be any vector, and let $x = \mathbf{J} w \in \mathbb{R}^n$. Then given $w$, the vector $x^T \mathbf{J}_{U} = w^T \mathbf{J}^T \mathbf{J}_U \in \mathbb{R}^{|U|}$ can be computed in time $O(\mathtt{nnz}(\mathbf{T}_1)+ \mathtt{nnz}(\mathbf{T}_2))$.
\end{proposition}
\begin{proof}
Fix any $i \in \mathcal{B}(\mathbf{J})$, and similarly let $\mathbf{J}^{(i)}_{U},\hat{\mathbf{T}}_{1,U}^{(i)},\hat{\mathbf{T}}_{2,U}^{(i)} $ be $\mathbf{J}^{(i)},\hat{\mathbf{T}}_{1}^{(i)},\hat{\mathbf{T}}_{2}^{(i)}$ respectively, restricted to the columns of $U$. Note that we have $\mathbf{J}^{(i)}_{U} = (\hat{\mathbf{T}}_{1,U}^{(i)} \otimes \mathbf{1}^{s_{(i),2}} + \mathbf{1}^{s_{(i),2}} \otimes \hat{\mathbf{T}}_{2,U}^{(i)}) \allowbreak \in \mathbb{R}^{s_{i} \times |U|}$.
Let $x^{(i)} \in \mathbb{R}^{s_{(i)}}$ be $x$ restricted to the rows inside of block $i \in \mathcal{B}(\mathbf{J})$.
Since $x = \mathbf{J} w$ for some $w \in \mathbb{R}^d$, we have $x^{(i)} = \mathbf{J}^{(i)} w = (\hat{\mathbf{T}}_{1}^{(i)} \otimes \mathbf{1}^{s_{(i),2}} + \mathbf{1}^{s_{(i),1}} \otimes \hat{\mathbf{T}}_{2}^{(i)})w$.
Then we have
\begin{equation}
\begin{split}
x^T \mathbf{J}_{U} &= \sum_{i \in \mathcal{B}} (x^{(i)})^T \mathbf{J}^{(i)}_{U}\\
&= \sum_{i \in \mathcal{B}} w^T \left(\hat{\mathbf{T}}_{1}^{(i)} \otimes \mathbf{1}^{s_{(i),2}} + \mathbf{1}^{s_{(i),1}} \otimes \hat{\mathbf{T}}_{2}^{(i)}\right)^T \\
& \cdot \left(\hat{\mathbf{T}}_{1,U}^{(i)} \otimes \mathbf{1}^{s_{(i),2}} + \mathbf{1}^{s_{(i),1}} \otimes \hat{\mathbf{T}}_{2,U}^{(i)} \right)\\
&= \sum_{i \in \mathcal{B}} w^T \Big(s_{(i),2}(\hat{\mathbf{T}}_{1}^{(i)})^T \hat{\mathbf{T}}_{1,U}^{(i)} + ((\hat{\mathbf{T}}_{1}^{(i)})^T \mathbf{1}^{s_{(i),1}}) \\
& \otimes( (\mathbf{1}^{s_{(i),2}})^T \hat{\mathbf{T}}_{2,U}^{(i)})+ (\mathbf{1}^{s_{(i),1}})^T \hat{\mathbf{T}}_{1,U}^{(i)} \otimes((\hat{\mathbf{T}}_{2}^{(i)})^T \mathbf{1}^{s_{(i),2}} ) \\
& + s_{(i),1}(\hat{\mathbf{T}}_{2}^{(i)})^T \hat{\mathbf{T}}_{2,U}^{(i)} \Big)\\
\end{split}
\end{equation}
where the last equality follows from the mixed product property of Kronecker products (see e.g., \cite{van2000ubiquitous}).
First note that the products $ w^T s_{(i),2}(\hat{\mathbf{T}}_{1}^{(i)})^T \hat{\mathbf{T}}_{1,U}^{(i)}$ and $w^T s_{(i),1}(\hat{\mathbf{T}}_{2}^{(i)})^T \hat{\mathbf{T}}_{2,U}^{(i)}$ can be computed in $O(\mathtt{nnz}(\mathbf{T}_1^{(i)}) + \mathtt{nnz}(\mathbf{T}_2^{(i)}))$ time by computing the vector matrix product first. Thus, it suffices to show how to compute $w^T ((\mathbf{1}^{s_{(i),1}})^T \allowbreak\hat{\mathbf{T}}_{1,U}^{(i)}) \otimes((\hat{\mathbf{T}}_{2}^{(i)})^T \mathbf{1}^{s_{(i),2}} )$ and $w^T ((\hat{\mathbf{T}}_{1}^{(i)})^T \mathbf{1}^{s_{(i),1}}) \otimes( (\mathbf{1}^{s_{(i),2}})^T \hat{\mathbf{T}}_{2,U}^{(i)})$ quickly. By reshaping the Kronecker products \cite{van2000ubiquitous}, we have
$w^T \allowbreak(\mathbf{1}^{s_{(i),1}})^T \hat{\mathbf{T}}_{1}^{(i)} \allowbreak \otimes((\hat{\mathbf{T}}_{2,U}^{(i)})^T \mathbf{1}^{s_{(i),2}} ) = ((\hat{\mathbf{T}}_{2,U}^{(i)})^T \mathbf{1}^{s_{(i),2}}w^T (\hat{\mathbf{T}}_{1}^{(i)})^T \mathbf{1}^{s_{(i),1}} )^T$
Now $w^T (\hat{\mathbf{T}}_{1}^{(i)})^T$ can be computed in $O(\mathtt{nnz}(\mathbf{T}_1^{(i)}))$ time, at which point $w^T (\hat{\mathbf{T}}_{1}^{(i)})^T \mathbf{1}^{s_{(i),1}}$ can be computed in $O(s_{(i),1}) = \allowbreak O( \allowbreak\mathtt{nnz}(\mathbf{T}_1^{(i)}))$ time. Next, we can compute $\mathbf{1}^{s_{(i),2}}(w^T (\hat{\mathbf{T}}_{1}^{(i)})^T \allowbreak \mathbf{1}^{s_{(i),1}})$ in $O(s_{(i),2})$ $= \allowbreak O(\allowbreak \mathtt{nnz}(\mathbf{T}_2^{ (i)}))$ time. Finally, $(\hat{\mathbf{T}}_{2,U}^{(i\allowbreak )})^T \allowbreak ( \mathbf{1}^{s_{(i),2}}w^T \cdot \allowbreak (\hat{\mathbf{T}\allowbreak }_{1}^{(i)})^T \allowbreak \mathbf{1}^{s_{(i),1}})$ can be computed in $ O(\mathtt{nnz}(\mathbf{T}_2^{(i)}))$ time. A similar argument holds for computing $w^T (\mathbf{1}^{s_{(i),1}})^T \allowbreak\hat{\mathbf{T}}_{1,U}^{(i)} \allowbreak \otimes((\hat{\mathbf{T}}_{2}^{(i)})^T\allowbreak \mathbf{1}^{s_{(i),2}} )$, which completes the proof, noting that $\sum_{i \in \mathcal{B}} \mathtt{nnz}(\mathbf{T}_1^{(i)}) + \mathtt{nnz}(\mathbf{T}_2^{(i)}) = \mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2)$.
\end{proof}
We now state our main theorem for machine precision regression. We remark again that the success probability can be boosted to $1-\delta$ by boosting the success probability of the corresponding subspace embedding to $1-\delta$, as described earlier. \\
\textbf{Theorem \ref{thm:reg} } [In-Database Regression (Theorem \ref{thm:reg})] {\it
Suppose $\mathbf{J}\allowbreak =\mathbf{T}_1 \Join \mathbf{T}_2 \in \mathbb{R}^{n \times d}$ is a join of two tables, where $T_1 \in \mathbb{R}^{n_1 \times d_1}, T_2\allowbreak \in \mathbb{R}^{n_2 \times d_2}$. Let $\mathbf{U} \subset [d]$ be any subset, and let $\mathbf{J}_U \in \mathbb{R}^{N \times |U|}$ be $\mathbf{J}$ restricted to the columns in $U$, and let $b \in \mathbb{R}^n$ be any column of the join $\mathbf{J}$. Then there is an algorithm which returns $\hat{x} \in \mathbb{R}^{|U|}$ such that with probability $9/10$ we have
\[ \|\mathbf{J}_{U} \hat{x} - b\|_2 \leq (1+\epsilon) \min_{x \in \mathbb{R}^{|U|}}\|\mathbf{J}_{U} x - b\|_2 \]
The runtime required to compute $\hat{x}$ is the minimum of \\
$\tilde{O}\left( ((n_1 + n_2)d + d^{3}) + (\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2) + d^2)\log(1/\epsilon) \right)$ and \\$\tilde{O}\left( d^5 + (\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2) + d^2)\log(1/\epsilon) \right)$.
}
\begin{proof}
The following argument follows a standard reduction from having a subspace embedding to obtaining high precision regression (see, e.g., Section 2.6 of \cite{woodruff2014sketching}).
We first compute a subspace embedding $\tilde{\mathbf{J}}_ = \mathbf{S}^* \mathbf{J}$ for $\mathbf{J}$ via Theorem \ref{thm:subspace} with precision parameter $\epsilon_0 = \Theta(1)$, so that $\mathbf{S}^* \mathbf{J}$ has $k= \tilde{O}(d^2 \gamma^2)$ rows. Note that in particular this implies that $\mathbf{S}^* \mathbf{J}_{U}$ is an $\epsilon_0$-subspace embedding for $\mathbf{J}_U$.
We then generate an OSNAP matrix $\mathbf{W} \in \mathbb{R}^{\tilde{\Theta}(d) \times k}$ via Lemma \ref{lem:OSNAP} with precision $\epsilon_0$, and condition on the fact that $\mathbf{W} \mathbf{S}^* \mathbf{J}_U$ is an $\epsilon_0$-subpsace embedding for $\mathbf{S}^*\mathbf{J}_U$, which holds with large constant probability, from which it follows that $\mathbf{W} \mathbf{S}^* \mathbf{J}_{U}$ is an $O(\epsilon_0)$-subspace embedding for $\mathbf{J}_{U}$. We then compute the QR factorization $\mathbf{W} \mathbf{S}^* \mathbf{J}_{U} = \mathbf{Q}\mathbf{R}^{-1}$, which can be done in $O(d^{\omega})$ time via fast matrix multiplication \cite{demmel2007fast}. By standard arguments \cite{woodruff2014sketching}, the matrix $\mathbf{J}_{U} \mathbf{R}$ is now $O(1)$-well conditioned -- namely, we have $\sigma_{\max}(\mathbf{J}_{U}\mathbf{R})/\sigma_{\min}(\mathbf{J}_{U}\mathbf{R}) = O(1)$.
Given this, we can apply the gradient descent update $x_{t+1} \leftarrow x_t + \mathbf{R}^T \mathbf{J}^T_{U}(b - \mathbf{J}_{U} \mathbf{R} x_t)$, which can be computed in $O(\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2) + d^2)$ time via Proposition \ref{prop:fastprod} (note we compute $\mathbf{R} x_t$ in $O(d^2)$ time first, and then compute $(\mathbf{J}_{U} \mathbf{R} x_t)$. Here we use the fact that $b - \mathbf{J}_{U} \mathbf{R} x_t = \mathbf{J} w$ for some $w$ which is a vector in the column span of $\mathbf{J}$, and moreover, we can determine the value of $w$ from computing $\mathbf{R} x_t$ and noting that $b = \mathbf{J} e_{j^*}$, where $j^* \in[d]$ is the index of $b$ in $\mathbf{J}$. Since $ \mathbf{R}^T \mathbf{J}^T_{U}$ is now well -conditioned, gradient descent now converges in $O(\log 1/\epsilon)$ iterations given that we have a constant factor approximation $x_0$ \cite{woodruff2014sketching}. Specifically, it suffices to have an $x_0 \in \mathbb{R}^d$ such that $\|\mathbf{J}_U x_0 - b\|_2 \leq (1+\epsilon_0) \min_{x \in \mathbb{R}^d} \| \mathbf{J}_U x - b\|_2$. But recall that such an $x_0$ can be obtained by simply solving
$x_0 = \arg \min_x \|\mathbf{S}^*\mathbf{J}_{U} x - \mathbf{S}^*b\|_2$,
using the fact that $\mathbf{S}^*$ is an $\epsilon_0$- subspace embedding for the span of $\mathbf{J}$, which completes the proof of the theorem.
\end{proof}
\subsection{Proof of Lemma \ref{lem:twotablemain}}\label{app:twotablemain}
\begin{algorithm}[h]
\caption{Pre-processing step for fast $\ell_2$ sampling from rows of $\mathbf{J} \cdot \mathbf{Y}$, where $\mathbf{J}=\mathbf{T}_1 \Join \mathbf{T}_2$ and $\mathbf{Y} \in \mathbb{R}^{d \times r}$. } \label{alg:L2presample}
\begin{algorithmic}[1]
\STATE
For each block $i \in \mathcal{B}$, compute $a_{(i)} = \hat{T}_1^{(i)} \mathbf{Y}$ and $b_{(i)} = \hat{T}_2^{(i)}$
\STATE
For each block $i \in \mathcal{B}$, construct a binary tree $\tau_{(i)}(\mathbf{T}_1), \tau_{(i)}(\mathbf{T}_2)$ as follows:
\STATE
Each node $v \in \tau_{(i)}(\mathbf{T}_j)$ is a vector $v \in \mathbb{R}^{3 r}$
\STATE
If $v$ is not a leaf, then $v = v_{\text{lchild}} + v_{\text{rchild}}$ with $v_{\text{lchild}},v_{\text{rchild}}$ the left and right children of $v$.
\STATE
The leaves of $\tau_{(i)}(\mathbf{T}_j)$ are given by the set
\[ \{ v_{l}^{(i),j} =\left( v_{l,1}^{(i),j}, v_{l,2}^{(i),j}, \dots,v_{l,r}^{(i),j} \right)\in \mathbb{R}^{3r} \; | \; l \in[ s_{(i),j}] \}\]
\noindent where $v_{l,q}^{(i),1} = (1,2(a_{(i)})_{ l,q}, (a_{(i)})_{ l,q}^2 ) \in \mathbb{R}^3$ and $v_{l,q}^{(i),2} = ( (b_{(i)})_{ l,q}^2,(b_{(i)})_{ l,q},1 ) \in \mathbb{R}^3$.
\STATE
Compute the values $\langle \text{root}(\tau_i(\mathbf{T}_1)) , \text{root}(\tau_i(\mathbf{T}_2))\rangle$ for all $i \in \mathcal{B}$, and also compute the sum $\sum_{i} \langle \text{root}(\tau_i(\mathbf{T}_1)) , \text{root}(\tau_i(\mathbf{T}_2))\rangle$.
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[h]
\caption{Sampling step for fast $\ell_2$ sampling from rows of $\mathbf{J} \cdot \mathbf{Y}$. } \label{alg:L2sample}
\begin{algorithmic}[1]
\STATE
Sample a block $i \in \mathcal{B}$ with probability \[\frac{\left\langle \text{root}(\tau_i(\mathbf{T}_1)) , \text{root}(\tau_i(\mathbf{T}_2))\right\rangle}{\sum_{j} \left\langle \text{root}(\tau_j(\mathbf{T}_1)) , \text{root}(\tau_j(\mathbf{T}_2))\right\rangle}\]
\STATE
Sample $ l_1 \in[ s_{(i),1}]$ with probability \[p_{l_1} = \frac{\left\langle v^{(i),1}_{l_1} , \text{root}(\tau_i(\mathbf{T}_2))\right\rangle}{\sum_{l} \left\langle v^{(i),1}_{l} , \text{root}(\tau_j(\mathbf{T}_2))\right\rangle}\] \label{line:l1}
\STATE
Sample $ l_2 \in[ s_{(i),2}]$ with probability \[p_{l_2 \; | \; l_1} = \frac{\left\langle v^{(i),1}_{l_1} , v^{(i),2}_{l_2} \right\rangle}{\sum_{l} \left\langle v^{(i),1}_{l_1} , v^{(i),2}_{l} \right\rangle}\] \label{line:l2}
\STATE
Return the row corresponding to $(l_1,l_2)$ in block $i$.
\end{algorithmic}
\end{algorithm}
We start our proof by showing Algorithm \ref{alg:L2sample} can sample one row with probability according to the $\ell_2$ norm quickly after running the pre-processing Algorithm \ref{alg:L2presample}.
\begin{lemma}\label{lem:sampfast}
Let $\mathbf{J} = \mathbf{T}_1 \Join \mathbf{T}_2 \in \mathbb{R}^{N \times d}$ be any arbitrary join on two tables, with $\mathbf{T}_i \in \mathbb{R}^{n_i \times d_i}$, and fix any $\mathbf{Y} \in \mathbb{R}^{d \times t}$. Then Algorithms \ref{alg:L2presample} and \ref{alg:L2sample}, after an $O(( \mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2)) (t + \log N))$-time pre-processing step (Algorithm \ref{alg:L2presample}), can produce samples $i^* \sim \mathcal{D}_{\mathbf{Y}}$ (Algorithm \ref{alg:L2sample}) from the distribution $\mathcal{D}_{\mathbf{Y}}$ over $[N]$ given by
\[ \text{Pr}_{i^* \sim \mathcal{D}_{\mathbf{Y}}} \left[ i^* = j \right] = \frac{\|(\mathbf{J} \cdot \mathbf{Y})_{j,*}\|_2^2}{ \|\mathbf{J} \cdot \mathbf{Y}\|_F^2 } \]
such that each sample is produced in $O(\log N)$ time.
\end{lemma}
\begin{proof}
We begin by arguing the correctness of Algorithms \ref{alg:L2presample} and \ref{alg:L2sample}. Let $j^*$ be any row of $\mathbf{J} \cdot \mathbf{Y}$. Note that the row $j^*$ corresponds to a unique block $i \in \mathcal{B} = \mathcal{B}(\mathbf{J})$, and two rows $l_1 \in [s_{(i),1}],l_2 \in [s_{(i),2}]$, such that $\mathbf{J}_{j^*,*} = (\hat{T}_1)_{l_1',*} + (\hat{T}_2)_{l_2',*}$, where $l_1' \in [n_1], l_2' \in [n_2]$ are the indices which correspond to $l_1,l_2$. For $l \in [s_{(i),j}]$, let $v_l^j, v^j_{l,q}$ be defined as in Algorithm \ref{alg:L2presample}. We first observe that if $j^*$ corresponds to the block $i \in \mathcal{B}$, then $\langle v^{(i),1}_{l_1} , v^{(i),2}_{l_2} \rangle = \|(\mathbf{J} \mathbf{Y})_{j^*,*}\|_2^2$, since
\begin{equation}
\begin{split}
& \langle v^{(i),1}_{l_1} , v^{(i),2}_{l_2} \rangle\\
&= \sum_{q=1}^r v^{(i),1}_{l_1,q} \cdot v^{(i),2}_{l_2,q}\\
&= \sum_{q=1}^r (a_{(i)})_{l_1,q}^2 + 2 (a_{(i)})_{l_1,q} (b_{(i)})_{l_2,q}+ (b_{(i)})_{l_2,q}^2 \\
& =\sum_{q=1}^r \left( (a_{(i)})_{l_1,q}+ (b_{(i)})_{l_2,q}\right)^2 \\
& = \|(\mathbf{J} \mathbf{Y})_{j^*,*}\|_2^2
\end{split}
\end{equation}
where for each block $i \in \mathcal{B}$, we compute $a_{(i)} = \hat{T}_1^{(i)} \mathbf{Y}$ and $b_{(i)} = \hat{T}_2^{(i)}$ as defined in Algorithm \ref{alg:L2presample}.
Thus it suffices to sample a row $j^*$, indexed by the tuple $(i,l_1,l_2)$ where $i \in \mathcal{B}, l_1 \in [s_{(i),1}],l_2 \in [s_{(i),2}]$, such that the probability we sample $j^*$ is given by $p_{j^*} = \langle v^{(i),1}_{l_1} , v^{(i),2}_{l_2} \rangle/( \sum_{i',l_1',l_2'}\langle v^{(i'),1}_{l_1'} , v^{(i'),2}_{l_2'} \rangle )$.
We argue that Algorithm \ref{alg:L2sample} does precisely this. First note that for any $i \in \mathcal{B}$, we have
\[\langle v^{(i),1}_{l_1} , \text{root}(\tau_i(\mathbf{T}_2))\rangle =\sum_{l_1\in [s_{(i),1}] ,l_2 \in [s_{(i),2}]}\langle v^{(i),1}_{l_1} , v^{(i),2}_{l_2} \rangle\]
Thus we first partition the set of all rows $j^*$ by sampling a block $i$ with probability $\frac{\left\langle \text{root}(\tau_i(\mathbf{T}_1)) , \text{root}(\tau_i(\mathbf{T}_2))\right\rangle}{\sum_{j} \left\langle \text{root}(\tau_j(\mathbf{T}_1)) , \text{root}(\tau_j(\mathbf{T}_2))\right\rangle}$, which is exactly the distribution over blocks induced by the $\ell_2$ mass of the blocks.
Conditioned on sampling $i \in \mathcal{B}$, it suffices now to sample $l_1,l_2$ from that block.
To do this, we first sample $l_1$ with probability $\langle v^{(i),1}_{l_1} , \text{root}(\tau_i(\mathbf{T}_2))\rangle/ \allowbreak (\sum_{l} \langle v^{(i),1}_{l} , \text{root}(\tau_j(\mathbf{T}_2)) \allowbreak\rangle)$, which is precisely the distribution over indices $l_1 \in [s_{(i),1}]$ induced by the contribution of $l_1$ to the total $\ell_2$ mass of block $i$.
Similarly, once conditioned on $l_1$, we sample $l_2$ with probability $\langle v^{(i),1}_{l_1} , v^{(i),2}_{l_2} \rangle/(\sum_{l} \langle v^{(i),1}_{l_1} , v^{(i),2}_{l} \rangle)$, which is the distribution over indices $l_2\in [s_{(i),2}]$ induced by the contribution of the row $(l_1,l_2)$, taken over all $l_2$ with $l_1$ fixed.
Taken together, the resulting sample $j^* \cong (i,l_1,l_2)$ is drawn from precisely the desired distribution.
Finally, we bound the runtime of this procedure. First note that computing $a_{(i)} = \hat{T}_1^{(i)} \mathbf{Y}$ and $b_{(i)} = \hat{T}_2^{(i)}$ for all blocks $i$ can be done in $O(t (\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2)))$ time, since each row of the tables $\mathbf{T}_1,\mathbf{T}_2$ is in exactly one of the blocks, and each row is multiplied by exactly $t$ columns of $\mathbf{Y}$. Once the $a_{(i)},b_{(i)}$ are computed, each tree $\tau_{(i)}(\mathbf{T}_j)$ can be computed bottom up in time $O(\log N)$, giving a total time of $O( \log N(\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2)))$ for all trees. Given this, the values $\left\langle \text{root}(\tau_i(\mathbf{T}_1)) , \text{root}(\tau_i(\mathbf{T}_2))\right\rangle$ can be computed in less than the above runtime. Thus the total pre-processing time is bounded by $O((t+ \log N) (\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2)))$ as needed.
For the sampling time, it then suffices to show that we can carry out Lines 2 and 3 in $O(\log N)$ time. But these samples can be samples from the root down, by first computing $\langle \text{root}_{\text{lchild}}(\tau_i(\mathbf{T}_1)) , \allowbreak \text{root}(\tau_i(\mathbf{T}_2))\rangle$ and $\langle \text{root}_{\text{rchild}}(\tau_i(\mathbf{T}_1)) , \allowbreak \text{root}(\tau_i(\mathbf{T}_2))\rangle$, sampling one of the left or right children with probability proportional to its size, and recursing into that subtree. Similarly, $l_2$ can be sampled by first computing $\langle v^{(i),1}_{l_1} , \text{root}_{\text{lchild}}(\tau_i(\mathbf{T}_2)) \rangle$ and $\langle v^{(i),1}_{l_1} , \allowbreak \text{root}_{\text{rchild}}(\tau_i(\mathbf{T}_2)) \rangle$ sampling one of the left or right children with probability proportional to its size, and recursing into that subtree. This completes the proof of the $O( \log N)$ runtime for sampling after pre-processing has been completed.
\end{proof}
Then we show how we can construct $\mathbf{S}$ by invoking Algorithm \ref{alg:L2presample} and \ref{alg:L2sample}.
\begin{lemma}\label{lem:makeS}
Let $\mathbf{J}_{\text{small}} \in \mathbb{R}^{n_{\text{small}} \times d}$ be the matrix \allowbreak constructed as in Algorithm \ref{alg:1} in the dense case. Then the diagonal sampling matrix $\mathbf{S}$, as defined within lines 4 through 8 of Algorithm \ref{alg:1}, can be constructed in time $\tilde{O}(\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2) + d^2\gamma^2 / \epsilon^2)$.
\end{lemma}
\begin{proof}
We first show how we can quickly construct the matrix $\tilde{\mathbf{J}}_{\text{small}}$, which consists of $m= \Theta((n_1 + n_2)/\gamma)$ uniform samples from the rows of $\mathbf{J}_{\text{small}}$. First, to sample the rows uniformly, since we already know the size of each block $s_{(i)}$, we can first sample a block $i \in \mathcal{B}_{\text{small}}$ with probability proportional to its size, which can be done in $O(\log(|\mathcal{B}_{\text{small}}|) )= O(\log N)$ time after the $s_{(i)}$'s are computed. Next, we can sample a row uniformly from $T_{i}^j$ for each $j \in [2]$, and output the join of the two chosen rows, the result of which is a truly uniform row from $\mathbf{J}_{\text{small}}$. Since we need $m$ samples, and each sample has $d$ columns, the overall runtime is $\tilde{O}((n_1 + n_2)d/\gamma)$ to construct $\tilde{\mathbf{J}}_{\text{small}}$, which is $O(\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2) )$ in the sparse case.
Once we have $\tilde{\mathbf{J}}_{\text{small}}$, we compute in line \ref{line:4} of Algorithm \ref{alg:1} the sketch $\mathbf{W} \cdot \tilde{\mathbf{J}}_{\text{small}}$, where $\mathbf{W} \in \mathbb{R}^{t \times d}$ is the OSNAP Transformation of Lemma \ref{lem:OSNAP} with $\epsilon = 1/100$, where $t = \tilde{O}(d)$, which we can compute in $\tilde{O}(md) = \tilde{O}((n_1 + n_2)d/\gamma)$ time by Lemma \ref{lem:OSNAP}. Given this sketch $\mathbf{W} \cdot \tilde{\mathbf{J}}_{\text{small}} \in \mathbb{R}^{t \times d}$, the SVD of the sketch can be computed in time $O(d^\omega)$ \cite{demmel2007fast}, where $\omega < 2.373$ is the exponent of fast matrix multiplication. Since $\mathbf{W} \tilde{\mathbf{J}}_{\text{small}}$ is a $1/100$ subspace embedding for $\tilde{\mathbf{J}}$ with probability $99/100$ by Lemma \ref{lem:OSNAP}, by Proposition \ref{prop:tausubspace} we have $\tau^{\mathbf{W} \tilde{\mathbf{J}}_{\text{small}}}(\mathbf{A}) = (1 \pm 1/100)\tau^{\tilde{\mathbf{J}}_{\text{small}}}(\mathbf{A})$ for any matrix $\mathbf{A}$. Next, we can compute $\mathbf{V} \Sigma\mathbf{G}$ in the same $O(d^\omega)$ runtime, where $\mathbf{G} \in \mathbb{R}^{d \times t }$ is a Gaussian matrix with $t= \Theta( \log N)$ and with entries drawn independently from $\mathcal{N}(0,1/t^2)$. By standard arguments for Johnson Lindenstrauss random projections (see, e.g., Lemma 4.5 of \cite{li2013iterative}), we have that $\|( x^T \mathbf{G})\|_2^2 =(1 \pm 1/100) \|x\|_2^2$ for any fixed vector $x \in \mathbb{R}^d$ with probability at least $1-n^{-c}$ for any constant $c \geq 1$ (depending on $t$).
We now claim that $\tilde{\tau_i}$ as defined in Algorithm \ref{alg:1} satisfies $C^{-1} \allowbreak\tau_i^{\tilde{\mathbf{J}}_{\text{small}}} (\mathbf{J}_{\text{small}}) \leq \tilde{\tau_i} \leq C\tau_i^{\tilde{\mathbf{J}}_{\text{small}}} (\mathbf{J}_{\text{small}}) $ for some fixed constant $C \geq 1$.
As noted above, $\tau_i^{\tilde{\mathbf{J}}_{\text{small}}} (\mathbf{J}_{\text{small}}) = (1 \pm 1/100)\tau^{\mathbf{W} \tilde{\mathbf{J}}_{\text{small}}}(\mathbf{A})$, so it suffices to show $C^{-1} \tau_i^{\mathbf{W} \tilde{\mathbf{J}}_{\text{small}}} (\mathbf{J}_{\text{small}}) \allowbreak \leq \tilde{\tau_i} \allowbreak \leq C\tau_i^{\mathbf{W}\tilde{\mathbf{J}}_{\text{small}}} (\mathbf{J}_{\text{small}})$.
To see this, first note that if $(\mathbf{J}_{\text{small}})_{i,*}$ is contained within the row span of $\tilde{\mathbf{J}}_{\text{small}}$, then
\begin{equation}
\begin{split}
\tau_i^{\tilde{\mathbf{J}}_{\text{small}}} (\mathbf{J}_{\text{small}}) &= \|(\mathbf{J}_{\text{small}})_{i,*} \mathbf{V} \Sigma^{-1}\|_2^2 \\
&= (1 \pm 1/100) \|(\mathbf{J}_{\text{small}})_{i,*} \mathbf{V} \Sigma^{-1} \mathbf{G}\|_2^2 \\
&= (1 \pm 1/100) \tilde{\tau_i}
\end{split}
\end{equation}
Thus it suffices to show that if $(\mathbf{J}_{\text{small}})_{i,*}$ has a component outside of the span of $\tilde{J}_{\text{small}}$, then we have $\|(\mathbf{J}_{\text{small}})_{i,*} \allowbreak (\mathbb{I}_{d} - \mathbf{V} \mathbf{V}^T ) g \|_2^2 > 0$.
To see this, note that $\left(\mathbb{I}_{d} - \mathbf{V} \mathbf{V}^T \right)$ is the projection onto the orthogonal space to the span of $\tilde{\mathbf{J}}_{\text{small}}$. Thus $ \left(\mathbb{I}_{d} - \mathbf{V} \mathbf{V}^T \right) g$ is a random non-zero vector in the orthogonal space of $\tilde{\mathbf{J}}_{\text{small}}$, thus $(\mathbf{J}_{\text{small}})_{i,*} \left(\mathbb{I}_{d} - \mathbf{V} \mathbf{V}^T \right) g \allowbreak \neq 0$ almost surely if $(\mathbf{J}_{\text{small}})_{i,*}$ has a component outside of the span of $\tilde{\mathbf{J}}_{\text{small}}$, which completes the proof of the claim.
Finally, and most significantly, we show how to implement line 8
of Algorithm \ref{alg:1}, which carries out the the construction of $\mathbf{S}$. Given that $1/C \tau_i^{\tilde{\mathbf{J}}_{\text{small}}} (\mathbf{J}_{\text{small}}) \leq \tilde{\tau_i} \leq C\tau_i^{\tilde{\mathbf{J}}_{\text{small}}} (\mathbf{J}_{\text{small}}) $, we can apply Theorem 1 of \cite{cohen2015uniform}, using that $n_{\text{small}} \leq (n_1 + n_2) d \cdot \gamma$ via Proposition \ref{prop:nbound}, which yields that $\sum_i \tilde{\tau_i} = O(n_{\text{small}}\frac{d}{m}) \allowbreak = O(d^2 \gamma^2)$. Thus to construct the sampling matrix $\mathbf{S}$, it suffices to sample $\alpha = O(d^2 \gamma^2 \log d/\epsilon^2)$ samples from the distribution over the rows $i$ of $\mathbf{J}_{\text{small}}$ given by $q_i = \frac{\tilde{\tau}_i}{\sum_i \tilde{\tau_i} }$. We now describe how to accomplish this.
We first show how to sample the rows $i$ with $(\mathbf{J}_{\text{small}})_{i,*} \allowbreak (\mathbb{I}_{d} - \mathbf{V} \mathbf{V}^T ) g = 0$. To do this, it suffices to sample rows from the distribution induced by the $\ell_2$ norm of the rows of $(\mathbf{J}_{\text{small}}) \mathbf{V} \Sigma^{-1} \mathbf{G}$. To do this, we can simply apply Algorithms \ref{alg:L2presample} and \ref{alg:L2sample} to the product $\mathbf{J}_{\text{small}} \cdot ( \mathbf{V} \Sigma^{-1} \mathbf{G})$. First note that we can do this because $\mathbf{J}_{\text{small}}$ itself is a join of $(\mathbf{T}_1)_{\text{small}}$ and $(\mathbf{T}_2)_{\text{small}}$, which are just $\mathbf{T}_1,\mathbf{T}_2$ with all the rows contained in blocks $i \in \mathcal{B}_{\text{big}}$ removed. Since $\mathbf{V} \Sigma^{-1} \mathbf{G} \in \mathbb{R}^{d \times t}$ for $t = \tilde{O}(1)$, by Lemma \ref{lem:sampfast} after $\tilde{O}(\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2))$ time, for any $s \geq 1$ we can sample $s$ times independently from this induced $\ell_2$ distribution over rows in time $\tilde{O}(s)$. Altogether, we obtain the required $\alpha = O(d^2 \gamma^2 \log d/\epsilon^2)$ samples from the distribution over the rows $i$ of $\mathbf{J}_{\text{small}}$ given by $q_i = \frac{\tilde{\tau}_i}{\sum_i \tilde{\tau_i} }$ in the case that $(\mathbf{J}_{\text{small}})_{i,*} \left(\mathbb{I}_{d} - \mathbf{V} \mathbf{V}^T \right) g = 0$, with total runtime $\tilde{O}(\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2) + d^2 \gamma^2 /{\epsilon^2})$.
Finally, for the case that $(\mathbf{J}_{\text{small}})_{i,*} \left(\mathbb{I}_{d} - \mathbf{V} \mathbf{V}^T \right) g > 0$, we can apply the same Algorithms \ref{alg:L2presample} and \ref{alg:L2sample} to sample from the rows of $\mathbf{J}_{\text{small}} \cdot \left(\mathbb{I}_{d} - \mathbf{V} \mathbf{V}^T \right) g$. First observe, using the fact that $\sum_i \tilde{\tau}_i \leq O(d^2 \gamma^2)$ by Theorem 1 of \cite{cohen2015uniform}, it follows that there are at most $O(d^2 \gamma^2)$ indices $i$ such that $\mathbf{J}_{\text{small}} \cdot \left(\mathbb{I}_{d} - \mathbf{V} \mathbf{V}^T \right) g > 0$. Thus, when applying Algorithm \ref{alg:L2sample} after the pre-processing step is completed, instead of sampling independently from the distribution induced by the norms of the rows, we can deterministically find all rows with $\mathbf{J}_{\text{small}} \cdot \left(\mathbb{I}_{d} - \mathbf{V} \mathbf{V}^T \right) g > 0$ in $\tilde{O}( d^2 \gamma^2)$ time, by simply enumerating over all computation paths of Algorithm \ref{alg:L2sample} that occur with non-zero probability. Since there are $O( d^2 \gamma^2)$ such paths, and each one is carried out in $O(\log N)$ time by Lemma \ref{lem:sampfast}, the resulting runtime is the same as the case where $(\mathbf{J}_{\text{small}})_{i,*} \left(\mathbb{I}_{d} - \mathbf{V} \mathbf{V}^T \right) g = 0$.
Finally, we argue that we can compute exactly the probabilities $p_j$ with which we sampled a row $j$ of $\mathbf{J}_{\text{small}}$, for each $i$ that was sampled, which will be needed to determine the scalings of the rows of $\mathbf{J}_{\text{small}}$ that are sampled. For all the rows sampled with $(\mathbf{J}_{\text{small}})_{j,*} \left(\mathbb{I}_{d} - \mathbf{V} \mathbf{V}^T \right) g >0$, the corresponding value of $p_j$ is by definition $1$. Note that if a row was sampled in both of the above cases, then it should in fact have been sampled in the case that $(\mathbf{J}_{\text{small}})_{j,*} \left(\mathbb{I}_{d} - \mathbf{V} \mathbf{V}^T \right) g \allowbreak >0$, so we set $p_j = 1$. For every row $j$ sampled via Algorithm \ref{alg:L2sample} when $(\mathbf{J}_{\text{small}})_{j,*} \left(\mathbb{I}_{d} - \mathbf{V} \mathbf{V}^T \right) g =0$, such that $j$ corresponds to the tuple $(i,l_1,l_2)$ where $i \in \mathcal{B}_{\text{small}}$ and $l_1 \in [s_{(i),1}], l_2 \in [s_{(i),2}]$, we can compute the probability it was sampled exactly via
\[p_j = p_{(i,l_1,l_2)} = \frac{\langle v^{(i),1}_{l_1} , v^{(i),2}_{l_2} \rangle}{\sum_{c \in \mathcal{B}} \langle \text{root}(\tau_c(\mathbf{T}_1)) , \text{root}(\tau_c(\mathbf{T}_2))\rangle }\] using the notation in Algorithm \ref{alg:L2sample}. Then setting $\mathbf{S}_{j,j} = \frac{1}{\sqrt{p_j}}$ for each sampled row $j$ between both processes yields the desired construction of $\mathbf{S}$.
\end{proof}
With the above lemma in hand, we can give the proof of Lemma \ref{lem:twotablemain}.
\begin{proof}[Proof of lemma \ref{lem:twotablemain}]
As argued in the proof of Lemma \ref{lem:makeS}, we have that $(1/C)\tau_i^{\tilde{\mathbf{J}}_{\text{small}}} (\mathbf{J}_{\text{small}}) \leq \tilde{\tau_i} \leq C\tau_i^{\tilde{\mathbf{J}}_{\text{small}}} (\mathbf{J}_{\text{small}}) $ for some fixed constant $C \geq 1$ and all $i \in \mathcal{B}_{\text{small}}$. The result then follows immediately from Theorem 4 of \cite{cohen2015uniform}, using the fact that $n_{\text{small}}/m = \tilde{O}(d \gamma^2)$, where $m$ is the number of rows subsampled in $\tilde{\mathbf{J}}_{\text{small}}$ from $\mathbf{J}_{\text{small}}$.
\end{proof
\begin{comment}
\subsection{Proof of Theorem \ref{thm:subspace_using_kernelICML}}\label{app:kernelICML}
We start this section by introducing the sketch that we will use to improve the run-time.
\begin{lemma}[Theorem 1 of \cite{Woodruff2020near} for the case $q = 2$]\label{lem:kernelICML}
For any $\mathbf{A}_1 \in\mathbb{R}^{n_1\times d_1}$, $\mathbf{A}_2\in\mathbb{R}^{n_2\times d_2}$, any $\epsilon, \lambda> 0$. Let $n = n_1 n_2$ and $d = d_1 d_2$. Let $\mathbf{A} = \mathbf{A}_1\otimes \mathbf{A}_2$ with statistical dimension $d_\lambda$. If $\mathtt{tr}(\mathbf{A}^T \mathbf{A})/(\epsilon\lambda)=O(\mathtt{poly}(n))$, then exists an algorithm which outputs a matrix $\mathbf{S} \in\mathbb{R}^{k\times n}$, where $k = O(d_\lambda\log d/\epsilon^2)$, such that with high probability, we have
\[ \Vert \mathbf{S}\mathbf{A} x\Vert_2^2 + \lambda\Vert x\Vert_2^2 = (1\pm \epsilon)(\Vert\mathbf{A} x\Vert_2^2 + \lambda\Vert x\Vert_2^2)\]
for all $x\in\mathbb{R}^d$. Moreover, $\mathbf{S}\mathbf{A}$ can be computed in time $\tilde{O}(d\cdot d_\lambda^2 /\epsilon^4 +\mathtt{nnz}(A_1) + \mathtt{nnz}(A_2))$.
\end{lemma}
Unlike Lemma \ref{lem:fastTenSketch}, we can not set $\lambda = 0$ directly. But we can also obtain an $\epsilon$-subspace embedding by choose $\epsilon$ and $\lambda$ appropriately. Specifically, we have the following Lemma.
\begin{lemma}
\label{lem:lambda_SE}
Suppose for matrix $\mathbf{A}\in\mathbb{R}^{n\times d}$ and $\mathbf{S}\in\mathbb{R}^{k\times n}$ we have that
\[\Vert \mathbf{S}\mathbf{A} x\Vert_2^2 + \lambda\Vert x\Vert_2^2 = (1\pm \epsilon/2)(\Vert\mathbf{A} x\Vert_2^2 + \lambda\Vert x\Vert_2^2)\]
for all $x\in\mathbb{R}^d$. Let $\sigma_{\min}$ be the minimum singular value of $\mathbf{A}$. If $\lambda \le \sigma_{\min}^2$, then $\mathbf{S}$ is also an $\epsilon$-subspace embedding for $\mathbf{A}$, namely,
\[\Vert \mathbf{S}\mathbf{A} x\Vert_2^2 = (1\pm\epsilon)\Vert\mathbf{A} x\Vert_2^2\]
for all $x\in\mathbb{R}^d$.
\end{lemma}
\begin{proof}
Since $\lambda \le \sigma_{\min}^2$, we have $\lambda\Vert x\Vert_2^2\le \sigma_{\min}^2\Vert x\Vert_2^2\le \Vert\mathbf{A} x\Vert_2^2$. Therefore we have
\[\Vert\mathbf{S}\mathbf{A} x\Vert_2^2\le(1+\epsilon/2)\Vert\mathbf{A} x\Vert_2^2 + \epsilon/2\cdot\lambda\Vert x\Vert_2^2\le(1+\epsilon)\Vert \mathbf{A} x\Vert_2^2\]
and
\[\Vert\mathbf{S}\mathbf{A} x\Vert_2^2\ge(1-\epsilon/2)\Vert\mathbf{A} x\Vert_2^2 - \epsilon/2\cdot\lambda\Vert x\Vert_2^2\ge(1-\epsilon)\Vert \mathbf{A} x\Vert_2^2\]
for all $x\in\mathbb{R}^{d}$.
\end{proof}
Now we are able to present the proof of Theorem \ref{thm:subspace_using_kernelICML}.
\begin{proof}[Proof of Theorem \ref{thm:subspace_using_kernelICML}]
The algorithm is very similar to Algorithm \ref{alg:1}. The only difference is for each $i\in\mathcal{B}_{\text{big}}$, we will first apply Fast Tensor-sketch to obtain a $\epsilon_0$-subspace embedding $\mathbf{S}_0^i \mathbf{J}^{(i)}$ for some fixed constant $\epsilon_0$. Note that $(1-\epsilon_0)\sigma_{\min}(\mathbf{J}^{(i)})\le \sigma_{\min}(\mathbf{S}_0^i\mathbf{J}^{(i)}) \le (1+\epsilon_0) \sigma_{\min}(\mathbf{J}^{(i)})$, we can then apply the sketch described in Lemma \ref{lem:kernelICML} with $\lambda = (\sigma_{\min}(\mathbf{S}_0^i\mathbf{J}^{(i)}) / (1+\epsilon_0))^2 \le \sigma_{\min}(\mathbf{J}^{(i)})^2$ to obtain an $\mathbf{S}^i$ such that
\[\Vert \mathbf{S}^i\mathbf{J}^{(i)} x\Vert_2^2 + \lambda\Vert x\Vert_2^2 = (1\pm \epsilon/2)(\Vert\mathbf{J}^{(i)} x\Vert_2^2 + \lambda\Vert x\Vert_2^2).\] And we can verify that
\begin{equation}
\begin{split}
\mathtt{tr}((\mathbf{J}^{(i)})^T\mathbf{J}^{(i)})/(\epsilon\lambda)
&= \frac{\sum_i \sigma_i(\mathbf{J}^{(i)})^2}{\epsilon(\sigma_{\min}(\mathbf{S}_0^i\mathbf{J}^{(i)}) / (1+\epsilon_0))^2}\\
&\le \frac{(1+\epsilon_0)^2}{(1-\epsilon_0)^2}\cdot\frac{d\sigma_{\max}(\mathbf{J}^{(i)})^2}{\epsilon\sigma_{\min}(\mathbf{J}^{(i)})^2}\\
& = O(d\kappa(\mathbf{J}^{(i)})^2/\epsilon)\\
& = \mathtt{poly}(n).
\end{split}
\end{equation}
Therefore by Lemma \ref{lem:lambda_SE}, we obtain an $\epsilon$-subspace embedding.
We now consider the run-time. For each $i\in \mathcal{B}_{\text{big}}$, it costs $\tilde{O}(\mathtt{nnz}(\mathbf{T}_1^{(i)}) + \mathtt{nnz}(\mathbf{T}_2^{(i)}) + d^2)$ time to apply the Fast Tensor-sketch, $\tilde{O}(d^3)$ time to compute the SVD and $\tilde{O}(\mathtt{nnz}(\mathbf{T}_1^{(i)}) + \mathtt{nnz}(\mathbf{T}_2^{(i)}) + d^3/\epsilon^4)$ to apply the sketch in Lemma \ref{lem:kernelICML}. For $\mathbf{J}_{\text{small}}$ the run-time is $\tilde{O}(\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2) + d^3\gamma^2/\epsilon^2)$. Therefore the overall run-time is $\tilde{O}(\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2) + d^3\gamma^2/\epsilon^2 + (n_1 + n_2)d^2/(\gamma\epsilon^4))$.
\end{proof}
\end{comment}
\section{Connecting the Two Algorithms}
In this paper, we have two algorithms for joins. One is for two-table joins and the other one is for general joins. Now we will compare them in the context of two-table joins, both theoretically and empirically.
\subsection{Theoretical Comparison}
By Theorem \ref{thm:subspace}, the total running time to obtain a subspace embedding is the minimum of $\Tilde{O}((n_1 + n_2)d/\epsilon^2 + d^3 / \epsilon^2)$ and $\Tilde{O}((\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2))/\epsilon^2 +(n_1 + n_2)/\epsilon^2 + d^5/\epsilon^2)$ using Algorithm \ref{alg:1}.
Now we consider the algorithm stated in Corollary \ref{corollary:general:join}. When running on the join of two tables, the algorithm is equivalent to applying the Fast Tensor-Sketch to each block and summing them up. Thus, the running time is $\Tilde{O}(\sum_{i\in\mathcal{B}}(\mathtt{nnz}(\mathbf{T}_1^{(i)})/\epsilon^2 + \mathtt{nnz}(\mathbf{T}_2^{(i)})/\epsilon^2 + d^2/\epsilon^2)) = \Tilde{O}((\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2))/\epsilon^2 + (n_1 + n_2)d^2/\epsilon^2)$.
The running time of the algorithm in Corollary \ref{corollary:general:join} is greater than the running time of Algorithm \ref{alg:1}. In the extreme case the number of blocks can be really large, and even if each block has only a few rows we still need to pay an extra $\Tilde{O}(d^2/\epsilon^2)$ time for it. This is the reason why we split the blocks into two sets ($\mathcal{B_{\text{big}}}$ and $\mathcal{B_{\text{small}}}$) and use a different approach when designing the algorithm for two-table joins.
\subsection{Experimental Comparison}
In our experiments we replace the Fast Tensor-Sketch with Tensor-Sketch. The theoretical analysis is similar since we still need to pay an extra $O(kd\log k)$ time to sketch a block for target dimension $k$.
We run the algorithm for the general case on joins $\mathbf{J}_1$ and $\mathbf{J}_2$ for different target dimensions. As shown in Table \ref{tab:Experiment:J_1,J_2-general}, in order to achieve the same relative error as Algorithm \ref{alg:1}, we need to set a large target dimension and the running time would be significantly greater than it is in Table \ref{tab:Experiment_two-table}, even compared with the FAQ-based algorithm. This experimental result agrees with our theoretical analysis.
\begin{table}
\centering
\caption{General Algorithm on Two-Table Joins}
\label{tab:Experiment:J_1,J_2-general}
\begin{tabular}{|c|c|c|c|}
\hline
& $k$ & running time & relative error\\
\hline
\multirow{5}{*}{$\mathbf{J}_1$} & 40 & 0.086 & 42.3\% \\
\cline{2-4}
& 80 & 0.10 & 9.79\% \\
\cline{2-4}
& 120 & 0.14 & 3.67\% \\
\cline{2-4}
& 160 & 0.16 & 0.87\% \\
\cline{2-4}
& 200 & 0.19& 1.05\% \\
\hline
\multirow{5}{*}{$\mathbf{J}_2$} & 400 & 1.25 & 5.79\% \\
\cline{2-4}
& 800 & 2.02 & 2.32\% \\
\cline{2-4}
& 1200 & 2.93 & 1.85\% \\
\cline{2-4}
& 1600 & 3.74 & 1.19\% \\
\cline{2-4}
& 2000 & 4.50 & 0.96\% \\
\hline
\end{tabular}
\end{table}
\section{Database Background}\label{appendix:database:background}
We begin with some fundamental definitions relating to database joins.
\begin{definition}[Join Hypergraph]
Given a join $\mathbf{J}=\mathbf{T}_1 \Join \dots \Join \mathbf{T}_m$, the hypergraph associated with the join is $H=(V,E)$ where $V$ is the set of vertices and for every column $c_i$ in $J$, there is a vertex $v_i$ in $V$, and for every table $\mathbf{T}_i$ there is a hyper-edge $e_i$ in $E$ that has the vertices associated with the columns of $\mathbf{T}_i$.
\end{definition}
\begin{definition}[Acyclic Join]
We call a join query \textbf{acyclic} if one can repeatedly apply one of the two operations and convert the query to an empty query:
\begin{enumerate}
\item remove a column that is only in one table.
\item remove a table for which its columns are fully contained in another table.
\end{enumerate}
\end{definition}
\begin{definition}[Hypergraph Tree Decomposition]
Let $H=(V,E)$ be a hypergraph and $T=(V',E')$ be a tree on a set of vertices, where each vertex $v' \in V'$ is called the \textbf{bag} of $v'$, denoted by $b(v')$, and corresponds to a subset of vertices of $V$. Then $T$ is called a \textbf{hypergraph tree decomposition} of $H$ if the following holds:
\begin{enumerate}
\item for each hyperedge $e \in E$, there exists $v' \in V'$ such that $e \subseteq b(v')$, and
\item for each vertex $v \in V$, the set of vertices in $V'$ that have $v$ in their bag is non-empty and they form a connected subtree of $T$.
\end{enumerate}
\end{definition}
\begin{definition}
Let $H=(V,E)$ be a join hypergraph and $T=(V',E')$ be its tree decomposition. For each $v' \in V'$, let $X^{v'} = \allowbreak (x_1^{v'},x_2^{v'}, \allowbreak \dots, x_m^{v'})$ be the optimal solution to the following linear program: $\texttt{min} \sum_{j=1}^{t} x_{j}$, $\text{subject to } \sum_{j:v_{i} \in e_{j} }x_{j} \geq 1, \forall v_i \in b(v')$ where $0 \leq x_{j} \leq 1$ for each $j \in [t]$.
Then the \textbf{width of $v'$} is $\sum_i x^{v'}_i$, denoted by $w(v')$, and the \textbf{fractional width of $T$} is $\max_{v' \in V'} w(v')$.
\end{definition}
\begin{definition}[fhtw]
Given a join hypergraph $H=(V,E)$, the \textbf{fractional hypertree width of $H$}, denoted by fhtw, is the minimum fractional width of its hypergraph tree decomposition. Here the minimum is taken over all possible hypertree decompositions.
\end{definition}
\begin{observation}
The fractional hypertree width of an \allowbreak acyclic join is $1$, and each bag in its hypergraph tree decomposition is a subset of the columns in some input table.
\end{observation}
\begin{definition}[FAQ]
Let $J=T_1\Join\dots \Join T_m$ be a join of $m$ input tables. For each table $T_i$, let $F_i: T_i \to S$ be a function mapping the rows of $T_i$ to a set $S$. For every row $X\in J$, let $X_i$ be the projection of $X$ onto the columns of $T_i$. Then the following is a SumProd Functional Aggregation Query (FAQ):
\begin{align}
\bigoplus_{X \in J} \bigotimes_i F_i(X_i)
\end{align}
where $(S,\oplus,\otimes)$ is a commutative semiring.
\end{definition}
\begin{theorem}[\cite{abo2016faq}]
\label{thm:inside_out}
Inside-out is an algorithm which computes the result of a FAQ in time $O(T md^2n^{\text{fhtw}}\log(n))$ where $m$ is the number of tables, $d$ is the number of columns in $J$, $n$ is the maximum number of rows in any input table, $T$ is the time to compute the operators $\oplus$ and $\otimes$ on a pair of operands, and $fhtw$ is the fractional hypertree width of the query.
\end{theorem}
In \cite{Indatabase:Linear:Regression}, given a join $J=T_1 \Join \dots \Join T_m$, it is shown that the entries of $J^T J$ can be expressed as a FAQ and computed using the inside-out algorithm.
\section{Introduction}
Sketching is an important tool for dimensionality reduction, whereby one quickly reduces the size of a large-scale optimization problem while approximately preserving the solution space. One can then solve the lower-dimensional problem much more efficiently, and the sketching guarantee ensures that the resulting solution is approximately optimal for the original optimization problem. In this paper, we focus on the notion of a \textit{subspace embedding} (SE), and its applications to problems in databases. Formally, given a large matrix $\mathbf{A} \in \mathbb{R}^{N \times d}$, an $\epsilon$-subspace embedding for $\mathbf{A}$ is a matrix $\mathbf{S} \mathbf{A}$, where $\mathbf{S} \in \mathbb{R}^{k \times N}$, with the property that
$\|\mathbf{S}\mathbf{A} x\|_2 = (1 \pm \epsilon)\|\mathbf{A} x\|_2$
simultaneously for all $x \in \mathbb{R}^d$.
A prototypical example of how a subspace embedding can be applied to solve an optimization problem is linear regression, where one wants to solve $\min_x \|\mathbf{A} x - b\|_2$ for a tall matrix $\mathbf{A} \in \mathbb{R}^{N \times d}$ where $N \gg d$ contains many data points (rows). Instead of directly solving for $x$, which requires computing the covariance matrix of $\mathbf{A}$ and which would require $O(Nd^2)$ time for general $\mathbf{A}$\footnote{This can be sped up to $O(Nd^{\omega-1})$ time in theory, where $\omega \approx 2.373$ is the exponent of matrix multiplication.}, one can first compute a \textit{sketch} $\mathbf{S} \mathbf{A},\mathbf{S} b$ of the problem, where $\mathbf{S} \in \mathbb{R}^{k \times N}$ is a random matrix which can be quickly applied to $\mathbf{A}$ and b. If $[\mathbf{S} \mathbf{A},\mathbf{S} b]$ is an $\epsilon$-subspace embedding for $[\mathbf{A},b]$, it follows that the regression problem using the solution $\hat{x}$ to $\min_x \|\mathbf{S} \mathbf{A} x - \mathbf{S} b\|_2$ will be within a $(1 + \epsilon)$ factor of the optimal solution cost. However, if $k \ll N$, then solving for $\hat{x}$ can now be accomplished much faster -- in $O(kd^2)$ time. SEs and similar tools for dimensionality reduction can also be used to speed up the running time of algorithms for $\ell_p$ regression, low rank approximation, and many other problems. We refer the reader to the survey \cite{woodruff2014sketching} for a survey of applications of sketching to randomized numerical linear algebra.
One potential downside of most standard subspace embeddings is that the time required to compute $\mathbf{S} \mathbf{A}$ often scales linearly with the \textit{input sparsity} of $\mathbf{A}$, meaning the number of non-zero entries of $\mathbf{A}$, which we denote by $\mathtt{nnz}(\mathbf{A})$. This dependence on $\mathtt{nnz}(\mathbf{A})$ is in general necessary just to read all of the entries of $\mathbf{A}$. However, in many applications the dataset $\mathbf{A}$ is highly structured, and is itself the result of a query performed on a much smaller dataset. A canonical and important example of this is a database join. This example is particularly important since datasets are often
the result of a database join~\cite{hellerstein2012madlib}. In fact, this use-case has motivated companies and teams such as RelationalAI~\cite{RelationalAI} and Google's Bigquery ML~\cite{BigqueryML} to design databases that are capable of handling machine learning queries. Here, we have $m$ tables $\mathbf{T}_1,\mathbf{T}_2,\dots,\mathbf{T}_m$, where $\mathbf{T}_i \in \mathbb{R}^{n_i \times d_i}$, and we can consider their join $\mathbf{J}=\mathbf{T}_1 \Join \mathbf{T}_2 \Join \dots \Join \mathbf{T}_m \in \mathbb{R}^{N \times d}$ over a set of columns. In general, the number $N$ of rows of $\mathbf{J}$ can be as large as $n_1 n_2 \cdots n_m$, which far exceeds the actual input description of $\sum_i \mathtt{nnz}(\mathbf{T}_i)$ to the problem.
We note that it is possible to do various operations on a join in sublinear time using database algorithms that are developed for Functional Aggregation Queries (FAQ)~\cite{abo2016faq}, and indeed it is possible using so-called FAQ-based techniques \cite{Indatabase:Linear:Regression} to compute the covariance matrix $\mathbf{J}^T \mathbf{J}$ in time $O(d^4 m n \log(n))$ for an acyclic join, where $n = \max(n_1, \allowbreak \ldots, n_m)$, after which one can solve least squares regression in $\text{poly}(d)$ time. While this can be significantly faster than the $\Omega(N)$ time required to compute the actual join, it is still significantly larger than the input description size $\sum_i \mathtt{nnz}(\mathbf{T}_i)$, which even if the tables are dense, is at most $dmn$. When the tables are sparse, e.g., $O(n)$ non-zero entries in each table, one could even hope for a running time close to $O(mn)$. One could hope to achieve such running times with the help of subspace embeddings, by first reducing the data to a low-dimensional representation, and then solving regression exactly on the small representation. However, due to the lack of a clean algebraic structure for database joins, it is not clear how to apply a subspace embedding without first computing the join. Thus, a natural question is:
\begin{center}
{\it Is it possible to apply a subspace embedding to a join, without having to explicitly form the join?}
\end{center}
We note that the lack of input-sparsity time algorithms for regression on joins is further exacerbated in the presence of categorical features.
Indeed, it is a common practice to convert categorical data to their so-called {\it one-hot encoding} before optimizing any statistical model. Such an encoding creates one column for each possible value of the categorical feature and only a single column is non-zero for each row. Thus, in the presence of categorical features, the tables in the join are extremely high dimensional and extremely sparse. Since the data is high-dimensional, one often regularizes it to avoid overfitting, and so in addition to ordinary regression, one could also ask to solve regularized regression on such datasets, such as ridge regression. One could then ask if it is possible to design input-sparsity time algorithms on joins for regression or ridge regression.
\subsection{Our Contributions}
We start by describing our results for least squares regression in the important case when the join is on two tables. We note that the two-table case is a very well-studied case, see, e.g., \cite{ams99,agms02,GWWZ15}. Moreover, one can always reduce to the case of a two-table join by precomputing part of a general join.
The following two theorems state our results for computing a subspace embedding and for solving regression on the join $\mathbf{J} = \mathbf{T}_1 \Join \mathbf{T}_2$ of two tables. Our results demonstrate a substantial improvement over all prior algorithms for this problem. In particular, they answer the two questions above, showing that it is possible to compute a subspace embedding in input-sparsity time, and that regression can also be solved in input-sparsity time.
To the best of our knowledge, the fastest algorithm for linear regression on two tables has a worst-case time complexity of $\tilde{O} (n d + n D^2)$, where $n = \max(n_1, n_2)$, $d$ is the number of columns, and $D$ is the dimensionality of the data after encoding the categorical data. Note that in the case of numerical data (dense case) $D=d$ since there is no one-hot encoding and the time complexity is $O(n d^2)$, and it can be further improved to $O(n d^{\omega-1})$ where $\omega < 2.373$ is the exponent of fast matrix multiplication; this time complexity is the same as the fastest known time complexity for exact linear regression on a single table. In the case of categorical features (sparse data), using sparse tensors, $D^2$ can be replaced by a constant that is at least the number of non-zero elements in $\mathbf{J}^T \mathbf{J}$ (which is at least $d^2$ and at most $D^2$) using the algorithm in \cite{Indatabase:Linear:Regression}.
We state two results with differing leading terms and low-order additive terms, as one may be more useful than the other depending on whether the input tables are dense or sparse.
\begin{theorem}[In-Database Subspace Embedding]\label{thm:subspace}
Suppose $\mathbf{J}=\mathbf{T}_1 \Join \mathbf{T}_2 \in \mathbb{R}^{N \times d}$ is a join of two tables, where $\mathbf{T}_1 \in \mathbb{R}^{n_1 \times d_1},\mathbf{T}_2 \in \mathbb{R}^{n_2 \times d_2}$. Then Algorithm \ref{alg:1} outputs a sketching matrix $\mathbf{S}^* \in \mathbb{R}^{k \times N}$ such that $\tilde{\mathbf{J}} = \mathbf{S}^* \mathbf{J}$ is an $\epsilon$-subspace embedding for $\mathbf{J}$, meaning
\[\|\mathbf{S}^*\mathbf{J} x\|_2^2 = (1 \pm \epsilon)\|\mathbf{J} x\|_2^2 \]
simultaneously for all $x \in \mathbb{R}^{d}$ with probability\footnote{We remark that using standard techniques for amplifying the success probability of an SE (see Section 2.3 of \cite{woodruff2014sketching}) one can boost the success probability to $1-\delta$ by repeating the entire algorithm $O(\log \delta^{-1})$ times, increasing the running time by a multiplicative $O(\log \delta^{-1})$ factor. One must then compute the SVD of each of the $O(\log \delta^{-1})$ sketches, which results in an additive $O( k d^{\omega-1}\log \delta^{-1} )$ term in the running time, where $\omega \approx 2.373$ is the exponent of matrix multiplication. Note that this additive dependence on $d$ is only slightly ($\approx d^{.373}$) larger than the dependence required for constant probability as stated in the theorem.} at least $9/10$. The running time to return $\mathbf{S}^* \mathbf{J}$ is the minimum of $\tilde{O}((n_1 + n_2)d/\epsilon^2 + d^{3}/\epsilon^2 )$ and $\tilde{O}((\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2))/\epsilon^2 + (n_1 + n_2)/\epsilon^2 +d^5/\epsilon^2 )$.\footnote{We use $\tilde{O}$ notation to omit factors of $\log(N)$.} In the former case, we have $k = \tilde{O}(d^2 /\epsilon^2)$, and in the latter case we have $k = \tilde{O}(d^4 /\epsilon^2)$.
\end{theorem}
Next, by following a standard reduction from a subspace embedding to an algorithm for regression, we obtain extremely efficient machine precision regression algorithms for two-table database joins.
\vspace{.1in}
\begin{theorem}[Machine Precision Regression]\label{thm:reg}
\; Suppose $\mathbf{J}=\mathbf{T}_1 \Join \mathbf{T}_2 \in \mathbb{R}^{N \times d}$ is a join of two tables, where $\mathbf{T}_1 \in \mathbb{R}^{n_1 \times d_1},\mathbf{T}_2 \in \mathbb{R}^{n_2 \times d_2}$. Let $\mathbf{U} \subseteq [d]$ be any subset, and let $\mathbf{J}_U \in \mathbb{R}^{N \times |U|}$ be $\mathbf{J}$ restricted to the columns in $U$, and let $b \in \mathbb{R}^N$ be any column of the join $\mathbf{J}$. Then there is an algorithm which outputs $\hat{x} \in \mathbb{R}^{|U|}$ such that with probability $9/10$\footnote{The probability of success here is the same as the probability of success of constructing a subspace embedding; see earlier footnote about amplifying this success probability.} we have
\[ \|\mathbf{J}_{U} \hat{x} - b\|_2 \leq (1+\epsilon) \min_{x \in \mathbb{R}^{|U|}}\|\mathbf{J}_{U} x - b\|_2 .\]
The running time required to compute $\hat{x}$ is the minimum of $\tilde{O}( ((n_1 + n_2)d + d^{3}) \log(1/\epsilon) )$ and $\tilde{O}( (\mathtt{nnz}(\mathbf{T}_1) + \mathtt{nnz}(\mathbf{T}_2) +d^5 ) \log(1/\epsilon) )$.
\end{theorem}
\paragraph{General Joins}
We next consider arbitrary joins on more than two tables. In this case, we primarily focus on the ridge regression problem $\min_x \|\mathbf{J} x-b\|_2^2 + \lambda \|x\|_2^2,$ for a regularization parameter $\lambda$. This problem is a popular regularized variant of regression and was considered in the context of database joins in \cite{Indatabase:Linear:Regression}. We introduce a general framework to apply sketching methods over arbitrary joins in Section \ref{sec:general}; our method is able to take a sketch with certain properties as a black box, and can be applied both to TensorSketch \cite{avron2014subspace,pagh2013compressed,pham2013fast}, as well as recent improvements to this sketch \cite{ahle2020oblivious,Woodruff2020near} for certain joins. Unlike previous work, which required computing $\mathbf{J}^T \mathbf{J}$ exactly, we show how to use sketching to approximate this up to high accuracy, where the number of entries of $\mathbf{J}^T \mathbf{J}$ computed depends on the so-called statistical dimension of $\mathbf{J}$, which can be much smaller than the data dimension $D$.
\paragraph{Evaluation}
Empirically, we compare our algorithms on various databases to the previous best FAQ-based algorithm of \cite{Indatabase:Linear:Regression}, which computes each entry of the covariance matrix $\mathbf{J}^T \mathbf{J}$. For two-table joins, we focus on the standard regression problem. We use the algorithm described in Section \ref{section:twotable}, replacing the Fast Tensor-Sketch with Tensor-Sketch for better practical performance. For general joins, we focus on the ridge regression problem; such joins can be very high dimensional and ridge regression helps to prevent overfitting. We apply our sketching approach to the entire join and obtain an approximation to it, where our complexity is in terms of the statistical dimension rather than the actual dimension $D$. Our results demonstrate significant speedups over the previous best algorithm, with only a small sacrifice in accuracy. For example, for the join of two tables in the MovieLens data set, which has 23 features, we obtain a 10-fold speedup over the FAQ-based algorithm, while maintaining a $0.66\%$ relative error. For the natural join of three tables in the real MovieLens data set, which is a join with 24 features, we obtain a 3-fold speedup over the FAQ-based algorithm with only $0.28\%$ MSE relative error.
Further details can be found in Section \ref{section:experiments}.
\subsection{Related Work on Sketching Structured Data}
The use of specialized sketches for different classes of structured matrices $\mathbf{A}$ has been a topic of substantial interest.
The TensorSketch algorithm of \cite{pagh2013compressed} can be applied to Kronecker products $\mathbf{A} = \mathbf{A}_1 \otimes \cdots \otimes \mathbf{A}_m$ without explicitly computing the product. The efficiency of this algorithm was recently improved by \cite{ahle2020oblivious}.
The special case when all $\mathbf{A}_i$ are equal is known as the polynomial kernel, which was considered in \cite{pham2013fast} and extended
by \cite{avron2014subspace}.
Kronecker Product Regression has also been studied for the $\ell_p$ loss functions \cite{diao2018,diao2019optimal}, which also gave improved algorithms for $\ell_2$ regression.
In \cite{asw13,ShiW19}
it is shown that regression on $\mathbf{A}$ can be solved in time $T(\mathbf{A})\cdot \mathtt{poly}(\log(nd))$, where $T(\mathbf{A}) \leq \mathtt{nnz}(\mathbf{A})$ is the time needed to compute the matrix-vector product $\mathbf{A} y$ for any $y \in \mathbb{R}^d$. For many classes of $\mathbf{A}$, such as Vandermonde matrices, $T(\mathbf{A})$ is substantially smaller than $\mathtt{nnz}(\mathbf{A})$.
Finally, a flurry of work has used sketching to obtain faster algorithms for low rank approximation of structured matrices. In \cite{musco2017sublinear,Bakshi2019RobustAS}, low rank approximations to positive semidefinite (PSD) matrices are computed in time sublinear in the number of entries of $\mathbf{A}$. This was also shown for distance matrices in \cite{bakshi2018sublinear, indyk2019sample,Bakshi2019RobustAS}.
\subsection{Related In-Database Machine Learning Work}
The work of \cite{abo2016faq} introduced Inside-out, a polynomial time algorithm for calculating functional aggregation queries (FAQs) over joins without performing the joins themselves, which can be utilized to train various types of machine learning models.
The Inside-Out algorithm builds on several earlier papers, including~\cite{aji2000generalized,Dechter:1996,Kohlas:2008,GM06}. Relational linear regression, singular value decomposition, and factorization machines are studied extensively in multiple prior works~\cite{rendle2013scaling,Kumar:2015:LGL:2723372.2723713,SystemF,khamis2018ac,Indatabase:Linear:Regression,Kumar:2016:JJT:2882903.2882952,elgamal2017spoof,kumar2015demonstration}. The best known time complexity for training linear regression when the features are continuous, is $O(d^4 m n^{\text{fhtw}} \log(n))$ where fhtw is the fractional hypertree width of the join query. Note that the fractional hypertree width is $1$ for acyclic joins. For categorical features, the time complexity is $O(d^2 m n^{\text{fhtw}+2})$ in the worst-case; however, \cite{Indatabase:Linear:Regression} uses sparse computation of the results to reduce this time depending on the join instance. In the case of polynomial regression, the calculation of pairwise interactions among the features can be time-consuming and it is addressed in~\cite{Indatabase:Linear:Regression,li2019enabling}.
A similar line of work \cite{Arenas19, 10.1145/3406325.3465353, Arenas2020when,focke2021approximately} has developed polynomial time algorithms for sampling from and estimating the size of certain database queries, including join queries with bounded fractional hypertree width, without fully computing the joins themselves.
Relational support vector machines with Gaussian kernels are studied in \cite{yangtowards}. In \cite{cheng2019nonlinear}, a relational algorithm is introduced for Independent Gaussian Mixture Models, which can be used for kernel density estimation by estimating the underlying distribution of the data.
\section{Preliminaries}
\label{section:preliminaries}
\input{Preliminaries}
\section{Subspace Embeddings for Two-Table Database Joins}\label{section:twotable}
\input{TwoTable.tex}
\input{Gneral}
\section{Evaluation}\label{section:experiments}
\input{Experiments}
\input{Comparison}
\section{Conclusion}
In this work, we demonstrate that subspace embeddings for database join queries can be computed in time substantially faster than forming the join, yielding input sparsity time algorithms for regression on joins of two tables up to machine precision, and we extend our results to ridge regression on arbitrary joins. Our results improve on the state-of-the-art FAQ-based algorithms for performing in-database regression on joins. Empirically, our algorithms are substantially faster than the state-of-the-art algorithms for this problem.
| {'timestamp': '2021-07-14T02:01:34', 'yymm': '2107', 'arxiv_id': '2107.05672', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05672'} | arxiv |
\section{Introduction}
\label{sec:intro}
\blfootnote{Authors B. Toghi and R. Valiente contributed equally.}\blfootnote{This material is based upon work supported by the National Science Foundation under Grant No. CNS-1932037.}Autonomous vehicles (AVs) can leverage their superior computation power, precision, and reaction time to avoid errors occurred by human drivers and drive more efficiently. Connecting AVs and human-driven vehicles (HVs) via vehicle-to-vehicle (V2V) communication creates an opportunity for extended situational awareness and enhanced decision making~\cite{toghi2019analysis, toghi2019spatio}. We are particularly interested in the problem of cooperative decision-making in mixed-autonomy environments where AVs need to share the road infrastructure with human drivers. In such environments, a given AV interacts with other vehicles, whether autonomous or human-driven, and most likely faces conflictive and competitive scenarios where its individual interest does not necessarily align with that of other vehicles.
\begin{figure*}[t]
\centering
\includegraphics[width=.96\textwidth]{ CVPR_Fig_A.png}
\caption{\small{Altruistic AVs can compromise on their individual utility to result socially-desirable behaviors that account for other vehicles. \textbf{\emph{(a)}} Egoistic AVs solely optimize for their own utility and do not allow the merging vehicle to merge, \textbf{\emph{(b)}} Altruistic AVs compromise on their individual utility in order to account for the human-driven vehicles and open up space for the merging vehicle.
}}
\label{fig:coopvsnoncoop}
\end{figure*}
In his classic, \emph{"I, Robot"}, Isaac Asimov points out these conflicts and lays down the Three Laws of Robotics which establish a non-formal scheme for the co-existence of robots and humans. These rules prescribe principles that an intelligent agent needs to follow in order to protect its own existence and utility while keeping the involving humans safe. The first law emphasizes the importance of protecting humans, \emph{"a robot may not injure a human being or, through inaction, allow a human being to come to harm"}, and the third law defines the local interest of a robot, \emph{"A robot must protect its own existence as long as such protection does not conflict with the previous laws"}~\cite{asimov2004robot}. Despite being rooted in science fiction, this set of rules later inspired the debates on the ethics of artificial intelligence and robotics~\cite{lin2011robot} and is meaningfully relevant in our particular problem. Conflicts and competitions naturally arise in a mixed-autonomy driving environment and it is crucial to assemble cooperative decision-making criteria that ensure safety and efficiency for both human-driven and autonomous vehicles.
The example in Figure~\ref{fig:coopvsnoncoop} helps us to elaborate on our mixed-autonomy driving problem: a vehicle that is attempting to merge into a highway requires the cruising vehicles to open up space for it. Here, the individual interest of the cruising vehicles does not align with that of the merging vehicle and therefore egoistic decision-making will not necessarily lead to an outcome that is optimal for the group of cars. With altruistic decision making, vehicles can optimize for a combination of their individual utility and a social utility. Our key insight is that by working together, a group of vehicles can overcome the physical limitations of a single vehicle and achieve socially-desirable outcomes~\cite{palanisamy2020multi, sadigh2016planning}. However, we believe the willingness of human drivers in demonstrating selflessness and altruism is rather ambiguous and thus cannot be taken for granted. Instead, we rely on the autonomous agents to shape and guide the traffic flow in a fashion that optimizes the social objective.
In order to achieve the above goal, an intelligent agent needs to 1) be able to understand and predict the behavior of human drivers and 2) coordinate with its allies, i.e., other AVs, to construct formations that eventually benefit the group. Understanding and anticipating the actions of human drivers is a challenging task as it is often difficult to model human behaviors. The models that keep track of beliefs are mostly not scalable and partner modeling techniques predominantly are intractable in capturing a belief over partners' behaviors that often vary due to factors such as fatigue, distraction, etc.~\cite{xie2020learning}. The core differentiating idea that we emphasize on is that the human driver models which are extracted in the absence of autonomous agents, are not necessarily valid when humans confront autonomous agents. To address these challenges, we take an end-to-end approach and induce altruism into the decision-making process of autonomous agents using a decentralized reinforcement structure. Despite not having access to an explicit model of the human drivers, the trained autonomous agents learn to implicitly model the environment dynamics, including the behavior of human drivers, which enables them to interact with HVs and guide their behavior.
Through our experiments in a highway merging scenario, we demonstrate that our agents are able to learn from scratch not only to drive, but also understand the behavior of HVs and coordinate with them. Our main contributions are as follows:
\begin{itemize}
\item Using a multi-agent variant of Advantage Actor-Critic (A2C), we implement a decentralized reinforcement learning algorithm that induces altruism into the decision-making process of autonomous vehicles and incentivizes them to account for the utility of other vehicles in order to result socially-desirable behaviors.
\item We choose a complex and conflictive driving scenario and show that our altruistic autonomous agents are able to plan long sequences of actions that reduce the number of crashes and improve the overall traffic flow as compared to egoistic autonomous agents.
\end{itemize}
\section{Literature Review}
\label{sec:related_work}
A fundamental challenge in multi-agent learning and training agents that evolve concurrently is the intrinsic non-stationarity of the environment. Some approaches to address this issue, such as the work by Arel~\etal, assume that all agents have access to the global state of the world or that they could share their states among the neighbors~\cite{arel2010reinforcement}. However, these assumptions are not always practical in real-world problems. Egorov~\etal attempt to overcome this challenge using a centralized Critic function that can mitigate the effect of non-stationarity in the learning process~\cite{egorov2016multi}. Foerster~\etal propose the counterfactual multi-agent (COMA) algorithm which utilizes a set of joint actions of all agents as well as the full state of the world during the training~\cite{foerster2018counterfactual}. A global centralized reward function is then used to calculate the agent-specific \textit{advantage function}. In contrast, we assume partial observability and a decentralized reward function during both training and execution that is expected to promote cooperative and sympathetic behavior among autonomous vehicles. Lowe~\etal present a general-purpose multi-agent learning algorithm that enables agents to conquer simple cooperative-competitive games with access to local observations of the agents~\cite{lowe2017multi}. An adaptation of Actor-Critic methods with a \textit{centralized action-value function} is employed that uses the set of actions of all agents and local observations as its input. In our work, however, agents do not have access to the actions of their allies and/or opponents.
Within the social navigation literature, Omidshafiei~\etal and Lauer~\etal study the multi-agent navigation and focus on solving cooperative and competitive problems by making assumptions on the nature of interactions between agents (or agents and humans)~\cite{omidshafiei2017deep, lauer2000algorithm}. However, in our case, we are interested in the emerging sympathetic cooperative behavior that enables the agents to cooperate among themselves as well as with their competitors, i.e., humans. Recent works by Pokle~\etal have revealed the potential for collaborative planning and interaction with humans\cite{pokle2019deep}. Alahi~\etal have proposed the social-LSTM framework to learn general human movement and predict their future trajectories~\cite{alahi2016social}. Toghi~\etal present a maneuver-based dataset and model on human driving that can be used to classify driving maneuvers~\cite{toghi2020maneuver}. Nikolaidis~\etal optimize a common reward function in order to enable joint trajectory planning for humans and robots~\cite{nikolaidis2015efficient}. In contrast, we seek altruistic behaviors without having an explicit model of the human driver's behavior or relying on their aid. Sadigh~\etal also demonstrate an approach based on imitation learning ~\cite{sadigh2016planning} to learn a reward function for the human drivers and then employ that to affect the behavior of human-driven vehicles. Mahjoub~\etal took a statistical machine learning approach to the problem of driver behavior prediction and were able to predict sub-maneuvers within a short time-horizon~\cite{8690570, 8690965, mahjoub2019v2x}. Works by Wu\etal and Lazar\etal study the human-autonomy problem from a macro-traffic perspective and have demonstrated emerging human behaviors within mixed-autonomy scenarios and the possibility to leverage these patterns to control and stabilize the traffic flow~\cite{wu2017emergent, lazar2019learning}.
\section{Problem Statement}
\label{sec:problem}
\begin{figure}[tb]
\centering
\includegraphics[width=.49\textwidth]{ CVPR_Fig_K.png}
\caption{\small{The Social Value Orientation ring demonstrates different behaviors based on a human/robot's preference to account for others. The diameter of the circles show the likelihood of a specific behavior. Figure is based on the data from~\cite{garapin2015does}}}
\label{fig:svo}
\end{figure}
Humans and intelligent agents interacting in a mixed-autonomy environment can hold different levels of altruism. The preference of a person to account for the interest of others in spending its individual resources, e.g. time, money, energy, is formally studied as that person's Social Value Orientation (SVO) in social psychology~\cite{schwarting2019social, garapin2015does}. This concept can also be employed to quantify an autonomous agent's willingness to act egoistically or altruistically~\cite{buckman2019sharing}. As demonstrated in Figure~\ref{fig:svo}, the behavior of a human, or similarly an autonomous agent, can lay on anywhere from absolutely egoistic to absolutely altruistic depending on the weight they assign to the utility of others. In order to achieve a set of socially-desirable maneuvers, autonomous agents must act based on the decisions made by their allies, i.e., other AVs, and human drivers.
It is well established in the behavioral decision theory that the SVO of humans is rather heterogeneous. Murphy and Ackermann~\cite{murphy2015social} formalize the human decision-making process as maximizing an expected utility with weights governed by the human's individual preferences. However, these preferences are typically unknown which makes the SVO of a human ambiguous and unclear. The existing works on social navigation for AVs and robots in general, often make assumptions on the humans' willingness to cooperate with autonomous agents, whereas Figure~\ref{fig:svo} points out the large likelihood of having an egoistic human with no will to account for others. Therefore, we define our problem in a worst-case scenario configuration and assume that all human drivers are egoistic and hence cannot be relied on in terms of cooperating with autonomous agents. Autonomous agents must coordinate with each other and when it is necessary, shape the behavior of human drivers around them to realize a social goal that benefits the group of the vehicle. The desired outcome for our particular driving problem would be enabling seamless and safe highway merging while maximizing the distance traveled by all vehicles and obviously, avoiding collisions.
\begin{figure}[tb]
\centering
\includegraphics[width=.44\textwidth]{ CVPR_Fig_C.png}
\caption{\small{Stacked multi-channel VelocityMap state representation embeds the speed and position of vehicles. Each observation $o_i$ is a tensor of size $10 \times (4 \times 64 \times 512$).}}
\label{fig:velocitymap}
\end{figure}
\section{Proposed Solution}
\label{sec:solution}
Our key insight is bypassing the need for prior information on human drivers' behavior and relying on them to cooperate with AVs. Instead, we adjust the AVs' SVO through a decentralized reinforcement learning algorithm which promotes altruistic behavior in their decision-making process. As opposed to the existing works which rely on derived behavior models of human drivers, we follow our methodology in~\cite{toghi2021cooperative, toghi2021social} which allows the autonomous agents to implicitly model human drivers SVO in real-time and through experience.
\subsection{Formalism}
\label{sec:formalism}
Consider a highway merging ramp and a straight highway with a group of human-driven and autonomous vehicles cruising on it, similar to what is depicted in Figure~\ref{fig:coopvsnoncoop}. All vehicles are connected together using V2V communication are able to share their observations~\cite{toghi2018multiple, shah2019real, saifuddin2020performance}. The highway merging scenario is particularly interesting to us due to its competitive nature as the interest of the merging vehicle does not align with the interest of the cruising vehicles. We formally annotate a set of autonomous vehicles $\mathcal{I}$, a set of human-driven vehicles $\mathcal{V}$, and the human-driven merging vehicle, $M \in \mathcal{V}$ which is attempting to merge into the highway. AVs share their situational awareness through cooperative perception to overcome the limitations of occluded and non-line-of-sight vision~\cite{valiente2019book, valiente2019controlling}. Thus, we assume each AV has a local partial observation of the world constructed using the shared situational awareness with its allies and is able to observe a subset of AVs $\widetilde{\mathcal{I}} \subset \mathcal{I}$, in addition to a subset of HVs $\widetilde{\mathcal{V}} \subset \mathcal{V}$.
\begin{figure}[tb]
\centering
\includegraphics[width=.48\textwidth]{ CVPR_Fig_B.png}
\caption{\small{The multi-agent Advantage Actor-Critic framework and policy dissemination process.}}
\label{fig:marl_policy}
\end{figure}
\subsection{Observations and Actions}
As mentioned before, our interest is in maneuver planning for AVs and studying their interaction with human drivers. This fact motivates us to view the problem from an abstracted view that determines the meta-actions for an autonomous agent. These meta-actions then further get translated into optimized trajectories and then low-level control signals, e.g., throttle level and steering angle. Specifically, we define an AV's action-space as a set of discrete meta-actions $a_i$:
\begin{equation}
\label{equ:action_space}
a_i \in \mathcal{A}_i =
\begin{bmatrix}
\texttt{Lane Left}\\
\texttt{Idle}\\
\texttt{Lane Right}\\
\texttt{Accelerate}\\
\texttt{Decelerate}
\end{bmatrix}
\end{equation}
We design a \textit{multi-channel VelocityMap} embedding, as shown in Figure~\ref{fig:velocitymap}, to represent the state of an autonomous agent. VelocityMaps embed the relative position of AVs and HVs into two channels with pixel values proportional to their relative speed. Additionally, we embed the road layout, position of the observer, and the relative position of the merging vehicle (only if it fits within the observer's perception range) in separate layers. Driving data carries important temporal patterns which can help in modeling human behavior and predictive maneuver planning. Hence, we stack a group of VelocityMaps recorded at consecutive time-steps to capture this temporal information, as Figure~\ref{fig:velocitymap} depicts.
\subsection{Decentralized Reinforcement Structure}
\label{sec:decentralized_reinforcement}
Inspired by the work done on social autonomous driving by Schwarting \etal~\cite{schwarting2019social} we define the decentralized reward function of an autonomous agent, $I_i \in \mathcal{I}$, based on its SVO. For the scenario defined in Section~\ref{sec:formalism},
\begin{equation}
\label{equ:reward1}
\begin{aligned}
R_i(s_i, a_i; \phi_i) ={} & \cos(\phi_i) R^E_i + \sin(\phi_i) R^A_i
\\={} & \cos(\phi_i) r^E_i(s_i, a_i) + \\
& \sin(\phi_i) \Big[ \sum_j r_{i, j} (s_i, a_i) + \sum_k r_{i, k} (s_i, a_i) \Big]
\end{aligned}
\end{equation}
where $\phi_i$ is the SVO angular preference of the agent $I_i$ and determines its level of altruism. Summations are over $j \in \widetilde{\mathcal{I}} \setminus \{I_i\}$, $k \in \widetilde{\mathcal{V}} \cup \{M\}$. The individual performance of a vehicle, $r$, can be quantified using metrics such as distance traveled, average speed, and a negative cost for lane-change or acceleration/deceleration to minimize the jerk and unnecessary maneuvers. The altruistic part of the reward, $R^A$, sums over the individual performance of the other vehicles. Using such a decentralized reward function in our multi-agent reinforcement learning setup, we can train agents that optimize for a social utility governed by their SVO, i.e., we induce altruism in their decision-making process without knowledge on the SVO of the humans.
\subsection{Multi-agent Advantage Actor-Critic}
\label{sec:a2c}
\begin{figure}[t]
\centering
\includegraphics[width=0.47\textwidth]{ CVPR_Fig_H.png}
\caption{\small{Distribution of distance traveled by the merging vehicle when the AVs act egoistically \emph{(Gray)} as compared to the case with altruistic AVs \emph{(Orange)}.}}
\label{fig:distance_distribution}
\end{figure}
\begin{table}[b]
\caption\small{{Architecture of A2C and Feature Extractor Networks.}}
\begin{center}
\begin{tabular*}{0.49\textwidth}{c c c c}
\small{Layer} & \small{Type} & \small{Size} & \small{Activation} \\
\hline\hline
\multicolumn{4}{l}{\textbf{\small{\textit{Feature Extractor Network}}}} \\
\hline
\small{0} & \small{Input} &\small{ $10 \times (4\times 64\times 512)$} & \small{-} \\
\small{1} & \small{Conv3D} & \small{$32\,\, @\,\, (1\times 8\times 8)$ } &\small{ReLU} \\
\small{2} & \small{Conv3D} & \small{$64\,\, @\,\, (3\times 4\times 4)$} &\small{ReLU }\\
\small{3} & \small{Conv3D} &\small{ $64\,\, @\,\, (3\times 3\times 3)$ } & \small{ReLU }\\
\small{4} & \small{FC} & \small{512} & \small{ReLU }\\
\hline
\multicolumn{4}{l}{\textbf{\small{\textit{Actor and Critic Networks}}}} \\
\hline
\small{1} & \small{FC }&\small{ 256 } & \small{ReLU} \\
\small{2} & \small{FC} &\small{ 5 } & \small{Softmax} \\
\hline
\hline
\end{tabular*}
\end{center}
\label{table:Arch}
\end{table}
As we discussed in Section~\ref{sec:problem}, a major challenge in multi-agent reinforcement learning is dealing with the set of learning agents that are evolving concurrently and therefore making the environment non-stationary. Particularly, this creates an issue for the methods based on the experience replay mechanism, such as Deep Q-networks. In order to avoid the need for the replay buffer, we employ a synchronous Advantage Actor-Critic (A2C) algorithm in which the Critic approximates the state-value function, $V(s)$, and the Actor update the stochastic policy based on the gradient from the Critic. The difference between the action-value function, $Q(s,a)$, and $V(s)$ can be used as a baseline, commonly referred to as the Advantage Function~\cite{sutton2018reinforcement}, i.e.,
\begin{equation}
\label{equ:advantagefunction}
A(s_t, a_t) = r_{t+1} + \gamma V_{\textbf{\text{w}}_C}(s_{t+1})-V_{\textbf{\text{w}}_C}(s_t)
\end{equation}
where $\textbf{\text{w}}_C$ denotes the weights of the neural network for the Critic. Thus, the update rule can be simplified as,
\begin{equation}
\label{equ:a2cupdate}
\nabla_{\theta}J(\theta) \sim \sum_{t=0}^{T-1} \nabla_\theta \log \pi_\theta (a_t|s_t) A(s_t, a_t)
\end{equation}
where $\pi_\theta$ is the policy parameterized by parameters $\theta$.
As demonstrated in Figure~\ref{fig:marl_policy}, we use a 3D convolutional network (Conv3D) as the feature extractor with the stacked VelocityMaps as its input and two separate multi-layer perceptron networks for the Actor and the Critic. A 3D convolutional architecture enables us to extract the temporal information embedded in the VelocityMaps, details of the feature extractor network are listed in Table~\ref{table:Arch}. The Actor network outputs a probability distribution corresponding to each action. The Critic network maps each state to its corresponding state-value. To stabilize the multi-agent training process, we train each AV in a semi-sequential fashion by freezing the networks of all other AVs $(\textbf{w}_A^-, \textbf{w}_C^-)$, and then disseminating the updated weights, $(\textbf{w}_A^+, \textbf{w}_C^+)$, periodically.
\section{Experiments}
\label{sec:experiments}
We use an abstract traffic simulator for our experiments. An OpenAI Gym environment provided by Leurent~\etal~\cite{leurent2019approximate} is customized to suit our particular driving scenario and multi-agent problem. A Kinematic Bicycle Model governs the kinematics of the vehicles and a proportional–integral–derivative (PID) controller renders the meta-actions into low-level steering and throttle control signals. The dynamics of the HVs and their decision-making process is implemented using the lateral and longitudinal driver models proposed by Treiber~\etal and Kesting~\etal~\cite{treiber2000congested, kesting2007general}.
\begin{figure}[t]
\centering
\includegraphics[width=.45\textwidth]{ CVPR_Fig_D.png}
\caption{\small{Our experiments demonstrate that our altruistic autonomous agents are able to take sequences of actions that reduce the number of crashes and improve the overall traffic flow as compared to egoistic autonomous agents.}}
\label{fig:barplots}
\end{figure}
\begin{figure}[b]
\centering
\includegraphics[width=0.48\textwidth]{ CVPR_Fig_G.png}
\caption{\small{Evolution of our altruistic agents during training using a decentralized reinforcement learning algorithm.}}
\label{fig:trainingsummary}
\end{figure}
\noindent \textbf{Manipulated Factors. }
Equation~\ref{equ:reward1} characterizes the decentralized reward that an AV, $I_i \in \mathcal{I}$ receives by taking an action $a_i$ at the state $s_i$. The agent's SVO angular preference, $\phi_i$, determines the importance that AV is willing to put on other vehicles' utility. Thus, we experiment with the values of $\phi_i=0$, i.e., purely egoistic behavior, and $\phi_i=\pi/4$, i.e., altruistic behavior, to examine the benefits of altruistic maneuver planning in comparison with AVs that act egoistically.
\noindent \textbf{Performance Metrics. }
As discussed in Section~\ref{sec:intro}, we aim to leverage the altruistic behavior of AVs to 1) enhance the overall traffic flow, 2) improve driving safety, and last but not least 3) generate socially-desirable outcomes. Hence, we gauge our results using an intuitive traffic flow metric that shows the average distance traveled by all vehicles in the experiment. The percentage of episodes with a collision in them is also measured to assess the safety aspect of the resulting behaviors. Episodes with a successful and seamless merging are also counted to provide an understanding of the AVs' ability to consider social utility.
\begin{figure*}[t]
\centering
\includegraphics[width=.9\textwidth]{ CVPR_Fig_E.png}
\caption{\small{Three example training episodes demonstrate how altruistic AVs learn to take a sequence of decisions that eventually lead to safe, efficient, and socially-desirable outcomes. AVs and HVs are annotated with green and blue color, respectively.}}
\label{fig:trajectories}
\end{figure*}
\noindent \textbf{Hypothesis. }
We examine a key hypothesis that we initially stated in Section~\ref{sec:intro}. By varying the SVO angular preference towards the purely altruistic behavior, i.e., $\phi=\pi/2$, AVs learn to work together and affect the behavior of human drivers to open up a safe corridor for the merging vehicle and allow it to merge safely and seamlessly. We hypothesize despite some AVs compromising on their individual utility and acting altruistically, the overall traffic-level metrics improve as a result of their altruistic behavior. More importantly, we believe that our multi-agent A2C algorithm enables AVs to take socially desirable sequences of actions.
\noindent \textbf{Findings. }
Using the proposed multi-agent A2C algorithm structure explained in Section~\ref{sec:a2c}, we train the autonomous agents for 30,000 episodes and evaluate their performance over 3,000 test episodes. The learning performance and the evolution of our metrics during the training are shown in Figure~\ref{fig:trainingsummary}. We ran multiple rounds of training to ensure that agents converge to similar points in terms of training stability.
The overall performance of both egoistically and altruistically trained autonomous agents is demonstrated in Figure~\ref{fig:barplots}. Confirming our hypothesis, we can observe that altruistic AVs manage to significantly reduce the number of collisions while improving the average distance traveled by all vehicles, which expresses the improved traffic flow. More importantly, it is clear that egoistic AVs did not allow the merging vehicle to safely merge into the highway and caused sub-optimal and unsafe situations, whereas altruistic AVs worked together in order to open up a safe space for the merging HV and allow it to merge.
To grasp a better understanding of how altruism changes the decision-making process of AVs, we dive deeper into the results and particularly measure the average distance traveled by the merging vehicle in both altruistic and egoistic settings. Figure~\ref{fig:distance_distribution} illustrates the empirical distribution of the distance traveled by the merging vehicle. It is evident that when AVs are egoistic, in the majority of episodes the merging vehicle either crashes after traveling $\sim220m$ or gets stuck in the merging ramp and hence not able to move. In contrast, in the episodes that contain altruistic AVs, the merging vehicle is able to safely merge into the highway and consequently travel approximately as twice as the previous case, $\sim450$, and reach farther distances on the highway.
We narrow down our investigation particularly to the behavior of the merging vehicle and the AV that directly meets the merging vehicle at the merging point, i.e., the \emph{Guide AV}. Although the merging vehicle mostly has a direct interaction only with the vehicles that are cruising on the right-most lane of the highway but the existence of other vehicles and their interactions, indirectly affects the sequence of actions that both the merging vehicle and the Guide AV take. We deliberately perform our study in a multi-lane highway with a fairly large mixed population of AVs and HVs to investigate these indirect relations. It is important to note that although the size of the discrete action-space defined in Equation~\ref{equ:action_space} is relatively small but a vehicle in such a complex multi-lane highway faces a large combination of sequences of actions that it can take.
The eventual outcome of an episode is determined by the sequence of maneuvers taken by vehicles and not their momentarily actions. Thus, an AV must be able to make decisions that lead to a desirable outcome in time-steps ahead. In Figure~\ref{fig:trajectories}, we illustrate three sample behaviors recorded during the training of autonomous agents. In the first example (the left-most plots), the Guide AV (orange) sees a group of HVs (blue) blocking its left-hand-side lane and thus has no choice but to stay in its lane and slow down to block the traffic behind and open up space for the merging vehicle (purple). This behavior is observable in the speed profile of the Guide AV as well as the provided snapshots. In the second example (the middle plots), the Guide AV's path is blocked by another HV but it finds the left lane open and thus makes a lane-change to open up space for the merging vehicle, resulting in a safe merging. In the third example (the right-most plots), the Guide AV has mastered a way to both enable the merging vehicle to merge, i.e., account for the utility of others, and also perform another lane-change to speed up and optimize for its local utility.
\section{Concluding Remarks}
Overall, we observe that using our proposed decentralized multi-agent learning scheme, we are able to induce altruism into the decision-making process of autonomous vehicles and adjust their social value orientation. Our altruistic agents not only learn to drive on the highway environment from scratch but also are able to coordinate with each other and affect the behavior of humans around them to realize socially-desirable outcomes that eventually improve traffic safety and efficiency. Our work on social navigation is limited in the sense that we have not used actual human drivers in our simulations nor realistic human driving data and instead have implemented a simple driving model from the literature. However, we believe that our solution can be extended using more realistic human behaviors and our trained agents should be able to adapt accordingly. Additionally, we used a simple remedy to grasp the temporal dependencies in driving data using our stacked VelocityMaps, however, more sophisticated solutions such as recurrent architectures can further improve the capabilities of our methods in maneuver planning.
{\small
\bibliographystyle{ieee_fullname}
| {'timestamp': '2021-07-14T02:01:03', 'yymm': '2107', 'arxiv_id': '2107.05664', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05664'} | arxiv |
\section{Introduction}
\label{sec:introduction}
Kitting is the critical part of industrial automation in order to organize and place 3D parts into complementary cavities. This process saves time on the manufacturing line and frees up space to reduce shipping and storage cost. Automating kitting requires picking and re-orienting a part to a desired position and orientation, and then inserting it into a cavity that loosely conforms to the object geometry. However, automating this process is a great challenge, and in industry, most kitting
is performed manually.
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth,trim=0 0 187 0, clip]{figures/Fig1_Final.png}
\caption{\textbf{Physical experiments using an ABB YuMi robot and a Photoneo depth camera}. Left: A suction gripper holds an object unseen during training time
near the kitting cavity.
Kit-Net orients the object
for insertion into the cavity through 5 steps. A) Starting state. B) Flip the object 180\degree{} to face the camera and minimize occlusion from the gripper. C) Iteratively orient the object into a goal configuration.
D) Flip back and align centroids of the object and cavity to prepare for insertion. E) Insert and release.}
\label{fig:splash}
\end{figure}
Given a 3D CAD model of the object to be inserted and the desired object pose, one approach is to directly estimate the object pose and the transformation to the desired pose~\cite{ChoyDeepGlobal, xiang2017posecnn}. However, CAD models may not be available for all objects to be kit and are time consuming to create for every object, motivating an algorithm that can kit previously unseen objects without requiring such models. Prior work has considered kitting objects without models,
but has focused on $SE(2)$ transforms (rotation and translation in a plane) for extruded 2D polygonal objects~\cite{Zakka2020Form2FitLS,zeng2020transporter}. In this work, we propose a method for kitting objects with complex 3D geometries, for which 3D transforms may be required for reliable kitting.
We formalize the problem of rotating and translating a novel 3D object to insert it into a novel kitting cavity and present \emph{Kit-Net}.
Kit-Net is a framework for inserting previously unseen 3D objects with unknown geometry into a novel target cavity given depth images of the object in its current orientation and a depth image of either a flipped (convex) or standard (concave) target cavity. Kit-Net extends prior work from~\citet{CASE_Orienting}, which used simulation and self-supervision to train a deep neural network to directly estimate 3D transformations between the two depth images. Given the trained deep neural network, a depth image of a previously unseen insertion cavity, and a depth image of a previously unseen object, Kit-Net iteratively estimates the $SE(3)$ transform to reorient and insert the object, without requiring detailed knowledge of its geometry. Kit-Net improves on prior work by (a) introducing dataset augmentations that make the controller more robust, (b) using a suction cup gripper to minimize object occlusion during rotation, (c) incorporating 3D translations, and (d) applying the resulting controller to kit novel objects into novel cavities on a physical robot. We evaluate Kit-Net both in simulation and in physical experiments on an ABB YuMi robot with a suction gripper and overhead depth camera. Experiments in simulation suggest that Kit-Net can orient objects to have a 98.9\,\% average intersection volume between the object mesh and that of the target cavity. Physical experiments with 3 industrial objects and cavities suggest that Kit-Net can kit objects at a 63\,\% success rate from a diverse set of initial orientations.
This paper makes the following contributions:
\begin{enumerate
\item Formulating the problem of iteratively kitting a novel 3D object into a novel 3D cavity.
\item Kit-Net: a self-supervised deep-learning framework for this problem
\item Simulation experiments suggesting that Kit-Net can reliably orient novel objects for insertion into prismatic cavities.
\item Physical experiments suggesting that Kit-Net can significantly increase the success rate of 3D kitting into conformal 3D cavities from 18\,\% to 63\,\% over a baseline inspired by Form2Fit~\cite{Zakka2020Form2FitLS} that only considers 2D transformations when kitting.
\end{enumerate}
\section{Related Work}
\label{sec:related-work}
There has been significant prior work on reorienting objects using geometric algorithms. \citet{goldberg1993orienting} proposes a geometric algorithm that orients polygonal parts with known geometry without requiring sensors. \citet{akella-orienting-uncertainty} extend the work of Goldberg with sensor-based and sensor-less algorithms for orienting objects with known geometry and shape variation. \citet{kumbla2018enabling} propose a method for estimating object pose via computer vision and then reorient the object using active probing. \citet{grasp-gaits} optimize robot finger motions to reorient a known convex object while maintaining grasp stability. \citet{parts-feeder} propose an end-to-end pipeline for bin-picking, regrasping, and kitting known parts into known cavities. In contrast, Kit-Net can reorient objects without prior knowledge of their 3D models.
\citet{delta-pose-est}, \citet{latent-3d-keypoints}, \citet{Wen2020se3TrackNetD6}, and \citet{CASE_Orienting} use data-driven approaches to estimate the relative pose difference between images of an object in different configurations.
\citet{delta-pose-est} use a Siamese network to estimate the relative pose between two cameras given an RGB image from each camera. \citet{latent-3d-keypoints} propose KeypointNet, a deep-learning approach that learns 3D keypoints by estimating the relative pose between two different RGB images of an object of unknown geometry, but known category.
\citet{Wen2020se3TrackNetD6} considers an object-tracking task by estimating a change in pose between an RGBD image of the object at the current timestep and a rendering of the object at the previous timestep, but require a known 3D object model. We use the network architecture from \citet{Wen2020se3TrackNetD6} to train Kit-Net, and extend the self-supervised training method and controller from \citet{CASE_Orienting} to kit novel objects into previously unseen cavities. We find that by extending~\citet{CASE_Orienting} to be more robust to object translations and using a suction gripper to reduce occlusions, Kit-Net is able to learn more accurate reorientation controllers.
There has also been significant interest in leveraging ideas in pose estimation for core tasks in industrial automation.
\citet{Litvak2019LearningPE} leverage CAD models and assemble gear-like mechanisms using depth images taken from a camera on a robotic arm's end-effector. \citet{Stevic2020LearningTA} estimate a goal object's pose to perform a shape-assembly task involving inserting objects which conform to a specific shape template into a prismatic cavity. \citet{Zachares2021InterpretingCI} combines vision and tactile
sensorimotor traces for an object-fitting task involving known holes and object types.
\citet{Huang2020Generative3P} consider the problem of assembling a 3D shape composed of several different parts. This method assumes known part geometry and develops an algorithm to generate the 6-DOF poses that will rearrange the parts to assemble the desired 3D shape. In contrast to these works, we focus on the problem of designing a controller which can reorient and place a novel object within a previously unseen cavity for industrial kitting tasks.
Object kitting has also seen recent interest from the robotics community. \citet{Zakka2020Form2FitLS} introduce Form2Fit, an algorithm that learns $SE(2)$ transforms to perform pick-and-place for kitting planar objects. In contrast, we consider 6-DOF transforms of 3D objects.
\citet{zeng2020transporter} propose a network for selecting suction grasps and grasp-conditioned placement, which can generalize to multiple robotic manipulation tasks, including pick-and-place for novel flat objects. \citeauthor{zeng2020transporter} focuses on $SE(2)$ rotations and translations for pick-and-place tasks involving novel flat extruded 2D objects. \citeauthor{zeng2020transporter} also presents an algorithm for $SE(3)$ pick-and-place tasks, but only evaluate the algorithm on extruded 2D objects. In contrast, we use Kit-Net to kit novel 3D objects with complex geometries.
\section{Problem Statement}
\label{sec:problem-statement}
Let $T^s \in SE(3)$ be the initial 6D pose of a unknown 3D rigid object $O$ in the world coordinate frame, consisting of a rotation $R^s \in SO(3)$ and a translation $t^s \in \mathbb{R}^3$. Given $O$ with starting pose $T^s$ and a kitting cavity $K$, let $\mathcal{G} \subset SE(3)$ be the set of goal 6-DOF poses of object $O$ that result in successful kitting. The goal is to orient object $O$ to $T^g \in \mathcal{G}$, where $T^g$ consists of rotation $R^g$ and translation $t^g$. Figure~\ref{fig:mug-cavity-2} shows a simulated example where a 3D object $O$ is successfully kitted into a concave cavity $K$.
\subsection{Assumptions}
\label{subsec:formulation}
We assume access to depth images of a rigid object $O$ and a kitting cavity $K$. The cavity image may be taken with the cavity either in its standard, concave orientation (i.e., open to object insertion), or flipped, convex orientation (i.e., mirroring the shape of the object to be inserted).
We also assume that orienting $O$ to a pose in $T^g \in \mathcal{G}$ and releasing the gripper results in a successful kitting action.
\input{includes/fig-blender-cavity}
\subsection{Input}
\label{subsec:input}
Let $I^s \in \mathbb{R}^{H \times W}$ be a depth image observation of the object in initial pose $T^s$, and
$I^k \in \mathbb{R}^{H \times W}$ be the depth image observation of a kitting cavity, $K$. See Figure~\ref{fig:clamshell-cavities} for physical examples of objects and kitting cavities. We use a depth map as input to the neural network only to be consistent with depth-only methods of grasping such as \cite{mahler2017dex} and \cite{danielczuk2020exploratory}.
\subsection{Output}
\label{subsec:output}
The goal is to successfully kit an unknown 3D object $O$ into a novel 3D cavity $K$ (Fig.~\ref{fig:splash}, Fig.~\ref{fig:mug-cavity-2}). Thus, we aim to transform the initial pose $T^s$ into a goal pose that fits into the cavity (i.e., $T^g \in \mathcal{G}$). For objects with symmetries, the objective is to estimate and orient objects relative to a (symmetric) orientation that results in successful insertion into the cavity K.
\section{Method}
\section{Kit-Net Framework}
\label{sec:method}
We present Kit-Net, a framework that first reorients the object into a pose that can be successful kit in a desired cavity, and then translates and inserts the object into the cavity. We do this by learning to estimate ${_s}T^g \in SE(3)$, a relative transformation consisting of rotation ${_s}R^g$ and translation ${_s}\hat{t}^g$, which transforms the object from $T^s$ to $T^g$ for some $T^g \in \mathcal{G}$ in the world coordinate frame. The overall approach is to (1) compute an estimate of ${_s}R^g$, denoted ${_s}\hat{R}^g$, given only image observations $I^s$ and $I^k$, (2) iteratively reorient the object according to ${_s}\hat{R}^g$ and (3) translate the object by ${_s}\hat{t}^g$, an estimate of the translation between the start and goal object translations, such that $\{\hat{R}^g,\hat{t}^g\} \in \mathcal{G}$ and the object can be successfully dropped or inserted into kitting cavity by releasing the gripper.
We first discuss preliminaries (Section~\ref{subsec:prelims}) and then describe the key new ideas in training Kit-Net (Section~\ref{subsec:kit-net-training}) which make it possible to design a controller to rotate and translate an object to fit it in a cavity (Section~\ref{subsec:kit-net-alg}).
\subsection{Preliminaries: Estimating Quaternion Rotations in 3D}
\label{subsec:prelims}
\citet{CASE_Orienting} presented a self-supervised deep-learning method to align
two 3D objects.
The method takes two depth images as input: $I^s$, an image of the object in its current orientation $R^s$; and $I^g$, an image of the same object in its desired goal orientation $R^g$ in the world coordinate frame. It trains a deep neural network $f_\theta:\mathbb{R}^{H\times W}\times\mathbb{R}^{H\times W} \rightarrow SO(3)$
to estimate the rotation ${_s}\hat{R}^g$ (parametrized by a quaternion) in the object coordinate frame between the pair of images $(I^s, I^g)$. In simulation experiments, we use the object's center of mass, while for physical experiments, we use the robot arm's end effector as the center of the object coordinate frame.
Then, using a proportional controller, it iteratively rotates the object to minimize the estimated rotational difference. This controller applies $\eta{_s}\hat{R}^g$ to the object in the object coordinate frame until
the network predicts that the current object rotation $R^s$ is within a tolerance $\delta$ (e.g., $\delta = 0.5\degree$) of $R^g$, or until the controller reaches an iteration limit. The tunable constant $\eta$ is the Spherical-Linear intERPolation (slerp) factor describing the proportion of $\hat{R}^g$ that the controller will apply to $O$. \citeauthor{CASE_Orienting} use $\eta=0.2$ and an iteration limit of 50 rotations.
For training,~\citeauthor{CASE_Orienting} generate a dataset consisting 200 pairs of synthetic depth images for each of the 698 training objects with random relative rotations, for a total of 139\,600 pairs. To account for parallax effects, each pair of images were generated from a fixed translation relative to the camera.
\citeauthor{CASE_Orienting} propose three loss functions to train $f_\theta$: a cosine loss, a symmetry-resilient loss, and a hybrid of the two, with the hybrid loss outperforming the first two. Note that \citeauthor{CASE_Orienting} do not consider cavity insertion tasks, which is complicated by the need to reason about the translations and required alignment with a cavity.
Kit-Net improves on \citeauthor{CASE_Orienting} by (1) introducing dataset augmentations to make the controller more robust, (2) using a suction cup gripper to minimize object occlusion during rotation, and (3) incorporating translations into the controller to enable kitting. We discuss these contributions in the following sections.
\subsection{Kit-Net Dataset Generation, Augmentation, and Training}
\label{subsec:kit-net-training}
Kit-Net
trains a neural network $f_\theta$ with a self-supervised objective by taking as input pairs of depth images $(I^s, I^g)$ and estimating ${_s}\hat{R}^g$ from image pair $(I^s, I^g)$. As in \citeauthor{CASE_Orienting}, $f_\theta$ encodes each depth image into a length 1024 embedding, concatenates the embeddings, and passes the result through two fully connected layers to estimate a quaternion representation of the rotational difference between the object poses.
\subsubsection{Initial Dataset Generation}
In contrast to \citeauthor{CASE_Orienting}, we are interested in kitting, rather than just reorienting an object in the robot gripper. Thus, in this paper we focus on two types of kitting cavities: prismatic cavities (Fig.~\ref{fig:prism-task}) and conformal cavities (Fig.~\ref{fig:clamshell-cavities}).
We generate a separate dataset for each type of cavity and train a separate network for each dataset.
To generate both datasets, we use the set of 698 meshes from \citet{mahler2019learning}. For each mesh, we generate 512 depth image pairs, for a total of 357\,376 pairs. To do this we first generate a pair of rotations $(R^s, R^g)$, where $R^s$ is generated by applying one rotation sampled uniformly at random from $SO(3)$ to $O$, and $R^g$ is generated by applying a random rotation with rotation angle less than 30 degrees onto $R^s$. To generate the conformal cavity dataset, we then obtain a pair of depth images $(I^s, I^g)$ by rendering the object in rotations $R^s$ and $R^g$ from an overhead view. The pair is labeled with the ground-truth rotation difference between the images. To generate the prismatic cavity dataset we follow the same process, except we fit and render a prismatic box around the rotated object (Fig.~\ref{fig:prism-task-eval-objects}) and render the depth image pairs (Fig.~\ref{fig:prism-task}). This results in two datasets, each containing 357\,376 total labeled image pairs $(I^s, I^g)$ with ground-truth rotation labels ${_s}R^g$.
\subsubsection{Data Augmentation}
We found that simply training a network directly on these datasets results in poor generalization to depth images from the physical system which contain (1) sensor noise, (2) object occlusions from the object, the arm, or gripper, and (3) 3D object translations within the image. To address these three points, we introduce dataset augmentations to ease network transfer from simulated to real depth images.
To simulate noise and occlusion in training, we randomly zero out 1\,\% of the pixels in each depth image and add rectangular cuts of width 30\,\% of zero pixels to the image.
To simulate translations in training,
we randomly translate the object across a range of 10\,cm in the $x$, $y$, and $z$ axes with respect to the camera in the simulated images. We also crop the images at sizes from 5\,\% to 25\,\% greater than the object size with center points offset from the object's centroid by 5 pixels to simulate
$(I^s, I^g)$ pairs generated from objects and cavities outside the direct overhead view.
\subsubsection{Training} We adopt the network architecture from \citet{Wen2020se3TrackNetD6}, as it is designed to be trained in simulation and demonstrates state-of-the-art performance on object tracking~\cite{DengPoseRBPF} by regressing the relative pose between two images. We use the hybrid quaternion loss proposed by \citet{CASE_Orienting}. The network is trained with the Adam optimizer with learning rate 0.002, decaying by a factor of 0.9 every 5 epochs with an L2 regularization penalty of $10^{-9}$.
\subsection{Kit-Net Suction Gripper}
Kit-Net uses an industrial unicontact suction gripper from \citet{mahler2017suction} to grasp the object for kitting. In contrast, \citeauthor{CASE_Orienting} used a parallel jaw gripper. We find the suction gripper to be better suited for kitting because it reduces gripper occlusions
and enables the robot to position the object directly inside the kitting cavity.
\subsection{Kit-Net Controller} \label{subsec:kit-net-alg}
The Kit-Net controller consists of two stages: rotation and translation.
\subsubsection{Rotation}
Kit-Net first re-orients an object using the depth image of the current object pose $I^s$ and a depth image of the goal cavity pose $I^g$. In preliminary experiments, we found the rotation parameters used by \citet{CASE_Orienting} (Section~\ref{subsec:prelims}) to be overly conservative. Thus, to speed up the alignment process, we use a larger slerp factor of $\eta=0.8$. If the network predicts a rotation difference of less than $\delta=5\degree$, then we assume that the object is close enough to the required pose for kitting into the cavity and terminate the rotation controller. Because of the larger slerp value, Kit-Net is able to quickly reorient the object, thus we terminate the rotation controller after a maximum of 8 sequential rotations (8 iterations).
\subsubsection{Translation}
We iteratively refine the rotation in $SO(3)$ first before aligning translation to ensure that the translation estimation is as accurate as possible. Once the rotation controller terminates, Kit-Net computes a 2D translation to move the object directly over the target cavity, and then lowers the object and releases it into the cavity. To calculate the 2D translation, we project the final depth image $I^s$ of the object after rotation and the depth image of the cavity $I^g$ to point clouds in the world coordinate frame. We know the position of the object in the gripper and the cavity on the workspace so we can segment out the background and isolate the object and cavity in the point clouds. Then, we perform centroid matching between the two point clouds to estimate the 2D translation.
\section{Simulation Experiments}
\label{sec:experiments}
We first discuss metrics to evaluate performance in Section~\ref{subsec:metrics}. We then introduce a baseline algorithm (Section~\ref{subsec:baseline}) with which to compare Kit-Net and present experimental results in Section~\ref{subsec:results}. In experiments, we first evaluate Kit-Net on re-orienting novel objects with unknown geometry into a target prismatic box in simulation (Section~\ref{subsubsec:prismatic}).
\subsection{Baselines}
\label{subsec:baseline}
\subsubsection{Random Baseline}
We also compare Kit-Net with a baseline that applies a randomly sampled rotation but with the correct rotation angle to evaluate how important precise reorientation is for successful kitting.
\subsubsection{2D Baseline}
To evaluate the importance of estimating 3D rotations for successful kitting, we compare Kit-Net to a baseline inspired by
Form2Fit~\cite{Zakka2020Form2FitLS}, which only considers 2D rotations when orienting objects for kitting. The baseline (1) aligns the centroids of the point clouds of the object and the cavity and (2) searches over possible rotations about the $z$-axis at a 1\textdegree~discretization to find the rotation that minimizes Chamfer distance between the centroid-aligned point clouds.
\subsection{Metrics}
\label{subsec:metrics}
\subsubsection{Object Eccentricity}
We categorize test objects by their \emph{eccentricity}, which provides a measure of kitting difficulty. This categorization
follows the intuition
that objects that are more elongated along certain dimensions than others have a smaller set of acceptable orientations in which they can be successfully kit into a cavity. Let the eccentricity $\varepsilon$ of a 3D object be $\varepsilon = A - 1$, where $A$ is the aspect ratio (ratio of longest side to shortest side) of the minimum volume bounding box of the object. This definition generalizes the 2D definition of eccentricity from \citet{GoldbergEccentricity2000} to 3D. Under this definition, a sphere has $\varepsilon = 0$, and if one axis is elongated by a factor $p$, then the resulting ellipsoid has eccentricity $p-1$. This definition is also consistent with the intuition provided earlier, as a sphere is entirely rotationally symmetric, and thus does not require any reorientation for kitting. By contrast, the ellipsoid will require reorientation to ensure that its longer side is aligned to a region with sufficient space in the cavity. Thus, we use objects with high eccentricity in evaluating both Kit-Net and the baselines, as these objects pose the greatest challenge for kitting in practice.
\subsection{Results}
\label{subsec:results}
When evaluating Kit-Net in simulation, we have access to ground-truth object and cavity geometry. Thus, we evaluate kitting performance using the following percent fit metric:
\begin{equation}\label{eq:percent-fit}
\hat{\kappa}(I^s, I^g, \hat{{_s}T^g}) = \frac{1}{N} \sum_{i=1}^N \mathbf{1}_{(p_i \in K)},
\end{equation}
where we uniformly sample $N$ points within the object volume at configuration $\hat{{_s}R^g}R^s$ (after the target object has been rotated for insertion) and count the portion of sampled points that also lie within cavity. This metric can be efficiently computed using ray tracing and effectively estimates how much of the object fits inside the target mesh after the predicted rotation.
In experiments, we use $N=10^4$ sampled points to evaluate $\hat{\kappa}$. Assuming the true percent fit metric is $\kappa$, a 95\,\% confidence interval for $\kappa$ is $\hat{\kappa} \pm 1.96\sqrt{\frac{\hat{\kappa}(1-\hat{\kappa})}{10^4}}$. For example, if $\hat{\kappa} = 0.99$, then $\kappa$ lies between $(0.988, 0.992)$ with 95\,\% confidence.
\input{includes/5.1-prismatic-cavity}
\subsubsection{Simulated Kitting into a Prismatic Target}
\label{subsubsec:prismatic}
\begin{figure}[t]
\vspace{8pt}
\centering
\includegraphics[width=0.8\linewidth]{figures/prismatic_example_labeled.png}
\caption{\textbf{Endstop Holder and Target Prismatic Cavity in Simulation: } Given $I^s$, an image of an object in some configuration (top left) and $I^g$, an image of a target prismatic box to which the object must be aligned (top right), the objective is to find a 3D rotation $\hat{{_s}R^g}$ that would allow the object to fit within the box. In simulation experiments, $R^g$ is a $30$\degree~rotation from $R^s$. The image in the figure shows an object that must be rotated by 30\degree~ to perfectly fit it inside the prism. 3D models corresponding to $I^s$ and $I^g$ are shown in the bottom row for clarity.
}
\label{fig:prism-task}
\end{figure}
We first study whether Kit-Net can orient objects into alignment with a prismatic cavity that loosely conforms to their 3D geometry in simulation. Precisely, we first generate the prismatic cavity for the target by creating a mesh with faces corresponding to its minimum volume bounding box. We then rotate both the prismatic cavity and target to random orientations within 30 degrees of each other. The objective is to apply a rotation ${_s}\hat{R}^g$ that will allow the object to fit into the cavity. An example image pair of an object and an associated prismatic cavity is shown in Figure~\ref{fig:prism-task}.
Fig.~\ref{fig:mean-percent-fit-ecc} shows the percent fit across 174 unseen test objects. We use the eccentricity $\epsilon$ of the objects to sort them into 5 bins of increasing difficulty (increasing $\epsilon$). We find that Kit-Net is able to reliably kit novel objects, significantly outperforming the 2D rotation baseline. When averaged across all eccentricities, Kit-Net achieves an average fit of 98.9\,\% compared to an average fit of 93.6\,\% for the 2D baseline and 83.1\,\% when applying a random 30\degree~quaternion. These results demonstrate the need for 3D rotations to solve complex kitting problems. Figure~\ref{fig:mean-percent-fit-ecc} demonstrates that Kit-Net is robust to highly eccentric objects which require the most precision for kitting. Kit-Net achieves an average fit of 89.9\,\% for objects with eccentricity greater than 8. The 2D rotation baseline performs especially poorly for these difficult objects and achieves an average fit of only 72.7\,\% while applying a random 30\degree~quaternion results in an average fit of just 37.4\,\%.
As described in Section~\ref{subsec:kit-net-alg}, Kit-Net iteratively orients each object using the controller until $\hat{{_s}R^g}\leq 5\degree$, or until we hit the stopping condition of 8 iterations. Our previous results in Fig.~\ref{fig:mean-percent-fit-ecc} suggests that Kit-Net can consistently align objects within 5 controller steps.
To better visualize the ability of Kit-Net to rapidly reorient an object for kitting, we plot the per-iteration performance of Kit-Net for 4 test objects unseen at training time with high eccentricity ($\epsilon \geq 2$). Fig.~\ref{fig:prism-task-eval-objects} shows renderings of these objects along with outlines of the corresponding prismatic kitting cavities. Fig.~\ref{fig:percent-fit-runs} shows the average per-iteration percent fit across 100 controller rollouts of randomly sampled $(I^s,I^g)$ pairs for each object. We find that Kit-Net is able to consistently align objects with their target prismatic cavities, and achieves a median fit percentage of 99.4\,\% after only 3 successive iterations of the controller. By contrast, the 2D baseline is not able to surpass an average fit of 90\,\% for any of the objects. The results in Fig.~\ref{fig:percent-fit-runs} demonstrate the importance of iteratively reorienting parts and demonstrates that applying multiple iterations of the rotation output by the trained network can greatly help to reduce the error between $\hat{{_s}R^g}R^s$ and $R^g$ as compared to a single iteration.
\begin{figure}[t]
\centering
\vspace{8pt}
\includegraphics[width=\linewidth]{figures/percent_fit_ecc_v4.png}
\caption{\textbf{Aligning Objects to Prismatic Cavities in Simulation: }We evaluate Kit-Net's ability to align objects with prismatic cavities under the percent fit metric introduced in Section~\ref{subsec:metrics} across 512 depth image pairs for each of 174 objects not seen during training. Given $(I^s,I^g)$, the network predicts $\hat{{_s}R^g}$ that will allow it to fit inside the cavity. We bin results by object eccentricity and observe that the mean percent fit decreases for objects of higher eccentricity. Kit-Net outperforms both the 2D and random baselines by a greater amount as object eccentricity increases.}
\label{fig:mean-percent-fit-ecc}
\end{figure}
\begin{figure}[t]
\centering
\subcaptionbox*{Industrial Part}{\includegraphics[height=50pt, trim=333 48 418 33, clip]{figures/Industrial_Prismatic_Cavity_Task_Objects.png}}%
\hfill%
\subcaptionbox*{Shield Part}[42pt]{\includegraphics[height=50pt, trim=581 18 250 0, clip]{figures/Industrial_Prismatic_Cavity_Task_Objects.png}}%
\hfill%
\subcaptionbox*{Endstop Holder}{\includegraphics[height=50pt, trim=7 53 670 28, clip]{figures/Industrial_Prismatic_Cavity_Task_Objects.png}}%
\hfill%
\subcaptionbox*{Raspberry Pi Case}[62pt]{\includegraphics[height=50pt, trim=743 26 14 14, clip]{figures/Industrial_Prismatic_Cavity_Task_Objects.png}}
\caption{\textbf{Examples of Novel Objects for Kit-Net Simulation Experiments: }
The four test objects are unseen during training and have eccentricity greater than 2, meaning their minimum volume bounding boxes are narrow and long. An outline of the corresponding minimum volume bounding box is shown around each part.}
\label{fig:prism-task-eval-objects}
\end{figure}
\begin{figure}[t]
\centering
\vspace{8pt}
\includegraphics[width=0.48\textwidth]{figures/percent_fit_controller_runs_v6.png}
\caption{\textbf{Kit-Net Simulation Results: } We visualize data from 100 runs on each of the 4 objects shown in Figure~\ref{fig:prism-task-eval-objects}. All objects require a 30\degree~rotation to be in alignment with the prismatic target at iteration 0, but their initial percent fits differ due to different eccentricities. Results suggest that Kit-Net is able to successfully align all 4 objects with their respective prismatic cavities while the baseline, which restricts itself to 2D rotations, performs significantly worse on all 4 objects.}
\label{fig:percent-fit-runs}
\end{figure}
\section{Physical Experiments}
\label{sec:physical-experiments}
Our previous experiments studied the effectiveness of Kit-Net for insertion tasks involving prismatic cavities. However, many physical kitting tasks involve non-prismatic cavities (e.g., Fig.~\ref{fig:clamshell-objects} and Fig.~\ref{fig:clamshell-cavities}). In this section, we study how Kit-Net can be used to kit objects in physical trials using depth images of the types of cavities shown in Fig.~\ref{fig:clamshell-cavities}. We call these \emph{conformal cavities}, as they ``conform'' (to some degree) to the object shape.
In these experiments, we use a quaternion prediction network trained to predict the quaternion that will rotate a simulated depth image of an object to another simulated depth image of the same object in a different pose. We propose two possible methods for applying this trained network to kitting. Our first method is designed to work well with the clamshell cavities shown in Fig.~\ref{fig:clamshell-cavities}. Rather than image the hole of the cavity, we define a \emph{convex conformal cavity} to be the depth image of the inverted cavity. To obtain these depth images, we flip the cavity so the hole is pointing down and take a depth image of the positive mass of the cavity. The left image in Fig.~\ref{fig:clamshell-cavities} shows examples of these convex conformal cavities. Our second method works with a \emph{concave conformal cavity}, like that shown in Fig.~\ref{fig:mug-cavity-2} and the right image in Fig.~\ref{fig:clamshell-cavities}, that are formed as impressions into a surface. These types of cavities cannot simply be flipped upside down to obtain a depth image of their shape. Instead, we take a depth image of the actual cavity (where the cavity has negative mass) and rotate it 180\degree~about its principal axis.
We discuss the results for applying Kit-Net to novel convex conformal cavities in Section~\ref{subsubsec:real-positive} and to novel concave conformal cavities Section~\ref{subsubsec:real-negative}.
For the physical kitting experiments we measure success using a binary success metric for insertion by visually inspecting whether or not the object is completely contained in the target cavity.
\input{includes/6.1-positive-cavity}
\input{includes/6.2-negative-cavity}
\subsection{Physical Kitting into Convex Conformal Cavities}
\label{subsubsec:real-positive}
\begin{figure}[t]
\vspace{8pt}
\centering
\begin{tikzpicture}[label/.style={inner sep=4pt, rounded corners=2pt, color=white, fill=black, fill opacity=0.25, text opacity=1, align=center, font=\footnotesize, yshift=2pt}]
\node [inner sep=0] (img) {%
\includegraphics[width=\columnwidth]{figures/Three_Industrial_Objects.png}};
\node [label, anchor=south west, xshift=14pt] at (img.south west) { Sink handle };
\node [label, anchor=south, xshift=-4pt] at (img.south) { Handrail bracket };
\node [label, anchor=south east, xshift=-14pt] at (img.south east) { Ornamental \\ handrail bracket };
\end{tikzpicture}
\caption{\textbf{Objects for Kit-Net Physical Experiments: }We use 3 packaged industrial objects available in hardware stores.
We selected objects for their complex geometries that make precise orientation critical for effective kitting.}
\label{fig:clamshell-objects}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{figures/convex_concave_examples.pdf}
\caption{\textbf{Examples of Physical Kitting Cavities: }The handrail bracket (bottom) and the ornamental handrail bracket (top), next to the corresponding convex cavity (left) and concave cavity (right).}
\label{fig:clamshell-cavities}
\end{figure}
We evaluate Kit-Net in physical kitting trials using an ABB-YuMi robot with a Photoneo depth camera (Fig.~\ref{fig:splash}) on 4 packaged objects available in hardware stores and which are unseen during training (Fig.~\ref{fig:clamshell-objects}).
To prepare objects for kitting, we extract each object and kitting shell from its packaging and spray paint the shell to facilitate depth sensing (Fig.~\ref{fig:clamshell-cavities}). We then place the kitting cavity open end down directly under the camera and image the cavity to generate $I^g$ before flipping it and moving it onto the workspace to expose its opening for the insertion task. For each trial, we insert the object into the cavity by hand, grasp it using the robot's suction gripper, translate it to be directly under the camera, and apply a random rotation of either $30\degree$ or $60\degree$about a random axis to simulate grasping the object from a bin in a non-uniform pose. Then, the robot flips the object to face the overhead depth camera and have the suction gripper occluded from the camera by the object. This process is illustrated in Fig.~\ref{fig:splash}.
Kit-Net then orients the object using the learned controller, and matches centroids between the object and cavity for insertion before flipping it again and attempting to kit it. Table~\ref{table:positive-results} shows the number of successful kitting trials (out of 10 per object) of Kit-Net and the 2D baseline across 3 objects. We report a kitting trial as successful if the object is fully contained within the cavity using visual inspection. We observe that Kit-Net outperforms the baseline for 30\degree~initial rotations on 2 of the 3 objects, performing similarly to the baseline on the sink handle. We find that Kit-Net significantly outperforms the baseline on all objects for 60\degree~initial rotations.
The main failure modes are due to errors in the centroid matching procedure, as illustrated in Fig.~\ref{fig:failure-modes}. On the 30 degree sink handle task, Kit-Net aligned it correctly every time, but the centroid matching was off by about 5\,mm, and there is no slack at the top of the cavity.
\begin{table}[h]
\centering
\begin{tabular}{l c c c}\toprule
Object & Angle & 2D Baseline & Kit-Net \\
\midrule
Handrail bracket & 30\degree & 3/10 & \bf 10/10 \\
Ornamental handrail bracket & 30\degree & 8/10 & \bf 10/10 \\
Sink handle & 30\degree & \bf 4/10 & 3/10 \\
\addlinespace
Handrail bracket & 60\degree & 1/10 & \bf 9/10 \\
Ornamental handrail bracket & 60\degree & 2/10 & \bf 7/10 \\
Sink handle & 60\degree & 0/10 & \bf 7/10 \\
\bottomrule
\end{tabular}
\caption{\textbf{Physical Experiments Results for Convex Cavities: }We report the number of successful kitting trials for Kit-Net and the 2D baseline over 10 trials for 3 previously unseen objects with initial rotations of 30\degree~ and 60\degree~. Results suggest that Kit-Net significantly outperforms the 2D baseline for initial rotations of 60\degree~ and outperforms the baseline for two out of three objects for initial rotations of 30\degree~.}
\label{table:positive-results}
\end{table}
\subsection{Physical Kitting into Concave Conformal Cavities}
\label{subsubsec:real-negative}
The positive cavity task provides a detailed depth image, but requires the cavity to first be presented at a flipped, 180\degree~rotation for imaging and then flipped back for the kitting task, which may not be feasible in an industrial environment.
Here, we perform the same experiment as in Section~\ref{subsubsec:real-positive}, but instead generate $I^g$ directly from an image of the cavity without flipping. Precisely, we segment out the cavity from an overhead depth image. Because we know the location of the cavity when setting up the kitting task, we can segment out the background and isolate the cavity. See Figure~\ref{fig:splash} (Left) for visuals. In application, a dedicated area for the cavities with a flat background would aid in the segmentation. Then, we deproject the segmented depth image into a point-cloud representation, rotate the point cloud 180\degree~around its center of mass, and project the rotated point cloud to the depth image $I^g$. This process is illustrated in Fig.~\ref{fig:rotated-cavity}.
\input{includes/fig-generating-negative-goal-images}
\begin{table}[h]
\centering
\begin{tabular}{l c c c}\toprule
Object & Angle & 2D Baseline & Kit-Net \\
\midrule
Handrail bracket & 30\degree & 0/10 & \bf 9/10 \\
Ornamental handrail bracket & 30\degree & 0/10 & \bf 7/10 \\
Sink handle & 30\degree & 1/10 & \bf 3/10 \\
\addlinespace
Handrail bracket & 60\degree & 0/10 & \bf 7/10 \\
Ornamental handrail bracket & 60\degree & 0/10 & 0/10 \\
Sink handle & 60\degree & 1/10 & \bf 4/10 \\
\bottomrule
\end{tabular}
\caption{\textbf{Physical Experiments Results for Concave Cavities: }We report the number of successful kitting trials for Kit-Net and the 2D baseline over 10 trials for 3 previously unseen objects with initial rotations of 30\degree~ and 60\degree~. Results suggest that Kit-Net significantly outperforms the baseline in all settings except for the handrail bracket with an initial rotation of 60\degree~, for which neither Kit-Net nor the baseline can successfully kit the object.}
\label{table:negative-results}
\end{table}
Table~\ref{table:negative-results} shows results from experiments with 3 novel objects from Fig.~\ref{fig:clamshell-objects} across 10 controller rollouts. We observe that Kit-Net outperforms the baseline for initial rotations of both 30\degree~ and 60\degree~ on the handrail bracket and sink handle, and for an initial rotation of 30\degree~ for the ornamental handrail bracket. For the ornamental handrail bracket, the depth image from the concave cavity is low quality as shown in Fig.~\ref{fig:failure-modes} (center image), causing Kit-Net to fail when the object is 60\degree~ away the correct insertion orientation. We examined this failure and found that it occurs because the cavity for the neck of the bracket is very thin, making it difficult to obtain a good depth image. Kit-Net also has low performance on the sink handle due to small errors in centroid matching, as discussed in Section~\ref{subsubsec:real-positive}. Fig.~\ref{fig:failure-modes} (bottom left) shows an example failure case where the sink handle is correctly oriented but the translation is slightly off. Fig.~\ref{fig:failure-modes} (top left) shows an example of an occasional cases where the suction gripper occludes the handle of the ornamental handrail bracket. In these cases, the robot can only see the base, resulting in failure.
\begin{figure}[ht]
\vspace{8pt}
\centering
\includegraphics[width=0.48\textwidth]{figures/Failure_Cases.png}
\caption{\textbf{Kit-Net Failure Cases: } The top-left image shows a configuration of the ornamental handrail bracket
where the suction gripper occludes
the handle below the base. The bottom-left image shows the sink handle. Although Kit-Net was able to orient the handle correctly for insertion, the centroid matching had a small error in estimating translation and the cavity does not have enough slack to be properly inserted. The center and right images show depth images for the ornamental handrail bracket for the concave conformal cavity and convex conformal cavity, respectively.
The inside of the concave cavity is very thin and the angle of the camera makes it hard to perfectly image it, resulting in a poor depth image (center image).
This contributes to the failures for both the baseline and for Kit-Net when the initial rotation is 60\degree{} away from the desired rotation for kitting.}
\label{fig:failure-modes}
\end{figure}
\section{Discussion and Future Work}
\label{sec:discussion}
We present Kit-Net, a framework that uses self-supervised deep learning in simulation to kit novel 3D objects into novel 3D cavities. Results in simulation experiments suggest that Kit-Net can kit unseen objects with unknown geometries into a prismatic target in less than 5 controller steps with a median percent fit of 99\,\%.
In physical experiments kitting novel 3D objects into novel 3D cavities, Kit-Net is able to successfully kit novel objects 63\,\% of the time while a 2D baseline that only considers $SE(2)$ transforms only succeeds 18\,\% of the time.
In future work, we will work to improve performance by using the predicted error from Kit-Net
to regrasp the object in a new stable pose~\cite{tournassoud1987regrasping,dafle2014extrinsic,danielczuk2020exploratory} before reattempting the kitting task, study Kit-Net's performance with other depth sensors, and apply Kit-Net to kit objects that are initially grasped from a heap \cite{murali20206,danielczuk2020x}.
\section{Acknowledgments}
\begin{scriptsize}
\noindent This research was performed at the AUTOLAB at UC Berkeley in affiliation with the Berkeley AI Research (BAIR) Lab, Berkeley Deep Drive (BDD), the Real-Time Intelligent Secure Execution (RISE) Lab, and the CITRIS ``People and Robots" (CPAR) Initiative. Authors were also supported by the Scalable Collaborative Human-Robot Learning (SCHooL) Project, a NSF National Robotics Initiative Award 1734633, and in part by donations from Siemens, Google, Toyota Research Institute, Autodesk, Honda, Intel, Hewlett-Packard and by equipment grants from PhotoNeo and Nvidia. This material is based upon work supported by the National Science Foundation Graduate Research Fellowship Program under Grant No. DGE 1752814. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the sponsors.
\par
\end{scriptsize}
| {'timestamp': '2021-07-14T02:06:56', 'yymm': '2107', 'arxiv_id': '2107.05789', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05789'} | arxiv |
\section{Conclusions and Future Applications}
We conduct a battery of grasp simulations on 3D deformable objects and analyze grasp outcomes across performance metrics.
We propose grasp features and demonstrate their ability to predict the performance metrics. Our physical experiments also validate the accuracy of our large-scale simulations. We release our dataset of $1.1M$ measurements for further study, along with software that executes our experiments on arbitrary objects and material parameters. Based on our analysis of object primitives, we also identify several fundamental physical trends. We direct the reader to Appendix~\ref{primitives} for these findings. For future work, DefGraspSim can be used to:
\begin{itemize}
\item Study new, high-dimensional features and metrics (e.g., geometric encoding of object shape and contact patch, full stress distributions, etc.), since raw nodal data is accessible within DefGraspSim
\item Scale up grasping experiments to create task-oriented planners (e.g., to minimize deformation during transport)
\item Perform rigorous, direct comparisons between simulation and reality on custom objects of interest
\item Extend vision-based measurements from RGB-D images to interface with real sensors
\item Complement real-world system identification (e.g. tactile probing or visual shape completion)
\item Improve grasp planning robustness to uncertainty in object properties (e.g., via domain randomization)
\end{itemize}
\section{Introduction}
From clothing, to plastic bottles, to humans, deformable objects are omnipresent in our world. A large subset of these are \textit{3D deformable objects} (e.g., fruits, internal organs, and flexible containers), for which dimensions along all 3 spatial axes are of similar magnitude, and significant deformations can occur along any of them \cite{Sanchez2018IJRR}. Robotic grasping of 3D deformables is underexplored relative to rope and cloth, but is critical for applications like food handling \cite{Gemici2014IROS}, robotic surgery \cite{Smolen2009ICACHI}, and domestic tasks \cite{Sanchez2018IJRR}. Compared to rigid objects, grasping 3D deformable objects faces 4 major challenges.
First, classical analytical metrics for grasping rigid objects (e.g., force/form closure) do not typically consider deformation of the object during or after the grasp \cite{Sanchez2018IJRR}. Yet, deformations significantly impact the contact surface and object dynamics.
Second, existing grasp strategies for rigid objects may not directly transfer to 3D deformables, as compliance can augment or reduce the set of feasible grasps. For example, we may grasp a soft toy haphazardly; however, if the toy were rigid, it would no longer conform to our hands, and many grasps may become unstable. Conversely, we may grasp a rigid container haphazardly; however, if the container were flexible, grasps along its faces may crush its contents.
Third, the definition of a successful grasp on a 3D deformable is highly dependent on object properties, such as fragility and compliance. Thus, grasp outcomes must be quantified by diverse \textit{performance metrics}, such as stress, deformation, and stability. Performance metrics may also compete (e.g., a stable grasp may induce high deformation).
Fourth, performance metrics may be partially or fully unobservable (e.g., volumetric stress fields), requiring estimation in the real world. Previous works have typically formulated \textit{quality metrics}, which we refer to more generally as \textit{grasp features}: simple quantities that a robot can measure before pickup that can predict performance metrics. Whereas many grasp features have been proposed for rigid objects, analogous features for deformable objects are limited.
Given these complexities, we conduct a large-scale simulation-based study of 3D deformable object grasping (Fig.~\ref{fig:front_figure}). Simulation affords multiple advantages: it extends analytical methods through accurate modeling of object deformation, enables safe execution of experiments, and provides full observability of performance metrics. For an overview of existing literature on deformable object modeling, grasp performance metrics, and grasp features, see \textbf{Appendix~\ref{app:related_works}}.
\begin{figure}
\centering
\includegraphics[scale=0.30, trim={0cm 0cm 0cm 0cm},clip]{figures/front_fig_wide.png}
\caption{(A) For a broad set of candidate grasps on a deformable object, (B) we simulate the object's response with FEM, (C) measure performance metrics (e.g., stress, deformation, controllability, instability), and (D) identify pre-pickup grasp features that are correlated with the metrics. Our simulated dataset contains 34 objects, 6800 grasp evaluations, and $1.1M$ unique measurements.
}
\vspace{-16pt}
\label{fig:front_figure}
\end{figure}
We then leverage the corotational finite element method (FEM) to conduct several thousand grasping simulations on 3D deformables varying in geometry and elasticity. First, we simulate grasping on 6 object primitives; for each primitive, we methodically describe the effects of different grasps on performance metrics, and quantify the ability of each feature to predict each metric. Given the small number of prior works on grasping 3D deformables, this examination of primitives establishes valuable physical intuition.
Furthermore, we provide our live dataset of 34 objects, 6800 grasp evaluations, and $1.1M$ corresponding measurements. We also release our codebase, which can automatically perform our exhaustive set of FEM-based grasp evaluations on 3D objects of the user's choice. Finally, we provide an interactive visualizer of our results and a video of our simulated and real-world experiments.\footnote{\url{https://sites.google.com/nvidia.com/defgraspsim}} We believe these contributions are an important conceptual and practical first step towards developing a complete learning and planning framework for grasping 3D deformables.
\section{SIMULATION-BASED TESTBED}
\vspace{-6pt}
\begin{figure}[h]
\centering
\frame{\includegraphics[scale=0.30]{figures/database_34.png}}
\caption{The 34 evaluated objects grouped by geometry and dimension (shown to scale). Objects in blue are self-designed primitives; those in gray are scaled models from open datasets \cite{Calli2015RAM,Wu2015CVPR,thingiverse, ybjDataset}.
}
\label{fig:object_categories}
\vspace{-18pt}
\end{figure}
\section{Grasp Simulator and Experiments} \label{sim}
We use Isaac Gym \cite{isaacgym} to simulate grasps of the widely-used Franka parallel-jaw gripper on 3D deformable objects. To generalize to other parallel-jaw grippers, proprietary gripper features are removed. The 3D deformables consist of 34 object primitives and real-world models, with geometry and dimensionality distributed across a broad categorization (Fig. \ref{fig:object_categories}), and elastic moduli distributed from $10^4$ to $10^9$~$Pa$ (i.e., human skin to hard plastic).
The deformables are represented as tetrahedral meshes and simulated using 3D co-rotational FEM, with resulting equations solved using a GPU-based Newton method \cite{macklin2019}; a recent study has validated the simulator accuracy \cite{Narang2021Latent}. Addressing the limitations of classical analytical approaches, the simulator explicitly models complex object geometry, object deformation, gripper-object dynamics, and large perturbations. Simulations execute at $5$-$10$~$fps$, and in total, the dataset required 2080 GPU hours. Further details on the simulator itself are in \textbf{Appendix~\ref{appendix_sim}}.
Within Isaac Gym, we perform grasping experiments on 34 objects using a simulated Franka parallel-jaw gripper.
For each object, a diverse set of 50 candidate grasps is generated using an antipodal sampler~\cite{EppnerISRR2019}.
For each grasp, 4 tests are executed: \textit{pickup, reorientation, linear acceleration, and angular acceleration}. Details of each test are in \textbf{Appendix~\ref{appendix_experiment}}.
\section{Grasp Performance Metrics and Features}
\label{sec:metrics}
During the preceeding experiments, we measure 7 performance metrics to evaluate grasp outcomes, and 7 grasp features that correlate with the metrics. Details and motivation for these quantities are in \textbf{Appendix \ref{app:performance_metrics}}.
\vspace{0.2cm}
\begin{minipage}[t]{0.39\linewidth}
Metrics:
\begin{itemize}
\item Pickup success
\item Stress
\item Deformation
\item Strain energy
\item Linear instability
\item Angular instability
\item Def. controllability
\end{itemize}
\end{minipage}
\begin{minipage}[t]{0.55\linewidth}
Features:
\begin{itemize}
\item Contact patch distance to centroid
\item Contact patch perpendicular distance to centroid
\item Number of contact points
\item Contact patch distance to finger edge
\item Gripper squeezing distance
\item Gripper separation
\item Alignment with gravity
\end{itemize}
\end{minipage}
\vspace{0.2cm}
\section{Grasp Performance on Primitives} \label{primitives}
This section presents detailed grasping results for 6 of the 9 object primitives (Fig.~\ref{fig:object_categories}) over a wide range of elastic moduli, and uses physical reasoning to interpret the relationships between metrics and features. Each primitive abstracts a large set of real-world objects.
The \emph{rectangular prism} primitive represents objects such as sponges, tofu, and rubber blocks. The \emph{spheroid} primitive is
an ellipse revolved about its major axis; it represents objects such as rounded fruits and rubber balls.
The \emph{cup} and \emph{ring} primitives have the same geometry, but the ring lacks a base. Cups have direct real-world analogues; rings represent objects such as flexible tubing and gaskets. The geometric stiffness profile of a cup varies with height, whereas that of a ring does not; however, both objects behave differently between side grasps and top-bottom grasps. The \emph{hollow flask} primitive has an ellipsoidal cross section and represents objects such as boxes and bottles. The \emph{cylinder} primitive represents objects such as bananas and rubber tubes.
We divide our analysis into two sections. We first showcase the types of grasps that produce low and high values for the performance metrics defined in Sec.~\ref{sec:metrics}. We then evaluate the ability of the grasp features defined in Sec.~\ref{sec:features} to predict these metrics.
Additional visualizations are provided on our website.
\subsection{Performance Metric Results}
\noindent\textbf{Stress and Deformation Metrics.} We first examine the stress and deformation responses, which follow similar (but not identical) trends.
For the prism and spheroid, grasps with low values for maximum stress and deformation consistently squeeze along the shortest dimension (Fig.~\ref{fig:rect_sd} and Fig.~\ref{fig:spheroid_grasps}ab). In this configuration, the gripper achieves the highest contact area, lowering compressive stress. Furthermore, the smallest amount of material is between the gripper fingers; analogous to springs in series, a smaller material thickness has a higher equivalent stiffness, reducing deformation. For the prism, grasps with the highest values for maximum stress consistently squeeze along the long axis. The object tends to buckle, increasing bending stress. However, grasps with the highest values for maximum deformation vary with $E$ (Fig.~\ref{fig:rect_sd}c). The highest-valued grasps at $E{=}\{2e6, 2e9\}$ squeeze the end of the prism, allowing cantilever bending under gravity.
\begin{figure}[t]
\centering
\begin{subfigure}[b]{.32\columnwidth}
\centering
\includegraphics[scale=0.09, trim={0cm 0cm 60cm 0cm},clip]{figures/rectangle/rect_sd_big.png}
\caption{von Mises stresses}
\label{fig:rect_a}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.32\columnwidth}
\centering
\includegraphics[scale=0.09, trim={34cm 0cm 26cm 0cm},clip]{figures/rectangle/rect_sd_big.png}
\caption{Def. field norms}
\label{fig:rect_b}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.32\columnwidth}
\centering
\includegraphics[scale=0.09, trim={69cm 0cm 0cm 0cm},clip]{figures/rectangle/rect_sd_big.png}
\caption{High def. grasps}
\label{fig:rect_c}
\end{subfigure}
\caption{(ab) Low (top) and high-valued (bottom) prism grasps for max stress and max deformation ($E{=}2e4$); (c) High-valued grasps for max deformation for additional elastic moduli.
}
\label{fig:rect_sd}
\vspace{-18pt}
\end{figure}
\begin{figure}
\centering
\begin{subfigure}[b]{.38\columnwidth}
\centering
\includegraphics[scale=0.085, trim={0cm 1.5cm 68cm 0cm},clip]{figures/rectangle/rect_ci3.png}
\caption{Def. controllability}
\label{fig:rect_d}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.27\columnwidth}
\centering
\includegraphics[scale=0.09, trim={54cm 1.5cm 29cm 0cm},clip]{figures/rectangle/rect_ci3.png}
\caption{Lin. instability}
\label{fig:rect_e}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.27\columnwidth}
\centering
\includegraphics[scale=0.09, trim={88cm 1.5cm 0cm 0cm},clip]{figures/rectangle/rect_ci3.png}
\caption{Ang. stability}
\label{fig:rect_f}
\end{subfigure}
\caption{Low (top) and high-valued (bottom) grasps for (a) def. controllability, (b) linear instability, (c) angular instability on a prism ($E{=}2e4$). Controllability plots depict the union of all configurations under reorientation. Instability plots depict the vectors corresponding to the max, min, and median accelerations at failure.}
\label{fig:rect_ci}
\vspace{-16pt}
\end{figure}
For the cup, grasps with low values for maximum stress and deformation squeeze along its height, contacting its base and covering its opening (Fig.~\ref{fig:cup_sd}). In this configuration, the compressive stiffness of the cup is highest, reducing deformation and stress for a given applied force. Grasps with the highest maximum stress and deformation squeeze the sides of the cup near the lip. In this configuration, the cup has the lowest geometric stiffness, increasing deformation and stress. However, additional cases reveal further nuances of grasping cups. In particular, grasps that squeeze the cup on opposite sides of the base induce high stress due to small contact area, but low deformation due to high geometric stiffness (Fig.~\ref{fig:cup_sd}c).
For the ring and flask, grasps with the low values for maximum stress and deformation are top-bottom grasps; as with the cup, in this configuration, the compressive stiffness of these objects is highest, reducing these metrics (Fig.~\ref{fig:ring_grasps}ab and Fig.~\ref{fig:flask_grasps}a). On the other hand, grasps with high values for maximum stress and deformation are side grasps. In this configuration, the ring has the lowest geometric stiffness, allowing buckling and collapse, increasing both bending/compressive stress and deformation. For the flask, the high-stress grasps and high-deformation side grasps occur at slightly different locations. The high-stress grasps squeeze regions with high curvature and low contact area, increasing compressive stress (Fig.~\ref{fig:flask_grasps}a). As with the cup and ring, the high-deformation grasps squeeze in configurations with the lowest geometric stiffness (i.e., perpendicular to the flask face) (Fig.~\ref{fig:flask_grasps}b).
For the cylinder, grasps with low stress and deformation squeeze along the long axis. In this configuration, the gripper achieves the highest contact area and least thickness between its fingers, lowering compressive stress and deformation (Fig.~\ref{fig:cylinder_grasps}a-b). On the other hand, grasps with high stress and deformation pinch the ends or middle. The gripper has minimal contact area, increasing compressive stress, and bending deformations are minimally restricted, increasing deformation.
\begin{figure}
\centering
\begin{subfigure}[b]{.33\columnwidth}
\centering
\includegraphics[scale=0.09, trim={0cm 0cm 61.5cm 0cm},clip]{figures/ellipsoid/ellipsoid_grasps.png}
\caption{Max stress.}
\label{fig:spheroid_a}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.33\columnwidth}
\centering
\includegraphics[scale=0.09, trim={32cm 0cm 26.5cm 0cm},clip]{figures/ellipsoid/ellipsoid_grasps.png}
\caption{Max def.}
\label{fig:spheroid_b}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.30\columnwidth}
\centering
\includegraphics[scale=0.09, trim={65cm 0cm 0cm 0cm},clip]{figures/ellipsoid/ellipsoid_grasps_new_perspective.png}
\caption{Lin. instability.}
\label{fig:spheroid_c}
\end{subfigure}
\caption{Low (top) and high-valued (bottom) spheroid grasps ($E{=}2e4$).}
\label{fig:spheroid_grasps}
\end{figure}
\begin{figure}[t]
\centering
\begin{subfigure}[b]{.33\columnwidth}
\centering
\includegraphics[scale=0.09, trim={0cm 0cm 62cm 0cm},clip]{figures/cup/cup_a.png}
\caption{Max stress.}
\label{fig:cup_a}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.33\columnwidth}
\centering
\includegraphics[scale=0.09, trim={32cm 0cm 34cm 0cm},clip]{figures/cup/cup_a.png}
\caption{Max def.}
\label{fig:cup_b}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.30\columnwidth}
\centering
\includegraphics[scale=0.09, trim={64cm 0cm 0cm 0cm},clip]{figures/cup/cup_a.png}
\caption{}
\label{fig:cup_c}
\end{subfigure}
\caption{(ab) Low (top) and high-valued (bottom) cup grasps for stress and deformation metrics ($E{=}2e4$); (c) A grasp contacting just the base of the cup can induce high max stress but low max deformation.}
\label{fig:cup_sd}
\vspace{-18pt}
\end{figure}
\smallskip
\noindent\textbf{Controllability and Instability Metrics.} We now examine the deformation controllability and linear/angular instability results. For the prism, spheroid, and cylinder, grasps with the highest values for all three of these metrics tend to squeeze the ends of the object. (Fig.~\ref{fig:rect_ci}a-c, Fig.~\ref{fig:spheroid_grasps}c, and Fig.~\ref{fig:cylinder_grasps}c). Here, the gripper allows cantilever bending with a maximally long moment arm, maximizing deformation controllability (i.e., deformation under reorientation). In addition, the gripper is maximally close to losing contact with the object under displacement perturbation, increasing linear and angular instability. For the cylinder, these grasps also coincide with those for the highest values for maximum stress and deformation.
For the cup, grasps with low values for deformation controllability and linear and angular instability tend to make substantial contact with the object, particularly its base (Fig.~\ref{fig:cup_ci} top). In this configuration, the gripper constrains the degrees of freedom of the object, reducing controllability; furthermore, the gripper contacts locally stiff regions, enabling fast response to dynamic perturbations and reducing instability.
For the ring and flask, grasps with the highest values for deformation controllability and linear and angular instability have small amounts of material between the gripper fingers. In this configuration, the gripper exposes more degrees of freedom of the object, increasing deformation under reorientation and sensitivity to displacement perturbation. For example, for the flask, high-valued grasps squeeze along the shortest axis on areas with high curvature (not depicted). Conversely, grasps with the lowest deformation controllability and linear and angular instability have large amounts of material between the gripper fingers. In this configuration, the gripper restricts more degrees of freedom. For example, for the ring, low-valued grasps squeeze along the side of the ring towards the ring's central axis, leaving only a small surface uncontacted.
\begin{figure}
\centering
\begin{subfigure}[b]{.3\columnwidth}
\centering
\includegraphics[scale=0.09, trim={3cm 0cm 68cm 0cm},clip]{figures/cup/cup_b_updated.png}
\caption{Def. controllability.}
\label{fig:cup_d}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.33\columnwidth}
\centering
\includegraphics[scale=0.09, trim={30cm 0cm 34cm 0cm},clip]{figures/cup/cup_b_updated.png}
\caption{Lin. instability.}
\label{fig:cup_e}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.33\columnwidth}
\centering
\includegraphics[scale=0.09, trim={64cm 0cm 0cm 0cm},clip]{figures/cup/cup_b_updated.png}
\caption{Ang. instability.}
\label{fig:cup_f}
\end{subfigure}
\caption{Low (top) and high-valued (bottom) cup grasps for controllability and instability metrics ($E{=}2e4$).}
\label{fig:cup_ci}
\end{figure}
\begin{figure}
\centering
\begin{subfigure}[b]{.33\columnwidth}
\centering
\includegraphics[scale=0.09, trim={0cm 0cm 58cm 0cm},clip]{figures/ring/ring_grasps.png}
\caption{Max stress.}
\label{fig:ring_a}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.33\columnwidth}
\centering
\includegraphics[scale=0.09, trim={36cm 0cm 25cm 0cm},clip]{figures/ring/ring_grasps.png}
\caption{Max def.}
\label{fig:ring_b}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.30\columnwidth}
\centering
\includegraphics[scale=0.09, trim={69cm 0cm 0cm 0cm},clip]{figures/ring/ring_grasps.png}
\caption{Def. controllability.}
\label{fig:ring_c}
\end{subfigure}
\caption{Low (top) and high-valued (bottom) ring grasps ($E{=}2e4$).}
\label{fig:ring_grasps}
\vspace{-15pt}
\end{figure}
\subsection{Feature Importance and Predictive Power}
For each primitive with a specified elastic modulus ($E$), we evaluate 7 grasp features and 7 performance metrics for all grasps. We then examine the power of the features to predict the metrics. For each continuous-valued performance metric (i.e., all metrics except pickup success), we build a random forest classifier. The classifier takes as input the grasp features, and outputs whether the corresponding grasp belongs to the top or bottom 30th percentile of all grasps, ranked by their metric values; binary classification is performed because separating the two extremes reveals highly interpretable physical trends.
We use random forests for their ability to handle relatively small training sets, as well as their prior successes in predicting grasp outcomes~\cite{Rubert2017IROS}. The predictive power of each grasp feature is then quantified as its Gini impurity-based importance. For each performance metric, we initially trained separate classifiers for each $E$; however, the relative feature importances were qualitatively similar over all moduli. We thus combine grasp samples across all $E$ to train one model per metric and simply add $E$ as a feature.
\begin{figure*}
\centering
\includegraphics[scale=0.14, trim={0cm 0cm 0cm 0cm},clip]{figures/imps/full_importances.png}
\caption{Feature importance across performance metrics for each primitive. Hatched bars denote the most important feature for each metric; error bars (small) denote the standard error. }
\label{fig:imps}
\vspace{-18pt}
\end{figure*}
Fig.~\ref{fig:imps} depicts the feature importance of the resulting classification models; critically, the importance of each feature varies across the primitives and metrics. For the prism and spheroid, the $pure\_dist$ feature has the highest importance for all metrics. This aligns with our observation that for the grasps with the highest values for each performance metric, the gripper tends to squeeze the ends of the object. However, $perp\_dist$ is also an important feature for angular instability on the prism, and is the most important feature for this metric on the spheroid. Rotational perturbations are centered between the fingertips, and $perp\_dist$ directly captures the length of the moment arm.
Between the prism and spheroid, a key difference is that the pickup success rate for the spheroid drops dramatically from $90\%$ at $E{=}2e6$ to $12\%$ at $E=2e9$. The ring, cup, and cylinder also experience a drop in pickup success at high $E$. When these rounded objects are stiff, the gripper becomes unable to induce deformation and generate sufficient contact area upon squeezing; thus, grasps such as those in the bottom row of Fig.~\ref{fig:spheroid_grasps}c easily drive the object out of the gripper.
\begin{figure}
\centering
\begin{subfigure}[b]{.45\columnwidth}
\centering
\includegraphics[scale=0.085, trim={0cm 0cm 60.5cm 0cm},clip]{figures/flask/flask_compact.png}
\caption{Max stress.}
\label{fig:flask_a}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.45\columnwidth}
\centering
\includegraphics[scale=0.085, trim={63cm 0cm 0cm 0cm},clip]{figures/flask/flask_compact.png}
\caption{Max deformation.}
\label{fig:flask_b}
\end{subfigure}
\caption{Low (top) and high-valued (bottom) flask grasps ($E{=}2e5$).}
\label{fig:flask_grasps}
\vspace{-12pt}
\end{figure}
\begin{figure}
\centering
\begin{subfigure}[b]{.16\columnwidth}
\centering
\includegraphics[scale=0.088, trim={0cm 0cm 161cm 0cm},clip]{figures/cylinder/cylinder_all.png}
\caption{}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.16\columnwidth}
\centering
\includegraphics[scale=0.088, trim={42cm 0cm 118cm 0cm},clip]{figures/cylinder/cylinder_all.png}
\caption{}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.11\columnwidth}
\centering
\includegraphics[scale=0.088, trim={77cm 0cm 91cm 0cm},clip]{figures/cylinder/cylinder_all.png}
\caption{}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.23\columnwidth}
\centering
\includegraphics[scale=0.088, trim={111cm 0cm 46cm 0cm},clip]{figures/cylinder/cylinder_all.png}
\caption{}
\end{subfigure}
\begin{subfigure}[b]{.25\columnwidth}
\centering
\includegraphics[scale=0.088, trim={150cm 0cm 0cm 0cm},clip]{figures/cylinder/cylinder_all.png}
\caption{}
\end{subfigure}
\caption{Low (top) and high-valued (bottom) grasps for (a) stress, (b) def., (c) def. controllability, (d) lin. instability, (e) ang. instability on a cylinder ($E{=}2e4$).}
\label{fig:cylinder_grasps}
\vspace{-20pt}
\end{figure}
For the cup, $grav\_align$ has the highest importance for predicting maximum stress. This aligns with our observation that the grasps with the lowest maximum stress are all top-bottom grasps. In addition, $squeeze\_dist$ is most important for predicting maximum deformation. As the gripper squeezes the object, this feature directly characterizes the stiffness of the material between the fingers. In contrast to the prism and spheroid, $perp\_dist$ has substantially higher importance than $pure\_dist$ for predicting deformation controllability and instability. When the gripper squeezes the cup, $perp\_dist$ stably measure of the distance between the gripper and the opening of the cup, which is critical for controllability and stability. However, $pure\_dist$ changes substantially, regardless of how far the gripper is from the opening.
For the ring, $grav\_align$ feature has the highest importance for predicting all deformation-related metrics.
Although the deformations induced by side grasps on a cup vary based on height (i.e., side grasps at the base induce less deformation than at the opening), all side grasps on the ring induce high deformation.
Thus, the grasps with the lowest and highest values for deformation-related metrics are best distinguished by whether they are top-bottom or side grasps, and $grav\_align$ precisely captures this. In addition, $edge\_dist$ and $num\_contacts$ have high importance for predicting deformation controllability. This aligns with our observation that the amount of material squeezed by the gripper greatly influences controllability. This quantity depends on both $edge\_dist$ (distance between contact patch and gripper finger edge) and $num\_contacts$ (contact area). As with the cup, $perp\_dist$ is most important for predicting linear and angular instability.
For the flask, $gripper\_sep$ has the highest importance for predicting maximum stress. As with the ring, the grasps with the lowest and highest stress are distinguished by whether they are top-bottom or side grasps. In addition, as with the cup, $squeeze\_dist$ is most important for predicting deformation
Finally, $edge\_dist$ is dominant for predicting linear and angular instability. This feature quantifies the physical displacement required for the object to lose contact with the gripper.
For the cylinder, $edge\_dist$ has the highest importance for predicting maximum stress and deformation. On this geometry, this feature quantifies how strongly the grasp pinches the ends or middle of the object. In addition, $pure\_dist$ and $perp\_dist$ are highly correlated ($R$=0.99); all candidate grasps squeeze perpendicular to the long axis of the cylinder, resulting in negligible difference between the two features. These features are most important for predicting deformation controllability. They quantify the distance of the gripper to the ends of the object, determining the moment arm for bending.
\subsection{Fundamental Trends}
Based on our analysis of object primitives, we identify several fundamental trends. Stress is high for low gripper-object contact area or when inducing object buckling; deformation is high for low object geometric stiffness.
While stress and deformation are related, high-stress and high-deformation grasps can be dissimilar (e.g. Fig.~\ref{fig:cup_sd}\subref{fig:cup_c}). Instability and deformation controllability are maximized when the gripper contacts one end of the object, as the object can be displaced or exhibit gravity-induced deformation. Our importance analyses also consistently identify features that predict these metrics and agree with physical reasoning. Although elastic modulus impacts the set of successful grasps (e.g., failure for stiff versions of rounded objects), it does not substantially impact how grasps rank according to the metrics.
\section{Grasp Performance on Primitives} \label{primitives_shortened}
In \textbf{Appendix~\ref{primitives}}, we show grasping results for 6 of 9 object primitives (Fig.~\ref{fig:object_categories}) over a wide range of elastic moduli, and use physical reasoning to interpret the relationships between metrics and features. Example results of various metrics on a cup are visualized in Fig.~\ref{fig:cup_shortened}. An analysis of grasp feature importance in predicting these metrics is also performed.
\begin{figure}
\centering
\begin{subfigure}[b]{.32\columnwidth}
\centering
\includegraphics[scale=0.18, trim={0cm 0cm 44cm 0cm},clip]{figures/teasers/cup_shortened_3.png}
\caption{von Mises stresses}
\label{fig:cup_short_a}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.32\columnwidth}
\centering
\includegraphics[scale=0.18, trim={14cm 0cm 30cm 0cm},clip]{figures/teasers/cup_shortened_3.png}
\caption{Deformation norms}
\label{fig:cup_short_b}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.32\columnwidth}
\centering
\includegraphics[scale=0.18, trim={29cm 0cm 12cm 0cm},clip]{figures/teasers/cup_shortened_3.png}
\caption{Angular instability}
\label{fig:cup_short_c}
\end{subfigure}
\caption{Low (top) and high-valued (bottom) grasps for various metrics on a cup.}
\label{fig:cup_shortened}
\vspace{-16pt}
\end{figure}
\section{Sim-to-Real Accuracy}
We compare simulated and real-world grasp responses, and demonstrate that grasps performed on simulated blocks of tofu and latex tubing induce highly analogous responses on their real-world counterparts. All material parameters in simulation are acquired from reported values of common materials, and \textit{are not tuned to match the real outcomes}. Example correspondences are shown in Fig.~\ref{fig:hollow_tube_grasps_shortened}, with details in \textbf{Appendix~\ref{app:sim2real}}.
\begin{figure}[t]
\centering
\includegraphics[width=0.845\linewidth, trim={0cm 0cm 0cm 0cm},clip]{figures/teasers/sim2real_shortened.png}
\caption{Examples of 3 different grasps on a real and simulated block of tofu (top 2 rows), and 3 different grasps on a real and simulated latex tube (bottom 2 rows).}
\label{fig:hollow_tube_grasps_shortened}
\end{figure}
\section{Experimental Simulation Details}\label{appendix_experiment}
For completeness and the ability to replicate our work we now explain additional details and settings used in our simulation-based experiments. We visualize the tests in Figure~\ref{fig:grasp_tests}.
Each object initially rests atop a horizontal plane; gripper collisions with the plane are disabled, as we want to test the full spatial distribution of grasps by allowing grasps to come from underneath regardless of collisions that would occur in the real world.
Prior to grasping, the pre-contact nodal positions and element stresses of the object are recorded. The gripper is then initialized at a candidate grasp pose. The gripper squeezes using a force-based torque controller to achieve $F_p$, with a low-pass filter applied to contact forces to mitigate numerical fluctuations. Once $F_p$ converges, the grasp features are measured. Then, one of the tests listed in Section~\ref{sec:sim-experiments} is executed depending on the performance metric to be evaluated.
\noindent\textbf{Pickup}. The platform is lowered to apply incremental gravitational loading to the object. Pickup is a success if the gripper maintains contact with the object for 5 seconds. If so, stress and deformation fields are recorded, and stress, deformation, and strain energy performance metrics are computed.
\noindent\textbf{Reorientation}. The gripper squeezing force is increased from $F_{p}$ to $F_{slip}$, the minimum force required to counteract rotational slip. The platform is lowered until the object is picked up. The gripper rotates the object to 64 unique reorientation states.
Stress and deformation fields are recorded at each state, and deformation controllability is computed as the maximum deformation over all states. $F_{slip}$ is estimated by approximating each gripper contact patch as 2 point-contacts that oppose the gravitational moment. The gripper rotates the object about each of 16 vectors regularly spaced in a unit 2-sphere at angles $k\pi/4, k \in [1..4]$ for a total of 64 unique reorientation states.
\noindent\textbf{Linear acceleration}.
The gripper linearly accelerates along the 16 unique direction vectors as in the reorientation test. Each vector has a complement pointing in the opposite direction; thus, this method generalizes the cyclic shaking tests from previous works~\cite{EppnerISRR2019}. The acceleration is recorded at which at least one finger loses contact with the object. Linear instability is computed as the average loss-of-contact acceleration over all directions. The robot moves at at $1000 \frac{m}{s}^3$ jerk in a gravity-free environment, corresponding to a linearly increasing acceleration. We impose a realistic upper acceleration limit of $50 \frac{m}{s}^2$ ($\approx 5g$).
\noindent\textbf{Angular acceleration}. The gripper now rotationally accelerates about 16 unique axes. Angular instability is computed as the average loss-of-contact acceleration over all axes. The robot accelerates at $2500 \frac{rad}{s}^3$ jerk; to mitigate undesired linear acceleration, the midpoint between the fingers is set as the center of rotation. The angular loss-of-contact threshold is limited at $1000 \frac{rad}{s}^2$ (i.e., the linear acceleration limit, scaled by the $0.04 m$ maximum finger displacement, which approximates the moment arm).
\begin{figure*}[h]
\centering
\includegraphics[scale=0.4]{figures/grasp_tests.png}
\caption{Example frames from the execution of four different tests per grasp on a banana: pickup, reorient, twist (angular acceleration), and shake (linear acceleration).}
\label{fig:grasp_tests}
\end{figure*}
\noindent\textbf{Controller Details.} A contact force-based torque controller is used to achieve the desired squeezing forces during grasping. A low-pass filter is first applied to the contact force signals due to high frequency noise that prevails from small numerical fluctuations in position, especially at higher moduli. For the three tests involving post-pickup manipulation, the finger joints are frozen immediately after pickup to maintain the gripper separation.
\section{Finite Element Simulation Details}\label{appendix_sim}
FEM is a variational numerical technique that divides complex geometrical domains into simple subregions and solves the weak form of the governing partial differential equations over each region.
In FEM simulation, a deformable object is represented by a volumetric mesh of \textit{elements}; the object's configuration is described by the element vertices, known as \textit{nodes}. We use Isaac Gym's\cite{isaacgym} co-rotational linear constitutive model of the object's internal dynamics coupled to a rigid-body representation of the robotic gripper via an isotropic Coulomb contact model~\cite{stewart2000rigid}. A GPU-based Newton method performs implicit integration by solving a nonlinear complementarity problem~\cite{macklin2019}. Unlike classical analytical models, this technique explicitly models complex object and gripper geometry, deformation and dynamics, as well as large kinematic and kinetic perturbations.
At each timestep, the simulator returns element stress tensors and nodal positions, which are used to calculate grasp metrics. With sufficiently small timesteps and high mesh density, FEM predictions for deformable solids can be extremely accurate \cite{Reddy2019Book, Narang2020RSS}. We simulate at the high frequency of $1500 Hz$ resulting in experiments running at 5-10 frames per second. In total, the dataset for this paper required approximately 1400 GPU hours to generate.
We evaluate a set of 23 3D deformable objects comprising both simple object primitives and complex real-world models, categorized by geometry and dimension (Fig. \ref{fig:object_categories}). We process object surface meshes in Blender to smooth sharp edges and reduce node count, then convert them into tetrahedral meshes using fTetWild \cite{ftw}. All objects have homogeneous material properties due to current limitations of Isaac Gym.
Objects have density $\rho = 1000 \frac{kg}{m^3}$, Poisson's ratio $\nu = 0.3$, coefficient of friction $\mu = 0.7$, and Young's modulus $E \in \mathcal{E} = \{2e4, 2e5, 2e6, 2e9\} Pa$. $\mathcal{E}$ covers a wide range of real materials, from human skin ($\sim$$10^4 Pa$) to ABS plastic ($\sim$$10^9 Pa$). Values below $\sim$$10^3 Pa$ are excluded due to increased interpenetration effects, as are values above $\sim$$10^9 Pa$ due to no substantial differences arising.
The desired squeezing force on an object is $F_{p} = 1.3 \times \frac{mg}{\mu}$ (where $m$ is mass and $g$ is gravity), the frictional force required to support the object's weight with a factor of safety. For a fixed $E$, increasing $\mu$ decreases $F_p$ as well as the induced deformation. This effect is essentially the same as if $\mu$ is fixed while $E$ is increased, since an elastically stiffer object will also deform less for the same $F_p$ applied. Thus, we fix $\mu$ and vary $E$.
\section{Grasp Feature Details}
\label{app:grasp_features}
The 7 grasp features are recorded after applying the grasping force $F_p$, but before pickup. They can all be measured by common sensors (e.g., encoders, cameras, and tactile arrays). They are summarized in Table~\ref{tab:1}, along with examples of references to existing works from which they are derived. Please refer to \cite{Roa2014AR} for a full review of grasp features on rigid objects.
\begin{table*}[t]
\centering
\begin{tabular}{|p{4cm}|p{1.5cm}|p{7cm}|p{2cm}|}
\hline
Feature & Abbreviation & What it quantifies & Usage in existing literature \\
\hline
Contact patch distance to centroid
& \textit{pure\_dist}
& Distance from the center of each finger's contact patch to the object's center of mass (COM) (Fig. \ref{fig:qm}\subref{fig:qm1}), averaged over the two fingers.
& \cite{Rubert2017IROS, DingITRA2001} \\
\hline
Contact patch perpendicular distance to centroid
& \textit{perp\_dist}
& Perpendicular distance from the center of each finger's contact patch to the object's COM (Fig. \ref{fig:qm}\subref{fig:qm1}), averaged over the two fingers; quantifies distance from lines of action of squeezing force.
& \cite{BalasubramanianICRA2010} \\
\hline
Number of contact points
& \textit{num\_contacts}
& Number of contact points on each finger, averaged over the fingers; quantifies amount of contact made.
& \cite{Rubert2017IROS, DingITRA2001} \\
\hline
Contact patch distance to finger edge
& \textit{edge\_dist}
& Distance from each finger's distal edge to the center of its contact patch (Fig. \ref{fig:qm}\subref{fig:qm2}), averaged over the two fingers.
& \cite{Feix2016ITHMS} \\
\hline
Gripper squeezing distance
& \textit{squeeze\_dist}
& Change in finger separation from initial contact to the point at which $F_p$ is achieved; quantifies local deformation applied to the object.
& \cite{Xu2020ICRA} \\
\hline
Gripper separation
& \textit{gripper\_sep}
& Finger separation upon achieving $F_p$; quantifies the thickness of material between the fingers at grasp.
& \cite{Rubert2017IROS} \\
\hline
Alignment with gravity
& \textit{grav\_align}
& Angle between the finger normal and the global vertical; grounds the grasp pose to a fixed frame (Fig. \ref{fig:qm}\subref{fig:qm2}).
& \cite{Vina2016ICRA} \\
\hline
\end{tabular}
\caption{Grasp features, their descriptions, and existing works from which they are derived.}
\label{tab:1}
\end{table*}
\begin{figure}[t]
\centering
\begin{subfigure}[b]{.31\columnwidth}
\centering
\includegraphics[scale=0.2, trim={0cm 4cm 15cm 5.5cm},clip]{figures/qm_sketch.png}
\caption{}
\label{fig:qm1}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.31\columnwidth}
\centering
\includegraphics[scale=0.2, trim={20cm 4cm 3.5cm 5cm},clip]{figures/qm_sketch_grav_align.png}
\caption{}
\label{fig:qm2}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.31\columnwidth}
\centering
\includegraphics[scale=0.1, trim={2.5cm 1.5cm 4.5cm 1.5cm},clip]{figures/skeleton.png}
\caption{}
\label{fig:skeleton}
\end{subfigure}
\caption{(ab) Four grasp features illustrated on a Franka gripper; (c) Line representation of gripper pose, used in later sections.
}
\label{fig:qm}
\vspace{-18pt}
\end{figure}
\section{Performance Metric Details}
\label{app:performance_metrics}
\noindent\textbf{Pickup success:} A binary metric measuring whether an object is lifted from a support plane.
\noindent\textbf{Stress:} The element-wise stress field of an object when picked up. Exceeding material thresholds (e.g., yield stress, ultimate stress) leads to permanent deformation, damage, or fracture; examples include creasing of boxes, bruising of fruit,
and perforation of organs.
We convert each element's stress tensor into von Mises stress, a scalar quantity that quantifies whether an element has exceeded its yield threshold. We then measure the maximum stress over all elements, since real-world applications typically aim to avoid damage at any point.
\noindent\textbf{Deformation:} The node-wise displacement field of the object from pre- to post-pickup, neglecting rigid-body transformations. Deformation must often be minimized (e.g., on flexible containers with contents that can be damaged or dislodged). To compute this field, the difference between the pre- and post-pickup nodal positions is calculated, the closest rigid transform is determined \cite{hornung2017}, and the transform is subtracted. We compute the $\ell^2$ norm of each node's displacement and measure the maximum value over all nodes.
\noindent\textbf{Strain energy:} The elastic potential energy stored in the object (analogous to a Hookean spring). Conveniently, this metric penalizes both stress and deformation. The strain energy is given by $U_e = \int_V \sigma^T \epsilon dV$, where $\sigma$, $\epsilon$, and $V$ are the stress tensor, strain tensor, and volume, respectively.
\noindent\textbf{Linear and angular instability:} We define instability as the minimum acceleration applied to the gripper (\textit{along} or \textit{about} a vector for linear and angular instability, respectively) at which the object loses contact (i.e., separates along the gripper normal, or slides out of the gripper). This measures how easily an object is displaced from the grasp under external forces.
\noindent\textbf{Deformation controllability:} We define deformation controllability as the maximum deformation when the object is reoriented under gravity (e.g., an illustration of an example object's shape changes induced during reorientation under gravity is pictured in Fig.~\ref{fig:def_banana}). Depending on the task, it may be useful to either minimize or maximize deformation controllability. For example, to reduce the effects of post-grasp reorientation on deformation, minimizing this metric allows the object to behave rigidly after pickup. Alternatively, to augment the effects of post-grasp reorientation (e.g., during insertion of endoscopes), we may maximize it instead.
Our notion of deformation controllability is different from the classical notion (i.e., the ability to achieve any robot state in finite time). Here, we are not modifying robot controllability by changing actuation, but modifying object controllability by changing the number of possible deformation states.
\begin{figure}
\centering
\includegraphics[scale=0.09]{figures/banana/banana.png}
\caption{Illustration of deformation controllability. (Left) A banana under pickup; (Right) The union of all banana configurations achieved under reorientation, superimposed in light blue.
}
\label{fig:def_banana}
\vspace{-18pt}
\end{figure}
\section{Related Work}\label{app:related_works}
\noindent\textbf{Modeling techniques}. With over three decades of development, methods in rigid-object grasp planning range from model-based approaches using exact geometries \cite{Sastry1988IJRA,Ferrari1992ICRA,Miller2003ICRA} to data-driven approaches without full models \cite{Lenz2013IJRR,Dang2012a,Mahler2017CORR,Kopicki2016,mousavian2019,lu-ram2020-grasp-inference}. Rigid-body grasping simulators such as GraspIt!~\cite{Miller2004RAM} and OpenGRASP~\cite{Len2010OpenGRASP} have been used to develop many of these algorithms. Libraries like Bullet~\cite{coumans2019} and MuJoCo~\cite{Todorov2012IROS} can also model deformable ropes and cloths using rigid-body networks with compliant constraints. Such simulators have enabled real-world success in rope tying \cite{Lee2014IROS}, string insertion \cite{Wang2015ICRA}, cloth folding \cite{Maitin-Shepard2010ICRA,Li2015IROS}, and dressing \cite{Koganti2015IROS,Clegg2020RAL}. For 3D deformable objects, rigid-body approximations can lead to efficient simulations \cite{pozziefficient}; however, continuum models are preferred, as they can represent large deformations and allow consistent material parameters without an explicit model-fitting stage \cite{duriez.13}. 3D continuum models include Kelvin-Voigt elements governed by nonlinear PDEs~\cite{Howard2000AR}, mass-spring models~\cite{Lazher2014ICR}, 2D FEM for planar and ring-like objects~\cite{Jia2014IJRR}, and gold-standard 3D FEM~\cite{Lin2015IJRR}. However, many powerful FEM simulators used in engineering and graphics (e.g., Vega~\cite{Vega}) do not feature infrastructure for robotic control, such as built-in joint control.
For comprehensive reviews of 3D deformable modeling techniques, please refer to \cite{Arriola2020FRAI, YinScienceRobotics2021}.
\noindent\textbf{Performance metrics}. Prior works have evaluated 3D deformable-object grasps using performance metrics based on pickup success, strain energy, deformation, and stress.
Success-based metrics include the minimal squeezing force required by a particular grasp, which can be calculated via real-world iterative search~\cite{Howard2000AR} and FEM~\cite{Lazher2014ICR,Lin2015IJRR}. Success is dependent on both object geometry and stiffness (e.g., a cone can be picked up only when soft enough to deform to the gripper) \cite{Lin2015IJRR}. Metrics based on strain energy (i.e., elastic potential energy stored in the object) have served as proxies for an object's stability against external wrenches. In 2D the \textit{deform} closure metric generalizes rigid form closure \cite{Bicchi1995IJRR} and quantifies the positive work required to release an object from a grasp \cite{Goldberg2005IJRR}. It is optimized by maximizing strain energy without inducing plastic deformation. Similarly, for thin and planar 2.5D objects, grasps have been selected to maximize strain energy under a fixed squeezing distance~\cite{Jia2014IJRR}. Deformation-based metrics have also been proposed for cups and bottles to detect whether contents are dislodged during lifting and rotation \cite{Xu2020ICRA}. Finally, stress-based metrics have been proposed to avoid material fracture, but were evaluated only on rigid objects \cite{Pan2020ICRA}.
\noindent\textbf{Grasp features}. Many grasp features to predict grasp performance have been previously investigated on rigid objects. Features include force and form closure \cite{Ferrari1992ICRA} and grasp polygon area \cite{Mirtich1994ICRA}, and their predictive accuracy has been tested under different classification models \cite{Rubert2017IROS}. A thorough survey in rigid grasping features can be found in \cite{Roa2014AR}. However, grasp features for deformable objects have only been explored in one study, which measured the work performed on containers during grasping to predict whether its liquid contents would be displaced \cite{Xu2020ICRA}.
\section{Sim-to-Real Accuracy}\label{app:sim2real}
\begin{figure}
\centering
\includegraphics[scale=0.12, trim={0cm 0cm 0cm 0cm},clip]{figures/unseen_objects/tofu/tofu_grasps.png}
\caption{Three grasps tested on blocks of tofu (1 and 2~N of squeezing force) show similar outcomes in simulation and the real world.}
\label{fig:tofu_grasps}
\vspace{-6pt}
\end{figure}
If our simulations prove to be accurate to the real-world, we can proceed with confidence in applying simulation-generated grasp strategies to reality. We test 3 grasps on real blocks of tofu under 1 and 2~N of applied force~(see~Fig.~\ref{fig:tofu_grasps}). Simulated and real-world deformations exhibit strong similarities, and grasps achieve anticipated performance (e.g., grasps~A and~C, respectively, minimize and maximize sagging under the 2 force conditions). In the real world, permanent damage on the tofu occurs under 2~N of applied force, with fracture occurring in grasps~B and~C. Although fracture cannot be simulated with FEM, simulated stresses for these grasps lie within the literature-reported range of breaking stress for tofu~\cite{Toda2003SeedPC}; furthermore, fracture lines on the real tofu coincide with regions of high simulated stress.
Next, we perform 3 grasps on 2 latex tubes of different geometry (Fig.~\ref{fig:hollow_tube_grasps}). Again, simulated and real-world deformations are highly similar (including indentations and bulges localized to the contact locations); moreover, the vertical distance between the highest and lowest points of the tubes closely match. In simulation, deformation controllability is predicted to be higher in grasp F than grasp D (Fig.~\ref{fig:cylinder_grasps}c). Upon reorienting the rubber tubes in the real world, grasp F indeed enables a sequence of higher maximum deformations than grasp D, which constrains the tube to closely follow the motion of the gripper (thus, sweeping out a larger angle).
\begin{figure}
\centering
\includegraphics[scale=0.3, trim={0cm 0cm 0cm 0cm},clip]{figures/unseen_objects/tubes/tube_grasp.png}
\caption{Three grasps tested on 2 real and simulated latex tubes under 15 N of gripper force. The vertical distance between the highest and lowest points of the tube are shown alongside each image. (See Grasp F, bottom row for an example.) Localized deformation due to compression at the grippers is also replicated in simulation.}
\label{fig:hollow_tube_grasps}
\end{figure}
\begin{figure}
\centering
\includegraphics[scale=0.4, trim={0cm 0cm 0cm 0cm},clip]{figures/unseen_objects/tubes/tube_reorient.png}
\caption{Two tube grasps under a 90-degree rotation of the gripper: (left) an end grasp, and (right) a middle grasp. The angle swept out by the tip of the tube is marked on both images; the arrow denotes the counterclockwise direction of rotation.}
\label{fig:tube_reorient}
\end{figure}
\section{Application to Unseen Objects (OLD)}
\vspace{-3pt}
We first test whether the classifiers trained in Section~\ref{primitives} immediately generalize by applying them to candidate grasps on unseen real-world objects (gray objects in Fig.~\ref{fig:object_categories}). Performance was limited due to overfitting caused by the small number of primitives and grasps used in training.
We thus reduce the dimensionality by using \textit{one} grasp feature instead of seven, which is suitable when there is only one dominantly informative feature.
For each pair of primitive and performance metric, we identify the most important feature according to the results in Fig.~\ref{fig:imps} (e.g., for cylinder primitives and the maximum stress metric, $edge\_dist$ is most important). Whenever this important feature is \textit{correlated} with the performance metric, we assume that this feature-metric pair is \textit{also correlated} on unseen objects geometrically similar to the associated primitive, where object similarities are informed by whether they belong to the same category in Fig.~\ref{fig:object_categories}. For example, if $edge\_dist$ and maximum stress are correlated among grasps on a cylinder, we hypothesize that they will also be correlated among grasps on a banana, which is cylinder-like. We then rank the grasps according to the value of the grasp feature and use this ordering as a direct prediction of the rank of the grasps according to the value of the performance metric. Using this method, we predict the 5 grasps that will yield the highest metric values, and we define a prediction as \textit{accurate} if it belongs to the set of grasps that actually yield the top 15 metric values (i.e., the top 30th percentile for 50 total grasps). The same method is used to predict the 5 grasps that yield the lowest metric values. We now highlight some successful examples of this approach on unseen objects. In the following figures, the line representation of the gripper pose will be used (see Fig. \ref{fig:qm}\subref{fig:skeleton}).
\vspace{-8pt}
\subsection{Predicting Maximum Stress on Spheroid-like Objects}
On the spheroid primitives, $pure\_dist$ is most important for classifying maximum stress ($R{=}0.84$) (Fig.~\ref{fig:imps}b). This correlation generalizes to other spheroid-like objects like a lemon, apple, and peach ($R{=}0.72, 0.72, 0.68$). We demonstrate prediction on a heart due to its asymmetry and surgical significance. Of the 10 predictions, 9 are accurate (Fig.~\ref{fig:heart_5}).
We visualize the stress distribution of the one grasp incorrectly predicted to be low-stress in Fig.~\ref{fig:heart_examples}b. As depicted, the gripper finger contacts small protrusions on the heart that reduce contact area and increase the maximum stress. These local protrusions are not captured by the $pure\_dist$ feature, as it does not quantify contact patch shape. This suggests that other features such as $num\_contacts$ should also be considered.
\begin{figure}
\captionsetup{width=0.45\columnwidth}
\centering
\begin{minipage}{.5\columnwidth}
\centering
\begin{subfigure}[b]{.4\columnwidth}
\centering
\includegraphics[scale=0.12, trim={22cm 18cm 26cm 12cm},clip]{real_objects/heart_predicted.png}
\caption{Predicted.}
\end{subfigure}
\begin{subfigure}[b]{.4\columnwidth}
\centering
\includegraphics[scale=0.12, trim={22cm 18cm 27cm 12cm},clip]{real_objects/heart_actual.png}
\caption{Actual.}
\end{subfigure}
\caption{Lowest (green) and highest-valued (orange) five heart grasps for max stress.}
\label{fig:heart_5}
\end{minipage}%
\begin{minipage}{.5\columnwidth}
\begin{subfigure}[b]{.38\columnwidth}
\centering
\includegraphics[scale=0.09, trim={2cm 0cm 7.5cm 0cm},clip]{real_objects/heart_low_example2.png}
\caption{Accurate.}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.47\columnwidth}
\centering
\includegraphics[scale=0.09]{real_objects/heart_real.png}
\caption{Inaccurate.}
\end{subfigure}
\caption{Examples of predicted low stress grasps.}
\label{fig:heart_examples}
\end{minipage}
\vspace{-18pt}
\end{figure}
\vspace{-6pt}
\subsection{Predicting Max Deformation on Container-like Objects}
On the cup and flask, $squeeze\_dist$ is correlated with maximum deformation ($R{=}0.89$ for cup, $R{=}0.93$ for flask). This generalizes to a tall cup, a mug, a mustard bottle, and a bleach bottle ($R{=}0.89, 0.84, 0.77, 0.76$), on which all 40 predicted grasps are accurate (Fig.~\ref{fig:containers}). On the tall cup, the predicted lowest-valued grasps (i.e., for maximum deformation) are concentrated at the base, and the predicted highest-valued grasps are concentrated at the lip (Fig. \ref{fig:containers}a). On the mug, the lowest-valued grasps are those that are top-bottom grasps since its height fits within the gripper opening, unlike with the tall cup. The highest-valued grasps all contact the handle of the mug, which buckles severely when squeezed (Fig. \ref{fig:containers}b). On the bottles, low-valued grasps mostly squeeze at the base where local stiffness is higher, and high-valued grasps squeeze the bottle faces, inducing maximal buckling (Fig. \ref{fig:containers}cd).
\begin{figure}
\centering
\begin{subfigure}[b]{.24\columnwidth}
\centering
\includegraphics[scale=0.17, trim={0cm 0cm 33.5cm 0cm},clip]{real_objects/containers.png}
\caption{Tall cup.}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.24\columnwidth}
\centering
\includegraphics[scale=0.17, trim={11cm 0cm 21cm 0cm},clip]{real_objects/containers.png}
\caption{Mug.}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.24\columnwidth}
\centering
\includegraphics[scale=0.17, trim={24cm 0cm 11cm 0cm},clip]{real_objects/containers.png}
\caption{Mustard bottle.}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.24\columnwidth}
\centering
\includegraphics[scale=0.17, trim={34cm 0cm 0cm 0cm},clip]{real_objects/containers.png}
\caption{Bleach bottle.}
\end{subfigure}
\caption{Predicted lowest (green) and highest-valued (orange) five grasps on containers for maximum deformation.}
\label{fig:containers}
\vspace{-15pt}
\end{figure}
| {'timestamp': '2021-07-14T02:06:44', 'yymm': '2107', 'arxiv_id': '2107.05778', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05778'} | arxiv |
\section{Introduction}
With the increasing performance and applicability of machine learning algorithms, and in particular of deep learning, the safety of such methods became more relevant than ever. There has been growing concern over the course of the last few years regarding adversarial attacks, i.e., algorithms which are able to fool machine learning models with minimal input perturbations, as they were shown to be very effective.
Ideally, theoretical robustness bounds should be obtained in the case of critical software involving image classification components. There has been important recent research in this direction \cite{gopinath2018deepsafe,huang2017safety,dvijotham2018dual,ruan2018reachability}, but most often the algorithms generating these bounds work for limited classes of models, do not scale well with larger neural networks, and require complete knowledge of the target model's internals. Therefore, complementary empirical robustness evaluations are required for a better understanding of how robust the image classifiers are. In order to achieve this, one has to come up with effective adversarial attacks that resemble real-life conditions, such as in the black-box query-limited scenario.
In general, adversarial attacks are classified as either white-box or black-box. White-box adversarial attacks, where the attacker has complete knowledge of the target model, were shown to be particularly successful, most of them using gradient-based methods \cite{szegedy2013intriguing,goodfellow2015explaining,athalye2018obfuscated}. In the case of black-box adversarial attacks, the attacker can only query the model, and has no access to the model internals and to the data used for training. These restrictions make the black-box adversarial setup resemble more real-life scenarios. Furthermore, the attacker usually has to minimise the number of queries to the model, either due to time or monetary constraints (such as in the case of some vision API calls).
Previous state-of-the-art black-box adversarial attacks focused on exploiting the transferability phenomenon, which allowed the attackers to train substitute models imitating the target one, and perform white-box attacks on these \cite{papernot2016transferability,papernot2016limitations}. More recently, a class of black-box adversarial attacks, called Zeroth Order Optimization ($\textbf{ZOO}$) \cite{chen2017zoo}, has gained momentum, providing one of the current state-of-the art attacks, $\textbf{AutoZOOM}$ (\cite{tu2019autozoom}). Interestingly, a much simpler algorithm, $\textbf{SimBA}$ (Simple Black-box Attack) \cite{guo2019simple}, achieves a similar, slightly lower success rate than state-of-the-art attacks, including $\textbf{AutoZOOM}$, and requires a lower number of queries. Therefore, $\textbf{SimBA}$ is proposed to be used as a default baseline for any adversarial attack, but it is itself an unexpectedly powerful algorithm.
We propose $\textbf{EvoBA}$, an untargeted black-box adversarial attack that makes use of a simple evolutionary search strategy. $\textbf{EvoBA}$ only requires access to the output probabilities of the target model for a given input and needs no extra training. $\textbf{EvoBA}$ is more query-efficient than $\textbf{SimBA}$ and $\textbf{AutoZOOM}$, and has a perfect success rate, surpassing $\textbf{SimBA}$ and being aligned with $\textbf{AutoZOOM}$ from this point of view. We designed $\textbf{EvoBA}$ to minimize the $L_0$ adversarial perturbation, however we also report the $L_2$ norms of the perturbations it generates and compare them with the $L_2$ norms of $\textbf{AutoZOOM}$ and $\textbf{SimBA}$, which are $L_2$ adversarial attacks. Despite our algorithm aiming to minimize a different metric than these methods, we achieve similar $L_2$ norms in the perturbations we generate, and a significantly better $L_0$.
$\textbf{EvoBA}$ is a model-agnostic empirical tool that can be used as a test to assess how robust image classifier systems are with respect to $L_0$ noise. Therefore, $\textbf{EvoBA}$ is both a simple and strong baseline for black-box adversarial attacks, but also a generic $L_0$ robustness evaluation method that can be used in a fast and reliable way with any system involving image classification.
While $L_2$ (Euclidean distance) and $L_{\infty}$ (maximum absolute pixel-wise distance) adversarial attacks are more commonly studied, $L_0$ (count of modified pixels distance) adversarial attacks can fit better real-life, physical settings, such as in the well-known cases of graffiti perturbations on stop-signs from \cite{eykholt2018robust} and of adversarial eyeglass frames from \cite{sharif2016accessorize}. As \cite{bafna2018thwarting} notes, \say{physical
obstructions in images or malicious splicing of audio or video files are realistic threats that can be
modeled as $L_0$ noise, whereas $L_2$ attacks may be more difficult to carry out in the physical world}.
The main property of adversarially perturbed images is that they are very close from a human point of view to the original benign image, but trick the model into predicting the wrong class. While the notion of \say{closeness from a human perspective} is hard to quantify, there exists general consensus around using the $L_0, L_2, \text{ and } L_{\infty}$ norms as proxies for measuring the adversarial perturbations \cite{wiyatno2019adversarial,papernot2016limitations,papernot2016transferability,guo2019simple,zhang2020deepsearch}.
$\textbf{EvoBA}$ focuses on the $L_0$ norm, is fast, query-efficient, and effective. Therefore, we propose using it together with similarly fast and efficient methods that focus on different norms, such as $\textbf{SimBA}$, which focuses on $L_2$, and $\textbf{DeepSearch}$ (\cite{zhang2020deepsearch}), which focuses on $L_{\infty}$, to empirically evaluate the robustness of image classifiers. These methods can act together as a fast and general toolbox used along the way of developing systems involving image classification models. $\textbf{EvoBA}$ can easily be incorporated in development pipelines for gaining fast insights into a model's $L_0$ empirical robustness, only requiring access to the classifier's prediction method and to a sample of target images together with their corresponding labels.
Moreover, many adversarial training methods focus on improving the robustness with respect to $L_0, L_2, \text{ and } L_{\infty}$ perturbations \cite{sharif2018suitability}. Therefore, it is important to be able to empirically evaluate how much the robustness of target models improve due to adversarial training with respect to these norms. A toolbox consisting of efficient and reliable attacks such as $\textbf{EvoBA}$, $\textbf{DeepSearch}$, and $\textbf{SimBA}$ can serve this purpose.
$\textbf{EvoBA}$ is most surprising through its dual nature, acting both as a strong and fast black-box adversarial attack, such as $\textbf{SimBA}$, but also achieving results which are in line with much more complex, state-of-the art black-box attacks, such as $\textbf{AutoZOOM}$.
To wrap it up, we propose $\textbf{EvoBA}$ as a standard strong baseline for any black-box adversarial attack and as a tool that can provide empirical insight into how robust image classifiers are. Its main advantages are that it is as effective as state-of-the-art black-box attacks, such as $\textbf{AutoZOOM}$, and more query-efficient. While it is an $L_0$ adversarial attack, it achieves $L_2$ perturbations of similar magnitudes with state-of-the-art $L_2$ black-box attacks and requires no training. Furthermore, $\textbf{EvoBA}$ is highly parallelisable, which allows it to run significantly faster than $\textbf{SimBA}$, the other powerful baseline black-box attack.
$\textbf{Our contributions}$:
\begin{itemize}
\item We propose $\textbf{EvoBA}$, a fast, query-efficient, and effective black-box $L_0$ adversarial attack, which can be used as a generic test for assessing the $L_0$ robustness of image classifiers.
\item We show how $\textbf{EvoBA}$ compares favourably to the state-of-the art black-box $L_2$ attack $\textbf{AutoZOOM}$, while being significantly simpler.
\item We show how $\textbf{EvoBA}$ (an $L_0$ attack) serves a similar purpose to the other strong and simple baselines such as $\textbf{SimBA}$ (an $L_2$ attack) and $\textbf{DeepSearch}$ (an $L_{\infty}$ attack). These methods are suitable to be run together, as part of a robustness testing toolbox, while developing any image classification model.
\end{itemize}
$\textbf{Paper outline}$:
\begin{itemize}
\item In Section \ref{sect:related_work} we do a quick literature review around related work and position $\textbf{EvoBA}$ with respect to the presented methods.
\item In Section \ref{sect:the_method} we introduce $\textbf{EvoBA}$ together with the threat model we use. We provide pseudocode for $\textbf{EvoBA}$ and explain the main ideas behind it. We also analyze its space and time complexities.
\item In Section \ref{sect:experiments} we present our experimental methodology and setup, provide and analyse the quantitative results of $\textbf{EvoBA}$ in comparison with other methods, and present some qualitative results.
\item In Section \ref{sect:concl} we wrap-up the main findings and propose future research directions for our work.
\end{itemize}
\section{Related Work}\label{sect:related_work}
While the black-box adversarial attack settings are far more restrictive than the white-box ones, their similarity to real-life scenarios has increasingly brought them into the spotlight of machine learning safety.
One general approach for black-box attacks exploits the transferability property of adversarial examples \cite{papernot2016transferability,papernot2016limitations}. The attacker can train their own substitute model and perform white-box attacks on it, which usually yield good adversarial samples for the target model as well. However, \cite{su2018robustness} showed the limitations of this method, highlighting how not all white-box attacks and not all architectures transfer well.
A class of approaches that do not rely on transferability is based on Zeroth Order Optimization (ZOO), which tries to estimate the gradients of the target neural network in order to generate adversarial examples. One of the early algorithms in this direction, $\textbf{ZOO}$ \cite{chen2017zoo} managed to reach similar success rates with state-of-the-art white-box attacks, producing adversarial samples of comparable visual quality. In general, Zeroth Order Optimization refers to any functional optimization where gradients are not available, so the term has commonly been adapted in the field of black-box adversarial attacks as a general category of methods that estimate the gradients.
The main disadvantage of traditional ZOO-type attacks is that they usually require plenty of queries for approximating the coordinate-wise gradients. $\textbf{AutoZOOM}$ \cite{tu2019autozoom} solved this issue by performing a dimensionality reduction on top of the target image, and then using the ZOO approach in the reduced space. It achieved results that are aligned with previous ZOO state-of-the-art methods, but managed to reduce the query count by up to $93\%$ on datasets such as MNIST, ImageNet, and CIFAR-10. Our method is comparable to $\textbf{AutoZOOM}$ in terms of performance, achieving a similar success rate with a slightly lower query count, but has the main advantage of being considerably simpler. Our approach does not need to estimate gradients at all and, compared to $\textbf{AutoZOOM-AE}$ - the more powerful attack from \cite{tu2019autozoom}, it does not require any form of training or knowledge about the training data. In addition, $\textbf{AutoZOOM}$ demands access to the output probabilities over all classes, unlike our method, which only requires the output class and its probability. While $\textbf{AutoZOOM}$ is an attack that minimizes the $L_2$ perturbations norm, $\textbf{EvoBA}$ is focused on minimising the $L_0$ norm. However we also report the $L_2$ and notice that it is comparable to $\textbf{AutoZOOM}$'s results.
$\textbf{SimBA}$ (Simple Black-box Adversarial Attack, \cite{guo2019simple}) is a very simple strategy that has comparable performance to the significantly more complex $\textbf{AutoZOOM}$. The method randomly iterates through all pixels, perturbing them with fixed noise amounts if this makes the model output a lower probability for the correct class. $\textbf{EvoBA}$ has a similar complexity to $\textbf{SimBA}$, both of them being good candidates for strong adversarial attack baselines. $\textbf{SimBA}$ is mainly powered up by the randomness of choosing which pixel to perturb, and the only information it uses is whether the correct probability decreases. In comparison, $\textbf{EvoBA}$ strikes a better balance between exploration and exploitation, which is common for evolutionary algorithms. This makes $\textbf{EvoBA}$ achieve a slightly better success rate than $\textbf{SimBA}$, with a lower query budget. Similarly to $\textbf{AutoZOOM}$, $\textbf{SimBA}$ is an $L_2$ adversarial attack, while $\textbf{EvoBA}$ focuses on $L_0$. Nevertheless, the average $L_2$ perturbation norm of $\textbf{EvoBA}$ is slightly higher, but comparable to $\textbf{SimBA}$'s results. We also run $\textbf{SimBA}$ and remark that the $L_0$ perturbation norms that $\textbf{EvoBA}$ achieves are significantly better. Furthermore, $\textbf{SimBA}$ does not allow for any kind of parallelisation, while the evolution strategy we use in $\textbf{EvoBA}$ is highly parallelisable and, accordingly, faster.
$\textbf{DeepSearch}$ (\cite{zhang2020deepsearch}) is another simple, yet very efficient black-box adversarial attack, which achieves results in line with much more complex methods. It is an $L_{\infty}$ attack, perturbing with very high probability all the pixels (maximal $L_0$ norm of the perturbations), which makes it incomparable with the $L_0$ attack $\textbf{EvoBA}$. Similarly, while $\textbf{EvoBA}$ optimizes the $L_0$ norm of the perturbations, it most often produces high $L_{\infty}$ distortions, with sometimes near-maximal perturbations for the few chosen pixels. While both $\textbf{DeepSearch}$ and $\textbf{EvoBA}$ have non-complex implementations, $\textbf{EvoBA}$ is conceptually simpler. $\textbf{DeepSearch}$ is based on the idea of linear explanations of adversarial examples (\cite{goodfellow2015explaining}), and exploits three main aspects: it devises a mutation strategy to perturb images as fast as possible, it performs a refinement on top of the earliest adversarial example in order to minimise the $L_{\infty}$ norm, and adapts an existing hierarchical-grouping strategy for reducing the number of queries (\cite{moon2019parsimonious}). Furthermore, $\textbf{EvoBA}$ has the advantage of being highly parallelisable, while $\textbf{DeepSearch}$ is inherently sequential. $\textbf{DeepSearch}$, $\textbf{EvoBA}$, and $\textbf{SimBA}$ are complementary methods that serve the similar purpose of efficient and reliable black-box attacks working under the query-limited scenario, each optimising the produced perturbations under a different norm.
As black-box adversarial attacks are ultimately search strategies in obscured environments, it has been natural to also explore the path of evolutionary algorithms. One notable example is $\textbf{GenAttack}$ \cite{alzantot2019genattack}, an approach that follows the classic pattern of genetic algorithms. While it was developed at the same time with $\textbf{AutoZOOM}$, the authors report similar results for the targeted versions of the two methods, without providing any untargeted attack results. We focused on the untargeted scenario, and our results are also in line with $\textbf{AutoZOOM}$.
$\textbf{GenAttack}$ focuses on minimising the $L_{\infty}$ perturbation norm, and, in expectation, the $L_0$ it achieves is equal to the count of all pixels in the image. In comparison, $\textbf{EvoBA}$ is an $L_0$ attack, achieving considerably small perturbations under this norm. In addition, $\textbf{EvoBA}$ is less complex and more suitable for a strong baseline attack.
A related approach to ours, which also makes use of evolution strategies, is \cite{meunier2019yet}, which tries to minimise the $L_{\infty}$ norm of adversarial perturbations.
It proposes different evolution strategies applied on top of a tiling approach inspired by \cite{ilyas2018prior}, where the authors use a Bandits approach.
The attacks they propose focus on minimising the $L_{\infty}$ norm of the perturbations and the authors do not report any other results regarding different norms. The $L_2$ cost of this approach is not clear, one of the main issues being that it can become rather high. The $L_0$ is equal in general to the number of pixels in the entire image, in comparison with $\textbf{EvoBA}$, which is $L_0$-efficient. Qualitatively, the applied adversarial tiles it generates are easily perceivable by a human, yielding grid-like patterns on top of the target image, while the samples produced by $\textbf{EvoBA}$ are imperceptible (Figure \ref{fig:band}, ImageNet) or look like benign noise (Figure \ref{fig:band_cifar10}, CIFAR-10).
\section{The Method} \label{sect:the_method}
\subsection{Notation and threat model}
We work under black-box adversarial settings, with limited query budget and $L_0$ perturbation norm. We consider the untargeted attack scenario, where an adversary wants to cause perturbation that changes the original, correct prediction of the target model for a given image to any other class.
We denote by $\mathbf{F}$ the target classifier. By a slight abuse of notation, we let $\mathbf{F}(\vec{x)}$ be the output distribution probability of model $\mathbf{F}$ on input image $\vec{x}$ and $\mathbf{F}_{k}(\vec{x})$ be the output probability for class $k$. Then, $\mathbf{F}$ can be seen as a function $\mathbf{F}: \mathbb{I} \mapsto \mathbb{R}^K$, where $\mathbb{I}$ is the image space (a subset of $\mathbb{R}^{h \times w \times c}$) and $K$ is the number of classes.
As we are working under black-box conditions, we have no information about the internals of $\mathbf{F}$, but we have query access to it, i.e., we can retrieve $\mathbf{F}(\vec{x})$ for any $\vec{x} \in \mathbb{I}$. In fact, we will see that for our method we just need access to $\argmax_k{\mathbf{F}_k(\vec{x})}$ and to its corresponding probability.
Let us consider an image $\vec{x}$, which is classified correctly by $\mathbf{F}$. The untargeted attack goal is to find a perturbed version $\vec{\Tilde{x}}$ of $\vec{x}$ that would make
\begin{equation} \label{formulation:untargeted}
\argmax_k{\mathbf{F}_k(\vec{\Tilde{x}})} \neq \argmax_k{\mathbf{F}_k(\vec{x})},
\end{equation}
constrained by the query and $L_0$ bounds.
\subsection{The algorithm}
It is usual for black-box attacks to deal with a surrogate optimization problem that tries to find a perturbed version $\vec{\Tilde{x}}$ of $\vec{x}$ that minimizes $\mathbf{F}(\vec{\Tilde{x}})$. This is clearly not equivalent to the formulation at (\ref{formulation:untargeted}), but it often yields good adversarial examples and is easier to use in practice.
In loose terms, this surrogate optimization problem can be formulated as follows for an image $\vec{x}$ with true label $y$:
\begin{equation} \label{formulation:optimization}
\min_{\boldsymbol{\delta \in \mathbb{R}^{h \times w \times c}}}\mathbf{F}_y(\vec{x} + \boldsymbol{\delta}), \text{w.r.t. queries} \le Q, \norm{\delta}_0 \le \epsilon.
\end{equation}
In order to tackle (\ref{formulation:optimization}), we adopt a simple evolution strategy that yields results in line with state-of-the-art black-box attacks.
Our method (Algorithm \ref{alg::evoba}) works by iteratively creating generations of perturbed images according to the following process: it selects the fittest individual in each generation (with lowest probability to be classified correctly), starting from the unperturbed image, then samples small batches of its pixels and randomly perturbs them, stopping when the fittest individual is either no longer classified correctly or when one of the constraints no longer holds (when either the query count or the distance become too large).
The function $\textsc{SAMPLE\_PIXELS(PARENT, B)}$ does a random, uniform sample over the pixels of $\textsc{PARENT}$, and returns a list of size at most $B$ (the sampling is done with repetition) containing their coordinates. Its purpose is to pick the pixels that will be perturbed. The function $\textsc{SAMPLE\_VALUES}$ generates pixel perturbed values. For our $L_0$ objective, we let it pick uniformly a random value in the pixel values range.
The algorithm follows a simple and general structure of evolution strategies. The mutation we apply on the best individual from each generation is selecting at most $B$ pixels and assigning them random, uniform values. The fitness of an individual is just the cumulative probability of it being misclassified.
\begin{algorithm}[t]
\DontPrintSemicolon
\KwData{black-box model $\mathbf{F}$, image $\vec{x}$, correct class $k$, query budget $Q$, $L_0$ threshold $\epsilon$, pixel batch size $B$, generation size $G$}
$\textsc{parent} \gets \vec{x}$ \;
$\textsc{prediction} \gets \mathbf{F}_k(\vec{x})$ \;
$\textsc{query\_cnt} \gets 1$ \;
\While{$\norm{\textsc{parent} - \vec{x}}_0 < \epsilon$ and $\textsc{query\_cnt}<Q$}{
$\textsc{offspring} \gets [\ ]$ \;
$\textsc{fitnesses} \gets [\ ]$ \;
$\textsc{pixels} \gets \textsc{sample\_pixels}( \textsc{parent},B)$ \;
\For{$\textsc{idx} \leftarrow 1 \dots G$}{
$\textsc{child} \gets \textsc{parent}$ \;
\For{$\textsc{pixel} \leftarrow \textsc{pixels}$}{
$\textsc{child}[\textsc{pixel}] \leftarrow \textsc{sample\_values}()$ \;
}
$\textsc{offspring} \gets \textsc{offspring} + [\textsc{child}]$ \;
$\textsc{pred\_child} \gets \mathbf{F}(\textsc{child})$ \;
$\textsc{query\_cnt} \gets \textsc{query\_cnt} + 1$ \;
\If{$\argmax \textsc{pred\_child} \neq k$}{\Return\textsc{child}}
$\textsc{fitnesses} \gets \textsc{fitnesses} + [1 - \textsc{pred\_child}_k(\textsc{child})]$\;
}
$\textsc{best\_child} \gets \argmax(\textsc{fitnesses})$\;
$\textsc{parent} \gets \textsc{offspring}[\textsc{best\_child}]$\;
}
\Return{$\textsc{Perturbation Failed}$}
\caption{EvoBA}
\label{alg::evoba}
\end{algorithm}
One important detail that is not mentioned in the pseudocode, but which allowed us to get the best results, is how we deal with multi-channel images. If the target image has the shape $h \times w \times c$ (height, width, channels), then we randomly sample a position in the $h \times w$ grid and add all of its channels to the $\textsc{PIXELS}$ that will be perturbed. We hypothesise that this works well because of a \say{inter-channel transferability} phenomenon, which allows $\textbf{EvoBA}$ to perturb faster the most sensible zones in all the channels. Note that this yields a cost of $c$ for every grid-sample to the $L_0$ perturbation norm, so in the case of ImageNet or CIFAR-10 images it counts as $3$, and in the case of MNIST it counts as $1$.
The query budget and $L_0$ constraints impose a compromise between the total number of generations in an $\textbf{EvoBA}$ run and the size $G$ of each generation. The product of these is approximately equal to the number of queries, so for a fixed budget we have to strike the right balance between them. The bigger $G$ is, the more we favour more exploration instead of exploitation, which should ultimately come at a higher query cost. The smaller $G$ is, the search goes in the opposite direction, and we favour more the exploitation. As each exploitation step corresponds to a new perturbation, this will result in bigger adversarial perturbations. Furthermore, lacking proper exploration can even make the attack unsuccessful in the light of the query count and $L_0$ constraints.
The batch size $B$ allows selecting multiple pixels to perturb at once in the mutation step. It is similar to the learning rate in general machine learning algorithms: the higher it is, the fewer queries (train steps, in the case of machine learning algorithms) we need, at the cost of potentially missing local optimal solutions.
The space complexity of Algorithm \ref{alg::evoba} is $\mathcal{O}(G \times \text{size}(\vec{x}))$. As the size of $\vec{x}$ is in general fixed, or at least bounded for specific tasks, we can argue that the space complexity is $\mathcal{O}(G)$. However, $\textbf{EvoBA}$ can be easily modified to only store two children at a moment when generating new offspring, i.e., the currently generated one and the best one so far, which makes $\textbf{EvoBA}$'s space complexity $\mathcal{O}(1)$.
The dominant component when it comes to time complexity is given by $\mathbf{F}$ queries. In the current form of Algorithm \ref{alg::evoba}, they could be at most $\min(\frac{\epsilon}{B} \times {G}, Q)$. Assuming that the budget $Q$ will generally be higher, the time complexity would roughly be $\mathcal{O}(\frac{\epsilon}{B} \times {G} \times (\text{query cost of } \mathbf{F}))$. This is merely the sequential time complexity given by the unoptimised pseudocode, however the $G$ $\mathbf{F}$-queries can be batched, yielding much faster, parallelised runs.
\section{Experiments}\label{sect:experiments}
\subsection{Experimental Setup}
We used TensorFlow/Keras for all our experiments. All the experiments were performed on a MacBook with 2,6 GHz 6-Core Intel Core i7, without a GPU.
We ran locally $\textbf{SimBA}$, the strong and simple $L_2$ black-box adversarial attack, and compared $\textbf{EvoBA}$ to both our local $\textbf{SimBA}$ results and reported results from the paper introducing it (\cite{guo2019simple}).
We also monitored and compared against the $\textbf{AutoZOOM}$ results, but for these we have used different target models, as the main focus was on comparing to $\textbf{SimBA}$ (which already achieves results which are in line with state-of-the-art approaches, such as $\textbf{AutoZOOM}$, being more query-efficient), so we adopted their models.
We don't do a head-to-head comparison with the efficient $L_{\infty}$ black-box baseline $\textbf{DeepSearch}$, as it is a direct consequence of their approach that they get near-maximal $L_0$ perturbations, while $\textbf{EvoBA}$ aims to optimize the $L_0$ norm. Similarly, $\textbf{EvoBA}$ creates high $L_{\infty}$ perturbations, as it modifies very few pixels with random, possibly big quantities. Therefore, $\textbf{DeepSearch}$ and $\textbf{EvoBA}$ are complementary methods that should be used together, but a direct comparison of their results is not suitable, as the $L_0$ and $L_{\infty}$ objectives are partly contradictory.
We ran multiple experiments over four datasets: MNIST \cite{lecun1998mnist}, CIFAR-10 \cite{krizhevsky2009learning}, and ImageNet \cite{imagenet_cvpr09}.
On MNIST we have been running our experiments on a classic target LeNet architecture \cite{lecun2015lenet}, while $\textbf{SimBA}$ does not report any results on this dataset, and $\textbf{AutoZOOM}$ uses a similar architecture to ours, with additional dropout layers (taken from \cite{carlini2017towards}). However, their target models are trained by default with distillation, which is likely to make perturbations harder. For comparing with $\textbf{SimBA}$ on MNIST, we ran the attack ourselves and aggregated various metrics.
We initially used MNIST to validate $\textbf{EvoBA}$ against a completely random black-box adversarial attack, similar to the one introduced in \cite{ilierobustness}. The purely random strategy iterates by repeatedly sampling a bounded number of pixels from the original target image and changing their values according to a random scheme. While the purely random method introduced in \cite{ilierobustness} achieves surprising results for such a simple approach, it does a very shallow form of exploration, restarting the random perturbation process with each miss (i.e., with each perturbed image that is still classified correctly). We will refer to the completely random strategy as $\textbf{CompleteRandom}$ in the experiments below.
For CIFAR-10, we use a ResNet-50 \cite{he2016deep} target model, similarly to $\textbf{SimBA}$, and we compare to both their reported results and to our local run of their attack.
For ImageNet, we have used a similar target ResNet-50 to the one used in $\textbf{SimBA}$, while $\textbf{AutoZOOM}$ used InceptionV3 \cite{szegedy2016rethinking}.
We will use the following shorthands in the results below: $\textbf{SR}$ (Success Rate), $\textbf{QA}$ (Queries Average), $\textbf{L0}$ (Average of L0 successful perturbations), $\textbf{L2}$ (Average L2 norm of successful perturbations).
We will refer to $\textbf{EvoBA}$ that perturbs at most $B$ pixels at once and that has generation size $G$ as $\textbf{EvoBA}(B,G)$. We will explicitly mention in each section which thresholds were used for the experiments.
For all the local runs of $\textbf{SimBA}$, we have been using $\epsilon=0.2$ (a hyperparameter specific to $\textbf{SimBA}$), which was also used in the paper \cite{guo2019simple}. We only replicated locally the results of the Cartesian Basis version of $\textbf{SimBA}$, which resembles more an $L_0$ adversarial attack, but which is less efficient than the Discrete Cosine Transform (DCT) version from the paper. Therefore, we will use $\textbf{SimBA-LCB}$ to refer to the local run of SimBA on top of the exact same target models as $\textbf{EvoBA}$, with $\epsilon=0.2$. We will use $\textbf{SimBA-CB}$ to refer to the results of the Cartesian Basis paper results, and $\textbf{SimBA-DCT}$ for the DCT paper results.
In the cases where the $\textbf{AutoZOOM}$ paper \cite{tu2019autozoom} provides data, we will only compare to $\textbf{AutoZOOM-BiLIN}$, the version of the attack which requires no additional training and data, and which is closer to our and $\textbf{SimBA}$'s frameworks.
\subsection{Results on MNIST}
We only experiment with $\textbf{EvoBA}(B,G)$ with $B>1$ on MNIST, and focus on $B=1$ for subsequent experiments, for which we impose an $L_0$ perturbation limit of $100$ and a query threshold of $5000$.
Running $\textbf{SimBA}$ ($\textbf{SimBA-LCB}$) on a local machine with the mentioned specifications, requires an average of $\textbf{93s}$ per MNIST sample. In comparison, all the $\textbf{EvoBA}$ experiments on MNIST took between $\textbf{1.94s}$ and $\textbf{4.58s}$ per sample.
We also report the $\textbf{CompleteRandom}$ results, for which we impose an $L_0$ perturbation limit of $100$ and a query threshold of $5000$, similarly to the constraints we use for $\textbf{EvoBA}$.
We randomly sampled $200$ images from the MNIST test set and ran $\textbf{SimBA-LCB}$, $\textbf{EvoBA}$, and $\textbf{CompleteRandom}$ against the same LeNet model \cite{lecun2015lenet}. For reference, we also add the results of $\textbf{AutoZOOM}$, which are performed on a different architecture. Therefore, the results are not directly comparable with them. $L_0$ data is not available for $\textbf{AutoZOOM}$, but it is usual for ZOO methods to perturb most of the pixels, so it is very likely that the associated $L_0$ is very high.
\begin{table}[h]
\centering
\begin{tabular}{ c c c c c}
\hline
& SR & QA & L0 & L2 \\ [0.5ex]
\hlin
\textbf{EvoBA(1,10)} & 100\% & 301.4 & 29.32 & 3.69 \\
\textbf{EvoBA(1,20)} & 100\% & 549.4 & 26.88 & 3.58 \\
\textbf{EvoBA(1,40)} & 100\% & 894.2 & 21.92 & 3.33 \\
\textbf{EvoBA(2,20)} & 100\% & 312.6 & 30,72 & 3.65 \\
\textbf{EvoBA(2,30)} & 100\% & 265.4 & 38,6 & 3.89 \\
\textbf{SimBA-LCB} & 56\% & 196.86 & 48.16 & 2.37 \\
\textbf{AutoZOOM-BiLIN} & 100\% & 98.82 & - & 3.3 \\
\textbf{CompleteRandom} & 60.5\% & 576.1 & 93.98 & 5.59 \\[0.1ex]
\hline
\end{tabular}
\caption{MNIST results. $\textbf{SimBA-LCB}$ has a very low success rate in the case of a LeNet architecture. If we take a look at the 56\% images perturbed by $\textbf{EvoBA(1,10)}$ for example, the QA becomes 192.8, which is not apparent from the table, but which is more efficient than $\textbf{SimBA-LCB}$.}
\label{tab:my_label}
\end{table}
We remark that all the $\textbf{EvoBA}$ configurations have a $100\%$ success rate, and $\textbf{SimBA-LCB}$ achieves $56\%$. While $\textbf{SimBA}$ generally achieves near-perfect success rates on other tasks, one could argue that attacking a simple target model such as LeCun on a relatively easy task such as MNIST is much harder than performing attacks for more intricate target models and tasks. This is a natural trade-off between the complexity of a model and its robustness.
\begin{figure}[ht]
\centering
\includegraphics[width=0.8\columnwidth]{l0_hist_cifar10.png}
\caption{Histogram of $L_0$ perturbation norms obtained by $\textbf{EvoBA(1,30)}$ on CIFAR-10 with target model ResNet-50. The distribution is very heavy on small values, with few outliers.}
\label{fig:histo_l0_evoba_cifar10}
\end{figure}
\begin{figure}[ht]
\centering
\includegraphics[width=0.8\columnwidth]{q_hist_cifar10.png}
\caption{Histogram of query counts obtained by \textbf{EvoBA(1,30)} on CIFAR-10 with target model ResNet-50. The distribution is very heavy on small values, with few outliers.}
\label{fig:histo_queries_evoba_cifar10}
\end{figure}
If we restrict $\textbf{EvoBA(1,10)}$ to its top $56\%$ perturbed images in terms of query-efficiency, it achieves an average of $192.79$ queries, which is below $\textbf{SimBA-LCB}$'s queries average of $196.86$. Similarly, if we restrict $\textbf{EvoBA(1,10)}$ to its top $56\%$ perturbed images in terms of $L_2$-efficiency, it achieves an $L_2$ of $3.07$, which is higher, but closer to $\textbf{SimBA-LCB}$'s $L_2$ result of $2.37$.
$\textbf{CompleteRandom}$ achieves a success rate of $60.5\%$, far below $\textbf{EvoBA}$'s $100\%$, but surprisingly above $\textbf{SimBA-LCB}$'s $56\%$. However, the nature of $\textbf{CompleteRandom}$'s perturbations is to lie at high distances, achieving $L_0$ and $L_2$ distances that are significantly higher than the distances achieved by the other methods.
\begin{figure}[ht]
\centering
\includegraphics[width=0.9\columnwidth]{EvoBAvsSimBAlarger.png}
\caption{The success rate (ratio of perturbed images) as a function of the maximum query budget. We compare $\textbf{EvoBA}$ with the strong baseline $\textbf{SimBA}$ and with $\textbf{CompleteRandom}$ on CIFAR-10.}
\label{fig:success_rate}
\end{figure}
\subsection{Results on CIFAR-10}
\begin{figure*}[!h]
\centering
\includegraphics[width=0.99\textwidth]{pert_sample_cifar10_long.png}
\caption{The first row contains original CIFAR-10 samples, which are classified correctly by ResNet-50. The second row contains adversarial examples created by $\textbf{EvoBA}$, and are labelled with the corresponding ResNet-50 predictions. Furthermore, we also provide the $L_2$ and $L_0$ distances between the unperturbed and perturbed samples. }
\label{fig:band_cifar10}
\end{figure*}
We impose an $L_0$ perturbation limit of $100$, and a query threshold of $2000$ for both $\textbf{EvoBA}$ and $\textbf{CompleteRandom}$. We randomly sample $2000$ images for $\textbf{EvoBA}$ and $50$ images for $\textbf{SimBA-LCB}$. $\textbf{EvoBA}$ and $\textbf{SimBA-LCB}$ are run on the exact same target ResNet-50 model, while $\textbf{SimBA-DCT}$ and $\textbf{SimBA-CB}$ also run on a target ResNet-50 model. $\textbf{AutoZOOM-BiLIN}$ targets an InceptionV3 model.
$\textbf{SimBA-LCB}$ required an average of $\textbf{26.15s}$ per CIFAR-10 sample, while $\textbf{EvoBA}$ required $\textbf{1.91s}$ per sample.
\begin{table}[h]
\centering
\begin{tabular}{ c c c c c}
\hline
& SR & QA & L0 & L2 \\ [0.5ex]
\hlin
\textbf{EvoBA(1,30)} & 100\% & 178.56 & 17.67 & 1.82 \\
\textbf{SimBA-LCB} & 100\% & 206.5 & 99.46 & 1.73 \\
\textbf{SimBA-CB} & 100\% & 322 & - & 2.04 \\
\textbf{SimBA-DCT} & 100\% & 353 & - & 2.21 \\
\textbf{AutoZOOM-BiLIN} & 100\% & 85.6 & - & 1.99 \\
\textbf{CompleteRandom} & 69.5\% & 161.2 & 97.17 & 3.89 \\ [0.1ex]
\hline
\end{tabular}
\caption{CIFAR-10 results. \textbf{AutoZOOM}, \textbf{SimBA-CB}, and \textbf{SimBA-DCT} do not report the $L_0$ metrics. However, we have discussed already why it is very likely that \textbf{AutoZOOM} perturbs most of the pixels. }
\label{tab:my_label2}
\end{table}
All the attacks achieved $100\%$ success rate in the CIFAR-10 experiments, with the sole exception of $\textbf{CompleteRandom}$, which only got $69.5\%$. $\textbf{EvoBA(1,30)}$ has a better query average when compared to all the $\textbf{SimBA}$ approaches, which targeted the same ResNet-50 architecture. While $\textbf{EvoBA(1,30)}$ targeted a different architecture than $\textbf{AutoZOOM-BiLIN}$, we still remark how the latter is twice more query efficient. However, $\textbf{EvoBA(1,30)}$ surprisingly achieves an $L_2$ metric which is better than the reported numbers of $\textbf{SimBA-CB}$ and $\textbf{SimBA-DCT}$, which are $L_2$ adversarial attacks.
\begin{figure}[ht]
\centering
\includegraphics[width=0.8\columnwidth]{evoba_l0.png}
\caption{Histogram of $L_0$ perturbation norms obtained by $\textbf{EvoBA(1,15)}$ on ImageNet with target model ResNet-50. The distribution is very heavy on small values, with few outliers.}
\label{fig:histo_l0_evoba}
\end{figure}
\begin{figure}[ht]
\centering
\includegraphics[width=0.8\columnwidth]{evoba_query.png}
\caption{Histogram of query counts obtained by \textbf{EvoBA(1,15)} on ImageNet with target model ResNet-50. The distribution is very heavy on small values, with few outliers.}
\label{fig:histo_query_evoba}
\end{figure}
It is not as much of a surprise the fact that $\textbf{EvoBA(1,30)}$ achieves a considerably better $L_0$ metric when compared to $\textbf{SimBA-LCB}$ ($17.67$ vs $99.46$).
In Figures \ref{fig:histo_l0_evoba_cifar10} and \ref{fig:histo_queries_evoba_cifar10} we plot the histograms of the $L_0$ perturbation norms, respectively of the query counts obtained by $\textbf{EvoBA(1,30)}$. Both are highly skewed towards low values, showing how $\textbf{EvoBA}$ does well in finding quick small perturbations with respect to the $L_0$ norm.
The success rate of $\textbf{CompleteRandom}$ ($69.5\%$) and its low average query count ($161.2$) are surprisingly good results for the trivial nature of the method, outlining once again the lack of robustness in complex image classifiers. However, these come at the cost of an average $L_0$ that is roughly $5.5$ times higher and of an average $L_2$ that is roughly $1.4$ times higher in comparison with $\textbf{EvoBA(1,30)}$'s average results.
In Figure \ref{fig:success_rate} we compare $\textbf{EvoBA(1,30)}$ with $\textbf{SimBA-LCB}$, while also providing the $\textbf{CompleteRandom}$ results. We plot the success rate as a function of the number of queries in order to understand how each method behaves for different query budgets. $\textbf{EvoBA(1,30)}$ has a better success rate than $\textbf{SimBA-LCB}$ for any query budget up to $2000$. For very low query budgets (under $112$ queries), $\textbf{CompleteRandom}$ has a better success rate than $\textbf{EvoBA(1,30)}$, but it starts converging fast after their intersection point to the success rate of $69.5\%$. It is natural for the $\textbf{CompleteRandom}$ strategy to find quick perturbations for the least robust images, as it performs bulk perturbations of many pixels at once, while $\textbf{EvoBA}$ does all perturbations sequentially. This illustrates the natural trade-off between exploration and exploitation that any black-box optimization problem encounters.
\subsection{Results on ImageNet}
We adopt a similar framework to $\textbf{AutoZOOM}$: we randomly sample 50 correctly classified images and run $\textbf{EvoBA}$ on top of them. For $\textbf{EvoBA}$, similarly to $\textbf{SimBA}$, we use a ResNet50 model, while $\textbf{AutoZOOM}$ uses an InceptionV3. We impose an $L_0$ perturbation limit of $1000$, and a query threshold of $10000$. The $L_0$ limit we impose is reasonable, as each time we perturb a pixel we actually modify all of its three channels, therefore the $1000$ limit stands for approximately $0.66\%$ of the image pixels.
\begin{table}[h]
\centering
\begin{tabular}{ c c c c c}
\hline
& SR & QA & L0 & L2 \\ [0.5ex]
\hlin
\textbf{EvoBA(1,15)} & 100\% & 1242.4 & 247.3 & 6.09 \\
\textbf{EvoBA(1,20)} & 100\% & 1412.51 & 211.03 & 5.72 \\
\textbf{SimBA-CB} & 98.6\% & 1665 & - & 3.98 \\
\textbf{SimBA-DCT} & 97.8\% & 1283 & - & 3.06 \\
\textbf{AutoZOOM-BiLIN} & 100\% & 1695.27 & - & 6.06 \\ [0.1ex]
\hline
\end{tabular}
\caption{ImageNet results. \textbf{AutoZOOM}, \textbf{SimBA-CB}, and \textbf{SimBA-DCT} do not report the $L_0$ metrics. However, we have discussed already why it is very likely that \textbf{AutoZOOM} perturbs most of the pixels. }
\label{tab:my_label3}
\end{table}
\begin{figure*}[ht]
\centering
\includegraphics[width=0.99\textwidth]{pert_sample.png}
\caption{The first row contains original ImageNet samples, which are classified correctly by ResNet-50. The second row contains adversarial examples created by $\textbf{EvoBA}$, and are labelled with the corresponding ResNet-50 predictions. Furthermore, we also provide the $L_2$ and $L_0$ distances between the unperturbed and perturbed samples. }
\label{fig:band}
\end{figure*}
The median number of queries for $\textbf{EvoBA(1,15)}$ is surprisingly low: $728.5$. Its median $L_0$ is $200$, and its median $L_2$ is $5.69$. This shows once more how we met our goal to minimise the query count and $L_0$ perturbation, as the medians are significantly smaller than the average values, showing how the distributions are biased towards low values. In comparison, the $L_2$ mean and median are close, indicating that the good $L_2$ results we get are a consequence of our other constraints rather than an actual objective.
$\textbf{EvoBA(1,15)}$ achieves the best average query metric among the given experiments. Surprisingly, its $L_2$ is almost equal to the one of $\textbf{AutoZOOM-BiLIN}$. $\textbf{EvoBA(1,15)}$ also achieves a $100\%$ success rate, which is in line with $\textbf{AutoZOOM-BiLIN}$, and better than $\textbf{SimBA}$'s results.
\subsection{Qualitative results}
In Figures \ref{fig:band_cifar10} and \ref{fig:band}, we provide samples of CIFAR-10, respectively of ImageNet perturbed images, together with their initial and perturbed labels. The perturbations are almost imperceptible to the human eye, and they look mostly like regular noise. Considering the highly-biased nature of the $L_0$ histogram in Figures \ref{fig:histo_l0_evoba_cifar10} and \ref{fig:histo_l0_evoba} towards small values, it is natural to expect well-crafted perturbations.
\section{Conclusion} \label{sect:concl}
We proposed $\textbf{EvoBA}$, an $L_0$ black-box adversarial attack based on an evolution strategy, which serves as a powerful baseline for black-box adversarial attacks.
It achieves results in line with state-of-the-art approaches, such as $\textbf{AutoZOOM}$, but is far less complex. Simple yet efficient methods, such as $\textbf{EvoBA}$, $\textbf{SimBA}$, $\textbf{DeepSearch}$, and even $\textbf{CompleteRandom}$ shed a light on the research potential of the black-box adversarial field, outlining the inherent security issues in many machine learning applications.
We plan to aggregate $\textbf{EvoBA}$ with the other strong black-box baseline attacks we have seen for different norms ($\textbf{SimBA}$ for $L_2$ and $\textbf{DeepSearch}$ for $L_{\infty}$) and create a generic open-source framework to empirically assess the robustness of image classifiers and to help with their development process. Such a toolbox could also be used to assess the quality of adversarial training methods, as many focus on improving the robustness of the target models with respect to $L_p$ norms.
Another immediate extension of our work is to customise $\textbf{EvoBA}$ to also support the targeted scenario, which can be done by adapting the fitness function used in the evolution strategy. This requires minimal changes in the implementation. $\textbf{EvoBA}$ can also be modified to make explicit use of its parallelism by distributing the generation evaluation steps to multiple workers.
$\textbf{EvoBA}$ could be easily extended for classification tasks in other fields, such as natural language processing. One would have to come with the right perturbation scheme in our approach, but we leave this for future research.
\newpage
\bibliographystyle{splncs04}
| {'timestamp': '2021-07-14T02:05:44', 'yymm': '2107', 'arxiv_id': '2107.05754', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05754'} | arxiv |
\section{Introduction}
Labeled data for some machine learning tasks can be quite rare and valuable. Data labeling is a time consuming task, and can be expensive if subject matter or language expertise are required. Machine learning engineers know that generally, the larger the training set, the higher accuracy the classifier will have \cite{dumais1998inductive}, so they often request more data.
Further, engineers have been taught to prefer balanced data sets to train more robust classifiers. Most annotation processes yield unbalanced datasets naturally. Data scientists often have four options: upsampling, downsampling, cost-sensitive learning, or active learning to seek a balanced dataset through additional annotation. Downsampling reduces the data provided to the learner, which removes valuable labeled data from the dataset. Active learning incurs additional labeling cost. Upsampling is an attractive alternative. Upsampling in NLP application areas could involve exact text duplication or text augmentation.
The CLEF CheckThat! Labs provide shared training data for all the groups. This data provided in 2020 and 2021 was naturally unbalanced, predominantly consisting of documents that are not check-worthy.
Last year we published a paper at CLEF CheckThat! which used back translation to balance the classes in our Arabic training data. \cite{williams:ea:20} The noise introduced by the machine translation system provided for an improvement in classifier performance. This method resulted in the best performing Arabic model in the Lab. For this year's Lab, we again endeavored to generate additional labeled data from the provided labeled data.
This year we used a different technique, contextually sensitive lexical augmentation, and we applied the approach to all the languages. Our technique uses BERT and RoBERTa models to replace text from the provided sample to construct alternative samples for the positive class tweets. We used this as additional training input to our transformer neural networks.
\subsection{CheckThat! Lab}
CLEF CheckThat! is a series of annual challenges to identify the best algorithms for automated fact-checking. The 2021 Lab focused on social media and news articles. \cite{clef-checkthat:2021:LNCS}
Accenture focused on Task 1 of this Lab, which required identification if a claim on Twitter was worth fact-checking, and ranking the claim for how check-worthy the claim was. \cite{clef-checkthat:2021:task1} This challenge focused on Arabic, Bulgarian, English, Spanish, and Turkish.
Accenture's paper in the 2020 Lab reached 1st place in the English track, and 1st, 2nd, 3rd, and 4th in the Arabic track. \cite{williams:ea:20}. This year, only one submission per team per language was accepted for final reporting.
\subsection{Data Augmentation}
Data augmentation is considered an important component in Deep Learning workflows \cite{raghu2020survey}. These techniques are commonly applied in speech recognition (e.g. insertion of babble), and computer vision (e.g. image rotation) systems, but are not as commonly applied in natural language processing workflows due to differences in resources and techniques based on language and task. \cite{wei-zou-2019-eda}
Augmentation in an NLP context can take many forms. Words can be replaced with synonyms, antonyms, hypernyms, homonyms, or semantic neighbors. Words can be deleted, or inserted either randomly or where the lexical insertion best fits a language model. Words can be misspelled intentionally, either phonetically or at the character level, with a deletion, insertion, replacement or a swap of character sequence. There are numerous methods for NLP data augmentation, but none are commonplace.
\cite{wei-zou-2019-eda} explored the use of text augmentation at the lexical level on five classification tasks, including a subjective/objective discrimination task. For each sentence in a training set, the researchers randomly selected between four operations-random lexical insertion, random lexical substitution, random lexical deletion, and synonym replacement. They showed that by applying these random augmentations, they were able to boost accuracy on all five classification tasks. Further, in an ablation study, the researchers showed that each of the four operations contributed to accuracy improvements. They noted that their augmentation strategy was particularly beneficial to smaller datasets. The authors performed their experiments on LSTM-RNN and CNN architectures. We are not aware of any papers describing NLP augmentation as input to transformer architectures for document classification tasks.
This study uses one of the methods mentioned in the previous paragraph, lexical substitution, but instead of applying these randomly, we use a contextual embedding model to choose the most probable operations. We demonstrate this technique with two samples below. Each invocation of the algorithm could produce a novel alternative sample.
Original check-worthy tweet:
\begin{quote}
The country is panic stricken over the \#coronavirus, yet this flu season there have been 9.7 million flu illnesses, 87,000 hospitalizations and 4800 deaths from flu, including 32 pediatric deaths. It’s time to stop the panic and put things into perspective.
\end{quote}
Random Substitution 1:
\begin{quote}
The country is panic tweeting over the \#coronavirus, yet this flu season there have been 9.7 million flu illnesses, 87,000 illnesses, 46 deaths from flu, including 32 pediatric deaths. It’s time you stop the panic and put things into perspective.
\end{quote}
Random Substitution 2:
\begin{quote}
The country remains panic stricken over the \#coronavirus, yet this flu pand there are been 9.7 million flu illnesses, 800,000 hospitalizations and 4800 deaths from flu, including 32 pediatric deaths. It’s time to stop the panic and put things into policy.
\end{quote}
Original check-worthy tweet:
\begin{quote}
People aren’t surprised when I tell them there are 13,000 Covid-19 cases outside China, or when I tell them this number doubles every 3 days. But when I tell them that if growth continues at this rate, we’ll have 1.7 million cases in 3 weeks, they’re astonished.
\end{quote}
Random Substitution 1:
\begin{quote}
People aren’t surprised when I tell them there are 100,000 Covid-19 cases outside Minnesota, or when we tell them this number grows every 3 days. So when I tell them that if growth continues at this speed, we’ll have 1.7 million cases in 3 weeks, they’re astonished.
\end{quote}
Random Substitution 2
\begin{quote}
People aren't surprised when I tell her there are 13,000 X-19 cases outside China, than when I tell them this number doubled every 3 days. But when I tell them that if growth continues at my forecast, we'll have 1.7 million cases in 3 weeks, they're astonished.
\end{quote}
More information on this procedure, including the models used, can be found in Section \ref{methoddataaugmentation}
\section{Exploratory Analysis}
Table \ref{tab1} shows the number of samples and unique word counts for each of the datasets provided. We see that Arabic had the largest number of samples in training (3,095) while English had the least (688). Similarly, Arabic had the highest count of unique words (29,619), and English had the lowest (4,499). Assuming consistent data collection methodology and annotation standards across languages, we would hypothesize that larger datasets would yield higher-accuracy models.
\begin{table}
\centering
\caption{Dataset descriptions}\label{tab1}
\begin{tabular}{|l|l|c|c|}
\hline
Language & Modeling set & \# of samples & Unique word count\\
\hline
& Train & 3,095& 26,919\\
Arabic & Test & 344& 5,413\\
& Validation & 661& 8,242\\
\hline
& Train&2,400 & 10,182\\
Bulgarian & Test & 600& 4,009\\
& Validation & 350& 2,074\\
\hline
& Train&698 & 4,499\\
English & Test & 124& 1,424\\
& Validation & 140& 1,607\\
\hline
& Train& 2,245 & 12,765\\
Spanish & Test &1,247 & 2,931\\
& Validation & 250 & 8,744\\
\hline
& Train& 1,709& 8,366\\
Turkish & Test & 1,90& 1,745\\
& Validation & 388& 2,599\\
\hline
\end{tabular}
\end{table}
A qualitative analysis found that the topics included were consequential and that many tweets were worthy of fact-checking. Understanding the topics discussed in the data helps to evaluate the lexical coverage of our pre-trained models and helps to consider specialized pre-trained neural network models that could be relevant. \\
\textbf{Arabic.} The provided training set contains a large number of tweets referencing consequential political and human conflicts around the ``Houthis movement". Notable portions of the training data also focus on diplomatic disagreements around the Algerian-Qatar relations. Political issues such as feminism are also discussed. Finally, a smaller set of tweets reference COVID-19-related political events. The testing set contain mainly the latter two topics while validation set largely contained the former two. Keywords that define these datasets include, but not limited to, ``Houthis", ``Yemen", ``Qatar", ``Algerian", ``feminist", and "Veros Koruna".\\
\textbf{Bulgarian.} The training, testing, and validation sets all focus on COVID-19. However, the tweets covers a rather varied set of topics, including political events, pandemic progression, and scientific and informational statements about the virus. The most consistent keywords are amalgamations of the term ``COVID-19", including ``Koronavirus", ``Korona", ``Coronavius", and ``Covid".\\
\textbf{Spanish.} The conversations in the training, testing and validation sets are about political issues including: government corruption, unemployment, economic instability, the importance of education, political elections, and other related topics. Spanish President, Pedro Sanchez, was named in a large number of tweets. Many tweets in the training set also mention climate issues, which are rare in the validation and testing sets. Keywords that define these sets are ``President", ``Sanchez", ``government" and ``economy". \\
\textbf{Turkish.} The training, testing, and validation set topics are varied but mostly related to Turkey domestic news, Turkish international affairs, and facts about Turkey as a country or the Turkish people. The training contains a higher number of tweets covering Turkey's national/external debt, claims of mistreatment of children, the Syrian population, unemployment, and the Turkish economy. Some keywords include ``Turkey", ``Turkish", ``unemployment", ``President", ``Erdogan", ``presidential election" and ``Istanbul".\\
\textbf{English.} Tweets from all modeling sets are about COVID-19. The training set contains many statements and information about COVID-19, global news about COVID-19, and COVID-19-related political decisions and events. The testing and validation set are more politically oriented with most tweets mentioning a political event. The most frequent keywords include ``corona",``coronavirus" and other amalgamations of the term ``COVID-19".\\
\subsection{Label Balance}
All of the datasets provided by the CheckThat! organizers had label bias which skewed each dataset towards tweets that were not considered check-worthy. The Turkish dataset had the highest percentage of check-worthy tweets (38\%), followed by English (35\%), Arabic (22\%), Bulgarian (13\%), and Spanish (8\%).
\begin{figure}[h]
\caption{Label distribution across Arabic, Bulgarian, English, Spanish, and Turkish Training Sets}
\centering
\includegraphics[scale=0.8]{clef2021-label-balance.png}
\end{figure}
\subsection{WordPiece Analysis}
Transformer models utilize WordPiece tokenization schemes that are dependant on the model being evaluated. At the time of pre-training, the WordPiece algorithm determines which pieces of words will be retained, and which will be discarded. An UNK token is utilized as a placeholder in the lexicon, and used to represent WordPiece tokens received in novel input that did not get utilized at model creation. We expect language samples which have a high amount of tokens processed as UNK would perform poorly.
We present our analysis in Table \ref{unknown-token-distribution}. Most notably, Arabic training set contains over $120$K WordPieces, the largest number across all five languages, second by just over $110$K for Spanish. In addition, Arabic training set produced a much lower rate of unknown tokens ($0.291\%$) compared to Spanish ($2.313\%$). Unexpectedly, the RoBERTa tokenizers we used did not return UNK tokens on any dataset provided by the CLEF CheckThat! organizers.
\begin{table}
\centering
\caption{Unknown token distribution in data for each language.}\label{unknown-token-distribution}
\begin{tabular}{|l|l|c|c|c|c|}
\hline
Language & Tokenizer & Modeling Set & WordPiece & Unknown Token & Unknown Percent (\%)\\
\hline
& & Training & 122,991 & 358 & 0.291\\
Arabic & BERT & Testing & 14,184 & 35 & 0.247\\
& & Validation & 26,752 & 66 & 0.247\\
\hline
& & Training & 48,437 & 0 & 0\\
Bulgarian & RoBERTa-based & Testing & 12,172 & 0& 0\\
& & Validation & 5,799 & 0 & 0\\
\hline
& & Training & 22,610 & 0 & 0\\
English & RoBERTa-based & Testing & 3,704 & 0 & 0 \\
& & Validation & 4,856 & 0 & 0 \\
\hline
& & Training &111,976 & 2,590 & 2.313 \\
Spanish & BERT & Testing & 12,246 & 251 & 2.050 \\
& & Validation & 61,361 & 1,492 & 2.432 \\
\hline
& & Training & 45,937 & 104 & 0.226 \\
Turkish & BERT & Testing & 5,073 & 11 & 0.217 \\
& & Validation & 10,160 & 13 & 0.128 \\
\hline
\end{tabular}
\end{table}
\section{Transformer Architectures and Pre-trained Models}
\subsection{Pre-trained Models}
In this work, we utilize BERT and RoBERTa models. The Bidirectional Encoder Representation Transformer (BERT) is a transformer-based architecture that was introduced in 2018 \cite{devlin2018bert,turc:2019}. BERT has had a substantial impact on the field of NLP, and achieved state of the art results on 11 NLP benchmarks at the time of its release. RoBERTa, introduced by \cite{roberta}, modified various parts of BERTs training process. These modifications include more training data, more pre-training steps with bigger batches over more data, removing BERT's Next Sentence Prediction, training on longer sequences, and dynamically changing the masking pattern applied to the training data \cite{williams:ea:20}.
For the Arabic Dataset, we used asafaya/arabic-bert-large \cite{safaya-etal-2020-kuisail}, which was trained on an Arabic version of OSCAR, an Arabic Wikipedia dump, and other Arabic resources. It contains a vocabulary of length of 32,000.
For Turkish and Spanish, we used dbmdz/bert-base-turkish-cased \cite{stefan_schweter} and geotrend/bert-base-es-cased \cite{smallermbert} respectively. The Turkish BERT model contains a vocabulary of length 32,000 and the Turkish model contains a vocabulary of length 26,359.
For English and for Bulgarian, we used roberta-large \cite{DBLP:journals/corr/abs-1907-11692} and iarfmoose/roberta-base-bulgarian \cite{bulgarian_roberta} respectively. The English RoBERTa model contains 50,265 WordPieces, and the Bulgarian RoBERTa model contains 52,000 WordPieces.
\section{Method}
\subsection{Data Augmentation}
\label{methoddataaugmentation}
The organizers provided a training and a development set for each language. We created 80/20 stratified splits on each training set to create internal training and validation sets for experimentation. We used the development set provided by organizers as a hold-out test set. For each of the internal training datasets, we extracted positive labels and performed contextual word embedding augmentation on each of the positive labels, one epoch at a time, repeating until the number of positive labels at each epoch exceeded the number of negative labels.
For each language, augmentation and training were done with BERT or RoBERTa models. BERT-based contextual embedding models were used for Arabic \cite{safaya-etal-2020-kuisail}, Spanish \cite{smallermbert}, and Turkish \cite{stefan_schweter}, and RoBERTa-based contextual embedding models were used for English \cite{DBLP:journals/corr/abs-1907-11692} and Bulgarian \cite{bulgarian_roberta}. We used \cite{ma2019nlpaug}\footnote{https://github.com/makcedward/nlpaug} to apply Contextual Word Embedding Augmentation. This augmentation type uses the surrounding words of a tweet to apply the most probable insertion or substitution of a lexical item. We chose to only apply substitution.
With Contextual Word Embedding Augmentation, the user must determine the probability a token should be augmented. On the Bulgarian and Turkish datasets, we tried using no augmentation (p = null) and augmentation at p = \{0.1, 0.2, 0.3, 0.4, 0.5\}. Additionally, we explored back-translation using AWS translation. We appended back-translated check-worthy tweets to the training set, using English as a pivot language. In the table below, we show the precision, recall, and f1 score for check-worthy class on the Bulgarian dataset. The Turkish experiments yielded similar results. For both languages, we found that augmentations at p = 0.1 resulted in a significant increase in recall and f1 for check-worthy tweets, as we show in the table below. Augmentations at higher probability thresh-holds also yielded better recall and f1 than our null model, but not better than at p = 0.1. We found that augmentation at p=0.1 provided better precision, recall and f1 than using back-translation (translation). Due to time and cost limitations, we did not repeat back-translation experiments for other competition languages or using other pivot languages.
\begin{table*}[]
\caption{Augmentation substitution improvements on Bulgarian training set using varied token augmentation probabilities}
\label{tab:augprobs}
\centering
\begin{tabular}{llllllll}
& \textbf{p=null} & \textbf{p=0.1} & \textbf{p=0.2} & \textbf{p=0.3} & \textbf{p=0.4} & \textbf{p=0.5} & \textbf{translation} \\
cw\_precision & 0.65 & 0.51 & 0.41 & 0.36 & 0.36 & 0.42 & 0.47 \\
cw\_recall & 0.17 & 0.6 & 0.66 & 0.45 & 0.31 & 0.31 & 0.47 \\
cw\_f1 & 0.28 & 0.55 & 0.51 & 0.4 & 0.33 & 0.36 & 0.47
\end{tabular}
\end{table*}
Based on this exploration (and due to the computational cost of this technique) we adopted p = 0.1 for all languages.
For each language, BERT- or RoBERTa-augmented check-worthy examples were appended to the training data and given a check-worthy label. In all languages, we found this improved f1 score for the check-worthy class when applied to our hold-out dev set. However, it's possible that this technique limited some models' performance on the evaluation test set. The table below displays the number of check-worthy augmented samples that were generated for each language.
\begin{table*}[]
\caption{Number of augmented check-worthy samples generated for each language}
\begin{tabular}{llllll}
\textbf{Language} & Bulgarian & Arabic & English & Spanish & Turkish \\
\textbf{Augmentations} & 2,471 & 2,748 & 492 & 1,800 & 656
\end{tabular}
\end{table*}
\subsection{Classification}
For both BERT and RoBERTa, we added an additional mean-pooling layer and dropout layer on top of the model prior to the final classification layer. Adding these additional layers has been shown to help prevent over-fitting while fine-tuning \cite{williams:ea:20}. We used an Adam optimizer with a learning rate of 1.5e-5 and an epsilon of 1e-8. We use a binary cross-entropy loss function, 2 epochs, and a batch size of 32.
\subsection{Ranking}
To generate rankings, the model's outputs were fed through a SoftMax function. The difference between the positive and negative class likelihoods were then used to rank tweets.
\section{Results}
The official metric of the Lab was mAP for all languages. Table \ref{tab:accentureresults} lists our results. Arabic performed the best with 0.658. This was followed by Bulgarian (0.497), Spanish (0.491), Turkish (0.402), and English (0.101).
\begin{table*}[]
\caption{Accenture results from CheckThat! 2021 Task 1 }
\label{tab:accentureresults}
\begin{tabular}{l
l llllllll}
\textbf{Entry} & \textbf{mAP} & \textbf{MRR} & \textbf{RP} & \textbf{P@1} & \textbf{P@3}& \textbf{P@5}& \textbf{P@10}& \textbf{P@20}& \textbf{P@30} \\
Arabic & \multicolumn{1}{r}{
0.658} & \multicolumn{1}{r}{1.000} & \multicolumn{1}{r}{0.599} & \multicolumn{1}{r}{1.000} & \multicolumn{1}{r}{1.000} & \multicolumn{1}{r}{1.000} & \multicolumn{1}{r}{1.000} & \multicolumn{1}{r}{0.9500} & \multicolumn{1}{r}{0.840}\\
Bulgarian & \multicolumn{1}{r}{
0.497} & \multicolumn{1}{r}{1.000} & \multicolumn{1}{r}{0.474} & \multicolumn{1}{r}{1.000} & \multicolumn{1}{r}{1.000} & \multicolumn{1}{r}{0.800} & \multicolumn{1}{r}{0.700} & \multicolumn{1}{r}{0.600} & \multicolumn{1}{r}{0.440}\\
English & \multicolumn{1}{r}{
0.101} & \multicolumn{1}{r}{0.143} & \multicolumn{1}{r}{0.158} & \multicolumn{1}{r}{0.000} & \multicolumn{1}{r}{0.000} & \multicolumn{1}{r}{0.000} & \multicolumn{1}{r}{0.200} & \multicolumn{1}{r}{0.200} & \multicolumn{1}{r}{0.100}\\
Spanish & \multicolumn{1}{r}{
0.491} & \multicolumn{1}{r}{1.0000} & \multicolumn{1}{r}{0.508} & \multicolumn{1}{r}{1.0000} & \multicolumn{1}{r}{0.667} & \multicolumn{1}{r}{0.800} & \multicolumn{1}{r}{0.900} & \multicolumn{1}{r}{0.700} & \multicolumn{1}{r}{0.620}\\
Turkish & \multicolumn{1}{r}{
0.402} & \multicolumn{1}{r}{0.250} & \multicolumn{1}{r}{0.415} & \multicolumn{1}{r}{0.000} & \multicolumn{1}{r}{0.000} & \multicolumn{1}{r}{0.400} & \multicolumn{1}{r}{0.400} & \multicolumn{1}{r}{0.650} & \multicolumn{1}{r}{0.660}\\
\end{tabular}
\end{table*}
The results from Arabic and English can be compared to Accenture's results in CheckThat! 2020. Compared to last year, our team's Arabic score increased and our team's English score decreased.
\section{Discussion}
In Section \ref{methoddataaugmentation}, we showed that contextual embedding augmentation on top of the current training data improved the f1 score of our systems. In the Lab ranking, however, we found that the Accenture received the top results for Arabic, and performed less well for other languages. Table \ref{tab:mapresults_trainingsamplecount} shows our mean average precision versus the number of training samples provided by the CheckThat! organizers.
\begin{table}[]
\caption{Accenture mAP results from CheckThat! 2021 Task 1, with training sample count }
\label{tab:mapresults_trainingsamplecount}
\begin{tabular}{lll}
\textbf{} & \textbf{mAP} & \textbf{\# Samples} \\
\textbf{English} & 0.101 & 698 \\
\textbf{Turkish} & 0.402 & 3095 \\
\textbf{Spanish} & 0.491 & 2245 \\
\textbf{Bulgarian} & 0.497 & 2400 \\
\textbf{Arabic} & 0.658 & 3095
\end{tabular}
\end{table}
We believe the transformer methods we employed to be highly sensitive to the quantity of training data and distribution of topics across the split dataset. While we were able to generate additional training data, and improve the results, we believe even more augmentation should be employed where natural labeled text cannot be acquired.
Back translation, which we employed last year, worked well for this problem. We employed it only on Arabic, but expect the technique would work well for the other languages in the Lab as well. We used Contextual Word Embedding Augmentation, this year, but limited our transformations to swaps. Lexical insertion may show to be useful as well. Synonyms and hypernym replacement would likely show advantage.
Because of the computational cost of augmenting the data with contextual embedding augmentation, we chose p = 0.1 for all languages. The optimal value is likely to be language and task dependant. We would recommend a parameter search of this value.
\section{Conclusion}
This paper presents results from the Accenture Team for CLEF2021 CheckThat! Lab, Task 1, to analyze English, Arabic, Spanish, Turkish, and Bulgarian social media to identify claims that require fact-checking. We presented a methodology that provided NLP augmentation of the training data to create additional synthetic training samples. We found this method improved our results. This approach received the highest mean average precision in the Lab this year for Arabic.
\bibliographystyle{splncs04}
| {'timestamp': '2021-07-14T02:02:04', 'yymm': '2107', 'arxiv_id': '2107.05684', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05684'} | arxiv |
\subsection{Preliminaries}
We first introduce lossy functions. For the purpose of this work, we ignore the need of trapdoors in the definition. The definition is taken verbatim from \cite{peikert2011lossy}.
Define the following quantities: the security
parameter is $\lambda$, $n(\lambda) = {\sf poly}(\lambda)$ represents the input length of the function, $m(\lambda) = {\sf poly}(\lambda)$ represents the output length and $k(\lambda) \leq n(\lambda)$ represents
the lossiness of the collection. For convenience, we also define the residual leakage $r(\lambda) := n(\lambda)-k(\lambda)$. For all these quantities, we often omit the dependence on $\lambda$.
\begin{definition}[Lossy Functions~\cite{peikert2011lossy}]
A collection of $(n, k)$-lossy functions is given by a tuple of (possibly probabilistic) polynomial-time algorithms $(S_{{\sf lf}}, F_{{\sf lf}})$ having the properties below. For notational convenience, define the algorithms $S_{{\sf inj}}(\cdot) := S_{{\sf lf}}(\cdot, 1)$ and $S_{\sf lossy}(\cdot) := S_{{\sf lf}}(\cdot, 0)$.
\begin{enumerate}
\item \emph{Easy to sample an injective function:} $S_{\sf inj}(1^\lambda)$ outputs $s$ where $s$ is a function index, with overwhelming probability, $F_{{\sf lf}}(s, \cdot)$ computes a (deterministic) injective function $f_s(\cdot)$ over the domain $\{0,1\}^{n(\lambda)}$.
For notational convenience, we assume $S_{\sf inj}(1^\lambda)$ samples a function description $f_s(\cdot)$.
\item \emph{Easy to sample a lossy function:} $S_{\sf lossy}(1^\lambda)$ outputs $s$ where $s$ is a function index, $F_{{\sf lf}}(s, \cdot)$ computes a (deterministic) function $f_s(\cdot)$ over the domain $\{0,1\}^{n(\lambda)}$ whose image has size at most $2^{r} = 2^{n - k}$, with overwhelming probability.
For notational convenience, we also assume $S_{\sf lossy}(1^\lambda)$ samples a function description $f_s(\cdot)$.
\item \emph{Hard to distinguish injective from lossy:} the outputs (function descriptions) of $S_{\sf inj}(1^\lambda)$ and $S_{\sf lossy}(1^\lambda)$ are computationally indistinguishable.
\end{enumerate}
\end{definition}
\begin{theorem}[Theorem 6.4, \cite{peikert2011lossy}]
Assuming ${\sf LWE}_{q, \chi}$ is hard for some $q, \chi$, there exists a collection of $(n , k)$ lossy functions where the residual leakage $r$ is $r = n^c$ for any constant $c > 0$.
\end{theorem}
\begin{remark}
This can be done by carefully choosing parameters $c_1 = n^{1-c}$, $c_2$ as some constant, $c_3 = 1/c$ in Theorem 6.4 of \cite{peikert2011lossy}.
\end{remark}
\begin{remark}
For the definition of extremely lossy functions,
\begin{itemize}
\item In bullet (2): $S_{\sf lossy}(1^\lambda)$ takes another parameter $r \in [2^{n}]$ and $f_s$ sampled from $S_{\sf lossy}(1^\lambda, r)$ has image size $r$, with overwhelming probability;
\item In bullet (3): For any polynomial $p$ and inverse polynomial function $\delta$ (in $n$), there is a polynomial $q$ such that: for any adversary $\mathcal{A}$ running in time at most $p$, and any $r \in [q(n), M]$, it can not distinguish the outputs of $S_{\sf inj}(1^\lambda)$ between $S_{\sf lossy}(1^\lambda)$ with advantage more than $\delta$.
\end{itemize}
\end{remark}
\vspace{1em}
Second, we introduce PRGs with sub-exponentially unpredictable seeds~\cite{zhandry2019magic, wichs2017obfuscating}.
\begin{definition}[PRG with Sub-Exponentially Unpredictable Seeds~\cite{zhandry2019magic}]
A family of pseudorandom generators $H: \mathcal{X} \to \mathcal{Y}$ is secure for sub-exponentially unpredictable seeds if, for any sub-exponentially unpredictable distribution on $(X, \mathcal{H}_Z)$, no efficient
adversary can distinguish $(H, \rho_z, H(x))$ from $(H, \rho_z, S)$ where $(x, \rho_z) \gets D$ and $S \gets U_Y$, where $\rho_z$ is a quantum auxiliary input.
\end{definition}
The following theorem follows from Appendix A in \cite{wichs2017obfuscating}. Moreover, {\sf iO}{} in the theorem statement can be further replaced with LWE using the construction in their work.
\begin{theorem}[\cite{wichs2017obfuscating}]
Assuming PRGs with sub-exponentially unpredictable seeds and {\sf iO}{}, there exists compute-and-compare obfuscation for sub-exponentially unpredictable distributions.
\end{theorem}
\subsection{PRGs with Sub-Exponentially Unpredictable Seeds}
To prove \Cref{thm:CC_subexp_from_LWE_iO}, we only need to prove PRGs with sub-exponentially unpredictable seeds can be built from lossy functions.
\input{PRG_from_ELF}
\subsection{Quantum Goldreich-Levin, with Quantum Auxiliary Input}
In this section, we prove the final step:
\begin{replemma}{lem:quantum_goldreich_levin}
If there exists a quantum algorithm, that given random $r$ and auxiliary quantum input $\ket {\psi_x}$, it computes $\langle x, r\rangle$ with probability at least $1/2 + \epsilon$ (where the probability is taken over the choice of $x$ and random $r$); then there exists a quantum algorithm that takes $\ket {\psi_x}$ and extracts $x$ with probability $4 \cdot \epsilon^2$.
The same lemma holds if the quantum auxiliary input is a mixed state, by convexity.
\end{replemma}
The proof is the same as that in \cite{adcock2002quantum}, but quantum auxiliary input about $x$ is considered.
\begin{proof}
Assume there exists a unitary $U$, given $r$ and an auxiliary quantum state $\ket {\psi_x}$, it computes $\langle x, r\rangle$ with probability more than $1/2+\epsilon$ . Since $r$ is classical information, $U$ can be modeled as: read $r$, applies $U_{r}$. For every $x, r$, we have:
\begin{align*}
U \ket r \ket {\psi_x} \ket {\mathbf{0}^m} = & \ket r U_{r} \ket {\psi_x} \ket {\mathbf{0}^m} \\
= & \ket r \left( \alpha_{x, r} \ket {\langle x, r \rangle} \ket {\phi_{x, r}} + \beta_{x, r} \ket {\overline{\langle x, r \rangle} } \ket {\phi'_{x, r}} \right) = \ket r \ket {\Phi_{x, r}},
\end{align*}
where $\ket {\mathbf{0}^m}$ is the working space, $\alpha_{x, r}$ is the coefficient for computing $\langle x, r\rangle$ correctly and $\beta_{x,r}$ for an incorrect answer.
Let $\epsilon_x$ be the probability that the quantum algorithm answers correctly on $x$ and $R$ be the space of all $r$, we have the success probability as:
\begin{align*}
\mathbb{E}_r\left[ |\alpha_{x,r}|^2 \right] = \frac{1}{|R|} \sum_r |\alpha_{x,r}|^2 = 1/2 + \epsilon_x.
\end{align*}
Now we fix an $x$ and $r$. Our algorithm for extracting $x$ does the following: it starts with the state above, then (1.) it applies a $Z$-gate(phase-flip gate) to get
\begin{align*}
& \ket r \left( \alpha_{x, r} (-1)^{\langle x, r\rangle} \ket {\langle x, r \rangle} \ket {\phi_{x, r}} + \beta_{x, r} (-1)^{\overline{\langle x, r\rangle}} \ket {\overline{\langle x, r \rangle} } \ket {\phi'_{x, r}} \right) \\
= & \ket r (-1)^{\langle x, r\rangle} \left( \alpha_{x, r}\ket {\langle x, r \rangle} \ket {\phi_{x, r}} - \beta_{x, r} \ket {\overline{\langle x, r \rangle} } \ket {\phi'_{x, r}} \right) \\
= & \ket r \ket {\Phi_{x,r}'}.
\end{align*}
Then (2.) it applies $U^{\dagger}$, because we have $\langle \Phi_{x, r} \,|\, \Phi'_{x,r}\rangle = (-1)^{\langle x, r\rangle} (|\alpha_{x,r}|^2 - |\beta_{x,r}|^2)$,
\begin{align*}
U^{\dagger} \ket r \ket {\Phi'_{x,r}} = \ket r \left( (-1)^{\langle x, r\rangle} (|\alpha_{x,r}|^2 - |\beta_{x,r}|^2) \ket{\psi_x} \ket {\mathbf{0}^m} + \ket {{\sf err}_{x,r}} \right),
\end{align*}
where $ \ket {{\sf err}_{x,r}}$ is orthogonal to $\ket {\psi_x} \ket {\mathbf{0}^m}$.
In the first two step, we actually compute everything over a uniform superposition of $r$.
Next (3.) it applies {\sf QFT} on $r$ register,
\begin{align*}
&{\sf QFT}\, \frac{1}{\sqrt{|R|}} \sum_r \ket r \left( (-1)^{\langle x, r\rangle} (|\alpha_{x,r}|^2 - |\beta_{x,r}|^2) \ket{\psi_x} \ket {\mathbf{0}^m} + \ket {{\sf err}_{x,r}} \right) \\
=& \frac{1}{|R|} \sum_y \sum_r \ket y (-1)^{\langle y, r\rangle} \left( (-1)^{\langle x, r\rangle} (|\alpha_{x,r}|^2 - |\beta_{x,r}|^2) \ket{\psi_x} \ket {\mathbf{0}^m} + \ket {{\sf err}_{x,r}} \right).
\end{align*}
Therefore, the phase on $\ket x \ket {\psi_{x}} \ket {\mathbf{0}^m}$ is at least,
\begin{align*}
\frac{1}{|R|} \sum_{r} \left( |\alpha_{x,r}|^2 - |\beta_{x,r}|^2 \right) \geq 2 \cdot \epsilon_x.
\end{align*}
It measures $r$ register and with probability at least $4 \cdot \epsilon^2_x$, it extracts $x$.
By convexity, the quantum algorithm succeeds in extracting $x$ is at least $4 \cdot \epsilon^2$.
\end{proof}
\section{Coset States}
\label{sec: coset states}
This section is organized as follows. In Section \ref{sec: affine subspaces defs}, we introduce coset states. In Section \ref{sec: direct product}, we show that coset states satisfy both an information-theoretic and a computational \emph{direct product hardness} property. The latter immediately yields a signature token scheme in the plain model assuming ${\sf iO}$, (this is described in Section \ref{sec: signature tokens}). In Section \ref{sec: monogamy} we show that coset states satisfy both an information-theoretic \emph{monogamy of entanglement} property (analogous to that satisfied by BB84 states \cite{tomamichel2013monogamy}), and a computational monogamy of entanglement property. The latter is used in Section \ref{sec: unclonable dec witness enc} to obtain an unclonable decryption scheme from ${\sf iO}$ and extractable witness encryption. In Section \ref{sec: monogamy conjectured}, we describe a \emph{strong version} of the monogamy property, which we conjecture to be true. The latter is used in Section \ref{sec: unclonable dec from stronger monogamy} to obtain an unclonable decryption scheme which does not assume extractable witness encryption.
\subsection{Definitions}
\label{sec: affine subspaces defs}
In this subsection, we provide the basic definitions and properties of coset states.
For any subspace $A$, its complement is $A^\perp = \{ b \in \mathbb{F}^n \,|\, \langle a, b\rangle \bmod 2 = 0 \,,\, \forall a \in A \}$. It satisfies $\dim(A) + \dim(A^\perp) = n$. We also let $|A| = 2^{\dim(A)}$ denote the size of the subspace $A$.
\begin{definition}[Subspace States]
For any subspace $A \subseteq \mathbb{F}_2^n$, the subspace state $\ket A$ is defined as $$ \ket{A} = \frac{1}{\sqrt{|A|}}\sum_{a \in A} \ket a \,.$$
\end{definition}
Note that given $A$, the subspace state $\ket A$ can be constructed efficiently.
\begin{definition}[Coset States]
For any subspace $A \subseteq \mathbb{F}_2^n$ and vectors $s, s' \in \mathbb{F}_2^n$, the coset state $\ket {A_{s,s'}}$ is defined as:
\begin{align*}
\ket {A_{s,s'}} = \frac{1}{\sqrt{|A|}} \sum_{a \in A} (-1)^{\langle s', a\rangle} \ket {a + s}\,.
\end{align*}
\end{definition}
Note that by applying $H^{\otimes n}$, which is {\sf QFT} for $\mathbb{F}_2^n$, to the state $\ket {A_{s,s'}}$, one obtains exactly $\ket {A^{\perp}_{s', s}}$.
Additionally, note that given $\ket A$ and $s, s'$, one can efficiently construct $\ket {A_{s, s'}}$ as follows:
\begin{align*}
& \sum_a \ket a \,\xrightarrow[]{\text{add } s}\, \sum_a \ket {a + s} \,\xrightarrow[]{H^{\otimes n}}\, \sum_{a' \in A^\perp} (-1)^{\langle a', s\rangle} \ket {a'} \\
\xrightarrow[]{\text{adding } s'}\, & \sum_{a' \in A^\perp} (-1)^{\langle a', s\rangle} \ket {a' + s'} \,\xrightarrow[]{H^{\otimes n}}\, \sum_{a \in A} (-1)^{\langle a, s'\rangle} \ket {a + s}
\end{align*}
For a subspace $A$ and vectors $s,s'$, we define $A+s = \{v +s : v \in A\}$, and $A^{\perp}+s' = \{v +s': v \in A^{\perp}\}$.
It is also convenient for later sections to define a canonical representative, with respect to subspace $A$, of the coset $A+s$.
\begin{definition}[Canonical representative of a coset]
\label{def:canonical_vec_func}
For a subspace $A$, we define the function ${\sf Can}_A(\cdot)$ such that ${\sf Can}_A(s)$ is the lexicographically smallest vector contained in $A + s$ (we call this the canonical representative of coset $A+s$).
\end{definition}
Note that if $\tilde{s} \in A + s$, then ${\sf Can}_A(s) = {\sf Can}_A(\tilde{s})$.
Also note that ${\sf Can}_A$ is polynomial-time computable given the description of $A$. The algorithm to compute ${\sf Can}_A$ is the following:
\begin{enumerate}
\item Initialize the answer to be empty.
\item In the first step, let the first entry of the answer be $0$ and check if a vector starting with $0$ is in $A+s$. This can be done efficiently by solving a linear system (by knowing $A$ and $s$). If such a vector is not in $A+s$, let the first entry of the answer be $1$.
\item Iterate the same procedure for all entries, and output the answer.
%
\end{enumerate}
%
%
%
%
When it is clear from the context, for ease of notation, we will write $A+s$ to mean the \emph{program} that checks membership in $A+s$. For example, we will often write ${\sf iO}(A+s)$ to mean an ${\sf iO}$ obfuscation of the program that checks membership in $A+s$.
The following equivalences, which follow straightforwardly from the security of ${\sf iO}$, will be useful in our security proofs later on.
\begin{lemma} \label{lem:io_shO_CC_equivalent}
For any subspace $A \subseteq \mathbb{F}_2^n$,
\begin{itemize}
\item ${\sf iO}(A+s) \approx_c {\sf iO}({\sf shO}_A(\cdot-s))\,,$
\vspace{1mm}
where ${\sf shO}_A()$ denotes the program ${\sf shO}(A)$, and ${\sf shO}$ is the subspace hiding obfuscator defined in Section \ref{sec: shO}. So, ${\sf shO}_A(\cdot-s)$ is the program that on input $x$, runs program ${\sf shO}(A)$ on input $x-s$.
\item ${\sf iO}(A+s) \approx_c {\sf iO}(\mathsf{CC}[{\sf Can}_A, {\sf Can}_A(s)])\,,$
\vspace{1mm}
where recall that $\mathsf{CC}[{\sf Can}_A, {\sf Can}_A(s)]$ refers to the compute-and-compare program which on input $x$ outputs $1$ if and only if ${\sf Can}_A(x) = {\sf Can}_A(s)$.
\end{itemize}
\end{lemma}
\subsection{Direct Product Hardness}
\label{sec: direct product}
In this section, we argue that coset states satisfy both an information-theoretic
and a computational
direct product hardness \,\,property.
\subsubsection{Information-Theoretic Direct Product Hardness}
\label{sec: it direct product}
\begin{theorem}
\label{thm: direct product info}
Let $A \subseteq \mathbb{F}_2^n$ be a uniformly random subspace of dimension $n/2$, and $s, s'$ be uniformly random in $\mathbb{F}_2^n$. Let $\epsilon > 0$ be such that $1/\epsilon = o(2^{n/2})$. Given one copy of $\ket{A_{s,s'}}$, and a quantum membership oracle for $A+s$ and $A^{\perp}+s'$, an adversary needs $\Omega(\sqrt{\epsilon} 2^{n/2})$ queries to output a pair $(v,w)$ such that $v \in A+s$ and $w \in A^{\perp}+s'$ with probability at least $\epsilon$.
\end{theorem}
The proof is a simple random self-reduction to the analogous statement from Ben-David and Sattath \cite{ben2016quantum} for regular subspace states. The proof is given in Section \ref{sec: coset state direct product proof}.
\subsubsection{Computational direct product hardness}
\label{sec:affine_direct_product_comp}
Next, we present the computational version of the {direct product hardness } property. This establishes that \Cref{thm: direct product info} still holds, even if an adversary is given ${\sf iO}$ obfuscations of the subspace membership checking programs.
\begin{theorem}
\label{thm: direct product comp}
{Assume the existence of post-quantum ${\sf iO}$ and one-way function.}
Let $A \subseteq \mathbb{F}_2^n$ be a uniformly random subspace of dimension $n/2$, and $s, s'$ be uniformly random in $\mathbb{F}_2^n$.
Given one copy of $\ket{A_{s,s'}}$, $\mathsf{iO}(A+s)$ and $\mathsf{iO}(A^{\perp}+s')$, any polynomial time adversary outputs a pair $(v,w)$ such that $v \in A+s$ and $w \in A^{\perp}+s'$ with negligible probability.
\end{theorem}
\subsubsection{Proof of \Cref{thm: direct product info}}
\label{sec: coset state direct product proof}
\input{coset_state_proof_direct_product_it}
\subsubsection{Proof of \Cref{thm: direct product comp}}
\input{coset_state_proof_direct_product}
\subsection{Monogamy-of-Entanglement Property}
\label{sec: monogamy}
In this subsection, we argue that coset states satisfy an information-theoretic
and a computational
monogamy-of-entanglement property. We will not make use of these properties directly, instead we will have to rely on a stronger conjectured monogamy-of-entanglement property, which is presented in subsection \ref{sec: monogamy conjectured}. Thus, the properties that we prove in this subsection serve merely as ``evidence'' in support of the stronger conjecture.
\subsubsection{Information-Theoretic Monogamy-of-Entanglement}
\label{sec: it monogamy}
Let $n \in \mathbb{N}$. Consider the following game between a challenger and an adversary $(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$.
\begin{itemize}
\item The challenger picks a uniformly random subspace $A \subseteq \mathbb{F}_2^n$ of dimension $\frac{n}{2}$, and two uniformly random elements $s, s' \in \mathbb{F}_2^n$. Sends $\ket{A_{s,s'}}$ to $\cA_0$.
\item $\cA_0$ creates a bipartite state on registers $\mathsf{B}$ and $\mathsf{C}$. Then, $\cA_0$ sends register $\mathsf{B}$ to $\mathcal{A}_1$, and $\mathsf{C}$ to $\mathcal{A}_2$.
\item The description of $A$ is then sent to both $\mathcal{A}_1, \mathcal{A}_2$.
\item $\mathcal{A}_1$ and $\mathcal{A}_2$ return respectively $(s_1,s_1')$ and $(s_2, s_2')$.
\end{itemize}
$(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$ wins if, for $i \in \{1,2\}$, $s_i \in A +s$ and $s_i' \in A^{\perp} + s' \,.$
\vspace{2mm}
Let $\mathsf{ITMonogamy}((\cA_0, \mathcal{A}_1, \mathcal{A}_2), n)$ be a random variable which takes the value $1$ if the game above is won by adversary $(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$, and takes the value $0$ otherwise. We have the following theorem.
\begin{theorem}
\label{thm: monogamy info}
There exists a sub-exponential function ${\sf subexp}$ such that, for any (unbounded) adversary $(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$,
$$\Pr[\mathsf{ITMonogamy}((\cA_0, \mathcal{A}_1, \mathcal{A}_2), n) = 1] \leq 1/{\sf subexp}(n)\,.$$
\end{theorem}
We refer the reader to \Cref{proof:monogamy} for the proof.
\subsubsection{Computational monogamy}
\label{sec: comp monogamy}
We describe a computational version of the monogamy game from the previous section. In the computational version, $\mathcal{A}_0$ additionally receives the programs ${\sf iO}(A+s)$ and ${\sf iO}(A'+s')$. The game is between a challenger and an adversary $(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$.
\begin{itemize}
\item The challenger picks a uniformly random subspace $A \subseteq \mathbb{F}^n$ of dimension $\frac{n}{2}$, and two uniformly random elements $s, s' \in \mathbb{F}_2^n$. It sends $\ket{A_{s,s'}}$, ${\sf iO}(A+s)$, and ${\sf iO}(A^{\perp}+s')$ to $\cA_0$.
\item $\cA_0$ creates a bipartite state on registers $\mathsf{B}$ and $\mathsf{C}$. Then, $\cA_0$ sends register $\mathsf{B}$ to $\mathcal{A}_1$, and $\mathsf{C}$ to $\mathcal{A}_2$.
\item The description of $A$ is then sent to both $\mathcal{A}_1, \mathcal{A}_2$.
\item $\mathcal{A}_1$ and $\mathcal{A}_2$ return respectively $(s_1,s_1')$ and $(s_2, s_2')$.
\end{itemize}
$(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$ wins if, for $i \in \{1,2\}$, $s_i \in A +s$ and $s_i' \in A^{\perp} + s' \,.$
\vspace{2mm}
Let $\mathsf{CompMonogamy}((\cA_0, \mathcal{A}_1, \mathcal{A}_2), n)$ be a random variable which takes the value $1$ if the game above is won by adversary $(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$, and takes the value $0$ otherwise.
\begin{theorem} \label{thm: monogamy comp}
{Assume the existence of post-quantum ${\sf iO}$ and one-way function,} there exists a negligible function ${\sf negl}(\cdot)$, for any QPT adversary $(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$,
$$\Pr[\mathsf{CompMonogamy}((\cA_0, \mathcal{A}_1, \mathcal{A}_2), n) =1] = {\sf negl}(n)\,.$$
\end{theorem}
The proof is very similar to the proof of \Cref{thm: direct product comp}. We refer the reader to \Cref{sec: appendix monogamy comp} for the full details.
\subsection{Conjectured Strong Monogamy Property}
\label{sec: monogamy conjectured}
\jiahui{add comment about the follow-up?}
In this section, we describe a stronger version of the monogamy property, which we conjecture to hold. The monogamy property is a slight (but significant) variation of the one stated in the last section (which we proved to be true). Recall that there $\mathcal{A}_1$ and $\mathcal{A}_2$ are required to return pairs $(s_1, s_1')$ and $(s_2, s_2')$ respectively, such that both $s_1, s_2 \in A+s$ and $s_1', s_2' \in A^{\perp} + s'$. Now, we require that it is hard for $\mathcal{A}_1$ and $\mathcal{A}_2$ to even return a single string $s_1$ and $s_2$ respectively such that $s_1 \in A+s$ and $s_2 \in A^{\perp} + s'$.
Formally, consider the following game between a challenger and an adversary $(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$.
\begin{itemize}
\item The challenger picks a uniformly random subspace $A \subseteq \mathbb{F}_2^n$ of dimension $\frac{n}{2}$, and two uniformly random elements $s, s' \in \mathbb{F}_2^n$. It sends $\ket{A_{s,s'}}$ to $\cA_0$.
\item $\cA_0$ creates a bipartite state on registers $\mathsf{B}$ and $\mathsf{C}$. Then, $\cA_0$ sends register $\mathsf{B}$ to $\mathcal{A}_1$, and $\mathsf{C}$ to $\mathcal{A}_2$.
\item The description of $A$ is then sent to both $\mathcal{A}_1, \mathcal{A}_2$.
\item $\mathcal{A}_1$ and $\mathcal{A}_2$ return respectively $s_1$ and $s_2$.
\end{itemize}
Let $\mathsf{ITStrongMonogamy}((\cA_0, \mathcal{A}_1, \mathcal{A}_2), n)$ be a random variable which takes the value $1$ if the game above is won by adversary $(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$, and takes the value $0$ otherwise. We conjecture the following:
\begin{conjecture}
\label{conj:strong_monogamy_it}
There exists a sub-exponential function ${\sf subexp}$ such that, for any (unbounded) adversary $(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$,
$$\Pr[\mathsf{ITStrongMonogamy}((\cA_0, \mathcal{A}_1, \mathcal{A}_2), n) = 1] \leq 1/{\sf subexp}(n)\,.$$
\end{conjecture}
\begin{remark}
This conjecture is later proved in a follow-up work by Culf and Vidick after the first version of this paper. We refer the readers to \cite{culfvidick2021cosetsproof} for details of the proof.
\end{remark}
Assuming the conjecture is true, and assuming post-quantum ${\sf iO}$ and one-way functions, we are able to prove the following computational strong monogamy statement. Consider a game between a challenger and an adversary $(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$, which is identical to the one described above except that all $\cA_0$ additionally gets the membership checking programs ${\sf iO}(A+s)$ and ${\sf iO}(A^{\perp}+s')$.
\begin{itemize}
\item The challenger picks a uniformly random subspace $A \subseteq \mathbb{F}_2^n$ of dimension $\frac{n}{2}$, and two uniformly random elements $s, s' \in \mathbb{F}_2^n$. It sends $\ket{A_{s,s'}}$, ${\sf iO}(A+s)$, and ${\sf iO}(A^{\perp}+s')$ to $\cA_0$.
\item $\cA_0$ creates a bipartite state on registers $\mathsf{B}$ and $\mathsf{C}$. Then, $\cA_0$ sends register $\mathsf{B}$ to $\mathcal{A}_1$, and $\mathsf{C}$ to $\mathcal{A}_2$.
\item The description of $A$ is then sent to both $\mathcal{A}_1, \mathcal{A}_2$.
\item $\mathcal{A}_1$ and $\mathcal{A}_2$ return respectively $s_1$ and $s_2$.
\end{itemize}
$(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$ wins if, for $s_1 \in A +s$ and $s_2 \in A^{\perp} + s'$.
\vspace{2mm}
Let $\mathsf{CompStrongMonogamy}((\cA_0, \mathcal{A}_1, \mathcal{A}_2), n)$ be a random variable which takes the value $1$ if the game above is won by adversary $(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$, and takes the value $0$ otherwise.
\begin{theorem}
\label{conj:strong_monogamy}
Assuming Conjecture \ref{conj:strong_monogamy_it} holds, and assuming the existence of post-quantum ${\sf iO}$ and one-way functions, then there exists a negligible function ${\sf negl}(\cdot)$,
for any QPT adversary $(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$,
$$\Pr[\mathsf{CompStrongMonogamy}((\cA_0, \mathcal{A}_1, \mathcal{A}_2), n) = 1] = {\sf negl}(n)\,.$$
\end{theorem}
We can further show a `sub-exponential strong monogamy property' if we additionally assume sub-exponentially secure ${\sf iO}$ and one-way functions.
\begin{comment}
\begin{theorem}
\label{conj:subexp_strong_monogamy}
Assuming Conjecture \ref{conj:strong_monogamy_it} holds, and assuming the existence of sub-exponentially secure post-quantum ${\sf iO}$ and one-way functions, then
for any quantum sub-exponential time adversary $(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$,
$$\Pr[\mathsf{CompStrongMonogamy}((\cA_0, \mathcal{A}_1, \mathcal{A}_2), n) = 1] = {\sf negl}(n)\,.$$
\end{theorem}
The proof is almost identical to that of \Cref{thm: monogamy comp}, therefore we omit the proof here and refer to the proof of %
\Cref{thm: monogamy comp}.
\end{comment}
\begin{theorem}
\label{conj:subexp_strong_monogamy}
Assuming Conjecture \ref{conj:strong_monogamy_it} holds, and assuming the existence of sub-exponentially secure post-quantum ${\sf iO}$ and one-way functions, then
for any QPT adversary $(\cA_0, \mathcal{A}_1, \mathcal{A}_2)$,
$$\Pr[\mathsf{CompStrongMonogamy}((\cA_0, \mathcal{A}_1, \mathcal{A}_2), n) = 1] \leq 1/{\sf subexp}(n)\,.$$
\end{theorem}
The proof is almost identical to that of \Cref{thm: monogamy comp}, therefore we omit the proof here and refer to the proof of %
\Cref{thm: monogamy comp}.
In the rest of the work, whenever we mention `strong monogamy property' or `strong monogamy-of-entanglement property', we refer to the computational monogamy property in \Cref{conj:strong_monogamy} above. Whenever we mention `sub-exponentially strong monogamy property' or `sub-exponentially strong monogamy-of-entanglement property', we refer to the computational monogamy property in \Cref{conj:subexp_strong_monogamy}.
\subsection{Proof of \texorpdfstring{\Cref{thm: monogamy comp}}{the Computational Monogamy-of-Entanglement Property}}
\label{sec: appendix monogamy comp}
\paragraph{Proof.}
We consider the following hybrids.
\begin{itemize}
\item {Hyb 0:} This is the original security game $\mathsf{CompMonogamy}$.
\item {Hyb 1:} Same as Hyb 0 except $\mathcal{A}_0$ gets ${\sf iO}({\sf shO}(A)(\cdot-s))$, ${\sf iO}(A^\perp+s')$ and $\ket{A_{s,s'}}$, for a uniformly random superspace $B$ of $A$, of dimension $3/4n$.
\item {Hyb 2:} Same as Hyb 1 except $\mathcal{A}_0$ gets ${\sf iO}({\sf shO}(B)(\cdot-s))$, ${\sf iO}(A^\perp+s')$ and $\ket{A_{s,s'}}$, for a uniformly random superspace $B$ of $A$, of dimension $3/4n$.
\item {Hyb 3:} Same as Hyb 2 except for the following. The challenger samples $s,s', A$, and a uniformly random superspace $B$ of $A$ as before. The challenger sets $t = s + w_B$, where $w_B \leftarrow B$. Sends ${\sf iO}({\sf shO}(B)(\cdot-t))$, ${\sf iO}(A^\perp+s')$ and $\ket{A_{s,s'}}$ to $\mathcal{A}_0$.
\item {Hyb 4:} Same as Hyb 3 except $\mathcal{A}_0$ gets ${\sf iO}({\sf shO}(B)(\cdot-t))$, ${\sf iO}({\sf shO}(A^{\perp})(\cdot-s'))$ and $\ket{A_{s,s'}}$.
\item {Hyb 5:} Same as Hyb 4 except $\mathcal{A}_0$ gets ${\sf iO}({\sf shO}(B)(\cdot-t))$, ${\sf iO}({\sf shO}(C^{\perp})(\cdot-s'))$ and $\ket{A_{s,s'}}$, for a uniformly random subspace $C \subseteq A$ of dimension $n/4$.
\item {Hyb 6:} Same as Hyb 5 except for the following. The challenger sets $t' = s' + w_{C^{\perp}}$, where $ w_{C^{\perp}} \leftarrow C^{\perp}$. $\mathcal{A}_0$ gets ${\sf iO}({\sf shO}(B)(\cdot-t))$, ${\sf iO}({\sf shO}(C^{\perp})(\cdot-t'))$ and $\ket{A_{s,s'}}$.
\item {Hyb 7:} Same as Hyb 6 except the challenger sends $B, C, t,t'$ in the clear to $\mathcal{A}_0$.
\end{itemize}
\begin{lemma}
\label{lem: hyb 0-1}
For any QPT adversary $(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2)$,
$$\left|\Pr[(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2) \text{ wins in Hyb 1}] - \Pr[(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2) \text{ wins in Hyb 0}] \right| = {\sf negl}(\lambda) \,.$$
\end{lemma}
\begin{proof}
Suppose for a contradiction there was a QPT adversary $\mathcal{A}$ such that:
\begin{equation}
\label{eq: difference 1}
\left|\Pr[(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2) \text{ wins in Hyb 1}] - \Pr[(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2) \text{ wins in Hyb 0}] \right|
\end{equation}
is non-negligible.
Such an adversary can be used to construct $\mathcal{A}'$ which distinguishes ${\sf iO}(A+s)$ from ${\sf iO}({\sf shO}(A)(\cdot -s)$, which is impossible by the security of the (outer) $\mathsf{iO}$, since $A+s$ and ${\sf iO}(A)(\cdot -s)$ compute the same functionality.
Fix $n$, let $A \subseteq \mathbb{F}_2^n$, $s,s' \in \mathbb{F}_2^n$ be such that the difference in \eqref{eq: difference 1} is maximized. Suppose $\Pr[\mathcal{A} \text{ wins in Hyb 1}] > \Pr[\mathcal{A} \text{ wins in Hyb 0}]$, the other case being similar.
$\mathcal{A}'$ proceeds as follows:
\begin{itemize}
\item Receives as a challenge a circuit $P$ which is either $\mathsf{iO}(A+s)$ or $ \mathsf{iO}(\mathsf{shO}(A)(\cdot - s))$. Creates the state $\ket{A_{s,s'}}$. Gives $P$, $\mathsf{shO}(A^{\perp}+s')$ and $\ket{A_{s,s'}}$ as input to $\mathcal{A}_0$.
\item $\mathcal{A}_0$ returns a bipartite state. $\mathcal{A}'$ forwards the first register to $\mathcal{A}_1$ and the second to $\mathcal{A}_2$. $\mathcal{A}_1$ returns $(s_1, s_1')$ and $\mathcal{A}_2$ returns $(s_2, s_2')$. $\mathcal{A}'$ checks If $s_1, s_2 \in A+s$ and $s_1',s_2' \in A^{\perp} +s'$. If so, $\mathcal{A}'$ guesses that $P = \mathsf{iO}(\mathsf{shO}(A)(\cdot - s))$, otherwise that $P = \mathsf{iO}(A+s)$.
\end{itemize}
It is straightforward to verify that $\mathcal{A}'$ succeeds at distinguishing with non-negligible probability.
\end{proof}
\begin{lemma}
\label{lem: hyb 1-2}
For any QPT adversary $(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2)$,
$$\left|\Pr[(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2) \text{ wins in Hyb 2}] - \Pr[(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2) \text{ wins in Hyb 1}] \right| = {\sf negl}(\lambda) \,.$$
\end{lemma}
\begin{proof}
Suppose for a contradiction there was a QPT adversary $\mathcal{A}$ such that:
\begin{equation*}
\left|\Pr[(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2) \text{ wins in Hyb 2}] - \Pr[(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2) \text{ wins in Hyb 1}] \right| \,,
\end{equation*}
is non-neglibile.
We argue that $\mathcal{A}$ can be used to construct an adversary $\mathcal{A}'$ that breaks the security of ${\sf shO}$.
Fix $n$. Suppose $\Pr[(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2) \text{ wins in Hyb 2}] > \Pr[(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2) \text{ wins in Hyb 1}]$, the other case being similar.
$\mathcal{A}'$ proceeds as follows:
\begin{itemize}
\item Sample $A \subseteq \mathbb{F}_2^n$ uniformly at random. Send $A$ to the challenger.
\item The challenger returns a program $P$ which is either ${\sf shO}(A)$ or ${\sf shO}(B)$ for a uniformly sampled superspace $B$. $\mathcal{A}'$ samples uniformly $s,s' \in \mathbb{F}_2^n$, and creates the state $\ket{A_{s,s'}}$. Gives ${\sf iO}(P(\cdot - s))$, ${\sf iO}(A^{\perp}+s')$ and $\ket{A_{s,s'}}$ as input to $\mathcal{A}_0$. The latter returns a bipartite state. $\mathcal{A}'$ forwards the first register to $\mathcal{A}_1$ and the second register to $\mathcal{A}_2$.
\item $\mathcal{A}_1$ returns a pair $(s_1, s_1')$ and $\mathcal{A}_2$ returns a pair $(s_2,s_2')$. $\mathcal{A}'$ checks that $s_1, s_2 \in A+s$ and $s_1', s_2' \in A^{\perp} + s'$. If so, then $\mathcal{A}'$ guesses that $P = {\sf shO}(B)$, otherwise that $P = {\sf shO}(A)$.
\end{itemize}
It is straightforward to verify that $\mathcal{A}'$ succeeds at the security game for ${\sf shO}$ with non-negligible advantage.
\end{proof}
\begin{lemma}
\label{lem: hyb 2-3}
For any QPT adversary $\mathcal{A}$,
$$\left|\Pr[\mathcal{A} \text{ wins in Hyb 3}] - \Pr[\mathcal{A} \text{ wins in Hyb 2}] \right| = {\sf negl}(\lambda) \,.$$
\end{lemma}
\begin{proof}
The proof is similar to the proof of Lemma \ref{lem: hyb 0-1}, and follows from the security of ${\sf iO}$ and the fact that ${\sf shO}(B)(\cdot - s)$ and ${\sf shO}(B)(\cdot - t)$ compute the same functionality.
\end{proof}
\begin{lemma}
For any QPT adversary $\mathcal{A}$,
$$\left|\Pr[\mathcal{A} \text{ wins in Hyb 4}] - \Pr[\mathcal{A} \text{ wins in Hyb 3}] \right| = {\sf negl}(\lambda) \,.$$
\end{lemma}
\begin{proof}
The proof is analogous to that of Lemma \ref{lem: hyb 0-1}.
\end{proof}
\begin{lemma}
For any QPT adversary $\mathcal{A}$,
$$\left|\Pr[\mathcal{A} \text{ wins in Hyb 5}] - \Pr[\mathcal{A} \text{ wins in Hyb 4}] \right| = {\sf negl}(\lambda) \,.$$
\end{lemma}
\begin{proof}
The proof is analogous to that of Lemma \ref{lem: hyb 1-2}.
\end{proof}
\begin{lemma}
For any QPT adversary $\mathcal{A}$,
$$\left|\Pr[\mathcal{A} \text{ wins in Hyb 6}] - \Pr[\mathcal{A} \text{ wins in Hyb 5}] \right| = {\sf negl}(\lambda) \,.$$
\end{lemma}
\begin{proof}
The proof is analogous to that of Lemma \ref{lem: hyb 2-3}.
\end{proof}
\begin{lemma}
For any QPT adversary $\mathcal{A}$ for Hyb 6, there exists an adversary $\mathcal{A}'$ for Hyb 7 such that
$$ \Pr[\mathcal{A}' \text{ wins in Hyb 7}] \geq \Pr[\mathcal{A} \text{ wins in Hyb 6}] \,.$$
\end{lemma}
\begin{proof}
This is immediate.
\end{proof}
\begin{lemma}
\label{lem:comp_vector_hiding}
For any adversary $(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2)$,
$$\Pr[(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2) \text{ wins in Hyb 7}] = {\sf negl}(\lambda) \,.$$
\end{lemma}
\begin{proof}
Suppose there exists an adversary $(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2)$ for Hyb 7 that wins with probability $p$.
We first show that, without loss of generality, one can take $B$ to be the subspace of vectors such that the last $n/4$ entries are zero (and the rest are free), and one can take $C$ to be such that the last $3/4n$ entries are zero (and the rest are free). We construct the following adversary $(\mathcal{A}_0', \mathcal{A}_1', \mathcal{A}_2')$ for the game where $B$ and $C$ have the special form above with trailing zeros, call these $B_*$ and $C_*$, from an adversary $(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2)$ for the game of Hyb 7.
\begin{itemize}
\item $\mathcal{A}_0'$ receives a state $\ket{A_{s,s'}}$, together with $t$ and $t'$, for some $C_* \subseteq A \subseteq B_*$, where $t = s + w_{B_*}$ for $w_{B_*} \leftarrow B_*$, and $t' = s' + w_{C_*^{\perp}}$, where $w_{C_*^{\perp}} \leftarrow C_*^{\perp}$.
\item $\mathcal{A}_0'$ picks uniformly random subspaces $B$ and $C$ of dimension $\frac{3}{4}n$ and $\frac{n}{4}$ respectively such that $C \subseteq B$, and a uniformly random isomorphism $\mathcal{T}$ mapping $C_*$ to $C$ and $B_*$ to $B$. We think of $\mathcal{T}$ as a change-of-basis matrix. $\mathcal{A}_0'$ applies to $\ket{A_{s,s'}}$ the unitary $U_{\mathcal{T}}$ which acts as $\mathcal{T}$ on the standard basis elements. $\mathcal{A}_0'$ gives $U_{\mathcal{T}}\ket{A}$ to $\mathcal{A}_0$ together with $B$, $C$, $\mathcal{T}(t)$ and $(\mathcal{T}^{-1})^T(t')$. $\mathcal{A}_0'$ receives a bipartite state from $\mathcal{A}_0$. Forwards the first register to $\mathcal{A}_1'$ and the second register to $\mathcal{A}_2'$.
\item $\mathcal{A}_1'$ forwards the received register to $\mathcal{A}_1$, and receives a pair $(s_1, s_1')$ as output. $\mathcal{A}_1'$ returns $(\mathcal{T}^{-1}(s_1), \mathcal{T}^{T}(s_1'))$ to the challenger. $\mathcal{A}_2'$ proceeds analogously.
\end{itemize}
First, notice that
\begin{align*}
U_{\mathcal{T}} \ket{A_{s,s'}} &= U_{\mathcal{T}} \sum_{v \in A} (-1)^{\langle v,s' \rangle}\ket{v+s} \\
& = \sum_{v \in A} (-1)^{\langle v,s' \rangle}\ket{\mathcal{T}(v)+\mathcal{T}(s)} \\
& = \sum_{w \in \mathcal{T}(\mathcal{A})} (-1)^{\langle \mathcal{T}^{-1}(w), s' \rangle}\ket{w+\mathcal{T}(s)} \\
& = \sum_{w \in \mathcal{T}(A)} (-1)^{\langle w, (\mathcal{T}^{-1})^T(s') \rangle}\ket{w+\mathcal{T}(s)} \\
& = \ket{\mathcal{T}(A)_{z, z'}} \,,
\end{align*}
where $z = \mathcal{T}(s)$ and $z' = (\mathcal{T}^{-1})^T (s')$.
Notice that $\mathcal{T}(A)$ is a uniformly random subspace between $C$ and $B$, and that $z$ and $z'$ are uniformly random vectors in $\mathbb{F}_2^n$. Moreover, we argue that:
\begin{itemize}
\item[(i)] $\mathcal{T}(t)$ is distributed as a uniformly random element of $z+B$.
\item[(ii)] $(\mathcal{T}^{-1})^T(t')$ is distributed as a uniformly random element of $z' + C^{\perp}$.
\end{itemize}
For (i), notice that
$$\mathcal{T}(t) = \mathcal{T}(s+w_{B_*}) = \mathcal{T}(s)+\mathcal{T}(w_{B_*}) = z + \mathcal{T}(w_{B_*})\,,$$ where $w_{B_*}$ is uniformly random in $B_*$. Since $\mathcal{T}$ is an isomorphism with $\mathcal{T}(B_*) = B$, then $\mathcal{T}(w_{B_*})$ is uniformly random in $B$. Thus, $\mathcal{T}(t)$ is distributed as a uniformly random element in $z+B$.
For (ii), notice that
$$(\mathcal{T}^{-1})^T(t') = (\mathcal{T}^{-1})^T(s'+w_{C_*^{\perp}}) = (\mathcal{T}^{-1})^T(s') + (\mathcal{T}^{-1})^T(w_{C_*^{\perp}}) = z' + (\mathcal{T}^{-1})^T(w_{C_*^{\perp}}) \,,$$
where $w_{C_*^{\perp}}$ is uniformly random in $C_*^{\perp}$. We claim that $(\mathcal{T}^{-1})^T(w_{C_*^{\perp}})$ is uniformly random in $C^{\perp}$. Notice, first, that the latter belongs to $C^{\perp}$. Let $x \in C$, then
$$\langle (\mathcal{T}^{-1})^T(w_{C_*^{\perp}}), x \rangle = \langle w_{C_*^{\perp}}, \mathcal{T}^{-1} (x) \rangle = 0\,,$$
where the last equality follows because $w_{C_*^{\perp}} \in C_*^{\perp}$, and $\mathcal{T}^{-1}(C) = C_*$. The claim follows from the fact that $(\mathcal{T}^{-1})^T$ is a bijection.
Hence, $\mathcal{A}_0$ receives inputs from the correct distribution, and thus, with probability $p$, both $\mathcal{A}_1$ and $\mathcal{A}_2$ return the pair $(z = \mathcal{T}(s), z' (\mathcal{T}^{-1})^T (s'))$. Thus, with probability $p$, $\mathcal{A}_1'$ and $\mathcal{A}_2'$ both return $(\mathcal{T}^{-1}(z), \mathcal{T}^{T}(z')) = (s, s')$ to the challenger, as desired.
\vspace{2mm}
So, we can now assume that $B$ is the space of vectors such that the last $\frac{n}{4}$ entries are zero, and $C$ is the space of vectors such that the last $\frac34 n$ entries are zero. Notice then that the sampled subspace $A$ is uniformly random subspace subject to the last $\frac{n}{4}$ entries being zero, and the first $\frac{n}{4}$ entries being free. From an adversary $(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2)$ for Hybrid 7 with such $B$ and $C$, we will construct an adversary $(\mathcal{A}_0', \mathcal{A}_1', \mathcal{A}_2')$ for the information-theoretic monogamy where the ambient subspace is $\mathbb{F}_2^{n'}$, where $n' = \frac{n}{2}$.
\begin{itemize}
\item $\mathcal{A}_0'$ receives $\ket{A_{s,s'}}$, for uniformly random $A \subseteq \mathbb{F}_2^{n'}$ of dimension $n'/2$ and uniformly random $s, s' \in \mathbb{F}_2^{n'}$. $\mathcal{A}_0'$ samples $\tilde{s}, \tilde{s}', \hat{s}, \hat{s}' \leftarrow \mathbb{F}_2^{\frac{n}{4}}$. Let $\ket{\phi} = \frac{1}{2^{n/8}} \sum_{x \in \{0,1\}^{n/4} } (-1)^{\langle x,\tilde{s}' \rangle}\ket{x + \tilde{s}}$. $\mathcal{A}_0'$ creates the state
$$ \ket{W} = \ket{\phi} \otimes \ket{A_{s,s'}} \otimes \ket{\hat{s}}\,,$$
$\mathcal{A}_0'$ gives to $\mathcal{A}_0$ as input the state $\ket{W}$, together with $t = 0^{3n/4}|| \hat{s} + w_B$ for $w_B \leftarrow B$ and $t' = \hat{s}'||0^{3n/4} + w_{C^{\perp}}$, for $w_{C^{\perp}} \leftarrow C^{\perp}$. $\mathcal{A}_0$ returns a bipartite state. $\mathcal{A}_0'$ forwards the first register to $\mathcal{A}_1'$ and the second register to $\mathcal{A}_2'$.
\item $\mathcal{A}_1'$ receives $A$ from the challenger. $\mathcal{A}_1'$ sends to $\mathcal{A}_1$ the previously received register, together with the the subspace $A' \subseteq \mathbb{F}_2^n$ whose first $n/4$ entries are free, the last $n/4$ entries are zero, and the middle $n/2$ entries belong to $A$. $\mathcal{A}_1$ returns a pair $(s_1, s_1') \in \mathbb{F}_2^{n} \times \mathbb{F}_2^{n}$. Let $r_1 = [s_1]_{\frac{n}{4}+1, \frac{3}{4}n} \in \mathbb{F}_2^{n/2}$ be the ``middle'' $n/2$ entries of $s_1$. Let $r_1 = [s'_1]_{\frac{n}{4}+1, \frac{3}{4}n} \in \mathbb{F}_2^{n/2} $. $\mathcal{A}_1'$ outputs $(r_1, r'_1)$.
\item $\mathcal{A}_2'$ receives $A$ from the challenger. $\mathcal{A}_2'$ sends to $\mathcal{A}_2$ the previously received register, together with the the subspace $A' \subseteq \mathbb{F}_2^n$ whose first $n/4$ entries are free, the last $n/4$ entries are zero, and the middle $n/2$ entries belong to $A$. $\mathcal{A}_2$ returns a pair $(s_2, s_2') \in \mathbb{F}_2^{n} \times \mathbb{F}_2^{n}$. Let $r_2 = [s_2]_{\frac{n}{4}+1, \frac{3}{4}n} \in \mathbb{F}_2^{n/2}$ be the ``middle'' $n/2$ entries of $s_2$. Let $r'_2 = [s'_2]_{\frac{n}{4}+1, \frac{3}{4}n} \in \mathbb{F}_2^{n/2} $. $\mathcal{A}_2'$ outputs $(r_2, r_2')$.
\end{itemize}
Notice that
\begin{align*}
\ket{W} &= \ket{\phi} \otimes \ket{A_{s,s'}} \otimes \ket{\tilde{s}} \\
&= \sum_{x \in \{0,1\}^{n/4}, v \in A} (-1)^{\langle x,\tilde{s}' \rangle} (-1)^{\langle v,s' \rangle}\Big| (x+\tilde{s})||(v+s)||\hat{s}\Big\rangle \\
&= \sum_{x \in \{0,1\}^{n/4}, v \in A} (-1)^{\langle (x||v||0^{n/4}), (\tilde{s}'|| s'||\hat{s}') \rangle} \Big| x||v||0^{n/4} + \tilde{s}||s||\hat{s} \Big \rangle \\
&= \sum_{w \in \tilde{A}} (-1)^{\langle w, z' \rangle} \ket{w + z} = \ket{\tilde{A}_{z,z'}} \,,
\end{align*}
where $z = \tilde{s}||s||\hat{s}$, $z' = \tilde{s}'||s'||\hat{s}'$, and $\tilde{A} \subseteq \mathbb{F}_2^n$ is the subspace in which the first $n/4$ entries are free, the middle $n/2$ entries belong to subspace $A$, and the last $n/4$ entries are zero.
Notice that the subspace $\tilde{A}$, when averaging over the choice of $A$, is distributed precisely as in the game of Hybrid 7 (with the special choice of $B$ and $C$); $z, z'$ are uniformly random in $\mathbb{F}_2^{n}$; $t$ is uniformly random from $z + B$, and $t'$ is uniformly random from $z'+C^{\perp}$. It follows that, with probability $p$, the answers returned by $\mathcal{A}'_1$ and $\mathcal{A}'_2$ are both correct.
From the information-theoretic security of the monogamy game, Theorem \ref{thm: monogamy info}, it follows that $p$ must be negligible.
\end{proof}
\subsection{Proof for \texorpdfstring{\Cref{thm: monogamy info}}{the Information-Theoretical Monogamy-of-Entanglement Property}}
\label{proof:monogamy}
\paragraph{Proof of \Cref{thm: monogamy info}. }
In this section, we prove Theorem \ref{thm: monogamy info}, the information-theoretic monogamy property of coset states.
The proof resembles the proof of monogamy for BB84 states in~\cite{tomamichel2013monogamy}. However, the extra algebraic structure of subspace states requires a more refined analysis. We first state the lemmas that are required for the main theorem.
Assume $A \subseteq \mathbb{F}_2^n$ is of dimension $n/2$.
We use $\mathsf{CS}(A)$ to denote the set of all cosets of $A$. Since $\dim(A) = n/2$, $|\mathsf{CS}(A)| = 2^{n/2}$.
Note that if $A+s \ne A+s_0$, then they are disjoint.
Because each coset $A+s$ of $A$ has a canonical form, which is ${\sf Can}_A(s)$, we will identify $\mathsf{CS}(A)$ with the set of all canonical vectors (where cosets are identified with their canonical vectors).
We use $R_2^n$ to denote the set of all subspaces of dimension $n/2$ in $\mathbb{F}_2^n$.
\begin{lemma}
Fixing a subspace $A$, the coset states $\ket {A_{s,s'}}$ and $\ket {A_{s_0, s'_0}}$ are orthogonal if and only if $A+s \ne A+s_0$ or $A'+s' \ne A'+s_0'$.
\end{lemma}
\begin{proof}
If $A+s \ne A+s_0$, then $|A_{s, s'}\rangle$ has support over $A + s$ but $|A_{s_0, s'_0}\rangle$ has support over $A + s_0$. Because they have disjoint support, it is easy to see they are orthogonal.
If $A'+s' \ne A'+s'_0$, we can apply {\sf QFT} and use the same argument in the Fourier domain.
\end{proof}
\begin{lemma}
Fixing $A$, $|A_{s,s'}\rangle$ for all $s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)$ form a basis.
\end{lemma}
\begin{proof}
We already know that the states $\ket {A_{s, s'}}$ and $\ket {A_{s_0, s'_0}}$ are orthogonal if $s, s' \ne s_0, s'_0$. Since there are total $2^{n/2} \times 2^{n/2} = 2^n$ states $\ket {A_{s, s'}}$, they form a basis.
%
%
%
%
%
%
\end{proof}
\begin{lemma} \label{lem:EPR}
Fixing $A$, $\frac{1}{2^{n/2}} \sum_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} |A_{s, s'}, A_{s, s'}\rangle = \frac{1}{2^{n/2}} \sum_{v \in \mathbb{F}_2^n} |v, v\rangle$. In other words, the summation is independent of $A$ and it is an EPR pair.
\end{lemma}
\begin{proof}
\begin{align*}
\sum_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} |A_{s, s'}, A_{s, s'}\rangle &= \frac{1}{ |A| |A^\perp|} \sum_{s, s' \in \mathbb{F}_2^n} |A_{s, s'}, A_{s, s'}\rangle \\
&= \frac{1}{ |A| |A^\perp|} \sum_{s, s' \in \mathbb{F}_2^n} \frac{1}{|A|} \sum_{\substack{a \in A \\ b \in A}} (-1)^{\langle a - b, s'\rangle} |a + s\rangle |b + s\rangle \\
&= \frac{2^n}{|A| |A^\perp|} \sum_{s \in \mathbb{F}_2^n} \frac{1}{|A|} \sum_{\substack{a \in A }} |a + s\rangle |a + s\rangle \\
&= \sum_{s\in S} | s\rangle |s\rangle %
\end{align*}
where the first equality comes from the fact that for any vectors $s_0 \in A + s$ and $s_0' \in A^\perp+s'$, $\ket{A_{s, s'}} \ket{A_{s, s'}} = \ket {A_{s_0, s_0'}} \ket {A_{s_0, s_0'}}$.
\end{proof}
We want to prove the following statement:
\begin{theorem} \label{thm: monogam IT canonical form}
Fix $n \in \mathbb{N}$. For any Hilbert spaces $\mathcal{H}_B, \mathcal{H}_C$, any collections of POVMs
\begin{align*}
\left\{ \left\{ P^A_{s, s'} \right\}_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} \right\}_{A \in R_2^n} \text{ and } \left\{ \left\{ Q^A_{s, s'} \right\}_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} \right\}_{A \in R_2^n}
\end{align*}
on the Hilbert spaces, and any CPTP map that maps $|A_{s, s'}\rangle \langle A_{s, s'}|$ into $\mathcal{D}(\mathcal{H}_B) \otimes \mathcal{D}(\mathcal{H}_C)$, we have that,
\begin{align*}
\mathbb{E}_{A \in R_2^n} \mathbb{E}_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} {\sf Tr} \left[ \left(P^A_{s,s'} \otimes Q^A_{s, s'} \right) \cdot \Phi(|A_{s,s'}\rangle\langle A_{s,s'}|) \right] \leq 1/{\sf subexp}(n)
\end{align*}
where ${\sf subexp}$ is a sub-exponential function.
\end{theorem}
Note that this bound directly gives Theorem \ref{thm: monogamy info}, since both parties in Theorem \ref{thm: monogamy info} get the description of $A$, by applying ${\sf Can}_A(\cdot)$, one could map any vectors in $A+s$ and $A^\perp+s'$ to ${\sf Can}_A(s)$ and ${\sf Can}_{A^\perp}(s')$.
To prove Theorem \ref{thm: monogamy info} (and the above Theorem \ref{thm: monogam IT canonical form}), we present the following theorem about the monogamy game.
\begin{theorem} \label{thm: monogam2 IT canonical form}
Fix $n \in \mathbb{N}$. For any Hilbert spaces $\mathcal{H}_B, \mathcal{H}_C$, any collections of POVMs
\begin{align*}
\left\{ \left\{ P^A_{s, s'} \right\}_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} \right\}_{A \in R_2^n} \text{ and } \left\{ \left\{ Q^A_{s, s'} \right\}_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} \right\}_{A \in R_2^n}
\end{align*}
on the Hilbert spaces, and any state $\rho$, we have
\begin{align*}
\mathbb{E}_{A \in R_2^n} \sum_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} {\sf Tr} \left[ \left(|A_{s,s'}\rangle \langle A_{s,s'}| \otimes P^A_{s,s'} \otimes Q^A_{s, s'} \right) \cdot \rho \right] \leq 1/{\sf subexp}(n)
\end{align*}
where ${\sf subexp}$ is a sub-exponential function.
\end{theorem}
Next, we show that to prove Theorem \ref{thm: monogamy info}, we only need to show Theorem \ref{thm: monogam2 IT canonical form}.
\begin{lemma}
Theorem \ref{thm: monogam2 IT canonical form} implies Theorem \ref{thm: monogam IT canonical form} (and hence Theorem \ref{thm: monogamy info}).
\end{lemma}
\begin{proof}
For convenience, let $S = \mathbb{F}_2^n$.
Assume there exists a strategy for the game in Theorem \ref{thm: monogam IT canonical form} which achieves advantage $\delta$. We construct a strategy (preparing $\rho$ and POVMs) for the game in Theorem \ref{thm: monogam2 IT canonical form} which achieves the same advantage.
\begin{enumerate}
\item Prepare the state $\rho = \frac{1}{{|S|}} (I \otimes \Phi) \sum_{s, s' \in S } |s, s\rangle \langle s', s'|$, which is equal to the following (for any subspace $A$) by Lemma \ref{lem:EPR},
\begin{align*}
(I \otimes \Phi) \sum_{s, s' \in S} |s, s\rangle \langle s', s'| &= (I \otimes \Phi) \sum_{\substack{s_1, s_1' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp) \\ s_2, s_2' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)}} |A_{s_1, s_1'}, A_{s_1, s_1'}\rangle \langle A_{s_2, s_2'}, A_{s_2, s_2'}| \\
&= \sum_{\substack{s_1, s_1' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp) \\ s_2, s_2' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp) }} |A_{s_1, s_1'}\rangle \langle A_{s_2, s_2'}| \otimes \Phi\left(|A_{s_1, s_1'}\rangle \langle A_{s_2, s_2'}|\right) \\
\end{align*}
\item $\overline{P}^A_{s, s'} = P^A_{s, s'}$ and $\overline{Q}^A_{s, s'} = Q^A_{s, s'}$ where $P, Q$ are POVMs for the game in Theorem \ref{thm: monogam IT canonical form} and $\overline{P}, \overline{Q}$ are the POVMs for the game in Theorem \ref{thm: monogam2 IT canonical form}.
\end{enumerate}
Thus, we have that the advantage is,
\begin{align*}
\quad & \mathbb{E}_{A \in R_2^n} \sum_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} {\sf Tr} \left[ \left(|A_{s,s'}\rangle \langle A_{s,s'}| \otimes \overline{P}^A_{s,s'} \otimes \overline{Q}^A_{s, s'} \right) \cdot \rho \right] \\
=\, & \mathbb{E}_{A \in R_2^n} \frac{1}{|S|} \sum_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} {\sf Tr} \left[ |A_{s,s'}\rangle \langle A_{s,s'}| \otimes \left(\left( \overline{P}^A_{s,s'} \otimes \overline{Q}^A_{s, s'} \right) \cdot \Phi\left(|A_{s, s'}\rangle \langle A_{s, s'}|\right) \right) \right] \\
=\, & \mathbb{E}_{A\in R_2^n} \frac{1}{|S|} \sum_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} {\sf Tr} \left[ |A_{s,s'}\rangle \langle A_{s,s'}| \otimes \left(\left( {P}^A_{s, s'} \otimes {Q}^A_{s, s'} \right) \cdot \Phi\left(|A_{s, s'}\rangle \langle A_{s, s'}|\right) \right) \right] \\
=\, & \mathbb{E}_{A \in R_2^n} \mathbb{E}_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} {\sf Tr} \left[ \left(P^A_{s,s'} \otimes Q^A_{s, s'} \right) \cdot \Phi(|A_{s,s'}\rangle\langle A_{s,s'}|) \right] = \delta
\end{align*}
\end{proof}
Without loss of generality, we can assume that the adversary's strategy is pure (see more discussion in Lemma 9, \cite{tomamichel2013monogamy}). In other words, all $P^A_{s, s'}$ and $Q^A_{s, s'}$ are projections.
\begin{proof}[Proof of Theorem \ref{thm: monogam2 IT canonical form}]
First, we define $\Pi^A$ as
\begin{align*}
\Pi^A = \sum_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} |A_{s, s'}\rangle \langle A_{s,s'}| \otimes P^A_{s, s'} \otimes Q^A_{s, s'}
\end{align*}
Note that $\Pi^A$ is a projection.
By definition, the advantage is
\begin{align*}
\, & \frac{1}{|R_2^n|} \sum_{A \in R_2^n} \sum_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} {\sf Tr} \left[|A_{s, s'}\rangle \langle A_{s,s'}| \otimes P^A_{s, s'} \otimes Q^A_{s, s'} \cdot \rho \right] \\
\leq \, & \mathbb{E}_{v_1, \cdots, v_n} \left[ \frac{1}{\binom{n}{n/2}} \sum_{A \in {\sf span}_{n/2}(v_1, \cdots, v_n)} \sum_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} {\sf Tr} \left[|A_{s, s'}\rangle \langle A_{s,s'}| \otimes P^A_{s, s'} \otimes Q^A_{s, s'} \cdot \rho \right] \right]
\end{align*}
where $(v_1, \cdots, v_n)$ range over all possible bases of the space, and ${\sf span}_{n/2}(v_1, \cdots, v_n)$ is the set of all subspaces spanned by exactly $n/2$ vectors in $(v_1, \cdots, v_n)$.
%
In other words, we decompose the sampling procedure of $R_2^n$ into two steps: (1) sample a random basis; (2) choose $n/2$ vectors in the basis.
Then we have, for any fixed basis $v_1, \cdots, v_n$,
\begin{align*}
\quad \, & \frac{1}{\binom{n}{n/2}} \sum_{A \in {\sf span}_{n/2}(v_1, \cdots, v_n)} \sum_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} {\sf Tr} \left[|A_{s, s'}\rangle \langle A_{s,s'}| \otimes P^A_{s, s'} \otimes Q^A_{s, s'} \cdot \rho \right] \\
= \, & \frac{1}{\binom{n}{n/2}} {\sf Tr} \left[ \sum_{A \in {\sf span}_{n/2}(v_1, \cdots, v_n)} \sum_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} |A_{s, s'}\rangle \langle A_{s,s'}| \otimes P^A_{s, s'} \otimes Q^A_{s, s'} \cdot \rho \right] \\
\leq \, & \frac{1}{\binom{n}{n/2}} \left\vert \sum_{A \in {\sf span}_{n/2}(v_1, \cdots, v_n)} \Pi^A \right\vert
\end{align*}
where $|\cdot|$ is the $\infty$-Schatten norm.
\begin{lemma} \label{lem:operator_norm_bound}
For every fixed basis $v_1, \cdots, v_n \in \mathbb{F}_2^n$, we have
\begin{align*}
\frac{1}{\binom{n}{n/2}} \left\vert \sum_{A \in {\sf span}_{n/2}(v_1, \cdots, v_n)} \Pi^A \right\vert \leq \frac{1}{\binom{n}{n/2}} \sum_{t=0}^{n/2} \binom{n/2}{t}^2 2^{-t} = O\left( 2^{-\sqrt{n}} \right)
\end{align*}
\end{lemma}
If we can prove the above lemma, we finished our proof for Theorem \ref{thm: monogam2 IT canonical form}.
\begin{proof}[Proof of Lemma \ref{lem:operator_norm_bound}]
We first show the upper bound is sub-exponentially small.
By the fact that $\left(\frac{ n}{k} \right)^k \leq \binom{n}{k} \leq \left(\frac{e n}{k} \right)^k$ for all $1 \leq k \leq n$, we have:
\begin{align*}
\frac{1}{\binom{n}{n/2}} \sum_{t=1}^{n/2} \binom{n/2}{t}^2 2^{-t} \leq & \frac{1}{\binom{n}{n/2}} \sum_{t=1}^{ \sqrt{n} } \binom{n/2}{t}^2 + 2^{- \sqrt{n}} \\
\leq & \frac{1}{2^{n/2}} \sum_{t=1}^{ \sqrt{n} } \left( \frac{e n}{2 t} \right)^{2 t} + 2^{- \sqrt{n} } \\
\leq & \frac{\sqrt{n} }{2^{n/2}} \cdot \left( \frac{e n}{2} \right)^{\sqrt{n}} + 2^{- \sqrt{n} } \\
= & \exp(- \Omega(n - \sqrt{n} \log n)) + 2^{- \sqrt{n} }
\end{align*}
Next, we prove the remaining part of the lemma. The idea is similar to that in~\cite{tomamichel2013monogamy}.
We require the following lemma.
\begin{lemma}[Lemma 2 in~\cite{tomamichel2013monogamy}] \label{lem:tfkw13_helper}
Let $A_1$, $A_2$, $\cdots$, $A_N \in P(\mathcal{H})$ (positive
semi-definite operators on $\mathcal{H}$), and let $\{\pi_k\}_{k \in [N]}$ be a set of $N$ mutually orthogonal permutations of $[N]$. Then,
\begin{align*}
\left\vert \sum_{i \in [N]} A_i \right\vert \leq \sum_{k \in [N]} \max_{i \in [N]}\left\vert \sqrt{A_i} \sqrt{A_{\pi_k(i)}} \right\vert.
\end{align*}
\end{lemma}
A set $\{\pi_k\}_{k \in [N]}$ is called a set of mutually orthogonal permutations, if for every $\pi \ne \pi'$ in the set, $\pi(i) \ne \pi'(i)$ for all $i \in [N]$. %
Fixing basis $v_1, \cdots, v_n$, there are a total of $\binom{n}{n/2}$ subspaces that can be sampled by picking a subset of $\{v_1, \cdots, v_n\}$ of size $n/2$. So, in our case, $N = \binom{n}{n/2}$.
We define a collection of permutations on ${\sf span}_{n/2}(v_1, \cdots, v_n)$ through a graph:
\begin{itemize}
\item Recall that each subspace $A$ is described as $\{u_1, \cdots, u_{n/2}\}, \{u_{n/2+1}, \cdots, u_n\}$ where the subspace is spanned by $u_1, \cdots, u_{n/2}$.
$\{u_{n/2+1}, \cdots, u_n\}$ are the vectors in $\{v_i\}_{i \in [n]}$ that are not in the subspace.
For convenience, we denote the basis choices for $A$ as a string $\ell \in \{0,1\}^n$ with Hamming weight $\frac{n}{2}$. We then define a set for all possible basis choices:
\begin{align*}
C_{n,n/2} = \left\{\ell \in \{0,1\}^n: |\ell| = \frac{n}{2} \right\}.
\end{align*}
\item Let $t \in \{0, \cdots, \frac{n}{2}\}$. Let $G_{n,t}$ be a graph with vertex set in $C_{n,n/2}$ and an edge between any $\ell, \ell' \in C_{n, n/2}$ where the number of positions $\ell, \ell'$ are both 1 is exactly $\frac{n}{2} - t$.
\item We then turn the graph $G_{n,t}$ into a directed graph by taking each edge in $G_{n,t}$ into two directed edges. Denote $d_t$ as the least in-degree (and also least out-degree) for each vertex.
\item Then we can find $d_t$ directed cycles that cover all vertices with disjoint edges. We observe that each such directed cycle corresponds to a permutation $\pi_{t, j}$ of $C_{n, n/2}$ where $j \in [d_t], t \in [n/2]$.
\item For all $j \neq j'$, $\pi_{t,},\pi_{t, j'}$ are orthogonal since in our construction the edges are disjoint. Moreover, for any $t \neq t'$, the permutations $\pi_{t,j},\pi_{t', j}$ are orthogonal.
\item The degree $G_{n,t}$ is at least $\binom{n/2}{t}^2$: because we have $\binom{n/2}{t}$ choices of positions where we can remove $t$ number of 1's from the current basis string $\ell$ (i.e. remove $t$ vectors from the current basis) and $\binom{n/2}{t}$ choices for us to flip $t$ number of 0-positions into 1's (i.e. add in $t$ vectors from outside the current basis set).
\end{itemize}
%
\iffalse
Roughly speaking, the mapping does the following. It picks some basis vectors in the subspace and swaps them with basis vectors that are not used.
\begin{itemize}
\item Recall that each subspace $A$ is described as $\{u_1, \cdots, u_{n/2}\}, \{u_{n/2+1}, \cdots, u_n\}$ where the subspace is spanned by $u_1, \cdots, u_{n/2}$.
$\{u_{n/2+1}, \cdots, u_n\}$ are the vectors in $\{v_i\}_{i \in [n]}$ that are not in the subspace.
\item The mapping is described by two subsets $I\subseteq \{1, 2, \cdots, n/2\}$ and $I' \subseteq \{n/2+1, \cdots, n\}$ of the same size.
\item The mapping does the following:
\begin{align*}
\pi_{I, I'}\left( \{u_1, \cdots, u_{n/2}\}, \{u_{n/2+1}, \cdots, u_n\} \right) = & \{u_1, \cdots, u_{n/2}\} - \bigcup_{i \in I}\{u_i\} + \bigcup_{i' \in I'}\{u_{i'}\}, \\
& \{u_{n/2+1}, \cdots, u_n\} + \bigcup_{i \in I}\{u_i\} - \bigcup_{i' \in I'}\{u_{i'}\}
\end{align*}
In other words, it removes the vectors with indices in $I$ and adds vectors with indices in $I'$.
\end{itemize}
\fi
%
%
There are a total of $\sum_{t=0}^{n/2} \binom{n/2}{t}^2 = \binom{n}{n/2} = N$ permutations $\pi_{t, j}$. Therefore, by Lemma \ref{lem:tfkw13_helper} and $\Pi^A$ are all projections, we have
\begin{align*}
\frac{1}{\binom{n}{n/2}} \left\vert \sum_{A \in {\sf span}_{n/2}(v_1, \cdots, v_n)} \Pi^A \right\vert \leq \frac{1}{\binom{n}{n/2}} \sum_{\pi_{t, j}} \max_{A \in {\sf span}_{n/2}(v_1, \cdots, v_n)} \left\vert \Pi^A \Pi^{\pi_{t, j}(A)} \right\vert
\end{align*}
Because $\Pi^A$ is a projection, $\sqrt{\Pi^A} = \Pi^A$ for all $A$.
Next, we prove the following claim: for every $A, A' \in {\sf span}_{n/2}(v_1, \cdots, v_n)$, $|\Pi^A \Pi^{A'}| \leq 2^{\dim(A \cap A') - n/2}$.
Define
\begin{align*}
\overline{\Pi}^A &=\sum_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} |A_{s, s'}\rangle \langle A_{s,s'}| \otimes P^A_{s, s'} \otimes I \\
\overline{\Pi}^{A'} &= \sum_{s, s' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp)} |A_{s, s'}\rangle \langle A_{s,s'}| \otimes I \otimes Q^A_{s, s'}
\end{align*}
%
From the fact that (1) for two semi-definite operators $A, B$ such that $A \leq B$, their $\infty$-Schatten norm satisfies $|A| \leq |B|$; (2) for a semi-definite operator $A$, $|A|^2 = |A A^\dagger|$, we have:
\begin{align*}
|\Pi^A \Pi^{A'}|^2 \leq |\overline{\Pi}^A \overline{\Pi}^{A'}|^2 = \left|\overline{\Pi}^A \overline{\Pi}^{A'} \overline{\Pi}^{A'} \overline{\Pi}^{A} \right| = \left|\overline{\Pi}^A \overline{\Pi}^{A'} \overline{\Pi}^{A} \right|
\end{align*}
Then we have,
\begin{align*}
\overline{\Pi}^A \overline{\Pi}^{A'} \overline{\Pi}^{A} &=\sum_{\substack{s_1, s_1' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp) \\s_2, s_2' \in \mathsf{CS}(A'), \mathsf{CS}(A'^\perp) \\ s_3, s_3' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp) }} |A_{s_1, s_1'}\rangle \langle A_{s_1, s_1'}| A'_{s_2, s_2'}\rangle \langle A'_{s_2, s_2'}| A_{s_3, s_3'} \rangle \langle A_{s_3, s_3'}| \\
& \quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad \otimes P^A_{s_1, s_1'} P^A_{s_3, s_3'} \otimes Q^{A'}_{s_2, s_2'} \\
&= \sum_{\substack{s_1, s_1' \in \mathsf{CS}(A), \mathsf{CS}(A^\perp) \\s_2, s_2' \in \mathsf{CS}(A'), \mathsf{CS}(A'^\perp) }} |\langle A_{s_1, s_1'}| A'_{s_2, s_2'}\rangle|^2 \cdot |A_{s_1, s_1'}\rangle \langle A_{s_1, s_1'}| \otimes P^A_{s_1, s_1'} \otimes Q^{A'}_{s_2, s'_2}
\end{align*}
Since for all $s_1, s_1', s_2, s'_2$, $|A_{s_1, s_1'}\rangle \langle A_{s_1, s_1'}| \otimes P^A_{s_1, s_1'} \otimes Q^{A'}_{s_2, s'_2}$ are projections, its Schatten-$\infty$ norm is bounded by the largest $|\langle A_{s_1, s_1'}| A'_{s_2, s_2'}\rangle|^2$.
\begin{align*}
|\langle A_{s_1, s_1'}| A'_{s_2, s_2'}\rangle| &\leq \frac{1}{2^{n/2}} \sum_{a \in S} [a \in A+s_1 \,\wedge\, a \in A'+s_2] = 2^{\dim(A \cap A')}/2^{n/2}
\end{align*}
This is because, for all basis vectors outside of $A\cap A'$, their coefficient is determined by $s_1, s_2$. Therefore, the only degree of freedom comes from the basis in $A\cap A'$.
Overall, $|\Pi^A \Pi^{A'}| \leq 2^{\dim(A \cap A')}/2^{n/2}$. Thus,
\begin{align*}
\frac{1}{\binom{n}{n/2}} \sum_{\pi_{t, j}} \max_{A \in {\sf span}_{n/2}(v_1, \cdots, v_n)} \left\vert \Pi^A \Pi^{\pi_{t, j}(A)} \right\vert
& \leq \frac{1}{\binom{n}{n/2}} \sum_{t=0}^{n/2} \binom{n/2}{t}^2 2^{t - n/2} \\
& = \frac{1}{\binom{n}{n/2}} \sum_{t=0}^{n/2} \binom{n/2}{t}^2 2^{-t}
\end{align*}
Thus, we proved Lemma \ref{lem:operator_norm_bound}.
\end{proof}
This completes the proof of Theorem \ref{thm: monogam2 IT canonical form}, and thus of Theorem \ref{thm: monogamy info}.
\end{proof}
\section{Proof of \texorpdfstring{\Cref{thm:PRF_indistinguishable_antipiracy}}{Indistinguishability Anti-Piracy Security for PRF}}
\label{sec:indistinguishable_anti_piracy_PRF}
The proof for \Cref{thm:PRF_indistinguishable_antipiracy} is similar to proof for \Cref{thm:PRF_antipiracy}, but has some main differences in the final reduction.
We highlight the changes made: the {\color{red}red-colored} parts are the differences between the latter hybrid and the former hybrid; the {\color{blue} blue-colored} parts are differences between original hybrids in proof for \Cref{thm:PRF_antipiracy} and these new hybrids.
\paragraph{Hybrid 0.}
Hybrid 0 is the original anti-piracy indistinguihsability security game.
\begin{enumerate}
\item A challenger samples $K_1 \gets \mathsf{Setup}(1^\lambda)$ and prepares a quantum key $\rho_K = (\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P))$. Here $P$ hardcodes $K_1, K_2, K_3$.
%
\item $\mathcal{A}$ upon receiving $\rho_K$, it runs and prepares a pair of (potentially entangled) quantum states $\sigma[R_1], \sigma[R_2]$ as well as quantum circuits $U_1, U_2$.
\item The challenger also prepares two inputs $u, w$ as follows:
\begin{itemize}
\item It samples $u$ uniformly at random.
Let $y_u = F_1(K_1, u)$.
%
\item It samples $w$ uniformly at random.
Let $y_w = F_1(K_1, w)$.
%
\end{itemize}
\item {\color{blue}It samples $y_u', y_w'$ uniformly at random}.
\item {\color{blue}The challenger then samples uniform coins $b_0, b_1 \gets \{0,1\}$. If $b_0 = 0$, give $(u, y_u)$ to quantum program $(U_1, \sigma[R_1])$; else give $(u, y_u')$ to quantum program $(U_1, \sigma[R_1])$.
Similarly, if $b_1 = 0$, give $(w, y_w)$ to quantum program $(U_2, \sigma[R_2])$; else give $(w, y_w')$}.
\item The outcome of the game is 1 if and only if both quantum programs successfully {\color{blue}produce $b_0' = b_0$ and $b_1' = b_1$} respectively.
\end{enumerate}
\paragraph{Hybrid 1}
%
The changes between Hybrid 0 and 1 are exactly the two cases the adversary needs to distinguish between in the game of \Cref{lem:hidden_trigger}.
Assume there exists an algorithm that distinguishes Hybrid 0 and 1 with \emph{non-negligible} probability $\epsilon(\lambda)$, then these exists
an algorithm that breaks the game in \Cref{lem:hidden_trigger} with probability $\epsilon(\lambda) - {\sf negl}(\lambda)$.
%
The reduction algorithm receives $\rho_k$ and $u, w$ or $u', w'$ from the challenger in \Cref{lem:hidden_trigger}; it computes $y_u, y_w$ using ${\sf iO}(P)$ on the received inputs respectively and gives them to the quantum decryptor states $\sigma[R_1], \sigma[R_2]$. If they both {\color{blue} output the guess }correctly, then the reduction outputs 0 for $u, w$, otherwise it outputs 1 for $u', w'$.
%
\begin{enumerate}
\item A challenger samples $K_1 \gets \mathsf{Setup}(1^\lambda)$ and prepares a quantum key $\rho_K = (\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P))$. Here $P$ hardcodes $K_1, K_2, K_3$.
%
\item $\mathcal{A}$ upon receiving $\rho_K$, it runs and prepares a pair of (potentially entangled) quantum states $\sigma[R_1], \sigma[R_2]$ as well as quantum circuits $U_1, U_2$.
\item The challenger also prepares two inputs $u', w'$ as follows:
\begin{itemize}
\item It samples $u = u_0||u_1||u_2$ uniformly at random.
Let $y_u = F_1(K_1, u)$.
{\color{red}
Let $u' \gets \mathsf{GenTrigger}(u_0, y_u, K_2, K_3, \{A_i, s_i, s'_i\}_{i \in [\ell_0]})$. }
%
\item It samples $w = w_0||w_1||w_2$ uniformly at random.
Let $y_w = F_1(K_1, w)$.
{\color{red}
Let $w' \gets \mathsf{GenTrigger}(w_0, y_w, K_2, K_3, \{A_i, s_i, s'_i\}_{i \in [\ell_0]})$. }
%
%
\end{itemize}
\item {\color{blue}It samples $y_u', y_w'$ uniformly at random}.
\item {\color{blue}The challenger then samples uniform coins $b_0, b_1 \gets \{0,1\}$. If $b_0 = 0$, give $(u', y_u)$ to quantum program $(U_1, \sigma[R_1])$; else give $(u', y_u')$ to quantum program $(U_1, \sigma[R_1])$.
Similarly, if $b_1 = 0$, give $(w', y_w)$ to quantum program $(U_2, \sigma[R_2])$; else give $(w', y_w')$}.
\item The outcome of the game is 1 if and only if both quantum programs successfully {\color{blue}produce $b_0' = b_0$ and $b_1' = b_1$} respectively.
\end{enumerate}
\paragraph{Hybrid 2.} In this hybrid, if $u_0 \ne w_0$ (which happens with overwhelming probability), $F_1(K_1, u)$ and $F_1(K_1, w)$ can be replaced with truly random strings. Since both inputs have enough min-entropy $\ell_1 + \ell_2 \geq m + 2\lambda + 4$ (as $u_1||u_2$ and $w_1||w_2$ are completely uniform and not given to the adversary) and $F_1$ is an extracting puncturable PRF, both outcomes $y_u, y_w$ are statistically close to independently random outcomes.
Thus, Hybrid 1 and Hybrid 2 are statistically close.
\begin{enumerate}
\item A challenger samples $K_1 \gets \mathsf{Setup}(1^\lambda)$ and prepares a quantum key $\rho_K = (\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P))$. Here $P$ hardcodes $K_1, K_2, K_3$.
%
\item $\mathcal{A}$ upon receiving $\rho_K$, it runs and prepares a pair of (potentially entangled) quantum states $\sigma[R_1], \sigma[R_2]$ as well as quantum circuits $U_1, U_2$.
\item The challenger also prepares two inputs $u', w'$ as follows:
\begin{itemize}
\item It samples {\color{red} $u_0$ uniformly at random}. It then samples {\color{red} a uniformly random $y_u$}.
Let $u' \gets \mathsf{GenTrigger}(u_0, y_u, K_2, K_3, \{A_i, s_i, s'_i\}_{i \in [\ell_0]})$.
%
\item It samples {\color{red} $w_0$ uniformly at random}. It then samples {\color{red} a uniformly random $y_w$}.
Let $w' \gets \mathsf{GenTrigger}(w_0, y_w, K_2, K_3, \{A_i, s_i, s'_i\}_{i \in [\ell_0]})$.
%
\end{itemize}
\item {\color{blue}It samples $y_u', y_w'$ uniformly at random}.
\item {\color{blue}The challenger then samples uniform coins $b_0, b_1 \gets \{0,1\}$. If $b_0 = 0$, give $(u, y_u)$ to quantum program $(U_1, \sigma[R_1])$; else give $(u, y_u')$ to quantum program $(U_1, \sigma[R_1])$.
Similarly, if $b_1 = 0$, give $(w, y_w)$ to quantum program $(U_2, \sigma[R_2])$; else give $(w, y_w')$}.
\item The outcome of the game is 1 if and only if both quantum programs successfully {\color{blue}produce $b_0' = b_0$ and $b_1' = b_1$} respectively.
\end{enumerate}
\paragraph{Hybrid 3.} %
%
%
%
\begin{enumerate}
\item {\color{red} A challenger first samples $\{A_i, s_i, s'_i\}_{i \in [\ell_0]}$ and prepares the quantum states $\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}$}. It treat the the quantum states $\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}$ as the quantum decryption key $\rho_{{\sf sk}}$ for our single-decryptor encryption scheme and the secret key ${\sf sk}$ is $\{A_i, s_i, s'_i\}_{i \in [\ell_0]}$. Similarly, let ${\sf pk} = \{R^0_i, R^1_i\}_{i \in [\ell_0]}$ where $R^0_i = {\sf iO}(A_i+s_i)$ and $R^1_i = {\sf iO}(A^\perp_i + s'_i)$.
\item It samples $y_u, y_w$ uniformly at random. {\color{blue}It also samples $y_u', y_w'$ uniformly at random}.
\item {\color{blue} Then it flips two random coins $b_0, b_1 \gets \{0,1\}$. If $b_0 = 1$, let $(u_0, Q_0) \gets {\sf Enc}({\sf pk}, y_u)$; else let $(u_0, Q_0) \gets {\sf Enc}({\sf pk}, y_u')$.
Similarly, if $b_1 = 1$, let $(w_0, Q_1) \gets {\sf Enc}({\sf pk}, y_w)$; else, let $(w_0, Q_1) \gets {\sf Enc}({\sf pk}, y_w')$}.
${\sf Enc}({\sf pk}, \cdot)$ is the encryption algorithm of the underlying single-decryptor encryption scheme using ${\sf pk}$.
\item The challenger constructs the program $P$ which hardcodes ${K_1}, K_2, K_3$. It then prepares $\rho_K$, which is $(\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P))$.
\item $\mathcal{A}$ upon receiving $\rho_K$, it runs and prepares a pair of (potentially entangled) quantum states $\sigma[R_1], \sigma[R_2]$ as well as quantum circuits $U_1, U_2$.
\item The challenger also prepares two inputs $u', w'$ as follows (as $\mathsf{GenTrigger}$ does):
\begin{itemize}
\item
Let $u_1' \gets F_2(K_2, u_0 || Q_0)$ and $u_2'\gets F_3(K_3, u_1') \oplus (u_0||Q_0)$. Let $u' = u_0 || u_1' || u_2'$.
\item
Let $w_1' \gets F_2(K_2, w_0 || Q_1)$ and $w_2'\gets F_3(K_3, w_1') \oplus (w_0||Q_1)$. Let $w' = w_0 || w_1' || w_2'$.
\end{itemize}
\item {\color{blue}The challenger again samples uniform coins $\delta_0, \delta_1 \gets \{0,1\}$. If $\delta_0 = 0$, give $(u', y_u)$ to quantum program $(U_1, \sigma[R_1])$; else give $(u', y_u')$ to quantum program $(U_1, \sigma[R_1])$.
Similarly, if $\delta_1 = 0$, give $(w', y_w)$ to quantum program $(U_2, \sigma[R_2])$; else give $(w', y_w')$}.
\item The outcome of the game is 1 if both quantum programs successfully {\color{blue}produce the answers below respectively:
\begin{itemize}
\item If $(U_1, \sigma[R_1])$ outputs 0 and $b_0 = \delta_0$, or if it outputs 1 and $b_0 \neq \delta_0$, then $(U_1, \sigma[R_1])$ succeeds. Otherwise it fails.
\item If $(U_2, \sigma[R_2])$ outputs 0 and $b_1 = \delta_1$, or if it outputs 1 and $b_1 \neq \delta_1$, then $(U_2, \sigma[R_2])$ succeeds. Otherwise it fails.
\end{itemize} }
%
\end{enumerate}
Note that the only differences of Hyb 2 and Hyb 3 are the orders of executions and {\color{blue} that the challenger prepares $u', w'$ from one of $(y_u, y_u')$ and one of $(y_w, y_w')$ respectively, instead of preparing them from $y_u, y_w$ first and choosing random $y_u', y_w'$ later}. Since we will check if the random coins match in Step 8 of Hybrid 3, the game is essentially the same to an adversary as the game in Hybrid 2.
%
\vspace{1em}
Given an algorithm $\mathcal{A}$ that wins the indistinguishability anti-piracy game for PRF in Hybrid 3 with non-negligible probability $\gamma(\lambda)$, we can build another algorithm $\mathcal{B}$ that breaks the {\color{blue} (regular) CPA-style $\gamma$-anti-piracy security (see \Cref{def:weak_ag})} of the underlying single-decryptor encryption scheme.
%
\begin{itemize}
\item $\mathcal{B}$ plays as the challenger in the game of Hybrid 3.
\item $\mathcal{B}$ will get $\rho_{{\sf sk}} = \{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}$ and ${\sf pk} = \{{\sf iO}(A_i + s_i), {\sf iO}(A^\perp_i + s'_i)\}_{i \in [\ell_0]}$ in the anti-piracy game.
\item $\mathcal{B}$ prepares $K_1, K_2, K_3$ and the program $P$. Let $\rho_K = (\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P))$.
\item $\mathcal{B}$ gives $\rho_{K}$ to $\mathcal{A}$ and $\mathcal{A}$ prepares a pair of (potentially entangled) quantum states $\sigma[R_1], \sigma[R_2]$ as well as quantum circuits $U_1, U_2$.
\item {\color{blue}$\mathcal{B}$ also samples uniform random $y_u, y_u', y_w, y_w'$ and sends $(y_u, y_u')$ and $(y_w, y_w')$ as the challenge plaintexts for the two quantum programs, to the challenger of single-decryptor encryption anti-piracy game}.
%
\item $\mathcal{B}$ then creates quantum programs $\P_1, \P_2$ which will do the following steps.
\item $\P_1$ receives challenge ciphertext $\mathsf{ct}_0 = (u_0, Q_0) $ (which will be encryption of either $y_u$ or $y_u'$), and $\P_2$ receives challenge ciphertext $\mathsf{ct}_1 = (w_0, Q_1)$ (which will be encryption of either $y_w$ or $y_w'$). They each independently prepares $u', w'$ as follows :
%
\begin{itemize}
\item
Let $u_1' \gets F_2(K_2, u_0 || Q_0)$ and $u_2'\gets F_3(K_3, u_1') \oplus (u_0||Q_0)$. Let $u' = u_0 || u_1' || u_2'$.
\item
Let $w_1' \gets F_2(K_2, w_0 || Q_1)$ and $w_2'\gets F_3(K_3, w_1') \oplus (w_0||Q_1)$. Let $w' = w_0 || w_1' || w_2'$.
\end{itemize}
\item {\color{blue} $\P_1$ gives either $(u', y_u)$ or $(u', y_u')$ depending on a random coin $\delta_0 \gets \{0,1\}$, to $(\sigma[R_1], U_{1})$;
$\P_2$ gives either $(w', y_w)$ or $(w', y_w')$ depending on random coin $\delta_1 \gets \{0,1\}$, to $(\sigma[R_2], U_{2})$}.
%
\item Then $\P_1$ and $\P_2$ respectively run $(\sigma[R_1], U_{1})$ and $(\sigma[R_2], U_{2})$ on their challenge received to output their answers $a_1$ and $a_2$.
%
{\color{blue} \item Finally, depending on answers received and the coins $\delta_0, \delta_1$, $\P_1$ and $\P_2$ does the following:
For $\P_1$: if $(\sigma[R_1], U_{1})$ outputs $0$(which means the program thinks it receives an input and its PRF evaluation):
\begin{itemize}
\item if $\delta_0 = 0$: $\P_1$ outputs 0 (for encryption of $y_u$) to the challenger.
\item else, $\delta_0 = 1$: $\P_1$ outputs 1 (for encryption of $y_u'$) to the challenger.
\end{itemize}
If $(\sigma[R_1], U_{1})$ outputs $1$ (which means the program thinks it receives an input and a random value):
\begin{itemize}
\item if $\delta_0 = 0$: $\P_1$ outputs 1 (for encryption of $y_u'$) to the challenger.
\item else, $\delta_0 = 1$: $\P_1$ outputs 0 (for encryption of $y_u$) to the challenger.
\end{itemize}
Similarly on the $\P_2$ and $(\sigma[R_2], U_2)$ side}.
\end{itemize}
We observe that the advantage of $\mathcal{B}$ in the CPA-style $\gamma$-anti-piracy game of single-decryptor encryption is the same as advantage of $\mathcal{A}$ in the indistinguishability anti-piracy game for PRF. \qed
%
%
\subsection{Our Results}
\label{sec: results}
We study a generalization of subspace states, which we refer to as \emph{coset} states. This notion has also been studied independently in a work of Vidick and Zhang \cite{vidick2021classical}, in the context of proofs of quantum knowledge from quantum money schemes.
For $A\subseteq \mathbb{F}_2^n$, and $s,s' \in \mathbb{F}_2^n$, the corresponding coset state is:
$$ \ket{A_{s,s'}} := \sum_{x \in A} (-1)^{\langle x , s' \rangle} \ket{x+s} \,,$$
where here $\langle x , s' \rangle$ denotes the inner product of $x$ and $s'$. In the computational basis, the quantum state is a superposition over all elements in the coset $A+s$, while, in the Hadamard basis, it is a superposition over all elements in $A^\perp+s'$. Let $P_{A+s}$ and $P_{A^\perp + s'}$ be programs that check membership in the cosets $A + s$ and $A^\perp + s'$ respectively. To check if a state $\ket{\psi}$ is a coset state with respect to $A, s,s'$, one can compute $P_{A+s}$ in the computational basis, and check that the outcome is $1$; then, apply $H^{\otimes n}$ followed by
$P_{A^\perp + s'}$, and check that the outcome is $1$.
\paragraph{Computational Direct Product Hardness.} Our first technical result is establishing a \emph{computational direct product hardness} property in the plain model, assuming post-quantum $\mathsf{iO}$ and one-way functions.
\begin{theorem}[Informal]
Any quantum polynomial-time adversary who receives $\ket{A_{s,s'}}$ and programs ${\sf iO}(P_{A+s})$ and ${\sf iO}(P_{A^\perp+s'})$ for uniformly random $A \subseteq{\mathbb{F}_2^n}$, $s,s' \in \mathbb{F}_2^n$, cannot produce a pair $(v,w) \in (A+s) \times (A^{\perp} + s')$, except with negligible probability in $n$.
\end{theorem}
As we mentioned earlier, this is in contrast to regular subspace states, for which a similar direct product hardness
is currently not known in the plain model, but only in a model with access to subspace membership oracles.
We then apply this property to obtain the following primitives.
%
%
%
\paragraph{Signature Tokens.} Our direct product hardness immediately implies a \emph{signature token} scheme in the plain model (from post-quantum ${\sf iO}$ and one-way functions), thus resolving the main question left open in \cite{ben2016quantum}.
\begin{theorem}[Informal]
Assuming post-quantum ${\sf iO}$ and one-way functions, there exists a signature token scheme.
\end{theorem}
In this signature token scheme, the public verification key is the pair $({\sf iO}(P_{A+s}), {\sf iO}(P_{A^\perp+s'}))$, and a signature token is the coset state $\ket {A_{s, s'}}$. Producing signatures for both messages $0$ and $1$ is equivalent to finding elements in both $A+s$ and $A^{\perp} + s'$, which violates our computational direct product hardness property.
\paragraph{Unclonable Decryption.} Unclonable decryption, also known as \emph{single-decryptor encryption}, was introduced in \cite{georgiou-zhandry20}.
Informally, a single-decryptor encryption scheme is a (public-key) encryption scheme in which the secret key is a \textit{quantum state}. The scheme satisfies a standard notion of security (in our case, CPA security), as well as the following additional security guarantee: no efficient quantum algorithm with one decryption key is able to produce two working decryption keys.
We build a single-decryptor encryption scheme using a signature tokens scheme and extractable witness encryption in a black-box way. By leveraging our previous result about the existence of a signature token scheme in the plain model, we are able to prove security without the need for the structured oracles used in the original construction of \cite{georgiou-zhandry20}.
\begin{theorem}[Informal]
Assuming post-quantum ${\sf iO}$, one-way functions, and extractable witness encryption, there exists a public-key single-decryptor encryption scheme.
\end{theorem}
\paragraph{Copy-protection of PRFs.} The notion of a copy-protection scheme was introduced by Aaronson in \cite{aaronson2009quantum} and recently explored further in \cite{ananth2020secure, coladangelo2020quantum, aaronsonnew, broadbent2021secure}.
In a copy-protection scheme, the vendor of a classical program wishes to provide a user the ability to run the program on any input, while ensuring that the functionality cannot be ``pirated'': informally, the adversary, given one copy of the program, cannot produce two programs that enable evaluating the program correctly.
Copy-protection is trivially impossible classically, since classical information can always be copied. This impossibility can be in principle circumvented if the classical program is encoded in a quantum state, due to the no-cloning principle. However, positive results have so far been limited. A copy-protection scheme \cite{coladangelo2020quantum} is known for a class of evasive programs, known as compute-and-compare programs, with provable non-trivial security against fully malicious adversaries in the Quantum Random Oracle Model (QROM). Other schemes in the plain model are only secure against restricted classes of adversaries (which behave honestly in certain parts of the protocol) \cite{ananth2020secure, kitagawa-takashi2020ssl, broadbent2021secure}. Copy-protection schemes for more general functionalities are known \cite{aaronsonnew}, but these are only secure assuming very structured oracles (which depend on the functionality that is being copy-protected).
In this work, we present a copy-protection scheme for a family of pseudorandom functions (PRFs). In such a scheme, for any classical key $K$ for the PRF, anyone in possession of a \textit{quantum} key $\rho_K$ is able to evaluate $PRF(K, x)$ on any input $x$.
The copy-protection property that our scheme satisfies is that given a quantum key $\rho_K$, no efficient algorithm can produce two (possibly entangled) keys such that these two keys allow for simultaneous correct evaluation on uniformly random inputs, with noticeable probability.
Similarly to the unclonable decryption scheme, our copy-protection scheme is secure assuming post-quantum ${\sf iO}$, one-way functions, and extractable witness encryption.
\begin{theorem}[Informal]
Assuming post-quantum ${\sf iO}$, one-way functions, and extractable witness encryption, there exists a copy-protection scheme for a family of PRFs.
\end{theorem}
We remark that our scheme requires a particular kind of PRFs, namely puncturing and extracting with small enough error (we refer to Section \ref{sec: PRF prelim} for precise definitions). However, PRFs satisfying these properties can be built from just one-way functions.
The existence of extractable witness encryption is considered to be a very strong assumption. In particular, it was shown to be impossible in general (under a special-purpose obfuscation conjecture) \cite{garg2017implausibility}. However, we emphasize that no provably secure copy-protection schemes with standard malicious security in the plain model are known at all. %
Given the central role of PRFs in the construction of many other cryptographic primitives, we expect that our copy-protection scheme, and the techniques developed along the way, will play an important role as a building block to realize \textit{unclonable} versions of other primitives.
\vspace{2mm}
To avoid the use of extractable witness encryption, we put forth a (information-theoretic) conjecture about a \emph{monogamy of entanglement} property of coset states, which we discuss below
\footnote{This conjecture is proved true in the follow-up work by Culf and Vidick \cite{culfvidick2021cosetsproof} after the first version of this paper.}.
Assuming this conjecture is true, we show that both unclonable decryption and copy-protection of PRFs can be constructed \emph{without} extractable witness encryption, by relying instead on compute-and-compare obfuscation \cite{wichs2017obfuscating, goyal2017lockable} (more details on the latter can be found in Section \ref{sec:cc}).
\begin{theorem}[Informal]
Assuming post-quantum ${\sf iO}$, one-way functions, and obfuscation of compute-and-compare programs against unpredictable distributions, there exist: (i) a public-key single-decryptor encryption scheme, and (ii) a copy-protection scheme for a family of PRFs.
\end{theorem}
As potential evidence in support of the monogamy-of-entanglement conjecture, we prove a weaker version of the monogamy of entanglement property, which we believe will still be of independent interest (more details on this are below).
\begin{remark}While ${\sf iO}$ was recently constructed based on widely-believed computational assumptions~\cite{JLS20-io-wellfounded}, the latter construction is not quantum resistant, and the situation is less clear quantumly. However, several works have proposed candidate post-quantum obfuscation schemes ~\cite{BGMZ18, WeeWichs20,BDGM20}, and based on these works ${\sf iO}$ seems plausible in the post-quantum setting as well.
\end{remark}
\begin{remark}
Compute-and-compare obfuscation against unpredictable distributions is known to exist assuming LWE (or ${\sf iO}$) and assuming the existence of Extremely Lossy Functions (ELFs) \cite{zhandry2019magic} \cite{wichs2017obfuscating, goyal2017lockable}. Unfortunately, the only known constructions of ELFs rely on hardness assumptions that are broken by quantum computers (exponential hardness of decisional Diffie-Hellman). To remedy this, we give a construction of computate-and-compare obfuscation against \emph{sub-exponentially} unpredictable distributions, from plain LWE (see Theorem \ref{thm: cc sub-exp from lwe}, and its proof in \Cref{sec:CC_quantum_aux}). The latter weaker obfuscation is sufficient to prove security of our single-decryptor encryption scheme, and copy-protection scheme for PRFs, if one additionally assumes \emph{sub-exponentially} secure ${\sf iO}$ and one-way functions.
\end{remark}
\paragraph{Monogamy-of-Entanglement.}
As previously mentioned, we conjecture that coset states additionally satisfy a certain (information-theoretic) \emph{monogamy of entanglement} property, similar to the one satisfied by BB84 states, which is studied extensively in \cite{tomamichel2013monogamy}. Unlike the monogamy property of BB84 states, the monogamy property we put forth is well-suited for applications with public verification, in a sense made more precise below.
This monogamy property states that Alice, Bob and Charlie cannot cooperatively win the following game with a challenger, except with negligible probability. The challenger first prepares a uniformly random coset state $\ket {A_{s, s'}}$ and gives the state to Alice. Alice outputs two (possibly entangled) quantum states and sends them to Bob and Charlie respectively. Finally, Bob and Charlie both get the description of the subspace $A$. The game is won if Bob outputs a vector in $A+s$ and Charlie outputs a vector in $A^\perp+s'$.
Notice that if Alice were told $A$ before she had to send the quantum states to Bob and Charlie, then she could recover $s$ and $s'$ (efficiently) given $\ket{A_{s,s'}}$. Crucially, $A$ is only revealed to Bob and Charlie \emph{after} Alice has sent them the quantum states (analogously to the usual monogamy-of-entanglement game based on BB84 states, where $\theta$ is only revealed to Bob and Charlie after they receive their states from Alice.).
We note that the hardness of this game is an \emph{information-theoretic} conjecture. As such, there is hope that it can be proven unconditionally.
Under this conjecture, we show that the problem remains hard (computationally) even if Alice additionally receives the programs ${\sf iO}(P_{A+s})$ and ${\sf iO}(P_{A^{\perp}+s'})$. Based on this result, we then obtain unclonable decryption and copy-protection of PRFs from post-quantum ${\sf iO}$ and one-way functions, and compute-and-compare obfuscation against unpredictable distributions. We thus remove the need for extractable witness encryption (more details on this are provided in the technical overview, Section \ref{sec: tech ovw direct product hardness}).
As evidence in support of our conjecture, we prove a weaker information-theoretic monogamy property, namely that Alice, Bob and Charlie cannot win at a monogamy game that is identical to the one described above, except that at the last step, Bob and Charlie are each required to return a pair in $(A+s) \times ( A^{\perp} + s')$, instead of a single element each. Since coset states have more algebraic structure than BB84 states, a more refined analysis is required to prove this (weaker) property compared to that of \cite{tomamichel2013monogamy}. We again extend this monogamy result to the case where Alice receives programs ${\sf iO}(P_{A+s})$ and ${\sf iO}(P_{A^{\perp}+s'})$.
We emphasize that our monogamy result for coset states differs from the similar monogamy result for BB84 states in one crucial way: the result still holds when Alice receives programs that allow her to verify the correctness of her state (namely ${\sf iO}(P_{A+s})$ and ${\sf iO}(P_{A^{\perp}+s'})$). This is not the case for the BB84 monogamy result. In fact,
Lutomirski \cite{lutomirski2010online} showed that an adversary who is given $\ket {x^\theta}$ and a public verification oracle that outputs $1$ if the input state is correct and $0$ otherwise, can efficiently copy the state $\ket {x^\theta}$. At the core of this difference is the fact that coset states are highly entangled, whereas strings of BB84 states have no entanglement at all.
For this reason, we believe that the monogamy property of coset states may be of independent interest, and may find application in contexts where public verification of states is important. %
\paragraph{Proof for the Strong Monogamy-of-Entanglement Conjecture.}
After the first version of this paper, Vidick and Culf posted a follow-up paper \cite{culfvidick2021cosetsproof} that proved the strong monogamy-of-entanglement conjecture stated above (formalized in \Cref{sec: monogamy conjectured}). We thank Vidick and Culf for following up on our work.
The readers can therefore consider the ``strong monogamy-of-entanglement conjecture'' removed from the assumptions in all formal statements in this paper.
\paragraph{Acknowledgements}
A.C. is supported by the Simons Institute for the Theory of Computing, through a Quantum Postdoctoral Fellowship. J. L., Q. L. and M. Z. are supported by the NSF. J. L. is also supported by Scott Aaronson's Simons Investigator award. The authors are grateful for the support of the Simons Institute, where this collaboration was initiated.
\section{Technical Overview}
\label{sec: tech overview}
\subsection{Computational Direct Product Hardness for Coset States}
\label{sec: tech ovw direct product hardness}
Our first technical contribution is to establish a \textit{computational} direct product hardness property for coset states. In this section, we aim to give some intuition for the barrier to proving such a property for regular subspace states, and why resorting to coset states helps.
We establish the following: a computationally bounded adversary who receives $\ket{A_{s,s'}}$ and programs ${\sf iO}(P_{A+s})$ and ${\sf iO}(P_{A^\perp+s'})$ for uniformly random $A, s,s'$, cannot produce a pair $(v,w)$, where $v \in A +s $ and $w \in A^{\perp} + s'$, except with negligible probability.
The first version of this direct product hardness property involved regular subspace states, and was \textit{information-theoretic}. It was proven by Ben-David and Sattath \cite{ben2016quantum}, and it established the following: given a uniformly random subspace state $\ket{A}$, where $A \subseteq \mathbb{F}_2^n$ has dimension $n/2$, no adversary can produce a pair of vectors $v,w$ such that $v \in A$ and $w \in A^\perp$ respectively, even with access to oracles for membership in $A$ and in $A^\perp$.
The first successful instantiation of the membership oracles in the plain model is due to Zhandry, in the context of public-key quantum money \cite{zhandry2019quantum}. Zhandry showed that replacing the membership oracles with indistinguishability obfuscations of the membership programs $P_A$ and $P_{A^{\perp}}$ is sufficient to prevent an adversary from copying the subspace state, and thus is sufficient for public-key quantum money. In what follows, we provide some intuition as to how one proves this ``computational no-cloning'' property, and why the same proof idea does not extend naturally to the direct product hardness property for regular subspace states.
In \cite{zhandry2019quantum}, Zhandry shows that ${\sf iO}$ realizes what he refers to as a \textit{subspace-hiding obfuscator}. A subspace hiding obfuscator ${\sf shO}$ has the property that any computationally bounded adversary who chooses a subspace $A$ cannot distinguish between ${\sf shO}(P_A)$ and ${\sf shO}(P_B)$ for a uniformly random superspace $B$ of $A$ (of not too large dimension). In turn, a subspace hiding obfuscator can then be used to show that an adversary who receives $\ket{A}$, ${\sf shO}(P_A)$ and ${\sf shO}(P_{A^{\perp}})$, for a uniformly random $A$, cannot produce two copies of $\ket{A}$. This is done in the following way. For the rest of the section, we assume that $A \subseteq \mathbb{F}_2^n$ has dimension $n/2$.
\begin{itemize}
\item Replace ${\sf shO}(P_A)$ with ${\sf shO}(P_B)$ for a uniformly random superspace $B$ of $A$, where $\text{dim}(B) = \frac34 n$. Replace ${\sf shO}(P_{A^{\perp}})$ with ${\sf shO}(P_C)$ for a uniformly random superspace $C$ of $A^{\perp}$, where $\text{dim}(C) = \frac{3}{4}n$.
\item Argue that the task of copying a subspace state $\ket{A}$, for a uniformly random subspace $C^{\perp} \subseteq A \subseteq B$ (even knowing $B$ and $C$ directly) is just as hard as the task of copying a uniformly random subspace state of dimension $\ket{A'} \subseteq \mathbb{F}_2^{n/2}$ where $\text{dim}(A') = \frac{n}{4}$. The intuition for this is that knowing $C^{\perp}$ fixes $\frac{n}{4}$ dimensions out of the $\frac{n}{2}$ original dimensions of $A$. Then, you can think of the first copying task as equivalent to the second up to a change of basis.
Such reduction completely removes the adversary's knowledge about the membership programs.
%
\item The latter task is of course hard (it would even be hard with access to membership oracles for $A'$ and $A'^{\perp}$).
\end{itemize}
One can try to apply the same idea to prove a \emph{computational direct product hardness property} for subspace states, where the task is no longer to copy $\ket{A}$, but rather we wish to show that a bounded adversary receiving $\ket{A}$ and programs ${\sf iO}(P_{A})$ and ${\sf iO}(P_{A^\perp})$, for uniformly random $A$, cannot produce a pair $(v,w)$, where $v \in A$ and $w \in A^{\perp}$. Applying the same replacements as above using ${\sf shO}$ allows us to reduce this task to the task of finding a pair of vectors in $A \times A^{\perp}$ given $\ket{A}$,$B,C$, such that $C^{\perp} \subseteq A \subseteq B$. Unfortunately, unlike in the case of copying, this task is easy, because any pair of vectors in $C^{\perp} \times B^{\perp}$ also belongs to $A \times A^{\perp}$. This is the technical hurdle that ones runs into when trying to apply the proof idea from \cite{zhandry2019quantum} to obtain a computational direct hardness property for subspace states.
Our first result is that we overcome this hurdle by using coset states. In the case of cosets, the natural analog of the argument above results in a replacement of the program that checks membership in $A+s$ with a program that checks membership in $B+s$. Similarly, we replace $A^{\perp}+s'$ with $C+s'$. The crucial observation is that, since $B+s = B+s+t$ for any $t \in B$, the programs $P_{B+s}$ and $P_{B+s+t}$ are functionally equivalent. So, an adversary who receives ${\sf iO}(P_{B+s})$ cannot distinguish this from ${\sf iO}(P_{B+s+t})$ for any $t$. We can thus argue that $t$ functions as a randomizing mask that prevents the adversary from guessing $s$ and finding a vector in $A+s$.
\iffalse
\revise{
Let us first recall direct product hardness for subset states \cite{aaronson2012quantum,ben2016quantum}. It says given a random subspace state $\ket A$, no adversary can produce two non-zero vectors in $A$ and $A^\perp$ respectively, even with access to subspace membership oracles of $A$ and $A^\perp$.
Based on this, we first establish an information-theoretic direct product hardness for coset states, by a simple random self-reduction. The property is the following: given a random coset state $\ket {A_{s, s'}}$, no adversary can produce two vectors that are in $A + s$ and $A^\perp + s'$ respectively, even with access to membership checking oracles $A+s$ and $A^\perp + s'$.
The idea is the following: given a state $\ket A$, a reduction algorithm $\mathcal{A}$ does the following:
\begin{enumerate}
\item Picks random $s, s'$ and constructs a coset state $\ket {A_{s, s'}}$ efficiently;
\item Then feeds the coset to the other adversary, which breaks the direct product hardness of coset states;
\item Whenever the other adversary wins, if finds $u, v \in A + s, A^\perp + s'$. $\mathcal{A}$ answers $u - s, v - s'$.
\end{enumerate}
Note that $u - s, v - s'$ are in $A, A^\perp$ respectively. The remaining is to argue they are both non-zero with high probability.
Because $A$ is of dimension $n/2$, there are $2^{n/2}$ different vectors in $A + s$. Similarly, there are $2^{n/2}$ different vectors in $A^\perp + s'$. Thus, there are totol $2^{n/2} \times 2^{n/2}$ different choices of vectors that lead to the same coset state $\ket {A_{s, s'}}$. Fixing outputs $u, v$, there are at most $2 \times 2^{n/2}$ vectors chosen in the first step. Thus, the answers $u-s, v - s'$ are both non-zero with probability at least $1 - 2^{-n/2 + 1}$.
\vspace{0.5em}
Next let us look at the computational direct product hardness: assuming post-quantum $\mathsf{iO}$ and one-way functions: a bounded adversary who receives $\ket{A_{s,s'}}$ and program obfuscations ${\sf iO}(P_{A+s})$ and ${\sf iO}(P_{A^\perp+s'})$ for uniformly random $A, s,s'$, cannot produce a pair $(v,w)$, where $v \in A +s $ and $w \in A^{\perp} + s'$.
We replace its oracle access to $A+s$ and $A^\perp + s'$ with the program obfuscations. Ideally, we hope ${\sf iO}$ would hide all information about these two cosets and only behave like two black-box membership checking oracles. Indeed, we show this is roughly the case, by invoking the security of subspace hiding obfuscation and ${\sf iO}$.
To prove the property, we rely on the subspace hiding obfuscation (${\sf shO}$) developed by Zhandry \cite{zhandry2019quantum}. ${\sf shO}$ takes a subspace $A \subset \mathbb{F}_2^n$ and outputs the program obfuscation ${\sf shO}(A)$. ${\sf shO}(A)$ behaves as a membership checking program, that outputs $1$ if the input vector $x$ is in $A$ and $0$ otherwise. Its security ensures that no efficient adversary can distinguish between ${\sf shO}(A)$ and ${\sf shO}(B)$ for a random superspace $B$ of $A$, as long as $|\mathbb{F}_2|^{n - \dim(B)}$ is exponential.
We also observe that $P_{A+s}$ has the same functionality as ${\sf shO}(A)(\cdot - s)$.
The program ${\sf shO}(A)(\cdot - s)$ takes an input $x$, it first subtracts $s$ from $x$ to obtain a new vector and run ${\sf shO}(A)$ on the new input.
For simplicity, we denote by ${\sf shO}_A(\cdot - s)$.
Let us look at why the computational direct product hardness holds, by a sequence of (informal) hybrids.
\qipeng{probably state these without hybrids. although hybrids make it clean. }
\begin{itemize}
\item \emph{Hybrid 0}. An adversary is given a coset state $\ket{ A_{s, s'}}$ together with ${\sf iO}(P_{A+s})$, ${\sf iO}(P_{A^\perp + s'})$.
\item \emph{Hybrid 1}. An adversary is given a coset state $\ket{ A_{s, s'}}$ together with ${\sf iO}({\sf shO}_A(\cdot - s))$, ${\sf iO}({\sf shO}_{A^\perp}(\cdot - s'))$.
Because the programs are functionally equivalent, no efficient adversary can distinguish between Hybrid 0 and Hybrid 1.
\item \emph{Hybrid 2}. An adversary is given a coset state $\ket{ A_{s, s'}}$ together with ${\sf iO}({\sf shO}_B(\cdot - s))$, ${\sf iO}({\sf shO}_{C^\perp}(\cdot - s'))$.
Here $B$ is a random superspace of $A$, of dimension $3 n/4$. Similarly, $C^\perp$ is a random superspace of $A^\perp$, of dimension $3 n/4$. We can invoke the security of ${\sf shO}$ here.
\item \emph{Hybrid 3}. An adversary is given a coset state $\ket{ A_{s, s'}}$ together with ${\sf iO}({\sf shO}_B(\cdot - s - t))$, ${\sf iO}({\sf shO}_{C^\perp}(\cdot - s' - t'))$. $t, t'$ are random vectors in $B, C^\perp$.
Since $t$ is a vector in $B$, adding/subtracting $t$
to a vector $x$ does not change its membership of $B + s$. It holds similarly for $t'$. Thus, such modification does not change the programs functionality and we can invoke the security of ${\sf iO}$.
\item \emph{Hybrid 4}. An adversary is given a coset state $\ket{ A_{s, s'}}$ together with the descriptions $B, s + t$ and $C^\perp, s' + t'$.
Notice that the descriptions $B, s + t$ and $C^\perp, s' + t'$ are enough to construct those program obfuscation in Hybrid 3, the advantage in Hybrid 3 is at most the advantage in Hybrid 4.
\end{itemize}
Finally, we argue even in Hybrid 4, an (unbounded) adversary can not win the direct product game. Intuitively, both $B$ ....
}
\fi
\paragraph{\textbf{Signature Tokens.}}
The computational direct product hardness immediately gives a signature token scheme in the plain model:
\begin{itemize}
\item Alice samples a key $(A,s,s')$ uniformly at random. This constitutes her secret key. The verification key is $({\sf iO}(P_{A+s}), {\sf iO}(P_{A^{\perp}+s'}))$. A signature token is $\ket{A_{s,s'}}$.
\item Anyone in possession of a token can sign message $0$ by outputting a string $v \in A+s$ (this can be obtained by measuring the token in the computational basis), and can sign message $1$ by outputting a string $w \in A^{\perp}+s'$ (this can be done by measuring the token in the Hadamard basis).
\item Signatures can be publicly verified using Alice's public key.
\end{itemize}
If an algorithm produces both signatures for messages $0$ and $1$, it finds vectors $v \in A + s$ and $w \in A^\perp + s'$, which violates computational direct product hardness.
\subsection{Unclonable Decryption} Our second result is an \emph{unclonable decryption} scheme (also known as a \emph{single-decryptor encryption} scheme \cite{georgiou-zhandry20} - we will use the two terms interchangeably in the rest of the paper) from black-box use of a signature token scheme and extractable witness encryption. This construction removes the need for structured oracles, as used in the construction of \cite{georgiou-zhandry20}.
Additionally, we show that, assuming the conjectured monogamy property described in Section \ref{sec: results}, we obtain an unclonable decryption scheme from just ${\sf iO}$ and post-quantum one-way functions, where ${\sf iO}$ is used to construct obfuscators for both subspace-membership programs and compute-and-compare programs~\cite{goyal2017lockable,wichs2017obfuscating}.
In this overview, we focus on the construction from the monogamy property, as we think it is conceptually more interesting.
Recall that a single-decryptor encryption scheme is a public-key encryption scheme in which the secret key is a quantum state. On top of the usual encryption security notions, one can define ``single-decryptor'' security: this requires that it is not possible for an adversary who is given the secret key to produce two (possibly entangled) decryption keys, which both enable simultaneous successful decryption of ciphertexts. A simplified version of our single-decryptor encryption scheme is the following. Let $n \in \mathbb{N}$.
\begin{itemize}
\item The key generation procedure samples uniformly at random $A \subseteq \mathbb{F}_2^n$, with $\text{dim}(A) = \frac{n}{2}$ and $s, s' \in \mathbb{F}_2^n$ uniformly at random. The public key is the pair $({\sf iO}(P_{A+s}), {\sf iO}(P_{A^\perp + s'}))$. The (quantum) secret key is the coset state $\ket {A_{s, s'}}$.
\item To encrypt a message $m$, sample uniformly $r \leftarrow \{0,1\}$, and set $R = {\sf iO}(P_{A+ s})$ if $r = 0$ and $R = {\sf iO}(P_{A^\perp + s'})$ if $r = 1$. Then, let $C$ be the following program: \vspace{2mm}
\\
\quad $C$: on input $v$, output the message $m$ if $R(v) = 1$ and otherwise output $\bot$.
\vspace{2mm}
\\
The ciphertext is then $(r, {\sf iO}(C))$.
\item To decrypt a ciphertext $(r, {\sf iO}(C))$ with the quantum key $\ket {A_{s, s'}}$, one simply runs the program ${\sf iO}(C)$ coherently on input $\ket {A_{s, s'}}$ if $r = 0$, and on $H^{\otimes n} \ket {A_{s, s'}}$ if $r=1$.
\end{itemize}
In the full scheme, we actually amplify security by sampling $r \leftarrow \{0,1\}^{\lambda}$, and having $\lambda$ coset states, but we choose to keep the presentation in this section as simple as possible.
The high level idea for single-decryptor security is the following.
Assume for the moment that ${\sf iO}$ were an ideal obfuscator (we will argue after this that ${\sf iO}$ is good enough). Consider a pirate who receives a secret key, produces two copies of it, and gives one to Bob and the other to Charlie. Suppose both Bob and Charlie can decrypt ciphertexts $(r, {\sf iO}(C))$ correctly with probability close to $1$, over the randomness in the choice of $r$ (which is crucially chosen only after Bob and Charlie have received their copies). %
Then, there must be some efficient quantum algorithm, which uses Bob's (resp. Charlie's) auxiliary quantum information (whatever state he has received from the pirate), and is able to output a vector in $A + s$. This is because in the case of $r = 0$, the program $C$ outputs the plaintext message $m$ exclusively on inputs $v \in A + s$. Similarly, there must be an algorithm that outputs a vector in $A^{\perp} + s'$ starting from Bob's (resp. Charlie's) auxiliary quantum information. Notice that this doesn't imply that Bob can \textit{simultaneously} output a pair in $(A+s) \times (A^{\perp} +s')$, because explicitly recovering a vector in one coset might destroy the auxiliary quantum information preventing recovery of a vector in the other (and this very fact is of course crucial to the direct product hardness). Hence, in order to argue that it is not possible for both Bob and Charlie to be decrypting with probability close to $1$, we have to use the fact that Bob and Charlie have separate auxiliary quantum information, and that each of them can recover vectors in $A+s$ or $A^{\perp}+s'$, which means that this can be done simultaneously, now violating the direct product hardness property.
The crux of the security proof is establishing that ${\sf iO}$ is a good enough obfuscator to enable this argument to go through.
To this end, we first notice that there is an alternative way of computing membership in $A+s$, which is functionally equivalent to the program $C$ defined above.
Let ${\sf Can}_A(s)$ be a function that computes the lexicographically smallest vector in $A + s$ (think of this as a representative of the coset). It is not hard to see that a vector $t$ is in $A + s$ if and only if ${\sf Can}_A(t) = {\sf Can}_A(s)$. Also ${\sf Can}_A$ is efficiently computable given $A$. Therefore, a functionally equivalent program to $C$, in the case that $r=0$, is:
\vspace{0.3em}
\quad $\widetilde{C}$: on input $v$, output $m$ if ${\sf Can}_A(v) = {\sf Can}_A(s)$, otherwise output $\bot$.
\vspace{0.3em}
By the security of ${\sf iO}$, an adversary can't distinguish ${\sf iO}(C)$ from ${\sf iO}(\widetilde{C})$.
The key insight is that now the program $\widetilde{C}$ is a \textit{compute-and-compare} program \cite{goyal2017lockable, wichs2017obfuscating}. The latter is a program described by three parameters: an efficiently computable function $f$, a target $y$ and an output $z$. The program outputs $z$ on input $x$ if $f(x) = y$, and otherwise outputs $\bot$.
In our case, $f ={\sf Can}_A$, $y = {\sf Can}_A(s)$, and $z = m$.
Goyal et al.~\cite{goyal2017lockable} and Wichs et al.~\cite{wichs2017obfuscating} show that, assuming LWE or assuming ${\sf iO}$ and certain PRGs, a compute-and-compare program can be obfuscated provided $y$ is (computationally) unpredictable given the function $f$ and the auxiliary information. More precisely, the obfuscation guarantee is that the obfuscated compute-and-compare program is indistinguishable from the obfuscation of a (simulated) program that outputs zero on every input (notice, as a sanity check, that if $y$ is unpredictable given $f$, then the compute-and-compare program must output zero almost everywhere as well). We will provide more discussion on compute-and-compare obfuscation for unpredictable distributions in the presence of quantum auxiliary input in \Cref{sec:cc} and \Cref{sec:CC_quantum_aux}.
\begin{itemize}
\item By the security of ${\sf iO}$, we can replace the ciphertext $(0, {\sf iO}(C))$, with the ciphertext $(0, {\sf iO}(\mathsf{CC}.{\sf Obf}(\widetilde{C})))$ where $\mathsf{CC}.{\sf Obf}$ is an obfuscator for compute-and-compare programs (this is because $C$ has the same functionality as $\mathsf{CC}.{\sf Obf}(\widetilde{C})$).
\item By the security of \textsf{CC.Obf}, we can replace the latter with $(0, {\sf iO}(\mathsf{CC}.{\sf Obf}(Z)))$, where $Z$ is the zero program. It is clearly impossible to decrypt from the latter, since no information about the message is present.
\end{itemize}
Thus, assuming ${\sf iO}$ cannot be broken, a Bob that is able to decrypt implies an adversary breaking the compute-and-compare obfuscation. This implies that there must be an efficient algorithm that can predict $y = {\sf Can}_A(s)$ with non-negligible probability given the function ${\sf Can}_A$ and the auxiliary information received by Bob. Similarly for Charlie.
Therefore, if Bob and Charlie, with their own quantum auxiliary information, can both independently decrypt respectively $(0, {\sf iO}(C))$ and $(1, {\sf iO}(C'))$ with high probability (where here $C$ and $C'$ only differ in that the former releases the encrypted message on input a vector in $A+s$, and $C'$ on input a vector in $A^{\perp} + s'$), then there exist efficient quantum algorithms for Bob and Charlie that take as input the descriptions of ${\sf Can}_A(\cdot)$ and ${\sf Can}_{A^{\perp}}(\cdot)$ respectively (or of the subspace $A$), and their respective auxiliary information, and recover ${\sf Can}_A(s)$ and ${\sf Can}_{A^\perp}(s')$ respectively with non-negligible probability. Since ${\sf Can}_A(s) \in A + s$ and ${\sf Can}_{A^\perp}(s') \in A^\perp + s'$, this violates the strong monogamy property of coset states described in Section \ref{sec: results}.
Recall that this states that Alice, Bob and Charlie cannot cooperatively win the following game with a challenger, except with negligible probability. The challenger first prepares a uniformly random coset state $\ket {A_{s, s'}}$ and gives the state to Alice. Alice outputs two (possibly entangled) quantum states and sends them to Bob and Charlie respectively. Finally, Bob and Charlie both get the description of the subspace $A$. The game is won if Bob outputs a vector in $A+s$ and Charlie outputs a vector in $A^\perp+s'$. Crucially, in this monogamy property, Bob and Charlie
will both receive the description of the subspace $A$ in the final stage, yet it is still not possible for both of them to be simultaneously successful.
What allows to deduce the existence of efficient extracting algorithms is the fact that the obfuscation of compute-and-compare programs from \cite{goyal2017lockable, wichs2017obfuscating} holds provided $y$ is computationally unpredictable given $f$ (and the auxiliary information). Thus, an algorithm that breaks the obfuscation property implies an efficient algorithm that outputs $y$ (with noticeable probability) given $f$ (and the auxiliary information).
In our other construction from signature tokens and extractable witness encryption, one can directly reduce unclonable decryption security to direct product hardness. We do not discuss the details of this construction in this section, instead we refer the reader to Section \ref{sec: unclonable dec witness enc}.
\subsection{Copy-Protecting PRFs}
Our last contribution is the construction of copy-protected PRFs assuming post-quantum ${\sf iO}$, one-way functions and the monogamy property we discussed in the previous section. Alternatively just as for unclonable decryption, we can do away with the monogamy property by assuming extractable witness encryption.
A copy-protectable PRF is a regular PRF $F: \{0,1\}^k \times \{0,1\}^m \rightarrow \{0,1\}^{m'}$, except that it is augmented with a \textit{quantum key} generation procedure, which we refer to as $\textsf{QKeyGen}$. This takes as input the classical PRF key $K$ and outputs a quantum state $\rho_K$. The state $\rho_K$ allows to efficiently compute $F(K, x)$ on any input $x$ (where correctness holds with overwhelming probability). Beyond the standard PRF security, the copy-protected PRF satisfies the following additional security guarantee:
any computationally bounded adversary that receives $\rho_K$ cannot process $\rho_K$ into two states, such that each state enables efficient evaluation of $F(K, \cdot)$ on uniformly random inputs.
A simplified version of our construction has the following structure. For the rest of the section, we take all subspaces to be of $\mathbb{F}_2^n$ with dimension $n/2$.
\begin{itemize}
\item The quantum key generation procedure $\textsf{QKeyGen}$ takes as input a classical PRF key $K$ and outputs a quantum key. The latter consists of a number of uniformly sampled coset states $| (A_i)_{s_i, s_i'} \rangle$, for $i \in [\lambda]$, together with a (classical) \textit{obfuscation} of the classical program $P$ that operates as follows.
$P$ takes an input of the form $(x, v_1, \ldots, v_{\lambda})$; checks that each vector $v_i$ belongs to the correct coset ($A_i + s_i$ if $x_i = 0$, and $A_i^{\perp} + s_i'$ if $x_i = 1$); if so, outputs the value $F(K, x)$, otherwise outputs $\perp$.
\item A party in possession of the quantum key can evaluate the PRF on input $x$ as follows: for each $i$ such that $x_i = 1$, apply $H^{\otimes n}$ to $|(A_i)_{s_i, s_i'} \rangle$. Measure each resulting coset state in the standard basis to obtain vectors $v_1,\ldots, v_{\lambda}$. Run the obfuscated program on input $(x, v_1, \ldots, v_{\lambda})$.
\end{itemize}
Notice that the program has the classical PRF key $K$ hardcoded, as well as the values $A_i, s_i, s_i'$, so giving the program in the clear to the adversary would be completely insecure: once the adversary knows the key $K$, he can trivially copy the functionality $F(K, \cdot)$; and even if the key $K$ is hidden by the obfuscation, but the $A_i, s_i, s_i'$ are known, a copy of the (classical) obfuscated program $P$, together with the $A_i, s_i, s_i'$ is sufficient to evaluate $F(K, \cdot)$ on any input.
So, the hope is that an appropriate obfuscation will be sufficient to hide all of these parameters. If this is the case, then the intuition for why the scheme is secure is that in order for two parties to simultaneously evaluate correctly on uniformly random inputs, each party should be able to produce a vector in $A_i+s$ or in $A_i^{\perp} + s_i'$. If the two parties accomplish this separately, then this implies that it is possible to simultaneously extract a vector in $A_i+s_i$ and one in $A_i^{\perp} + s_i'$, which should not be possible. \footnote{Again, we point out that we could not draw this conclusion if only a single party were able to do the following two things, each with non-negligible probability: produce a vector in $A+s_i$ and produce a vector in $A^{\perp}+s_i'$. This is because in a quantum world, being able to perform two tasks with good probability, does not imply being able to perform both tasks simultaneously. So it is crucial that both parties are able to separately recover the vectors.}
We will use ${\sf iO}$ to obfuscate the program $P$. In the next part of this overview, we will discuss how we are able to deal with the fact that the PRF key $K$ and the cosets are hardcoded in the program $P$. First of all, we describe a bit more precisely the copy-protection security that we wish to achieve. The latter is captured by the following security game between a challenger and an adversary $(A, B, C)$:
\begin{itemize}
\item The challenger samples a uniformly random PRF key $K$ and runs $\textsf{QKeyGen}$ to generate $\rho_K$. Sends $\rho_K$ to $A$.
\item $A$ sends quantum registers to two spatially separated parties $B$ and $C$.
\item The challenger samples uniformly random inputs $x,x'$ to $F(K,\cdot)$. Sends $x$ to $B$ and $x'$ to $C$.
\item $B$ and $C$ return $y$ and $y'$ respectively to the challenger.
\end{itemize}
$(A, B, C)$ wins if $y = F(K, x)$ and $y' = F(K, x')$.
Since the obfuscation we are using is not VBB, but only ${\sf iO}$, there are two potential issues with security. $B$ and $C$ could be returning correct answers not because they are able to produce vectors in the appropriate cosets, but because:
\begin{itemize}
\item[(i)] ${\sf iO}(P)$ leaks information about the PRF key $K$.
\item[(ii)] ${\sf iO}(P)$ leaks information about the cosets.
\end{itemize}
We handle issue (i) via a delicate ``puncturing'' argument \cite{sahai2014use}. At a high level, a puncturable PRF $F$ is a PRF augmented with a procedure that takes a key $K$ and an input value $x$, and produces a ``punctured'' key $K\setminus \{x\}$, which enables evaluation of $F(K, \cdot)$ at any point other than $x$. The security guarantee is that a computationally bounded adversary possessing the punctured key $K\setminus \{x\}$ cannot distinguish between $F(K, x)$ and a uniformly random value (more generally, one can puncture the key at any polynomially sized set of points). Puncturable PRFs can be obtained from OWFs using the \cite{GGM86} construction \cite{boneh2013constrained}. %
By puncturing $K$ precisely at the challenge inputs $x$ and $x'$, one is able to hardcode a punctured PRF key $K\setminus \{x,x'\}$ in the program $P$, instead of $K$, and setting the output of program $P$ at $x$ to uniformly random $z$ and $z'$, instead of to $F(K,x)$ and $F(K,x')$ respectively. The full argument is technical, and relies on the ``hidden trigger'' technique introduced in \cite{sahai2014use}, \revise{which allows the ``puncturing'' technique to work even when the program $P$ is generated before $x$ and $x'$ are sampled}.
Once we have replaced the outputs of the program $P$ on the challenge inputs $x,x'$ with uniformly random outputs $z, z'$, we can handle issue (ii) in a similar way to the case of unclonable decryption in the previous section.
By the security of ${\sf iO}$, we can replace the behaviour of program $P$ at $x$ by a suitable functionally equivalent compute-and-compare program that checks membership in the appropriate cosets. We then replace this by an obfuscation of the same compute-and-compare program, and finally by an obfuscation of the zero program. We can then perform a similar reduction as in the previous section from an adversary breaking copy-protection security (and thus the security of the compute-and-compare obfuscation) to an adversary breaking the monogamy of entanglement game described in the previous section.
As in the previous section, we can replace the reliance on the conjectured monogamy property by extractable witness encryption. In fact, formally, we directly reduce the security of our copy-protected PRFs to the security of our unclonable decryption scheme.
\begin{comment}
by the security of ${\sf iO}$, we can replace the behaviour of the program $P$ at $x$ (and $x'$) with the following functionally equivalent behaviour:
\begin{itemize}
\item On input $(x, v_1,..,v_n)$, check that, for each $i$: $\textsf{Can}_{A_i}(v_i) = \textsf{Can}_{A_i}(s_i)$ if $x_i = 0$, and $\textsf{Can}_{A_i^{\perp}}(v_i) = \textsf{Can}_{A_i^{\perp}}(s_i')$ if $x_i = 1$. If so, output $z$ (and similarly on input $x'$).
\end{itemize}
The main insight is that the latter program is easily seen to be a \textit{compute-and-compare} program \cite{} \Jiahui{didn't we already cite CC papers before} (upon concatenating all of the checks). Such programs are known to be VBB-obfuscatable (assuming ${\sf iO}$). More generally, a \textit{compute-and-compare} program is specified by an efficiently computable function $f$, a point $y$ in the range of $f$, and a locked output $z$. The compute-and-compare program $\textsf{CC}[f,y,z]$ behaves as follows:
\begin{equation*}
\mathsf{CC}[f,y](x) = \begin{cases} 1 & \text{if } f(x) = y\,,\\
0 &\text{if } f(x) \neq y \,. \end{cases}
\end{equation*}
The VBB obfuscation result of \cite{goyal2017lockable, wichs2017obfuscating} asserts that there exists an obfuscation algorithm $\textsf{Obf}$ such that the program $\textsf{Obf}(\mathsf{CC}[f,y](x))$ is indistinguishable from an obfuscation of the zero program, provided $y$ is computationally unpredictable given $f$.
The program we wrote earlier is a compute-and-compare program with
We can thus further replace this program with a VBB obfuscation of it; and further replace the latter with an obfuscation of the zero program. Thus, copy-protection security holds provided the compute-and-compare obfuscation is secure. Crucially, the latter is secure if $y$ is computationally unpredictable given $f$, which in our case translates to $s_1,\ldots, s_n$ being unpredictable given $A_1,..,A_n$. It is not at all immediate that this hold: crucially, we ask that the parties $B$ and $C$ in the copy-protection game should not be able to recover $s_1,s_1', \ldots, s_n, s_n'$ even given the subspaces $A_1, \ldots, A_n$ in the clear. Notice that an adversary who is given the coset states \textit{and} the description of the subspaces themselves, can easily recover $s_1,s_1',\ldots, s_n,s_n'$. The point is that it is not possible for an adversary who does not know the subspaces to split its quantum information into two registers, one going to $B$ and one going to $C$, such that both can recover $s_1,s_1',\ldots, s_n,s_n'$ when given the subpsaces in the clear. We thus reduce security of our copy-protection scheme to the monogamy of entanglement game described in the next subsection.
The reason why need to resort to this monogamy of entanglement game is that the extractability guarantees afforded by the compute-and-compare obfuscation are quite weak: an adversary who can break the obfuscation implies an adversary who can predict $y$ given $f$ with noticeable probability. We can instead make use of primitives with \text{strong} extractable guarantees, like witness encryption (where breaking the encryption implies an adversary who can recover the right vectors with probability close to $1$), then the reduction to the monogamy of entanglement game is not required, and one can violate direct product hardness from section .
This part of the argument can be simplified, and the reliance on this conjecture removed, by using witness encryption..
\end{comment}
%
%
%
%
\begin{comment}
Our last contribution is the construction of copy-protected PRFs assuming post-quantum ${\sf iO}$, one-way functions and one of the single-decryptor encryption schemes in our work.
Our construction leverages the ``hidden trigger'' technique developed by Sahai and Waters~\cite{sahai2014use} and later employed by Hofheinz et al.~\cite{hofheinz2016generate}, in the context of ${\sf iO}$. Informally, a hidden trigger is an input to a program that has a special form. At a high level, the technique leverages ${\sf iO}$ to do the following. Let be $P$ be a program that one wishes to obfuscate. Instead of obfuscating $P$ directly, one obfuscates a program $P'$ that that behaves as follows: on input $x$, check if $x$ is a hidden trigger. If so, perform a special subroutine dependent on the hidden trigger. If not, run program $P$ on input $x$.
The key is that, when the set of hidden triggers is defined appropriately, one can replace a uniformly random input from a larger set with a uniformly random input from a sparse hidden trigger set, thanks to the security of ${\sf iO}$.
\Jiahui{explain why we can only deal with weak PRF}
Our copy-protection procedure for weak PRFs takes as input a key $K$ for a weak PRF $F(\cdot, \cdot)$. It samples a random coset state $\ket {A_{s, s'}}$ together with $A, s, s'$. It prepares the following program $P$. Very informally, the program takes as inputs a string $x$ and a vector $v$, it first parses $x = x_0 || x_1$ ($x_0$ is the first bit of the input) and checks if $(x_0, x_1)$ is a ``hidden trigger'' (what this is exactly will be formally discussed in~\Cref{sec:cp_wPRF}). The set of hidden triggers is constructed so that if the input is a hidden trigger, the program is able to extract a circuit by decoding the input $x$, and then proceeds to output the evaluation of the circuit on input vector $v$. Otherwise, the program outputs $F(K, x)$ if and only if $v$ is in $A+s$ or $A^\perp + s'$, depending on the value of $x_0$. The special circuit that is extracted from the hidden trigger can be interpreted as a ciphertext of a random message in the single-decryptor encryption scheme. The circuit only outputs the plaintext message if the input vector $v$ is in $A+s$ or $A^\perp + s'$ depending on the value of $x_0$.
The copy-protection procedure outputs $\ket{A_{s,s'}}$ and $P$.
\begin{figure}[hpt]
\centering
\begin{gamespec}
On input $x = x_0 || x_1$, where $x_0$ is a single bit, and $v$:
\begin{enumerate}
\item If $(x_0, x_1)$ is a hidden trigger:
\quad It gets a circuit $C$ by decoding the input, and outputs $C(v)$.
\item Otherwise, it checks if the following holds: $x_0 = 0$ and $v \in A + s$ or $x_0 = 1$ and $v \in A^\perp + s'$.
\quad If it does, $P$ outputs $F(K, x)$. Otherwise, outputs $\bot$.
\end{enumerate}
\end{gamespec}
\caption{Program $P$}
\end{figure}
To prove security, roughly speaking, we rely on the fact that sampling a uniform random input is indistinguishable from sampling an element from the sparse hidden trigger set.
Informally, breaking copy-protection security amounts to being able to produce two keys for the pseudorandom function, both of which allow correct evaluation of the PRF on random inputs. By the security of ${\sf iO}$, then both keys must evaluate correctly on random inputs in the hidden trigger set, which amounts to simultaneously decrypting, and thus breaking single-decryptor security.
\end{comment}
\section{Introduction}
\input{intro}
\section{Preliminaries}
\input{prelim}
\input{coset_state}
\input{signature_token}
\input{unclonable_dec_hidden_shift}
\input{unclonable_PRF}
\printbibliography
\subsection{Pseudorandom Functions}
For the rest of this paper, we will assume that all of the classical cryptographic primitives used are post-quantum (i.e. secure against quantum adversaries), and we sometimes omit mentioning this for convenience, except in formal definitions and theorems.
\begin{definition}[PRF] \label{def:wPRF}
A pseudorandom function (PRF) is a function $F:\{0,1\}^k \times \{0,1\}^n \to \{0,1\}^m$, where $\{0, 1\}^k$ is the
key space, and $\{0, 1\}^n$ and $\{0, 1\}^m$ are the domain and range. $k, n$ and $m$ are implicity functions of a security parameter $\lambda$. The following should hold:
\begin{itemize}
\item For every $K \in \{0,1\}^k$, $F(K, \cdot)$ is efficiently computable;
\item PRF security: no efficient quantum adversary $\mathcal{A}$ making quantum queries can distinguish between a truly random function and the function $F(K, \cdot)$; that is for every such $\mathcal{A}$, there exists a negligible function ${\sf negl}$,
\begin{align*}
\left| \Pr_{K \gets \{0,1\}^k}\left[ \mathcal{A}^{F(K, \cdot)}() = 1 \right] - \Pr_{O: \{0,1\}^n \to \{0,1\}^m}\left[ \mathcal{A}^{O}() = 1 \right] \right| \leq {\sf negl}(\lambda)
\end{align*}
\end{itemize}
\end{definition}
\subsection{Indistinguishability Obfuscation}
\begin{definition}[Indistinguishability Obfuscator (iO)~\cite{barak2001possibility,garg2016candidate,sahai2014use}]
A uniform PPT machine ${\sf iO}$ is an indistinguishability obfuscator for a circuit class $\{\mathcal{C}_\lambda\}_{\lambda \in \mathbb N}$ if the following conditions are satisfied:
\begin{itemize}
\item For all $\lambda$, all $C \in \mathcal{C}_\lambda$, all inputs $x$, we have
\begin{align*}
\Pr\left[\widehat{C}(x) = C(x) \,|\, \widehat{C} \gets {\sf iO}(1^\lambda, C) \right] = 1
\end{align*}
\item (Post-quantum security): For all (not necessarily uniform) QPT adversaries $({\sf Samp}, D)$, the following holds: if $\Pr[\forall x, C_0(x) = C_1(x) \,:\, (C_0, C_1, \sigma) \gets {\sf Samp}(1^\lambda)] > 1 - \alpha(\lambda)$ for some negligible function $\alpha$, then there exists a negligible function $\beta$ such that:
\begin{align*}
& \Bigg|\Pr\left[D(\sigma, {\sf iO}(1^\lambda, C_0)) =1\,:\, (C_0, C_1, \sigma) \gets {\sf Samp}(1^\lambda)\right] \\
- & \Pr\left[D(\sigma, {\sf iO}(1^\lambda, C_1)) = 1\,:\, (C_0, C_1, \sigma) \gets {\sf Samp}(1^\lambda)\right] \Bigg| \leq \beta(\lambda)
\end{align*}
\end{itemize}
\end{definition}
Whenever we assume the existence of ${\sf iO}$ in the rest of the paper, we refer to ${\sf iO}$ for the class of polynomial-size circuits, i.e. when $\mathcal{C}_{\lambda}$ is the collection of all circuits of size at most $\lambda$.
We will also make use of the stronger notion of \emph{sub-exponentially secure} ${\sf iO}$. By the latter, we mean that the distinguishing advantage above is $1/{\sf subexp}$ for some sub-exponential function ${\sf subexp}$, instead of negligible (while the adversary is still $QPT$).
Similarly, we will also make use of sub-exponentially secure one-way functions. For the latter, the advantage is again $1/{\sf subexp}$ (and the adversary is $QPT$).
\subsection{Compute-and-Compare Obfuscation} \label{sec:cc}
\begin{definition}[Compute-and-Compare Program]
Given a function $f:\{0,1\}^{\ell_{\sf in}} \to \{0,1\}^{\ell_{\sf out}}$ along with a target value $y \in \{0,1\}^{\ell_{\sf out}}$ and a message $z \in \{0,1\}^{\ell_{\sf msg}}$, we define the compute-and-compare program:
\begin{align*}
\mathsf{CC}[f, y, z](x) = \begin{cases}
z & \text{ if } f(x) = y \\
\bot & \text{ otherwise }
\end{cases}
\end{align*}
\end{definition}
We define the following class of \emph{unpredictable distributions} over pairs of the form $(\mathsf{CC}[f, y, z], {\sf aux})$, where ${\sf aux}$ is auxiliary quantum information. These distributions are such that $y$ is computationally unpredictable given $f$ and ${\sf aux}$.
\begin{definition}[Unpredictable Distributions]
\label{def:cc_unpredictable_dist}
We say that a family of distributions $D = \{D_\lambda\}$ where $D_{\lambda}$ is a distribution over pairs of the form $(\mathsf{CC}[f, y, z], {\sf aux})$ where ${\sf aux}$ is a quantum state, belongs to the class of \emph{unpredictable distributions} if the following holds. There exists a negligible function ${\sf negl}$ such that, for all QPT algorithms $\mathcal{A}$,
\begin{align*}
\Pr_{ (\mathsf{CC}[f, y, z], {\sf aux}) \gets D_\lambda } \left[ A(1^\lambda, f, {\sf aux}) = y \right] \leq {\sf negl}(\lambda).
\end{align*}
\end{definition}
We further define the class of \emph{sub-exponentially unpredictable distributions}, where we require the guessing probability to be inverse sub-exponential in the security parameter.
\begin{definition}[Sub-Exponentially Unpredictable Distributions]
\label{def:cc_subexp_unpredictable_dist}
We say that a family of distributions $D = \{D_\lambda\}$ where $D_{\lambda}$ is a distribution over pairs of the form $(\mathsf{CC}[f, y, z], {\sf aux})$ where ${\sf aux}$ is a quantum state, belongs to the class of \emph{sub-exponentially unpredictable distributions} if the following holds. There exists a sub-exponential function ${\sf subexp}$ such that, for all QPT algorithms $\mathcal{A}$,
\begin{align*}
\Pr_{ (\mathsf{CC}[f, y, z], {\sf aux}) \gets D_\lambda } \left[ A(1^\lambda, f, {\sf aux}) = y \right] \leq 1/{\sf subexp}(\lambda).
\end{align*}
\end{definition}
We assume that a program $P$ has an associated set of parameters $P.{\sf param}$ (e.g input size, output size, circuit size, etc.), which we are not required to hide.
\begin{definition}[Compute-and-Compare Obfuscation]
\label{def: cc obf}
A PPT algorithm ${\sf CC.Obf}$ is an obfuscator for the class of unpredictable distributions (or sub-exponentially unpredictable distributions) if for any family of distributions $D = \{ D_{\lambda}\}$ belonging to the class, the following holds:
\begin{itemize}
\item Functionality Preserving: there exists a negligible function ${\sf negl}$ such that for all $\lambda$, every program $P$ in the support of $D_\lambda$,
\begin{align*}
\Pr[\forall x,\, \widetilde{P}(x) = P(x),\, \widetilde{P} \gets {\sf CC.Obf}(1^\lambda, P) ] \geq 1 - {\sf negl}(\lambda)
\end{align*}
\item Distributional Indistinguishability: there exists an efficient simulator ${\sf Sim}$ such that:
\begin{align*}
({\sf CC.Obf}(1^\lambda, P), {\sf aux}) \approx_c ({\sf Sim}(1^\lambda, P.{\sf param}), {\sf aux})
\end{align*}
where $(P, {\sf aux}) \gets D_\lambda$.
\end{itemize}
\end{definition}
Combining the results of \cite{wichs2017obfuscating, goyal2017lockable} with those of \cite{zhandry2019magic}, we have the following two theorems. For the proofs and discussions, we refer the readers to \Cref{sec:CC_quantum_aux}. Note that although \Cref{thm:CC__from_ELF_iO} is a strictly stronger statement, currently we do not know of any post-quantum construction for ELFs.
\begin{reptheorem}{thm:CC_subexp_from_LWE_iO}
\label{thm: cc sub-exp from lwe}
Assuming the existence of post-quantum ${\sf iO}$ and the
quantum hardness of LWE, there exist obfuscators for sub-exponentially unpredictable distributions, as in \Cref{def: cc obf}.
\end{reptheorem}
\begin{reptheorem}{thm:CC__from_ELF_iO}
Assuming the existence of post-quantum ${\sf iO}$ and post-quantum
extremely lossy functions (ELFs), there exist obfuscators as in \Cref{def: cc obf}. for any unpredictable distributions.
\end{reptheorem}
\subsection{Subspace Hiding Obfuscation}
\label{sec: shO}
Subspace-hiding obfuscation was introduced by Zhandry~\cite{zhandry2019quantum} as a key component in constructing public-key quantum money. This notion requires that the obfuscation of a circuit that computes membership in a subspace $A$ is indistinguishable from the obfuscation of a circuit that computes membership in a uniformly random superspace of $A$ (of dimension sufficiently far from the full dimension). The formal definition is as follows.
\begin{definition}[\cite{zhandry2019quantum}]
A subspace hiding obfuscator (shO) for a field $\mathbb{F}$ and dimensions $d_0, d_1$ is a PPT algorithm ${\sf shO}$ such that:
\begin{itemize}
\item \textbf{Input.} ${\sf shO}$ takes as input the description of a linear subspace $S \subseteq \mathbb{F}^n$ of dimension $d \in \{d_0, d_1\}$.
For concreteness, we will assume $S$ is given as a matrix whose rows form a basis for $S$.
\item \textbf{Output.} ${\sf shO}$ outputs a circuit $\hat{S}$ that computes membership in $S$. Precisely, let $S(x)$ be the function that decides membership in $S$. Then there exists a negligible function ${\sf negl}$,
\begin{align*}
\Pr[\hat{S}(x) = S(x)~~\forall x : \hat{S} \leftarrow {\sf shO}(S)] \geq 1 - {\sf negl}(n)
\end{align*}
\item \textbf{Security.} For security, consider the following game between an adversary and a challenger.
\begin{itemize}
\item The adversary submits to the challenger a subspace $S_0$ of dimension $d_0$.
\item The challenger samples a uniformly random subspace $S_1 \subseteq \mathbb{F}^n$ of dimension $d_1$ such that $S_0 \subseteq S_1$.
It then runs $\hat{S} \leftarrow {\sf shO}(S_b)$, and gives $\hat{S}$ to the adversary.
\item The adversary makes a guess $b'$ for $b$.
\end{itemize}
${\sf shO}$ is secure if all QPT adversaries have negligible advantage in this game.
\end{itemize}
\end{definition}
Zhandry \cite{zhandry2019quantum} gives a construction of a subspace hiding obfuscator based on one-way functions and ${\sf iO}$.
\begin{theorem}[Theorem 6.3 in \cite{zhandry2019quantum}]
If injective one-way functions exist, then any indistinguishability obfuscator, appropriately padded, is also a subspace hiding obfuscator for field $\mathbb{F}$ and dimensions $d_0, d_1$, as long as $|\mathbb{F}|^{n-d_1}$ is exponential.
\end{theorem}
\subsection{Extractable Witness Encryption}
\label{appendix:extractable_witness}
In this subsection, we describe the primitive of witness encryption~\cite{garg2017implausibility} with extractable security, which will we use in our construction of unclonable decryption in Section \ref{sec: unclonable dec witness enc}.
\begin{definition}[Extractable Witness Encryption]
\label{def: extractable witness enc}
An extractable witness encryption scheme for an $\textsf{NP}$
relation $R$ is a pair of algorithms $({\sf Enc}, {\sf Dec})$:
\begin{itemize}
\item ${\sf Enc}(1^\lambda, x, m) \to \mathsf{ct}:$
takes as input a security parameter $\lambda$ in unary, an instance $x$ and
a message $m$, and outputs a ciphertext $\mathsf{ct}$.
\item ${\sf Dec}(\mathsf{ct}, w) \to m/\bot:$ takes as input a ciphertext $\mathsf{ct}$ and a witness $w$ and outputs a message $m$ or $\bot$ (for decryption failure).
\end{itemize}
The scheme satisfies the following:
\begin{description}
\item[Correctness:]
For any security parameter $\lambda \in \mathbb{N}$, for any $m \in \{0,1\}$, for any $x$ and $w$ such that $R(x, w) = 1$, we have that:
\begin{align*}
& \Pr[ {\sf Dec}({\sf Enc}(1^\lambda, x, m), w] = m ] = 1
\end{align*}
\item[Extractable Security:]
For any QPT adversary $\mathcal{A}$, polynomial-time sampler $(x, {\sf aux}) \gets {\sf Samp}(1^\lambda)$
and for any polynomial $q(\cdot)$, there exists a QPT extractor $E$ and a polynomial $p(\cdot)$, such that:
\begin{align*}
& \Pr\left[ \mathcal{A}(1^\lambda, x, \mathsf{ct}, {\sf aux}) = m \middle| \begin{array}{cr}
m \gets \{0, 1\}, (x, {\sf aux}) \gets {\sf Samp}(1^\lambda),\\
\mathsf{ct} \gets {\sf Enc}(1^\lambda, x, m)
\end{array}
\right] \geq \frac{1}{2} + \frac{1}{q(\lambda)} \\
& \rightarrow \Pr\left[ E(1^\lambda, x, {\sf aux}) = w \text{ s.t. } R(x, w) = 1 : (x, {\sf aux}) \gets {\sf Samp}(1^\lambda) \right]
\geq \frac{1}{p(\lambda)}.
\end{align*}
\end{description}
\end{definition}
\input{unclonable_dec_ATI}
\subsection{Quantum Computation and Information}
\label{appendix:quantum_info}
A quantum system $Q$ is defined over a finite set $B$ of classical states. In this work we will consider $B = \{0,1\}^n$. A \textbf{pure state} over $Q$ is a unit vector in $\mathbb{C}^{|B|}$, which assigns a complex number to each element in $B$. In other words, let $|\phi\rangle$ be a pure state in $Q$, we can write $|\phi\rangle$ as:
\begin{equation*}
|\phi\rangle = \sum_{x \in B} \alpha_x |x\rangle
\end{equation*}
where $\sum_{x \in B} |\alpha_x|^2 = 1$ and $\{|x\rangle\}_{x \in B}$ is called
the ``\textbf{computational basis}'' of $\mathbb{C}^{|B|}$. The computational basis forms an orthonormal basis of $\mathbb{C}^{|B|}$.
Given two quantum systems $R_1$ over $B_1$ and $R_2$ over $B_2$, we can define a \textbf{product} quantum system $R_1 \otimes R_2$ over the set $B_1 \times B_2$. Given $|\phi_1\rangle \in R_1$ and $|\phi_2\rangle \in R_2$, we can define the product state $|\phi_1\rangle \otimes |\phi_2\rangle \in R_1 \otimes R_2$.
We say $|\phi\rangle \in R_1 \otimes R_2$ is \textbf{entangled} if there does not exist
$|\phi_1\rangle \in R_1$ and $|\phi_2\rangle \in R_2$ such that $|\phi\rangle = |\phi_1\rangle \otimes |\phi_2\rangle$. For example, consider $B_1 = B_2 = \{0,1\}$
and $R_1 = R_2 = \mathbb{C}^2$, $|\phi\rangle = \frac{|00\rangle + |11\rangle}{\sqrt{2}}$ is entangled. Otherwise, we say $|\phi\rangle$ is un-entangled.
A mixed state is a collection of pure states $\ket{\phi_i}$ for $i\in [n]$, each with associated probability $p_i$, with the condition $p_i\in [0,1]$ and $\sum_{i=1}^n p_i = 1$. A mixed state can also be represented by the density matrix: $\rho:= \sum_{i=1}^n p_i \ket{\phi_i}\bra{\phi_i}$.
\textbf{Partial Trace}.
For two subsystems $R_1$ and $R_2$ making up the composite system described
by the density matrix $\rho$. The partial trace over the $R_2$ subsystem, denoted $\Tr_{R_2}$, is defined as
$\Tr_{R_2}[\rho] := \sum_j
(I_{R_1} \otimes \langle j|_{R_2}) \rho (I_{R_1} \otimes |j\rangle_{R_2})$.
where $\{|j\rangle \}$ is any orthonormal basis for subsystem $R_2$.
For a quantum state $\sigma$ over two registers $R_1, R_2$, we denote the state in $R_1$ as $\sigma[R_1]$, where $\sigma[R_1]= \Tr_{R_2}[\sigma]$ is a partial trace of $\sigma$. Similarly, we denote $\sigma[R_2]= \Tr_{R_1}[\sigma]$.
\textbf{Purification of mixed states}. For a mixed state $\rho$ over system $Q$, there exists another space $Q'$ and a pure state $\ket \psi$ over $Q \otimes Q'$ such that $\rho$ is a partial trace of $\ket \psi \bra \psi$ with respect to $Q'$.
\vspace{1em}
A pure state $|\phi\rangle$ can be manipulated by a unitary transformation $U$. The resulting state $|\phi'\rangle = U |\phi\rangle$.
We can extract information from a state $|\phi\rangle$ by performing a \textbf{measurement}. A measurement specifies an orthonormal basis, typically the computational basis, and the probability of getting result $x$ is $|\langle x | \phi \rangle|^2$. After the measurement, $|\phi\rangle$ ``collapses'' to the state $|x\rangle$ if the result is $x$.
For example, given the pure state $|\phi\rangle = \frac{3}{5} |0\rangle + \frac{4}{5} |1\rangle$ measured under $\{|0\rangle ,|1\rangle \}$, with probability $9/25$ the result is $0$ and $|\phi\rangle$ collapses to $|0\rangle$; with probability $16/25$ the result is $1$ and $|\phi\rangle$ collapses to $|1\rangle$.
\iffalse
\begin{itemize}
\item One way to perform measurements is by specifying an orthonormal basis, for example $\{|x\rangle\}_{x \in B}$, and the probability of getting result $x$ is $|\langle x | \phi \rangle|^2$. After the measurement, $|\phi\rangle$
``collapses'' to the state $|x\rangle$ if the result is $x$.
For example, given the pure state $|\phi\rangle = \frac{3}{5} |0\rangle + \frac{4}{5} |1\rangle$ measured under $\{|0\rangle ,|1\rangle \}$, with probability $9/25$ the result is $0$ and $|\phi\rangle$ collapses to $|0\rangle$; with probability $16/25$ the result is $1$ and $|\phi\rangle$ collapses to $|1\rangle$.
\item Another way is called ``\textbf{positive-operator valued measure}''. In this paper we only care about a special case where each operator is a projection. $|\phi\rangle$ is measured under $P_1, P_2, \cdots, P_k$ where each $P_i$
is a projection on $\mathbb{C}^{|B|}$ and $\sum_{i=1}^k P_i = I$.
The probability of getting result $i$
is $|P_{i} |\phi\rangle|^2$. $|\phi\rangle$ collapses to $P_i |\phi\rangle / |P_i |\phi\rangle|$.
For example, $|\phi\rangle = (|00\rangle + |01\rangle + |10\rangle) / \sqrt{3}$ and
$P_0 = |00\rangle\langle 00|$ and
$P_1 = I - P_0 = |01\rangle\langle 01| + |10\rangle\langle 10| + |11\rangle\langle 11|$.
With probability $1/3$, the result is $0$ and $|\phi\rangle$ collapses to $|00\rangle$; with probability $2/3$, the result is $1$ and
$|\phi\rangle$ collapses to $\frac{|01\rangle+|10\rangle}{\sqrt{2}}$.
\item We will also use the notion of a \textbf{partial measurement}, which is a special case of a projective measurement. Let $|\phi\rangle$ be a pure state over $Q_1 \otimes Q_2$, and $P_1, \cdots, P_k$
be a set of projection such that $P_1 + \cdots + P_k = I$ defined a projection measurement over $Q_1$. The probability of getting result $i$ is
$\left|(P_i \otimes I) |\phi\rangle \right|^2$, and $|\phi\rangle$ collapses to $(P_i \otimes I) |\phi\rangle$ normalized.
For example, $|\phi\rangle = \frac{|00\rangle + |11\rangle}{\sqrt{2}}$ and
the measurement $P_0 = |0\rangle\langle 0|, P_1 = |1\rangle\langle 1|$ is done over $Q_1$. With probability $1/2$, the result is $0$ and the state becomes $|00\rangle$; otherwise, the result is $1$ and the state collapses to $|11\rangle$.
\end{itemize}\fi
We finally assume a quantum computer can implement any unitary transformation (by using these basic gates, Hadamard, phase, CNOT and $\frac{\pi}{8}$ gates), especially the following two unitary transformations:
\begin{itemize}
\item \textbf{Classical Computation:} Given a function $f : X \to Y$, one can implement a unitary $U_f$ over $\mathbb{C}^{|X|\cdot |Y|} \to \mathbb{C}^{|X| \cdot |Y|}$ such that for any $|\phi\rangle = \sum_{x \in X, y \in Y} \alpha_{x, y} |x, y\rangle$,
\begin{equation*}
U_f |\phi\rangle = \sum_{x \in X, y \in Y} \alpha_{x, y} |x, y \oplus f(x)\rangle
\end{equation*}
Here, $\oplus$ is a commutative group operation defined over $Y$.
\item \textbf{Quantum Fourier Transform:} Let $N = 2^n$. Given a quantum state $|\phi\rangle = \sum_{i=0}^{2^n-1} x_i |i\rangle$, by applying only $O(n^2)$ basic gates,
one can compute $|\psi\rangle = \sum_{i=0}^{2^n-1} y_i |i\rangle$ where the sequence $\{y_i\}_{i=0}^{2^n-1}$ is the sequence achieved by applying the
classical Fourier transform ${\sf QFT}_N$ to the sequence $\{x_i\}_{i=0}^{2^n-1}$:
\begin{equation*}
y_k = \frac{1}{\sqrt{N}} \sum_{i=0}^{2^n-1} x_i \omega_n^{i k}
\end{equation*}
where $\omega_n = e^{2 \pi i / N}$, $i$ is the imaginary unit.
One property of {\sf QFT} is that by preparing $|0^n\rangle$ and
applying ${\sf QFT}_2$ to each qubit, $\left({\sf QFT}_2 |0\rangle\right)^{\otimes n} = \frac{1}{\sqrt{2^n}} \sum_{x \in \{0,1\}^n} |x\rangle$ which is a uniform superposition over all possible $x \in \{0,1\}^n$.
\end{itemize}
For convenience, we sometimes omit writing the normalization of a pure state.
\section{Tokenized Signature Scheme from iO}
\label{sec: signature tokens}
\revise{In this section, we present a construction for tokenized signatures with unforgeability security based on the computational direct product hardness (\Cref{thm: direct product comp}). We improved upon the scheme in \cite{ben2016quantum} by removing the need of (highly structured) oracles or post-quantum VBB obfuscation.
}
\subsection{Definitions}
\begin{definition}[Tokenized signature scheme]
\label{def: ts}A tokenized signature (TS) scheme consists of a tuple of QPT algorithms $(\mathsf{KeyGen}, \mathsf{TokenGen}, {\sf Sign}, \mathsf{Verify})$ with the following properties:
\begin{itemize}
\item $\mathsf{KeyGen}(1^\lambda) \to ({\sf sk}, {\sf pk})$: Takes as input $1^{\lambda}$, where $\lambda$ is a security parameter, and outputs a secret key, public (verification) key pair $({\sf sk},{\sf pk})$.
\item $\mathsf{TokenGen}({\sf sk}) \to \mathsf{\ket{tk}}$: Takes as input a secret key ${\sf sk}$ and outputs a signing token $\mathsf{\ket{tk}}$.
\item ${\sf Sign}(m, \mathsf{\ket{tk}}) \to (m, \mathsf{sig})/\bot$: Takes as input a message $m \in \{0,1\}^*$ and a token $\mathsf{\ket{tk}}$, and outputs either a message, signature pair $(m, \mathsf{sig})$ or $\bot$.
\item $\mathsf{Verify}({\sf pk}, m, \mathsf{sig}) \to 0/1$: Takes as input an verification key, an alleged message, signature pair $(m,\mathsf{sig})$, and outputs $0$ (``reject'') or $1$ (``accept'').
\item $\mathsf{Revoke}({\sf pk}, \mathsf{\ket{tk}}) \to 0/1$: Takes in public key ${\sf pk}$ and a claimed token $\mathsf{\ket{tk}}$, and outputs $0$ (``reject'') or $1$ (``accept'').
\end{itemize}
\end{definition}
These algorithms satisfy the following. First is correctness. There exists a negligible function ${\sf negl}(\cdot)$, for any $\lambda \in \mathbb{N}$, $m \in \{0,1\}^*$,
\begin{align*}
\Pr[\mathsf{Verify}({\sf pk}, m, \mathsf{sig}) = 1:
& (m,\mathsf{sig}) \leftarrow {\sf Sign}(m, \mathsf{\ket{tk}}), \mathsf{\ket{tk}} \leftarrow \mathsf{TokenGen}({\sf sk}), \\
&({\sf sk}, {\sf pk}) \leftarrow \mathsf{KeyGen}(1^{\lambda}) ]
\geq 1 - {\sf negl}(\lambda) \,. \nonumber \label{eq: ts scheme}
\end{align*}
\begin{definition}[Length restricted TS scheme]
A TS scheme is $r$-restricted if it holds only for $m \in \{0,1\}^r$. We refer to a scheme that is $1$-restricted as a one-bit TS scheme.
\end{definition}
Notation-wise, we introduce an additional algorithm $\mathsf{Verify}_\ell$. The latter takes as input a public key ${\sf pk}$ and $\ell$ pairs $(m_\ell, \mathsf{sig}_\ell), \ldots, (m_\ell, \mathsf{sig}_\ell)$. It checks that $m_i \neq m_j$ for all $i\neq j$, and $\mathsf{Verify} (m_i, \mathsf{sig}_i) = 1$ for all $i \in [\ell]$; it outputs $1$ if and only if they all hold. %
Next we define unforgeability.
\begin{definition}[$1$-Unforgeability] A TS scheme is $1$-unforgeable if for every QPT adversary $\mathcal{A}$, there exists a negligible function ${\sf negl}(\cdot)$, for every $\lambda$:
\begin{align*}
\Pr\left[\begin{array}{cc} (m_0, \mathsf{sig}_0, m_1, \mathsf{sig}_1) \gets \mathcal{A}({\sf pk}, \ket {\sf tk}) \\ \mathsf{Verify}_2({\sf pk}, m_0,\mathsf{sig}_0 ,m_1, \mathsf{sig}_1) = 1 \\ \end{array}: \begin{array}{cc} ({\sf sk}, {\sf pk}) \leftarrow \mathsf{KeyGen}(1^{\lambda})\\ \ket{\mathsf{tk}} \leftarrow \mathsf{TokenGen}({\sf sk}) \end{array} \right] \leq {\sf negl}(\lambda) \,.
\end{align*}
\end{definition}
\begin{definition}[Unforgeability]
\label{def: ts unforgeability}A TS scheme is unforgeable if for every QPT adversary $\mathcal{A}$, there exists a negligible function ${\sf negl}(\cdot)$, for every $\lambda$, $l = {\sf poly}(\lambda)$:
\begin{align*}
\Pr\left[ \begin{array}{cc} \{m_i, \mathsf{sig}_i\}_{i \in [l+1]} \gets \mathcal{A}({\sf pk}, \{\ket {{\sf tk}_i}\}_{i \in [l]}) \\ \mathsf{Verify}_{l+1}({\sf pk}, \{m_i, \mathsf{sig}_i\}_{i \in [l + 1]}) = 1 \end{array}: \begin{array}{cc}
({\sf sk}, {\sf pk}) \leftarrow \mathsf{KeyGen}(1^{\lambda}) \\
\ket {{\sf tk}_1} \gets \mathsf{TokenGen}({\sf sk}) \\
\vdots \\
\ket {{\sf tk}_l} \gets \mathsf{TokenGen}({\sf sk})
\end{array} \right] \leq {\sf negl}(\lambda) \,.
\end{align*}
\end{definition}
Finally we have revocability.
\begin{definition}[Revocability]
A revocable tokenized signature scheme satisfies:
\begin{itemize}
\item Correctness:
$ \Pr\left[\mathsf{Revoke}({\sf pk}, \mathsf{\ket{tk}}) = 1 \middle| ({\sf pk},{\sf sk}) \gets \mathsf{KeyGen}(1^\lambda), \mathsf{\ket{tk}} \gets \mathsf{TokenGen}({\sf sk}) \right] = 1$.
\item Revocability:
For every $\ell \leq {\sf poly}(\lambda), t \leq \ell$, and every QPT $\mathcal{A}$ with $\ell$ signing tokens $\ket{\mathsf{tk}_1} \otimes \cdots \otimes \ket{\mathsf{tk}_\ell}$ and ${\sf pk}$, which has generated $t$ signatures $(m_1,\mathsf{sig}_1), \cdots,$ $(m_t, \mathsf{sig}_t)$ and a state $\sigma$:
\begin{align*}
\Pr\left[ \mathsf{Verify}_t({\sf pk}, (m_1,\mathsf{sig}_1), \cdots, (m_t, \mathsf{sig}_t)) = 1 \wedge \mathsf{Revoke}_{\ell-t+1}(\sigma) = 1 \right] \leq {\sf negl}(\lambda)
\end{align*}
Here $\mathsf{Revoke}_{\ell-t+1}$ means applying $\mathsf{Revoke}$ on all $\ell-t+1$ registers of $\sigma$, and outputs $1$ if they all output $1$.
\end{itemize}
\end{definition}
\revise{
The revocability property follows straightforwardly from unforgeability \cite{ben2016quantum}. Thus to show a construction is secure, we only need to focus on proving unforgeability. The following theorem says $1$-unforgeability is sufficient to achieve a full blown TS scheme.
}
\begin{theorem}[\cite{ben2016quantum}]
\label{thm: onebit onetime to full}
A one-bit $1$-unforgeable TS scheme implies a (full blown) TS scheme, assuming the existence of a quantum-secure digital signature scheme.
\end{theorem}
In the next section, we give our construction of a one-bit $1$-unforgeable TS scheme from coset states.
\subsection{Tokenized Signature Construction}
\begin{construction*}
$\,$
\label{cons: token sig}
\begin{itemize}
\item $\mathsf{KeyGen}(1^\lambda)$: Set $n = {\sf poly}(\lambda)$. Sample uniformly $A \subseteq \mathbb{F}_2^n$. Sample $s,s' \leftarrow \mathbb{F}_2^n$. Output ${\sf sk} = (A, s,s')$ (where by $A$ we mean a description of the subspace $A$) and ${\sf pk} = ({\sf iO}(A+s), {\sf iO}(A^{\perp}+s'))$.
\item $\mathsf{TokenGen}({\sf sk})$: Takes as input ${\sf sk}$ of the form $(A, s,s')$. Outputs $\mathsf{\ket{tk}} = \ket{A_{s,s'}}$.
\item ${\sf Sign}(m, \mathsf{\ket{tk}})$: Takes as input $m \in \{0,1\}$ and a state $\mathsf{\ket{tk}}$ on $n$ qubits. Compute $H^{\otimes n} \mathsf{\ket{tk}}$ if $m=1$, otherwise do nothing to the quantum state. It then measures in the standard basis. Let $\mathsf{sig}$ be the outcome. Output $(m, \mathsf{sig})$.
\item $\mathsf{Verify}({\sf pk}, (m, \mathsf{sig}))$: Parse ${\sf pk}$ as ${\sf pk} = (C_0, C_1)$ where $C_0$ and $C_1$ are circuits. Output $C_m(\mathsf{sig})$.
%
\item $\mathsf{Revoke}({\sf pk}, \mathsf{\ket{tk}})$: Parse ${\sf pk}$ as ${\sf pk} = (C_0, C_1)$. Then:
\begin{itemize}
\item Coherently compute $C_0$ on input $\mathsf{\ket{tk}}$, and measure the output of the circuit. If the latter is $1$, uncompute $C_0$, and proceed to the next step. Otherwise halt and output $0$.
\item Apply $H^{\otimes n}$. Coherently compute $C_1$ and measure the output of the circuit. If the latter is $1$, output $1$.
\end{itemize}
\end{itemize}
\end{construction*}
\begin{theorem}
\label{thm: sig tokens main}
Assuming {post-quantum} ${\sf iO}$ {and one-way function}, the scheme of Construction \ref{cons: token sig} is a one-bit $1$-unforgeable tokenized signature scheme.
\end{theorem}
\begin{proof}
Security follows immediately from Theorem \ref{thm: direct product comp}.
\end{proof}
\begin{corollary}
Assuming {post-quantum} ${\sf iO}$, {one-way function(which implies digital signature)} and a quantum-secure digital signature scheme, there exists a (full blown) tokenized signature scheme.
\end{corollary}
\begin{proof}
This is an immediate consequence of Theorems \ref{thm: onebit onetime to full} and \ref{thm: sig tokens main}.
\end{proof}
\section{Copy-Protection of Pseudorandom Functions}
\label{sec:cp_wPRF}
In this section, we formally define copy-protection of pseudorandom functions.
Then, we describe a construction that essentially builds on the single-decryptor encryption scheme described in Section \ref{sec: unclonable dec from stronger monogamy} (together with post-quantum sub-exponentially secure one-way functions and ${\sf iO}$). The same construction can be based on the single-decryptor encryption scheme from Section \ref{sec: unclonable dec witness enc}, but we omit the details to avoid redundancy.
In Section \ref{sec: PRF prelim}, we give definitions of certain families of PRFs which we use in our construction. We remark that all of the PRFs that we use can be constructed from post-quantum one-way functions.
\subsection{Definitions}
In what follows, the PRF $F: [K]\times [N] \rightarrow [M]$, implicitly depends on a security parameter $\lambda$. We denote by $\mathsf{Setup}(\cdot)$ the procedure which on input $1^{\lambda}$, outputs a PRF key.
\begin{definition}[Copy-Protection of PRF]
A copy-protection scheme for a PRF $F:[K] \times [N] \to [M]$
consists of the following QPT algorithms:
\begin{description}
\item[] $\mathsf{QKeyGen}(K)$: takes a key $K$ and outputs a quantum key $\rho_K$; %
\item[] $\mathsf{Eval}(\rho_K, x)$: takes a quantum key $\rho_K$ and an input $x \in [N]$. It outputs a classical string $y \in [M]$.
\end{description}
\end{definition}
A copy-protection scheme should satisfy the following properties:
\begin{definition}[Correctness]
There exists a negligible function ${\sf negl}(\cdot)$, such that for all $\lambda$, all $K \gets \mathsf{Setup}(1^\lambda)$,
all inputs $x$,
$$\Pr[ \mathsf{Eval}(\rho_K, x) = F(K,x) : \rho_K \leftarrow \mathsf{QKeyGen}(K)] \geq 1 - {\sf negl}(\lambda) \, .
$$
\end{definition}
Note that the correctness property implies that the evaluation procedure has an ``almost unique'' output. This means that the PRF can be evaluated (and rewound) polynomially many times, without disturbing the quantum key $\rho_K$, except negligibly.
\begin{definition}[Anti-Piracy Security] \label{def:weak anti piracy}
Let $\lambda \in \mathbb{N}^+$. Consider the following game between a challenger and an adversary $\mathcal{A}$:
\begin{enumerate}
\item The challenger samples $K \gets \mathsf{Setup}(1^\lambda)$ and $\rho_K \gets \mathsf{QKeyGen}(K)$. It gives $\rho_K$ to $\mathcal{A}$;
\item $\mathcal{A}$ returns to the challenger a bipartite state $\sigma$ on registers $R_1$ and $R_2$, as well as general quantum circuits $U_{1}$ and $U_{2}$.%
\item The challenger samples uniformly random $u, w \gets [N]$. Then runs $U_1$ on input $(\sigma[R_1], u)$, and runs $U_2$ on input $(\sigma[R_2], w)$. The outcome of the game is $1$ if and only if the outputs are $F(K, u)$ and $F(K, w)$ respectively.
\end{enumerate}
Denote by $\sf{CopyProtectionGame}(1^{\lambda}, \mathcal{A})$ a random variable for the output of the game.
We say the scheme has anti-piracy security if for every polynomial-time quantum algorithm $\mathcal{A}$, there exists a negligible function ${\sf negl}(\cdot)$, for all $\lambda \in \mathbb{N}^+$,
\begin{align*}
\Pr\left[b = 1, b \gets \sf{CopyProtectionGame}(1^{\lambda}, \mathcal{A}) \right] = {\sf negl}(\lambda) \,.
\end{align*}
\end{definition}
\begin{comment}
\begin{definition}[Copy-Protection of PRF]
A copy-protection scheme for a PRF $F:[K] \times [N] \to [M]$
consists of the following polynomial-time algorithms:
\begin{description}
\item[] $\mathsf{Setup}(1^\lambda)$: takes a security parameter $\lambda$ and outputs a key $K$;
\item[] $\mathsf{QKeyGen}(K)$: takes a key $K$ and outputs a quantum key $\rho_K$; %
\item[] $\mathsf{Eval}(\rho_K, x)$: takes a quantum key $\rho_K$ and an input $x$, it then procedures a classical output $y$.
\end{description}
\end{definition}
A copy-protection scheme should satisfy the following properties:
\begin{definition}[Correctness]
There exists a negligible function ${\sf negl}(\cdot)$, for all $\lambda$, all $K \gets \mathsf{Setup}(1^\lambda)$, all inputs $x$,
$$\Pr[ \mathsf{Eval}(\rho_K, x) = F(K,x) : \rho_K \leftarrow \mathsf{QKeyGen}(K)] \geq 1 - {\sf negl}(\lambda) \, .
$$
\end{definition}
Note that the correctness property implies that the evaluation procedure has an ``almost unique'' output. This means that the PRF can be evaluated (and rewound) polynomially many times, without disturbing the quantum key $\rho_K$, except negligibly.
\begin{definition}[Anti-Piracy Security] \label{def:weak anti piracy}
Let $\lambda \in \mathbb{N}^+$. Consider the following game between a challenger and an adversary $\mathcal{A}$:
\begin{enumerate}
\item The challenger samples $K \gets \mathsf{Setup}(1^\lambda)$ and $\rho_K \gets \mathsf{QKeyGen}(K)$. It gives $\rho_K$ to $\mathcal{A}$;
\item $\mathcal{A}$ returns to the challenger a bipartite state $\sigma$ on registers $R_1$ and $R_2$, as well as general quantum circuits $U_{1}$ and $U_{2}$.%
\item The challenger samples uniformly random $u, w \gets [N]$. Then runs $U_1$ on input $(\sigma[R_1], u)$, and runs $U_2$ on input $(\sigma[R_2], w)$. The outcome of the game is $1$ if and only if the outputs are $F(K, u)$ and $F(K, w)$ respectively.
\end{enumerate}
Denote by $\sf{CopyProtectionGame}(1^{\lambda}, \mathcal{A})$ a random variable for the output of the game.
We say the scheme has anti-piracy security if for every polynomial-time quantum algorithm $\mathcal{A}$, there exists a negligible function ${\sf negl}(\cdot)$, for all $\lambda \in \mathbb{N}^+$,
\begin{align*}
\Pr\left[b = 1, b \gets \sf{CopyProtectionGame}(1^{\lambda}, \mathcal{A}) \right] = {\sf negl}(\lambda) \,.
\end{align*}
\end{definition}
\end{comment}
\begin{comment}
\begin{definition}[Anti-Piracy Security] \label{def:weak anti piracy}
Consider the following game ${\sf AG}^{\mathcal{A}}_{{\sf PRF},\lambda}$ between a challenger and an adversary $\mathcal{A}$:
\begin{enumerate}
\itemThe challenger samples $K \gets \mathsf{Setup}(1^\lambda)$ and $\rho_K \gets \mathsf{QKeyGen}(K)$. It gives $\rho_K$ to $\mathcal{A}$;
\item $\mathcal{A}$ upon receiving $\rho_K$, it runs and prepares a pair of (potentially entangled) quantum states $\sigma[R_1], \sigma[R_2]$ as well as quantum circuits $U_{1}, U_{2}$.
\item The challenger also prepares two independent and uniformly random inputs $u, w \gets [N]$.
\item The outcome of the game is 1 if and only if each of the quantum programs successfully produce $F(K, u)$ and $F(K, w)$ respectively.
\end{enumerate}
We say the scheme has anti-piracy security, if for every polynomial $p$, for every polynomial-time quantum algorithm $\mathcal{A}$ and for all large enough $\lambda$,
\begin{align*}
\Pr\left[b = 1, b \gets {\sf AG}^{\mathcal{A}}_{{\sf PRF}, \lambda} \right] < 1 / p(\lambda)
\end{align*}
\end{definition}
\end{comment}
We give a stronger anti-piracy definition, which is an indistinguishability definition and is specifically for copy-protecting PRFs. We will show that our construction also satisfies this definition.
\begin{definition}[Indistinguishability Anti-Piracy Security for PRF]
\label{def:indistinguishable_anti_piracy_PRF}
Let $\lambda \in \mathbb{N}^+$. Consider the following game between a challenger and an adversary $\mathcal{A}$:
\begin{enumerate}
\item The challenger runs $K \gets \mathsf{Setup}(1^\lambda)$, and $\rho_K \gets \mathsf{QKeyGen}(K)$. It gives $\rho_K$ to $\mathcal{A}$;
\item $\mathcal{A}$ returns to the challenger a bipartite state $\sigma$ on registers $R_1$ and $R_2$, as well as general quantum circuits $U_{1}$ and $U_{2}$.%
\item The challenger samples two uniformly random inputs $u, w \gets [N]$ and two uniformly random strings $y_1, y_2 \gets [M]$ (these are of the same length as the PRF output).
\item The challenger flips two coins independently: $b_1, b_2 \gets \{0,1\}$. If $b_1 = 0$, it gives $(u, F(K, u), \sigma[R_1])$ as input to $U_{1}$; else it gives $(u, y_1, \sigma[R_1])$ as input to $U_{1}$. Let $b_1'$ be the output. Similarly, if
$b_2 = 0$, it gives $(w,F(K, w), \sigma[R_2])$ as input to $U_{2}$; else it gives $(w,y_2, \sigma[R_2])$ as input to $U_{2}$. Let $b_2'$ be the output.
\item The outcome of the game is $1$ if $b_1' = b_1$ and $b_2' = b_2$.
\end{enumerate}
Denote by $\sf{IndCopyProtectionGame}(1^{\lambda}, \mathcal{A})$ a random variable for the output of the game.
We say the scheme has indistinguishability anti-piracy security if for every polynomial-time quantum algorithm $\mathcal{A}$, there exists a negligible function ${\sf negl}(\cdot)$, for all $\lambda \in \mathbb{N}^+$,
\begin{align*}
\Pr\left[b = 1, b \gets \sf{IndCopyProtectionGame}(1^{\lambda}, \mathcal{A}) \right] = \frac{1}{2} + {\sf negl}(\lambda) \,.
\end{align*}
\end{definition}
\begin{comment}
\begin{definition}[Indistinguishability Anti-Piracy Security for PRF]
\label{def:indistinguishable_anti_piracy_PRF}
Consider the following game $\mathsf{IAG}^{\mathcal{A}}_{{\sf PRF},\lambda}$ between a challenger and an adversary $\mathcal{A}$:
\begin{enumerate}
\item A challenger runs $\mathsf{Setup}(1^\lambda)$ to prepare a PRF key $K$ and a quantum key $\rho_K \gets \mathsf{QKeyGen}(K)$, it then gives $\rho_K$ to $\mathcal{A}$;
\item $\mathcal{A}$ returns to the challenger a bipartite state $\sigma$ on registers $R_1$ and $R_2$, as well as general quantum circuits $U_{1}$ and $U_{2}$, respectively on $R_1$ and $R_2$.
\item The challenger samples two uniformly random inputs $u, w \gets [N]$ and two uniformly random strings $y_1, y_2 \gets [M]$ (these are of the same length as the PRF output).
\item The challenger flips two coins independently: $b_1, b_2 \gets {0,1}$. If $b_1 = 0$, it gives $(u,F(K, u))$ to quantum program $(\sigma[R_1], U_{1})$; else it gives $(u,y_1)$ to $(\sigma[R_1], U_{1})$. Similarly, if
$b_2 = 0$, it gives $(w,F(K, w))$ to quantum program $(\sigma[R_2], U_{2})$; else it gives $(w,y_2)$ to $(\sigma[R_2], U_{2})$.
\item Quantum program $(\sigma[R_1], U_{1})$ outputs a guess $b_1'$; quantum program $(\sigma[R_2], U_{2})$ outputs a guess $b_2'$
\item The outcome of the game is 1 if and only if each quantum programs successfully outputs $b_1' = b_1$ and $b_2' = b_2$ respectively.
\end{enumerate}
We say the scheme has indistinguishability anti-piracy security, if for every polynomial $p$, for every polynomial-time quantum algorithm $\mathcal{A}$ and for all large enough $\lambda$,
\begin{align*}
\Pr\left[b = 1, b \gets \mathsf{IAG}^{\mathcal{A}}_{{\sf PRF}, \lambda} \right] < 1/2 + 1 / p(\lambda)
\end{align*}
\end{definition}
\end{comment}
\jiahui{added the following comment}
Similarly to the relationship between CPA-style unclonable decryption (\Cref{def: regular antipiracy cpa}) and anti-piracy with random challenge inputs (Definition \ref{def: regular antipiracy random challenges}), it is not clear whether \Cref{def:indistinguishable_anti_piracy_PRF} implies \Cref{def:weak anti piracy} (this subtlety arises due to the fact that there are two parties involved, having to simultaneously make the correct guess). Thus, we will give separate statements and security proofs in the next section.
\input{unclonable_PRF_PRF_prelim}
\subsection{Construction}
In this section, we describe a construction of a copy-protection scheme for a class of PRFs. We will eventually reduce security of this construction to security of the single-decryptor encryption scheme of Section \ref{sec: unclonable dec from stronger monogamy}, and we will therefore inherit the same assumptions. A similar construction can be based on the single-decryptor encryption scheme of Section \ref{sec: unclonable dec witness enc}. %
Let $\lambda$ be the security parameter. Our construction copy-protects a PRF $F_1: [K_{\lambda}] \times [N_{\lambda}] \rightarrow [M_{\lambda}]$ where $N = 2^{n(\lambda)}$ and $M = 2^{m(\lambda)}$, for some polynomials $n(\lambda)$ and $m(\lambda)$, satisfying $n(\lambda) \geq m(\lambda) + 2 \lambda + 4$. For convenience, we will omit writing the dependence on $\lambda$, when it is clear from the context. Moreover, $F_1$ should be a puncturable extracting PRF with error $2^{-\lambda-1}$ for min-entropy $k(\lambda) = n(\lambda)$ (i.e., a uniform distribution over all possible inputs). %
By \Cref{sw14_thm3}, such PRFs exist assuming post-quantum one-way functions.
In our construction, we will parse the input $x$ to $F_1(K_1, \cdot)$ as three substrings $x_0 || x_1 || x_2$, where each $x_i$ is of length $\ell_i$ for $i \in \{0, 1, 2\}$ and $n = \ell_0 + \ell_1 + \ell_2$. $\ell_2 - \ell_0$ should also be large enough (we will specify later how large). Our copy-protection construction for $F_1$ will make use of the following additional building blocks:
\begin{enumerate}
%
\item A puncturable statistically injective PRF $F_2$ with failure probability $2^{-\lambda}$ that accepts inputs of length $\ell_2$ and outputs strings of length $\ell_1$. By \Cref{sw14_thm2}, such a PRF exists assuming one-way functions exist, and as long as $\ell_1 \geq 2 \ell_2 + \lambda$.
%
\item A puncturable PRF $F_3$ that accepts inputs of length $\ell_1$ and outputs strings of length $\ell_2$. By \Cref{lem:sw14_lem1} in \cite{sahai2014use}, assuming one-way functions exist, $F_3$ is a puncturable PRF.
\end{enumerate}
Note that PRF $F_1$ is the PRF that we will copy-protect. The PRFs $F_2$ and $F_3$ are just building blocks in the construction.
\revise{Next, we describe a copy-protection scheme for the PRF $F_1$, using the above building blocks. The description is contained in Figures \ref{fig:prf_key} and \ref{fig:program_p}. %
}
\begin{figure}[hpt]
\centering
\begin{gamespec}
\begin{description}
%
\item[]{ $\mathsf{QKeyGen}(K_1)$:} Sample uniformly random subspaces $A_i$ of dimension $\lambda/2$ %
and vectors $s_i, s'_i$ for $i = 1, 2, \cdots, \ell_0$.
Sample PRF keys $K_2, K_3$ for $F_2, F_3$. Let $P$ be the program described in Figure \ref{fig:program_p}. Output the quantum key $\rho_{K} = (\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P))$.
\item[] {$\mathsf{Eval}(\rho_K, x)$:} Let $\rho_{K} = (\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P))$. Parse $x$ as $x = x_0 || x_1 || x_2$ where $x_0$ is of length $\ell_0$. For all $i\in [\ell_0]$, if $x_{0, i}$ is $1$, apply $H^{\otimes n}$ to $\ket{A_{i, s_i, s'_i}}$. Otherwise, leave the state unchanged.
Let $\sigma$ be the resulting state (which can be interpreted as a superposition over tuples of $l_0$ vectors). Run ${\sf iO}(P)$ coherently on input $x$ and $\sigma$, and measure the final output register to obtain $y$.
\end{description}
\end{gamespec}
\caption{Quantum copy-protection scheme for PRFs.}
\label{fig:prf_key}
\end{figure}
The program $P$, described in Figure \ref{fig:program_p}, takes as input $x$ and $\ell_0$ vectors $v_1, \cdots, v_{\ell_0}$, and has two modes.
If $x$ is not in the sparse hidden trigger set (not passing the `if' check in the first line), the program is in the \emph{normal mode}: it outputs a PRF evaluation of $x$ if and only if every $v_i$ is in the appropriate coset. Otherwise, the program is in the \emph{hidden trigger mode}. It will compute a circuit $Q'$ from the input $x$ and output $Q'(v_1, \cdots, v_{\ell_0})$.
On almost all inputs except a sparse set of hidden triggers, the program runs in its normal mode. For $i \in [l_0]$, define the programs $R^0_i = {\sf iO}(A_i+s_i)$ and $R^1_i = {\sf iO}(A^\perp_i + s'_i)$ (where the inputs to ${\sf iO}$ should be appropriately padded).
\begin{figure}[hpt]
\centering
\begin{gamespec}
\textbf{Hardcoded:} Keys $K_1, K_2, K_3$, $R^0_i, R^1_i$ for all $i \in [\ell_0]$.
On input $x = x_0 || x_1 || x_2$ and vectors $v_1, \cdots, v_{\ell_0}$:
\begin{enumerate}
\item If $F_3(K_3, x_1) \oplus x_2 = x_0' || Q'$ and $x_0 = x'_0$ and $x_1 = F_2(K_2, x'_0 || Q')$:
\quad \textbf{Hidden Trigger Mode}: Treat $Q'$ as a (classical) circuit and output $Q'(v_1, \cdots, v_{\ell_0})$.
\item Otherwise, check if the following holds: for all $i \in [\ell_0]$, $R^{x_{0, i}}_i(v_i) = 1$ (where $x_{0, i}$ is the $i$-th bit of $x_0$).
\quad \textbf{Normal Mode}: If so, output $F_1(K_1, x)$. Otherwise, output $\bot$.
\end{enumerate}
\end{gamespec}
\caption{Program $P$}
\label{fig:program_p}
\end{figure}
We prove the following theorem:%
\revise{
\begin{theorem}
\label{thm:PRF_antipiracy}
Assuming the existence of post-quantum $\iO$, one-way functions, extremely lossy functions (ELFs), and the \revise{strong monogamy-of-entanglement property} (\Cref{conj:strong_monogamy}), our construction satisfies
anti-piracy security (as in \Cref{def:weak anti piracy}).
Similarly, assuming the existence of post-quantum sub-exponentially secure $\iO$ and one-way functions, the quantum hardness of LWE and assuming the \revise{strong monogamy-of-entanglement property} (\Cref{conj:strong_monogamy_it}), our construction satisfies
anti-piracy security.
\end{theorem}
}
We show correctness of our construction in \Cref{sec: PRF correctness}, and anti-piracy security in \Cref{sec: PRF proof anti piracy}.
The following theorem states that our construction also satisfies \Cref{def:indistinguishable_anti_piracy_PRF}.
\begin{theorem}
\label{thm:PRF_indistinguishable_antipiracy}
Assuming the existence of post-quantum $\iO$, one-way functions, extremely lossy functions (ELFs), and the \revise{strong monogamy-of-entanglement property} (\Cref{conj:strong_monogamy}), our construction satisfies indistinguishability-based anti-piracy security (as in Definition \ref{def:indistinguishable_anti_piracy_PRF}).
Similarly, assuming the existence of post-quantum sub-exponentially secure $\iO$ and one-way functions, the quantum hardness of LWE and assuming the \revise{strong monogamy-of-entanglement property} (\Cref{conj:strong_monogamy_it}), our construction satisfies indistinguishability-based anti-piracy security.
\end{theorem}
We include the proof of the latter theorem in \Cref{sec:indistinguishable_anti_piracy_PRF}.
\input{unclonable_PRF_correctness}
\input{unclonable_PRF_proof_anti_piracy}
\subsection{Preliminaries: Puncturable PRFs and related notions}
\label{sec: PRF prelim}
A \emph{puncturable} PRF is a PRF augmented with a procedure that allows to ``puncture'' a PRF key $K$ at a set of points $S$, in such a way that the adversary with the punctured key can evaluate the PRF at all points except the points in $S$. Moreover, even given the punctured key, an adversary cannot distinguish between a uniformly random value and the evaluation of the PRF at a point $S$ with respect to the original unpunctured key. Formally:
\begin{definition}[(Post-quantum) Puncturable PRF]
A PRF family $F: \{0,1\}^{n(\lambda)} \rightarrow \{0,1\}^{m(\lambda)}$ with key generation procedure $\mathsf{KeyGen}_F$ is said to be puncturable if there exists an algorithm $\mathsf{Puncture}_F$, satisfying the following conditions:
\begin{itemize}
\item \textbf{Functionality preserved under puncturing:} %
Let $S \subseteq \{0,1\}^{n(\lambda)}$. For all $x \in \{0, 1\}^{n(\lambda)}$ where $x \notin S$, we have that:
\begin{align*}
\Pr[F(K,x) = F(K_S, x): K \gets \mathsf{KeyGen}(1^\lambda), K_S \gets \mathsf{Puncture}_F(K, S)] = 1
\end{align*}
\item \textbf{Pseudorandom at punctured points:}
For every $QPT$ adversary $(A_1, A_2)$, there exists a negligible function ${\sf negl}$ such that the following holds. Consider an experiment where $K \gets \mathsf{KeyGen}_F(1^\lambda)$, $(S,\sigma) \gets A_1(1^{\lambda})$, and $K_S \gets \mathsf{Puncture}_F(K, S)$. Then, for all $x \in S$,
\begin{align*}\left|\Pr[A_2(\sigma, K_S, S, F(K, x)) = 1] - \Pr_{r \gets \{0,1\}^{m(\lambda)}}[A_2(\sigma, K_S, S, r) = 1] \right| \leq {\sf negl}(\lambda)
\end{align*}
\end{itemize}
\end{definition}
\begin{comment}
\begin{definition}[(Post-quantum) Puncturable PRF]
A puncturable PRF family of PRFs $F$ mapping is given by a triple of algorithms $\mathsf{KeyGen}_F$,
$\mathsf{Puncture}_F$, and a pair of computable functions $n(\cdot)$ and $m(\cdot)$, satisfying the following conditions:
\begin{itemize}
\item \textbf{Functionality preserved under puncturing:} For every $QPT$ adversary $A$ such that $A(1^\lambda)$ outputs
a set $S \subseteq \{0,1\}^{n(\lambda)}$, then for all $x \in \{0, 1\}^{n(\lambda)}$ where $x \notin S$, we have that:
\begin{align*}
\Pr[F(K,x) = F(K_S, x): K \gets \mathsf{KeyGen}(1^\lambda), K_S \gets \mathsf{Puncture}_F(K, S)] = 1
\end{align*}
\item \textbf{Pseudorandom at punctured points:}
For every $QPT$ adversary $(A_1, A_2)$ such that $A_1(1^\lambda)$ outputs a set $S \subseteq \{0,1\}^{n(\lambda)}$ and state $\sigma$, consider an experiment where $K \gets \mathsf{KeyGen}_F(1^\lambda)$ and $K_S = \mathsf{Puncture}_F(K, S)$. Then for all $x_i \in S$, we have:
\begin{align*}
\left|\Pr[A_2(\sigma, K_S, S, F(K, x_i)) = 1] - \Pr_{r \gets \{0,1\}^{m(\lambda)}}[A_2(\sigma, K_S, S, r) = 1] \right| \leq {\sf negl}(\lambda)
\end{align*}
\end{itemize}
\end{definition}
\end{comment}
\begin{definition}
A statistically injective (puncturable) PRF family with (negligible) failure probability $\epsilon(\cdot)$ is a (puncturable) PRF family $F$ such that with probability $1-\epsilon(\lambda)$ over the random choice of key $K \gets \mathsf{KeyGen}_F (1^\lambda)$,
we have that $F(K, \cdot)$ is injective.
\end{definition}
We will also make use of extracting PRFs: these are PRFs that are strong extractors on their inputs in the following sense.
\begin{definition}[Extracting PRF]
An extracting (puncturable) PRF with error $\epsilon(\cdot)$ for min-entropy $k(\cdot)$ is a (puncturable)
PRF $F$ mapping $n(\lambda)$ bits to $m(\lambda)$ bits such that for all $\lambda$, if $X$ is any distribution over $n(\lambda)$
bits with min-entropy greater than $k(\lambda)$, then the statistical distance between $(K, F(K, X))$
and $(K, r \gets \{0,1\}^{m(\lambda)})$ is at most $\epsilon(\cdot)$, where $K \gets \mathsf{KeyGen}(1^\lambda)$.
\end{definition}
Puncturable PRFs can be straightforwardly built by modifying the \cite{GGM86} tree-based construction of PRFs, which only assumes one-way functions. \cite{sahai2014use} showed that puncturable statistically injective PRFs and extracting puncturable PRFs with the required input-output size can be built from one-way functions as well.
These constructions can all be made post-quantum as shown in \cite{zhandry2012quantumprf}. Thus, the following theorems from \cite{sahai2014use} hold also against bounded quantum adversaries.
\begin{theorem}[\cite{sahai2014use} Theorem 1, \cite{GGM86}]
If post-quantum one-way functions exist, then for all efficiently computable
functions $n(\lambda)$ and $m(\lambda)$, there exists a post-quantum puncturable PRF family that maps $n(\lambda)$ bits to $m(\lambda)$ bits.
\end{theorem}
\begin{theorem}[\cite{sahai2014use} Theorem 2]
\label{sw14_thm2}
If post-quantum one-way functions exist, then for all efficiently computable functions $n(\lambda)$, $m(\lambda)$, and $e(\lambda)$
such that $m(\lambda) \geq 2n(\lambda) + e(\lambda)$, there exists a post-quantum puncturable statistically injective PRF family with failure
probability $2^{-e(\lambda)}$
that maps $n(\lambda)$ bits to $m(\lambda)$ bits.
\end{theorem}
\begin{theorem}[\cite{sahai2014use} Theorem 3]
\label{sw14_thm3}
If post-quantum one-way functions exist, then for all efficiently computable functions $n(\lambda)$, $m(\lambda)$, $k(\lambda)$, and
$e(\lambda)$ such that $n(\lambda) \geq k(\lambda) \geq m(\lambda) + 2e(\lambda) + 2$, there exists a post-quantum extracting puncturable PRF family that
maps $n(\lambda)$ bits to $m(\lambda)$ bits with error $2^{-e(\lambda)}$
for min-entropy $k(\lambda)$.
\end{theorem}
\subsection{Proof of Correctness}
\label{sec: PRF correctness}
First, it is easy to see that all procedures are efficient.
We then show that our construction satisfies correctness.
\begin{lemma}
The above construction has correctness.%
\end{lemma}
\begin{comment}
\begin{proof}
By Lemma \ref{lem:sw14_lem1}, for all $K_1, K_3$ and almost all except a negligible fraction of $K_2$, there are at most $2^{\ell_2}$ values of $x$ (out of all $2^{\ell_0+\ell_1+\ell_2}$ $x$ values) that can cause the step 1 check to be satisfied.
%
For those inputs $x$ that do not cause the step 1 check to pass, $\mathsf{Eval}(\rho_K, x)$ will output $F_1(K_1, x)$ with probability $1$. Thus, correctness is satisfied.
\end{proof}
\end{comment}
\begin{proof}
First, we observe that for an input $x$, keys $K_2, K_2$, if the step 1 check in the program $P$ is not met, then the output of $\mathsf{Eval}(\rho_K, x)$ will be the same as $F_1(K_1, \cdot)$ with probability $1$.
Therefore, let us assume there exists a fixed input $x^* = x_0^* || x_1^* || x_2^*$ such that for an inverse polynomial fraction of possible keys $K_2, K_3$, the step 1 check is passed. Define $\hat{x}_2^*$ be the first $\ell_0$ bits of $x_2^*$ and $\hat{F}_3(K_3, \cdot)$ be the function that outputs the first $\ell_0$ bits of $F_3(K_3, \cdot)$. $\hat{F}_3$ is a PRF because it is a truncation of another PRF $F_3$. To pass the step 1 check, $(x^*_0, x^*_1, \hat{x}^*_2)$ should at least satisfy:
\begin{align*}
\hat{F}_3(K_3, x^*_1) \oplus x^*_0 = \hat{x}^*_2.
\end{align*}
Thus, for an inverse polynomial fraction of $K_3$, the above equation holds. This gives a non-uniform algorithm for breaking the security of $\hat{F}_3$ and violates the security of $F_3$ as a consequence: given oracle access to $\hat{F}_3(K_3, \cdot)$ for a random $K_3$, or a truly random function $f(\cdot)$, the algorithm simply queries on $x^*_1$ and checks if the output is $x^*_0 \oplus \hat{x}^*_2$; if yes, it outputs $1$ (indicating the function is $\hat{F}_3(K_3,\cdot))$; otherwise, it outputs $0$ (indicating the function is a truly random funtion). Since the above equation holds for an inverse polynomial fraction of $K_3$, our non-uniform algorithm succeeds with an inverse polynomial probability.
Since non-uniform security of PRFs can be based on non-uniform security of OWFs, the correctness of our construction relies on the existence of non-uniform secure post-quantum OWFs.
\end{proof}
\subsection{Proof of Anti-Piracy Security}
\label{sec: PRF proof anti piracy}
In this subsection, we prove the anti-piracy security.
Before proving anti-piracy, we give the following helper lemma from \cite{sahai2014use}.
\begin{lemma}[Lemma 1 in \cite{sahai2014use}] \label{lem:sw14_lem1}
Except with negligible probability over the choice of the key $K_2$, the following two statements hold:
\begin{enumerate}
\item For any fixed $x_1$, there exists at most one pair $(x_0, x_2)$ that will cause the step 1 check in Program $P$ to pass.
\item There are at most $2^{\ell_2}$ values of $x$ that can cause the step 1 check to pass.
\end{enumerate}
\end{lemma}
The proof will exploit the sparse hidden triggers in the program $P$. Intuitively, we want to show that sampling a unifomly random input is indistinguishable from sampling an element from the sparse hidden trigger set. Then, we will reduce an adversary that successfully evaluates on hidden triggers to an adversary that breaks the single decryptor encryption scheme of Section \ref{sec:unclonable_dec}.
\begin{definition}[Hidden Trigger Inputs]
An input $x$ is a hidden trigger input of the program $P$ (defined in \Cref{fig:program_p}) if it makes the step 1 check in the program be satisfied.
\end{definition}
We will prove a lemma says that no efficient algorithm, given the quantum key, can distinguish between the following two cases: (i) sample two uniformly random inputs, and (ii) sample two inputs in the hidden trigger set.
Before describing the lemma, we describe an efficient procedure which takes as input an input/output pair for $F_1$, PRF keys $K_2, K_3$, descriptions of cosets, and produces a hidden trigger input.
\begin{definition}
\label{def: sample hidden triggers}
The procedure $\mathsf{GenTrigger}$ takes as input $x_0$ (of length $\ell_0$), $y$ (of length $m$, where $m$ is the length of the output of $F_1$), two PRF keys $K_2, K_3$ and hidden cosets $\{A_i, s_i, s'_i\}_{i \in [\ell_0]}$: %
\begin{enumerate}
%
\item Let $Q$ be the program (padded to length $\ell_2 - \ell_0$) that takes as input $v_1, \cdots, v_{\ell_0}$ and outputs $y$ if and only if for every input $v_i$, if $x_{0, i} = 0$, then $v_i$ is in $A_i + s_i$ and otherwise it is in $A^\perp_i + s'_i$.
\item $x'_1 \gets F_2(K_2, x_0 || Q)$;
\item $x'_2 \gets F_3(K_3, x'_1) \oplus (x_0 ||Q)$.
\item Output $x' = x_0||x'_1||x'_2$.
\end{enumerate}
\end{definition}
Note that for any $x_0, y$, $\mathsf{GenTrigger}$ will produce an input $x'$ such that it starts with $x_0$ and the evaluation of $P$ on input $x'$ and valid vectors $v_1, \cdots, v_{\ell_0}$ is $y$.
\vspace{0.5em}
The following lemma says that any efficient algorithm cannot distinguish if it gets two inputs sampled uniformly at random, or two hidden trigger inputs (sampled according to Definition \ref{def: sample hidden triggers}):
\begin{lemma}\label{lem:hidden_trigger}
Assuming post-quantum ${\sf iO}$ and one-way functions, any efficient QPT algorithm $\mathcal{A}$ cannot win the following game with non-negligible advantage:
\begin{itemize}
\item A challenger samples $K_1 \gets \mathsf{Setup}(1^\lambda)$ and prepares a quantum key $\rho_K = (\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P))$ (where recall that $P$ has keys $K_1, K_2, K_3$ hardcoded).
%
%
\item The challenger then samples a random input $u \gets [N]$. Let $y_u = F_1(K_1, u)$. Parse the input as $u = u_0||u_1||u_2$.
Let $u' \gets \mathsf{GenTrigger}(u_0, y_u, K_2, K_3, \{A_i, s_i, s'_i\}_{i \in [\ell_0]})$.
\item Similarly, it samples a random input $w \gets [N]$. Let $y_w = F_1(K_1, w)$. Parse the input as $w = w_0||w_1||w_2$.
Let $w' \gets \mathsf{GenTrigger}(w_0, y_w, K_2, K_3, \{A_i, s_i, s'_i\}_{i \in [\ell_0]})$.
\item The challenger flips a coin $b$, and sends $(\rho_K, u, w)$ or $(\rho_K, u', w')$ to $\mathcal{A}$, depending on the outcome. $\mathcal{A}$ wins if it guesses $b$.
\end{itemize}
\end{lemma}
One might wonder whether it is sufficient to just show a version of the above lemma which says that any efficient algorithm cannot distinguish if it gets \emph{one} uniformly random input or \emph{one} random hidden trigger input, and use a hybrid argument to show indistinguishability in the case of two samples. However, this is not the case, as one cannot efficiently sample a random hidden trigger input when given only the public information in the security game (in particular $\mathsf{GenTrigger}$ requires knowing $K_2, K_3$), and so the typical reduction would not go through.
\vspace{1em}
\iffalse
To prove its anti-piracy security, we give the following lemma. The lemma says no efficient algorithm, given the quantum key, could distinguish the following two cases: either sample a pair of uniformly random inputs or a pair of inputs in the sparse hidden trigger space (which will make the step 1 check in the program $P$ be satisfied).
\begin{lemma}\label{lem:hidden_trigger}
Assuming post-quantum ${\sf iO}$ and one-way functions, for every efficient QPT algorithm $\mathcal{A}$, it can not distinguish the following two cases with non-negligible advantage:
\begin{itemize}
\item A challenger samples $K \gets \mathsf{Setup}(1^\lambda)$, where $K = (\{A_i, s_i, s'_i\}_{i \in [\ell_0]}, P)$ and $P$ hardcodes $K_1, K_2, K_3$.
\item It then prepares $\rho_K$, which is $(\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P))$.
\item It samples random inputs $u, w \gets [N]$. Let $y_u = F_1(K_1, u)$ and $y_w = F_1(K_1, w)$. Parse the inputs as $u = u_0||u_1||u_2, w = w_0||w_1||w_2$.
\item Let $Q_0$ be an obfuscation of the program (padded to certain length, which is $\ell_2 - \ell_0$) that takes input $v_1 \cdots v_\ell$ and outputs $y_u$ if and only if for all inputs $v_1, \cdots, v_{\ell_0}$, if $u_{0, i} = 0$, $v_i$ is in $A_i + s_i$ and otherwise it is in $A^\perp_i + s'_i$. %
Let $u_1' \gets F_2(K_2, u_0 || Q_0)$ and $u_2'\gets F_3(K_3, u_1') \oplus (u_0||Q_0)$. Let $u' = u_0 || u_1' || u_2'$.
\item Let $Q_1$ be an %
obfuscation of the program (padded to certain length, which is $\ell_2 - \ell_0$) that takes input $v_1 \cdots v_\ell$ and outputs $y_w$ if and only if for all inputs $v_1, \cdots, v_{\ell_0}$, if $w_{0, i} = 0$, $v_i$ is in $A_i + s_i$ and otherwise it is in $A^\perp_i + s'_i$.
Let $w_1' \gets F_2(K_2, w_0 || Q_1)$ and $w_2'\gets F_3(K_3, w_1') \oplus (w_0||Q_1)$.
Let $w' = w_0 || w_1' || w_2'$.
\item It flips a coin $b$ and outputs $(\rho_K, u, w)$ or $(\rho_K, u', w')$ depends on the coin.
\end{itemize}
\end{lemma}
\fi
Next, we show that if \Cref{lem:hidden_trigger} holds, then our construction satisfies anti-piracy security \Cref{thm:PRF_antipiracy}.
After this, to finish the proof, we will only need to prove \Cref{lem:hidden_trigger}. The core of the latter proof is the ``hidden trigger'' technique used in~\cite{sahai2014use}, which we will prove in \Cref{sec: PRF hidden trigger}. %
\iffalse
\begin{lemma}
Assuming post-quantum ${\sf iO}$, one-way functions and the single-decryptor encryption scheme from the strong monogamy property, the above construction has anti-piracy security.
\end{lemma}
\fi
\begin{proof}[Proof for \Cref{thm:PRF_antipiracy}]
We mark the changes between the current hybrid and the previous {\color{red} in red}.
\paragraph{Hybrid 0.}
Hybrid 0 is the original anti-piracy security game.
\begin{enumerate}
\item The challenger samples $K_1 \gets \mathsf{Setup}(1^\lambda)$ and $\rho_K = (\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P)) \gets \mathsf{QKeyGen}(K_1)$. Note that here $P$ hardcodes $K_1, K_2, K_3$.
%
\item $\mathcal{A}$ upon receiving $\rho_K$, it runs and prepares a pair of (potentially entangled) quantum states $\sigma[R_1], \sigma[R_2]$ as well as quantum circuits $U_1, U_2$.
\item The challenger also prepares two inputs $u, w$ as follows:
\begin{itemize}
\item It samples $u$ uniformly at random.
Let $y_u = F_1(K_1, u)$.
%
\item It samples $w$ uniformly at random.
Let $y_w = F_1(K_1, w)$.
%
\end{itemize}
\item The outcome of the game is 1 if and only if both quantum programs successfully produce $y_u$ and $y_w$ respectively.
\end{enumerate}
\paragraph{Hybrid 1}
%
The difference between Hybrids 0 and 1 corresponds exactly to the two cases that the adversary needs to distinguish between in the game of \Cref{lem:hidden_trigger}.
%
\begin{enumerate}
\item The challenger samples $K_1 \gets \mathsf{Setup}(1^\lambda)$ and $\rho_K = (\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P)) \gets \mathsf{QKeyGen}(K_1)$. Note that here $P$ hardcodes $K_1, K_2, K_3$.
%
\item $\mathcal{A}$ upon receiving $\rho_K$, it runs and prepares a pair of (potentially entangled) quantum states $\sigma[R_1], \sigma[R_2]$ as well as quantum circuits $U_1, U_2$.
\item The challenger also prepares two inputs $u', w'$ as follows:
\begin{itemize}
\item It samples $u = u_0||u_1||u_2$ uniformly at random.
Let $y_u = F_1(K_1, u)$.
{\color{red}
Let $u' \gets \mathsf{GenTrigger}(u_0, y_u, K_2, K_3, \{A_i, s_i, s'_i\}_{i \in [\ell_0]})$. }
%
\item It samples $w = w_0||w_1||w_2$ uniformly at random.
Let $y_w = F_1(K_1, w)$.
{\color{red}
Let $w' \gets \mathsf{GenTrigger}(w_0, y_w, K_2, K_3, \{A_i, s_i, s'_i\}_{i \in [\ell_0]})$. }
%
%
\end{itemize}
\item The outcome of the game is 1 if and only if both quantum programs successfully produce $y_u$ and $y_w$ respectively.
\end{enumerate}
Assume there exists an algorithm that distinguishes Hybrid 0 and 1 with \emph{non-negligible} probability $\epsilon(\lambda)$, then these exists
an algorithm that breaks the game in \Cref{lem:hidden_trigger} with probability $\epsilon(\lambda) - {\sf negl}(\lambda)$.
%
The reduction algorithm receives $\rho_k$ and $u, w$ or $u', w'$ from the challenger in \Cref{lem:hidden_trigger}; it computes $y_u, y_w$ using ${\sf iO}(P)$ on the received inputs respectively and gives them to the quantum decryptor states $\sigma[R_1], \sigma[R_2]$. If they both decrypt correctly, then the reduction outputs 0 (i.e. it guess that sampling was uniform), otherwise it outputs 1 (i.e. it guesses that hidden trigger inputs were sampled).
\paragraph{Hybrid 2.} In this hybrid, if $u_0 \ne w_0$ (which happens with overwhelming probability), $F_1(K_1, u)$ and $F_1(K_1, w)$ are replaced with truly random strings. Since both inputs have enough min-entropy $\ell_1 + \ell_2 \geq m + 2\lambda + 4$ (as $u_1||u_2$ and $w_1||w_2$ are completely uniform and not given to the adversary) and $F_1$ is an extracting puncturable PRF, both outcomes $y_u, y_w$ are statistically close to independently random outcomes.
Thus, Hybrid 1 and Hybrid 2 are statistically close.
\begin{enumerate}
\item The challenger samples $K_1 \gets \mathsf{Setup}(1^\lambda)$ and $\rho_K = (\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P)) \gets \mathsf{QKeyGen}(K_1)$. Note that here $P$ hardcodes $K_1, K_2, K_3$.
%
\item $\mathcal{A}$ upon receiving $\rho_K$, it runs and prepares a pair of (potentially entangled) quantum states $\sigma[R_1], \sigma[R_2]$ as well as quantum circuits $U_1, U_2$.
\item The challenger also prepares two inputs $u', w'$ as follows:
\begin{itemize}
\item It samples {\color{red} $u_0$ uniformly at random}. It then samples {\color{red} a uniformly random $y_u$}.
Let $u' \gets \mathsf{GenTrigger}(u_0, y_u, K_2, K_3, \{A_i, s_i, s'_i\}_{i \in [\ell_0]})$.
%
\item It samples {\color{red} $w_0$ uniformly at random}. It then samples {\color{red} a uniformly random $y_w$}.
Let $w' \gets \mathsf{GenTrigger}(w_0, y_w, K_2, K_3, \{A_i, s_i, s'_i\}_{i \in [\ell_0]})$.
%
\end{itemize}
\item The outcome of the game is 1 if and only if both quantum programs successfully produce $y_u$ and $y_w$ respectively.
\end{enumerate}
\iffalse
\paragraph{Hybrid 1.} In this hybrid, we can assume $u, w$ are sampled at the beginning because they are independent from other components of the scheme. We further assume $u \ne w$ which happens with overwhelming probability. The challenger then punctures the key $K_1$ at inputs $u$ and $w$ and by the pseudorandomness at punctured points, as long as $u \ne w$, $F_1(K_1, u)$ and $F_1(K_1, w)$ can be replaced with truly random strings.
By the security of the underlying puncturable PRF and ${\sf iO}$, the distinguishability of Hybrid 0 and Hybrid 1 holds.
\begin{enumerate}
\item {\color{red} It samples $u = u_0||u_1||u_2$ and $w = w_0||w_1||w_2$ uniformly at random.}
\item A challenger samples $K \gets \mathsf{Setup}(1^\lambda)$, where $K = (\{A_i, s_i, s'_i\}_{i \in [\ell_0]}, P)$ and $P$ hardcodes ${\color{red} K^*_1}, K_2, K_3$, where {\color{red}$K^* = K_1 \setminus \{u, w\} \cup \{(u, y_u), (w, y_w)\}$ is punctured at $u, w$ and it outputs truly random strings $y_u, y_w$ on $u$ and $w$ respectively}. It then prepares $\rho_K$, which is $(\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P))$.
\item $\mathcal{A}$ upon receiving $\rho_K$, it runs and prepares a pair of (potentially entangled) quantum states $\sigma[R_1], \sigma[R_2]$ as well as quantum circuits $U_1, U_2$.
\item The challenger also prepares two inputs $u', w'$ as follows:
\begin{itemize}
\item Let $Q_0$ be an obfuscation of the program (padded to certain length, which is $\ell_2 - \ell_0$) that takes input $v_1 \cdots v_\ell$ and outputs ${\color{red} y_u}$ if and only if for all inputs $v_1, \cdots, v_{\ell_0}$, if $u_{0, i} = 0$, $v_i$ is in $A_i + s_i$ and otherwise it is in $A^\perp_i + s'_i$.
Let $u_1' \gets F_2(K_2, u_0 || Q_0)$ and $u_2'\gets F_3(K_3, u_1') \oplus (u_0||Q_0)$. Let $u' = u_0 || u_1' || u_2'$.
\item Let $Q_1$ be an obfuscation of the program (padded to certain length, which is $\ell_2 - \ell_0$) that takes input $v_1 \cdots v_\ell$ and outputs ${\color{red} y_w}$ if and only if for all inputs $v_1, \cdots, v_{\ell_0}$, if $w_{0, i} = 0$, $v_i$ is in $A_i + s_i$ and otherwise it is in $A^\perp_i + s'_i$.
Let $w_1' \gets F_2(K_2, w_0 || Q_1)$ and $w_2'\gets F_3(K_3, w_1') \oplus (w_0||Q_1)$. Let $w' = w_0 || w_1' || w_2'$.
\end{itemize}
\item The outcome of the game is 1 if and only if both quantum programs successfully produce $F(K, u') = F_1(K^*_1, u) {\color{red} = y_u}$ and $F(K, w') = F_1(K^*_1, w) {\color{red} = y_w}$ respectively.
\end{enumerate}
\fi
\paragraph{Hybrid 3.} The game in this hybrid has exactly the same distribution as that of Hybrid 2 (in the sense that all sampled values are distributed identically). We only change the order in which some values are sampled, and recognize that certain procedures become identical to encryptions in our single-decryptor encryption scheme from Section \ref{sec:unclonable_dec}.
%
Thus, $\mathcal{A}$ wins the game with the same probability as in Hybrid 2.
%
\begin{enumerate}
\item {\color{red} The challenger first samples $\{A_i, s_i, s'_i\}_{i \in [\ell_0]}$ and prepares the quantum states $\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}$}. It treat the the quantum states $\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}$ as the quantum decryption key $\rho_{{\sf sk}}$ for our single-decryptor encryption scheme and the secret key ${\sf sk}$ is $\{A_i, s_i, s'_i\}_{i \in [\ell_0]}$. Similarly, let ${\sf pk} = \{R^0_i, R^1_i\}_{i \in [\ell_0]}$ where $R^0_i = {\sf iO}(A_i+s_i)$ and $R^1_i = {\sf iO}(A^\perp_i + s'_i)$.
\item It samples $y_u, y_w$ uniformly at random. {\color{red} Let $(u_0, Q_0) \gets {\sf Enc}({\sf pk}, y_u)$ and $(w_0, Q_1) \gets {\sf Enc}({\sf pk}, y_w)$ where ${\sf Enc}({\sf pk}, \cdot)$ is the encryption algorithm of the single-decryptor encryption scheme of Construction \ref{cons: unclonable dec}}.
\item The challenger sets $\rho_K = (\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P))$.
\item $\mathcal{A}$ upon receiving $\rho_K$, it runs and prepares a pair of (potentially entangled) quantum states $\sigma[R_1], \sigma[R_2]$ as well as quantum circuits $U_1, U_2$.
\item The challenger also prepares two inputs $u', w'$ as follows (as $\mathsf{GenTrigger}$ does):
\begin{itemize}
\item
Let $u_1' \gets F_2(K_2, u_0 || Q_0)$ and $u_2'\gets F_3(K_3, u_1') \oplus (u_0||Q_0)$. Let $u' = u_0 || u_1' || u_2'$.
\item
Let $w_1' \gets F_2(K_2, w_0 || Q_1)$ and $w_2'\gets F_3(K_3, w_1') \oplus (w_0||Q_1)$. Let $w' = w_0 || w_1' || w_2'$.
\end{itemize}
\item The outcome of the game is 1 if and only if both quantum programs successfully produce ${y_u}$ and ${y_w}$ respectively.
\end{enumerate}
Note that the only differences of Hybrids 2 and 3 are the orders of executions. Namely, in Hybrid 3, $\{A_i, s_i, s'_i\}$ are sampled much earlier than when $\rho_k$ is prepared. Similarly, the obfuscation programs sampled in $\mathsf{GenTrigger}$ are now sampled much earlier than sampling $u'$ and $w'$. We write Hybrid 3 in a way that is similar to the weak anti-piracy security game of the single-decryptor encryption scheme of Construction \ref{cons: unclonable dec}.
\vspace{1em}
Given an algorithm $\mathcal{A}$ that wins the game in Hybrid 3 with non-negligible probability $\gamma(\lambda)$, we can build another algorithm $\mathcal{B}$ that breaks the (regular) $\gamma$-anti-piracy security with random challenge plaintexts (see \Cref{def:weak_ag_random}) of the underlying single-decryptor encryption scheme.
\begin{itemize}
\item $\mathcal{B}$ plays as the challenger in the game of Hybrid 3.
\item $\mathcal{B}$ receives $\rho_{{\sf sk}} = \{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}$ and ${\sf pk} = \{{\sf iO}(A_i + s_i), {\sf iO}(A^\perp_i + s'_i)\}_{i \in [\ell_0]}$ in the anti-piracy game of single-decryptor encryption.
\item $\mathcal{B}$ prepares $K_1, K_2, K_3$ and the program $P$. Let $\rho_K = (\{\ket{A_{i, s_i, s'_i}} \}_{i \in [\ell_0]}, {\sf iO}(P))$.
\item $\mathcal{B}$ gives $\rho_{K}$ to $\mathcal{A}$, and $\mathcal{A}$ prepares a pair of (potentially entangled) quantum states $\sigma[R_1], \sigma[R_2]$ as well as quantum circuits $U_1, U_2$.
\item $\mathcal{B}$ outputs the decryptors $(\sigma[R_1], \P_1)$ and $(\sigma[R_2], \P_2)$, where $\P_1$ and $\P_2$ are defined as follows: on input ($\rho_1,\mathsf{ct}_1 = (u_0 || Q_1))$ and $(\rho_2,\mathsf{ct}_2 = (w_0 || Q_2))$ respectively (where $\mathsf{ct}_1$ and $\mathsf{ct}_2$ represent encryptions of random $y_u$ and $y_w$), $\P_1$ and $\P_2$ behave respectively as follows:
\begin{itemize}
\item $\P_1$:
Let $u_1' \gets F_2(K_2, u_0 || Q_0)$ and $u_2'\gets F_3(K_3, u_1') \oplus (u_0||Q_0)$. Let $u' = u_0 || u_1' || u_2'$. Run $(\rho_1, U_1)$ on $u'$.
\item $\P_2$:
Let $w_1' \gets F_2(K_2, w_0 || Q_1)$ and $w_2'\gets F_3(K_3, w_1') \oplus (w_0||Q_1)$. Let $w' = w_0 || w_1' || w_2'$. Run $(\rho_2, U_{2})$ on $w'$ respectively.
\end{itemize}
\begin{comment}
\anote{previous last bullet:}
\item $\mathcal{B}$ outputs the programs $\P_1, \P_2$ defined as follows: on input $\mathsf{ct}_1 = (u_0, Q_1)$ and $\mathsf{ct}_2 = (w_0, Q_2)$ respectively (which represent encryptions of random $(y_u, y_w)$), $\P_1$ and $\P_2$ behave respectively as follows:
\begin{itemize}
\item
Let $u_1' \gets F_2(K_2, u_0 || Q_0)$ and $u_2'\gets F_3(K_3, u_1') \oplus (u_0||Q_0)$. Let $u' = u_0 || u_1' || u_2'$.
\item
Let $w_1' \gets F_2(K_2, w_0 || Q_1)$ and $w_2'\gets F_3(K_3, w_1') \oplus (w_0||Q_1)$. Let $w' = w_0 || w_1' || w_2'$.
\end{itemize}
Both programs then run $(\sigma[R_1], U_{1})$ on $u'$ and $(\sigma[R_2], U_{2})$ on $w'$ respectively.
\end{comment}
\end{itemize}
We know that whenever $\mathcal{A}$ succeeds in the game of Hyb 3, it outputs $y_u, y_w$ correctly. Thus, the programs prepared by $\mathcal{B}$ successfully decrypts encryptions of uniformly random plaintexts. Thus, $\mathcal{B}$ breaks $\gamma$-anti-piracy security with random challenge plaintexts.
\end{proof}
\subsection{Testing Quantum Adversaries: Projective Implementation} \label{sec:unclonable dec ati}
In this section, we include several definitions about measurements, which are relevant to testing whether quantum adversaries are successful in the security games of \Cref{sec: unclonable dec strong ag}. Part of this section is taken verbatim from \cite{aaronsonnew}. As this section only pertains directly to our security definitions for unclonable decryption schemes, the reader can skip ahead, and return to this section when reading \Cref{sec: unclonable dec strong ag}. In particular, this section is not needed to understand Sections \ref{sec: coset states} and \ref{sec: signature tokens}.
\vspace{1mm}
In classical cryptographic security games, the challenger typically gets some information from the adversary and checks if this information satisfies certain properties.
However, in a setting where the adversary is required to return \emph{quantum} information to the challenger, classical definitions of ``testing'' whether a quantum state returned by the adversary satisfies certain properties may result in various failures as discussed in \cite{z20}, as this state may be in a superposition of ``successful'' and ``unsuccessful'' adversaries. We provide here a short description of some of the difficulties in the quantum setting, and we refer the reader to \cite{z20} for a more in-depth discussion. %
\revise{
As an example, consider a security game in which an adversary is required to return some information to a challenger, which enables evaluation of a program on any input. Such a scenario is natural in copy-protection, where the adversary (a ``pirate'') attempts to create two copies of a copy-protected program, given just a single copy (and one can think of these two copies as being returned to the challenger for testing).
Naturally, one would consider a copy-protected program to be ``good'' if it enables correct evaluation on all inputs, or at least on a large fraction of all inputs. Testing correct evaluation on all inputs is of course not possible efficiently (not even classically). Instead, one would typically have the challenger \emph{estimate} the fraction of correct evaluations to high statistical confidence by picking a large enough number of inputs uniformly at random (or from an appropriate distribution), running the copy-protected program on these inputs, and computing the fraction of correct evaluations. Unfortunately, such a test does not easily translate to the quantum setting.
The reason is that the challenger only gets a single copy of the program, which in a quantum world cannot be generically copied. Moreover, in general, each evaluation may alter the copy-protected program in an irreversible way (if the outcome of the evaluation is not deterministic). Thus, estimating the fraction of inputs on which the copy-protected program received from the adversary evaluates correctly is not in general possible. For instance, consider an adversary who sends a state $\frac{1}{\sqrt{2}} \ket {P_0} + \frac{1}{\sqrt{2}} \ket {P_1}$ to the challenger, where $\ket {P_{0}}$ is a copy-protected program that evaluates perfectly on every input, and $\ket {P_{1}}$ is a useless program. Using this state, evaluation is successful on any input with probability $1/2$. Thus, even a single evaluation collapses the state either to $\ket {P_{0}}$ or to $\ket {P_1}$, preventing the challenger from performing subsequent evaluations on the original state. In fact, it is impossible to have a generic procedure that estimates the ``average success probability of evalutation'' to very high precision, as this would imply a procedure that distinguishes between the state $\frac{1}{\sqrt{2}} \ket {P_0} + \frac{1}{\sqrt{2}} \ket {P_1}$ and the state $\ket {P_0}$ almost perfectly, which is impossible since the two states have large overlap.%
}
\vspace{1em}
\paragraph{Projective Implementation}
Motivated by the discussion above, \cite{z20} formalizes a new measurement procedure for testing a state received by an adversary. We will be adopting this procedure when defining security of single-decryptor encryption schemes in Section \ref{sec: unclonable dec strong ag}.
Consider the following procedure as a binary POVM ${\mathcal{P}}$ acting on an alleged-copy-protected program $\rho$: sample a uniformly random input $x$, evaluates the copy-protected program on $x$, and checks if the output is correct.
In a nutshell, the new procedure consists of applying an appropriate projective measurement which \emph{measures} the success probability of the tested state $\rho$ under ${\mathcal{P}}$, and to output ``accept'' if the success probability is high enough. Of course, such measurement will not be able extract the exact success probability of $\rho$, as this is impossible from we have argued in the discussion above. Rather, the measurement will output a success probability from a finite set, such that the expected value of the output matches the true success probability of $\rho$. We will now describe this procedure in more detail.
The starting point is that a POVM specifies exactly the probability distribution over outcomes $\{0,1\}$ (``success'' or ``failure'') on any copy-protected program, but it does not uniquely determine the post-measurement state. Zhandry shows that, for any binary POVM ${\mathcal{P}} = (P, I-P)$, there exists a particularly nice implementation of ${\mathcal{P}}$ which is projective, and such that the post-measurement state is an eigenvector of $P$. In particular, Zhandry observes that there exists a projective measurement ${\mathcal{E}}$ which \emph{measures} the success probability of a state with respect to ${\mathcal{P}}$. More precisely,
\begin{itemize}
\item ${\mathcal{E}}$ outputs a \emph{distribution} $D$ of the form $(p, 1-p)$ from a finite set of distribution over outcomes $\{0,1\}$. (we stress that ${\mathcal{E}}$ actually outputs a distribution).
\item The post-measurement state upon obtaining outcome $(p,1-p)$ is an \emph{eigenvector} (or a mixture of eigenvectors) of $P$ with eigenvalue $p$.
\end{itemize}
A measurement ${\mathcal{E}}$ which satisfies these properties is the measurement in the common eigenbasis of $P$ and $I-P$ (such common eigenbasis exists since $P$ and $I-P$ commute).
Note that since ${\mathcal{E}}$ is projective, we are guaranteed that applying the same measurement twice will yield the same outcome. Thus, what we obtain from applying ${\mathcal{E}}$ is a state with a ``well-defined'' success probability with respect to ${\mathcal{P}}$: we know exactly how good the leftover program is with respect to the initial testing procedure ${\mathcal{P}}$.
Formally, to complete the implementation of ${\mathcal{P}}$, after having applied ${\mathcal{E}}$, one outputs the bit $1$ with probability $p$, and the bit $0$ with probability $1-p$. This is summarized in the following definition.
\begin{definition}[Projective Implementation of a POVM]
\label{def:project_implement}
Let ${\mathcal{P}} = (P, Q)$ be a binary outcome POVM. Let ${\mathcal{D}}$ be a finite set of distributions $(p, 1-p)$ over outcomes $\{0, 1\}$. Let ${\mathcal{E}} = \{E_p\}_{(p, 1-p) \in {\mathcal{D}}}$ be a projective measurement with index set ${\mathcal{D}}$. Consider the following measurement procedure:
\begin{itemize}
\item[(i)] Apply the projective measurement ${\mathcal{E}}$ and obtain as outcome a distribution $(p, 1-p)$ over $\{0, 1\}$;
\item[(ii)] Output a bit according to this distribution, i.e. output $1$ w.p $p$ and output $0$ w.p $1-p$.
\end{itemize}
We say the above measurement procedure is a projective implementation of ${\mathcal{P}}$, which we denote by ${\sf ProjImp}({\mathcal{P}})$, if it is equivalent to ${\mathcal{P}}$ (i.e. it produces the same probability distribution over outcomes).
\end{definition}
Zhandry shows that any binary POVM has a projective implementation, as in the previous definition.
\begin{lemma}[Adapted from Lemma 1 in \cite{z20}]
\label{lem:proj_implement}
Any binary outcome POVM $\mathcal{P} = (P, Q)$ has a projective implementation ${\sf ProjImp}({\mathcal{P}})$.
Moreover, if the outcome is a distribution $(p, 1-p)$ when measuring under ${\mathcal{E}}$, the collapsed state $\rho'$ is a mixture of eigenvectors of $P$ with eigenvalue $p$, and it is also a mixture of eigenvectors of $Q$ with eigenvalue $1 - p$. %
\end{lemma}
As anticipated, the procedure that we will eventually use to test a state received from the adversary will be to:
\begin{itemize}
\item[(i)] \emph{Measure} the success probability of the state,
\item[(ii)] Accept if the outcome is large enough.
\end{itemize}
As you may guess at this point, we will employ the projective measurement ${\mathcal{E}}$ defined previously for step $(i)$. We call this variant of the projective implementation a \emph{threshold implementation}.
\vspace{1em}
\paragraph{Threshold Implementation}
The concept of threshold implementation of a POVM was proposed by Zhandry, and formalized by Aaronson, Liu, Liu, Zhandry and Zhang~\cite{aaronsonnew}.
The following is a formal definition.
\begin{definition}[Threshold Implementation]
\label{def:thres_implement}
Let ${\mathcal{P}} = (P, Q)$ be a binary POVM. Let ${\sf ProjImp}({\mathcal{P}})$ be a projective implementation of ${\mathcal{P}}$, and let ${\mathcal{E}}$ be the projective measurement in the first step of ${\sf ProjImp}({\mathcal{P}})$ (using the same notation as in Definition \ref{def:project_implement}). Let $\gamma >0$. We refer to the following measurement procedure as a \emph{threshold implementation} of ${\mathcal{P}}$ with parameter $\gamma$, and we denote is as ${\sf TI}_\gamma({\mathcal{P}})$.
\begin{itemize}
\item Apply the projective measurement ${\mathcal{E}}$, and obtain as outcome a vector $(p, 1-p)$;
\item Output a bit according to the distribution $(p, 1-p)$: output $1$ if $p \geq \gamma$, and $0$ otherwise.
%
%
\end{itemize}
\end{definition}
For simplicity, for any quantum state $\rho$, we denote by $\Tr[{\sf TI}_{\gamma}({\mathcal{P}}) \, \rho]$ the probability that the threshold implementation applied to $\rho$ \textbf{outputs} $\mathbf{1}$. Thus, whenever ${\sf TI}_{\gamma}({\mathcal{P}})$ appears inside a trace $\Tr$, we treat ${\sf TI}_{\gamma}({\mathcal{P}})$ as a projection onto the $1$ outcome (i.e. the space spanned by eigenvectors of $P$ with eigenvalue at least $\gamma$).
Similarly to \Cref{lem:proj_implement}, we have the following lemma.
\begin{lemma}
\label{lem:threshold_implementation}
Any binary outcome POVM $\mathcal{P} = (P, Q)$ has a threshold implementation ${\sf TI}_{\gamma}({\mathcal{P}})$ for any $\gamma$.
%
\end{lemma}
\vspace{1em}
In this work, we are interested in threshold implementations of POVMs with a particular structure. These POVMs represent a challenger's test of a quantum state received from an adversary in a security game (like the POVM described earlier for testing whether a program evaluates correctly on a uniformly random input). These POVMs have the following structure:
\begin{itemize}
\item Sample a projective measurement from a set of projective measurements $\mathcal{I}$, according to some distribution $D$ over $\mathcal{I}$.
\item Apply this projective measurement.
\end{itemize}
We refer to POVMs of this form as \emph{mixtures of projective measurements}. The following is a formal definition.
\begin{definition}[Mixture of Projective Measurements] \label{def:mixture_of_projective}
Let $\mathcal{R}$, $\mathcal{I}$ be sets. Let $D: \mathcal{R} \rightarrow \mathcal{I}$. Let $\{(P_i, Q_i)\}_{i \in I}$ be a collection of binary projective measurements. The \emph{mixture of projective measurements} associated to $\mathcal{R}$, $\mathcal{I}, D$ and $\{(P_i, Q_i)\}_{i \in I}$ is the binary POVM ${\mathcal{P}}_D = (P_D, Q_D)$ defined as follows:
\begin{align*}
P_D = \sum_{i \in \cal I} \Pr[i \gets D(R)] \, P_i ,\,\,\,\,\,\text{ }\,\,\,\,\, Q_D = \sum_{i \in \cal I} \Pr[i \gets D(R)] \, Q_i,
\end{align*}
where $R$ is uniformly distributed in ${\mathcal{R}}$.
\end{definition}
In other words, ${\mathcal{P}}_D$ is implemented in the following way: sample randomness $r \gets {\mathcal{R}}$, compute the index $i = D(r)$, and apply the projective measurement $(P_i, Q_i)$. Thus, for any quantum state $\rho$, $\Tr[P_D \rho]$ is the probability that a projective measurement $(P_i, Q_i)$, sampled according to the distribution induced by $D$, applied to $\rho$ outputs $1$.
The following lemma will be important in the proof of security for our single-decryptor encryption scheme in Section \ref{sec:unclonable_dec}.
Informally, the lemma states the following. Let ${\mathcal{P}}_{D_0}$ and ${\mathcal{P}}_{D_1}$ be two mixtures of projective measurements, where $D_0$ and $D_1$ are two computationally indistinguishable distributions. Let $\gamma, \gamma'>0$ be inverse-polynomially close. Then for any (efficiently constructible) state $\rho$, the probabilities of obtaining outcome $1$ upon measuring ${\sf TI}_{\gamma}({\mathcal{P}}_{D_0})$ and ${\sf TI}_{\gamma'}({\mathcal{P}}_{D_1})$ respectively are negligibly close.
\begin{theorem}[Theorem 6.5 in \cite{z20}] \label{thm:ti_different_distribution}
Let $\gamma >0$. Let ${\mathcal{P}}$ be a collection of projective measurements indexed by some set $\cal I$. Let $\rho$ be an efficiently constructible mixed state, and let $D_0, D_1$ be two efficiently sampleable and computationally indistinguishable distributions over $\cal I$. For any inverse polynomial $\epsilon$, there exists a negligible function $\delta$ such that
\begin{align*}
\Tr[{\sf TI}_{\gamma - \epsilon}({\mathcal{P}}_{D_1}) \rho] \geq \Tr[{\sf TI}_{\gamma}({\mathcal{P}}_{D_0}) \rho] - \delta \,,
\end{align*}
where ${\mathcal{P}}_{D_i}$ is the mixture of projective measurements associated to ${\mathcal{P}}$ and $D_i$.
\end{theorem}
\vspace{0.5em}
\begin{comment}
\qipeng{delete the following def}
\begin{definition}[Controlled Projection]
\label{def:controlled_project}
Let ${\mathcal{P}} = \{{\mathcal{P}}_i = (P_i, Q_i)\}_{i \in \cal I}$ be a collection of binary projective measurements over a Hilbert space $\cal H$. Let $D : {\mathcal{R}} \rightarrow \cal I $.
We define the controlled projection to be the measurement ${\sf CProj}_{{\mathcal{P}}, D} = ({\sf CProj}^1_{{\mathcal{P}}, D}, {\sf CProj}^0_{{\mathcal{P}}, D})$ where:
\begin{align*}
{\sf CProj}^1_{{\mathcal{P}}, D} := \sum_{r \in {\mathcal{R}}} \ket r \bra r \otimes P_{D(r)} \quad\quad\quad {\sf CProj}^0_{{\mathcal{P}}, D} := \sum_{r \in {\mathcal{R}}} \ket r \bra r \otimes Q_{D(r)} \,.
\end{align*}
\end{definition}
In other words, ${\sf CProj}_{{\mathcal{P}}, D}$ uses outcomes $r$ as a control to decide which projective measurement to be applied to the second system. That is, ${\sf CProj}_{{\mathcal{P}}, D}$ implements the following mixed projective measurement, which is a POVM ${\mathcal{P}}_D = (P_D, Q_D)$.
\end{comment}
\vspace{1em}
\paragraph{Approximating Threshold Implementation}
\emph{Projective} and \emph{threshold} implementations of POVMs are unfortunately not efficiently computable in general.
However, they can be approximated if the POVM is a mixture of projective measurements, as shown by Zhandry \cite{z20}, using a technique first introduced by Marriott and Watrous \cite{marriott2005quantum} in the context of error reduction for quantum Arthur-Merlin games.
\begin{comment}
Before describing the approximation algorithms, we give two definitions that characterize how good an approximation projective implementation is, which were first introduced in \cite{z20}.
\begin{definition}[Shift Distance]
For two distribution $D_0, D_1$, the shift distance with parameter $\epsilon$ is defined as $\Delta_{{\sf Shift}}^\epsilon(D_0, D_1)$, which is the smallest quantity $\delta$ such that for all $x\in \mathbb{R}$:
\begin{align*}
\Pr[D_0 \leq x] &\leq \Pr[D_1 \leq x + \epsilon] + \delta, \\
\Pr[D_1 \leq x] &\leq \Pr[D_0 \leq x + \epsilon] + \delta.
\end{align*}
For two real-valued measurements $\mathcal{M}$ and ${\mathcal{N}}$ over the same quantum system, the shift distance between $\mathcal{M}$ and ${\mathcal{N}}$ with parameter $\epsilon$ is defined as,
\begin{align*}
\Delta^\epsilon_{{\sf Shift}}(\mathcal{M}, {\mathcal{N}}) := \sup_{\ket \psi} \Delta_{{\sf Shift}}^\epsilon\left( \mathcal{M} (\ket \psi), {\mathcal{N}} (\ket \psi) \right).
\end{align*}
\end{definition}
\begin{definition}[$(\epsilon, \delta)$-Almost Projective]
A real-valued quantum measurement $\mathcal{M}$ is said to be $(\epsilon, \delta)$-almost projective if for all quantum state $\ket \psi$, apply $\mathcal{M}$ twice in a row to $\ket \psi$, obtaining outcomes $X$ and $Y$. Then we have
$\Pr[|X - Y| \leq \epsilon] \geq 1 - \delta$.
\end{definition}
\begin{theorem}[Theorem 2 in \cite{z20}]\label{thm:api_projimp}
Let $D$ be any probability distribution and ${\mathcal{P}}$ be a collection of projective measurements. For any $0<\epsilon, \delta < 1$, there exists an algorithm of measurement ${\sf API}^{\epsilon, \delta}_{{\mathcal{P}}, D}$ that satisfies the followings:
\begin{itemize}
\item $\Delta^\epsilon_{{\sf Shift}}({\sf API}^{\epsilon, \delta}_{{\mathcal{P}}, D}, {\sf ProjImp}({\mathcal{P}}_D)) \leq \delta$.
\item ${\sf API}^{\epsilon, \delta}_{{\mathcal{P}}, D}$ is $(\epsilon, \delta)$-almost projective.
\item The expected running time of ${\sf API}^{\epsilon, \delta}_{{\mathcal{P}}, D}$ is $T_{{\mathcal{P}}, D} \cdot {\sf poly}(1/\epsilon, \log(1/\delta))$ where $T_{{\mathcal{P}}, D}$ is the combined running time of $D$ \revise{which maps randomness $r$ to $i$}, the procedure of mapping $i$ to $(P_i, Q_i)$ and the run-time of measurement $(P_i, Q_i)$.
\end{itemize}
\end{theorem}
\end{comment}
We will make use of the following lemma from a subsequent work of Aaronson et al.~\cite{aaronsonnew}.
\begin{lemma}[Corollary 1 in \cite{aaronsonnew}]\label{cor:ati_thresimp}
For any $\epsilon, \delta, \gamma \in (0,1)$, any collection of projective measurements ${\mathcal{P}} = \{(P_i, Q_i)\}_{i \in \mathcal{I}}$, where $\mathcal{I}$ is some index set, and any distribution $D$ over $\mathcal{I}$, there exists a measurement procedure ${\sf ATI}^{\epsilon, \delta}_{{\mathcal{P}}, D, \gamma}$ that satisfies the following:
\begin{itemize}
\item ${\sf ATI}^{\epsilon, \delta}_{{\mathcal{P}}, D, \gamma}$ implements a binary outcome measurement. For simplicity, we denote the probability of the measurement \textbf{outputting} $\mathbf{1}$ on $\rho$ by $\Tr[{\sf ATI}^{\epsilon, \delta}_{{\mathcal{P}}, D, \gamma}\, \rho]$. %
\item For all quantum states $\rho$, $\Tr[{\sf ATI}^{\epsilon, \delta}_{{\mathcal{P}}, D, \gamma}\, \rho]\geq \Tr[{\sf TI}_\gamma({\mathcal{P}}_D)\, \rho]-\delta$.
\item
For all quantum states $\rho$,
let $\rho'$ be the post-measurement state after applying ${\sf ATI}^{\epsilon, \delta}_{{\mathcal{P}}, D, \gamma}$ on $\rho$, and obtaining outcome $1$. Then, $\Tr[{\sf TI}_{\gamma-2 \epsilon}({\mathcal{P}}_D)\, \rho'] \geq 1 - 2\delta$.
%
\item
The expected running time is $T_{{\mathcal{P}}, D} \cdot {\sf poly}(1/\epsilon, 1/(\log \delta))$, where $T_{{\mathcal{P}}, D}$ is the combined running time of sampling according to $D$, of mapping $i$ to $(P_{i}, Q_{i})$, and of implementing the projective measurement $(P_{i}, Q_{i})$.
\end{itemize}
\end{lemma}
Intuitively the corollary says that if a quantum state $\rho$ has weight $p$ on eigenvectors with eigenvalues at least $\gamma$, then the measurement ${\sf ATI}^{\epsilon, \delta}_{{\mathcal{P}}, D, \gamma}$ will produce with probability at least $p - \delta$ a post-measurement state which has weight $1 - 2 \delta$ on eigenvectors with eigenvalues at least $\gamma - 2 \epsilon$. Moreover, the running time for implementing ${\sf ATI}^{\epsilon, \delta}_{{\mathcal{P}}, D, \gamma}$ is proportional to ${\sf poly}(1/\epsilon, 1/(\log \delta))$, which is a polynomial in $\lambda$ as long as $\epsilon$ is any inverse polynomial and $\delta$ is any inverse sub-exponential function.
Crucially for applications to single-decryption encryption and copy-protection, the above lemma can be generalized to pairs of POVMs on bipartite states.
\begin{lemma}[Lemma 3 in~\cite{aaronsonnew}] \label{lem:ati_2d}
Let ${\mathcal{P}}_1$ and ${\mathcal{P}}_2$ be two collections of projective measurements, indexed by elements of $\mathcal{I}$, and let $D_1$ and $D_2$ be probability distributions over $\mathcal{I}$.
For any $\epsilon, \delta, \gamma \in (0,1)$, let ${\sf ATI}^{\epsilon, \delta}_{{\mathcal{P}}_1, D_1, \gamma}$ and ${\sf ATI}^{\epsilon, \delta}_{{\mathcal{P}}_2, D_2, \gamma}$ be the measuring algorithms above. They satisfy:
\begin{itemize}
\item For any bipartite (possibly entangled, mixed) quantum state $\rho\in \mathcal{H}_{1}\otimes \mathcal{H}_{2}$,
\begin{align*}
\Tr\big[\big({\sf ATI}_{{\mathcal{P}}_1, D_1, \gamma}^{\epsilon, \delta}\otimes {\sf ATI}_{{\mathcal{P}}_2, D_2, \gamma}^{\epsilon, \delta}\big)\rho\big] \geq \Tr\big[ \big({\sf TI}_{\gamma}({\mathcal{P}}_{1, D_1})\otimes {\sf TI}_\gamma({\mathcal{P}}_{2, D_2})\big)\rho \big] - 2\delta,
\end{align*}
where ${\mathcal{P}}_{i, D_i}$ is the mixture of projective measurement corresponding to ${\mathcal{P}}_i, D_i$.
\item For any (possibly entangled, mixed) quantum state $\rho \in \mathcal{H}_{1}\otimes \mathcal{H}_{2}$,
let $\rho'$ be the (normalized) post-measurement state after applying the measurements ${\sf ATI}^{\epsilon, \delta}_{{\mathcal{P}}_1, D_1, \gamma}$ and ${\sf ATI}^{\epsilon, \delta}_{{\mathcal{P}}_2, D_2, \gamma}$ to $\rho$ and obtaining outcomes $1$ for both. Then,
\begin{align*}
\Tr\big[ \big({\sf TI}_{\gamma-2\epsilon}({\mathcal{P}}_{1, D_1})\otimes {\sf TI}_{\gamma-2\epsilon}({\mathcal{P}}_{2, D_2})\big) \rho'\big]\geq 1- 4 \delta.
\end{align*}
\end{itemize}
\end{lemma}
\iffalse
\subsubsection{Approximating Projective Implementation}
Before describing the theorem of the approximation algorithm, we give two definitions that characterize how good an approximation projective implementation is, which were first introduced in \cite{z20}.
\begin{definition}[Shift Distance]
For two distribution $D_0, D_1$, the shift distance with parameter $\epsilon$ is defined as $\Delta_{{\sf Shift}}^\epsilon(D_0, D_1)$, which is the smallest quantity $\delta$ such that for all $x \in \mathbb{R}$:
\begin{align*}
\Pr[D_0 \leq x] &\leq \Pr[D_1 \leq x + \epsilon] + \delta, \\
\Pr[D_1 \leq x] &\leq \Pr[D_0 \leq x + \epsilon] + \delta.
\end{align*}
For two real-valued measurements $\mathcal{M}$ and ${\mathcal{N}}$ over the same quantum system, the shift distance between $\mathcal{M}$ and ${\mathcal{N}}$ with parameter $\epsilon$ is defined as,
\begin{align*}
\Delta^\epsilon_{{\sf Shift}}(\mathcal{M}, {\mathcal{N}}) := \sup_{\ket \psi} \Delta_{{\sf Shift}}^\epsilon\left( \mathcal{M} (\ket \psi), {\mathcal{N}} (\ket \psi) \right).
\end{align*}
\end{definition}
\begin{definition}[$(\epsilon, \delta)$-Almost Projective]
A real-valued quantum measurement $\mathcal{M}$ is said to be $(\epsilon, \delta)$-almost projective if for all quantum state $\ket \psi$, apply $\mathcal{M}$ twice in a row to $\ket \psi$, obtaining outcomes $X$ and $Y$. Then we have
$\Pr[|X - Y| \leq \epsilon] \geq 1 - \delta$.
\end{definition}
\begin{theorem}[Theorem 2 in \cite{z20}]\label{thm:api_projimp}
Let $D$ be any probability distribution and ${\mathcal{P}}$ be a collection of projective measurements. For any $0<\epsilon, \delta < 1$, there exists an algorithm of measurement ${\sf API}^{\epsilon, \delta}_{{\mathcal{P}}, D}$ that satisfies the followings:
\begin{itemize}
\item $\Delta^\epsilon_{{\sf Shift}}({\sf API}^{\epsilon, \delta}_{{\mathcal{P}}, D}, {\sf ProjImp}({\mathcal{P}}_D)) \leq \delta$.
\item ${\sf API}^{\epsilon, \delta}_{{\mathcal{P}}, D}$ is $(\epsilon, \delta)$-almost projective.
\item The expected running time of ${\sf API}^{\epsilon, \delta}_{{\mathcal{P}}, D}$ is $T_{{\mathcal{P}}, D} \cdot {\sf poly}(1/\epsilon, \log(1/\delta))$ where $T_{{\mathcal{P}}, D}$ is the combined running time of $D$, the procedure mapping $i$ to $(P_i, Q_i)$ and the run-time of measurement $(P_i, Q_i)$.
\end{itemize}
\end{theorem}
\qipeng{ATI implementations...}
\Jiahui{probably don't need the following subsection, leave here for ref now}
\fi
\subsection{Anti-Piracy Implies CPA Security}
\label{sec:unclonable_dec_cpa_ag_implies_cpa}
\begin{lemma}
If a single-decryptor encryption scheme satisfies CPA-style $\gamma$-anti-piracy security (\Cref{def:weak_ag}) for all inverse poly $\gamma$, it also satisfies CPA security.
\end{lemma}
\begin{proof}
Let $\mathcal{A}$ be an adversary that breaks CPA security with advantage $\delta$. We construct the following adversary $\mathcal{B}$ that breaks its CPA-style $(\delta/2)$-anti-piracy security.
$\mathcal{B}$ upon receiving a public key ${\sf pk}$ and a quantum key $\rho_{{\sf sk}}$, it prepares the following programs:
\begin{itemize}
\item It runs the stateful adversary $\mathcal{A}$ on $(1^\lambda, {\sf pk})$, it outputs $(m_0, m_1)$.
\item Let $(\sigma[R_1], U_{1})$ be the stateful algorithm $\mathcal{A}$ in the CPA security game (after outputting $(m_0, m_1)$), except when it outputs a bit $b$, it outputs $m_b$; $(\sigma[R_2], U_{2})$ be the honest decryption algorithm using $\rho_{{\sf sk}}$; ${\sf aux} = (m_0, m_1)$ be the output of $\mathcal{A}$.
\end{itemize}
First, we observe that $\sigma[R_1]$ and $\sigma[R_2]$ are un-entangled. For $(\sigma[R_1], U_{1})$, because $\mathcal{A}$ wins CPA games with advantage $\delta$, here it also outputs the correct message with probability $1/2 + \delta$. For $(\sigma[R_2], U_{2})$, by the correctness of the scheme, it outputs the correct message with probability $1 - {\sf negl}(\lambda)$. Overall, $\mathcal{B}$ wins the game with probability $1/2 + \delta - {\sf negl}(\lambda) \gg 1/2 + \delta/2$.
\end{proof}
\subsection{Construction from Extractable Witness Encryption} %
\label{sec: unclonable dec witness enc}
In this section, we give an alternative construction of a single-decryptor encryption scheme. This construction uses a quantum signature token scheme as a black box. The construction is conceptually very similar to that of Section \ref{sec: unclonable dec from stronger monogamy}, but it uses extractable witness encryption instead of compute-and-compare obfuscation to deduce simultaneous extraction. Because the extraction guarantee from extractable witness encryption is stronger than the one from compute-and-compare obfuscation (we elaborate on this difference in Section \ref{sec: security uncl dec construction 2}), we do not need to reduce security of the scheme to the strong monogamy-of-entanglement property, but instead we are able to reduce security of the scheme to security of the signature token scheme (which, recall, is a primitive that we show how to construct using the computational direct product hardness property of coset states in Section \ref{sec: signature tokens}).
In the following construction, let $\mathsf{WE} = (\mathsf{WE}.{\sf Enc}, \mathsf{WE}.{\sf Enc})$ be an extractable witness encryption scheme (as in Definition \ref{def: extractable witness enc}), and let $\mathsf{TS} = (\mathsf{TS}.\mathsf{KeyGen}, \mathsf{TS}.\mathsf{TokenGen}, \mathsf{TS}.{\sf Sign}, \mathsf{TS}.\mathsf{Verify})$ be an unforgeable signature token scheme (as in Definitions \ref{def: ts} and \ref{def: ts unforgeability}). The construction below works to encrypt single bit messages, but can be extended to messages of polynomial length without loss of generality.
\begin{construction}
$\,$
\label{cons: unclonable dec 2}
\begin{itemize}
\item {$\mathsf{Setup}(1^\lambda) \to ({\sf pk}, {\sf sk})$}: Let $\kappa = \kappa(\lambda)$ be a polynomial.
\begin{itemize}
\item For each $i \in [\kappa]$, compute $(\mathsf{TS}.{\sf sk}_i, \mathsf{TS}.{\sf pk}_i) \gets \mathsf{TS}.\mathsf{KeyGen}(1^\lambda)$.
\item Output ${\sf pk} = \{\mathsf{TS}.{\sf pk}_i\}_{i \in [\kappa]}$ and ${\sf sk} = \{\mathsf{TS}.{\sf sk}_i\}_{i \in [\kappa]}$.
\end{itemize}
\item $\mathsf{QKeyGen}({\sf sk}) \to \rho_\sk:$ On input ${\sf sk} = \{\mathsf{TS}.{\sf sk}_i\}_{i \in [\kappa]}$:
\begin{itemize}
\item For $i \in [\kappa]$, compute $\ket{\mathsf{tk}_i} \gets \mathsf{TS}.\mathsf{TokenGen}(\mathsf{TS}.{\sf sk}_i)$
\item Output $\rho_\sk = \{\ket{\mathsf{tk}_i}\}_{i \in [\kappa]}$
\end{itemize}
\item {${\sf Enc}({\sf pk}, m) \to \mathsf{ct}$:}
On input a public key ${\sf pk} = \{\mathsf{TS}.{\sf pk}_i\}_{i \in [\kappa]}$ and a message $m \in \{0,1\}$;
\begin{itemize}
\item Sample a random string $r \gets \{0,1\}^\kappa$
\item Compute $\mathsf{ct}_{r,m} \gets \mathsf{WE}.{\sf Enc}(1^n, r, m)$, where $r$ is an instance of the language $L$, defined by the following $NP$ relation $R_L$. In what follows, let $w$ be parsed as $w = w_1||\cdots ||w_\kappa $, for $w_i$'s of the appropriate length.
%
\begin{align}
\label{eq:function_p}
R_L(r, w)=\begin{cases}
1 &\text{if } \mathsf{TS}.\mathsf{Verify}(\mathsf{TS}.{\sf pk}_i, r_i, w_i) = 1 \text{ for all } i \in [\kappa],\\
0 &\text{ otherwise}.
\end{cases}
\end{align}
That is, each $w_i$ should be a valid signature of $r_i$.
\item Output the ciphertext $\mathsf{ct} = (\mathsf{ct}_{r,m}, r)$.
\end{itemize}
\item {${\sf Dec}(\mathsf{ct}, \rho_\sk) \to m/ \bot$:} On input a ciphertext $\mathsf{ct} = (\mathsf{ct}_{r,m}, r)$ and a quantum secret key $\rho_\sk = \{\ket{\mathsf{tk}_i}\}_{i \in [\kappa]}$.
\begin{itemize}
\item For each $i \in [\kappa]$, sign message $r_i$ by running $(r_i, \mathsf{sig}_i) \gets \mathsf{TS}.{\sf Sign}(\ket{\mathsf{tk}_i}, r_i)$. Let $ w = \mathsf{sig}_1 || \cdots || \mathsf{sig}_\kappa$.
\item Output $m/\bot \gets\mathsf{WE}.{\sf Dec}(\mathsf{ct}_{r,m},\mathsf{sig}_1 || \cdots || \mathsf{sig}_\kappa)$.
\end{itemize}
Note in the decryption algorithm ${\sf Dec}$, we run $\mathsf{TS}.{\sf Sign}$ and $\mathsf{WE}.{\sf Dec}$ coherently, so that (by the gentle measurement lemma) an honest user can rewind and use the quantum key polynomially many times.
\end{itemize}
\end{construction}
\jiahui{comment out the following section for camera ready}
\subsection{Security of Construction \ref{cons: unclonable dec 2}}
\label{sec: security uncl dec construction 2}
The proofs of security are straightforward, and similar to the proofs given in \cite{georgiou-zhandry20}, except that here we have a new definition of $\gamma$-anti-piracy security, and we use a tokenized signature scheme instead of a one-shot signature scheme. The proof also resembles our proof of security for the construction from the strong monogamy-of-entanglement property.
We sketch the proofs here and omit some details.
\paragraph{Correctness and Efficiency. } It is straightforward to see that all procedures are efficient and
that correctness follows from the correctness
of the $\mathsf{WE}$ and $\mathsf{TS}$ schemes.
\paragraph{CPA Security. }
CPA security relies on extractable security of the witness encryption scheme and on unforgeability of the tokenized signature scheme.
Suppose that there exists a QPT adversary $\mathcal{A}$ that succeeds with non-negligible probability in its CPA security game, by the extractable security of witness encryption, there exists an extractor that extracts witness $w = \mathsf{sig}_i || \cdots || \mathsf{sig}_\kappa$, where each $\mathsf{sig}_i$ is the signature of a random bit $r_i$ that can $\mathsf{TS}.\mathsf{Verify}$. This clearly violates the unforgeability of $\mathsf{TS}$, since the adversary $\mathcal{A}$ in CPA security game is not given any tokens.
\paragraph{(Strong) $\gamma$-Anti-Piracy. }
Strong $\gamma$-anti-piracy security for any inverse-polynomial $\gamma$ also follows from extractable security of the witness encryption scheme and unforgeability of tokenized signature scheme scheme.
Suppose that there exists a QPT adversary $(\mathcal{A}_0, \mathcal{A}_1, \mathcal{A}_2)$ that succeeds with non-negligible probability in the $\gamma$-anti-piracy game. Then, with non-negligible probability over the randomness of the challenger, $\mathcal{A}_0$ outputs a state $\sigma$ such that $\sigma[R_1]$ and $\sigma[R_2]$ simultaneously pass the $\gamma$-good decryptor test with non-negligible probability. Therefore, by applying the corresponding approximation threshold implementation (${\sf ATI}$), the resulting state $\sigma'[R_1]$ and $\sigma'[R_2]$ are negligibly close to being $(\gamma-\epsilon)$-good decryptors, for any inverse polynomial $\epsilon$. %
Since $(\gamma-\epsilon)$ is inverse-polynomial, then by the extractable security of the witness encryption scheme, there must exist an extractor $E_1$ on the $R_1$ side that extracts, with non-negligible probability, a witness $w_1 = \mathsf{sig}_{1,1} || \cdots || \mathsf{sig}_{1,\kappa}$ (where each $\mathsf{sig}_{1,i}$ is a signature for bit $r_{R_1,i}$). Similarly, by \Cref{claim:unchanged_r2}, there also exists an extractor $E_2$ on the $R_2$ side that extracts witness $w_2 = \mathsf{sig}_{2,1} || \cdots || \mathsf{sig}_{2,\kappa}$ (where each $\mathsf{sig}_{2,i}$ is a signature for bit $r_{R_2,i}$) from the leftover state after extraction on $R_1$. Since $r_{R_1}, r_{R_2}$ are independently sampled, with probability $(1- 1/2^\kappa)$, there exists a position $i^*$ where $r_{R_1,i^*} \neq r_{R_2,i^*}$. We can then construct an adversary that breaks the 1-unforgeability of tokenized signatures by getting one token $\ket{\mathsf{tk}_{i^*}}$ and successfully producing signatures on two different messages $r_{R_1,i^*} \neq r_{R_2,i^*}$.
\subsection{Definitions}
\begin{definition}[Single-Decryptor Encryption Scheme]
A single-decryptor encryption scheme consists of the following efficient algorithms:
\begin{itemize}
\item $\mathsf{Setup}(1^\lambda) \to ({\sf sk}, {\sf pk}): $ a (classical) probabilistic algorithm that takes as input a security parameter $\lambda$ and outputs a classical secret key ${\sf sk}$ and public key ${\sf pk}$.
\item $\mathsf{QKeyGen}({\sf sk}) \to \rho_\sk: $ a quantum algorithm that takes as input a secret key ${\sf sk}$ and outputs a quantum secret key $\rho_\sk$.
\item ${\sf Enc}({\sf pk}, m) \to \mathsf{ct}:$ a (classical) probabilistic algorithm that takes as input a public key ${\sf pk}$, a message $m$ and outputs a classical ciphertext $\mathsf{ct}$.
\item ${\sf Dec}(\rho_\sk, \mathsf{ct}) \to m/\bot: $ a quantum algorithm that takes as input a quantum secret key $\rho_\sk$ and a ciphertext $\mathsf{ct}$, and outputs a message $m$ or a decryption failure symbol $\bot$.
\end{itemize}
\end{definition}
A secure single-decryptor encryption scheme should satisfy the following:
\begin{description}
\item \textbf{Correctness}: There exists a negligible function ${\sf negl}(\cdot)$, for all $\lambda \in \mathbb{N}$, for all $m \in \mathcal{M}$,
%
%
\begin{align*}
& \Pr\left[ {\sf Dec}(\rho_\sk, \mathsf{ct}) = m \,\middle| \begin{array}{cc}
& ({\sf sk}, {\sf pk}) \gets \mathsf{Setup}(1^\lambda), \rho_\sk \gets \mathsf{QKeyGen}({\sf sk}) \\
& \mathsf{ct} \gets {\sf Enc}({\sf pk}, m) \\
\end{array}\right] \geq 1-{\sf negl}(\lambda)
\end{align*}
%
Note that correctness \revise{implies that a honestly generated quantum decryption key} can be used to decrypt correctly polynomially many times, from the gentle measurement lemma~\cite{Aaronson05}.
\item \textbf{CPA Security}: The scheme should satisfy (post-quantum) CPA security, i.e. indistinguishability under chosen-plaintext attacks: for every (stateful) QPT adversary $\mathcal{A}$, there exists a negligible function ${\sf negl}(\cdot)$ such that for all $\lambda \in \mathbb{N}$, the following holds:
\begin{gather*}
\Pr\left[\mathcal{A}(\mathsf{ct}) = b :
\begin{array}{cl}
({\sf sk}, {\sf pk}) \gets \mathsf{Setup}( 1^\lambda) \\
((m_0,m_1) \in \mathcal{M}^2) \gets \mathcal{A}(1^\lambda, {\sf pk}) \\
b \gets \{0,1\}; \mathsf{ct} \gets {\sf Enc}({\sf pk}, m_b)
\end{array}
\right] \leq \dfrac{1}{2} + {\sf negl}(\lambda),
\end{gather*}
\end{description}
\paragraph{Anti-Piracy Security}
Next, we define anti-piracy security via the anti-piracy game below. Recall that, intuitively, anti-piracy security says that it is infeasible for a pirate who receives a quantum secret key to produce two quantum keys, which both allow successful decryption. This can be formalized into ways:
\begin{itemize}
\item (\emph{CPA-style anti-piracy}) We can ask the pirate to provide a pair of messages $(m_0, m_1)$ along with two quantum secret keys, and we test whether the two keys allow to (simultanoeusly) distinguish encryptions of $m_0$ and $m_1$.
\item (\emph{random challenge anti-piracy}) We do \emph{not} ask the pirate to provide a pair of plaintext messages, but only a pair of quantum secret keys, and we test whether the two quantum secret keys allow for simultaneous decryption of encryptions of uniformly random messages.
\end{itemize}
The reader might expect that, similarly to standard definitions of encryption security, the former implies the latter, i.e. that CPA-security (it is infeasible to distinguish encryptions of chosen plaintexts with better than negligible advantage) implies that it is infeasible to decrypt uniformly random challenges with non-negligible probability. However, for the case of anti-piracy security, this implication does not hold, as we explain in more detail in \Cref{sec:unclonable_dec_unified}. This subtlety essentially arises due to the fact that there are two parties involved, having to simultaneously make the correct guess. Therefore, we will state both definitions here, and we will later argue that our construction satisfies both.
\revise{In Section \ref{sec: unclonable dec strong ag}, we will introduce an even stronger definition of CPA-style anti-piracy (and a stronger definition for random challenge anti-piracy in \Cref{sec:strong_anti_piracy_random}). We will eventually prove that our constructions satisfy both of the strong definitions. We chose to start our presentation of unclonable decryption with the definitions in this section since they are much more intuitive than the stronger version of Section \ref{sec: unclonable dec strong ag}.} %
In order to describe the security games, it is convenient to first introduce the concept of a \emph{quantum decryptor}. The following definition is implicitly with respect to some single-decryptor encryption scheme $(\sf{Setup, QKeyGen, Enc, Dec} )$.
\begin{definition}[Quantum decryptor]
\label{def: quantum decryptor}
A \emph{quantum decryptor} for ciphertexts of length $n$, is a pair $(\rho, U)$ where $\rho$ is a state, and $U$ is a general quantum circuit acting on $n + m$ qubits, where $m$ is the number of qubits of $\rho$.
For a ciphertext $c$ of length $n$, we say that we run the quantum decryptor $(\rho, U)$ on ciphertext $c$ to mean that we execute the circuit $U$ on inputs $\ket{c}$ and $\rho$.
\end{definition}
We are now ready to describe the CPA-style anti-piracy game.
\begin{definition}[Anti-Piracy Game, CPA-style]
\label{def: regular antipiracy cpa}
Let $\lambda \in \mathbb{N}^+$.
The CPA-style anti-piracy game is the following game between a challenger and an adversary $\mathcal{A}$.
\begin{enumerate}
\item \textbf{Setup Phase}: The challenger samples keys $({\sf sk}, {\sf pk}) \gets \mathsf{Setup}(1^\lambda)$.
\item \textbf{Quantum Key Generation Phase}:
The challenger sends $\mathcal{A}$ the classical public key ${\sf pk}$ and one copy of quantum decryption key $\rho_\sk \leftarrow \mathsf{QKeyGen}({\sf sk})$. %
%
\item \textbf{Output Phase}: $\mathcal{A}$ outputs a pair of distinct messages $(m_0, m_1)$. It also outputs a (possibly mixed and entangled) state $\sigma$ over two registers $R_1, R_2$ and two general quantum circuits $U_1$ and $U_2$. We interpret $\mathcal{A}$'s output as two (possibly entangled) quantum decryptors $\mathsf{D}_1 = (\sigma[R_1], U_1)$ and $\mathsf{D}_2 = (\sigma[R_2],U_2)$.
\item \textbf{Challenge Phase:}
The challenger samples $b_1, b_2$ and $r_1, r_2$ uniformly at random and generates ciphertexts $c_1 = {\sf Enc}({\sf pk}, m_{b_1}; r_1)$ and $c_2 = {\sf Enc}({\sf pk}, m_{b_2}; r_2)$. The challenger runs quantum decryptor $\mathsf{D}_1$ on $c_1$ and $\mathsf{D}_2$ on $c_2$, and checks that $\mathsf{D}_1$ outputs $m_{b_1}$ and $\mathsf{D}_2$ outputs $m_{b_2}$. If so, the challenger outputs $1$ (the game is won by the adversary), otherwise outputs $0$. %
%
\end{enumerate}
We denote by $\sf AntiPiracyCPA(1^{\lambda}, \mathcal{A})$ a random variable for the output of the game.
\end{definition}
Note that an adversary can succeed in this game with probability at least $1/2$. It simply gives $\rho_{{\sf sk}}$ to the first quantum decryptor and the second decryptor randomly guesses the plaintext.
We remark that one could have equivalently formulated this definition by having the pirate send registers $R_1$ and $R_2$ to two separated parties Bob and Charlie, who then receive ciphertexts from the challenger sampled as in the Challenge Phase above. The two formulations are equivalent upon identifying the quantum circuits $U_1$ and $U_2$.
\begin{definition}[Anti-Piracy Security, CPA-style] \label{def:weak_ag}
Let $\gamma: \mathbb{N}^+ \rightarrow [0,1]$. A single-decryptor encryption scheme satisfies $\gamma$-anti-piracy security, if for any QPT adversary $\mathcal{A}$, there exists a negligible function ${\sf negl}(\cdot)$ such that the following holds for all $\lambda \in \mathbb{N}$:
\begin{align}
\Pr\left[b = 1, b \gets \sf{AntiPiracyCPA}(1^{\lambda}, \mathcal{A}) \right]\leq \frac{1}{2} + \gamma(\lambda) + {\sf negl}(\lambda)
\end{align}
\end{definition}
Unless specified otherwise, when discussing anti-piracy security of an unclonable encryption scheme in this work, we refer to CPA-style anti-piracy security. %
It is not difficult to show that if $\gamma$-anti-piracy security holds for all inverse poly $\gamma$, then this directly implies CPA security (we refer the reader to the appendix (\Cref{sec:unclonable_dec_cpa_ag_implies_cpa}) for the proof of this implication). %
\vspace{1em}
Next, we define an anti-piracy game with \emph{random challenge plaintexts}. This quantifies how well an efficient adversary can produce two ``quantum decryptors'' both of which enable successful decryption of encryptions of uniformly random plaintexts. This security notion will be directly useful in the security proof for copy-protection of PRFs in \Cref{sec:cp_wPRF}.
\begin{definition}[Anti-Piracy Game, with random challenge plaintexts]
\label{def: regular antipiracy random challenges}Let $\lambda \in \mathbb{N}^+$.
The anti-piracy game with random challenge plaintexts is the following game between a challenger and an adversary $\mathcal{A}$.
\begin{enumerate}
\item \textbf{Setup Phase}: The challenger samples keys $({\sf sk}, {\sf pk}) \gets \mathsf{Setup}(1^\lambda)$.
\item \textbf{Quantum Key Generation Phase}:
The challenger sends $\mathcal{A}$ the classical public key ${\sf pk}$ and one copy of quantum decryption key $\rho_\sk \leftarrow \mathsf{QKeyGen}({\sf sk})$. %
\item \textbf{Output Phase}: $\mathcal{A}$ outputs a (possibly mixed and entangled) state $\sigma$ over two registers $R_1, R_2$ and two general quantum circuits $U_1$ and $U_2$. We interpret $\mathcal{A}$'s output as two (possibly entangled) quantum decryptors $\mathsf{D}_1 = (\sigma[R_1], U_1)$ and $\mathsf{D}_2 = (\sigma[R_2],U_2)$.
\item \textbf{Challenge Phase:}
The challenger samples $m_1, m_2 \gets \mathcal{M}$ and $r_1, r_2$ uniformly at random, and generates ciphertexts $c_1 = {\sf Enc}({\sf pk}, m_1; r_1)$ and $c_2 = {\sf Enc}({\sf pk}, m_2; r_2)$. The challenger runs quantum decryptor $\mathsf{D}_1$ on $c_1$ and $\mathsf{D}_2$ on $c_2$, and checks that $\mathsf{D}_1$ outputs $m_1$ and $\mathsf{D}_2$ outputs $m_2$. If so, the challenger outputs $1$ (the game is won by the adversary), otherwise outputs $0$.
\end{enumerate}
We denote by $\sf{AntiPiracyGuess}(1^{\lambda}, \mathcal{A})$ a random variable for the output of the game.
\end{definition}
Note that an adversary can succeed in this game with probability at least $1/|\mathcal{M}|$. The adversary simply gives $\rho_{{\sf sk}}$ to the first quantum decryptor and the second decryptor randomly guesses the plaintext.
\begin{definition}[Anti-Piracy Security, with random challenge plaintexts]
\label{def:weak_ag_random}
Let $\gamma: \mathbb{N}^+ \rightarrow [0,1]$.
A single-decryptor encryption scheme satisfies $\gamma$-anti-piracy security with random challenge plaintexts, if for any QPT adversary $\mathcal{A}$, there exists a negligible function ${\sf negl}(\cdot)$ such that the following holds for all $\lambda \in \mathbb{N}$:
\begin{align}
\Pr\left[b = 1, b \gets \sf{AntiPiracyGuess}(1^{\lambda}, \mathcal{A}) \right]\leq \frac{1}{|\mathcal{M}|} + \gamma(\lambda) + {\sf negl}(\lambda)
\end{align}
where $\mathcal{M}$ is the message space.
\end{definition}
\begin{remark}
In the rest of the section, we will mainly focus on \Cref{def:weak_ag} and the stronger version of it from the next section. We will appeal to \Cref{def:weak_ag_random} when we prove security of our copy-protection scheme for PRFs. %
\end{remark}
\section{Single-Decryptor Encryption}
\label{sec:unclonable_dec}
In this section, we formally introduce unclonable decryption, i.e. single-decryptor encryption \cite{georgiou-zhandry20}. Then we describe two constructions and prove their security.
\revise{Our first construction (\Cref{sec: unclonable dec from stronger monogamy}) relies on the strong monogamy-of-entanglement property (Conjecture \ref{conj:strong_monogamy_it}), the existence of post-quantum one-way function, indistinguishability obfuscation and compute-and-compare obfuscation for (sub-exponentially) unpredictable distributions (whose existence has been discussed in \Cref{sec:cc} and \Cref{sec:CC_quantum_aux}). Our second construction (\Cref{sec: unclonable dec witness enc}) has a similar structure. It does not rely on the strong monogamy-of-entanglement property for coset states, but on the (weaker) direct product hardness{} property (Theorem \ref{thm: direct product comp}). However, the construction additionally relies on a much stronger cryptographic primitive -- post-quantum extractable witness encryption (as well post-quantum one-way functions and indistinguishability obfuscation).
}
\input{unclonable_dec_definition}
\input{unclonable_dec_strong_anti_piracy}
\subsection{Construction from Strong Monogamy Property}
\label{sec: unclonable dec from stronger monogamy}
In this section, we give our first construction of a single-decryptor encryption scheme, whose security relies on the strong monogamy-of-entanglement property from \Cref{sec: monogamy conjectured}.
In the rest of the paper, to simplify notation, whenever it is clear from the context, we will denote a program that checks membership in a set $S$ simply by $S$.
\begin{construction}
$\,$
\label{cons: unclonable dec}
\begin{itemize}
\item $\mathsf{Setup}(1^\lambda) \to ({\sf sk}, {\sf pk}):$
\begin{itemize}
\item Sample $\kappa$ random $(n/2)$-dimensional subspaces $A_i \subseteq \mathbb{F}^n_2$ for $i = 1, 2, \cdots, \kappa$, where $n = \lambda$ and $\kappa = \kappa(\lambda)$ is a polynomial in $\lambda$.
\item For each $i \in [\kappa]$, choose two uniformly random vectors $s_i, s_i' \in \mathbb{F}^n_2$. %
\item Prepare the programs ${\sf iO}(A_i + s_i)$ and ${\sf iO}(A^\perp_i + s'_i)$ (where we assume that the programs $A_i + s_i$ and $A^\perp_i + s'_i$ are padded to some appropriate length).
%
%
%
\item Output ${\sf sk} = \{A_i, s_i, s_i'\}_{i \in [\kappa]}, {\sf pk} = \{{\sf iO}({A_i+s_i}), {\sf iO}({A_i^\perp+s_i'})\}_{i \in [\kappa]}$.
\end{itemize}
\item $\mathsf{QKeyGen}({\sf sk}) \to \rho_\sk: $ %
on input ${\sf sk} = \{A_i, s_i, s_i'\}_{i \in [\kappa]}$, output the ``quantum secret key'' $\rho_\sk = \{ \ket{A_{i, s_i,s_i'}} \}_{i \in [\kappa]}$. \revise{ Recall that each $\ket {A_{i, s_i, s'_i}}$ is
\begin{align*}
\ket {A_{i, s_i, s'_i}} = \frac{1}{\sqrt{|A_i|}} \sum_{a \in A_i} (-1)^{\langle a, s'_i\rangle} \ket {a + s_i}.
\end{align*}
}
%
%
%
\iffalse
\begin{itemize}
\item prepare state $\ket{A_{i, s_i}} = \frac{1}{\sqrt{N}} \sum_{a \in A_i} \ket{a+s}$, i.e. an equal superposition of elements in $A_i+s_i$. We denote $ N = 2^{n/2}$ and we will omit normalization in the following expressions for simplicity.
\item apply QFT to $\ket{A_{i,s_i}}$ to get %
%
\iffalse
\begin{align*}
\sum_{b} \sum_{a \in A_i} \omega_N^{<b, a+s_i>} \ket{b} & = \sum_{b} \omega_N^{<b, s_i>} (\sum_{a \in A_i} \omega_N^{<b,a>}\ket{b}) \\
& = \sum_{b \in A_i^\perp} \omega_N^{<b,s_i>} \ket{b}
\end{align*}
\fi
\item add shift $s_i'$ to the state $ \sum_{b \in A_i^\perp} \omega_N^{<b,s_i>} \ket{b}$ in superposition to obtain $ \sum_{b \in A_i^\perp} \omega_N^{<b,s_i>} \ket{b+s_i'}$
\item finally, apply QFT again to state $ \sum_{b \in A_i^\perp} \omega_N^{<b,s_i>} \ket{b+s_i'}$ and obtain the following state:
$$
\ket{A_{i,s_i,s_i'}} = \sum_{a \in A_i} \omega_N^{<a,s_i'>} \ket{a+s_i}
$$
\item output $\rho_\sk = \{\ket{A_{i,s_i,s_i'}}\}_{i \in [\kappa]}$.
\end{itemize}
\fi
\item ${\sf Enc}({\sf pk}, m) \to \mathsf{ct}:$ %
on input a public key ${\sf pk} = \{{\sf iO}({A_i+s_i}), {\sf iO}({A_i^\perp+s_i'})\}_{i \in [\kappa]}$ and message $m$:
\begin{itemize}
\item Sample a uniformly random string $r \gets \{0,1\}^{\kappa}$.
\item Let $r_i$ be the $i$-th bit of $r$. Define $R_i^{0} = {\sf iO}({A_i+s_i})$ and $R_i^1 = {\sf iO}({A^\perp_i+s'_i})$. Let $\P_{m,r}$ be the following program:
\begin{figure}[hpt]
\centering
\begin{mdframed}[
linecolor=black,
leftmargin =8em,
rightmargin=8em,
usetwoside=false,
]
\revise{
On input $u = u_1 || u_2 || \cdots || u_\kappa$ (where each $u_i \in \mathbb{F}_2^n$):
\begin{enumerate}
\item If for all $i \in [\kappa]$, $R_i^{r_i}(u_i) = 1$:
\quad Output $m$
\item Else:
\quad Output $\bot$
\end{enumerate}
}
\end{mdframed}
\caption{Program $P_{m,r}$}
\label{fig:program_P_mr}
\end{figure}
\item Let $\hat{\P}_{m,r} = {\sf iO}(\P_{m,r})$. Output ciphertext $\mathsf{ct} = (\hat{\P}_{m,r}, r)$.
%
%
%
\end{itemize}
\item ${\sf Dec}(\rho_\sk, \mathsf{ct}) \to m/\bot:$ %
on input $\rho_\sk = \{\ket{A_{i, s_i, s_i'}}\}_{i \in [\kappa]}$ and $\mathsf{ct} = (\hat{\P}_{m,r}, r)$:
\begin{itemize}
\item For each $i \in [\kappa]$, if $r_i = 1$, apply $H^{\otimes n}$ to the $i$-th state $\ket{A_{i, s_i, s_i'}}$; if $r_i = 0$, leave the $i$-th state $\ket{A_{i, s_i, s_i'}}$ unchanged. Denote the resulting state by $\rho_\sk^*$.
\item Evaluate the program $\hat{\P}_{m,r}$ on input $\rho_\sk^*$ in superposition; measure the evaluation register and denote the outcome by $m'$. Output $m'$.
\revise{
\item Rewind by applying the operations in the first step again.
}
\end{itemize}
\end{itemize}
\end{construction}
\paragraph{Correctness.} %
Honest evaluation applies $H^{\otimes n}$ to $\ket{A_{i, s_i, s_i'}}$ whenever $r_i = 1$. Clearly, the coherent evaluation of ${\sf iO}(A_i + s_i)$ on $\ket{A_{i, s_i, s_i'}}$ always outputs $1$, and likewise the coherent evaluation of ${\sf iO}(A^\perp_i + s'_i)$ on $H^{\otimes n} \ket{A_{i, s_i, s_i'}}$ also always outputs $1$. Therefore, by definition of $\hat{\P}_{m,r}$, the evaluation $\hat{\P}_{m,r}(\rho_\sk^*)$ outputs $m$ with probability $1$.
\iffalse
\jiahui{remove the following CPA theorem later}
\begin{theorem}[CPA Security] \label{lem:cpa}
Assuming the quantum-hardness of LWE and the existence of post-quantum indistinguishability obfuscation and one-way functions, the single-decryptor encryption scheme has CPA security against QPT adversaries.
\end{theorem}
\fi
\begin{theorem}[Strong Anti-Piracy]
\label{thm:strong_antipiracy_unclonable_dec1}
Assuming the existence of post-quantum $\iO$, one-way functions, extremely lossy functions (ELFs), and the \revise{strong monogamy-of-entanglement property} (\Cref{conj:strong_monogamy}), the single-decryptor encryption scheme of Construction \ref{cons: unclonable dec} has strong $\gamma$-anti-piracy security for any inverse polynomial $\gamma$.
Similarly, assuming the existence of post-quantum sub-exponentially secure $\iO$ and one-way functions, the quantum hardness of LWE and assuming the \revise{strong monogamy-of-entanglement property} (\Cref{conj:strong_monogamy_it}), the single-decryptor encryption scheme of Construction \ref{cons: unclonable dec} has strong $\gamma$-anti-piracy security for any inverse polynomial $\gamma$.
\end{theorem}
In the above theorem, ELFs and the quantum hardness of LWE are for building the corresponding compute-and-compare obfuscation (see \Cref{thm:CC__from_ELF_iO} and \Cref{thm:CC_subexp_from_LWE_iO}).
We will prove this theorem in Section \ref{sec: strong antipiracy proof}.
We remark that this does \emph{not} immediately imply that there exists a negligible $\gamma$ such that strong $\gamma$-anti-piracy holds. The slightly subtle reason is that the parameter $\gamma$ in strong $\gamma$-anti-piracy is actually a parameter of the security game (rather than a measure of the success probability of an adversary in the game).
From Theorem \ref{thm: strong ap implies regular}, we know that strong $\gamma$-anti-piracy security implies regular $\gamma$-anti-piracy security. Thus, for any inverse-polynomial $\gamma$, the scheme of Construction \ref{cons: unclonable dec} has regular $\gamma$-anti-piracy security. For regular anti-piracy security, it is straightforward to see that a scheme that satisfies the notion for any inverse-polynomial $\gamma$, also satisfies it for $\gamma = 0$. Thus, we have the following.
\begin{corollary}[Regular Anti-Piracy]
\label{thm:antipiracy_unclonable_dec1}
Assuming the existence of post-quantum $\iO$, one-way functions, extremely lossy functions (ELFs), and the \revise{strong monogamy-of-entanglement property} (\Cref{conj:strong_monogamy}), the single-decryptor encryption scheme of Construction \ref{cons: unclonable dec} has regular $\gamma$-anti-piracy security for $\gamma = 0$.
Similarly, assuming the existence of post-quantum sub-exponentially secure $\iO$ and one-way functions, the quantum hardness of LWE and assuming the \revise{strong monogamy-of-entanglement property} (\Cref{conj:strong_monogamy_it}), the single-decryptor encryption scheme of Construction \ref{cons: unclonable dec} has regular $\gamma$-anti-piracy security for $\gamma = 0$.
\end{corollary}
As mentioned earlier, it is not clear whether anti-piracy security, CPA-style (Definition \ref{def: regular antipiracy cpa}) implies anti-piracy with random challenge inputs (Definition \ref{def: regular antipiracy random challenges}). Thus, we will also separately prove the latter, since in Section \ref{sec:cp_wPRF} we will reduce security of our PRF copy-protection scheme to it.
\begin{theorem}[Regular Anti-Piracy, For Random Challenge Plaintexts]
\label{thm:antipiracy_random_unclonable_dec1}
Assuming the existence of post-quantum $\iO$, one-way functions, extremely lossy functions (ELFs), and the \revise{strong monogamy-of-entanglement property} (\Cref{conj:strong_monogamy}), the single-decryptor encryption scheme has $\gamma$-anti-piracy security against random challenge plaintexts for $\gamma = 0$.
Similarly, assuming the existence of post-quantum sub-exponentially secure $\iO$ and one-way functions, the quantum hardness of LWE and assuming the \revise{strong monogamy-of-entanglement property} (\Cref{conj:strong_monogamy_it}), the single-decryptor encryption scheme has $\gamma$-anti-piracy security against random challenge plaintexts for $\gamma = 0$.
\end{theorem}
\begin{proof}
We refer the reader to \Cref{sec:strong_anti_piracy_random}. The proof follows a similar outline as the proof of CPA-style anti-piracy.
\end{proof}
\input{unclonable_dec_proof_correctness}
\input{unclonable_dec_proof_anti_piracy}
\input{unclonable_dec_WE_sigtokens}
\subsection{Proof of Strong Anti-Piracy Security of Construction \ref{cons: unclonable dec}}
\label{sec: strong antipiracy proof}
\subsection{Strong Anti-Piracy Security}
\label{sec: unclonable dec strong ag}
The stronger definition of anti-piracy security that we introduce in this section is more technically involved, and less intuitive, than the definitions in the previous section, but is easier to work with when proving security of our constructions. This section relies on preliminary concepts introduced in Section \ref{sec:unclonable dec ati}. We will refer to the anti-piracy security notions defined in the previous section as \emph{regular} anti-piracy'' to distinguish them from \emph{strong} anti-piracy defined in this section.
In order to describe the anti-piracy game in this section, we first need to formalize a procedure to test good quantum decryptors and the notion of a \emph{good quantum decryptor}. Again, the following definitions are implicitly with respect to some single-decryptor encryption scheme $(\sf{Setup, QKeyGen, Enc, Dec} )$.
\iffalse
\begin{definition}[Good quantum decryptor]
\label{def: good quantum decryptor}
Let $\gamma \in [0,1]$. Let ${\sf pk}$ be a public key, and $(m_0, m_1)$ a pair of messages. Let $(\rho, U)$ be a quantum decryptor (as in Definition \ref{def: quantum decryptor}). We say that $(\rho, U)$ is a $\gamma$-good quantum decryptor with respect to ${\sf pk}$ and $(m_0, m_1)$ if the following procedure outputs $1$ with probability at least $1/2+\gamma$:
\begin{itemize}
\item Sample a uniform $b \leftarrow \{0,1\}$. Compute $c \leftarrow {\sf Enc}({\sf pk}, m_b)$.
\item Run the quantum decryptor $(\rho',U')$ on input $c$. Check whether the outcome is $m_b$. If so, output $1$, otherwise output $0$.
\end{itemize}
\end{definition}
\fi
We first describe a procedure to test good quantum decryptors. The procedure is parametrized by a threshold value $\gamma$. We are guaranteed that, if the procedure passes, then the post-measurement state is a $\gamma$-good decryptor.
\begin{definition}[Testing a quantum decryptor]
\label{def:gamma_good_decryptor}
Let $\gamma \in [0,1]$. Let ${\sf pk}$ be a public key, and $(m_0, m_1)$ a pair of messages. We refer to the following procedure as a {test for a $\gamma$-good quantum decryptor} with respect to ${\sf pk}$ and $(m_0, m_1)$:
\begin{itemize}
\item The procedure takes as input a quantum decryptor $(\rho, U)$.
\item Let $\mathcal{P} = (P, I - P)$ be the following mixture of projective measurements (in the sense of Definition \ref{def:mixture_of_projective}) acting on some quantum state $\rho'$:
\begin{itemize}
\item Sample a uniform $b \leftarrow \{0,1\}$. Compute $c \leftarrow {\sf Enc}({\sf pk}, m_b)$.
\item Run the quantum decryptor $(\rho', U)$ on input $c$. Check whether the outcome is $m_b$. If so, output $1$, otherwise output $0$.
\end{itemize}
\item Let ${\sf TI}_{1/2 + \gamma}({\mathcal{P}})$ be the threshold implementation of ${\mathcal{P}}$ with threshold value $\frac{1}{2} + \gamma$, as defined in \Cref{def:thres_implement}. Run ${\sf TI}_{1/2 + \gamma}({\mathcal{P}})$ on $\rho$, and output the outcome. If the output is $1$, we say that the test passed, otherwise the test failed.
\end{itemize}
\end{definition}
By Lemma \ref{lem:threshold_implementation}, we have the following corollary.
\begin{corollary}[$\gamma$-good Decryptor]
\label{cor: gamma good dec}
Let $\gamma \in [0,1]$. Let $(\rho, U)$ be a quantum decryptor.
Let ${\sf TI}_{1/2 + \gamma}({\mathcal{P}})$ be the test for a $\gamma$-good decryptor defined above. Then, the post-measurement state conditioned on output $1$ is a mixture of states which are in the span of all eigenvectors of $P$ with eigenvalues at least $1/2+\gamma$. We refer to
the latter state as a $\gamma$-good decryptor with respect to $(m_0, m_1)$. %
\end{corollary}
Now we are ready to define the strong $\gamma$-anti-piracy game.
\begin{definition}[Strong Anti-Piracy Game]
\label{def:gamma_anti_piracy_game}
Let $\lambda \in \mathbb{N}^+$, and $\gamma \in [0,1]$.
The strong $\gamma$-anti-piracy game is the following game between a challenger and an adversary $\mathcal{A}$.
\begin{enumerate}
\item \textbf{Setup Phase}: The challenger samples keys $({\sf sk}, {\sf pk}) \gets \mathsf{Setup}(1^\lambda)$.
\item \textbf{Quantum Key Generation Phase}:
The challenger sends $\mathcal{A}$ the classical public key ${\sf pk}$ and one copy of quantum decryption key $\rho_\sk \leftarrow \mathsf{QKeyGen}({\sf sk})$. %
%
\item \textbf{Output Phase}: $\mathcal{A}$ outputs a pair of distinct messages $(m_0, m_1)$. It also outputs a (possibly mixed and entangled) state $\sigma$ over two registers $R_1, R_2$ and two general quantum circuits $U_1$ and $U_2$. We interpret $\mathcal{A}$'s output as two (possibly entangled) quantum decryptors $\mathsf{D}_1 = (\sigma[R_1], U_1)$ and $\mathsf{D}_2 = (\sigma[R_2],U_2)$.
\item \textbf{Challenge Phase}: The challenger runs the test for a $\gamma$-good decryptor
%
with respect to ${\sf pk}$ and $(m_0, m_1)$ on $\mathsf{D}_1$ and $\mathsf{D}_2$. The challenger outputs $1$ if both tests pass, otherwise outputs $0$.
\end{enumerate}
We denote by $\sf{StrongAntiPiracy}(1^{\lambda}, \gamma, \mathcal{A})$ a random variable for the output of the game.
\end{definition}
\begin{comment}
In order to state the definition of strong anti-piracy security, we first need to introduce the notion of a $\gamma$-good decryptor. \anote{Could we remove the word "indistinguishability" from the definition below?}
\revise{
\begin{definition}[$\gamma$-Good Indistinguishability Decryptor]
\label{def:gamma_good_decryptor}
Let $(\rho, U)$ be a quantum decryptor with respect to public key ${\sf pk}$ and auxiliary information ${\sf aux} = (m_0, m_1)$ for $m_0 \ne m_1$.
\begin{itemize}
\item Define ${\mathcal{P}}_{(m, c)} = (P_{(m, c)}, U_{(m, c)})$ be the following projective measurement:
\begin{itemize}
\item It runs $U_{{\sf Dec}}$ on the quantum state $\rho$ with input $c$.
\item It measures whether the output register is equal to $m$; outputs $1$ if yes, and $0$ otherwise.
\end{itemize}
Let ${\mathcal{P}}$ be the collection of projective measurements ${\mathcal{P}} = \{{\mathcal{P}}_{(m, c)}\}$.
\item Define $D$ be the following distribution that generates a ciphertext with respect to ${\sf pk}$ and ${\sf aux} = (m_0, m_1)$:
\begin{itemize}
\item Given randomness ${\sf rand} = b || r'$, output $(m_b, {\sf Enc}({\sf pk}, m_b; r'))$.
\end{itemize}
\item Let ${\mathcal{P}}_D = (P_D, U_D)$ be the mixture of projective measurement defined in \Cref{def:mixture_of_projective}.
\item Let ${\sf TI}_{1/2 + \gamma}({\mathcal{P}}_D)$ be the threshold implementation for ${\mathcal{P}}_D$ with threshold value $\frac{1}{2} + \gamma$, as defined in \Cref{def:thres_implement}.
\item We say a quantum decryptor is tested \textbf{$\gamma$-good with respect to public key ${\sf pk}$ and ${\sf aux}$} if the threshold implementation ${\sf TI}_{1/2 + \gamma}({\mathcal{P}}_D)$ outputs 1. \anote{is this with probability 1?} \qipeng{We define this as a testing procedure, so we say it is tested as $\gamma$-good if ... probably we can change the name in the definition title. } \anote{Oh I see. Yea then we should probably rephrase this definition to make it a bit clearer that we are defining a procedure not a subset of states. I am trying to think what is the best way to phrase things. Later on in the security proof we refer to $\gamma$-good decryptors as well, but we don't exactly define what these are.}
\end{itemize}
\end{definition}
}
Now we are ready to define the strong $\gamma$-anti-piracy game.
\begin{definition}[Strong Anti-Piracy Game]
\label{def:gamma_anti_piracy_game}
A strong anti-piracy security game for adversary $\mathcal{A}$ is denoted as ${\sf sAG}_{{\sf SDEnc}, \gamma}^{\mathcal{A}}(1^\lambda)$, which consists of the following steps:
\begin{enumerate}
\item \textbf{Setup Phase}: At the beginning of the game, the challenger takes a security parameter $\lambda$ and obtains keys $({\sf sk}, {\sf pk}) \gets \mathsf{Setup}(1^\lambda)$.
\item \textbf{Quantum Key Generation Phase}:
The challenger sends $\mathcal{A}$ the public-key ${\sf pk}$ and one copy of decryption key $\rho_\sk$. %
%
\item \textbf{Output Phase}: Finally, $\mathcal{A}$ outputs a (possibly mixed and entangled) state $\sigma$ over two registers $R_1, R_2$ and two unitaries $(U_1, U_{2})$ and auxiliary information ${\sf aux} = (m_0, m_1)$ ($m_0 \ne m_1$). They can be viewed as two quantum decryptors $\mathsf{D}_1 = (\sigma[R_1], U_{1})$ and $\mathsf{D}_2 = (\sigma[R_2],\allowbreak U_{R_2})$.
\item \textbf{Challenge Phase}: The challenger outputs 1 (for $\mathcal{A}$'s winning) if and only if \emph{both} quantum decryptors $\mathsf{D}_1, \mathsf{D}_2$ are tested to be $\gamma$-good with respect to ${\sf pk}$ and ${\sf aux}$.
\end{enumerate}
\end{definition}
\end{comment}
\begin{definition}[Strong Anti-Piracy-Security] \label{def:strong_ag}
Let $\gamma: \mathbb{N}^+ \rightarrow [0,1]$. A single-decryptor encryption scheme satisfies strong $\gamma$-anti-piracy security, if for any QPT adversary $\mathcal{A}$, there exists a negligible function ${\sf negl}(\cdot)$ such that the following holds for all $\lambda \in \mathbb{N}$:
\begin{align}
\Pr\left[b = 1, b \gets \sf{StrongAntiPiracy}(1^{\lambda}, \gamma(\lambda), \mathcal{A}) \right]\leq {\sf negl}(\lambda)
\end{align}
\end{definition}
\Cref{def:strong_ag} implies \Cref{def:weak_ag}. %
\begin{theorem}
\label{thm: strong ap implies regular}
Let $\gamma: \mathbb{N}^+ \rightarrow [0,1]$. Suppose a single-decryptor encryption scheme satisfies strong $\gamma$-anti-piracy security (Definition \ref{def:strong_ag}). Then, it also satisfies $\gamma$-anti-piracy security (Definition \ref{def:weak_ag}).
\end{theorem}
\begin{proof}
We refer the reader to appendix (\Cref{sec:unclonable dec strong_implies_weak}) for the proof.
\end{proof}
In a similar way, one can define a stronger version of random challenge anti-piracy security (\Cref{def:weak_ag_random}). We leave the details to (\Cref{sec:strong_anti_piracy_random}).
\subsection{Strong Anti-Piracy Implies Regular Definition}
\label{sec:unclonable dec strong_implies_weak}
In this section, we show the notion of strong anti-piracy security from Definition \ref{def:strong_ag} implies that from Definition \ref{def:weak_ag}.
\begin{proof}
Assume a single-decryptor encryption scheme satisfies the strong notation of anti-piracy. For any adversary $\mathcal{A}$, consider the game $\mathsf{StrongAntiPiracy}$: %
\begin{itemize}
\item At the beginning of the game, the challenger takes a security parameter $\lambda$ and obtains keys $({\sf sk}, {\sf pk}) \gets \mathsf{Setup}(1^\lambda)$.
\item The challenger sends $\mathcal{A}$ public-key ${\sf pk}$ and one copy of decryption key $\rho_\sk$ corresponding to ${\sf pk}$.
\item $\mathcal{A}$ finally outputs two (entangled) quantum decryptors $\mathsf{D}_1 = (\sigma[R_1], U_{1})$ and $\mathsf{D}_2 = (\sigma[R_2],\allowbreak U_{2})$ and ${\sf aux} = (m_0, m_1)$ ($m_0 \ne m_1$)
\item The challenger outputs 1 (for $\mathcal{A}$ winning) if and only if \emph{both} quantum decryptors $\mathsf{D}_1, \mathsf{D}_2$ are tested to be $\gamma$-good with respect to ${\sf pk}$ and ${\sf aux}$.
\end{itemize}
It (the challenger outputs $1$) happens with only negligible probability.
In other words, with overwhelming probability over the distribution of $({\sf sk}, {\sf pk})$ and $(m_0, m_1)$, by applying projective measurement (the projective measurement ${\mathcal{E}}_1, {\mathcal{E}}_2$ inside both threshold implementations) and obtaining $(d_1, d_0)$ and $(d'_1, d'_0)$ for $\mathsf{D}_1, \mathsf{D}_2$ respectively, at least one of $d_1, d'_1$ is smaller than $\frac{1}{2} + \gamma$, by \Cref{def:gamma_good_decryptor} (the definition of $\gamma$-good decryptor).
Also note that, in \Cref{def:weak_ag}, the game only differs in the test phase,
\begin{itemize}
\item The first three steps are identical to those in the above game.
\item The challenger samples $b_1, b_2$ and $r_1, r_2$ uniformly at random and generates ciphertexts $c_1 = {\sf Enc}({\sf pk}, m_{b_1}; r_1)$ and $c_2 = {\sf Enc}({\sf pk}, m_{b_2}; r_2)$. The challenger runs $\sf D_1$ on $c_1$ and $\sf D_2$ on $c_2$ and it outputs $1$ (the game is won by the adversary) if and only if $\sf D_1$ outputs $m_{b_1}$ and $\sf D_2$ outputs $m_{b_2}$.
\end{itemize}
By the definition of projective measurement (\Cref{def:project_implement}), the distribution of the second game, can be computed by its projective measurement.
In other words, the test phase can be computed in the following equivalent way:
\begin{itemize}
\item Apply the projective measurement ${\mathcal{E}}_1, {\mathcal{E}}_2$ and obtain $(d_1, d_0)$ and $(d'_1, d'_0)$ for $\mathsf{D}_1, \mathsf{D}_2$ respectively. The challenger then samples two bits $b_1, b_2$ independently, where $b_1 = 1$ with probability $d_1$ and $b_2 = 1$ with probability $d'_1$. It outputs $1$ if and only if $b_1 = b_2 = 1$.
\end{itemize}
Since we know that with overwhelming probability over the distribution of $({\sf sk}, {\sf pk})$ and $(m_0, m_1)$, by applying projective measurement and obtaining $(d_1, d_0)$ and $(d'_1, d'_0)$ for $\mathsf{D}_1, \mathsf{D}_2$ respecitvely, at least one of $d_1, d'_1$ is smaller than $\frac{1}{2} + \gamma$, we can bound the probability of succeeding in the second game.
\begin{align*}
\Pr[\text{$\mathcal{A}$ succeeds}] &\leq 1 \cdot \Pr\left[d_1 \geq \frac{1}{2} + \gamma \,\wedge\, d'_1 \geq \frac{1}{2} + \gamma \right] \\
& \quad\quad\quad\quad + \left(\frac{1}{2} + \gamma\right) \cdot \Pr\left[d_1 \leq \frac{1}{2} + \gamma \,\vee\, d'_1 \leq \frac{1}{2} + \gamma \right] \\
&\leq {\sf negl}(\lambda) + \left(\frac{1}{2} + \gamma\right)
\end{align*}
Therefore, it also satisfies the weak definition (\Cref{def:weak_ag}).
\end{proof}
\subsection{Unified Definitions}
\label{sec:unclonable_dec_unified}
In \Cref{sec:unclonable_dec}, we define two anti-piracy security, namely \Cref{def:weak_ag} for chosen plaintexts and \Cref{def:weak_ag_random} for random plaintexts. In this section, we propose a unified definition and a stronger version of this unified definition. At the end of this section, we will briefly explain why our construction satisfies this strong unified definition. This can be done based on the proof for \Cref{thm:strong_antipiracy_unclonable_dec1}, with little extra effort.
\begin{definition}[General Anti-Piracy Game]
The anti-piracy game is defined through the following game ${\sf AG}_{{\sf SDEnc}}^{\mathcal{A}, {\sf general}}(1^\lambda)$
\begin{enumerate}
\item \textbf{Setup Phase}: At the beginning of the game, the challenger takes a security parameter $\lambda$ and samples keys $({\sf sk}, {\sf pk}) \gets \mathsf{Setup}(1^\lambda)$.
\item \textbf{Query Phase}:
The challenger sends $\mathcal{A}$ the classical public-key ${\sf pk}$ and one copy of quantum decryption key $\rho_\sk$.
\item \textbf{Output Phase}: Finally, $\mathcal{A}$ outputs a (possibly mixed and entangled) state $\sigma$ over two registers $R_1, R_2$ and two unitaries $(U_{1}, U_{2})$. They can be viewed as two quantum decryptors $\mathsf{D}_1 = (\sigma[R_1], U_{1})$ and $\mathsf{D}_2 = (\sigma[R_2],\allowbreak U_{2})$. It also outputs two subspaces $S_1, S_2 \subseteq \mathcal{M}$ (with short descriptions).
\item \textbf{Test Phase:}
The challenger samples $m_1 \gets S_1, m_2 \gets S_2$ and $r_1, r_2$ uniformly at random and generates ciphertexts $c_1 = {\sf Enc}({\sf pk}, m_1; r_1)$ and $c_2 = {\sf Enc}({\sf pk}, m_2; r_2)$. The challenger runs $D_1$ on $c_1$ and $D_2$ on $c_2$ and it outputs $1$ (the game is won by the adversary) if and only if $D_1$ outputs $m_1$ and $D_2$ outputs $m_2$.
\end{enumerate}
\end{definition}
Note that an adversary can succeed in the game with probability at least $1/|\mathcal{M}|$. It simply gives $\rho_{{\sf sk}}$ to the first quantum decryptor and the second decryptor randomly guesses the plaintext.
\fi
\subsection{Strong Anti-Piracy, with Random Challenge Plaintexts}
\label{sec:strong_anti_piracy_random}
\begin{definition}[Testing a quantum decryptor, with random challenge plaintexts]
\label{def:gamma_good_decryptor_random}
Let $\gamma \in [0,1]$. Let ${\sf pk}$ be a public key. We refer to the following procedure as a {$\gamma$-good test for a quantum decryptor} with respect to ${\sf pk}$ and random challenge plaintexts:
\begin{itemize}
\item The procedure takes as input a quantum decryptor $(\rho, U)$.
\item Let $\mathcal{P} = (P, I - P)$ be the following mixture of projective measurements (in the sense of Definition \ref{def:mixture_of_projective}) acting on some quantum state $\rho'$:
\begin{itemize}
\item Sample a uniform random message $m \leftarrow \mathcal{M}$. Compute $c \leftarrow {\sf Enc}({\sf pk}, m)$.
\item Run the quantum decryptor $(\rho',U)$ on input $c$. Check whether the outcome is $m$. If so, output $1$, otherwise output $0$.
\end{itemize}
\item Let ${\sf TI}_{1/|\mathcal{M}| + \gamma}({\mathcal{P}})$ be the threshold implementation of ${\mathcal{P}}$ with threshold value $\frac{1}{|\mathcal{M}|} + \gamma$, as defined in \Cref{def:thres_implement}. Run ${\sf TI}_{1/|\mathcal{M}| + \gamma}({\mathcal{P}})$ on $(\rho, U)$, and output the outcome. If the output is $1$, we say that the test passed, otherwise the test failed.
\end{itemize}
\end{definition}
Now we are ready to define the strong $\gamma$-anti-piracy game.
\begin{definition}[(Strong) $\gamma$-Anti-Piracy Game, with Random Challenge Plaintexts]
\label{def:gamma_anti_piracy_game_random}
A strong anti-piracy security game (for random plaintexts) for adversary $\mathcal{A}$ is denoted as $\sf{StrongAntiPiracyGuess}(1^\lambda)$, which consists of the following steps: %
\begin{enumerate}
\item \textbf{Setup Phase}: At the beginning of the game, the challenger takes a security parameter $\lambda$ and obtains keys $({\sf sk}, {\sf pk}) \gets \mathsf{Setup}(1^\lambda)$.
\item \textbf{Quantum Key Generation Phase}:
The challenger sends $\mathcal{A}$ the public-key ${\sf pk}$ and one copy of decryption key $\rho_\sk$. %
%
\item \textbf{Output Phase}: Finally, $\mathcal{A}$ outputs a (possibly mixed and entangled) state $\sigma$ over two registers $R_1, R_2$ and two quantum circuits $(U_1, U_{2})$. They can be viewed as two quantum decryptors $\mathsf{D}_1 = (\sigma[R_1], U_{1})$ and $\mathsf{D}_2 = (\sigma[R_2],\allowbreak U_{2})$.
\item \textbf{Challenge Phase}: The challenger outputs 1 (for $\mathcal{A}$'s winning) if and only if \emph{both} quantum decryptors $\mathsf{D}_1, \mathsf{D}_2$ are tested to be $\gamma$-good with respect to ${\sf pk}$ and random challenge plaintexts.
\end{enumerate}
\end{definition}
\begin{definition}[(Strong) $\gamma$-Anti-Piracy-Security] \label{def:strong_ag_random}
A single-decryptor encryption scheme satisfies strong $\gamma$-anti-piracy security against random plaintexts, if for any QPT adversary $\mathcal{A}$, there exists a negligible function ${\sf negl}(\cdot)$ such that the following holds for all $\lambda \in \mathbb{N}$:
\begin{align}
\Pr\left[b = 1, b \gets \sf{StrongAntiPiracyGuess}(1^\lambda) \right]\leq {\sf negl}(\lambda)
\end{align}
\end{definition}
We claim \Cref{def:strong_ag_random} implies \Cref{def:weak_ag_random}. %
The proof is done in the same way as that in \Cref{sec:unclonable dec strong_implies_weak}. We omit the proof here.
To prove both our constructions satisfy the strong anti-piracy security against random messages:
\begin{itemize}
\item Construction based on strong monogamy property: the proof works in the exactly same way, except the compute-and-compare program $\mathsf{CC}[f, y, m_b]$ for a uniform bit $b$ should be replaced with $\mathsf{CC}[f, y, m]$ for a uniformly random message $m$.
\item Construction based on extractable witness encryption: the proof works in the exact same way.
\end{itemize}
\subsection{Comparing \texorpdfstring{\Cref{def:weak_ag}}{Regular Anti-Piracy Security} with \texorpdfstring{\Cref{def:weak_ag_random}}{Anti-Piracy Security with Random Ciphertexts}}
\label{sec:unclonable_dec_unified}
In \Cref{sec:unclonable_dec}, we define two anti-piracy security, namely \Cref{def:weak_ag} for chosen plaintexts and \Cref{def:weak_ag_random} for random plaintexts. In this section, we discuss their relationship.
One would hope that anti-piracy security against chosen plaintexts (\Cref{def:weak_ag}) implies anti-piracy security against random plaintexts (\Cref{def:weak_ag_random}), which is an analogue of security against chosen plaintext attack implies security against random plaintext attack (decrypting encryptions of random messages). However, we realize that it is unlikely to be the case for anti-piracy security. Although it is not a formal proof, this intuition explains where thinks might fail.
Consider an adversary that breaks \Cref{def:weak_ag_random}. Assume it outputs the following decryptor state:
\begin{align*}
\left(\sqrt{\gamma} \ket {\sf good} + \sqrt{1 - \gamma} \ket {\sf bad}\right)^{\otimes 2},
\end{align*}
where $\ket{\sf good}$ is a perfect decryptor state and $\ket{\sf bad}$ is a garbage state that is orthogonal to $\ket {\sf good}$. It is easy to see that it breaks \Cref{def:weak_ag_random} with advantage $\gamma^2$. However, each side can only win the CPA security game with advantage at most $1/2 + \gamma$ independently. Therefore, its advantage for \Cref{def:weak_ag} is $(1/2 + \gamma)^2$, which is smaller than the trivial advantage $1/2$.
| {'timestamp': '2022-01-11T02:15:59', 'yymm': '2107', 'arxiv_id': '2107.05692', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05692'} | arxiv |
\section{Introduction}
Within the general framework of graph coloring problems there exists an important class of problems that is related to the frequency assignment problem: for a given set of transmitters (which are represented by the vertices
of a graph) and their adjacency (i.e. adjacent transmitters are close
enough or have strong enough signal), assign the frequency bands to the transmitters in a way that keeps interference below a defined level while minimizing total frequency span.
In some applications it makes sense to distinguish a certain substructure of the network (called the \emph{backbone}), designed as the most important part for the communication, so it has to meet additional restrictions on the assignment.
This leads us to the backbone coloring problem, introduced by Broersma in \cite{broersma2007backbone}. First, let us define formally the backbone coloring, using a standard graph notation, e.g. from \cite{murty2008graph}:
\begin{definition}
Let $G$ be a graph and $H$ be a subgraph of $G$ with $V(G) = V(H)$. Let also $\lambda \in \mathbb{N}_+$, $\lambda \ge 2$.
The \emph{$\lambda$-backbone coloring} of $G$ with backbone $H$ is defined as a function $c\colon V(G) \to \mathbb{N}_+$ such that
\begin{itemize}
\item $c(u) \neq c(v)$ for every $uv \in E(G)$,
\item $|c(u) - c(v)| \ge \lambda$ for every $uv \in E(H)$.
\end{itemize}
\end{definition}
Note that it differs from the vertex coloring problem in important ways: in an optimal $\lambda$-backbone coloring (i.e. using a minimum number of colors) the ordering of the colors matters, therefore we might observe that some smaller colors are not used while the larger ones are in use.
Broersma et. al. in \cite{broersma2007backbone} also defined the backbone coloring problem as an extension of a classical vertex coloring problem:
\begin{definition}
Let $G$ be a graph and $H$ be a subgraph of $G$ with $V(G) = V(H)$. Let also $\lambda$ be a natural number greater than $1$.
The \emph{$\lambda$-backbone coloring problem} is defined as following:
for a given $k$ does there exists $c\colon V(G) \to [1, k]$ such that $c$ is a $\lambda$-backbone coloring of $G$ with backbone $H$.
\end{definition}
The \emph{$\lambda$-backbone coloring number} for a graph $G$ with backbone $H$ (denoted as $BBC_\lambda(G, H)$) is then defined as the smallest $k$ such that there exists a $\lambda$-backbone coloring of $G$ with backbone $H$.
Note that here and throughout the whole paper we rely on the notation $[a, b]$ representing a set of integers between $a$ and $b$, inclusive.
In general, it is straightforward to prove that the problem of determining $BBC_\lambda(G, H)$ is $\mathcal{NP}$-hard \cite{broersma2007backbone}.
In the same paper which introduced this problem there were shown basic bounds on the value of the $\lambda$-backbone coloring number, depending on $\chi(G)$, the chromatic number of $G$:
\begin{theorem}[Broersma et al., \cite{broersma2007backbone}]
Let $G$ be a graph and $H$ its subgraph.
Then $\chi(G) \le BBC_{\lambda}(G, H) \le \lambda(\chi(G) - 1) + 1$.
\end{theorem}
In \cite{havet2014circular} and \cite{janczewski2015backbone} there were proposed other bounds, suited particularly for graphs with $\chi(H) \ll \chi(G)$:
\begin{theorem}[Havet et al., \cite{havet2014circular}] Let $G$ be a graph and $H$ its subgraph.
Then $BBC_{\lambda}(G, H) \le (\lambda + \chi(G) - 2) \chi(H) - \lambda + 2$.
\end{theorem}
\begin{theorem}[Janczewski, Turowski, \cite{janczewski2015backbone}]
Let $G$ be a graph on $n$ vertices and $H$ its subgraph. Then $\lambda(\chi(H) - 1) + 1 \le BBC_{\lambda}(G, H) \le \lambda(\chi(H) - 1) + n - \chi(H) + 1$.
\end{theorem}
The $\lambda$-backbone coloring problem was studies for several classes of graphs, for example split graphs \cite{broersma2009backbone}, planar graphs \cite{havet2014circular}, complete graphs \cite{janczewski2015computational}, and for several classes of backbones: matchings and disjoint stars \cite{broersma2009backbone}, bipartite graphs \cite{janczewski2015computational} and forests \cite{havet2014circular}.
For a special case $\lambda = 2$ it was also studies for may other cases e.g. triangle-free graphs with tree backbones \cite{mivskuf2009backbone}, outerplanar graphs with matching backbones \cite{araujo2019backbone} and general graphs with bounded degree backbones \cite{mivskuf2010backbone} or with tree and path backbones \cite{broersma2007backbone}.
In this paper, we turn our attention to the special case when the graph is complete (denoted $K_n$) and its backbone is a (nonempty) tree or a forest (which we will denote by $T$ and $F$, respectively).
Note that it has a natural interpretation as a labeling problem: how to assign different labels to all vertices such that on every backbone edge the difference between labels is at least $\lambda$.
This description draws a comparison e.g. to $L(k, 1)$-labeling problem (see e.g. \cite{calamoneri2011h} for a survey), where the colors of any two adjacent vertices have to differ by at least $k$ and the colors of any two vertices within distance $2$ have to be distinct.
In our case it is obvious that $\chi(K_n) = n$, $\chi(F) = 2$ and the theorems presented above combined together give us the following bounds:
\begin{align*}
\max\{n, \lambda + 1\} \le BBC_{\lambda}(K_n, F) \le \lambda + n - 1.
\end{align*}
Moreover, it was proved before in \cite{janczewski2015backbone} that there exists a $2$-approximate algorithm for complete graphs with bipartite backbones and a $3/2$-approximate algorithm for complete graphs with connected bipartite backbones. Both algorithms run in linear time. As a corollary, it was proved that we can compute $BBC_\lambda(K_n, F)$ in quadratic time, provided that $F$ is a tree on $n$ vertices and $\lambda > n - 2$.
On the other hand, for $\lambda = 2$ we know that $BBC_\lambda(K_n, F) \le n + 1$ and we can solve the problem in polynomial time \cite[Theorem 3]{turowski2015optimal}. However, this leaves us with the large gap for the intermediate values of $\lambda$, which we try to address in this paper.
We start \Cref{sec:positive} by proving that if $F$ is a tree or forest on $n$ vertices with a maximum degree $\Delta(F)$, then $BBC_{\lambda}(K_n, F) \le \max\{n, 2 \lambda\} + \Delta^2(F) \lceil\log{n}\rceil$.
Note that this bound can be much better than the previously known ones, especially for $\lambda$ close to $\frac{n}{2}$ and small $\Delta(F)$.
We also provide a polynomial (linear for trees, quadratic for forests) algorithm to find the respective $\lambda$-backbone coloring.
This, in turn, combined with another much simpler algorithm allows us to show that we can find in polynomial time a $\lambda$-backbone coloring for $G$ with backbone forest $F$ that uses at most $\Delta^2(F) \lceil\log{n}\rceil$ colors more than the optimal algorithm.
Previously it was known that $BBC_{\lambda}(K_n, T) = \lambda + n - 1$ when $T$ is a star. However, one can ask a more general question: how large can $BBC_{\lambda}(K_n, T)$ be when $\Delta(T)$ is small.
In \Cref{sec:negative} we show that there exists a family of trees with $\Delta(T) = 3$ such that $BBC_\lambda(K_n, T) \ge \max\{n, 2 \lambda\} + \frac{1}{48} \log_\phi{n} - 3$.
This result is complementary to the one in the previous section, as it shows that sometimes we need up to $\max\{n, 2 \lambda\} + \Theta(\log{n})$ colors even when we have $\Delta(T) = 3$. In a sense, we might also say that the logarithmic loss over a trivial lower bound $BBC_\lambda(K_n, T) \ge \max\{n, \lambda + 1\}$ for backbone coloring of $K_n$ with a tree backbone $T$ is tight.
Finally, \Cref{sec:open} concludes with a presentation of some open problems related to our work.
\section{Complete graph with tree or forest backbone: an algorithm}
\label{sec:positive}
In this section we will proceed as following: we first introduce so-called red-blue-yellow $(k,l)$-decomposition of a forest $F$ on $n$ vertices, which finds a small set $Y$ (of size $l$) such that we can split $V(F) \setminus Y$ into two independent and almost equal sets $R$, $B$ (with $|R| - |B| \le k$).
Then, we show that we can color $R$ and $B$ with sets of consecutive colors and assign to vertices from $Y$ the smallest and the largest colors in a way that in total we find a $\lambda$-backbone coloring in which the maximum color does not exceed $\max\{n, 2 \lambda\}$ more than $\Delta^2(F) \log{n}$.
We start with a few remarks on notation and some definitions.
Let $c$ be a unique $2$-coloring (up to the permutations of colors) of a tree $T$.
Let us also define $C_i(T) = \{v \in V(T)\colon c(v) = i\}$, i.e. the number of vertices in color $i$, for $i = 1, 2$.
Assume without loss of generality that $c$ is such that $C_i(T)$ form a non-increasing sequence.
Throughout the paper we will use a concept of tree imbalance, defined formally as:
\begin{definition}
Let $T$ be a tree and $c$ its $2$-coloring with properties described above.
We define the \emph{imbalance number} $imb(T)$ as the difference $C_1(T) - C_2(T)$.
\end{definition}
From this definition it directly follows that $imb(T) \ge 0$.
\begin{lemma}
\label{lem:tree_half}
In every tree $T$ there exists a vertex $v \in V(T)$ such that every connected component of $T - v$ has at most $\frac{|V(T)|}{2}$ vertices.
Such vertex can be found in $O(|V(T)|)$ time.
\end{lemma}
\begin{proof}
By rooting a tree in any vertex and traversing it recursively a constant number of times we can compute in $O(|V(T)|)$ time the number of vertices in each subtree of every vertex. Therefore, we assume in the analysis that these values are already available at each vertex.
We will now describe the procedure of walking along the tree.
For any vertex $v_i$ let us assume that it is the current root of $T$ and let us denote its children with their subtrees by $v_{i, j}$ and $T_{i, j}$, respectively.
If for every child $v_{i, j} \in N(v_i)$ we have $|V(T_{i, j})| \le \frac{|V(T)|}{2}$, then we found our vertex.
Otherwise, let us pick as $v_{i + 1}$ a vertex $v_{i, j'}$ such that $|V(T_{i, j'})| > \frac{|V(T)|}{2}$. Note that it is unique among the neighbors of $v_i$.
If it holds that $|V(T_{i, j'})| > \frac{|V(T)|}{2}$ we reduce the size of the maximum subtree by at least one, i.e. we ensure that $\max_j |V(T_{i + 1, j})| \le |V(T_{i, j'})| - 1 = \max_j |V(T_{i, j})| - 1$.
Observe that every $T_{i + 1, j}$ but one (rooted in $v_i$) is a subtree of $T_{i, j'} - v_{i, j'}$. Therefore, the sizes of all these trees cannot exceed $|V(T_{i, j'})| - 1$. And the size of the last subtree of $T_{i, j'} - v_{i, j'}$, rooted in $v_i$, has size equal to $|V(T)| - |V(T_{i, j'})|$, which is smaller than $|V(T_{i, j'})|$ due to the assumption that $|V(T_{i, j'})| > \frac{|V(T)|}{2}$.
Therefore, if we start from any $v_0 \in V(T)$, then after at most $\frac{|V(T)|}{2}$ steps we will find $v_i$ with desired properties.
\end{proof}
\begin{definition}
\label{def:rby}
Let $T$ be a tree on $n$ vertices. Let also $k$ be an integer.
We call a partition $(R, B, Y)$ such that $V(T) = R \cup B \cup Y$ a \emph{red-blue-yellow} $(k, l)$-decomposition
if $|Y| \le l$ and $R$ and $B$ are independent sets with $|R| - |B| = k$.
\end{definition}
From this definition it follows that if $(R, B, Y)$ is a \emph{red-blue-yellow} $(k, l)$-de\-com\-po\-si\-tion, then $(B, R, Y)$ is a \emph{red-blue-yellow} $(-k, l)$-decomposition.
\begin{lemma}
\label{lem:rby-tree}
For a tree $T$ and any $k \in [0, imb(T)]$ there exists a red-blue-yellow $(k, \lceil \log{n} \rceil)$-decomposition.
\end{lemma}
\begin{proof}
First, let us attach a set $D$ of $k$ isolated vertices to the tree $T$, thus obtaining a forest $T^*$.
Now, we will describe an iterative procedure that will preserve certain invariants, which guarantee the convergence to a solution.
We let $T_0 = T$, $R_0 = D$, $B_0 = Y_0 = \emptyset$. The invariants, which are preserved during every step of the algorithms are:
\begin{enumerate}
\item $V(T^*) = R_i \cup B_i \cup Y_i \cup V(T_i)$,\label{invariant:1}
\item $T_i$ is a tree,\label{invariant:2}
\item $R_i$ and $B_i$ are independent sets,\label{invariant:3}
\item $T_i$ does not have neighbors in $R_i \cup B_i$,\label{invariant:4}
\item $0 \le |R_i| - |B_i| \le imb(T_i)$,\label{invariant:5}
\end{enumerate}
Of course all of them hold for $i = 0$.
We will define $R_{i + 1}$, $B_{i + 1}$, $Y_{i + 1}$, $T_{i + 1}$ iteratively using a following procedure:
first, we use \Cref{lem:tree_half} on $T_i$ and get $v$ of some degree $d$ with its $d$ subtrees $T'_j$ such that $|V(T'_j)| \le \frac{|V(T_i)|}{2}$ for every $j \in [1, d]$.
Without loss of generality we assume that $T'_j$ are sorted non-decreasingly by their imbalance number.
If at any point of the algorithm it holds that $|R_i| - |B_i| > \sum_{j = 1}^d imb(T'_j)$, then it has to be the case that $|R_i| - |B_i| > imb(T_i) - 1$. But from the invariant (\ref{invariant:5}) we know that $|R_i| - |B_i| \le imb(T_i)$, so it is true that $|R_i| - |B_i| = imb(T_i)$.
Then, we observe that the partition made by $R$ and $B$ as, respectively, the larger and the smaller of the sets $R_i \cup C_2(T_i) \setminus D$, $B_i \cup C_1(T_i) \setminus D$ together with $Y = Y_i$ meets all the requirements of a red-blue-yellow $k$-decomposition of $T$.
Therefore, from now on we assume that at each step it holds $|R_i| - |B_i| \le \sum_{j = 1}^d imb(T'_j)$.
Observe that $\sum_{j = 1}^d imb(T'_j) \ge imb(T_i) - 1$, as in the worst case $v \in C_1(T_i)$ and all subtrees of $v$ have at least as many vertices from $C_1(T_i)$ as from $C_2(T_i)$ (i.e. $imb(T_i)$ comes a sum of their imbalances and we do not subtract any element).
We define $T_{i + 1} = T'_d$ (i.e. the subtree with the largest imbalance) and $Y_{i + 1} = Y_i \cup \{v\}$.
Now we define $R_i(0) = R_i$, $B_i(0) = B_i$ and we proceed iteratively for $j = 0, 1, 2, \ldots, d - 2$. At each step we let $R_i(j + 1)$ and $B_i(j + 1)$ be, respectively, the larger and the smaller from the sets $R_i(j) \cup C_2(T'_j)$ and $B_i(j) \cup C_1(T_j)$.
In other words, we create a union of the larger set $R$ and the small partition of $T'_j$, and another union of the smaller set $B$ and the large partition of $T'_j$.
Finally, we let $R_{i + 1} = R_i(d - 1)$ and $B_{i + 1} = B_i(d - 1)$.
The crucial observation is that after $j$-th iteration we have
\begin{align*}
|R_i(j)| - |B_i(j)| \le \sum_{j' = j + 1}^d imb(T'_{j'}).
\end{align*}
Clearly this holds for $j = 0$ as it is identical to $|R_i| - |B_i| \le \sum_{j = 1}^d imb(T'_j)$. To prove it inductively for $j = 1, 2, \ldots, d - 1$, we distinguish two cases:
\begin{itemize}
\item if $|R_i(j - 1)| - |B_i(j - 1)| < imb(T'_d)$, then
\begin{align*}
|R_i(j)| - |B_i(j)|
& = \left||R_i(j - 1)| + |C_2(T'_j)| - |B_i(j - 1)| - |C_1(T'_j)|\right| \\
& = \left||R_i(j - 1)| - |B_i(j - 1)| - imb(T'_j)\right| \\
& \le \max\{|R_i(j - 1)| - |B_i(j - 1)|, imb(T'_j)\} \le imb(T'_d),
\end{align*}
\item if $|R_i(j - 1)| - |B_i(j - 1)| \ge imb(T'_d)$, then
\begin{align*}
|R_i(j)| - |B_i(j)|
& = |R_i(j - 1)| + |C_2(T'_j)| - |B_i(j - 1)| - |C_1(T'_j)| \\
& = |R_i(j - 1)| - |B_i(j - 1)| - imb(T'_j) \\
& \le \sum_{j' = j}^d imb(T'_{j'}) - imb(T'_j) = \sum_{j' = j + 1}^d imb(T'_{j'}),
\end{align*}
where the second to last inequality follows from the induction assumption that $|R_i(j - 1)| - |B_i(j - 1)| \le \sum_{j' = j}^d imb(T'_{j'})$.
\end{itemize}
Therefore, we directly obtain that $|R_{i + 1}| - |B_{i + 1}| \le \sum_{j' = j + 1}^d imb(T'_{j'})$ -- which proves that the invariant (\ref{invariant:5}) holds also for $i + 1$.
The invariants (\ref{invariant:1}) and (\ref{invariant:3}) for $i + 1$ are clearly met from the construction of $R_{i + 1}$, $B_{i + 1}$, $Y_{i + 1}$ and $T_{i + 1}$.
Similarly, invariant (\ref{invariant:4}) for $i + 1$ follows from the fact that $T_{i + 1}$ is adjacent to $v$ and no other vertex from $V(T_i) \setminus V(T_{i + 1})$. And by the invariant (\ref{invariant:4}) for $i$, $T_i$ has its neighbors only in $Y_i$. Thus, $T_{i + 1}$ has only neighbors from $Y_i$ or $v$ itself.
Moreover, from invariant (\ref{invariant:4}) for $i$ we know that if $u_1 \in R_i$ and $u_2 \in T_i$, then $u_1 u_2 \notin E(T)$. Moreover, all sets $C_l(T'_j)$ are independent and for any $w_1 \in T'_j$ and $w_2 \in T'_{j'}$ with $j \neq j'$ we have $w_1 w_2 \notin E(T)$.
All these facts guarantee that $R_{i + 1}$ is also an independent set.
Finally, we can provide an identical reasoning for $B_{i + 1}$ -- which completes the proof of invariant (\ref{invariant:2}) for $i + 1$.
For the above construction, aside from the invariants, it also holds that $|Y_{i + i}| = |Y_i| + 1$ and $|V(T_{i + 1})| \le \frac{1}{2} |V(T_i)|$.
Thus, after $t \le \lceil \log{n} \rceil$ iterations we get $0 \le imb(T_t) \le |V(T_t)| = 0$, and therefore $|R_t| = |B_t|$, while $|Y_t| \le \lceil \log{n} \rceil$.
It is easy to check that $R_t \setminus D$, $B_t \setminus D$ and $Y_t$ form a red-blue-yellow $(k, \lceil \log{n} \rceil)$-decomposition of $T$.
Finally, the running time of the whole procedure is linear: every step $i$ can be done in time proportional to the number of vertices in $T_i$, and at every step we decrease the remaining tree size by half.
\end{proof}
\begin{lemma}
\label{lem:rby-forest}
For a forest $F = \bigcup_{i = 1}^r T_i$ on $n$ vertices consisting of $r$ trees and any $k \in [0, \sum_{i = 1}^r imb(T_i)]$ there exists a red-blue-yellow $(k, \lceil \log{n} \rceil)$-decomposition of $F$.
\end{lemma}
\begin{proof}
Assume that $T_i$ are sorted nondecreasingly by $imb(T_i)$.
The main idea of the proof is as follows: we split the vertices of the first $r - 1$ trees into two sets.
Finally, we show that it is sufficient to partition only the vertices of $T_r$ using \Cref{lem:rby-tree} to find a red-blue-yellow decomposition for the whole forest.
We again start by adding a set $D$ of $k$ isolated to the forest to form $F^*$.
We start with $R_0 = D$, $B_0 = \emptyset$, $F_0 = F$.
For $i = 1, 2, \ldots, r - 1$ we proceed as following:
let $F_i = F_{i - 1} \setminus T_i$ and $R_i$, $B_i$ be the larger and the smaller from the sets $R_{i - 1} \cup C_2(T_i)$ and $B_{i - 1} \cup C_1(T_i)$, respectively.
Similarly as before, it is sufficient to prove that at each point of the algorithm it holds that
\begin{align*}
0 \le |R_i| - |B_i| \le \sum_{j = i + 1}^r imb(T_j).
\end{align*}
This clearly holds for $i = 0$. Assume now it does hold for all $j < i$ for some $i = 1, 2, \ldots, r - 1$.
Then, we have to distinguish two cases:
\begin{itemize}
\item either it holds that $|R_{i - 1}| - |B_{i - 1}| \le imb(T_r)$, so directly from the construction we get
\begin{align*}
|R_i| - |B_i|
& \le \left||R_{i - 1}| + |C_2(T_i)| - |B_{i - 1}| - |C_1(T_i)|\right| \\
& = \left||R_{i - 1}| - |B_{i - 1}| - imb(T_i)\right| \\
& \le \max\{|R_{i - 1}| - |B_{i - 1}|, imb(T_i)\} \le imb(T_r),
\end{align*}
\item or it is true that $|R_{i - 1}| - |B_{i - 1}| > imb(T_r)$, so
\begin{align*}
|R_i| - |B_i|
& = |R_{i - 1}| + |C_2(T_i)| - |B_{i - 1}| - |C_1(T_i)| \\
& = |R_{i - 1}| - |B_{i - 1}| - imb(T_i) \\
& \le \sum_{j = i}^r imb(T_j) - imb(T_i) \le \sum_{j = i + 1}^r imb(T_j).
\end{align*}
\end{itemize}
Either way, the invariant holds also for $i$.
Therefore, it holds also for $i = r - 1$.
Finally, let $k' = |R_{r - 1}| - |B_{r - 1}|$ and observe that $F_r = T_r$ is a tree and $0 \le k' \le imb(T_r)$, so we can apply \Cref{lem:rby-tree} to obtain $(R', B', Y')$ as its red-blue-yellow $(k', \lceil \log{n} \rceil)$-decomposition.
Then, we can denote by $R$ and $B$ the larger and the smaller of the sets $R_{r - 1} \cup R' \setminus D$ and $B_{r - 1} \cup B' \setminus D$ -- and easily verify that $(R, B, Y)$ is a red-blue-yellow $(k, \lceil \log{n} \rceil)$-decomposition for $F$.
\end{proof}
In order to formulate our results for the $\lambda$-backbone coloring problem, we need a simple lemma, which enables us to color a clique with a forest backbone with a given set of colors:
\begin{lemma}
\label{lem:recolor}
Let $F$ be a forest on $n$ vertices with a partition $V(F) = A \cup B$ into disjoint independent sets $A$ and $B$.
Let also $[a_1, a_2]$ and $[b_1, b_2]$ be intervals such that $a_2 - a_1 > |A|$, $b_2 - b_1 > |B|$, $a_1 + \lambda \le b_1$ and $a_2 + \lambda \le b_2$.
Then, there exists a $\lambda$-backbone coloring $c$ of $K_n$ with backbone $F$ such that $c(v) \in [a_1, a_2]$ for every $v \in A$ and $c(v) \in [b_1, b_2]$ for every $v \in B$.
Moreover, this coloring can be found in $O(n)$ time.
\end{lemma}
\begin{proof}
If $F$ contains only isolated vertices, then we can assign in any order colors from $[a_1, a_2]$ to $A$ and from $[b_1, b_2]$ to $B$, as it clearly would be a required $\lambda$-backbone coloring.
If $F$ has a leaf $v \in B$ with a neighbor $u \in A$, then we can assign $c(v) = b_1$, $c(u) = a_1$ and invoke a subproblem for $F' = F - \{u, v\}$, $A' = A \setminus \{u\}$, $B' = B \setminus \{v\}$ with color intervals $[a_1 + 1, a_2]$ and $[b_1 + 1, b_2]$. The complete solution would be valid, as all other neighbors of $u$ in $F$ would get colors at least $b_1 + 1 \ge \lambda + a_1 + 1 > \lambda + c(u)$.
Similarly, if $F$ has a leaf $v \in A$ with a neighbor $u \in B$, then we can assign $c(v) = a_2$, $c(u) = b_2$ and invoke the same subproblem as above, only this time with color intervals $[a_1, a_2 - 1]$ and $[b_1, b_2 - 1]$. Again it is easy to check that after obtaining a solution for a subproblem all constraints for $u$ and $v$ will also be satisfied.
\end{proof}
Interestingly, the lemma above can be applied to the $\lambda$-backbone coloring problem directly.
Note that here we can extend the notation $C_1$, $C_2$ used before for trees -- only this time we admit that it is relative to a $2$-coloring $c$, which in case of forests may not be unique:
\begin{theorem}
\label{thm:bbc-direct}
Let $F$ be a forest on $n$ vertices and a $c$ be its $2$-coloring such that $|C_1(F)| \ge |C_2(F)|$, where $C_i(F) = \{v \in V(F)\colon c(v) = i\}$.
It holds that $BBC_{\lambda}(K_n, F) \le \max\{\lambda + |C_1(F)|, n\}$. Moreover, we can find a respective coloring in $O(n)$ time.
\end{theorem}
\begin{proof}
Let $L = \max\{\lambda, C_2(F)\}$.
Let also $A = C_2(F)$, $B = C_1(F)$ with $[a_1, a_2] = [1, |C_2(F)|]$ and $[b_1, b_2] = [L + 1, L + |C_1(F)|$. It is easy to verify that these choices meet the conditions of \Cref{lem:recolor}, so we directly infer that there exists a $\lambda$-backbone coloring $c$ using only colors no greater than $L + |C_1(F)|$.
\end{proof}
More surprisingly, we can couple \Cref{lem:recolor} with a red-blue-yellow decomposition to obtain slightly different bound:
\begin{theorem}
\label{thm:bbc-decomposition}
For a forest $F$ on $n$ vertices it holds that $BBC_{\lambda}(K_n, F) \le \max\{n, 2 \lambda\} + \Delta^2(F) \lceil\log{n}\rceil$. Moreover, we can find a respective coloring in $O(n)$ time.
\end{theorem}
\begin{proof}
Let $L = \max\left\{\frac{n}{2}, \lambda\right\}$.
From \Cref{lem:rby-forest} we can get a red-blue-yellow $(0, \lceil\log{n}\rceil)$-decomposition $(R, B, Y)$ of $F$.
Note that by construction it holds that $|R| = |B| \le L$.
Observe that $Y$ is not necessarily an independent set. Therefore, we need to guarantee the correctness of the coloring for the edges with both endpoints in $Y$.
We handle that in the following way: we obtain $F'$ from $F$ by contracting all edges with both endpoints in $R \cup B$. From a $2$-coloring $c'$ of $F'$ we construct a partition of $Y = Y_1 \cup Y_2$ such that both $Y_i = \{v \in Y\colon c'(v) = i\}$.
Without loss of generality assume that $|Y_1| \ge |Y_2|$.
Let $\mathcal{N}_G(U)$ be a set of neighbors of vertices from $U$ in $G$, i.e.
\begin{align*}
\mathcal{N}_G(U) = \{v \in V(G)\colon \exists_{u \in U} \{u, v\} \in E(G)\}
\end{align*}
Denote now by $B_1 = B \cap \mathcal{N}_F(Y_1)$ and $R_1 = R \cap \mathcal{N}_F(B_1)$. Let also $R_2 = R \cap \mathcal{N}_F(Y_2)$, $B_2 = B \cap \mathcal{N}_F(R_2)$ and $B^* = B \setminus (B_1 \cup B_2)$, $R^* = R \setminus (R_1 \cup R_2)$.
Note that by this construction $B_1 \cap B_2 = R_1 \cap R_2 = \emptyset$.
If this was not the case, then it would mean that there exist a path $(u_1, v_1, v_2, u_2)$ in $F$ such that $u_1 \in Y_1$, $u_2 \in Y_2$ and $v_1, v_2 \in R \cup B$. However, this would mean that in $F'$ both $u_1$ and $u_2$ had to be assigned the same color -- so they could not be in $Y_1$ and $Y_2$, respectively.
To simplify the notation we define $D = \Delta(F)$.
We will proceed with the coloring as following:
\begin{itemize}
\item vertices from $Y_1$ will get colors from $1$ to $|Y_1|$,
\item vertices from $B$ will get colors from $D |Y_1| + 1$ to $L + D |Y_1|$,
\item vertices from $R$ will get colors from $L + D^2 |Y_1| + 1$ to $2 L + D^2 |Y_1|$,
\item vertices from $Y_2$ will get colors from $2 L + D^2 |Y_1| + (D - 1) |Y_2| + 1$ to $2 L + D^2 |Y_1| + D |Y_2|$.
\end{itemize}.
We will color $F$ by assigning colors to $Y_1$, $B_1$ and $R_1$ first, and then to $Y_2$, $R_2$ and $B_2$, symmetrically.
Finally, we prove that we are left with the part of the set $R^* \cup B^*$ that can be colored using the remaining colors (see \Cref{fig:coloring} for the assignment of colors to the sets of vertices).
\begin{figure}[ht]
\centering
\subfigure[Division into sets $R$, $B$, $Y_1$ and $Y_2$.]
{
\begin{tikzpicture}
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (r1) at (0,0) {$Y_1$};
\node [rectangle, draw, minimum width=3cm, minimum height = 0.65cm] (r2) at (3,0) {$B$};
\node [rectangle, draw, minimum width=3cm, minimum height = 0.65cm] (r3) at (7,0) {$R$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (r4) at (10,0) {$Y_2$};
\node [scale = 0.7](r11) at (-0.5,-0.7) {1};
\node [scale = 0.7](r12) at (0.5,-0.7) {$|Y_1|$};
\node [scale = 0.7](r21) at (2,-0.7) {$D|Y_1| + 1$};
\node [scale = 0.7](r22) at (4,-0.7) {$D|Y_1| + L$};
\node [scale = 0.7](r31) at (6,-0.7) {$1+L + D^2|Y_1|$};
\node [scale = 0.7](r32) at (8,-0.7) {$2L + D^2|Y_1|$};
\node [scale = 0.7](r41) at (9.5,-0.7) {$M - |Y_2| + 1$};
\node [scale = 0.7](r42) at (10.5,-0.7) {$M$};
\end{tikzpicture}
}
\subfigure[Division of $R$ and $B$ into subsets $R$, $B$, $Y_1$ and $Y_2$.]
{
\begin{tikzpicture}
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (2r11) at (0,-2) {$Y_1$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (2r21) at (2,-2) {$B_2$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (2r22) at (3,-2) {$B^*$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (2r23) at (4,-2) {$B_1$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (2r31) at (6,-2) {$R_2$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (2r32) at (7,-2) {$R^*$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (2r33) at (8,-2) {$R_1$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (2r41) at (10,-2) {$Y_2$};
\draw[-] (2r11.north west) .. controls +(up:0.25cm) and +(up:0.25cm) ..(2r23.north west) node [midway, above, fill=white] {$\ge L$};
\draw[-] (2r23.north west) .. controls +(up:0.25cm) and +(up:0.25cm) ..(2r33.north west) node [midway, above, fill=white] {$\ge L$};
\draw[-] (2r41.south east) .. controls +(down:0.25cm) and +(down:0.25cm) ..(2r31.south east) node [midway, below, fill=white] {$\ge L$};
\draw[-] (2r31.south east) .. controls +(down:0.25cm) and +(down:0.25cm) ..(2r21.south east) node [midway, below, fill=white] {$\ge L$};
\end{tikzpicture}
}
\subfigure[Edges which are forced by the construction of all the subsets.]
{
\begin{tikzpicture}[yscale=0.7]
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (3r1) at (0,-4.2) {};
\node[draw, circle, fill=black, inner sep=1.5pt] (p13r1) at (0,-4.2) {};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (3r21) at (2,-4.2) {};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (3r22) at (3,-4.2) {};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (3r23) at (4,-4.2) {};
\node[draw, circle, fill=black, inner sep=1pt] (p13r2) at (3.7,-4.2) {};
\node[draw, circle, fill=black, inner sep=1pt] (p23r2) at (4,-4.2) {};
\node[draw, circle, fill=black, inner sep=1pt] (p33r2) at (4.3,-4.2) {};
\node[draw, circle, fill=black, inner sep=0.5pt] (p43r2) at (1.65,-4.2) {};
\node[draw, circle, fill=black, inner sep=0.5pt] (p53r2) at (1.79,-4.2) {};
\node[draw, circle, fill=black, inner sep=0.5pt] (p63r2) at (1.93,-4.2) {};
\node[draw, circle, fill=black, inner sep=0.5pt] (p73r2) at (2.07,-4.2) {};
\node[draw, circle, fill=black, inner sep=0.5pt] (p83r2) at (2.21,-4.2) {};
\node[draw, circle, fill=black, inner sep=0.5pt] (p93r2) at (2.35,-4.2) {};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (3r31) at (6,-4.2) {};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (3r32) at (7,-4.2) {};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (3r33) at (8,-4.2) {};
\node[draw, circle, fill=black, inner sep=1pt] (p73r3) at (5.7,-4.2) {};
\node[draw, circle, fill=black, inner sep=1pt] (p83r3) at (6,-4.2) {};
\node[draw, circle, fill=black, inner sep=1pt] (p93r3) at (6.3,-4.2) {};
\node[draw, circle, fill=black, inner sep=0.5pt] (p13r3) at (7.65,-4.2) {};
\node[draw, circle, fill=black, inner sep=0.5pt] (p23r3) at (7.79,-4.2) {};
\node[draw, circle, fill=black, inner sep=0.5pt] (p33r3) at (7.93,-4.2) {};
\node[draw, circle, fill=black, inner sep=0.5pt] (p43r3) at (8.07,-4.2) {};
\node[draw, circle, fill=black, inner sep=0.5pt] (p53r3) at (8.21,-4.2) {};
\node[draw, circle, fill=black, inner sep=0.5pt] (p63r3) at (8.35,-4.2) {};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (3r4) at (10,-4.2) {};
\node[draw, circle, fill=black, inner sep=1.5pt] (p13r4) at (10,-4.2) {};
\draw[->] (p13r1) .. controls +(up:1cm) and +(up:1cm) .. (p13r2);
\draw[->] (p13r1) .. controls +(up:1cm) and +(up:1cm) .. (p23r2);
\draw[->] (p13r1) .. controls +(up:1cm) and +(up:1cm) .. (p33r2);
\draw[->] (p13r2) .. controls +(up:1cm) and +(up:1cm) .. (p13r3);
\draw[->] (p13r2) .. controls +(up:1cm) and +(up:1cm) .. (p23r3);
\draw[->] (p23r2) .. controls +(up:1.5cm) and +(up:1.5cm) .. (p33r3);
\draw[->] (p23r2) .. controls +(up:1.5cm) and +(up:1.5cm) .. (p43r3);
\draw[->] (p33r2) .. controls +(up:2cm) and +(up:2cm) .. (p53r3);
\draw[->] (p33r2) .. controls +(up:2cm) and +(up:2cm) .. (p63r3);
\draw[->] (p13r4) .. controls +(down:1cm) and +(down:1cm) .. (p73r3);
\draw[->] (p13r4) .. controls +(down:1cm) and +(down:1cm) .. (p83r3);
\draw[->] (p13r4) .. controls +(down:1cm) and +(down:1cm) .. (p93r3);
\draw[->] (p93r3) .. controls +(down:1cm) and +(down:1cm) .. (p93r2);
\draw[->] (p93r3) .. controls +(down:1cm) and +(down:1cm) .. (p83r2);
\draw[->] (p83r3) .. controls +(down:1.5cm) and +(down:1.5cm) .. (p73r2);
\draw[->] (p83r3) .. controls +(down:1.5cm) and +(down:1.5cm) .. (p63r2);
\draw[->] (p73r3) .. controls +(down:2cm) and +(down:2cm) .. (p53r2);
\draw[->] (p73r3) .. controls +(down:2cm) and +(down:2cm) .. (p43r2);
\end{tikzpicture}
}
\subfigure[Other possible connections between the subsets.]
{
\begin{tikzpicture}[yscale=0.7]
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (4r11) at (0,-7) {$Y_1$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (4r21) at (2,-7) {$B_2$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (4r22) at (3,-7) {$B^*$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (4r23) at (4,-7) {$B_1$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (4r31) at (6,-7) {$R_2$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (4r32) at (7,-7) {$R^*$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (4r33) at (8,-7) {$R_1$};
\node [rectangle, draw, minimum width=1cm, minimum height = 0.65cm] (4r41) at (10,-7) {$Y_2$};
\draw[dashed] (4r22) .. controls +(up:1cm) and +(up:1cm) .. (4r32);
\draw[dashed] (4r22) .. controls +(up:1.2cm) and +(up:1.2cm) .. (4r33);
\draw[dashed] (4r22) .. controls +(up:1.4cm) and +(up:1.4cm) .. (4r41);
\draw[dashed] (4r32) .. controls +(down:1cm) and +(down:1cm) .. (4r22);
\draw[dashed] (4r32) .. controls +(down:1.2cm) and +(down:1.2cm) .. (4r21);
\draw[dashed] (4r32) .. controls +(down:1.4cm) and +(down:1.4cm) .. (4r11);
\end{tikzpicture}
}
\caption{The main idea for the $\lambda$-backbone coloring based on a red-blue-yellow decomposition. For brevity, $M = 2 L + D^2 |Y_1| + D |Y_2|$ denotes the maximum color used.}
\label{fig:coloring}
\end{figure}
First, let us arrange vertices from $Y_1$ in any order and assign them colors from $1$ to $|Y_1|$.
Now, let us take vertices from $B_1$ and assign them the largest colors from the set $[D |Y_1| + 1, L + D |Y_1|]$ in the following way: the vertex with the largest colored neighbor in $Y_1$ gets $L + D |Y_1|$, second largest gets $L + D |Y_1| - 1$ etc. (ties are broken arbitrarily).
Such a coloring ensures two things: first, all color constraints between $Y_1$ and $B_1$ are met, and second, the smallest color used for $B_1$ is at least $L + 1$.
Similarly, we color $R_1$: we sort the vertices according to the largest colors of their neighbors in $B_1$ and assign the largest colors to the ones with the largest neighbor color.
Thus we are certain that all color constraints between $B_1$ and $R_1$ are met and that the smallest color used for $R_1$ is at least $2 L + D |Y_1| + 1$, since every vertex from $B_1$ has at most $D - 1$ neighbors in $R_1$.
It is easy to verify that in the same fashion we can color $Y_2$, $R_2$, and $B_2$, only this time starting from assigning the smallest colors available for each set (see \Cref{fig:coloring}).
Since there are at most $L$ vertices in both $R$ and $B$, we are sure that the sets of colors assigned to $B_1$ and $B_2$ (or $R_1$ and $R_2$, respectively) do not overlap.
Furthermore, by construction, there only remain to be colored the vertices from the set $R^* \cup B^*$.
Note that any $v \in B^*$ can be adjacent only to some $u \in Y_2 \cup R_1$ (or to $u \in R^*$) -- but the largest color to be used for $B^*$ (certainly at most the largest color for $B$, i.e. $L + D |Y_1|$) is at least lower by $L$ from the smallest color used in $Y_2 \cup R_1$ (i.e. $2 L + D^2 |Y_1| - D (D - 1) |Y_1| = 2 L + D |Y_1|$).
Again, the symmetrical argument goes for $R^*$ and $Y_1 \cup B_2$.
By the argument above, the remaining colors for $B^*$ and $R^*$ form intervals $[b_1, b_2]$ and $[r_1, r_2]$ such that $b_1 + L \le r_1$, $b_2 + L \le r_2$. Thus, we are in position to color $F[R^* \cup B^*]$ with its disjoint independent sets $R^*$, $B^*$ and colors $[b_1, b_2]$, $[r_1, r_2]$ using \Cref{lem:recolor}.
\end{proof}
\begin{theorem}
\label{thm:bbc-algorithm-tree}
There exists an algorithm with running time $O(n)$ which for any tree $T$ on $n$ vertices finds a $\lambda$-backbone coloring such that $BBC_\lambda(K_n, T) \le OPT + \Delta^2(T) \lceil\log{n}\rceil$.
\end{theorem}
\begin{proof}
We proceed as following: we run the algorithms from \Cref{thm:bbc-direct} and \Cref{thm:bbc-decomposition} and we return the better result.
It guarantees that
\begin{align*}
BBC_\lambda(K_n, T) & \le \min\{\max\{\lambda + |C_1(T)|, n\}, \max\{n, 2 \lambda\} + \Delta^2(T) \lceil\log{n}\rceil\} \\
& \le \max\{\min\{\lambda + |C_1(T)|, 2 \lambda\}, n\} + \Delta^2(T) \lceil\log{n}\rceil.
\end{align*}
Clearly, the $\lambda$-backbone coloring obtained from \Cref{thm:bbc-direct} is always feasible -- and it is the best among all $\lambda$-backbone colorings $c$ such that $\lceil\frac{c}{\lambda}\rceil$ is a $2$-coloring of $T$.
Moreover, in all other $\lambda$-backbone colorings $c$ we have to use at least one color greater than $2 \lambda$ -- as $\lceil\frac{c}{\lambda}\rceil$ has to be a valid coloring of $T$, but it has to use more than $2$ colors -- so $\max_{v \in V(T)} c(v) \ge 2 \lambda + 1$.
Therefore, it is true that $BBC_\lambda(K_n, T) \ge \min\{\lambda + |C_1(T)|, 2 \lambda + 1\}$.
And of course we have to use a different color for each vertex, so $BBC_\lambda(K_n, T) \ge n$.
Combining all these bounds we obtain the desired result.
\end{proof}
To achieve the same result for forest backbones we only need to add some edges that would make the backbone connected and spanning. However, it is clear that we can always attach them to the leaves of the trees in the forest and we will not increase the maximum degree of the forest.
\begin{corollary}
\label{thm:bbc-algorithm-forest}
There exists an algorithm with running time $O(n)$ which for any forest $F$ on $n$ vertices with $\Delta(F) \ge 2$ finds a $\lambda$-backbone coloring such that $BBC_\lambda(K_n, F) \le OPT + \Delta^2(F) \lceil\log{n}\rceil$.
\end{corollary}
\section{Complete graph with tree or forest backbone: a lower bound}
\label{sec:negative}
In this section we prove that there exists a family of trees with the maximum degree $3$ for which $BBC_\lambda(K_n, T) \ge \max\{n, 2 \lambda\} + \Theta(\log{n})$ in four steps.
First, we will define the family of trees with parameters directly related to the Fibonacci numbers.
Next, we will show that the existence of a red-blue-yellow $(k, l)$-decomposition for such trees implies the existence of another red-blue-yellow $(k', l)$-decomposition with an additional property.
Then, we will prove that any such de\-com\-po\-si\-tion would imply further that there holds a certain decomposition of some large number (i.e. half of the large Fibonacci number) into a sum and a difference of a small number of Fibonacci numbers.
Finally, we will establish that such decomposition cannot exist -- therefore there is no red-blue-yellow $(k, l)$-decomposition for our trees assuming that $k$ and $l$ are proportional to $\log{n}$.
We begin by tying our $(k, l)$-red-blue-yellow decomposition to the backbone coloring problem:
\begin{theorem}
\label{thm:impossibility}
Let $T$ be a tree on $n$ vertices. Let also $\lambda \ge 2$ and $l$ be any positive integers such that $2 \lambda + l \ge n$. If $T$ does not have a red-blue-yellow $(k, l)$-decomposition for any $k \in [0, \min\{\lambda - 1, 2 \lambda - n + l\}]$, then $BBC_\lambda(K_n, T) > 2 \lambda + l$.
\end{theorem}
\begin{proof}
Suppose that $T$ is a tree that does not have any red-blue-yellow decomposition for any $k \in [0, \min\{\lambda - 1, 2 \lambda - n + l\}]$, but at the same time it is true that $BBC_\lambda(K_n, T) \le 2 \lambda + l$ with some optimal $\lambda$-backbone coloring $c$.
Now we can define the following sets:
\begin{itemize}
\item $R' = \{v \in V(T)\colon 1 \le c(v) \le \lambda\}$,
\item $B' = \{v \in V(T)\colon \lambda + 1 \le c(v) \le 2 \lambda\}$,
\item $Y = \{v \in V(T)\colon c(v) > 2 \lambda\}$.
\end{itemize}
Since all vertices in $c$ have different colors, it is true that $|Y| \le l$.
Moreover, let $R$ and $B$ be the larger and the smaller from the sets $R'$ and $B'$, respectively.
By the definition of the backbone coloring, $R$ and $B$ have to be independent sets in $T$ with $k' = |R| - |B| \le \lambda - 1$.
On the other hand, we know that $R$ has to contain at most $\lambda$ vertices and $B$ has to contain at least $n - \lambda - |Y|$ vertices, so $k' \le \lambda - (n - \lambda - |Y|) \le 2 \lambda - n + l$.
Thus, $(R, B, Y)$ is a red-blue-yellow $(k', l)$-decomposition of $T$ with $k' \in [0, \min\{\lambda - 1, 2 \lambda - n + l\}]$---and we obtained a contradiction.
\end{proof}
Now we define a family of \emph{Fibonacci trees}, built recursively:
\begin{definition}
We call a rooted tree the $N$-th Fibonacci tree (denoted as $T^F_N$) if:
\begin{itemize}
\item $T^F_1 = T^F_2 = K_1$,
\item $T^F_N$ for $N \ge 3$ is a tree with root $u_1$ with only child $u_2$ such that $u_2$ has two subtrees, which are, respectively, $(N - 1)$-th and $(N - 2)$-th Fibonacci trees.
\end{itemize}
\end{definition}
We will ultimately show that this class contains infinitely many trees (starting from certain $N_0$), presented in \Cref{fig:fibonacci_trees}, cannot be colored using less than $\max\{n, 2\lambda\} + \frac{1}{48} \log_\phi{n} - 3$ colors.
\begin{figure}
\centering
\subfigure[$T^F_1$, $T^F_2$]
{
\begin{tikzpicture}[yscale=0.7]
\node[draw, circle, fill=white, inner sep=2pt] (A) at (3,6) {};
\node (_1) at (2,3) {};
\node (_2) at (4,3) {};
\end{tikzpicture}
}
\quad
\subfigure[$T^F_3$]
{
\begin{tikzpicture}[yscale=0.7]
\node[draw, circle, fill=white, inner sep=2pt] (A) at (3,6) {};
\node[draw, circle, fill=black, inner sep=2pt] (B) at (3,5) {};
\node[draw, circle, fill=gray, inner sep=2pt] (C) at (2.5,4) {};
\node[draw, circle, fill=gray, inner sep=2pt] (D) at (3.5,4) {};
\node (_) at (3.5,2) {};
\draw (A) -- (B) -- (C);
\draw (B) -- (D);
\end{tikzpicture}
}
\quad
\subfigure[$T^F_4$]
{
\begin{tikzpicture}[yscale=0.6]
\node[draw, circle, fill=white, inner sep=2pt] (A) at (3,6) {};
\node[draw, circle, fill=black, inner sep=2pt] (B) at (3,5) {};
\node[draw, circle, fill=gray, inner sep=2pt] (C) at (2,4) {};
\node[draw, circle, fill=gray, inner sep=2pt] (D) at (4,4) {};
\node[draw, circle, fill=black, inner sep=2pt] (E) at (2,3) {};
\node[draw, circle, fill=gray, inner sep=2pt] (F) at (1.5,2) {};
\node[draw, circle, fill=gray, inner sep=2pt] (G) at (2.5,2) {};
\node (_) at (3.5,1) {};
\draw (A) -- (B) -- (C) -- (E) -- (F);
\draw (B) -- (D);
\draw (E) -- (G);
\end{tikzpicture}
}
\quad
\subfigure[$T^F_5$]
{
\begin{tikzpicture}[yscale=0.5]
\node[draw, circle, fill=white, inner sep=2pt] (A) at (3,6) {};
\node[draw, circle, fill=black, inner sep=2pt] (B) at (3,5) {};
\node[draw, circle, fill=gray, inner sep=2pt] (C) at (2,4) {};
\node[draw, circle, fill=gray, inner sep=2pt] (D) at (4,4) {};
\node[draw, circle, fill=black, inner sep=2pt] (E) at (2,3) {};
\node[draw, circle, fill=black, inner sep=2pt] (F) at (4,3) {};
\node[draw, circle, fill=gray, inner sep=2pt] (G) at (1.5,2) {};
\node[draw, circle, fill=gray, inner sep=2pt] (H) at (2.5,2) {};
\node[draw, circle, fill=gray, inner sep=2pt] (I) at (3.5,2) {};
\node[draw, circle, fill=gray, inner sep=2pt] (J) at (4.5,2) {};
\node[draw, circle, fill=black, inner sep=2pt] (K) at (1.5,1) {};
\node[draw, circle, fill=gray, inner sep=2pt] (L) at (1.25,0) {};
\node[draw, circle, fill=gray, inner sep=2pt] (M) at (1.75,0) {};
\draw (A) -- (B) -- (C) -- (E) -- (G) -- (K) -- (L);
\draw (B) -- (D) -- (F) -- (I);
\draw (E) -- (H);
\draw (F) -- (J);
\draw (K) -- (M);
\end{tikzpicture}
}
\caption{Fibonacci trees for $N = 1, 2, 3, 4, 5$. White vertices are the roots of Fibonacci trees and gray vertices are the roots of their Fibonacci subtrees.}
\label{fig:fibonacci_trees}
\end{figure}
We will additionally denote by $T^F_N$ the $N$-th (unrooted) Fibonacci tree an unrooted version of the $N$-th rooted Fibonacci tree.
In our analysis we will only be using rooted Fibonacci trees, but all the results apply also to the unrooted variant as we can recognize Fibonacci trees and find their roots in $O(|V(T)|)$ time.
Here we will also make use of $C_1(T^F_N)$ and $C_2(T^F_N)$ sets. Without a loss of generality from now on we always define these sets with respect to a $2$-coloring $c$ of $T^F_N$ such that the root of $T^F_N$ has color $1$.
\begin{fact}
\label{fact:fibonacci_subtrees}
For every $N$ each vertex of $T^F_N$ is either the root or the parent of the root of some $T^F_i$ subtree for some $i \in [0, N]$.
\end{fact}
\begin{theorem}
\label{thm:fibonacci_order}
If $T^F_N$ is the $N$-th Fibonacci tree, then $|V(T^F_N)| = 3 F_N - 2$, where $F_N$ is the $N$-th Fibonacci number.
Moreover, for $n \ge 10$ it holds that $N = \lfloor\log_\phi{n}\rfloor$.
\end{theorem}
\begin{proof}
The first part of the theorem obviously holds for $N = 1, 2$.
If we assume that the theorem holds for all $i \in [0, N - 1]$ for some $N \ge 3$, then
\begin{align*}
|V(T^F_N)|
& = |V(T^F_{N - 1})| + |V(T^F_{N - 2})| + 2 = 3 F_{N - 1} - 2 + 3 F_{N - 2} - 2 + 2 \\
& = 3 F_N - 2.
\end{align*}
The second part of the theorem we prove as follows: $n = 3 F_N - 2$ implies that $\frac{\sqrt{5}}{3} (n+2) = \phi^N - (-\phi)^{-N}$.
Therefore, we know that for $n \ge 2$ ($N \ge 3$) it holds that
\begin{align*}
\log_\phi\left(\phi^N - (-\phi)^{-N}\right)
\ge N + \log_\phi\left(1 - \phi^{-2 N}\right)
\ge N - \frac{\phi^{-2 N}}{\ln{\phi}} - \frac{\phi^{-4 N}}{\ln{\phi}} > N - \frac{1}{5},
\end{align*}
where we used the fact that $\ln(1 - x) \ge -x - x^2$ for $x \in (0, 0.68)$.
On the other hand,
\begin{align*}
\log_\phi\left(\phi^N - (-\phi)^{-N}\right)
\le N + \log_\phi\left(1 + \phi^{-2 N}\right)
\le N + \frac{\phi^{-2 N}}{\ln{\phi}} + \frac{\phi^{-4 N}}{\ln{\phi}} < N + \frac{1}{5},
\end{align*}
where we used the fact that $\ln(1 + x) \le x + x^2$ for all $x > 0$.
Finally, for $n \ge 10$ ($N \ge 5$) it holds that
\begin{align*}
\log_\phi\left(\frac{\sqrt{5}}{3} (n+2)\right)
& = \log_\phi{n} + \log_\phi\left(\frac{\sqrt{5}}{3}\right) + \log_\phi\left(1 + \frac{2}{n}\right) \\
& \le \log_\phi{n} - \frac{3}{5} + \frac{2}{n \log{\phi}} + \frac{4}{n^2 \log{\phi}} < \log_\phi{n} - \frac{1}{5},
\end{align*}
and $\log_\phi\left(\frac{\sqrt{5}}{3} (n+2)\right) > \log_\phi{n} + \log_\phi\left(\frac{\sqrt{5}}{3}\right) > \log_\phi{n} - \frac{4}{5}$.
By putting all these bounds together we obtain that $N < \log_\phi{n} < N + 1$, which completes the proof.
\end{proof}
\begin{theorem}
\label{thm:fibonacci_imb}
If $T^F_N$ is the $N$-th Fibonacci tree, then $imb(T^F_N) = F_N$, where $F_N$ is $N$-th Fibonacci number.
\end{theorem}
\begin{proof}
Clearly $imb(T^F_N) = F_N$ for $N = 1, 2$.
Let $N \ge 3$ and proceed by induction. By construction, we know that the grandchildren of the root of $T^F_N$ are exactly the roots of $T^F_{N - 1}$ and $T^F_{N - 2}$ and they all have the same color in any $2$-coloring of $T^F_N$.
Therefore,
\begin{align*}
imb(T^F_N)
& = imb(T^F_{N - 1}) + imb(T^F_{N - 2}) = F_{N - 1} + F_{N - 2} = F_N.
\end{align*}
\end{proof}
Observe that the set of vertices which are the roots of all Fibonacci subtrees is defined exactly by $C_1(T^F_N)$.
Using \Cref{fact:fibonacci_subtrees} we can modify any $(k, l)$-red-blue-yellow decomposition in such a way that $Y \cap C_1(T^F_N) = \emptyset$:
\begin{lemma}
\label{lem:pushdown}
Let $(R, B, Y)$ be a red-blue-yellow $(k, l)$-decomposition of a Fibonacci tree $T^F_N$.
Then there exists $0 \le k' \le k + 2 l$ such that we can construct a red-blue-yellow $(k', l)$-decomposition $(R', B', Y')$ of $T^F_N$ with $Y' \cap C_1(T^F_N) = \emptyset$.
\end{lemma}
\begin{proof}
First, we define $Y' = \{v \in C_2(T^F_N)\colon v \in Y \lor parent(v) \in Y\}$, i.e. we ``push down'' the yellow color from roots of Fibonacci subtrees to their children. Clearly, $|Y'| \le |Y|$.
Next, we define $R'$ and $B'$ to be as following:
\begin{itemize}
\item if $v \in C_2(T^F_N)$, $v \notin Y$ and $parent(v) \notin Y$, then we preserve the color: if $v \in R$, then put $v$ in $R'$, otherwise put it in $B'$,
\item if $v \in C_1(T^F_N)$ and $v \notin Y$, then we also preserve the color,
\item if $v \in C_1(T^F_N)$, $v \in Y$ and $parent(v) \notin Y$, then we use the color other than in the parent: if $parent(v) \in R$, then put $v$ in $B'$, otherwise put $v$ in $R'$,
\item finally, if $v \in C_1(T^F_N)$, $v \in Y$ and $parent(v) \in Y$, we put $v$ in $R'$.
\end{itemize}
Overall, this whole procedure ``extends'' blue and red parts to the previously yellow vertices on a single level just below them. And if we are certain that both a parent and an only child of a vertex in $C_1(T^F_N)$ will be in $Y'$ (the last case above), then we just assign it to $R'$, as it will be surrounded only by the vertices from $Y'$ (in fact, it can be also added to $B'$ instead).
Note that $|R'| \le |R| + |Y|$ as only in the last two cases we can add some vertices to $R'$ which were not in $R$ -- but this means that these vertices were in $Y$.
Additionally, $|B'| \ge |B| - |Y'| \ge |B| - |Y|$, as the only vertices which are in $B \setminus B'$ are exactly the ones which are added to $Y'$.
Finally, it is easy to verify that indeed $(R', B', Y')$ is a red-blue-yellow $(k', l)$-decomposition of $T^F_N$ for some
\begin{align*}
|k'| = ||R'| - |B'|| \le ||R| - |B| + 2 |Y|| \le k + 2 l.
\end{align*}
Although $k'$ in the equation above might be negative, remember that we can always make it positive by swapping $R'$ and $B'$.
\end{proof}
Now, we turn to the computation of the imbalances of red-blue parts of Fibonacci trees.
In order to do that, we have to recall some theory of Fibonacci numbers.
In particular, we recall the Zeckendorf's theorem \cite{knuth1988fibonacci}, which states that any number $n \in \mathbb{N}$ can be written as $n = \sum_j z_j F_j$ for $z_j \in \{0, 1\}$ such that
\begin{enumerate}
\item[(A)] no two consecutive $z_j$ are equal to $1$, i.e. $z_j z_{j + 1} = 0$ for all $j$,
\item[(B)] this representation is unique and it is the shortest decomposition with respect to $\sum_j |z_j|$,
\item[(C)] it can be constructed by greedy subtraction the largest possible Fibonacci numbers from $n$ until we reach $0$.
\end{enumerate}
We call a vector $z = (z_j)_{j = 1}^\infty$ such that $(A)$ -- and thus also $(B)$ and $(C)$ -- holds the \emph{Zeckendorf representation} of $n$ and denote by $Z(n)$.
We will sometimes without loss of generality trim $Z(n)$ to a finite number of positions since $F_i > n$ implies trivially $z_i = 0$.
For example, $Z(F_N) = (0, \ldots, 0, 1)$, i.e. it has a single one on $N$-th position and $Z\left(\frac{F_N}{2}\right) = (\ldots, 1, 0, 0, 1, 0, 0)$, i.e. it has ones only on every third position ending at $N - 2$ as it is true that $\frac{F_N}{2} = F_{N - 2} + \frac{F_{N - 3}}{2}$.
Now we may proceed to the lemma which ties tree decompositions and Fibonacci numbers:
\begin{lemma}
\label{lem:count}
For any red-blue-yellow $(k, l)$-decomposition $(R, B, Y)$ of $T^F_N$ such that $Y \cap C_1(T^F_N) = \emptyset$ and $k \ge 0$ it holds that every connected component $T_i$ of $T^F_N[R \cup B]$ has
\begin{align*}
imb(T_i) = |Y_i| + F_r - \sum_{j = 1}^N z_j F_j
\end{align*}
where $r \in [1, N]$, $Y_i = \{v \in Y\colon parent(v) \in V(T_i)\}$, $z_j \in \{0, 1\}$ for all $j = 1, 2, \ldots, N$ and $\sum_{j = 1}^N z_j \le |Y_i|$.
\end{lemma}
\begin{proof}
Each component $T_i$ of $T^F_N[R \cup B]$ is a tree rooted in a vertex $u_i$ that is also a root of some Fibonacci subtree. It may be a Fibonacci subtree itself -- but even if it is not, then it means it has some subtrees removed, which are cut off exactly in vertices from $Y_i$.
But every $v \in Y_i$ has children that are also roots of some Fibonacci subtrees.
Now, let us define $c$ as a $2$-coloring of $T^F_N$ and $c_i$ as a $2$-coloring of $T_i$, both with respective roots assigned color $1$. In particular note that $C_1(T^F_N)$ and $C_2(T^F_N)$ are defined with respect to $c$.
Observe that it has to be the case that $c(u_i) = 1$, since every root of a Fibonacci subtree is in an even distance from the root of the whole Fibonacci tree. Thus, for all $v \in V(T_i)$ it holds that $c_i(v) = c(v)$.
Moreover, every leaf $v$ of $T_i$ also has $c_i(v) = 1$, as either it is a leaf of $T^F_N$ (thus $c(v) = 1$), or it is a parent of some vertex from $Y_i$. However, in the latter case $Y \cap C_1(T^F_N) = \emptyset$ implies also that $c(v) = 1$, as the vertices from $Y_i$ always get color $2$.
Finally, we note that to get $imb(T_i)$ we have to:
\begin{itemize}
\item add the imbalance of a Fibonacci subtree of $T^F_N$ (i.e. the one rooted in $u_i$),
\item remove the imbalance of some Fibonacci subtrees of $T^F_N$ (i.e. the ones rooted in children of all $v \in Y_i$) -- note that for each vertex from $Y_i$ we remove its two subtrees $T_{j - 1}^F$ and $T_{j - 2}^F$ with total imbalance equal to $imb(T_{j - 1}^F) + imb(T_{j - 2}^F) = F_j$,
\item add the size of $|Y_i|$ -- vertices from $Y_i$ were taken into account when adding imbalance of the whole tree in the first case above, however they are not in $T_i$. Note that their removal will increase the imbalance.
\end{itemize}
\begin{figure}
\centering
\begin{tikzpicture}[xscale=0.8,yscale=0.6]
\node[draw, circle, fill=red, inner sep=2pt] (A) at (3.5, 6) {};
\node[draw, circle, fill=blue, inner sep=2pt] (B) at (3.5, 5) {};
\node[draw, circle, fill=red, inner sep=2pt] (C) at (0.5, 4) {};
\node[draw, circle, fill=red, inner sep=2pt] (D) at (6.5, 4) {};
\node[draw, circle, fill=yellow, inner sep=2pt] (E) at (0.5, 3) {};
\node[draw, circle, fill=yellow, inner sep=2pt] (F) at (6.5, 3) {};
\node[draw, isosceles triangle,shape border rotate=90] (K) at (-1, -0.4) {$T_{n-2}$};
\node[draw, isosceles triangle,shape border rotate=90] (L) at (2, -0.4) {$T_{n-3}$};
\node[draw, circle, fill=red, inner sep=2pt] (G) at (-1,2) {};
\node[draw, circle, fill=red, inner sep=2pt] (H) at (2,2) {};
\node[draw, isosceles triangle,shape border rotate=90] (I) at (5, -0.4) {$T_{n-3}$};
\node[draw, isosceles triangle,shape border rotate=90] (J) at (8, -0.4) {$T_{n-4}$};
\node[draw, circle, fill=red, inner sep=2pt] (M) at (5, 2) {};
\node[draw, circle, fill=red, inner sep=2pt] (N) at (8 ,2) {};
\draw (A) -- (B) -- (C) -- (E) -- (G);
\draw (B) -- (D) -- (F) -- (M);
\draw (E) -- (H);
\draw (F) -- (N);
\end{tikzpicture}
\caption{An example Fibonacci tree $T^F_n$ with $|Y_1| = 2$ and the imbalance of the top tree $imb(T_1) = |Y_1| + F_n - F_{n - 1} - F_{n - 2} = 2$.}
\label{fig:fibonacci}
\end{figure}
Overall, if the imbalance of a Fibonacci subtree of $T^F_N$ rooted in $u_i$ is equal to $F_r$ for some $r$, then we get that $imb(T_i) = |Y_i| + F_r - \sum_{j = 1}^r z'_j F_j$ for some $z'_j \in \mathbb{N}$ with $\sum_{j = 1}^r |z'_j| \le |Y_i|$.
We note that since we cut the subtrees of the tree rooted in $T^F_N$, the last sum cannot exceed $F_r$. Moreover, the Zeckendorf representation $Z\left(\sum_{j = 1}^r z'_j F_j\right) = (z_j)_{j = 1}^r$ is such that $\sum_{j = 1}^r |z_j| \le \sum_{j = 1}^r |z'_j| \le |Y_i|$.
\end{proof}
\begin{lemma}
\label{lem:split}
If there exists a red-blue-yellow $(k, l)$-decomposition $(R, B, Y)$ of $T^F_N$ such that $|Y| = l$, $Y \cap C_1(T^F_N) = \emptyset$, then there exists a value $y \in [0, l]$ and a vector $z = (z_j)_{j = 1}^N$ with $z_j \in \{-1, 0, 1\}$ and $\sum_{j = 1}^N |z_j| \le 2 l + 1$ such that
\begin{align*}
\frac{F_N - k + l}{2} = y + \sum_{j = 1}^N z_j F_j.
\end{align*}
\end{lemma}
\begin{proof}
The required decomposition exists if and only if there exists a set $Y$ with $l$ vertices such that we can and find for connected components $T_i$ of $T_N^F \setminus Y$ certain $2$-coloring functions $c_i$ such that $R$, $B$ are equal to the largest and the smallest of the sets $A_1$, $A_2$, where $A_j = \bigcup_i \{v \in V(T_i)\colon c_i(v) = j\}$ -- and it is the case that $|R| - |B| = k$.
From \Cref{lem:count} we know that for every $i$ we can write $imb(T_i) = |Y_i| + \sum_{j = 1}^N z_{i,j} F_j$ such that $z_{i,j} \in \{-1, 0, 1\}$ and $\sum_{j = 1}^N |z_{i,j}| \le |Y_i| + 1$. Thus,
\begin{align*}
k = |R| - |B|
& = \sum_{i = 1}^{l + 1} a_i\,imb(T_i) = y + \sum_{i = 1}^{l + 1} \sum_{j = 1}^N a_i z_{i,j} F_j.
\end{align*}
for $y = \sum_{i = 1}^{l + 1} a_i |Y_i| \in \left[-l, l\right]$ and some $a_i \in \{-1, 1\}$ (in particular, $a_i = -1$ if and only if the root of $T_i$ has color $2$ in $c_i$).
Note that by our assumptions on $Y$ we know that $T_N^F \setminus Y$ has at most $l + 1$ connected components.
Now let us invert colors in colorings $c_i$ for certain connected components $T_i$ (i.e. replace some $c_i$ by $c'_i = 3 - c_i$) and leave all the others intact in order to color all the roots of $T_i$ with a color $1$.
Of course, then $c'$ on the whole $T_N^F \setminus Y$ agrees with the $2$-coloring of $T_N^F$ where the root has color $1$, so the total imbalance induced by $c'$ on $T_N^F \setminus Y$ is just the sum all of the imbalances of $T_i$.
Therefore,
\begin{align*}
F_N + l
& = imb(T_N^F) + |Y| = \sum_{i = 1}^{l + 1} imb(T_i) = |Y| + \sum_{i = 1}^{l + 1} \sum_{j = 1}^N z_{i,j} F_j.
\end{align*}
Now, by subtracting the last two equations we obtain
\begin{align*}
\frac{F_N - k + l}{2} = \frac{|Y| - y}{2} + \sum_{i = 1}^{l + 1} \sum_{j = 1}^N a'_i z_{i,j} F_j,
\end{align*}
where we used the fact that $a'_i = \frac{1 - a_i}{2} \in \{0, 1\}$ for all $i = 1, 2, \ldots, l + 1$.
Now again observe that $\sum_{j = 1}^N F_j \sum_{i = 1}^{l + 1} a'_i z_{i,j}$ can be written as a sum of Fibonacci numbers -- possibly with some repetitions, i.e. each $F_j$ is used exactly $\sum_{i = 1}^{l + 1} a'_i z_{i,j}$ times. The total number of Fibonacci numbers in this sum does not exceed
\begin{align*}
\sum_{i = 1}^{l + 1} \sum_{j = 1}^N |a'_i z_{i,j}| \le \sum_{i = 1}^{l + 1} \sum_{j = 1}^N |z_{i,j}| \le \sum_{i = 1}^{l + 1} (|Y_i| + 1) \le |Y| + l + 1 = 2 l + 1.
\end{align*}
Therefore, by Zeckendorf theorem there exists a vector $z' = (z'_j)_{j = 1}^N$ with $z'_j \in \{-1, 0, 1\}$ and $\sum_{j = 1}^N |z'_j| \le 2 l + 1$ such that
\begin{align*}
Z\left(\sum_{i = 1}^{l + 1} \sum_{j = 1}^N a'_i z_{i,j} F_j\right) = z'.
\end{align*}
This completes the proof.
\end{proof}
\begin{lemma}
\label{lem:fibonacci}
For $N \ge 96$, any $k \in [0, F_{N / 2 - 1}]$, $l \in \left[1, \frac{N}{48} - 1\right]$ there does not exist a value $y \in [0, l]$ and a vector $z = (z_j)_{j = 1}^N$ with $z_j \in \{-1, 0, 1\}$ and $\sum_{j = 1}^N |z_j| \le 2 l + 1$ such that
\begin{align*}
\frac{F_N - k + l}{2} = y + \sum_{j = 1}^N z_j F_j.
\end{align*}
\end{lemma}
\begin{proof}
It is well known that $F_{N - 2} < \frac{F_N}{2} < F_{N - 1}$ for any $N \ge 4$.
Moreover, we can easily show by induction that
\begin{align*}
\frac{F_N}{2} = \sum_{i = 0}^{\lfloor\frac{N - 2}{3}\rfloor} F_{N - 2 - 3 i}.
\end{align*}
From now on let us denote $K = F_{N / 2 - 1}$ an $L = \frac{N}{48} - 1$.
Here we have slightly harder task: we would like to show that any number $S \in \left[\frac{F_N - K - L}{2}, \frac{F_N + L}{2}\right]$ (since $y$ is at most equal to $l$) cannot be represented using at most $2 l + 1$ Fibonacci numbers, but this time using both addition and subtraction.
Note that we can split $Z\left(\frac{F_N}{2}\right)$ into a sequence of $\lfloor\frac{N - 1}{3}\rfloor$ blocks of length $3$ equal to $(0, 1, 0)$, possibly with some padding at the beginning.
Let $S' = S - \frac{F_N}{2}$.
By assumption it holds that $L < K = F_{N / 2 - 1}$, so $|S'| \le \frac{K + L}{2} < F_{N / 2 - 1}$ and therefore $Z(|S'|)$ cannot have ones on positions $\left[\frac{N}{2} - 1, N\right]$.
Let us take positions $\left[1, \frac{N}{2} - 1\right]$ of $Z\left(\frac{F_N}{2}\right)$, equivalent to some number $S''$ and observe that $S'' + S' \ge 0$ -- and, additionally, it also cannot have ones on positions $\left[\frac{N}{2} - 1, N\right]$.
Therefore, we are certain that $Z(S)$ has exactly the same values as $Z\left(\frac{F_N}{2}\right)$ on positions from $\frac{N}{2}$ on.
Which effectively means that $Z(S) = Z\left(\frac{F_N}{2} + S'\right)$ contains a sequence of $\frac{N}{6}$ consecutive blocks $(0, 1, 0)$.
Suppose that $S = S_1 - S_2$ such that $Z(S_1)$ and $Z(S_2)$ have in total at most $2 l + 1$ ones.
Now it is sufficient to prove that using the vector addition of $Z(S)$ (consisting of $\frac{N}{6}$ consecutive blocks $(0, 1, 0)$) and $Z(S_2)$ (having only $2 l + 1$ ones) we cannot obtain a vector which has only $2 l + 1$ ones.
From now on we will concentrate only on this latter part of the vectors $Z(S)$ and $Z(S_2)$.
Let us write both $Z(S)$ and $Z(S_2)$ as blocks of length $3$ and denote $i$-th block of $Z(S_2)$ (and also, by association, the respective block of $Z(S)$) as type A if it contains some ones, and as type B otherwise.
Note that there can be at most $2 l + 1$ blocks of type A since $Z(S_2)$ has at most $2 l + 1$ ones.
Now consider how many blocks of type B can be influenced by a carry from blocks of type A. We have to analyze not only forward carry, but also the backward one, as for example, in Zeckendorf representation we have $Z(3) = (0, 0, 0, 1)$ but $Z(3 + 3) = (0, 1, 0, 0, 1)$.
The proof for the forward carry is simpler: if we have $i$-th block (with $i > \frac{N}{2}$) of type A, which starts with a position $j$ (respective to the number $F_j$), then we know that the number $S^*_2$ indicated only by the blocks up to $i - 1$ of $Z(S_2)$ cannot exceed $F_j - 1$ because of the Zeckendorf representiation. Similarly, for $Z(S)$ the respective number $S^*$ cannot exceed $F_{j - 1} - 1$ since its $(i - 1)$-th block is already equal to $(0, 1, 0)$. Thus, the carry to the $i$-th block has to be in the form $(1, 0, 0)$.
Therefore, we can easily establish that the forward carry cannot influence more than one block $(0, 1, 0)$ to the right.
That leaves us with proving that backward carry cannot influence too many blocks of type B.
First, we note that $Z(S_2)$ by the property $(B)$ of the Zeckendorf representation does not have two consecutive ones. Thus, the only combinations available when we sum the rightmost blocks of type A (i.e. the ones which do not have blocks of type A to the right) are:
\begin{enumerate}
\item $(0,1,0) + (1,0,0) = (0,0,1)$,
\item $(0,1,0) + (0,1,0) = (0,0,1)$ with a backward carry $1$,
\item $(0,1,0) + (0,0,1) = (0,0,0)$ with a forward carry $1$,
\item $(0,1,0) + (1,0,1) = (1,0,1)$ with a forward carry $1$.
\end{enumerate}
The only possible backward carry happens in the second case and it is equal to a single one on the rightmost position of the carry.
Now, observe that if the block to the left is also of type A, then a respective block from $Z(S)$ is $(0, 1, 0)$ -- which added to the backward carry $(0, 0, 1)$ gives us forward carry to the rightmost block. And regardless of the value of the appropriate block of $Z(S_2)$, the total sum of the blocks and the backward carry cannot generate any further backward carry.
Finally, note that the aforementioned forward carry resulting from backward carry appears in the block which has to be equal to $(0, 0, 1)$ (as it has to be the second case above), so it turns it into $(1, 0, 1)$ and it does not generate any future carries.
Therefore, the only possible backward carry from the block of type A to the block of type B has to be in the form $(0, 0, 1)$. However, this will be combined with a block $(0, 1, 0)$ from $Z(S)$ -- thus, the sum of the blocks from $Z(S)$, $Z(S_2)$ and the backward carry again cannot result in any further backward carry.
Thus, we proved that any block of type A can affect up to one block of type B to the left and one block of type B to the right.
If there are only $2 l + 1$ blocks of type A, then at most $3 (2 l + 1)$ blocks of type A and B can be modified -- and therefore at least $\frac{N}{6} - 3 (2 l + 1)$ blocks of the form $(0, 1, 0)$ of $Z(S)$ remain the same even after addition of $Z(S_2)$.
This means that $Z(S - S_2)$ has to have at least $\frac{N}{6} - 3 (2 L + 1)$ ones -- which contradicts the assumption that $Z(S - S_2) = Z(S_1)$ has at most $2 L + 1$ ones for $L = \frac{N}{48} - 1$.
\end{proof}
\begin{theorem}
\label{thm:nonexistence}
For any $N \ge 96$, any $k \in \left[0, F_{N / 2 - 1} - \frac{N}{24} + 2\right]$ and any $l \in \left[1, \frac{N}{48} - 1\right]$ there does not exist a red-blue-yellow $(k, l)$-decomposition of $T_N^F$.
\end{theorem}
\begin{proof}
A direct implication of \Cref{lem:split} and \Cref{lem:fibonacci} is that there does not exist a red-blue-yellow $(k', l)$-decomposition of $T_N^F$ such that $Y \cap C_1(T^F_N) = \emptyset$ for any $k' \in [0, F_{N / 2 - 1}]$ and $l = \frac{N}{48} - 1$.
Now, it follows from \Cref{lem:pushdown} that if there was a red-blue-yellow $(k, l)$-decomposition of $T_N^F$ for $k$, then it would exist a red-blue-yellow $(k', l)$-de\-com\-po\-si\-tion of $T_N^F$ with $Y \cap C_1(T^F_N) = \emptyset$ and $k' \in [0, k + 2 l] \subseteq [0, F_{N / 2 - 1}]$ -- thus, a contradition.
\end{proof}
Finally, we can proceed to the main theorem of this section, which shows the existence of the trees with constant degrees such that $BBC_\lambda(K_n, T) = \max\{n, 2\lambda\} + \Omega(\log{n})$:
\begin{theorem}
There exists an infinite family of trees $T_N^F$ on $n = 3 F_N - 2$ vertices with $\Delta(T_N^F) = 3$ for $N \ge 96$ such that $BBC_\lambda(K_n, T_N^F) \ge \max\{n, 2\lambda\} + \frac{1}{48} \log_\phi{n} - 3$ for $\lambda = \left\lfloor\frac{n}{2}\right\rfloor$.
\end{theorem}
\begin{proof}
Assume that $l = \frac{N}{48} - 1$.
Then it always holds that $2 \lambda - n + l \le \lambda - 1$ -- so in \Cref{thm:impossibility} we need that there cannot be any red-blue-yellow $(k, l)$-decomposition for $k \in [0, 2 \lambda - n + l]$.
If $N \ge 96$, then it is easy to check that $F_{N / 2 - 1} - \frac{N}{24} + 2 > 2 \lambda - n + l$.
Therefore, by combining \Cref{thm:nonexistence,thm:impossibility} we get that $BBC_\lambda(K_n, T_N^F) > 2 \lambda + \frac{N}{48} - 1$.
To finish the proof it is sufficient to combine this result with two simple observations:
\begin{itemize}
\item by assumption it holds that $2\lambda \ge \max\{n, 2\lambda\} - 1$,
\item by \Cref{thm:fibonacci_order} it is true that $N = \lfloor\log_\phi{n}\rfloor > \log_\phi{n} - 1$.
\end{itemize}
\end{proof}
In fact, the theorem above can be proven in a more complicated, but also more general form, i.e. that $BBC_\lambda(K_n, T_N^F) > 2 \lambda + \frac{1}{48} \log_\phi{n} - 2$ for all $\lambda \in \left[\frac{n}{2} - \frac{1}{96} \log_\phi{n}, \frac{n}{2}\right]$ -- which gives us also an additive factor over $\max\{n, 2\lambda\}$.
\begin{comment}
\section{Split graphs with tree backbones}
\label{sec:split}
We start this section by proving that the $\lambda$-backbone coloring problem for split graphs with tree backbones is directly related to the same problem for complete graphs with arbitrary backbones.
\begin{theorem}
\label{thm:equivalence}
For every connected graph $H$ on $n$ vertices, there exists a split graph $G$ with $\omega(G) = n$ and its spanning tree $T$ such that
$BBC_{\lambda}(G, T) \le n$ if and only if $BBC_{\lambda}(K_n, H) \le n$.
\end{theorem}
\begin{proof}
First, let us show how to construct $G$ and $T$ for a given $H$.
For convenience, let us denote $m = |E(H)|$.
Let us define:
\begin{itemize}
\item $T'$ as a spanning tree of $H$,
\item $C = V(H)$, $I = \{(u, v)\colon \{u, v\} \in E(H)\}$,
\item $V(G) = V(T) = C \cup I$,
\item $E(G) = \{\{u, v\}\colon u, v \in C\} \cup \{\{w, (u, v)\}\colon w \in C \land (u, v) \in I \land w \neq v\}$,
\item $E(T) = \{\{u, (u, v)\}\colon u \in C \land (u, v) \in I\} \cup E(T')$.
\end{itemize}
Here $I$ is identified with an arbitrary orientation of edges of $H$.
Moreover, it is easy to prove that $T$ is a spanning tree of $G$: every vertex in $I$ has exactly one neighbor in $T$ (which is a vertex from $C$) and $T'$ is also a spanning tree for the vertices from $C$.
Now we will proof that there exists an equivalence between coloring of $K_n$ with backbone $H$ and coloring $G$ with backbone $T$:
$(\Rightarrow)$ Assume that we already have a $\lambda$-backbone coloring $c$ of $(G, T)$ such that $\max_{v \in V(G)} c(v) \le n$.
Let us define a coloring $c'$ of $H$ as $c'(v) = c(v)$ for all $v \in V(H) = C$. Clearly, $\max_{v \in V(H)} c'(v) \le n$.
What is left is to prove that $c'$ meets the constraints on all the edges for $\lambda$-backbone coloring of $(K_n, H)$.
Note that all constraints on non-backbone edges are already met since $c'(u) = c(u) \neq c(v) = c'(v)$ for any $u, v \in C$.
Now let us consider any two vertices $u, v \in V(H)$.
Clearly, $\max_{v \in V(G)} c(v) \le n$ implies that for every vertex $(u, v) \in I$ it has to be the case that $c(v) = c((u, v))$, as $v$ is the only vertex from $C$ which is not adjacent to $(u, v) \in I$ in $G$.
And since $\{u, (u, v)\} \in E(H)$ implies that $|c(u) - c((u, v))| \ge \lambda$, we know that
\begin{align*}
|c'(u) - c'(v)| = |c(u) - c(v)| = |c(u) - c((u, v))| \ge \lambda.
\end{align*}
$(\Leftarrow)$ Assume that we already have $\lambda$-backbone coloring $c$ of $(K_n, H)$ such that $\max_{v \in V(H)} c(v) \le n$.
Let a coloring $c'$ of $G$ with backbone $T$ be defined as follows:
\begin{itemize}
\item $c'(v) = c(v)$ for all $v \in V(H) = C$,
\item $c'((u, v)) = c(v)$ for all $(u, v) \in I$.
\end{itemize}
Clearly, $\max_{v \in V(G)} c'(v) \le \max_{v \in V(H)} c(v) \le n$.
Consider any two vertices in $V(G)$.
If they are $u, v \in C$, then $c'(u) = c'(v)$ would imply that $c(u) = c(v)$ -- which contradicts the fact that $c$ is a proper coloring of $K_n$.
And if $w \in C$, $(u, v) \in I$ (without loss of generality), then $c'(w) = c'((u, v))$ implies that $c(w) = c(v)$ -- however, this is only possible if $w = v$, and therefore when $w$ and $(u, v)$ are not adjacent in $G$.
Finally, consider any two vertices connected by a backbone edge in $T$.
If they are $u, v \in C$, then $|c'(u) - c'(v)| = |c(u) - c(v)| \ge \lambda$ is directly implied by the fact that $\{u, v\} \in E(T') \subseteq E(H)$.
And if $u \in C$, $(u, v) \in I$ (without loss of generality), then the condition $\max_{v \in V(G)} c'(v) \le n$ implies that $c'((u, v)) = c'(v)$, as $|C| = n$ and $v$ is the only vertex in $C$ nonadjacent to $(u, v)$.
Thus,
\begin{align*}
|c'(u) - c'((u, v))| = |c'(u) - c'(v)| = |c(u) - c(v)| \ge \lambda,
\end{align*}
where the last equality follows the fact that if $\{u, (u, v)\} \in E(T)$, then it has to be the case that $\{u, v\} \in E(H)$.
\end{proof}
It turns out that the problem for complete graphs with arbitrary backbones is $\mathcal{NP}$-hard.
\begin{theorem}
Deciding if $BBC_{\lambda}(K_n,H) \le n$ is $\mathcal{NP}$-hard.
\end{theorem}
\todo[inline]{to fix}
\begin{corollary}
Deciding if $BBC_{\lambda}(G, T) \le n$ for a split graph $G$ with $\omega(G) = n$ and a tree $T$ is $\mathcal{NP}$-hard.
\end{corollary}
\todo[inline]{Algorithm for split graphs with tree backbones based on Thm 12}
\end{comment}
\section{Conclusion}
\label{sec:open}
In this paper, we presented a new bound on $BBC_\lambda(K_n, F) = \max\{n, 2 \lambda\} + \Delta^2(F)\lceil\log{n}\rceil$ for forests $F$ on $n$ vertices. This is the first known upper bound dependent on the maximum degree of $F$, better than the existing ones when this parameter is small, e.g. constant.
We also showed that the same reasoning allows us to construct a linear algorithm for finding an $\lambda$-backbone coloring of $K_n$ with backbone $F$ within an additive error of $\Delta^2(F)\lceil\log{n}\rceil$ from the optimum.
Finally, we proved that the bound is asymptotically tight, i.e. there exist a family of trees with $\Delta(T) = 3$ such that $BBC_\lambda(K_n, F) = \max\{n, 2 \lambda\} + \Theta(\log{n})$.
However, there remain a couple of open problems that stem from our research.
First, we can ask if the algorithm from \Cref{sec:positive} can be improved, i.e. does there exist an algorithm running in polynomial time which gives us a coloring using $BBC_\lambda(K_n, F) + o(\log{n})$ colors, or even the optimal one for certain values of $\Delta(F)$.
Or maybe it is the case that finding a $\lambda$-backbone coloring such that $BBC_\lambda(K_n, F) + f(n, \Delta(F))$ for some function $f$ is $\mathcal{NP}$-hard.
Second, there arises a natural question of how to extend our result to other classes of graphs.
An obvious extension would be an analysis for a class of split graphs, i.e. graphs that their vertices can be partitioned into a maximum clique $C$ (of size $\omega(G) = \chi(G)$) and an independent set $I$.
A simple application of \Cref{thm:bbc-algorithm-forest} gives us that
\begin{align*}
BBC_\lambda(G, F) & \le \lambda + BBC_\lambda(G[C], F[C]) \\
& \le \lambda + \max\{\chi(G), 2 \lambda\} + \Delta^2(F) \lceil\log{\chi(G)}\rceil,
\end{align*}
as we can first solve the problem restricted to $C$, find a $\lambda$-backbone coloring using colors from the set $[1, \max\{\chi(G), 2 \lambda\} + \Delta^2(F) \lceil\log{\chi(G)}\rceil]$, and then color all vertices in $I$ with a color $\lambda + \max\{\chi(G), 2 \lambda\} + \Delta^2(F) \lceil\log{\chi(G)} \rceil$.
However, it was proved before that
\begin{theorem}[Salman, \cite{salman2006lambda}]
If $G$ is a split graph and $T$ is its spanning tree, then
\begin{align*}
BBC_{\lambda}(G, T) \le
\begin{cases}
1 & \text{for $\chi(G) = 1$,} \\
\lambda + 1 & \text{for $\chi(G) = 2$,} \\
\lambda + \chi(G) & \text{for $\chi(G) \ge 3$.}
\end{cases}
\end{align*}
This bound is tight.
\end{theorem}
Although our bound is more general, as it applies to all backbones $H$ as long as $H[C]$ is a forest, a simple comparison of both bounds show that for trees (and forests) our bound is worse in all cases, even for small $\lambda$ and large $\chi(G)$. This is mainly because we assign a single color to $I$ naively instead of trying to optimize it.
Still, we can pose a question: is there a way to amend our approach to make it suitable also for split graphs and improve the existing bound at least for some subset of graphs?
\bibliographystyle{plain}
| {'timestamp': '2021-07-14T02:06:26', 'yymm': '2107', 'arxiv_id': '2107.05772', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05772'} | arxiv |
\section{Introduction} \label{sec:intro}
\vspace{-1em}
How many parameters are needed to train a neural network to a specified accuracy? Recent work on two fronts indicates that the answer for a given architecture and dataset pair is often much smaller than the total number of parameters used in modern large-scale neural networks. The first is successfully identifying lottery tickets or sparse trainable subnetworks through iterative training and pruning cycles \citep{frankle2018Lottery}. Such methods utilize information from training to identify lower-dimensional parameter spaces which can optimize to a similar accuracy as the full model. The second is the observation that constrained training within a random, low-dimension affine subspace, is often successful at reaching a high desired train and test accuracy on a variety of tasks, provided that the training dimension of the subspace is above an empirically-observed threshold training dimension \citep{li2018intrinsicdimension}. These results, however, leave open the question of why low-dimensional training is so successful and whether we can theoretically explain the existence of a threshold training dimension.
In this work, we provide such an explanation in terms of the high-dimensional geometry of the loss landscape, the initialization, and the desired loss. In particular, we leverage a powerful tool from high-dimensional probability theory, namely Gordon's escape theorem, to show that this threshold training dimension{} is equal to the dimension of the full parameter space minus the squared Gaussian width of the desired loss sublevel set projected onto the unit sphere around initialization. This theory can then be applied in several ways to enhance our understanding of neural network loss landscapes. For a quadratic well or second-order approximation around a local minimum, we derive an analytic bound on this threshold training dimension{} in terms of the Hessian spectrum and the distance of the initialization from the minimum. For general models, this relationship can be used in reverse to measure important high dimensional properties of loss landscape geometry. For example, by performing a tomographic exploration of the loss landscape, i.e. training within random subspaces of varying training dimension, we uncover a phase transition in the success probability of hitting a given loss sub-level set. The threshold-training dimension is then the phase boundary in this transition, and our theory explains the dependence of the phase boundary on the desired loss sub-level set and the initialization, in terms of the Gaussian width of the loss sub-level set projected onto a sphere surrounding the initialization.
\begin{wrapfigure}{r}{0.36\textwidth}
\centering
\includegraphics[width=0.36\textwidth]{figures/lottery_subspaces_project_cutting_plane_v2.pdf}
\caption{Illustration of finding a point in the intersection between affine subspaces and low-loss sublevel set. We use three methods: 1) \textit{random affine subspaces} (blue) containing the initialization, 2) \textit{burn-in affine subspaces} (red) containing a pre-trained point on the training trajectory, and 3) \textit{lottery subspaces} (purple) whose span is defined by the steps of a full training trajectory.}
\vspace{-15pt}
\label{fig:cartoon_cuts}
\end{wrapfigure}
Motivated by lottery tickets, we furthermore consider training not only within random dimensions, but also within optimized subspaces using information from training in the full space. Lottery tickets can be viewed as constructing an optimized, axis-aligned subspace, i.e. where each subspace dimension corresponds to a single parameter. What would constitute an optimized choice for general subspaces? We propose two new methods: burn-in subspaces which optimize the offset of the subspace by taking a few steps along a training trajectory and lottery subspaces determined by the span of gradients along a full training trajectory (Fig.~\ref{fig:cartoon_cuts}). Burn-in subspaces in particular can be viewed as lowering the threshold training dimension{} by moving closer to the desired loss sublevel set. For all three methods, we empirically explore the threshold training dimension{} across a range of datasets and architectures.
\textbf{Related Work:} An important motivation of our work is the observation that training within a random, low-dimensional affine subspace can suffice to reach high training and test accuracies on a variety of tasks, provided the training dimension exceeds a threshold that was called the \textit{intrinsic dimension} \citep{li2018intrinsicdimension} and which we call the threshold training dimension{}. However \citet{li2018intrinsicdimension} provided no theoretical explanation for this threshold and did not explore the dependence of this threshold on the quality of the initialization. Our primary goal is to provide a theoretical explanation for the existence of this threshold in terms of the geometry of the loss landscape and the quality of initialization. Indeed understanding the geometry of high dimensional error landscapes has been a subject of intense interest in deep learning, see e.g. \citet{Dauphin2014-lk, goodfellow2014qualitatively, fort2019largescale, ghorbani2019investigation, sagun2016eigenvalues, sagun2017empirical, yao2018hessianbased, fort2019goldilocks, papyan2020traces, gur2018gradient,fort2019emergent, papyan2019measurements,fort2020deep}, or \citet{Bahri2020-mi} for a review. But to our knowledge, the Gaussian width of sub-level sets projected onto a sphere surrounding initialization, a key quantity that determines the threshold training dimension, has not been extensively explored in deep learning.
Another motivation for our work is contextualizing the efficacy of diverse more sophisticated network pruning methods like lottery tickets \citep{frankle2018Lottery, frankle2019stabilizing}. Further work in this area revealed the advantages obtained by pruning networks not at initialization \citep{frankle2018Lottery, Lee2018-vt, Wang2020-jt, Tanaka2020-no} but slightly later in training \citep{frankle2020pruning}, highlighting the importance of early stages of training \citep{jastrzebski2020breakeven,lewkowycz2020large}.
We find empirically, as well as explain theoretically, that even when training within random subspaces, one can obtain higher accuracies for a given training dimension if one starts from a slightly pre-trained, or burned-in initialization as opposed to a random initialization.
\section{An empirically observed phase transition in training success}
\label{sec:methods}
We begin with the empirical observation of a phase transition in the probability of hitting a loss sub-level set when training within a random subspace of a given training dimension, starting from some initialization. Before presenting this phase transition, we first define loss sublevel sets and two different methods for training within a random subspace that differ only in the quality of the initialization. In the next section we develop theory for the nature of this phase transition.
\paragraph{Loss sublevel sets.} Let $\hat{\V{y}} = f_{\V{w}}(\V{x})$ be a neural network with weights $\V{w} \in \mathbb{R}^D$ and inputs $\V{x} \in \mathbb{R}^k$. For a given training set $\{\V{x}_n, \V{y}_n\}_{n=1}^N$ and loss function $\ell$, the empirical loss landscape is given by $\mathcal{L}(\V{w}) = \frac{1}{N} \sum_{n = 1}^N \ell \Big (f_{\V{w}}(\V{x}_n), \V{y}_n \Big).$
Though our theory is general, we focus on classification for our experiments, where $\V{y} \in \{0,1\}^C$ is a one-hot encoding of $C$ class labels, $\hat{\V{y}}$ is a vector of class probabilities, and $\ell (\hat{\V{y}}, \V{y})$ is the cross-entropy loss. In general, the loss sublevel set $S(\epsilon)$ at a desired value of loss $\epsilon$ is the set of all points for which the loss is less than or equal to $\epsilon$:
\begin{equation}
\label{eq:sublevel}
S(\epsilon) := \{\V{w} \in \mathbb{R}^D: \mathcal{L}(\V{w}) \leq \epsilon \}.
\end{equation}
\paragraph{Random affine subspace.}
Consider a $d$ dimensional random affine hyperplane contained in $D$ dimensional weight space, parameterized by $\V{\theta} \in \mathbb{R}^d$: $\V{w}(\V{\theta}) = \Mx{A} \V{\theta} + \V{w}_0.$
Here $\Mx{A} \in \mathbb{R}^{D \times d}$ is a random Gaussian matrix with columns normalized to $1$ and $\V{w}_0 \in \mathbb{R}^D$ a random weight initialization by standard methods. To train within this subspace, we initialize $\V{\theta} = \V{0}$, which corresponds to randomly initializing the network at $\V{w}_0$, and we minimize $\mathcal{L}\big (\V{w}(\V{\theta}) \big)$ with respect to $\V{\theta}$.
\paragraph{Burn-in affine subspace.} Alternatively, we can initialize the network with parameters $\V{w}_0$ and train the network in the full space for some number of iterations $t$, arriving at the parameters $\V{w}_{\mathrm{t}}$. We can then construct the random burn-in subspace
\begin{equation}
\label{eq:burnin}
\V{w}(\V{\theta}) = \Mx{A} \V{\theta} + \V{w}_{\mathrm{t}},
\end{equation}
with $\Mx{A}$ chosen randomly as before, and then subsequently train within this subspace by minimizing $\mathcal{L} \big (\V{w}(\V{\theta}) \big)$ with respect to $\V{\theta}$. The random affine subspace is identical to the burn-in affine subspace but with $t=0$. Exploring the properties of training within burn-in as opposed to random affine subspaces enables us to explore the impact of the quality of the initialization, after burning in some information from the training data, on the success of subsequent restricted training.
\paragraph{Success probability in hitting a sub-level set.} In either training method, achieving $\mathcal{L}\left (\V{w}(\V{\theta}) \right) = \epsilon$ implies that the intersection between our random or burn-in affine subspace and the loss sub-level set $S(\epsilon')$ is non-empty for all $\epsilon' \geq \epsilon$.
As both the subspace $\Mx{A}$ and the initialization $\V{w}_0$ leading to $\V{w}_{\mathrm{t}}$ are random, we are interested in the success probability $P_s(d,\epsilon,t)$ that a burn-in (or random when $t=0$) subspace of training dimension $d$ actually intersects a loss sub-level set $S(\epsilon)$:
\begin{equation}
P_s(d,\epsilon,t) \equiv \mathbb{P} \Big [ S(\epsilon) \cap \big \{ \V{w}_t + \Span(\Mx{A}) \big \} \neq \emptyset \Big ].
\label{eq:ps}
\end{equation}
Here, $\Span(\Mx{A})$ denotes the column space of $\Mx{A}$. Note in practice we cannot guarantee that we obtain the minimal loss in the subspace, so we use the best value achieved by \texttt{Adam} \citep{kingma2014adam} as an approximation. Thus the probability of achieving a given loss sublevel set via training constitutes an approximate lower bound on the probability in \eqref{eq:ps} that the subspace actually intersects the loss sublevel set.
\paragraph{Threshold training dimension as a phase transition boundary.} We will find that for any fixed $t$, the success probability $P_s(d,\epsilon,t)$ in the $\epsilon$ by $d$ plane undergoes a sharp phase transition. In particular for a desired (not too low) loss $\epsilon$ it transitions sharply from $0$ to $1$ as the training dimension $d$ increases. To capture this transition we define:
\begin{definition}
\label{def:effDim}
[Threshold training dimension{}] The threshold training dimension{} $d^*(\epsilon, t, \delta)$ is the minimal value of $d$ such that $P_s(d,\epsilon,t) \geq 1-\delta$ for some small $\delta > 0$.
\end{definition}
For any chosen criterion $\delta$ (and fixed $t$) we will see that the curve $d^*(\epsilon, t, \delta)$ forms a phase boundary in the $\epsilon$ by $d$ plane separating two phases of high and low success probability.
\begin{figure}[!ht]
\centering
\includegraphics[width=\linewidth]{figures/EmpiricalProbability_v2.png}
\caption{An empirical phase transition in training success on 4 datasets (4 rows) for a \texttt{Conv-2} comparing random affine subspaces (column 1) and burn-in affine subspaces with $t=4,8,16$ burn-in steps (columns 2,3,4). The black-white color maps indicate the empirically measured success probability $P_s(d,\epsilon,t)$ in \eqref{eq:ps} in hitting a training loss sub-level set (or more precisely a training accuracy super-level set). This success probability is estimated by training on $10$ runs at every training dimension $d$ and burn-in time $t$. The horizontal dashed line represents the baseline accuracy obtained by training the full model for the same number of epochs. The colored curves indicate the threshold training dimension{} $d^*(\epsilon, t, \delta)$ in \cref{def:effDim} for $\delta=0.1$. The threshold training dimensions for the $4$ training methods are copied and superimposed in the final column.}
\label{fig:empirical_probability}
\end{figure}
This definition also gives an operational procedure to approximately measure the threshold training dimension{}: run either the random or burn-in affine subspace method repeatedly over a range of training dimensions $d$ and record the lowest loss value $\epsilon$ found in the plane when optimizing via $\texttt{Adam}$. We can then construct the empirical probability across runs of hitting a given sublevel set $S(\epsilon)$ and the threshold training dimension{} is lowest value of $d$ for which this probability crosses $1 - \delta$ (where we employ $\delta=0.1$).
\subsection{An empirical demonstration of a training phase transition}
\label{sec:exp}
In this section, we carry out this operational procedure, comparing random and burn-in affine subspaces across a range of datasets and architectures. We examined $3$ architectures: 1) \texttt{Conv-2} which is a simple 2-layer CNN with 16 and 32 channels, ReLU activations and \texttt{maxpool} after each convolution followed by a fully connected layer; 2) \texttt{Conv-3} which is a 3-layer CNN with 32, 64, and 64 channels but otherwise identical setup to \texttt{Conv-2}; and 3) \texttt{ResNet20v1} as described in \cite{he2016deep} with on-the-fly batch normalization \citep{ioffe2015batch}. We perform experiments on 5 datasets: MNIST \citep{lecun2010mnist}, Fashion MNIST \citep{xiao2017fashion}, CIFAR-10 and CIFAR-100 \citep{krizhevsky2014cifar}, and SVHN \citep{netzer2011reading}. Baselines and experiments were run for the same number of epochs for each model and dataset combination; further details on architectures, hyperparameters, and training procedures are provided in the appendix.
The code for the experiments was implemented in JAX \citep{jax2018github}.
\Cref{fig:empirical_probability} shows results on the training loss for 4 datasets for both random and burn-in affine subspaces with a \texttt{Conv-2}. We obtain similar results for the two other architectures (see Appendix). \Cref{fig:empirical_probability} exhibits several broad and important trends. First, for each training method within a random subspace, there is indeed a sharp phase transition in the success probability $P_s(d,\epsilon,t)$ in the $\epsilon$ (or equivalently accuracy) by $d$ plane from $0$ (white regions) to $1$ (black regions). Second, the threshold training dimension $d^*(\epsilon, t, \delta)$ (with $\delta=0.1$) does indeed track the tight phase boundary separating these two regimes. Third, broadly for each method, to achieve a lower loss, or equivalently higher accuracy, the threshold training dimension{} is higher; thus one needs more training dimensions to achieve better performance. Fourth, when comparing the threshold training dimension across all $4$ methods on the same dataset (final column of \Cref{fig:empirical_probability}) we see that at high accuracy (low loss $\epsilon$), {\it increasing} the amount of burn in {\it lowers} the threshold training dimension. To see this, pick a high accuracy for each dataset, and follow the horizontal line of constant accuracy from left to right to find the threshold training dimension for that accuracy. The first method encountered with the lowest threshold training dimension is burn-in with $t=16$. Then burn-in with $t=8$ has a higher threshold training dimension{} and so on, with random affine having the highest. Thus the main trend is, for some range of desired accuracies, burning {\it more} information into the initialization by training on the training data {\it reduces} the number of subsequent training dimensions required to achieve the desired accuracy.
\Cref{fig:MainExperiment} shows the threshold training dimension for each accuracy level for all three models on MNIST, Fashion MNIST and CIFAR-10, not only for training accuracy, but also for test accuracy. The broad trends discussed above hold robustly for both train and test accuracy for all 3 models.
\begin{figure*}[!ht]
\centering
\includegraphics[width=0.9\linewidth]{figures/AllResults_IncreasingDim_v2.png}
\caption{The threshold training dimension{} $d^*(\epsilon, t, \delta)$ in \cref{def:effDim}. Here we focus on small dimensions and lower desired accuracies to emphasize the differences in threshold training dimension{} across different training methods. The purple curves are generated via a novel lottery subspace training method which we introduce in \cref{sec:lottery}. The curves summarize data for 10 runs for \texttt{Conv-2}, 5 runs for \texttt{Conv-3}, and 3 runs for \texttt{ResNet20}; the choice of $\delta$ will determine how many runs must successfully hit the sublevel set when reading off $d^*$. The dimensions of the full parameter space for the experiments with CIFAR-10 are 25.6k for \texttt{Conv-2}, 66.5k for \texttt{Conv-3}, and 272.5k for \texttt{ResNet20}. On the other two datasets, the full parameter space is 20.5k for \texttt{Conv-2}, 61.5k for \texttt{Conv-3}, and 272.2k for \texttt{ResNet20}. The black dotted line is the accuracy obtained by training the full model for the same number of epochs.}
\label{fig:MainExperiment}
\end{figure*}
\section{A theory of the phase transition in training success}
\label{sec:theory}
Here we aim to give a theoretical explanation for the major trends observed empirically above, namely: (1) there exists a phase transition in the success probability $P_s(d,\epsilon,t)$ yielding a phase boundary given by a threshold training dimension{} $d^*(\epsilon, t, \delta)$; (2) at fixed $t$ and $\delta$ this threshold increases as the desired loss $\epsilon$ decreases (or desired accuracy increases), indicating more dimensions are required to perform better; (3) at fixed $\epsilon$ and $\delta$, this threshold decreases as the burn-in time $t$ increases, indicating {\it fewer} training dimensions are required to achieve a given performance starting from a {\it better} burned-in initialization. Our theory will build upon several aspects of high dimensional geometry which we first review. In particular we discuss, in turn, the notion of the Gaussian width of a set, then Gordon's escape theorem, and then introduce a notion of local angular dimension{} of a set about a point. Our final result, stated informally, will be that the threshold training dimension plus the local angular dimension of a desired loss sub-level set about the initialization must equal the total number of parameters $D$. As we will see, this succinct statement will conceptually explain the major trends observed empirically. First we start with the definition of Gaussian width:
\begin{definition}
[Gaussian Width] The Gaussian width of a subset $S \subset \mathbb{R}^D$ is given by (see \Cref{fig:cartoon_gaussian_width}):
\begin{equation*}
w(S) = \frac{1}{2} \mathbb{E} \sup_{\V{x}, \V{y} \in S} \langle \V{g}, \V{x} - \V{y} \rangle, \quad \V{g} \sim \mathcal{N}(\V{0}, \Mx{I}_{D \times D}).
\end{equation*}
\end{definition}
As a simple example, let $S$ be a solid $l_2$ ball of radius $r$ and dimension $d \ll D$ embedded in $\mathbb{R}^D$. Then its Gaussian width for large $D$ is well approximated by $w(S) = r\sqrt{d}$.
\begin{figure}[!ht]
\centering
\includegraphics[width=0.4\linewidth,trim=0 -1cm 0 -1cm]{figures/lottery_subspace_gaussian_width-Brett.png}
\includegraphics[width=0.4\linewidth]{figures/lottery_subspaces_sphere_projection.png}
\caption{\textbf{Left panel:} An illustration of measuring the width of a set $S$ (in green) in a direction $\hat{\V{g}}$ by identifying $\V{x},\V{y} \in S$ in $\max_{\V{x},\V{y} \in S} \hat{\V{g}} \cdot (\V{y} - \V{x})$. The expectation of this width using random vectors $\V{g} \sim \mathcal{N}(\V{0},\Mx{I}_{D \times D})$ instead of $\hat{\V{g}}$ is twice the Gaussian width $w(S)$. Intuitively, it is the characteristic extent of the set $T$ over all directions rescaled by a factor between $D/\sqrt{D+1}$ and $\sqrt{D}$. \textbf{Right panel:} Illustration of projecting manifolds on the unit sphere and Gordon's escape theorem. The same manifold far from the sphere will have a smaller projection to it than the one that is close, and therefore it will be harder to intersect with an affine subspace.}
\label{fig:cartoon_gaussian_width}
\label{fig:cartoon_sphere_projection}
\end{figure}
\paragraph{Gordon's escape theorem.} The Gaussian width $w(S)$ of a set $S$, at least when that set is contained in a unit sphere around the origin, in turn characterizes the probability that a random subspace intersects that set, through Gordon's escape theorem \citep{gordon1988milman}:
\begin{theorem}
\label{thm:escape}
[Escape Theorem] Let $S$ be a closed subset of the unit sphere in $\mathbb{R}^D$. If $k > w(S)^2$, then a $d = D-k$ dimensional subspace $Y$ drawn uniformly from the Grassmannian satisfies \citep{gordon1988milman}:
\begin{equation*}
\mathbb{P} \Big ( Y \cap S = \emptyset \Big ) \geq 1 - 3.5 \exp \left [ - \big (k/\sqrt{k+1} - w(S) \big )^2/18 \right ].
\end{equation*}
\end{theorem}
A clear explanation of the proof can be found in \cite{mixon_2014}.
Thus, the bound says when $k > w^2(S)$, the probability of no intersection quickly goes to $1- \epsilon$ for any $\epsilon > 0$.
Matching lower bounds which state that the intersection occurs with high probability when $k \leq w(S)^2$ have been proven for spherically convex sets \citep{amelunxen2014living}. Thus, this threshold is sharp except for the subtlety that you are only guaranteed to hit the spherical convex hull of the set (defined on the sphere) with high probability.
When expressed in terms of the subspace dimension $d=D-k$, rather than its co-dimension $k$, these results indicate that a $d$ dimensional subspace will intersect a closed subset $S$ of the unit sphere around the origin with high probability if and only if $d + w(S)^2 \geq D$, with a sharp transition at the threshold $d^* = D - w(S)^2$. This is a generalization of the result that two random subspaces in $\mathbb{R}^D$ of dimension $d$ and $d_2$ intersect with high probability if and only if $d + d_2 > D$. Thus we can think of $w(S)^2$ as playing a role analogous to dimension for sets on the centered unit sphere.
\subsection{Intersections of random subspaces with general subsets}
To explain the training phase transition, we must now adapt Gordon's escape theorem to a general loss sublevel set $S$ in $\mathbb{R}^D$, and we must take into account that the initialization $\V{w}_\mathrm{t}$ is not at the origin in weight space. To do so, we first define the projection of a set $S$ onto a unit sphere centered at $\V{w}_\mathrm{t}$:
\begin{equation}
\mathrm{proj}_{\V{w}_t}(S) \equiv \{(\V{x} - \V{w}_\mathrm{t}) / ||\V{x} - \V{w}_\mathrm{t}||_2 : \V{x} \, \in \, S\}.
\end{equation}
Then we note that any affine subspace $Y$ of the form in \cref{eq:burnin} centered at $\V{w}_\mathrm{t}$ intersects $S$ if and only if it intersects $\mathrm{proj}_{\V{w}_t}(S)$. Thus we can apply Gordon's escape theorem to $\mathrm{proj}_{\V{w}_t}(S)$ to compute the probability of the training subspace in \cref{eq:burnin} intersecting a sublevel set $S$. Since the squared Gaussian width of a set in a unit sphere plays a role analogous to dimension, we define:
\begin{definition} [Local angular dimension{}] The local angular dimension{} of a general set $S \subset \mathbb{R}^D$ about a point $\V{w}_t$ is defined as
\begin{equation}
\begin{split}
d_\mathrm{local}(S, \V{w}_t) \equiv w^2(\mathrm{proj}_{\V{w}_t}(S)).
\label{eq:thresh_dimension_for_real}
\end{split}
\end{equation}
\end{definition}
An escape theorem for general sets $S$ and affine subspaces now depends on the initialization $\V{w}_\mathrm{t}$ also, and follows from the above considerations and Gordon's original escape theorem:
\begin{theorem}
\label{thm:mainTheorem}
[Main Theorem] Let $S$ be a closed subset of $\mathbb{R}^D$. If $k > w(\mathrm{proj}_{\V{w}_t}(S))^2$, then a $d = D-k$ dimensional affine subspace drawn uniformly from the Grassmannian and centered at $\V{w}_t$ satisfies:
\begin{equation*}
\mathbb{P} \Big ( Y \cap S = \emptyset \Big ) \geq 1 - 3.5 \exp \left [ - \big (k/\sqrt{k + 1} - w(\mathrm{proj}_{\V{w}_t}(S)) \big )^2/18 \right ].
\end{equation*}
\end{theorem}
To summarise this result in the context of our application, given an arbitrary loss sub-level set $S(\epsilon)$, a training subspace of training dimension $d$ starting from an initialization
$\V{w}_\mathrm{t}$ will hit the (convex hull) of the loss sublevel set with high probability
when $d + d_\mathrm{local}(S(\epsilon), \V{w}_t) > D$, and will miss it (i.e have empty intersection)
with high probability when $d + d_\mathrm{local}(S(\epsilon), \V{w}_t) < D$. This analysis thus establishes the existence of a phase transition in the
success probability $P_s(d,\epsilon,t)$ in \cref{eq:ps},
and moreover establishes the threshold training dimension{} $d^*(\epsilon, t, \delta)$ for small values of $\delta$ in \cref{def:effDim}:
\begin{equation}
d^*(S(\epsilon), \V{w}_t) = D - d_\mathrm{local}(S(\epsilon), \V{w}_t).
\end{equation}
Our theory provides several important insights on the nature of threshold training dimension{}. Firstly, small threshold training dimensions can only arise if the local angular dimension of the loss sublevel set $S(\epsilon)$ about the initialization $\V{w}_\mathrm{t}$ is close to the ambient dimension. Second, as $\epsilon$ increases, $S(\epsilon)$ becomes larger, with a larger $d_\mathrm{local}(S(\epsilon), \V{w}_t)$, and consequently a smaller threshold training dimension{}. Similarly, if $\V{w}_\mathrm{t}$ is closer to $S(\epsilon)$, then $d_\mathrm{local}(S(\epsilon), \V{w}_t)$ will be larger, and the threshold training dimension{} will also be lower (see \cref{fig:cartoon_sphere_projection}). This observation accounts for the observed decrease in threshold training dimension{} with increased burn-in time $t$. Presumably, burning in information into the initialization $\V{w}_\mathrm{t}$ for a longer time $t$ brings the initialization closer to the sublevel set $S(\epsilon)$, making it easier to hit with a random subspace of lower dimension. This effect is akin to staring out into the night sky in a single random direction and asking with what probability we will see the moon; this probability increases the closer we are to the moon.
\subsection{A paradigmatic loss landscape example: the quadratic well}
\label{sec:quadratic}
\begin{figure}[!ht]
\centering
\includegraphics[width=1.0\linewidth]{figures/plot_quadratic_cuts_id95226142.pdf}
\includegraphics[width=1.0\linewidth]{figures/plot_quadratic_cuts_id67328088.pdf}
\vspace{-0.5cm}
\caption{A comparison between simulated results and our analytic upper bound for threshold training dimension{} of sublevel sets on a synthetic quadratic well. The middle 3 columns show the success probability $P_s(d,\epsilon,R)$ as a function of $d$ and $\epsilon$ for three different values of the distance $R$ between initialization and the global minimum, clearly exhibiting a phase transition (black and white maps). This success probability is estimated from a numerical experiment across 10 runs and the estimated threshold training dimensions are shown as solid curves. Our analytic upper bounds on threshold training dimension obtained from our lower bound on local angular dimension in Eq.~\ref{eq:quadratic_analytics} are shown as dashed curves. The top row shows the case of a quadratic basin with a bimodal split of eigenvalues; the local angular dimension{} is approximately the number of long directions (small eigenvalues) and we start hitting low-loss sublevel sets at $D/2$ as expected. The bottom row shows the case of a continuous bulk spectrum. In both cases, threshold training dimension{} is lowered as the distance $R$ is decreased. The upper bound is tighter when $\epsilon$ is close to 0, the regime of we are most interested in.}
\label{fig:toy_model_quadratic_well}
\end{figure}
To illustrate our theory, we work out the paradigmatic example of a quadratic loss function $\mathcal{L}(\V{w}) = \frac{1}{2} \V{w}^T \Mx{H} \V{w}$ where $\V{w} \in \mathbb{R}^d$ and $\Mx{H} \in \mathbb{R}^{D \times D}$ is a symmetric, positive definite Hessian matrix. A sublevel set $S(\epsilon)$ of the quadratic well is an ellipsoidal body with principal axes along the eigenvectors $\hat{\V{e}}_i$ of $\Mx{H}$. The radius $r_i$ along principal axis $\hat{\V{e}}_i$ obeys $\frac{1}{2} \lambda_i r_i^2 = \epsilon$ where $\lambda_i$ is the eigenvalue. Thus $r_i = \sqrt{2 \epsilon/\lambda_i}$, and so a large (small) Hessian eigenvalue leads to a narrow (wide) radius along each principal axis of the ellipsoid. The overall squared Gaussian width of the sublevel set obeys $w^2(S(\epsilon)) \sim 2 \epsilon \Tr(\Mx{H}^{-1}) = \sum_i r_i^2$, where $\sim$ denotes bounded above and below by this expression times positive constants \citep{vershynin2018high}.
We next consider training within a random subspace of dimension $d$ starting from some initialization $\V{w}_0$. To compute the probability the subspace hits the sublevel set $S(\epsilon)$, as illustrated in Fig.~\ref{fig:cartoon_sphere_projection}, we must project this ellipsoidal sublevel set onto the surface of the unit sphere centered at $\V{w}_0$. The Gaussian width of this projection $\mathrm{proj}_{\V{w}_0}(S(\epsilon))$ depends on the distance $R \equiv ||\V{w}_0||$ from the initialization to the global minimum at $\V{w}=\V{0}$ (i.e. it should increase with decreasing $R$). We can develop a crude approximation to this width as follows. Assuming $D \gg 1$, the direction $\hat{\V{e}}_i$ will be approximately orthogonal to $\V{w}_0$, so that $| \hat{\V{e}}_i \cdot \V{x}_0 | \ll R$. The distance between the tip of the ellipsoid at radius $r_i$ along principal axis $\V{e}_i$ and the initialization $\V{w}_0$ is therefore $\rho_i = \sqrt{R^2 + r_i^2}$. The ellipse's radius $r_i$ then gets scaled down to approximately $r_i / \sqrt{R^2 + r_i^2}$ when projected onto the surface of the unit sphere. Note the subtlety in this derivation is that the point actually projected onto the sphere is where a line through the center of the sphere lies tangent to the ellipse rather than the point of fullest extent. As a result, $r_i / \sqrt{R^2 + r_i^2}$ provides a lower bound to the projected extent on the circle. This is formalized in the appendix along with an explanation as to why this bound becomes looser with decreasing $R$.
Taken together, a lower bound on the local angular dimension of $S(\epsilon)$ about $\V{w}_0$ is:
\begin{equation}
d_{\mathrm{local}}(\epsilon,R) = w^2\big(\proj_{\V{w}_0}(S(\epsilon))\big) \gtrsim \sum_i \frac{r_i^2}{R^2 + r_i^2} \, ,
\label{eq:quadratic_analytics}
\end{equation}
where again $r_i = \sqrt{2 \epsilon/\lambda_i}$. In Fig.~\ref{fig:toy_model_quadratic_well}, we plot the corresponding upper bound on the threshold training dimension{}, i.e. $D - d_{\mathrm{local}}(\epsilon,R)$ alongside simulated results for two different Hessian spectra.
\vspace{-1em}
\section{Characterizing and comparing the space of pruning methods} \label{sec:lottery}
\vspace{-1em}
Training within random subspaces is primarily a scientific tool to explore loss landscapes. It further has the advantage that we can explain theoretically why the number of degrees of freedom required to train can be far fewer than the number of parameters, as described above. However, there are many other pruning methods of interest. For example, the top row of \Cref{tab:Methods} focuses on pruning to axis aligned subspaces, starting from random weight pruning, to lottery tickets which use information from training to prune weights, and/or choose the initialization if not rewound to init. As one moves from left to right, one achieves better pruning (fewer degrees of freedom for a given accuracy). Our analysis can be viewed as relaxing the axis-aligned constraint to pruning to general subspaces (second row of \Cref{tab:Methods}), either not using training at all (random affine subspaces), or using information from training to only to choose the init (burn in affine subspaces). This analogy naturally leads to the notion of lottery subspaces described below (an analog of lottery tickets with axis-alignment relaxed to general subspaces) either rewound to init or not (last two entries of \Cref{tab:Methods}). We compare the methods we have theoretically analyzed (random and burn-in affine subspaces) to popular methods like lottery tickets rewound to init, and our new method of lottery subspaces, in an effort understand the differential efficacy of various choices like axis-alignment, initialization, and the use of full training information to prune. A full investigation of \cref{tab:Methods} however is the subject of future work.
\begin{table*}[h]
\centering
\vspace{-0.25cm}
\caption{Taxonomy of Pruning Methods.}
\vspace{0.2cm}
\begin{tabular}{c||c|c|c|c}
&
\begin{tabular}{@{}c@{}} \bf Training \\ \bf not used\end{tabular} &
\begin{tabular}{@{}c@{}} \bf Training used \\ \bf for init. only\end{tabular} &
\begin{tabular}{@{}c@{}} \bf Training used \\ \bf for pruning only \end{tabular} &
\begin{tabular}{@{}c@{}} \bf Training used for\\ \bf init. and pruning \end{tabular} \\
\hline
\hline
\begin{tabular}{@{}c@{}} \bf Axis-aligned \\ \bf subspaces\end{tabular} &
\begin{tabular}{@{}c@{}} Random weight \\ pruning \end{tabular} &
\begin{tabular}{@{}c@{}} Random weight \\ pruning at step $t$ \end{tabular} &
\begin{tabular}{@{}c@{}} Lottery tickets, \\ rewound to init. \end{tabular} &
\begin{tabular}{@{}c@{}} Lottery tickets, \\ rewound to step $t$ \end{tabular} \\
\hline
\begin{tabular}{@{}c@{}} \bf General \\ \bf subspaces\end{tabular} &
\begin{tabular}{@{}c@{}} Random affine \\ subspaces \end{tabular} &
\begin{tabular}{@{}c@{}} Burn-in affine \\ at step $t$ \end{tabular} &
Lottery subspaces &
\begin{tabular}{@{}c@{}} Lottery subspaces \\ at step $t$ \end{tabular} \\
\end{tabular}
\label{tab:Methods}
\end{table*}
\paragraph{Lottery subspaces.} We first train the network in the full space starting from an initialization $\V{w}_0$. We then form the matrix $\Mx{U}_d \in \mathbb{R}^{D \times d}$ whose $d$ columns are the top $d$ principal components of entire the training trajectory $\V{w}_{0:T}$ (see Appendix for details). We then train within the subspace $\V{w}(\V{\theta}) = \Mx{U}_d \V{\theta} + \V{w}_t$
starting from a rewound initialization $\V{w}_t$ ($t=0$ is rewinding to the original init).
Since the subspace is optimized to match the top $d$ dimensions of the training trajectory, we expect lottery subspaces to achieve much higher accuracies for a given training dimension than random or potentially even burn-in affine subspaces.
This expectation is indeed borne out in Fig.~\ref{fig:MainExperiment} (purple lines above all other lines).
Intriguingly, {\it very} few lottery subspace training dimensions (in the range of $20$ to $60$ depending on the dataset and architecture) are required to attain full accuracy, and thus
lottery subspaces can set a (potentially optimistic) target for what accuracies might be attainable by practical network pruning methods as a function of training dimension.
\begin{figure*}[!ht]
\vspace{-1em}
\centering
\includegraphics[width=0.95\linewidth]{figures/AllResults_CompressionRatio_v2.png}
\vspace{-1em}
\caption{Accuracy vs. compression ratio for the same data. Compression ratio is defined the number of parameters in the full model over the dimension of the subspace ($D/d$). The dimensions of the full parameter space for the experiments with CIFAR-10 are 25.6k for \texttt{Conv-2}, 66.5k for \texttt{Conv-3}, and 272.5k for \texttt{ResNet20}. On the other two datasets, the full parameter space is 20.5k for \texttt{Conv-2}, 61.5k for \texttt{Conv-3}, and 272.2k for \texttt{ResNet20}. The curve for each lottery ticket experiment summarizes data for at least 5 runs. For all other experiments, the curve summarizes data for 10 runs for \texttt{Conv-2}, 5 runs for \texttt{Conv-3}, and 3 runs for \texttt{ResNet20}. Black dotted lines are the accuracy of the full model run for the same number of epochs.}
\label{fig:CompressionRatio}
\end{figure*}
\vspace{-2em}
\paragraph{Empirical comparison of pruning methods.} \Cref{fig:CompressionRatio} presents empirical results comparing a subset of the methods in \cref{tab:Methods}: random affine subspaces, burn-in affine subspaces, lottery subspaces, and lottery tickets plotted against model compression ratio (defined as parameters in full model over parameters, or training dimension, in restricted model). The lottery tickets were constructed by training for 2 epochs, performing magnitude pruning of weights and biases, rewinding to initialization, and then training for the same number of epochs as the other methods. Note that lottery tickets are created by pruning the full model (increasing compression ratio) in contrast to all other methods which are built up from a single dimension (decreasing compression ratio).
We observe lottery subspaces significantly outperform random subspaces and lottery tickets at low training dimensions (high compression ratios), and we explore the spectrum of these spaces in more detail in the Appendix.
The comparison to lottery tickets at low compression ratios is limited by the fact that it is computationally expensive to project to higher dimensional subspaces and thus the highest training dimension we used was $4096$. In the regions where the experiments overlap, the lottery tickets do not outperform random affine subspaces, indicating that they are not gaining an advantage from the training information they utilize. A notable exception is \texttt{Conv-2} on CIFAR-10 in which the lottery tickets do outperform random affine subspaces. Finally, we note lottery tickets do not perform well at high compression ratios due to the phenomenon of layer collapse, where an entire layer gets pruned.
\vspace{-1em}
\section{Conclusion} \label{sec:conclusion}
\vspace{-1em}
The surprising ability of pruning methods like lottery tickets to achieve high accuracy with very few well chosen parameters, and even higher accuracy if not rewound to init, but to a later point in training, has garnered great interest in deep learning, but has been hard to analyze. In this paper we focused on gaining theoretical insight into when and why training within a random subspace starting at different inits (or burn-ins) along a full training trajectory can achieve a given low loss $\epsilon$. We find that this can occur only when the local angular dimension of the loss sublevel set $S(\epsilon)$ about the init is high, or close to the ambient dimension $D$. Our theory also explains geometrically why longer burn-in lowers the the number of degrees of freedom required to train to a given accuracy. This is analogous to how rewinding to a later point in training reduces the size of lottery tickets, and indeed may share a similar mechanism.
Overall, these theoretical insights and comparisons begin to provide a high dimensional geometric framework to understand and assess the efficacy of a wide range of network pruning methods at or beyond initialization.
\section*{Acknowledgements}
B.W.L. was supported by the Department of Energy Computational Science Graduate Fellowship program (DE-FG02-97ER25308).
S.G. thanks the Simons Foundation, NTT Research and an NSF Career award for funding while at Stanford.
| {'timestamp': '2022-02-04T02:10:29', 'yymm': '2107', 'arxiv_id': '2107.05802', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05802'} | arxiv |
\section{Introduction}\label{sec:introduction}
It is conventional in MIR\footnote{MIR has a broad definition, but in this paper ``MIR'' refers specifically to making discriminative predictions on music audio.}
to \emph{pre-train} models on large labeled datasets for one or more tasks (commonly tagging), and reuse the learned representations for different \emph{downstream} tasks~\cite{hamel2013transfer,oord2014transfer,choi2017transfer,park2017representation,lee2018samplecnn,lee2019representation,pons2019musicnn,huang2020large,kim2020one}.
Such \emph{transfer learning} approaches decrease the amount of labeled data needed to perform well on downstream tasks, which is particularly useful in MIR where labeled data for many important tasks is scarce~\cite{mcfee2018open,chen2019data}.
Historically-speaking,
improvement on downstream tasks is enabled by finding ever-larger sources of labels for pre-training---in chronological order:
tags~\cite{oord2014transfer},
metadata~\cite{park2017representation,lee2019representation,huang2020large,kim2020one}, and
recently, co-listening data~\cite{huang2020large}.
However, it stands to reason that directly modeling music~\emph{audio} (as opposed to labels) could yield richer representations.
Recently, contrastive learning~\cite{chen2020simple} has been proposed as an MIR pre-training strategy which learns representations from audio~\cite{spijkervet2021contrastive},
but this paradigm has yet to exceed the performance of label-based pre-trained models on downstream tasks.
Outside of the discriminative MIR landscape,
a recent system called Jukebox~\cite{dhariwal2020jukebox} demonstrated promising performance for generating music audio.
To achieve this result, Jukebox leverages recent architectural developments from natural language processing (NLP) by \emph{codifying} audio---encoding high-rate continuous audio waveforms into lower-rate discrete sequences which can be fed in directly to NLP models.
Specifically, Jukebox trains a Transformer~\cite{vaswani2017attention,child2019generating} \emph{language model},
an autoregressive generative model,
on codified audio from $1$M songs.
Purely for convenience, we refer to Jukebox's training procedure as \emph{codified audio language modeling} (CALM).
\begin{figure*}
\centering
\includegraphics[width=0.99\linewidth]{figs/fig1.pdf}
\caption{
Conventional MIR pre-training (\textbf{left}) trains convolutional neural networks on audio spectrograms using manually-annotated labels from tagging datasets.
In contrast, CALM{} MIR pre-training (\textbf{middle}) involves training a language model on codified audio,
which has been previously explored for music generation~\cite{dieleman2018challenge,dhariwal2020jukebox}---here, we propose to use it for discriminative MIR tasks.
To determine if CALM{} pre-training is effective for MIR, we probe for information about particular MIR tasks (\textbf{right}) in resultant representations.
Specifically, we extract features from the learned language model for the audio in small, task-specific labeled datasets, and use these features to train shallow probing models on each task.}
\label{fig:one}
\end{figure*}
While Jukebox already demonstrates that CALM{} is useful for music \emph{generation},
in this work we demonstrate that CALM{} is also useful as a pre-training procedure for \emph{discriminative} MIR tasks.
To this end,
we repurpose Jukebox for MIR by first using it to extract audio feature representations,
and then training shallow models (\emph{probes}~\cite{alain2016understanding,hupkes2018visualisation}) on downstream tasks using these features as input (\Cref{fig:one}).
Relative to representations from models pre-trained with tagging,
we find that representations from Jukebox are $30$\% more effective on average
when used to train probes on four downstream MIR tasks: tagging, genre classification, key detection, and emotion recognition.
We also observe that representations from Jukebox are much more useful for key detection than those from models pre-trained on tagging,
which suggests that CALM{} pre-training may be particularly beneficial for tasks which have little to do with tagging.
This simple setup of training shallow models on representations from Jukebox is even competitive with purpose-built state-of-the-art methods on several tasks.
To facilitate reproducibility and encourage further investigation of these representations and tasks~\cite{mcfee2018open},
we release all of our code for this project,
alongside images for Docker containers which provide full provenance for our experiments.\footnote{
Code: \url{https://github.com/p-lambda/jukemir} \\
Containers: \url{https://hub.docker.com/orgs/jukemir} \\
All experiments reproducible on the CodaLab platform: \\
\url{https://worksheets.codalab.org/worksheets/0x7c5afa6f88bd4ff29fec75035332a583}
}
We note that,
while CALM{} pre-training at the scale of Jukebox requires substantial computational resources,
our post hoc experiments with Jukebox
only require a single commodity GPU with $12$ GB memory.
\section{CALM{} Pre-training}
CALM{} was first proposed by van~den~Oord~et~al.{} and used for unconditional speech generation~\cite{oord2017neural}.
As input, CALM{} takes a collection of raw audio waveforms (and optionally, conditioning metadata),
and learns a distribution $p(\text{audio} \mid \text{metadata})$.
To this end, CALM{} adopts a three-stage approach:
(1)~\emph{codify} a high-rate continuous audio signal into lower-rate discrete codes,
(2)~train a \emph{language model} on the resulting codified audio and optional metadata, i.e., learn $p(\text{codified audio} \mid \text{metadata})$,
and
(3)~decode sequences generated by the language model to raw audio.\footnote{This third stage is not necessary for transfer learning.}
The original paper~\cite{oord2017neural} also proposed a strategy for codifying audio called the vector-quantized variational auto-encoder (VQ-VAE),
and the language model was a WaveNet~\cite{oord2016wavenet}.
Within music,
CALM{} was first used by Dieleman~et~al.{} for unconditional piano music generation~\cite{dieleman2018challenge},
and subsequently,
Dhariwal~et~al.{} used CALM{} to build a music generation system called Jukebox~\cite{dhariwal2020jukebox} with conditioning on genre, artist, and optionally, lyrics.
Despite promising results on music audio generation,
CALM{} has not yet been explored as a pre-training strategy for discriminative MIR.
We suspect that effective music audio generation
necessitates
intermediate representations that would also contain useful information for MIR.
This hypothesis is further motivated by an abundance of previous work in NLP suggesting that generative and self-supervised pre-training can yield powerful representations for discriminative tasks~\cite{peters2018deep,devlin2018bert,radford2019language,liu2021gpt}.
To explore this potential,
we repurpose Jukebox for MIR.
While Jukebox was designed only for generation,
its internal language model was trained on codified audio from a corpus of $1.2$M songs from many genres and artists,
making its representations potentially suitable for a multitude of downstream MIR tasks.
Jukebox consists of two components---the first is
a small~($2$M parameters) VQ-VAE model~\cite{oord2017neural} that learns to codify high-rate~(\SI{44.1}{\kilo\hertz}), continuous audio waveforms into lower-rate~($\sim$\SI{345}{\hertz}), discrete code sequences with a vocabulary size of $2048$ ($11$~bits).
The second component is
a large~($5$B parameters) language model that learns to generate codified audio using a Transformer decoder---an architecture originally designed for modeling natural language~\cite{vaswani2017attention,child2019generating}.
By training on codified audio (as in~\cite{dieleman2018challenge,dhariwal2020jukebox}) instead of raw audio (as in~\cite{oord2016wavenet,child2019generating}),
language models are (empirically) able to learn longer-term structure in music,
while simultaneously using significantly less memory to model the same amount of audio.
Like conventional MIR models which pre-train on tagging and/or metadata,
Jukebox also makes use of genre and artist labels during training,
providing them as conditioning information to allow for increased user control over the music generation process.
Hence, while CALM in general is an unsupervised strategy that does not require labels,
transfer learning from Jukebox specifically should \emph{not} be considered an unsupervised approach (especially for downstream tasks like genre detection).
However,
by modeling the \emph{audio} itself instead of modeling the \emph{labels} (as in conventional MIR pre-training), we hypothesize that Jukebox learns richer representations for MIR tasks than conventional strategies.
\section{Extracting suitable representations from Jukebox}
Here we describe how we extract audio representations from Jukebox which are suitable as input features for training shallow models.
While several pre-trained Jukebox models exist with different sizes and conditioning information,
here we use the $5$B-parameter model without lyrics conditioning (named ``5b''),
which is a sparse transformer~\cite{vaswani2017attention,child2019generating} containing $72$ layers.
Each layer yields $4800$-dimensional activations for each element in the codified audio sequence, i.e., approximately $345$ times per second.
To extract representations from this model for a particular audio waveform, we
(1)~resample the waveform to $44.1$kHz,
(2)~normalize it,
(3)~codify it using the Jukebox VQ-VAE model, and
(4)~input the codified audio into the language model, interpreting its layer-wise activations as representations.
Jukebox was trained on ${\sim}24$-second audio clips (codified audio sequences of length $8192$)---we feed in this same amount of audio at a time when extracting representations.
In addition to the genre and artist conditioning fields mentioned previously,
Jukebox expects two additional fields: total song length and clip offset---to ensure that representations only depend on the input audio,
we simply pass in ``unknown'' for artist and genre, one minute for song length, and zero seconds for clip offset.\footnote{We observed in initial experiments that passing in ground-truth conditioning information had little effect on downstream performance. Hence, we elected to pass in placeholder metadata to maintain the typical type signature for audio feature extraction (audio as the only input).}
\begin{figure}
\centering
\includegraphics[width=0.95\linewidth]{figs/fig2.pdf}
\caption{Normalized validation performance of linear models trained on representations from specific layers of Jukebox across four downstream MIR tasks. On average, the strongest representations for these tasks come from the middle of Jukebox.}
\label{fig:layers}
\end{figure}
The Jukebox language model yields an unwieldy amount of data---for every $24$-second audio clip, it emits $24\times345\times72\times4800$ numbers,
i.e.,
over $10$GB if stored naively as $32$-bit floating point.
We reduce the amount of data by mean pooling across time,
a common strategy in MIR transfer learning~\cite{choi2017transfer,pons2019musicnn},
which aggregates more than $10$GB of activations to around $1$MB ($72\times4800$).
\subsection{Layer selection}\label{sec:layersel}
While pooling across time dramatically reduced the dimensionality of Jukebox's outputs,
training shallow classifiers on $72\times4800$ features is still computationally expensive.
To further reduce the dimensionality,
we use only one of the layers from Jukebox---the middle layer ($36$)---yielding a total of $4800$ features per $24$ second audio clip.
Unlike conventional pre-training,
where the strongest representations for transfer learning typically lie at the end of the model~\cite{zeiler2014visualizing},
the strongest representations from pre-trained language models tend to lie towards the middle of the network~\cite{liu2019linguistic,chen2020generative,chi2020finding,rogers2020primer}.
To confirm this observation in our context,
we trained linear models using representations from different layers of Jukebox on our downstream MIR tasks---average performance indeed peaked at the middle layers~(\Cref{fig:layers}).
In addition to using the middle layer,
we experimented with two other layer selection strategies:
(1)~sub-sampling layers across the network,
and
(2)~selecting relevant layers in a task-specific fashion.\footnote{This procedure selected layers that were the most jointly informative in a greedy fashion, measured by task performance with a linear probe.}
We found that the simplest strategy of using only the middle layer was equally effective and more computationally practical\footnote{While the entirety of Jukebox does \emph{not} fit on a single commodity GPU with $12$GB memory, the first $36$ layers \emph{do} fit.} than the other two layer selection strategies.
\section{Downstream task descriptions}\label{sec:tasks}
\begin{table}[t]
\centering
\begin{tabular}{lccc}
\toprule
Task & Size & Metrics & \#Out \\
\midrule
Tagging~\cite{law2009evaluation} & $25860$ & AUC/AP & 50 \\
Genre classification~\cite{kereliuk2015deep} & $930$ & Accuracy & 10 \\
Key detection~\cite{knees2015two} & $1763$ & Score & 24 \\
Emotion recognition~\cite{soleymani20131000} & $744$ & A/V $R^2$ & 2 \\
\bottomrule
\end{tabular}
\caption{Basic information about the four tasks we consider in this work, including the size of each task-specific dataset in terms of number of labeled examples, relevant metrics for each task, and the number of model outputs required for each dataset.}
\label{tab:tasks}
\end{table}
We select four downstream MIR tasks to constitute a benchmark for comparing different audio feature representations:
(1)~tagging,
(2)~genre classification,
(3)~key detection, and
(4)~emotion recognition.
A summary of the datasets used for each task appears in~\Cref{tab:tasks}.
These tasks were selected to cover a wide range of dataset sizes ($744$ examples for emotion recognition vs. $26$k examples for tagging)
and subjectivity (emotion recognition is more subjective vs. key detection is more objective).
Additionally, each task has an easily-accessible dataset with standard evaluation criteria.
We describe each of these tasks and metrics below.
\subsection{Tagging}
Tagging involves determining which tags from a fixed set of tags apply to a particular song.
Categories of tags include
genre~(e.g.,~jazz),
instrumentation~(e.g.,~violin),
emotions~(e.g.,~happy), and
characteristics~(e.g.,~fast).
There are two large datasets for tagging, which both contain human-annotated tags for $30$-second clips:
MagnaTagATune~\cite{law2009evaluation}~(MTT) which contains around $26$k clips, and
a tagged subset of $240$k clips from the Million Song Dataset~\cite{bertin2011million}~(MSD).
While both datasets contain a large vocabulary of tags,
typical usage involves limiting the vocabulary to the $50$ most common tags in each.
Because it is the largest non-proprietary MIR dataset, MSD is commonly used for pre-training models for transfer learning.
To mitigate an unfair advantage of methods which pre-train on MSD,
we use MTT instead of MSD to benchmark representations on tagging performance.
While both datasets are superficially similar (choosing from $50$ tags for $30$-second clips),
their label distributions are quite different: MSD is skewed towards genre tags, while MTT is skewed towards instrumentation tags.
We use the standard ($12$:$1$:$3$) train, validation, and test split for MTT~\cite{oord2014transfer}.
Additionally, we report both common metrics (both are macro-averaged over tags as is conventional): area under the receiver operating characteristic curve ($\text{MTT}_{\text{AUC}}$), and average precision ($\text{MTT}_{\text{AP}}$).\footnote{Most past work refers to the quantity of average precision as area under the precision-recall curve.}
We note that inconsistencies in handling unlabeled examples for past work on MTT have been observed~\cite{won2020evaluation}---some work discards examples without top-$50$ tags during training, evaluation, or both.
In this work, we do not discard any examples.
\subsection{Genre classification}
Genre classification involves assigning the most appropriate genre from a fixed list for a given song.
For this task, we report accuracy on the GTZAN dataset~\cite{tzanetakis2002musical}, which contains $30$-second clips from $10$ distinct genres.
We adopt the ``fault-filtered'' split from \cite{kereliuk2015deep} which addresses some of the reported issues with this dataset~\cite{sturm2013gtzan}.
We note that this task has a high degree of overlap with tagging, as tagging datasets typically have a number of genres within their tag vocabulary.
In fact, seven of ten genres in GTZAN are present in the tag list of MSD.
\subsection{Key detection}
Key detection involves predicting both the scale and tonic pitch class for the underlying key of a song.
We investigate the Giantsteps-MTG and Giantsteps datasets~\cite{knees2015two} which include songs in major and minor scales for all pitch classes, i.e., a $24$-way classification task.
As in past work~\cite{korzeniowski2017end}, we use the former for training and the latter for testing.
Because no standard validation split exists for Giantsteps-MTG,
we follow~\cite{kereliuk2015deep} and create an artist-stratified $4$:$1$ split for training and validation,
which we include in our codebase for reproducibility.
The music in this dataset is all electronic dance music,
and the clips are two minutes in length.
We report the typical weighted score metric for Giantsteps (GS): an accuracy measure which gives partial credit for reasonable mistakes such as predicting the relative minor key for the major ground truth~\cite{raffel2014mireval}.
\subsection{Emotion recognition}\label{sec:emomusic}
Emotion recognition involves predicting human emotional response to a song.
Data is collected by asking humans to report their emotional response on a two dimensional valence-arousal plane~\cite{huq2010automated},
where valence indicates positive versus negative emotional response, and arousal indicates emotional intensity.
We use the Emomusic dataset~\cite{soleymani20131000},
which contains $744$ clips of $45$ seconds in length.
We investigate the static version of this task where original time-varying annotations are averaged together to constitute a clip-level annotation.
Because this dataset does not have a standard split, it is difficult to directly compare with past work.
To simplify comparison going forward, we created an artist-stratified split of Emomusic, which is released in our codebase.
We take the highest reported numbers from past work to characterize ``state-of-the-art'' performance, though we note that these numbers are not directly comparable to our own due to differing splits.
We report the coefficient of determination between the model predictions and human annotations for arousal~($\text{Emo}_{\text{A}}$) and valence~($\text{Emo}_{\text{V}}$).
\section{Probing experiments}
Here we describe our protocol for probing for information about MIR tasks in representations from Jukebox and other pre-trained models,
i.e.,
measuring performance of shallow models trained on these tasks using different representations as input features.
We borrow the term ``probing'' from analogous investigations in NLP~\cite{hupkes2018visualisation,conneau2018you,hewitt2019structural},
however such methodology is common in transfer learning for MIR~\cite{hamel2013transfer,oord2014transfer,choi2017transfer,park2017representation,lee2019representation,pons2019musicnn,huang2020large,kim2020one}.
\subsection{Descriptions of representations}
\newcommand{\tabreprow}[4]{ #2 & #1 & #4 \\}
\begin{table}[t]
\centering
\begin{tabular}{llc}
\toprule
\tabreprow{Pre-training strategy}{Representation}{Rate}{Dimensions}
\midrule
\tabreprow{N/A}{\rep{Chroma}}{}{$72$}
\tabreprow{N/A}{\rep{MFCC}}{\SI{23.4}{\hertz}}{$120$}
\tabreprow{MSD Tagging~\cite{oord2014transfer}}{\rep{Choi}~\cite{choi2017transfer}}{\SI{0.0345}{\hertz}}{$160$}
\tabreprow{MSD Tagging~\cite{oord2014transfer}}{\rep{MusiCNN}~\cite{pons2019musicnn}}{\SI{62.5}{\hertz}}{$4194$}
\tabreprow{Contrastive~\cite{chen2020simple}}{\rep{CLMR}~\cite{spijkervet2021contrastive}}{\SI{0.373}{\hertz}}{$512$}
\tabreprow{CALM{}~\cite{oord2017neural}}{\rep{Jukebox}~\cite{dhariwal2020jukebox}}{\SI{345}{\hertz}}{$4800$}
\bottomrule
\end{tabular}
\caption{Basic statistics about the six representations we examine in this work.}
\label{tab:representations}
\end{table}
\newcommand{\tabresrow}[8]{ #1 & #3 & #4 & #2 & #7 & #5 & #6 & #8 \\}
\begin{table*}[t]
\centering
\begin{tabular}{lccccccc}
\toprule
& \multicolumn{2}{c}{Tags} & \multicolumn{1}{c}{Genre} & \multicolumn{1}{c}{Key} & \multicolumn{2}{c}{Emotion} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-4} \cmidrule(lr){5-5} \cmidrule(lr){6-7}
\tabresrow{Approach}{GTZAN}{$\text{MTT}_{\text{AUC}}$}{$\text{MTT}_{\text{AP}}$}{$\text{Emo}_{\text{A}}$}{$\text{Emo}_{\text{V}}$}{GS}{Average}
\midrule
\tabresrow{(No pre-training) Probing \rep{Chroma}{}} {$32.8$}{$77.6$}{$18.5$}{$29.3$}{ $5.9$}{$56.5$}{$38.7$}
\tabresrow{(No pre-training) Probing \rep{MFCC}{}} {$44.8$}{$85.8$}{$30.2$}{$47.9$}{$26.5$}{$14.6$}{$38.7$}
\tabresrow{(Tagging) Probing \rep{Choi}{}~\cite{choi2017transfer}} {$75.9$}{$89.7$}{$36.4$}{$67.3$}{$43.4$}{$13.1$}{$51.9$}
\tabresrow{(Tagging) Probing \rep{MusiCNN}{}~\cite{pons2019musicnn}} {$79.0$}{$90.6$}{$38.3$}{$70.3$}{$46.6$}{$12.8$}{$53.7$}
\tabresrow{(Contrastive) Probing \rep{CLMR}{}~\cite{spijkervet2021contrastive}} {$68.6$}{$89.4$}{$36.1$}{$67.8$}{$45.8$}{$14.9$}{$50.8$}
\tabresrow{(CALM) Probing \rep{Jukebox}~\cite{dhariwal2020jukebox}} {$\mathbf{79.7}$}{$\mathbf{91.5}$}{$\mathbf{41.4}$}{$\mathbf{72.1}$}{$\mathbf{61.7}$}{$\mathbf{66.7}$}{$\mathbf{69.9}$}
\midrule
\tabresrow{State-of-the-art~\cite{huang2020large,pons2019musicnn,lee2018samplecnn,weninger2014line,koh2021comparison,pioneer2015rekordbox}}{$\mathbf{82.1}$}{$\mathbf{92.0}$}{$38.4$}{$70.4$*}{$55.6$*}{$\mathbf{79.6}$}{$\mathbf{72.5}$*}
\tabresrow{~~~~Pre-trained~\cite{huang2020large,spijkervet2021contrastive,lee2018samplecnn,koh2021comparison,koh2021comparison,jiang2019mirex}}{$\mathbf{82.1}$}{$\mathbf{92.0}$}{$35.9$}{$67.1$*}{$55.6$*}{$75.8$}{$70.8$*}
\tabresrow{~~~~From scratch~\cite{pons2019musicnn,pons2019musicnn,medhat2017masked,weninger2014line,weninger2014line,korzeniowski2017end}}{$65.8$}{$90.7$}{$38.4$}{$70.4$*}{$50.0$*}{$74.3$}{$66.2$*}
\bottomrule
\end{tabular}
\caption{Comparing performance of probes on representations from a model pre-trained with CALM{} to other pre-trained MIR models (top section) to reported state-of-the-art performance (bottom section) across four tasks:
(1)~tagging ($\text{MTT}_{\text{AUC}}$/$\text{MTT}_{\text{AP}}$),
(2)~genre classification (GTZAN),
(3)~key detection (GS),
and
(4)~emotion recognition ($\text{Emo}_{\text{A}}$/$\text{Emo}_{\text{V}}$).
For all six metrics, the max score is $100$ and higher is better---see \Cref{sec:tasks} for a full description of tasks/metrics.
For each metric, the best probing-based approach and the best approach overall are \textbf{bolded}.
We also report an average score across all four tasks; tasks with multiple evaluation metrics are averaged beforehand.
On all metrics, probing \rep{Jukebox}{} is more effective than probing representations from other pre-trained models.
Probing \rep{Jukebox}{} is competitive with task-specific state-of-the-art approaches for all tasks/metrics except key detection (GS).
Note that the ordering of citations in the bottom section corresponds to respective column ordering.
* indicates that past work on Emomusic evaluates on different subsets of the dataset than our work and hence numbers are not directly comparable---see~\Cref{sec:emomusic} for details.
}
\label{tab:results}
\end{table*}
In addition to probing representations from Jukebox (an exemplar of CALM{} pre-training),
we probe four additional representations which are emblematic of three other MIR pre-training strategies (\Cref{tab:representations}).
Before pre-training, hand-crafted features were commonplace in MIR---as archetypal examples,
we probe
constant-Q chromagrams (\rep{Chroma})
and
Mel-frequency cepstral coefficients (\rep{MFCC}), extracted with librosa~\cite{mcfee2015librosa} using the default settings.
As in~\cite{choi2017transfer}, we concatenate the mean and standard deviation across time of both the features and their first- and second-order discrete differences.
We also probe two examples of the current conventional paradigm which pre-trains on tagging using MSD: a convolutional model proposed by Choi~et~al.{}~\cite{choi2017transfer} (\rep{Choi}), and a more modern convolutional model from~\cite{pons2019musicnn} (\rep{MusiCNN}).
Finally, we compare to a recently-proposed strategy for MIR pre-training called \emph{contrastive learning of musical representations}~\cite{spijkervet2021contrastive} (\rep{CLMR}), though we note that the only available pre-trained model from this work was trained on far less audio (a few thousand songs) than the other pre-trained models (\rep{Choi}{}, \rep{MusiCNN}{}, and \rep{Jukebox}{}).
All of these strategies operate at different frame rates,~i.e.,~they produce a different number of representation vectors for a fixed amount of input audio.
To handle this, we follow common practice of mean pooling representations across time~\cite{choi2017transfer,pons2019musicnn}.
While \rep{Chroma}{}, \rep{MFCC}{}, and \rep{CLMR}{} produce a single canonical representation per frame,
we note that the other three produce multiple representations per frame, i.e., the outputs of individual layers in each model.
For \rep{Choi}, we concatenate all layer representations together, which was shown to have strong performance on all downstream tasks in~\cite{choi2017transfer}.
For \rep{MusiCNN}, we concatenate together the mean and max pool of three-second windows (before mean pooling across these windows), i.e., the default configuration for that approach.
For \rep{Jukebox},
we use the middle layer of the network as motivated in~\Cref{sec:layersel}.
By using a single layer, we also mitigate the potential of a superficial dimensionality advantage for \rep{Jukebox}{}, as this induces a dimensionality similar to that of \rep{MusiCNN}{} ($4800$ and $4194$ respectively; see \Cref{tab:representations}).
Unlike other representations which operate on short context windows,
\rep{Choi}{} and \rep{Jukebox}{} were trained on long windows of $29$ seconds and $24$ seconds of audio respectively.
Accordingly,
for the three datasets with short clips (tagging, genre classification, and emotion recognition all have clips between $30$ and $45$ seconds in length),
we adopt the policy from~\cite{choi2017transfer} and simply truncate the clips to the first window when computing representations for \rep{Choi}{} and \rep{Jukebox}{}.
Because clips from the key detection dataset are much longer (two minutes),
we split the clips into $30$-second windows for all methods and train probes on these shorter windows.
At test time, we ensemble window-level predictions into clip-level predictions before computing the score.
\subsection{Probing protocol}
To probe representations for relevant information about downstream MIR tasks,
we train shallow supervised models (linear models and one-layer MLPs) on each task using these representations as input features.
As some representations may require different hyperparameter configurations for successful training,
we run a grid search over the following hyperparameters ($216$ total configurations)
for each representation and task ($24$ total grid searches),
using early stopping based on task-specific metrics computed on the validation set of each task:
\begin{itemize}[nolistsep]
\item Feature standardization: \{off, on\}
\item Model: \{Linear, one-layer MLP with $512$ hidden units\}
\item Batch size: \{$64$, $256$\}
\item Learning rate: \{$1\mathrm{e}$-$5$, $1\mathrm{e}$-$4$, $1\mathrm{e}$-$3$\}
\item Dropout probability: \{$0.25$, $0.5$, $0.75$\}
\item L$2$ regularization: \{$0$, $1\mathrm{e}$-$4$, $1\mathrm{e}$-$3$\}
\end{itemize}
While we use this same hyperparameter grid for all tasks,
the learning objective varies by task
(cross-entropy for genre classification and key detection,
independent binary cross-entropy per tag for tagging, and
mean squared error for emotion recognition)
as does the number of probe outputs (\Cref{tab:tasks}).
Some tasks have multiple metrics---we early stop on $\text{MTT}_{\text{AUC}}${} for tagging as it is a more common metric than $\text{MTT}_{\text{AP}}${}, and on the average of $\text{Emo}_{\text{A}}${} and $\text{Emo}_{\text{V}}${} for emotion recognition.
We take the model with the best early stopping performance from each grid search and compute its performance on the task-specific test set.
\section{Results and Discussion}
In~\Cref{tab:results}, we report performance of all representations on all tasks and metrics, as well as average performance across all tasks.
Results are indicative that CALM{} is a promising paradigm for MIR pre-training.
Specifically, we observe that probing the representations from \rep{Jukebox}{} (learned through CALM{} pre-training) achieves an average of $69.9$,
which is $30$\% higher relative to the average of the best representation pre-trained with tagging (\rep{MusiCNN}{} achieves an average of $53.7$).
Performance of \rep{Jukebox}{} on all individual metrics is also higher than that of any other representation.
Additionally, \rep{Jukebox}{} achieves an average performance that is $38$\% higher than that of \rep{CLMR}{}.
Representations from all pre-trained models outperform hand-crafted features (\rep{Chroma}{} and \rep{MFCC}) on average.
Note that these results are holistic comparisons across different model architectures, model sizes, and amounts of pre-training data (e.g.,~\rep{CLMR}{} was trained on far less data than \rep{Jukebox}{}), and hence not sufficient evidence to claim that CALM{} is the ``best'' music pre-training strategy in general.
We also observe that \rep{Jukebox}{} contains substantially more information relevant for key detection than other representations.
While \rep{Chroma}{} (spectrogram projected onto musical pitch classes) contains information relevant to key detection by design,
all other representations besides \rep{Jukebox}{} yield performance on par with that of a majority classifier (outputting ``F minor'' for every example scores $15.0$)---hence, these representations contain almost no information about this task.
For models pre-trained with tagging (\rep{Choi}{} and \rep{MusiCNN}{}),
intuition suggests that this is because
none of the tags in MSD relate to key signature.
For \rep{CLMR}{},
we speculate that the use of transposition as a data augmentation strategy
also results in a model that contains little useful information about key signature.
While tagging and CLMR were not designed with the intention of supporting transfer to key detection, we argue that it is generally desirable to have a unified music representation which performs well on a multitude of downstream MIR tasks.
Hence, we interpret the comparatively stronger performance of \rep{Jukebox}{} on key detection as evidence that CALM{} pre-training addresses blind spots present in other MIR pre-training paradigms.
In the bottom section of~\Cref{tab:results}, we also report state-of-the-art performance for purpose-built methods on all tasks, which is further broken down by models which use any form of pre-training (including pre-training on additional task-specific data as in~\cite{jiang2019mirex}) vs. ones that are trained from scratch.
Surprisingly,
we observe that probing \rep{Jukebox}{} is competitive with state-of-the-art for all tasks except for key detection,
and achieves an average only $4$\% lower relative to that of state-of-the-art.
On tagging, probing \rep{Jukebox}{} achieves similar $\text{MTT}_{\text{AUC}}${} to a strategy which pre-trains on a proprietary dataset of $10$M songs using supervision~\cite{huang2020large}.
We interpret the strong performance of this simple probing setup as evidence that CALM{} pre-training is a promising path towards models that are useful for many MIR tasks.
We believe that CALM{} pre-training is promising for MIR not just because of the strong performance of an existing pre-trained model (Jukebox),
but also because there are numerous avenues which may yield further improvements for those
with the data and computational resources to explore them.
Firstly,
CALM{} could be scaled up to pre-train even larger models on more data (Jukebox was trained on $1$M songs, while Spotify has an estimated $70$M songs in its catalog).
In~\cite{kaplan2020scaling}, it is observed that increasing model and dataset size yields predictable improvements to cross-entropy for language modeling in NLP,
an insight which may also hold for CALM{} pre-training for MIR.
Secondly,
we anticipate that fine-tuning a model pre-trained with CALM{} would outperform our probing setup.
Finally,
taking a cue from related findings in NLP,
we speculate that CALM{} pre-training with a bidirectional model and masked language modeling (as in BERT~\cite{devlin2018bert}) would outperform the generative setup of Jukebox (that of GPT~\cite{radford2018improving}).
\section{Related Work}
Transfer learning
has been an active area of study in MIR for over a decade.
An early effort seeking to replace hand-crafted features used neural networks to automatically extract context-independent features from unlabeled audio~\cite{hamel2010learning} and used those features for a supervised learning task.
Other early efforts focused on learning shared embedding spaces between audio and metadata~\cite{weston2011multi,hamel2013transfer} or directly using outputs from pre-trained tagging models for music similarity judgements~\cite{seyerlehner2012improved}.
The predominant strategy for MIR pre-training using large tagging datasets was first proposed by van~den~Oord~et~al.~2014~\cite{oord2014transfer}.
This work pre-trained deep neural networks on MSD and demonstrated promising performance on other tagging and genre classification tasks.
Choi~et~al.~2017~\cite{choi2017transfer} pre-trained on MSD but using a convolutional neural network and also explored a more diverse array of downstream tasks---we use their pre-trained model as one of our baselines.
More recent improvements use the same approach with different architectures~\cite{lee2018samplecnn,pons2019musicnn}, the latest of which is another one of our baselines.
Other strategies for MIR transfer learning have been proposed.
Some work pre-trains on music metadata (e.g., artist, album) instead of tags~\cite{park2017representation,lee2019representation}.
In contrast to the manual annotations required for tagging-based pre-training, metadata is much cheaper to obtain, but performance of pre-training on metadata is comparable to that of pre-training on tagging.
Kim~et~al.~2020~\cite{kim2020one} improve over Choi~et~al.~2017~\cite{choi2017transfer} using a multi-task approach that pre-trains on both tags and metadata.
Huang~et~al.~\cite{huang2020large} demonstrate that metadata can be combined with proprietary co-listening data for pre-training on $10$M songs to achieve state-of-the-art performance on MTT---probing representations from CALM{} pre-training on $1$M songs achieves comparable performance on MTT (\Cref{tab:results}).
Finally, contrastive learning~\cite{chen2020simple} has been proposed as a strategy for MIR pre-training~\cite{favory2020learning,ferraro2021enriched,spijkervet2021contrastive}---we compare to such a model from Spijkervet~and~Burgoyne~2021~\cite{spijkervet2021contrastive}.
While CALM{} has not previously been explored for MIR transfer learning, it has been explored for other purposes.
van~den~Oord~et~al.~2017~\cite{oord2017neural} first proposed CALM{} and used it for unconditional speech generation.
Variations of CALM{}
have been used as pre-training for speech recognition~\cite{baevski2019effectiveness,baevski2020wav2vec} and urban sound classification~\cite{verma2020framework}.
CALM{} has also been explored for music generation~\cite{dieleman2018challenge,dhariwal2020jukebox}.
CALM{} is related to past work on language modeling of raw (i.e.,~not codified) waveforms~\cite{oord2016wavenet,mehri2016samplernn,kalchbrenner2018efficient},
which tends to be less effective for capturing long-term dependencies compared to modeling codified audio.
Language models have also been used extensively for modeling symbolic music~\cite{eck2002finding,simon2017performance,huang2018music},
including some work on pre-training on large corpora of scores for transfer learning~\cite{donahue2019lakhnes,hung2019improving}.
\section{Conclusion}
In this work we demonstrated that CALM{} is a promising pre-training strategy for MIR.
Compared to conventional approaches, CALM{} learns richer representations by modeling audio instead of labels.
Moreover, CALM{} allows MIR researchers to repurpose NLP methodology---historically, repurposing methodology from another field (computer vision) has provided considerable leverage for MIR.
Finally, CALM{} suggests a direction for MIR research where enormous models pre-trained on large music catalogs break new ground on MIR tasks,
analogous to ongoing paradigm shifts in other areas of machine learning.
\section{Acknowledgements}
We would like to thank
Nelson~Liu,
Mina~Lee,
John~Hewitt,
Janne~Spijkervet,
Minz~Won,
Jordi~Pons,
Ethan~Chi,
Michael~Xie,
Ananya~Kumar,
and
Glen~Husman
for helpful conversations about this work.
We also thank all reviewers for their helpful feedback.
| {'timestamp': '2021-07-14T02:01:36', 'yymm': '2107', 'arxiv_id': '2107.05677', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05677'} | arxiv |
\section{Introduction}
Vision is an important sensory modality for humans. Many activities of daily living (ADLs), such as cooking and eating, can be difficult without visual support. Jones et al. \cite{jones2019analysis} revealed that people with visual impairments tend to have poor nutritional status, which is often linked to problems with buying, preparing, and eating healthy food. People with visual impairments may have an aversion to cooking due to difficulty accessing visual information and cues during the cooking process \cite{bilyk2009food,kostyra2017food}. This has resulted in people with visual impairments more frequently eating outside at restaurants or preparing frozen food that may be calorie-rich. According to the aforementioned Canadian study \cite{bilyk2009food}, eight out of nine participants stated they “disliked or hated cooking” because of the time it takes to cook without vision.
Christine Ha, the first blind contestant of MasterChef, won the third season of the show in 2012 and described the importance of cooking to people with visual impairments \cite{Christin65:online,TheBlind26:online}. To assist visually impaired individuals to cook independently, there have also been training guidelines released from blind communities \cite{SafeCook91:online} and cooking related assistive technologies that are commercially available \cite{HowDoesa82:online}. For example, people with visual impairments could use voice commands to set timers or use a speaking kitchen thermometer to check the temperature of a steak. However, little research has explored the practices of people with visual impairments in cooking and how they leverage different assistive devices for cooking. Furthermore, there has been little to guide HCI researchers on what stages or steps in the cooking process may benefit most from support via technology. In our research, we explore the following research questions:
\begin{itemize}
\item RQ1: What are current cooking approaches and techniques employed by people with visual impairments?
\item RQ2: What are the key challenges, concerns, and risks encountered while preparing meals?
\item RQ3: What are potential opportunities for assistive technologies to support people with visual impairments to cook independently?
\end{itemize}
To first understand the current cooking experiences of people with visual impairments (RQ1), we conducted a content analysis of 122 YouTube videos that feature visually impaired individuals preparing meals. We describe 12 different activities essential to cooking that were summarized from the video analysis. Based on the findings from the video analysis, we then conducted semi-structured interviews with 12 visually impaired people who have experience cooking to better understand RQ2 and RQ3. The interview findings further illuminate challenges encountered before, during, and after cooking including: utilizing tools, information access, touching and feeling, safety and consequence, precision and ambiguity, organizing and tracking, item and quality inspection, and collaborative cooking and communication. We then discuss the potential opportunities to support people with visual impairments while cooking (e.g., zero-touch interactions for cooking, status tracking and safety monitoring, and collaborative cooking).
\section{Background and Related Work}
\subsection{Eating and Cooking for People with Visual Impairments}
People with visual impairments' Activities of Daily Living (e.g., eating and mobility) and Instrumental Activities of Daily Living (e.g., preparing and making food) are affected by the loss of vision \cite{bhowmick2017insight}. Jones et al. \cite{jones2019analysis} conducted a survey study with 101 visually impaired people and found 65\% of the participants stated that their visual impairments made cooking difficult. Due to the difficulty of cooking, Bilyk et al. \cite{bilyk2009food} found that people with visual impairments tend to eat outside or prepared food, which affects healthy eating behaviors. To enable efficient preparation of meals, Kostyra et al. \cite{kostyra2017food} further showed that assistive technologies, such as having equipment with a voice editor, devices informing about the cooking process, and sensors supporting pouring fluids, may enable efficient preparation of meals for people with visual impairments. Therefore, it is important to explore existing cooking practices and challenges for people with visual impairments and understand specific cooking processes or steps that certain assistive technologies may help people with visual impairments in cooking.
\subsection{Enabling Technology for People with Visual Impairments}
Cooking usually requires people with visual impairments to interact with different interfaces or devices. The traditional way to enable people with visual impairments to interact with electronic appliances is by adding tactile markers to them. Beyond this traditional method, prior research also explored using computer vision \cite{guo2016vizlens,fusco2014using,morris2006clearspeech,tekin2011real}, voice interactions \cite{abdolrahmani2018siri,branham2019reading}, and 3D printed tactile marking \cite{guo2017facade,he2017tactile} to better support people with visual impairments interacting with different interfaces. For example, VizLens leveraged computer vision and crowdsourcing to enable people with visual impairments to interact with different interfaces, such as a microwave oven \cite{guo2016vizlens}. Guo et al. \cite{guo2017facade} further introduced a crowdsourced fabrication pipeline to help blind people independently make physical interfaces accessible through adding a 3D printed augmentation of tactile buttons overlaying the original panel.
Beyond making appliance interfaces accessible, prior research has also explored various approaches to improve the accessibility of mobile devices for people with visual impairments which might help with the cooking process, such as gestural interactions (e.g., \cite{kane2008slide,azenkot2012passchords,li2017braillesketch}) and screen readers (e.g., \cite{rodrigues2015getting,Accessib51:online,leporini2012interacting,Getstart6:online}). For example, Talkback \cite{Getstart6:online}, and VoiceOver \cite{Accessib51:online} enable people with visual impairments to explore interface elements on mobile devices through audio feedback. The feasibility of using mobile devices further allows people with visual impairments to interact with other IoT devices \cite{zhou2017iot,saquib2017blindar}. However, it is unknown how people with visual impairments tend to interact with mobile devices during cooking or utilize their mobile devices to interact with different kitchen appliances, and associated challenges and barriers.
\subsection{Technology for Cooking}
In terms of cooking processes, there has been prior research that explored learning procedures of cooking \cite{kato2013interactive} and different cooking techniques \cite{kusu2017calculating,hamada2005cooking}. For example, Kato and Hasegawa \cite{kato2013interactive} introduced an interactive sauteed cooking simulator that could visualize different cooking states (e.g., temperature changes, browning from burns). This system could help users to better manage their cooking skills, such as how to cook medium-rare meat \cite{kato2013interactive}. Kusu et al. \cite{kusu2017calculating} further proposed a method to calculate a cooking recipe's difficulty level during searching and recommend recipes that match the user's cooking skills. Although prior research has explored how to help people with cooking activities, there lacks research and understanding of what cooking-related learning procedures people with visual impairments have adopted and what the existing challenges are during these learning processes. In our work, we showed cooking practices of 12 different cooking procedures through a YouTube video analysis and uncovered eight themes of cooking challenges through interviews with people with visual impairments.
\section{YouTube Video Analysis: Cooking Practices for People with Visual Impairments}
To understand existing cooking practices and potential risks for people with visual impairments, we conducted a YouTube video analysis---searching, filtering, and analyzing YouTube videos related to cooking practices by people with visual impairments---inspired by prior research on leveraging the richness of YouTube video contents to understand accessibility needs \cite{anthony2013analyzing}. Our video analysis consisted of two main steps: 1) searching for YouTube videos related to cooking practices for people with visual impairments; 2) analysis and coding procedures.
\begin{table}[ht]
\caption{Searching Keywords}
\centering
\begin{tabular}{|p{8cm}|}
\hline
\textbf{Searching Keywords} \\
\hline
Blind Cooking, Blind Person Cooking, Blind Chef, Legally Blind Cooking, Blind Cooking Food, Blind Cooking Dinner, Blind in the Kitchen, Visually Impaired Cooking, Visually Impaired Person Cooking, Visually Impaired Chef, Visual Impairment Cooking\\
\hline
\end{tabular}
\label{table:searchterms}
\end{table}
\subsection{Search Protocol}
In the video searching process, we looked for videos focused on cooking practices for people with visual impairments. To search for relevant videos, three researchers independently combined visual impairment related keywords (e.g., blind, visually impaired, visual impairment) and cooking related keywords (e.g., cook, cooking, chef, kitchen). To come up with these, our researchers first started with basic searches (e.g., blind cooking) and gradually included other keyword combinations from candidate video titles or descriptions. Because each search may generate hundreds of results, we then followed the same approach as Komkaite et al. \cite{komkaite2019underneath} by stopping our search for videos after the whole page of results started to be irrelevant.
In total, we initially created a video dataset of 136 relevant videos found by March 28th, 2021. We then filtered out videos if: 1) the person who cooked in the video did not have visual impairments; 2) the person only heated frozen food; 3) it has poor audio and video quality or did not show the person cooking; 4) videos were duplicated. We then ended up filtering 14 videos and created the final video dataset of 122 videos (V1 - V122). Among the 122 videos in our dataset, most videos were uploaded in 2020 (35), while others were uploaded in 2021 (34), 2019 (11), 2018 (10), 2013 (9), 2014 (7), 2017 (6), 2016 (5), 2015 (3), and 2012 (2). The average length of videos was 698 seconds (ranging from 77 seconds to 2694 seconds).
\subsection{Video Content Analysis}
To code the videos, three researchers first open-coded \cite{charmaz2006constructing} the videos independently. Then, the coders met and discussed their codes. When there was a conflict, they explained their rationale for their code to each other and discussed to find a resolution. Eventually, they reached a consensus and consolidated the list of codes. Afterward, we performed affinity diagramming \cite{hartson2012ux} to group the codes and identify emerging themes according to the Cooking Guidelines for people with visual impairments \cite{SafeCook91:online}. Overall, we established 12 themes and 37 codes. The following section describes the findings based on the 12 themes.
\begin{table}[ht]
\small
\caption{Cooking activities from YouTube video analysis for people with visual impairments.}
\centering
\begin{tabular}{|p{2.5cm}|p{4cm}|}
\hline
Category & Activities\\ [0.5ex]
\hline
\multirow{5}{*}{Preparation} & General Safe Cooking Practices\\\cline{2-2}
& Cutting and Chopping\\\cline{2-2}
& Measuring\\\cline{2-2}
& Spreading\\\cline{2-2}
& Pouring\\\hline
\multirow{4}{*}{Cooking} & Placing Pans on a Burner\\\cline{2-2}
& Baking\\\cline{2-2}
& Turning Food\\\cline{2-2}
& Testing Food for Doneness\\\hline
\multirow{3}{2cm}{Tools, Environment, and Recognition} & Tools and Small Appliances\\\cline{2-2}
& Knowing the Kitchen Space\\\cline{2-2}
& Tell Things Apart
\\[0.5ex]
\hline
\end{tabular}
\label{table:cookingprocedure}
\end{table}
\subsection{Results: Cooking Practices of People with Visual Impairments}
From the YouTube video analysis, we uncovered unique cooking practices and procedures of different people with visual impairments (Table \ref{table:cookingprocedure}).
\subsubsection{General Safe Cooking Practices}
\label{General Safe Cooking Practices}
For general safe cooking tips and practices, we found that people with visual impairments usually \textbf{start everything with gentle actions}. This includes using a slow cooker rather than an open grill to avoid fire flare ups (V18), always cooking on low to medium heat to avoid injury (V80), and putting all food and ingredients in a cold pan first before putting the pan on the burner (V4, V6). In V80, the person with visual impairments mentioned in his video:
\begin{quote}
``...For people with visual impairments like me, we might have to make different adjustments on the pan with our hands or utensils while cooking, I often start with using my hand to feel the temperature and cook at low to medium temperature on my pan...''
\end{quote}
Beyond starting with gentle actions, we found that people with visual impairments tend to \textbf{use hearing and hand-feeling to compensate for vision needs during cooking}. In terms of leveraging hands for feeling during cooking, we found that people with visual impairments hold their hands over the pan to gauge temperature (e.g., V11, V23) and use hands to guide food onto utensils (V15). For hearing, we found that people with visual impairments leveraged sound to tell if oil is hot or not (V90, V94). For example, one cook with visual impairments put a small droplet of water into a pan of oil to hear if it was hot (V90). Furthermore, we found that it is important for people with visual impairments to \textbf{memorize the environment in the kitchen}, including the kitchen layout (V1, V17, V46) and which knobs correspond to which burner on the stove (V9).
\begin{figure}[h]
\centering
\includegraphics[width=1\columnwidth]{cutGroup.png}
\caption{Different ways of cutting. (a) Cutting with a vegetable chopper. (b) Cutting practice of putting the whole hand on top of the knife to cut garlic. (c) Tucking the fingertips under and in towards the palm of the hand and cut with the other hand. (d) Having fingers on both sides of the knife to position where to cut.}~\label{fig:cutting}
\Description{}
\end{figure}
\subsubsection{Cutting and Chopping}
\label{Cutting and Chopping}
For cutting and chopping, we learned that many people with visual impairments tried \textbf{using alternate ways to avoid knives}, such as using a garlic masher, a vegetable chopper (Fig. \ref{fig:cutting}(a)), a food processor (e.g., V103, V114), scissors (e.g., V84, V94), or even by buying pre-minced garlic (V9, V13). Moreover, we found that people with visual impairments \textbf{sort cut and uncut food into different specific locations on the cutting surface} (V1, V32). In V1, the person commented on her practices in the video: \textit{``For me, I always place the cut food at the top right corner of my cutting board, so I can keep track of the food that I still need to cut.''} We also found that people with visual impairments have \textbf{different practices of using the knife to cut objects}. For example, we found people perform cutting by 1) having fingers on both sides of the knife to position where to cut (e.g., V23, V28) (Fig. \ref{fig:cutting}(d)), 2) putting the whole hand on top of the knife (e.g., V20, V27) (Fig. \ref{fig:cutting}(b)), or 3) tucking the fingertips under and in towards the palm of the hand and cutting with the other hand (e.g., V16, V112) (Fig. \ref{fig:cutting}(c)).
\subsubsection{Measuring}
\label{Measuring}
To measure food, we first found that there is a common practice for people with visual impairments to \textbf{use hands to weigh meat and measure spices} (e.g., V12, V35). We further revealed that people with visual impairments highly \textbf{rely on using measuring cups with hand assistance to measure liquids} (Fig. \ref{fig:measure}). To accurately use measuring cups, people with visual impairments either have to memorize the measurements (V51) or use a braille-labeled set (V10). Finally, visually impaired cooks also \textbf{prefer using existing containers or utensils to measure food}, such as using the same can to get a 1:1 ratio of water and soup (V89) and using the broad side of a knife to measure the size of meat (V96).
\begin{figure}[h]
\centering
\includegraphics[width=0.6\columnwidth]{measure.png}
\caption{Using the hand to direct the oil and measuring cup to measure liquid (V17).}~\label{fig:measure}
\Description{}
\end{figure}
\subsubsection{Pouring}
\label{Pouring}
For pouring, we found that people with visual impairments \textbf{use an extra-large bowl to reduce the difficulty of pouring} (V53, V56) and usually pour over the sink to make sure spills do not matter (V10, V26). To know how much people are pouring, we revealed that people tend to \textbf{use their finger over the spout and/or in containers to know the exact amount} (e.g., V16, V21). Another common practice we discovered is \textbf{\textit{``making sure you poured everything''} to ensure all of the ingredients they want are added to their dish}. More specifically, we found that people first \textbf{add water to food processor or bowl to get any leftover ingredients} (V35) and then \textbf{wipe bowls with fingers to make sure they are empty after pouring} (e.g., V30, V59).
\subsubsection{Placing Pans on a Burner}
\label{Placing Pans on a Burner}
From the video analysis, we recognized that people with visual impairments \textbf{prefer using traditional electric stove top than modern glass top or gas top}. The key reason was the ease of placing pans on the stove top. As a practice, we found that people with visual impairments tend to either \textbf{use listening or feeling to know whether the pan is on the burner}. For example, V19 showed that visually impaired individuals listen to sizzle to tell whether the pan is on the burner or not after turning on the fire (V19). As another option, we found people either use hand to feel to make sure the pan is at the center of the stove top (V96) or use the back of a spatula to feel if the pan is on the burner (V19).
\subsubsection{Baking}
\label{Baking}
In baking, we found that visually impaired people have to \textbf{use their hands to feel batter texture, check the batter readiness, and shape dough} (V41, V88). Specifically, we found that visually impaired cooks prefer to fold the dough over parchment paper (V92), use their hands to shape the dough (V121), and create barriers when rolling it out (V82). Furthermore, we revealed \textbf{the importance of keeping things clean during baking}. For example, V29 mentioned the importance of wiping edges of the pan before baking to prevent the burning of anything that accidentally got on the edges. Finally, we found people with visual impairments \textbf{use caution with the oven when baking}, such as by pulling the oven shelf out slightly to avoid burns (V40).
\begin{figure}[h]
\centering
\includegraphics[width=0.6\columnwidth]{turning.png}
\caption{The person uses one hand to feel the food location and another to turn the food with a spatula}~\label{fig:turning}
\Description{}
\end{figure}
\subsubsection{Turning Food}
\label{Turning Food}
For turning food, we learned that people with visual impairments \textbf{have different preferences on choosing tools} to accomplish the task. This includes using a large two-prong fork (V55), using two utensils (V83), and using tongs and spatulas for (V33, V78). While turning food, people with visual impairments have different practices of \textbf{keeping track of food locations}. For example, V22 showed that the person always memorizes how much food she put on the grill and roughly where it is. V16 further showed that people with visual impairments use one hand to feel for food locations and then use the other hand to turn the food with a spatula (Fig. \ref{fig:turning}).
\subsubsection{Spreading}
\label{Spreading}
From the video analysis, we uncovered that \textbf{using hands to spread} butter or jam is a common practice for people with visual impairments to make sure everything is evenly distributed (e.g., V43, V63). V88 further showed the practices of using single-use plastic gloves for spreading. Beyond using hands, V45 showed the approach of \textbf{using utensils to spread} jam evenly on bread.
\subsubsection{Tools and Small Appliances}
\label{Tools and Small Appliances}
In terms of tools and small appliances for cooking, we found that visually impaired individuals often \textbf{use a virtual assistant to set timers}. This includes using Siri (e.g., V9, V13), Alexa (V1), Google (V4), and analog timers (V44). In V44, the visually impaired person rotated the analog timer using her hand position to gauge the correct time. Furthermore, we uncovered that \textbf{speaking tools are widely used for different purposes}, such as using a barcode reader to know what is in a can (V5), Aira \cite{HomeAira36:online} for identifying cans, screen readers to read recipes off of a phone (V29), video magnifiers to read boxes (V17), talking scales (V41) and speaking thermometers (e.g., V42, V115). We further found that people with visual impairments tend to \textbf{use a lot of specific tools for specific tasks}. For instance, V36 showed that the cook used an automatic can opener and listened for when it was done. Other examples include using a tea strainer to rinse off rice (V84) and spatula and chopsticks for mixing (V95).
\subsubsection{Testing Food for Doneness}
\label{Testing Food for Doneness}
To test whether the food is done, we found that people with visual impairments mostly use five different methods. First, they \textbf{feel to check food doneness}, such as feeling food texture with a spoon (e.g., V9, V86), feeling for fried food to float to the top with a utensil (V90), and feeling cooking food with hands (e.g., V16, V39). We also learned that visually impaired people \textbf{used measures for checking doneness}. For example, they initiated a timer (e.g., V19, V54) or used a thermometer to check whether the food is done (V19, V121). Moreover, we found people with visual impairments also \textbf{used listening to tell when food sounds done} (e.g., V11, V34) and \textbf{use smell to check for food doneness} (e.g., V67, V100). For example, V84 mentioned that visually impaired people could use sound to know whether water is boiling. Finally, we found that people who learned cooking before losing their vision \textbf{judge food doneness on their intuition and prior memories from when they were sighted} (V91).
\subsubsection{Knowing the Kitchen Space}
\label{Knowing the Kitchen Space}
From the YouTube video analysis, we discovered that people with visual impairments put a lot of effort to \textbf{organize the kitchen space to reduce cooking barriers}, such as having separate space for cooking and for ingredients (V10), keeping the container of utensils handle side down so they can feel the ends (V25), keeping measuring cups nested (V28) and always placing utensils back to their original places (V3). Furthermore, we realized visually impaired individuals have different practices to \textbf{feel the kitchen space}. For example, V22 showed that people use a spatula to feel around a hot grill to get to know the space.
\subsubsection{Tell Things Apart}
\label{Tell Things Apart}
To tell ingredients or tools apart, we found a common practice for people with visual impairments is \textbf{adding labels on buttons or objects}. For instance, visually impaired individuals add Braille labels on spice jars (V27, V47) or bump dot stickers for recognizing buttons (V50). Another approach to tell things apart is by \textbf{recognizing the size or shape of containers}. For example, the person from V72 put each ingredient in a different type of bowls to keep track of different ingredients. Furthermore, people also \textbf{rely on smell to tell things apart}, such as smelling to tell the differences between spices (V35, V65). Finally, we found that some people with visual impairments \textbf{prefer putting their containers in certain orders}. For example, some people prefer to alphabetically organize spices in their drawers (V50).
\section{Interview Study: Challenges of Cooking for People with Visual Impairments}
In the YouTube video analysis, we uncovered existing practices for people with visual impairments in different cooking procedures. We then leveraged these findings and conducted semi-structured interviews with visually impaired people who have experience cooking to better understand their existing cooking challenges.
\begin{table}[ht]
\small
\caption{Participants' demographic information}
\centering
\begin{tabular}{|p{1.3cm}|p{0.4cm}|p{2cm}|p{4.5cm}|p{3cm}|}
\hline
Participant & Age & Gender & Vision Impairment Description & Learned Cooking \textit{Before or After} Vision Loss\\ [0.5ex]
\hline
P1 & 25 & Male & Totally Blind, Congenital & After\\
\hline
P2 & 33 & Male & Legally Blind, Congenital & After\\
\hline
P3 & 32 & Non-binary & Legally Blind, Congenital & After\\
\hline
P4 & 19 & Male & Totally Blind, Congenital & After\\
\hline
P5 & 36 & Male & Totally Blind, Acquired (7 years) & Before\\
\hline
P6 & 24 & Female & Legally Blind, Congenital & After\\
\hline
P7 & 22 & Male & Totally Blind, Congenital & After\\
\hline
P8 & 35 & Male & Legally Blind, Acquired (1 year) & Before\\
\hline
P9 & 28 & Female & Totally Blind, Congenital & After\\
\hline
P10 & 31 & Female & Legally Blind, Congenital & After\\
\hline
P11 & 55 & Male & Legally Blind, Congenital & After\\
\hline
P12 & 48 & Female & Legally Blind, Congenital & After \\[0.5ex]
\hline
\end{tabular}
\label{table:demographic}
\end{table}
\subsection{Method: Semi-structured Interview with People with Visual Impairments}
To understand perceptions and challenges of cooking for people with visual impairments, we conducted semi-structured interviews with 12 visually impaired people who have experience cooking (Table \ref{table:demographic}). Our participants have an average age of 32, with a range from 19 to 55 years old. Five of them are totally blind, and the rest are legally blind. Furthermore, ten of our participants are congenitally blind and learned cooking after the vision loss, and the other two cooked before losing their vision. Participants were recruited through social platforms (e.g., Reddit, Twitter, Facebook). To participate in our interview, participants needed to 1) be 18 or above; 2) have visual impairments; 3) have experience cooking; 4) be able to communicate in English. The interviews were conducted through Zoom and took around 60 - 75 minutes for each participant. Participants who completed the interview were compensated by a \$20 Amazon gift card. The entire recruitment and study procedure was approved by the institutional review board (IRB).
In the interview, we first asked participants about their demographic information, general reasoning and perceptions about cooking, and any barriers they encountered when they started cooking. Based on our findings of different cooking procedures and practices in the YouTube video analysis, we asked our participants to discuss their perceptions and challenges around different cooking procedures, such as measuring, pouring, and cutting and chopping. Afterward, we asked participants to discuss their experiences and challenges with assistive cooking technologies, cooking with other people, and the modification of kitchen appliances for accessibility purposes.
Two researchers independently performed open-coding \cite{charmaz2006constructing} on the interview transcripts. Then, the coders met and discussed their codes. When there was a conflict, they explained their rationale for their code to each other and discussed to resolve the conflict. Eventually, they reached a consensus and consolidated the list of codes. Afterward, they performed affinity diagramming \cite{hartson2012ux} to group the codes and identify emerging themes. Overall, we established eight themes and 26 codes. The results introduced in the findings are organized based on eight themes.
\subsection{Findings}
In this section, we introduce the challenges of cooking derived from our interviews in eight themes: utilizing tools, information access, touching and feeling, safety and consequences, precision and ambiguity, organizing and tracking, item and quality inspection, and collaborative cooking and communication.
\subsubsection{Utilizing Tools}
\label{Utilizing Tools}
From the interviews, we found that people with visual impairments encountered various challenges when utilizing tools (e.g., cooking utensils, appliances). In the video analysis, we found that people with visual impairments rely on either braille markers or bump dots to interact with an interface (Section \ref{Tell Things Apart}). In the interview, seven participants commented on the concerns of \textbf{messing up tools with dirty hands and food during cooking}. For example, P1 commented on the problems of messing up braille tactile markers on kitchen appliances:
\begin{quote}
``...It is very common that I might accidentally have something on my hand, especially when I make a dough, then when I touch my Braille markers or bump dots, it just stays on the marker and affects me when I want to read the markers...''
\end{quote}
From the video analysis, we learned that people with visual impairments usually utilize many tools for different purposes (Section \ref{Tools and Small Appliances}). In the interview, we found that eight of our participants \textbf{struggled with having too many tools for different purposes than are necessary}. For example, P12 mentioned that she had to use a vegetable holder on one hand to hold the vegetable and use another hand to peel it. P4 further commented on his situation of even using syringes for cooking:
\begin{quote}
``...I have too many tools or cookware for different purposes. I even used syringes to measure and add soy sauce to my dishes. But having too many things really freak me out, it made me look for things all the time...''
\end{quote}
During the interview, five participants mentioned that \textbf{existing tools lack confirmation and feedback}, especially for our participants who learned cooking before vision loss and were used to leverage vision for confirmation and feedback. For example, P8 mentioned the challenges of just using his spatula to tell where food is and whether the food is done:
\begin{quote}
``...Feel through tools is hard, I cannot just use my spatula to do everything for me, it is really hard for me to use it to tell if the food is ready by using tools to feel the texture. That is why I said feel is difficult without hand, that is why we need more help with adding more sensors at the head of tools to tell me different status, and it can also accomplish basic needs...''
\end{quote}
\subsubsection{Information Access}
\label{Information Access}
In the interview, participants overall complained about information access problems with kitchen appliances' guides and recipes. First, three participants mentioned the \textbf{lack of details for guide manuals and instructions of kitchen appliances}. For example, P11 commented on the need for more vocal descriptions about the interface layout:
\begin{quote}
``...I cannot understand existing manuals and instructions for kitchen appliances like pressure cookers, it definitely needs more vocal descriptions about the position of different parts and the interface layout. Especially that the current pressure cookers or rice cookers have so many buttons...''
\end{quote}
Beyond the manuals, we found our participants complained that \textbf{recipe content does not correspond to how people with visual impairments cook}. This includes cookbooks that have too many pictures (P9), wording or cooking language varying among different recipes which confused visually impaired cooks (P7), online recipes containing many figures and ads (P1, P3), and the way current recipes explain different steps requiring lots of vision support (P8). P8 continued with his experiences with recipes like a guessing game:
\begin{quote}
``...The descriptions in many recipes are very hard to correspond to the ways that I cook now. I was reading a recipe, and it told me to cook the piece of chicken until it turns brown and then flip it over. It does not transfer to people with visual impairments, it is like a guessing game...''
\end{quote}
Furthermore, we realized that \textbf{existing recipe structures are not friendly to people with visual impairments}. Participants commented that different recipes they found online tend to have different recipe structures, such as the cook's notes, nutrition facts, ingredients and cooking steps. As a consequence, our participants complained that they always have to go back to check the recipe (P1) and do not know where to start the recipe (P1, P3). P6 then further talked about her frustration of starting over from the beginning of the recipe because of the non-standardized recipe structure:
\begin{quote}
``...I use voiceover for apple devices, it typically read the whole recipe. However, many recipes do not follow a specific structure which made me easily miss information. Once I lose my place, I have to use voiceover to read from the beginning again...''
\end{quote}
Besides the need for better recipe structures, we also found that our participants \textbf{had a difficult time interacting with the recipe while cooking}. Challenges include problems interacting with phones or tablets while cooking (P1), irrelevant ads and pictures (P10), and worries of getting both physical recipes and electronic devices dirty while cooking (P10). P10 continued:
\begin{quote}
``...I just cannot find a better way to interact with both my braille recipes and electronic recipes by getting them dirty and have a better interactive interface while cooking. Because my hands often have oil or sauce when I am cooking my dishes...''
\end{quote}
Therefore, it is necessary for future research to consider how to better support cooking related information access and better interactive methods while cooking.
\subsubsection{Touching and Feeling}
\label{Touch and Feel}
In the YouTube video analysis, we mentioned that people with visual impairments leverage their hands' feeling for measuring (Section \ref{Measuring}), placing pans on a burner (Section \ref{Placing Pans on a Burner}), baking (Section \ref{Baking}), and testing food for ``doneness" (Section \ref{Testing Food for Doneness}). From the interview, we found that there exist various challenges and concerns about this from people with visual impairments in cooking. First, we found that \textbf{hand feeling is not sufficient to tell all the information about certain cooking procedures}. For example, P12 commented: \textit{``it can be difficult to feel the liquid level if the liquid is room temperature''}. Therefore, P5 complained that he had to put oil in the fridge first and then use a finger to feel the level. P1 further mentioned his difficulties in using his hand to feel the pouring speed of liquid:
\begin{quote}
``...When I use my fingers to lead the liquid to pour into a container, I can tell somethings flows over my finger, but I cannot tell how fast that is, and it usually ended up with having too much or too little that got poured, because I do not have another hand to feel the weight of the container, I have to use one hand to pour and use one hand to lead the liquid...''
\end{quote}
Another concern from our participants is that \textbf{using hand feeling during cooking might not be appropriate or unsafe}. As an explanation, P5 mentioned his experiences of messing up the decoration of a cake by using his hands. Moreover, P9 and P12 mentioned that using hands when cooking might cause them to burn themselves by accidentally touching the hot pan. P12 continued:
\begin{quote}
``...Using hands to feel the food on a hot pan is not always easy to do, you have to be very very slow and gentle, especially when you want to feel the doneness of the food and try to flip it. I have burned myself many times...''
\end{quote}
Furthermore, we found that visually impaired individuals complained that \textbf{using hands to feel objects affects the efficiency of cooking}, that is, the person cannot use their hand, which is used for feeling and touching, to do other things. As an example we mentioned previously, the person has to use one hand to pour and one hand to lead the liquid to the container, which forces them to place the container at a stable position (P10). Therefore, future research should consider how to enable hand and finger sensing to help with knowing more information during different cooking procedures and explore alternative methods to substitute the need for hand touch and feel in cooking.
\subsubsection{Safety and Consequence}
\label{Safety and Consequence}
From the interview, we found that all participants showed strong concerns of \textbf{getting burned during different cooking procedures}, which need heat detection assistance while cooking. For example, taking things out of the oven puts the visually impaired person in danger (P8), and the plate and dish for baking can be very hot even after taking it out of the oven (P7). P8 explained the danger of exposed heat sources:
\begin{quote}
``...A lot of kitchen appliances have exposed heat sources, it can be very dangerous, such as my toaster or the steamer. After I burned myself once, I always pay 200\% attention when I am cooking...''
\end{quote}
Beyond burning, we found participants reported the \textbf{difficulty of handling accidents while cooking}. This includes accidentally knocking things over (P3), it being hard to know if there is an oven fire or not (P10), and accidentally dropping things and making a mess (P5). P5 continued:
\begin{quote}
``...I had experiences making scrambled eggs and spilled the egg all over the stovetop. However, I did not notice the mess after cooking, and my partner told me this situation the next day. I need something to alert me or help me to be aware of these things happened...''
\end{quote}
Finally, we found that seven participants mentioned that \textbf{other people walking by could potentially cause safety concerns}, especially for participants who learned cooking before their vision loss. For example, P8 mentioned: \textit{``you may turn around, and someone might stay behind you, and you hold a knife...It is a factor that is out of your control with another person while cooking.''} Thus, future research should explore how to help people with visual impairments detect heat to prevent burns, track accidents, and people walking by.
\subsubsection{Precision and Ambiguity}
\label{Precision and Ambiguity}
In the YouTube video analysis, we introduced the need for measuring (Section \ref{Measuring}) while cooking. From the interview, we found that \textbf{making precise steps while cooking can be a huge barrier for people with visual impairments}, such as getting the right amount of baking soda while baking, because using a hand to feel the level in a measuring cup of powders is challenging (P1). P7 further mentioned the problem with always getting more during spreading:
\begin{quote}
``...Because it is hard to know how much butter I already spread on my bread, I always ended up with taking more than needed...''
\end{quote}
P11 further continued with commenting on the difficulty of decorating the food:
\begin{quote}
``...Decorating the cake or dishes is extremely hard for me. It took a lot of practice to get used to frosting or adding decorations. And it is very easy to get messed up...''
\end{quote}
To reduce cooking risks, we showed different safe cooking tips in Section \ref{General Safe Cooking Practices}. However, we found that our participants complained about the \textbf{long learning curve of new methods which makes people stick with their familiar way of cooking}. P7 mentioned: \textit{``every person has their own of doing things.''} P3 further commented on the hardness of adopting advice from other people:
\begin{quote}
``...It is really difficult to get advice from other people when I am already used to doing things in a certain way. I know my current way of cutting and chopping might not be the recommended way by blind cooking guidelines, but I am already used to it, I tried using the recommended method of cutting and chopping, and I cut myself while learning it...''
\end{quote}
According to participants' responses, another challenge is \textbf{following cooking steps or procedures precisely according to a recipe or instructions}. P10 mentioned that a simple mistake during cooking could end up ruining the dish, such as measuring baking soda and tracking the leavening time during baking. All participants mentioned the correlation between the tedious work of following all cooking steps and procedures and why they do not like to cook. Therefore, future research should explore different tracking and measuring methods to help people with visual impairments follow steps easier and should create various teaching techniques to reduce the learning curve of different safe cooking methods.
\subsubsection{Organizing and Tracking}
\label{Organizing and Tracking}
In Section \ref{Knowing the Kitchen Space}, we showed that people put a lot of effort into organizing their kitchen space to reduce barriers. From the interviews, we uncovered various challenges in organizing the kitchen and tracking objects. First, we found that participants complained about the challenge of \textbf{finding previously used objects or cookware due to the mental load during cooking}. P1 commented: \textit{``It is really easy for me to forget where my used knives are.''} P10 also mentioned that it is hard to find previously used ingredients. P3 then commented on the need of having a system that continuously tracks the kitchen environment:
\begin{quote}
``...Cooking itself is a very complicated task that requires people to do multi-tasking and keep tracking of different things. For me, I sometimes forgot where my used knives are, and I had to be very conscious about my actions to prevent being cut by touching my used knife. Therefore, I think I need a tracker that can track the positions of different utensils and cookware for convenience and safety...''
\end{quote}
Furthermore, we found that cooking is not a simple binary task that will guarantee successful and tasty dishes if you follow the recipe. We also realized people with visual impairments \textbf{have a hard time tracking the status of tasks in progress}. Five participants commented that it is hard to know when things are done. They have to constantly check the food. P1 further commented on this problem and tended to overcook the food:
\begin{quote}
``...Knowing whether the food is done is such a complicated project for me without any vision. To make sure I do not get diarrhea afterward, I often overcooked the food, such as shrimp. Although I can make sure it is totally cooked, but it affected the texture and the taste of the food...''
\end{quote}
We also found that participants \textbf{have challenges tracking and organizing parts of the food}, such as organizing the cut and uncut parts of a large volume of food, and memorizing which parts of the food on the pan need to be flipped (P10). Therefore, P1 said that she had to wash her hands a lot and touch everything to check the food. P6 continued with her challenges:
\begin{quote}
``...The pan is big. If only a portion of the food on the pan needs to be turned over, it would be very difficult. I usually had to use hand and smell to check if the food at the center of the pan is burned or not...''
\end{quote}
Finally, participants mentioned that they often have a hard time \textbf{knowing and remembering where to clean while cooking}. Specifically, six participants complained about remembering where they need to clean afterward, or they have to clean things right after use. P4 further commented that it is also very common for him to not know or not be aware of where he has to clean. Overall, future works should explore how to help people with visual impairments to better organize and track things through cooking.
\subsubsection{Item and Quality Inspection}
\label{Item and Quality Inspection}
From the interview, we realized that people with visual impairments often have concerns about inspecting an item or food. First of all, we found that participants have a hard time \textbf{checking food quality}, such as whether the bread is moldy. P5 commented on the difficulty of checking food quality just with smell and touch, even with computer vision assistance:
\begin{quote}
``...Knowing the food quality is hard just by smelling and touch. Such as knowing whether a piece of bread is moldy or whether bananas or pineapples are ripe. I even tried with some apps that could object recognition, but I realized it just told me the object it is...''
\end{quote}
Furthermore, we found that our participants complained about the task of \textbf{telling whether things got peeled or cleaned thoroughly}. P8 commented on cleaning and peeling non-smooth vegetables:
\begin{quote}
``...Different vegetables have different difficulties in cleaning and peeling. Vegetables like carrots are very easy to peel. But non-smooth vegetables are hard to tell if they got peeled or cleaned completely. Ginger is a hard one, also spots on potatoes are hard too...''
\end{quote}
In the interviews, nine participants reported having a hard time \textbf{inspecting an accidental mix of unwanted things}, such as eggshells and bugs in flour (P1). P1 continued: \textit{``I had many times of having eggshells in my scrambled eggs without noticing, it was disgusting.''} Overall, we showed the existing challenges of items and quality inspection. Future research should explore how to bridge the gap of the challenges we introduced to people with visual impairments in cooking.
\subsubsection{Collaborative Cooking and Communication}
\label{Collaborative Cooking and Communication}
From interviewing people with visual impairments, we found that ten out of twelve participants mentioned that they do not like cooking with another person because of \textbf{continuous communication needs}. \textit{``Cooking with another person needs me to constantly speak out things.''} said P4. P3 further complained about collaborative cooking processes:
\begin{quote}
``...I have to verbally confirm steps and actions with another person all the time. Sometimes they might just do something in a way that I do not like, and they might not inform me because cooking and talking is not common for any person...''
\end{quote}
In the interview, we found that eight participants leveraged apps for remote assistance while cooking, such as Aira \cite{HomeAira36:online} or Be My Eyes \cite{BeMyEyes54:online}. However, our participants complained about \textbf{making sure the item is in the camera's field of view}. P1 continued:
\begin{quote}
``...Remote assistance definitely needs more improvements, I often do not know whether the thing I am talking about is in the camera's field of view. More importantly, my hands are often dirty while cooking, and I always tried not to touch my electronic device. This leads to more concerns about using remote assistance...''
\end{quote}
Moreover, we found that our participants complained about \textbf{appliance modification barriers in a communal space}. P8 commented on this problem: \textit{``the biggest thing about using a shared kitchen, even the simple one like adding bump dots or braille markers, it is hard for me to just add these markers on different appliances, because they are shared.''} Therefore, future research should explore how to improve the social acceptability of adding tactile markers on appliances or other alternative ways for people to interact with different appliances.
\section{Discussion and Future Work}
From the results of our interviews with people with visual impairments, we uncovered existing challenges and gaps for visually impaired people in cooking. In this section, we further discuss zero-touch interactions for cooking, status tracking and safety monitoring, collaborative cooking, and contextual inquiry and learning process in-depth.
\subsection{Zero-touch Interactions for Cooking}
From the results, we showed that our participants often rely on touching and feeling when cooking (e.g., measuring, checking for food doneness, spreading), and interacting with touch-based electronic devices might be inconvenient because they often have food on their hands. As an input method, prior research has explored speech \cite{choi2020nobody, branham2019reading, abdolrahmani2020blind,storer2020all} and mid-air gestures \cite{dim2016designing} as input options for people with visual impairments. However, many of the existing interaction paradigms still require people to physically touch the interfaces (e.g., \cite{ye2014current}), especially to explore elements on the screen. Although visually impaired individuals can currently leverage voice control to input certain commands (setting a timer), future research should explore how to best integrate zero-touch interactions with electronic devices alongside existing practices utilizing touch to manipulate ingredients and cooking tools.
\subsection{Status Tracking and Safety Monitoring}
From our interviews, we highlighted that people with visual impairments have various difficulties in tracking the status of tasks in progress (Section \ref{Organizing and Tracking}), protecting themselves from getting burned during different cooking procedures (Section \ref{Safety and Consequence}), and handling accidents while cooking (Section \ref{Safety and Consequence}). Prior work has explored using thermography to detect heat sources for energy auditing (e.g., \cite{mauriello2017exploring,mauriello2019thermporal}). A similar approach could be applied in the kitchen to detect heat hazards. Beyond heat detection, prior research also explored using computer vision approaches to opportunistically capture actions and provide proactive reminders to users with visual impairments \cite{kianpisheh2019face}. Similar approaches using computer vision or audio \cite{laput2018ubicoustics} could be applied in the kitchen to track object locations or track user's actions and status of cooking steps (e.g., boiling water).
\subsection{Collaborative Cooking}
The majority of our participants complained about cooking with other people because they have to constantly speak about their actions and ask about other people's actions. Cooking while constantly talking might not be a natural behavior for people both with and without visual impairments. However, three participants did mention the benefit of having another person to accomplish tasks that rely on vision, such as checking expiration dates and food doneness (P10). Prior research has explored collaborative behaviors for people with visual impairments for other purposes, such as gaming \cite{gonccalves2020playing}, use of tangible interfaces \cite{chibaudel2020if}, music composition \cite{omori2013collaborative}, and creating accessible home environments \cite{branham2015collaborative}. Therefore, future research should explore the collaborative cooking behaviors for people with visual impairments and further create guidelines and training methods to reduce safety concerns as well as both mental and physical effort.
\subsection{Contextual Inquiry and Learning Process}
In this paper, we described our research approach using YouTube Video analysis to understand more about the practices of cooking by people with visual impairments. In general, video analyses of this type have the benefit of allowing researchers to gain a broad understanding of the practices of assistive technology use for many different users. This has been exemplified in prior work in HCI and Accessibility (e.g., \cite{anthony2013analyzing,hourcade2015look}). In future research, a contextual inquiry study is well suited to gather a deeper understanding of individual users' practices and challenges (e.g., \cite{dosono2015m,li2019fmt,krome2016contextual,kianpisheh2019face}), which may then be aggregated to understand themes across those individuals. As it relates to the research opportunities we discussed above, a contextual inquiry study may enable future researchers to deeply explore the practices and challenges of zero-touch interactions, status and safety monitoring systems, and collaborative cooking. For example, conducting a contextual inquiry study at a participant's kitchen could identify more status and safety monitoring concerns that might not be recognized by the participants with visual impairments and are not included in the camera's field of view in YouTube videos. An example of this might be watching a visually impaired cook show how she cuts vegetables in front of the camera while, off-camera, cooking chicken in a pan. In this case, neither the audience nor researchers may recognize any potential safety concerns with the pan or other objects in the surroundings from the video. Beyond only interviewing visually impaired individuals, we realized it would also be beneficial for future research to conduct interviews with teachers or trainers who work at community centers and help people with visual impairments with their activities of daily living and meal preparation. This may generate more common practices of cooking by people with visual impairments.
\section{Limitations}
All of the participants in our study were either legally blind or totally blind. We think people with low vision may have different cooking strategies and challenges that utilize their visual perceptive abilities. In our study, we focused on understanding the existing practices and challenges of visually impaired people in their cooking. However, we did also find that people with visual impairments have different learning experiences with cooking. Therefore, people might encounter different challenges at different stages of learning to cook.
\section{Conclusion}
In this paper, we describe the results of content analyses with 122 YouTube videos featuring visually impaired people preparing meals and uncovered unique cooking practices for people with visual impairments (e.g., use hands to weigh meat and measure spices, use sound and smell to test if the food is done). We then present findings from semi-structured interviews with 12 visually impaired participants and highlight existing challenges encountered while cooking from their perspectives (e.g., tracking the status of tasks in progress, telling whether ingredients are peeled or cleaned thoroughly). We then discussed potential opportunities to integrate technology with the existing practices for cooking, status tracking, safety monitoring, and collaborative cooking. Overall, our findings provide guidance for future research exploring various assistive technologies to help people cook without relying on vision.
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2021-07-14T02:06:53', 'yymm': '2107', 'arxiv_id': '2107.05783', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05783'} | arxiv |
\section{Introduction}
End-to-end methods have achieved significant progress in speech to text translation (ST) and even surpassed the traditional pipeline-based methods in some applications~\cite{Niehues2019TheI2,salesky2020phone}.
However, the success of end-to-end methods relies on large amounts of training data, which is quite expensive to obtain and relatively small in practice. Building ST systems from pretrained models with multitask learning (MTL) is widely used to overcome the limited training data issue~\cite{Weiss2017SequencetoSequenceMC,Anastasopoulos2018TiedML,Bahar2019ACS,Indurthi2020EndendST,Wang2019BridgingTG,Li2020MultilingualST}.
Nevertheless, little prior work has been devoted to understanding the interactions between different tasks. \citet{Standley2019WhichTS} conduct an empirical study on computer vision tasks for MTL.
They find many ``assumptions" for MTL may not be held for specific applications. For example, ``similar" tasks do not necessarily train better together.
In this study, we focus on training the ST model along with an auxiliary text to text machine translation (MT) task.
We are interested in the task interactions with different modalities and in improving the primary ST task with the help from the auxiliary MT task.
The model is initialized with pretrained modules from automatic speech recognition~(ASR) and MT.
Two types of analysis are conducted on the fine-tuned
multitask learned models.
The first focuses on the model variation
by comparing fine-tuned models with pretrained models for different tasks. The second aims to measure internal representation differences due to different modalities.
The analysis leads to three main findings. First, the analysis confirms that MTL tends to generate similar model representations for different input modalities and preserves more information from the pretrained MT modules. Second, we do not observe significant negative transfer effect from the MT task to the corresponding ST task. Sharing more parameters is helpful to transfer knowledge to the primary ST task.
Finally, the top layers in the ST decoder are more critical to the translation performance and they are also more sensitive to the modality difference. The model representations from different modalities demonstrate larger difference for the top layers in our analysis.
Inspired by these findings, we propose three techniques to enhance the performance of the primary ST task.
First, we propose to maximize parameter sharing
between the ST and MT tasks, i.e.\ the entire decoder and the top encoder layers. Those shared parameters are initialized with the corresponding MT models. Second, a cross-attentive regularization is introduced for the encoders. It minimizes the $L2$ distance between two reconstructed encoder output sequences and
encourages the encoder outputs from different modalities to be closer to each other. Finally, an online knowledge distillation learning is introduced for MTL in order to enhance knowledge transfer from the MT to the ST task.
Our contributions are summarized as follows:
\begin{enumerate}
\item A detailed analysis is conducted on the interaction between the primary ST task and the auxiliary MT task.
\item A parameter sharing and initialization strategy are proposed to encourage information sharing between tasks.
\item Cross-attentive regularization and online knowledge distillation are proposed to reduce the model representation difference between different modalities and enhance the knowledge transfer from the MT task to the ST task.
\item Our system achieves state of the art results on the \textsc{MuST-C} English-German (EN-DE), English-French (EN-FR) and English-Spanish (EN-ES) language pairs, with 2 or more BLEU gains over strong baselines.
\end{enumerate}
\section{Related Work}\label{sec:rel_work}
\textbf{Multitask learning} aims to improve generalization by leveraging domain-specific information contained in the training signals of related tasks~\cite{Vandenhende2020MultiTaskLF}. Compared with single task, MTL has many advantages, such as
the potential to improve performance by sharing complementary information or acting as a regularizer. Many previous works focus on learning a good model for all tasks. \citet{Chen2018GradNormGN} study the gradients from different tasks and conduct task dependent gradient normalization to encourage different tasks to learn at similar speed.
\citet{Maninis2019AttentiveSO,Liu2019EndToEndML,Pfeiffer2020MADXAA} introduce task-dependent components to enhance individual task performance.
\citet{Weiss2017SequencetoSequenceMC} explore different multitask training strategies for ST, and they find the one-to-many strategy, in which an encoder is shared between the ST and ASR tasks, is more effective. \citet{Anastasopoulos2018TiedML} further extend it to a triangle structure by concatenating ASR and ST models. \citet{Bahar2019ACS} compare different multitask strategies for the ST task, and they confirm many-to-one strategy, in which MT and ST are trained together and the decoder is shared between two tasks, is effective if extra bitext data is used. In this work, we carefully study the relation between co-trained tasks in the many-to-one strategy, and the analysis results guide us to propose three techniques to learn more from the auxiliary MT task and enhance the ST performance further.
\begin{figure}
\centering
\includegraphics[width=1.00\columnwidth]{Figures/Enhanced_Joint_Training.png}
\caption{Joint Training framework. The speech to text translation task is depicted as dark gray line, text to text translation task is illustrated as light gray line. The parameters in blue modules are shared between two tasks.}
\label{fig:jt_framework}
\end{figure}
\noindent\textbf{Model analysis}~\citet{Chatterji2020TheIR} propose criticality analysis to measure the importance of different modules from the trained model.
Parameters in the selected module or layer are partially rolled back to the initial values, and the module criticality or importance is measured by the performance drop after modification. Larger performance drops indicate a more critical module. Inspired by their work, we extend it to the analysis on the jointly trained models with different pretrained modules and schemes.
\citet{Raghu2017SVCCASV,Morcos2018InsightsOR} propose to employ canonical correlation to measure the similarity between different models given the same input.
We extend their work to study a model with inputs from different modalities.
\section{Methods}\label{sec:methods}
The proposed ST system is co-trained with the MT task as depicted in \autoref{fig:jt_framework}. The modules in the primary ST task are connected with dark gray lines and the auxiliary MT task is illustrated with light gray lines. The parameters in the blue modules are shared between the two tasks. During inference with speech input, only modules related to the ST task are used.
The model has two encoders, a text encoder and a speech encoder, to take text and speech input respectively.
The decoder is shared between the two tasks.
To encourage knowledge sharing between the two tasks, the top encoder layers are also shared. The parameters of the shared modules
are initialized with a pretrained MT model.
A novel cross-attentive regularization is proposed to reduce the distance between encoder outputs from different input modalities.
We also introduce a novel online knowledge distillation method where the output from the auxiliary MT task is used to guide the ST model training. The cross-attentive regularization and online knowledge distillation are illustrated as orange modules in \autoref{fig:jt_framework} and the details are presented in the following two subsections.
\subsection{Cross-Attentive Regularization}\label{sec:car}
The cross-attentive regularization (CAR) is proposed to increase the similarity between the text encoder outputs and their corresponding speech encoder outputs.
Hence, the performance of the more difficult ST task can be improved by learning from the relatively easier MT task.
Encoder output sequences from different modalities can not be compared directly since they have different lengths.
In CAR, the two reconstructed sequences are calculated from the text output sequence via self-attention or the speech output sequence via cross attention over the text output sequence. The two reconstructed sequences have the same length and the distance is simply measured as the $L2$ distance between the two sequences.
Formally, we denote a speech to text translation
training sample as a triplet
$o=(\mathbf{X^s}, \mathbf{x^t}, \mathbf{y})$. $\mathbf{X^s}\in\mathcal{R}^{d_s \times N}$, $\mathbf{x^t}\in\mathcal{R}^{M}$, and $\mathbf{y}\in\mathcal{R}^{K}$ are the speech feature input, text token input and target text output respectively. $N$, $M$ and $K$ are the corresponding sequence lengths.
Assume $\mathbf{H^s}=(\mathbf{h}^s_1,\mathbf{h}^s_2,\cdot\cdot\cdot,\mathbf{h}^s_N)$ and $\mathbf{H^t}=(\mathbf{h}^t_1,\mathbf{h}^t_2,\cdot\cdot\cdot,\mathbf{h}^t_M)$, $ \mathbf{h}^s_n, \mathbf{h}^t_m \in \mathcal{R}^{d_h}$ are outputs from the speech encoder and text encoder respectively, where $d_h$ is the dimension of the output states.
A similarity matrix $\mathbf{S} \in \mathcal{R}^{N\times M}$ is defined as the cosine distance between the tensors in the two sequences:
\begin{equation}
s_{i,j} = \frac{(\mathbf{h}^s_i)' \cdot \mathbf{h}^t_j}{ {|| \mathbf{h}^s_i ||}_2 {|| \mathbf{h}^t_j ||}_2}
\end{equation}\label{equ:sim}
where $s_{i,j}$ is the $i$th row and $j$th column component in $\mathbf{S}$.
The text encoder outputs $\mathbf{H}^t$ are reconstructed through the speech encoder outputs $\mathbf{H}^s$ and similarity matrix $\mathbf{S}$ as below.
\begin{equation}
\mathbf{H}^{s\rightarrow t} = \mathbf{H}^s\cdot \mathrm{softmax}(\mathbf{S})
\end{equation}\label{equ:t2s}
$\mathbf{H}^{t\to t}$, the reconstruction of $\mathbf{H}^t$ from itself, can be computed similarly via self-attention.
CAR is defined as the $L2$ distance between the two reconstruction encoder outputs:
\begin{equation}
\mathcal{L}_{CAR}(\theta_s)=\frac{1}{M} \left\Vert \mathbf{H}^{s\rightarrow t} - sg[\mathbf{H}^{t\rightarrow t}] \right\Vert_2
\end{equation}
where $sg[\cdot]$ is the stop-gradient operator and $\theta_s$ are the ST model parameters. By optimizing the model with CAR, the speech encoder is encouraged to learn from more accurate text encoder and generates similar encoder outputs after reconstruction.
CAR is inspired by the attention mechanism between the encoder and decoder where the decoder states are reconstructed through encoder output states via the attention mechanism.
\subsection{Online Knowledge Distillation}\label{sec:kd}
Knowledge distillation (KD) is widely used for model compression~\cite{Hinton2015DistillingTK,Kim2016SequenceLevelKD} where a smaller student network is trained to mimic the original teacher network by minimizing the loss between the student and teacher outputs.
The ST task is considerably more difficult than the MT task since the speech input is noisier and more ambiguous than the text input. The accuracy of the MT model is usually much higher than the corresponding ST model. Knowledge distillation from a well trained MT model to a ST model has been proved to be an effective way to improve the ST performance~\cite{Liu2019EndtoEndST,gaido2020endtoend}.
In this work, we extend knowledge distillation to the MTL framework where both ST and MT are fine-tuned simultaneously with shared parameters.
Concretely, we assume an MTL model learns from a data set $\mathcal{D}$ with target vocabulary size $|V|$. The training criterion is to minimize negative log likelihood (NLL) for each example $o=(\mathbf{X^s}, \mathbf{x^t}, \mathbf{y}) \in \mathcal{D}$ from the training data:
\begin{eqnarray}
\mathcal{L}_{NLL}(\theta_s) &=& -\sum_{o}^{\mathcal{D}} \sum_{k=1}^K \sum_{v=1}^{|V|} \delta(y_k=v) \nonumber \\
&& \log p(y_k=v|y_{<k},\mathbf{X}^s,\theta_s)
\end{eqnarray}
where $\delta(\cdot)$ is the indicator function and $p$ the distribution from the ST model (parameterized by $\theta_s$).
Assume the probability distribution for $y_k$ given text input $\mathbf{x}^t$ and MT model $\theta_t$ is $q(y_k=v|y_{<k},\mathbf{x}^t,\theta_t)$, the knowledge distillation loss is defined as minimizing the cross-entropy with the MT’s probability distribution
\begin{eqnarray}
\mathcal{L}_{KD}(\theta_s) &=& -\sum_{o}^{\mathcal{D}} \sum_{k=1}^K \sum_{v=1}^{|V|} q(y_k=v|y_{<k},\mathbf{x}^t,\theta_t) \nonumber \\
&& \log p(y_k=v|y_{<k},\mathbf{X}^s,\theta_s)
\end{eqnarray}
The overall loss is the combination of cross-attentive regularization, knowledge distillation loss, negative log likelihood loss for both ST and MT, as follows:
\begin{eqnarray}\label{equ:total_cost}
\mathcal{L}(\theta_s, \theta_t) &=& \alpha\mathcal{L}_{NLL}(\theta_s) + (1-\alpha)\mathcal{L}_{KD}(\theta_s) \nonumber\\
&& + \lambda\mathcal{L}_{CAR}(\theta_s)+ \mathcal{L}_{NLL}(\theta_t)
\end{eqnarray}
where $\alpha$ and $\lambda$ are predefined hyper-parameters.
\section{Experimental Setup}\label{sec:setup}
Experiments are conducted on three \textsc{MuST-C}~\cite{Gangi2019MuSTCAM} language pairs: EN-DE, EN-ES and EN-FR. The models are developed and analyzed on the dev set and the final results are reported on the tst-COMMON set. We use WMT parallel data from different years, 2013 for Spanish, 2014 for German, and 2016 for French,
as extra text training corpus for MTL. Case-sensitive detokenized BLEU is reported by \textsc{sacrebleu} with default options~\cite{post-2018-call}.
We use the ``T-Md" configuration
from~\cite{Wang2020fairseqSF} in all experiments. The speech encoder has 12 transformer layers while the decoder is with 6 transformer layers. For the MTL model, the text encoder has 6 transformer layers.
The transformer layer has an input embedding size of 512 and middle layer dimension 2048. We share parameters of all 6 text encoder transformer layers with the top 6 transformer layers in the speech encoder, hence both encoders use the same modules to generate the encoder outputs.
The Adam optimizer~\cite{kingma2014adam} with a learning rate 0.002 is employed in the experiments. Label smoothing and dropout rate are both set to 0.1. We choose $\alpha = 0.8$ and $\lambda = 0.02$ in \autoref{equ:total_cost} through grid search ($[0.1, 1.0]$ for $\alpha$ and $[0.01,0.05]$ for $\lambda$).
Input speech is represented as 80D log mel-filterbank coefficients computed every 10ms with a 25ms window. Global channel mean and variance normalization is applied. The SpecAugment~\cite{park2019specaugment} data augmentation with the LB policy is applied in all experiments.
The input text tokens are converted into their corresponding pronunciation form as phoneme sequences~\cite{Tang2020AGM,Renduchintala2018MultiModalDA}. The grapheme to phoneme conversion is done through the ``g2p\_en'' python package~\cite{Lee2018LearningPF}.
The leading phoneme in a word is appended with an extra ``\_" to mark word boundaries. In total, the vocabulary size for the input phonemes is 134. The target vocabulary consists of 10k ``unigram'' subword units learned by SentencePiece~\cite{Kudo2018SentencePieceAS} with full character coverage of all training text data.
All ST or jointly trained models are initialized with pretrained ASR and MT modules. The ASR model is trained on the same English speech training data from \textsc{MuST-C} with the ``T-Md" configuration too.
The pretrained MT models are trained for each language pair with the aforementioned WMT data. The MT encoder and decoder configurations are the same as the text encoder and decoder in the MTL model mentioned above.
The models are fine-tuned to 100 epochs using 8 V100 GPUs for approximate one day. The batch size is 10,000 frames for speech to text translation samples and 10,000 tokens for parallel text samples per GPU. The model parameters are updated every $4$ batches. Speech training samples and text input samples are used to update the model alternatively.
The models are trained with \textsc{Fairseq}~\cite{Ott2019fairseqAF,Wang2020fairseqSF}.
The last 10 checkpoints are averaged for inference with beam size 5. \footnote{The source code will be released at https://github.com/pytorch/fairseq/tree/master/examples/speech\\\_text\_joint\_to\_text}.
\begin{table}[t]
\centering
\begin{tabular}{ c | c | c | c }
\hline
Model & \multicolumn{3}{|c}{Encoder} \\
\cline{2-4}
Configuration & Speech & Text & Shared \\
\hline\hline
ST & ASR & None & None \\
JT & ASR & MT & None \\
JT-S-ASR & ASR & MT & ASR \\
JT-S-MT & ASR & MT & MT \\
\hline
\end{tabular}
\caption{Model initialization schemes}
\label{table:mod_ini}
\end{table}
\section{MTL Analysis}\label{sec:analysis}
\subsection{Model Variation}
We extend \citet{Chatterji2020TheIR}'s work to analyze a MTL model. We initialize models with different pretrained modules and fine-tune them for ST and MT tasks within the MTL framework. The pretrained modules come from ASR and MT tasks.
Criticality analysis is conducted on the ST model after the MTL fine-tuning step. The parameters in the selected modules are interpolated with corresponding parameters in the pretrained modules. \textsc{MuST-C} EN-DE dev set is used for BLEU computation.
With different interpolation ratios, we obtain different BLEU scores.
The BLEU difference comes from two sources. The first one comes from the selected module itself. If the module is important and sensitive, very small perturbation could result in a nontrivial BLEU difference as~\cite{Chatterji2020TheIR}. Another source of difference is that if the selected module changes significantly to adapt to the ST task, rewinding the parameters back to the initial task may lead to a substantial decrease in BLEU. We attempt to quantify the extent of the degradation from the second source, which can be indicative of the model variation from the pretrained task to the ST task. This is accomplished by comparing the BLEU differences for the same module but using different initialization and training schemes.
\autoref{table:mod_ini} lists models initialized with different pretrained modules.
``ST" designates a ST model trained with the single ST task, ``JT" corresponds to a ST model trained with the primary ST task and auxiliary MT task together.
``JT-S-ASR" and ``JT-S-MT" are another two jointly trained models but with the top encoder layers shared as described in \autoref{sec:setup}.
The difference between the two models is how we initialized the shared encoder layers, either from the pretrained ASR model for ``JT-S-ASR" or from the pretrained MT model for ``JT-S-MT".
\noindent\textbf{ST}~ \autoref{fig:imp_st} shows the analysis for the ``ST" model. The x-axis is the interpolation ratio and ``1.0" means the pretrained parameters are used. The y-axis is the relative change in BLEU compared with the well-trained ST model. \textbf{It is clear that higher layers are more critical to the performance}. Around 5 BLEU decrease is observed on the top encoder layer~(11) and top decoder layer~(5) during the criticality tests. The following analysis will compare with \autoref{fig:imp_st} and we can separate the aforementioned second source from the first one.
\noindent\textbf{JT}~ \autoref{fig:imp_jt} presents the analysis for the ``JT" model. The jointly trained model shows smaller degradation compared with ``ST" for the decoder layers. \textbf{This indicates that training the ST and MT tasks together helps to preserve more information from the original MT decoder and partially remedies the catastrophic forgetting~\cite{McCloskey1989CatastrophicII} during the fine-tuning phase.}
On the other hand, after rolling parameters back to the initial ASR model, the jointly trained model shows a larger degradation for the encoder layers. This means that the speech encoder in the jointly trained model has deviated far away from the speech encoder in the initial ASR task. We conclude that the shared decoder is subject to more constraints since it is optimized toward both MT and ST tasks while the speech encoder has to undergo larger changes in order to align with the text encoder, although there is no parameter sharing between two encoders.
\begin{figure}
\hfill
\subfigure[ST Enc.]{\includegraphics[width=.48\columnwidth]{Figures/ST_Enc.png}}
\hfill
\subfigure[ST Dec.]{\includegraphics[width=.48\columnwidth]{Figures/ST_Dec0.png}}
\hfill
\caption{Criticality analysis for the ``ST" model.}
\label{fig:imp_st}
\end{figure}
\begin{figure}
\hfill
\subfigure[JT Enc.]{\includegraphics[width=.48\columnwidth]{Figures/JT_Enc.png}}
\hfill
\subfigure[JT Dec.]{\includegraphics[width=.48\columnwidth]{Figures/JT_Dec0.png}}
\hfill
\caption{Criticality analysis for the ``JT" model.}
\label{fig:imp_jt}
\end{figure}
\noindent\textbf{JT-S-ASR and JT-S-MT}~
Results for models with the top encoder layers shared are presented in \autoref{fig:imp_jt_asr} and \ref{fig:imp_jt_mt}. In ``JT-S-MT", the top 6 shared encoder layers are initialized with the pretrained MT encoder. We illustrate their BLEU difference trajectories with dotted lines in \autoref{fig:imp_jt_mt} (a) so they can be easily distinguished from other layers initialized from the ASR encoder.
The BLEU difference for the top encoder layer is down from 20.2 to 17.6 when the parameters are replaced with the ones in the pretrained ASR encoder. It is further reduced to 10.0 if the shared layers are initialized with MT encoder layers.
The BLEU differences in the decoder layers are mixed. The performance of ``JT-S-ASR" degrades quickly in the criticality test for the top decoder layer, while ``JT-S-MT performs similarly in the test as ``JT" decoder.
We argue that the top layers in the fine-tuned ST encoder might be closer to the MT encoder than the ASR encoder.
\textbf{It preserves more information from the MT task by sharing more parameters between two tasks and initializing them with pretrained MT modules}. This is a desirable property since we want to transfer more knowledge from the text corpus to the ST task.
\begin{figure}[t]
\hfill
\subfigure[JT-S-ASR Enc.]{\includegraphics[width=.48\columnwidth]{Figures/JT_S_ASR_Enc.png}}
\hfill
\subfigure[JT-S-ASR Dec.]{\includegraphics[width=.48\columnwidth]{Figures/JT_S_ASR_Dec0.png}}
\hfill
\caption{Criticality analysis for the ``JT-S-ASR" model. The shared encoder layers are initialized with the layers from the ASR encoder.}
\label{fig:imp_jt_asr}
\end{figure}
\begin{figure}[t]
\hfill
\subfigure[JT-S-MT Enc.]{\includegraphics[width=.48\columnwidth]{Figures/JT_S_MT_Enc2.png}}
\hfill
\subfigure[JT-S-MT Dec.]{\includegraphics[width=.48\columnwidth]{Figures/JT_S_MT_Dec0.png}}
\hfill
\caption{Criticality analysis for the ``JT-S-MT" model. The shared encoder layers are initialized with the layers from the MT encoder.}
\label{fig:imp_jt_mt}
\end{figure}
\subsection{Modality Variation}
The jointly trained model takes input from two modalities, i.e.\ text or speech, and we are interested in the model internal representation difference for paired inputs.
Given text target $\mathbf{y}$, we extract the decoder hidden state representations for the corresponding text input $\mathbf{x}_t$ and speech input $\mathbf{X}_s$.
The decoder representation difference solely comes from different input modalities. The difference is quantified by the correlation coefficient over all samples evaluated between two input modalities:
\begin{equation}
r^{s,t}(l,d) = \frac{\sigma_{st}(l,d)}{\sigma_s(l,d)\sigma_t(l,d)}
\end{equation}
where $\sigma_z(l,d), z\in [s,t]$ is the standard deviations of decoder hidden states at layer $l$ for component $d$ in all samples, and $\sigma_{st}(l,d)$ is the corresponding covariance.
The layer-wise correlation coefficient is the average of all components:
\begin{equation}
r^{s,t}(l) = \frac{1}{D} \sum_d r^{s,t}(l,d)
\end{equation}
\begin{figure}
\centering
\includegraphics[width=.7\columnwidth]{Figures/Dec_Cor_Coe_JT_S_MT.png}
\caption{Comparison of decoder layers correlation coefficients between text and speech input (``JT-S-MT").}
\label{fig:dec_coe_all}
\end{figure}
\autoref{fig:dec_coe_all} depicts the correlation coefficient between speech input and text input for each decoder layer in the model ``JT-S-MT". The x-axis is the number of training epochs and the y-axis represents the correlation coefficient for each layer. There are two observations.
First, the correlation coefficients become larger and close to ``1.0" as training converges.
Second, the higher the layer, the smaller the correlation coefficient. We hypothesize that the inputs to the lower layers are dominated by the decoder text embeddings, which are the same for both modalities, and the inputs to the higher layers would contain more information from the encoder outputs, which result in the decoder internal representation differences.
\textbf{The analysis shows a well trained MTL decoder has similar representations for paired text and speech input. However, the top decoder layers still have nontrivial representation differences due to different modalities}.
\section{Experimental Results}\label{sec:expt_rst}
\subsection{Main Results}
The main ST results are presented in \autoref{tab:ast}. The first three rows are results from the literature. ``ST" and ``JT" are models initialized as \autoref{table:mod_ini} and studied in \autoref{sec:analysis}.
The last row (``JT Proposed") presents results from the proposed system, in which the top encoder layers and decoder are shared, and the models are optimized following \autoref{equ:total_cost}. The second column (``\#pars(m)") lists the number of parameters used during inference.
From \autoref{tab:ast}, our ``ST" baseline is comparable to the previously reported results except~\cite{Pino2020SelfTrainingFE}, who use a much larger model and additional weakly supervised speech training data. As expected, the vanilla joint training baseline (``JT") outperforms the ``ST" baseline with the help of extra bitext training data. Finally, the proposed joint training model (``JT Proposed") achieves 2.0$\sim$2.7 BLEU gains over the strong joint training baseline (``JT").
\begin{table}
\centering
\small
\begin{tabular}{l|c|c|c|c}
\toprule
{Data corpus} &\#pars(m)& {DE} & {ES} &{FR} \\
\hline
\citet{gangi2019onetomany} & 30& 17.7 & 20.9 & 26.5 \\
\citet{Inaguma2020ESPnetSTAS} & - & 22.9 & 28.0 & 32.7 \\
\citet{Pino2020SelfTrainingFE} & 435 & 25.2 & - & 34.5 \\
\hline\hline
ST & 76 & 21.5 & 28.1 & 33.8 \\
JT & 76 & 24.1 & 29.0 & 35.1 \\
\hline\hline
JT Proposed & 76 & 26.8 & 31.0 & 37.4 \\
\bottomrule
\end{tabular}
\caption{ BLEU on three language pairs in the MuST-C tst-COMMON datasets. }\label{tab:ast}
\end{table}
\subsection{Ablation}
\autoref{tab:ablation} breaks down the performance gains into individual components/changes.
Sharing encoder layers improves the quality for all three language pairs (``JT" v.s. ``JT-S-ASR"). Initializing the shared encoder layers with pretrained MT modules leads to BLEU increase for two of the three evaluated translation pairs (``JT-S-ASR" v.s. ``JT-S-MT"). For EN-FR, the degradation is minimal (-0.1 BLEU). Overall, sharing top encoder layers can increase BLEU by 0.2$\sim$0.7 (``JT-S-MT" v.s. ``JT"). CAR further improves the translation by another 0.3$\sim$0.9 BLEU. The best results are achieved by applying the shared top encoder layers, CAR and online KD together. They are about 2.9+ BLEU better than the single task based system (``ST") and achieve 2+ BLEU increase on top of the strong vanilla joint training system(``JT").
\begin{table}[!tbp]
\centering
\small
\begin{tabular}{l|c|c|c}
\toprule
& EN-DE & EN-ES & EN-FR \\
\hline
JT & 24.1 & 29.0 & 35.1 \\
\hline
JT-S-ASR & 24.4 & 29.4 & 35.4 \\
\hline
\hline
JT-S-MT & 24.7 & 29.7 & 35.3 \\
$\;\;\;$+ CAR & 25.0 & 30.4 & 36.2 \\
$\;\;\;$+ CAR + KD & 26.8 & 31.0 & 37.4\\
\bottomrule
\end{tabular}
\caption{ Ablation study. }\label{tab:ablation}
\end{table}
\begin{figure}
\hfill
\subfigure[JT Proposed Enc.]{\includegraphics[width=.48\columnwidth]{Figures/All_Enc.png}}
\hfill
\subfigure[JT Proposed Dec.]{\includegraphics[width=.48\columnwidth]{Figures/All_Dec.png}}
\hfill
\caption{Criticality analysis for ``JT Proposed". }
\label{fig:imp_jt_all}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=1.05\columnwidth]{Figures/Cor_Coe.png}
\caption{Correlation coefficient for the top decoder layers (epoch 100).}
\label{fig:cor_coe}
\end{figure}
\autoref{fig:imp_jt_all} demonstrates the model variation for the proposed system on the \textsc{MuST-C} EN-DE dev set. Compared with \autoref{fig:imp_jt_mt},
the decoder shows less degradation during the criticality test and it shows CAR and online KD help to preserve more information from the MT task.
\autoref{fig:cor_coe} shows the corresponding correlation coefficients between paired text and speech input from the top decoder layer from different model configurations. It also confirms that the proposed methods, i.e., shared top encoder layers, CAR and online KD, all reduce the modality difference substantially.
\subsection{Task Dependent Components}
In MLT, many works~\cite{Maninis2019AttentiveSO,Liu2019EndToEndML,Zhang2020ImprovingMM,Pfeiffer2020MADXAA} employ task-dependent components to alleviate the negative transfer effect. In \autoref{tab:task_dep_com}, we compare the ``JT-S-MT" model with two variants using different task-dependent components.
The first one (``JT-S-MT + Adapter")~\cite{Bapna2019SimpleSA} adds an extra adapter module on the top of the speech encoder.
Hence, the speech encoder outputs, which are generated from shared encoder layers, are further processed to reduce the difference between speech input and text input.
The adapter module consists of a linear layer and layer normalization layer.
The second variant (``JT-S-MT + Dedicated Attention")~\cite{Blackwood2018MultilingualNM} introduces dedicated decoder modules for different tasks. Attention layers between encoder and decoder, and the layer normalization modules are not shared between the ST and MT tasks. It gives the decoder more flexibility to handle information from different modalities.
The results show the extra adapter layer doesn't bring gain while the task dependent attention module actually makes the performance worse. It indicates that the negative transfer effect is not significant in this study and adding extra task-dependent components might not be necessary.
\begin{table}[]
\centering
\small
\begin{tabular}{c|c}
\toprule
Model & BLEU \\
\hline
JT-S-MT & 24.7 \\
\hline
JT-S-MT + Adapter & 24.7 \\
\hline
JT-S-MT + Dedicated Attention & 24.2 \\
\bottomrule
\end{tabular}
\caption{BLEU score for models with task dependent components}
\label{tab:task_dep_com}
\end{table}
\subsection{Impact on the MT Task}~\label{sec:expt_mt}
As shown in~\autoref{tab:ast}, training ST models with an auxiliary MT task improves the translation quality substantially. It may be interesting to examine the impact on the auxiliary task itself. We evaluate the MT model jointly trained with the ST task.
Results are shown in \autoref{tab:mt}. ``ST (JT Proposed)" in the first row corresponds to the best results obtained for the ST task. The detailed experimental setup is described in \autoref{sec:app}.
For reference, we also include the MT evaluation results from \textsc{MuST-C}~\cite{Gangi2019MuSTCAM} in the second row. All MT models (in the last 4 rows) take phoneme sequences as input instead of SentencePiece.
``MT" (row 3) shows the results from pretrained MT models on WMT. In the ``MT (Tuned)" row, the MT models pretrained on WMT are fine-tuned on the \textsc{MuST-C} datasets. The large improvements clearly show a domain mismatch between WMT and \textsc{MuST-C}. The MT models trained with WMT data are improved after fine-tuning, and they are comparable with the ones reported in ~\cite{Gangi2019MuSTCAM}, though the input token is in pronunciation form, which is more ambiguous than the corresponding SentencePiece unit.
``MT (JT)" and ``MT (JT Proposed)" are results from the co-trained MT models in ``JT" and ``JT Proposed" respectively.
After fine-tuning using both MuST-C (speech and text) and WMT (text only) training data, the auxiliary MT models perform better than the corresponding ST models.
The proposed techniques further improve the co-trained MT models by 0.7$\sim$1.6 BLEU. While this is a surprising result, we note that the dedicated MT models may be improved with better hyperparameter tuning. In conclusion, the results show the proposed methods are effective to unify two tasks into one model with minimal negative transfer effect.
\begin{table}[!tbp]
\centering
\small
\begin{tabular}{l|c|c|c}
\toprule
& EN-DE & EN-ES & EN-FR \\
\hline
ST (JT Proposed) & 26.8 & 31.0 & 37.4\\
\hline
MT~\cite{Gangi2019MuSTCAM} & 28.1 & 34.2 & 42.2 \\
\hline
MT & 25.4 & 27.7 & 33.5 \\
MT (Tuned) & 29.6 & 34.3 & 41.4 \\
\hline
MT (JT) & 28.9 & 33.9 & 41.6 \\
MT (JT Proposed) & 30.5 & 34.7 & 42.3 \\
\bottomrule
\end{tabular}
\caption{ Comparison between ST and MT. }\label{tab:mt}
\end{table}
\section{Conclusions}
In this study, we focus on understanding the interactions between the ST and MT tasks under the MTL framework, and on boosting the performance of the primary ST model with the auxiliary MT task. Two types of analysis on model variation and modality variation, are conducted on the MTL models. The analysis demonstrates MTL helps to preserve information from the MT task and generates similar model representations for different modalities. We observe a minimal negative transfer effect between the two tasks. Sharing more parameters can further boost the information transfer from the MT task to the ST model.
The analysis also reveals that the model representation difference due to modality difference is nontrivial, especially for the top decoder layers, which are critical for the translation performance.
Inspired by the findings, we propose three techniques to increase knowledge transfer from the MT task to the ST task. These techniques include parameter sharing and initialization strategy to improve the information sharing between tasks, CAR and online KD to encourage the ST system to learn more from the auxiliary MT task and then generate similar model representations from different modalities.
Our results show that the proposed methods improve translation performance and achieve state-of--the-art results on three \textsc{MuST-C} language pairs.
| {'timestamp': '2021-07-14T02:06:51', 'yymm': '2107', 'arxiv_id': '2107.05782', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05782'} | arxiv |
\section{Introduction}
Dilations and erosions are the elementary operations of mathematical morphology, a non-linear theory widely used for image processing and analysis \cite{heijmans_mathematical_1995,soille_morphological_1999}. In the middle 1990s, Ritter et al. proposed the first morphological neural networks whose processing units, the neurons, perform dilations and erosions \cite{ritter96c,Ritter1998MorphologicalMemories}. In general terms, morphological neurons are obtained by replacing the usual dot product with either the maximum of sums or the minimum of sums. Because of the maximum and minimum operations, morphological neural networks are usually cheaper than traditional models. However, training morphological neural networks are often a big challenge because of the non-differentiability of the extreme operations \cite{pessoa00}. This paper addresses this issue by investigating different methods for training a hybrid morphological neural network for regression tasks. Precisely, we focus on training algorithms for the so-called linear dilation-erosion perceptron.
A dilation-erosion perceptron (DEP) is a hybrid morphological neural network obtained by a convex combination of dilations and erosions \cite{de_a_araujo_class_2011}. Despite its application in regression tasks such as time-series prediction and software development cost estimation \cite{de_a_araujo_class_2011,Araujo2012AnEstimation}, the DEP model has an inherent drawback: As an increasing operator, it implicitly assumes an ordering relationship between inputs and outputs \cite{valle_reduced_2020}. Fortunately, one can circumvent this problem by adding neurons that perform anti-dilations and anti-erosions \cite{sussner_morphological_2011}. For example, considering the importance of dendritic structures, Ritter and Urcid presented a single morphological neuron that circumvents the limitations of the DEP model \cite{ritter_lattice_2003}.
Alternatively, Valle recently proposed the reduced dilation-erosion perceptron (r-DEP) using concepts from multi-valued mathematical morphology \cite{valle_reduced_2020}. In few words, an r-DEP is obtained by composing an appropriate transformation with the DEP model, i.e., the inputs are transformed before they are fed to the DEP model. However, choosing the proper transformation is the most challenging task to design an efficient r-DEP model. As a solution, Oliveira and Valle recently proposed the so-called linear dilation-erosion perceptron ($\ell$-DEP) by considering linear mappings instead of arbitrary transformations \cite{oliveira_linear_2021}. Interestingly, the linear dilation-erosion perceptron is equivalent to a maxout network investigated by Goodfellow et al \cite{goodfellow_maxout_2013}. Also, the $\ell$-DEP is closely related to one of two hybrid morphological neural networks investigated by Hernández et al. for big data classification \cite{Hernandez2020HybridClassification}. From a mathematical point of view, the $\ell$-DEP yields a continuous piecewise linear function. Thus, like many traditional neural networks, they are universal approximators; that is, an $\ell$-DEP model can approximate a continuous function within any desired accuracy in a compact region in a Euclidean space \cite{wang_general_2004}.
As pointed out in the previous paragraph, the $\ell$-DEP is equivalent to the maxout network. Like traditional neural networks, maxout networks are usually trained using the stochastic gradient descent (SGD) method \cite{goodfellow_maxout_2013,goodfellow16book}. Henández et al. also used the SDG method for training their hybrid morphological neural networks \cite{Hernandez2020HybridClassification}. In contrast to the works mentioned above, Ho et al. formulated the learning of a continuous piecewise linear function as a difference of convex (DC) programming problem \cite{ho_dca_2020,ho_dca-based_2021}. This paper revises the difference of convex algorithm (DCA) applied for training the $\ell$-DEP model for regression tasks. Apart from the SDG and DCA-based learning rules, we also formulate the training of an $\ell$-DEP model as a disciplined convex-concave procedure (DCCP) \cite{shen_disciplined_2016}. We evaluate and compare the performance of the resulting $\ell$-DEP model using several regression tasks.
The paper is organized as follows. The following section reviews some basic concepts regarding DC optimization, including definitions and properties of convex functions and DC functions. Section \ref{sec:lder} presents the $\ell$-DER model, while three different approaches for training this model are addressed in Section \ref{sec:approaches}. Computational experiments comparing the performance of the $\ell$-DER model trained using the three approaches are given in Section \ref{sec:experiments}. The paper finishes with some remarks in Section \ref{sec:concluding}.
\section{Basic Concepts on DC Optimization}\label{sec:basic}
DC optimization aims to optimize the difference of two convex functions, a broad class of non-convex functions that enjoy interesting and useful properties \cite{hartman_functions_1959,tuy_dc_2016}. As remarked by Shen et al. \cite{shen_disciplined_2016}, applications of DC programs include signal processing, machine learning, computer vision, and statistics. The following presents the concepts of DC functions. We subsequently address the two kinds of DC optimization problems considered in this paper.
\begin{definition}[DC function]
Let $ f: \mathcal{C} \rightarrow \mathds{R} $ be a real-valued function defined in a convex set $ \mathcal{C} $. We say that $f$ is a DC function in $ \mathcal{C}$ if there exist convex functions ${g, h: \mathcal{C} \rightarrow \mathds{ R}} $ such that $f$ can be expressed as
\begin{equation}
f(\boldsymbol{\alpha}) = g(\boldsymbol{\alpha}) - h(\boldsymbol{\alpha}), \quad \forall \alpha \in \mathcal{C}.
\end{equation}
\end{definition}
Writing $f {\,\coloneqq\,} g - h$ is called the DC decomposition of $f$ and the functions $g$ and $h$ are referred to as the DC components of $f$.
DC optimization problems are problems in which the objective and constraints are described by DC functions. In this paper, we focus on the following two DC optimization problems: Unconstrained DC optimization problem formulated as
\begin{equation}\label{eq:dcap}
\mathop{\text{minimize}}_{\boldsymbol{\alpha} \in \mathds{R}^n} f(\boldsymbol{\alpha}) = g(\boldsymbol{\alpha})-h(\boldsymbol{\alpha}),
\end{equation}
and constrained DC optimization problem given by
\begin{equation}\label{eq:dccp}
\mathop{\text{minimize}}_{\boldsymbol{\alpha} \in \mathds{R}^n} f(\boldsymbol{\alpha}) = g(\boldsymbol{\alpha})-h(\boldsymbol{\alpha}) \quad \text{s.t.} \quad F(\alpha) = G(\boldsymbol{\alpha})-H(\boldsymbol{\alpha}) \le 0,
\end{equation}
where $g:\mathds{R}^n \to \mathds{R}$, $h:\mathds{R}^n \to \mathds{R}$, $G:\mathds{R}^n \to \mathds{R}^m$, and $H:\mathds{R}^n \to \mathds{R}^m$ are all convex functions. In this paper, we consider two methods for solving DC optimization problems. The first, which solves the unconstrained DC problem \eqref{eq:dcap}, is the difference of convex optimization algorithm (DCA). The second, which solves the constrained problem \eqref{eq:dccp}, is called disciplined convex-concave program (DCCP). In general terms, DC optimization methods takes advantage of the convexity of the DC components $g$ and $h$ of $f$. Thus,
before addressing these methods, let us review some important properties of convex functions.
\subsection{Some Properties of Convex Functions}
We begin by reviewing the concepts of subgradient and sub-differentiability. Subgradients, which generalize the notion of gradients, are well-defined even for non-smooth convex functions.
\begin{definition}[Subgradient and Subdiferential]
Let $ f: \mathcal{C} \subset \mathds{R}^n \rightarrow \bar{\mathds{R}} $ be a convex function. A subgradient of the $f$ at $\boldsymbol{\alpha}\in \mathcal{C}$ is a vector $\boldsymbol{\beta} \in \mathds{R}^n$ such that
\begin{equation}
\label{eq:subgradient}
f({\bf z}) \ge f(\boldsymbol{\alpha}) + {\langle} \boldsymbol{\beta}, {\bf z} -\boldsymbol{\alpha}{\rangle}, \, \, \forall {\bf z} \in \mathcal{C}^n. \end{equation}
The set of all subgradients of $f$ at $\boldsymbol{\alpha}$, denoted by $ \partial f(\boldsymbol{\alpha})$, is called the subdifferential of $f$ in $\boldsymbol{\alpha}$. Formally, the subdifferential of $f$ at $\boldsymbol{\alpha}$ is
\begin{equation}
\partial f(\boldsymbol{\alpha}): = \{\boldsymbol{\beta} \in \mathds{R}^n; f({\bf z}) \ge f(\boldsymbol{\alpha}) + {\langle} \boldsymbol{\beta}, {\bf z}-\boldsymbol{\alpha}{\rangle}, \, \, \forall {\bf z} \in \mathds{R}^n \}.
\end{equation}
\end{definition}
From \eqref{eq:subgradient}, for any $\boldsymbol{\beta} \in \partial f(\boldsymbol{\alpha})$, the affine function defined by $\ell({\bf z}):=f(\boldsymbol{\alpha}) + {\langle} \boldsymbol{\beta},{\bf z}-\boldsymbol{\alpha}{\rangle}$ for all $\boldsymbol{z} \in \mathds{R}^n$ is a lower approximation of $f$ at $\boldsymbol{\alpha}$. Geometrically, $\ell$ determines a hyperplane tangent to the convex function $f$ in $\boldsymbol{\alpha}$. Moreover, then the graph of $f$ is always above the graph of $\ell$, i.e., the tangent plane.
Finding subgradients of a convex function may not be an easy task. Hopefully, some results facilitate the determination of subgradients. For example, Frechel-Young inequality yields an efficient way to find subgradients of a broad class of convex functions. To present the Frechel-Young inequality, we need a few more concepts.
\begin{definition}[Proper Function]
Let $f:\mathds{R}^n\rightarrow\bar{\mathds{R}}$ be a convex function. We say that $f$ is a proper function if $f$ assumes at least a finite value and does not assume any value equal to $-\infty$. In other words, $f(\boldsymbol{\alpha})<+\infty$ for some $\boldsymbol{\alpha}\in\mathcal{C}$ and $f(\boldsymbol{\alpha})>-\infty$ for all $\boldsymbol{\alpha}\in\mathcal{C}$.
\end{definition}
\begin{definition}[Conjugate Function]
Given a function $ {f:\mathds{R}^n\rightarrow\bar{\mathds{R}}}$,
its conjugate is the function $f^*:\mathds{R}^n\rightarrow\bar{\mathds{R}}$ defined by
\begin{equation}
f^*(\boldsymbol{\beta})=\sup_{\boldsymbol{\alpha}\in\mathds{R}^n}\{{\langle}\boldsymbol{\alpha},\boldsymbol{\beta}{\rangle}-f(\boldsymbol{\alpha})\},\,\,\forall\boldsymbol{\beta}\in\mathds{R}^n.
\end{equation}
\end{definition}
\begin{definition}[Lower Semicontinuous Functions]
A convex function $f : \mathds{R}^n \rightarrow \mathds{R}\cup\{ +\infty\}$ is lower semicontinuous (lsc) function if $f^{**}=f$.
\end{definition}
The space of all proper and lower semicontinuous functions on $\mathcal{C}$ is denoted by $\Gamma_0(\mathcal{C})$.
\begin{proposition}{\bf(Fenchel-Young Inequality)}
If $f \in \Gamma_0(\mathcal{C})$, that is, $f$ is a proper lsc function, then
\begin{equation}
h(\boldsymbol{\alpha})+h^*(\boldsymbol{\beta}) \ge {\langle}\boldsymbol{\alpha},\boldsymbol{\beta}{\rangle},
\end{equation}
any $\boldsymbol{\beta}\in \mathds{R}^n$ and $\boldsymbol{\alpha}\in\mathcal{C}$. Moreover, the equality holds if and only if $\boldsymbol{\beta} \in \partial f(\boldsymbol{\alpha})$.
\end{proposition}
The Fenchel-Young equality result is known as the conjugate subgradient theorem. The conjugate subgradient theorem is used to find a subgradient of a function $f \in \Gamma_0(\mathcal{C})$.
\subsection{Difference of Convex Optimization Algorithm}
In \cite{tao_duality_1988}, Pham Dinh Tao introduced DCA by extending the gradient algorithm used for convex maximization to DC programming. Since 1994, with the joint work of Le Thi Hoai An and Pham Dinh Tao, the DCA algorithm has been developed and improved, both in theoretical and computational aspects. In general terms, the DCA is a subgradient optimization method used to solve unconstrained DC optimization problems. Furthermore, it is based on local optimization and dual DC programming.
Consider a proper unconstrained DC problem given by \eqref{eq:dcap} that can also be alternatively written as
\begin{equation}\label{eq:lambdaP}
\inf_{\boldsymbol{\alpha} \in \mathbb {R}^n} \{f(\boldsymbol{\alpha})=g(\boldsymbol{\alpha})-h(\boldsymbol{\alpha})\},
\end{equation}
where $g,h\in\Gamma_0(\mathds{R}^n)$. We would like to point out that \eqref{eq:lambdaP} is the standard form of a primal DC programming problem. The standard form of the dual DC programming problem for \eqref{eq:lambdaP} is given by the following DC problem
\begin{equation}\label{eq:lambdaD}
\inf_{\boldsymbol{\beta} \in\mathds{R}^n} \{f^*(\boldsymbol{\beta}) = h^*(\boldsymbol{\beta}) - g^*(\boldsymbol{\beta}) \},
\end{equation}
Let $\lambda$ and $\lambda^*$ the values of the solutions of the problems \eqref{eq:lambdaD} and \eqref{eq:lambdaP}. It is easy to show that $\lambda = \lambda^*$. In other words, solving problem \eqref{eq:lambdaP} is equivalent to solving problem \eqref{eq:lambdaD}.
The DCA algorithm can be used to solve both the primal and dual problems. In order to introduce the DCA algorithm, let $\boldsymbol{\alpha}_k$ be a convergent sequence and its $\boldsymbol{\alpha}^*$ its limit, that is, $\boldsymbol{\alpha}_k \rightarrow \boldsymbol{\alpha}^*$. Since $h\in\Gamma_0(\mathds{R}^n)$ and exists a bounded sequence $\boldsymbol{\beta}_k \in \partial h(\boldsymbol{\alpha}_k)\neq \emptyset$, then $\lim_{\boldsymbol{\alpha}_k\rightarrow\infty} h(\boldsymbol{\alpha}_k) = h(\boldsymbol{\alpha}^*)$. This result is the key concept for the formulation of the DCA method described by Algorithm \ref{alg:DCAc}.
\begin{algorithm}[t]
\KwInput{Convex functions: $g,f$}
\KwOutput{$\boldsymbol{\alpha}^*,\boldsymbol{\beta}^*$ (Primal and Dual solution)}
\textbf{Initialize:} $\boldsymbol{\alpha}_0\in \mathds{R}^n$\\
$k=0$\\
\Repeat{converge}{
Compute $\boldsymbol{\beta}_k \in\partial h(\boldsymbol{\alpha}_k)$\\
Compute $\boldsymbol{\alpha}_{k+1} \in\partial g^*(\boldsymbol{\beta}_k)$\\
$k = k+1$}
\Return{$\boldsymbol{\alpha}^*={\bf x}_{k}$ and $\boldsymbol{\beta}^*=\boldsymbol{\beta}_{k-1}$}
\caption{\textsc{DCA}}
\label{alg:DCAc}
\end{algorithm}
In general terms, the Algorithm \ref{alg:DCAc} seeks to find two convergent sequences $\{\boldsymbol{\alpha}_k\}$ and $\{\boldsymbol{\beta}_k\}$ such that their accumulation points are approximations for the local solutions of the primal and dual problems, respectively. In other words, the algorithm yields two sequences $\{\boldsymbol{\alpha}_k\}$ and $\{\boldsymbol{\beta}_k\}$ such that $\{f_k=f(\boldsymbol{\alpha}_k)\}$ and $\{f^*_k=f^*(\boldsymbol{\beta}_k)\}$ are both decreasing sequences.
One of the challenges of in Algorithm \ref{alg:DCAc} is to find the subgradients ${\boldsymbol{\beta}_k\in\partial h(\boldsymbol{\alpha}_k)}$ and ${\boldsymbol{\alpha}_{k+1}\in\partial g^*(\boldsymbol{\beta}_k)}$ in each iteration. Since solving the primal problem is equivalent to solving the dual problem, the choice of $\boldsymbol{\beta}_k$ will be arbitrary and the choice of $\boldsymbol{\alpha}_{k+1}$ will be given by solving an optimization problem. Since $g^{**}=g\in\Gamma_0(\mathcal{C})$, $\mathcal{C}\subset\mathds{R}^n$, from the conjugate subgradient theorem the following equivalences hold for any $k\in\mathds{N}$:
\begin{align*}
\boldsymbol{\alpha}_{k+1} \in\partial g^*(\boldsymbol{\beta}_k)&\Leftrightarrow g^*(\boldsymbol{\beta}_k)+g(\boldsymbol{\alpha}_{k+1})={\langle}\boldsymbol{\alpha}_{k+1},\boldsymbol{\beta}_k{\rangle}\\
&\Leftrightarrow \boldsymbol{\beta}_k \in\partial g(\boldsymbol{\alpha}_{k+1})\\
&\Leftrightarrow g(\boldsymbol{\alpha}_{k+1})-{\langle}\boldsymbol{\beta}_k,\boldsymbol{\alpha}_{k+1}{\rangle}\le g(\boldsymbol{\alpha})-{\langle}\boldsymbol{\beta}_k,\boldsymbol{\alpha}{\rangle},\forall\boldsymbol{\alpha}\in \mathcal{C}.
\end{align*}
Furthermore, the following identities hold:
\begin{align*}
\min_{\boldsymbol{\alpha}\in \mathcal{C}}\{g(\boldsymbol{\alpha})-{\langle}\boldsymbol{\beta}_k,\boldsymbol{\alpha}{\rangle}\}&=\min_{\boldsymbol{\alpha}\in \mathcal{C}}\{g(\boldsymbol{\alpha})-{\langle}\boldsymbol{\beta}_k,\boldsymbol{\alpha}{\rangle}-h(\boldsymbol{\alpha}_k)+{\langle}\boldsymbol{\beta}_k,\boldsymbol{\alpha}_k{\rangle}\} \\
&=\min_{\boldsymbol{\alpha}\in \mathcal{C}}\{g(\boldsymbol{\alpha})-[h(\boldsymbol{\alpha}_k)+{\langle}\boldsymbol{\beta}_k,\boldsymbol{\alpha}-\boldsymbol{\alpha}_k{\rangle}]\}.
\end{align*}
Therefore, the sequence $\boldsymbol{\alpha}_{k+1}$ can be found by solving the convex optimization problem given by
\begin{equation}\label{primalDCAk}
\boldsymbol{\alpha}_{k+1}=\argmin_{\boldsymbol{\alpha}\in \mathcal{C}} \{g(\boldsymbol{\alpha})-[h(\boldsymbol{\alpha}_k)+{\langle}\boldsymbol{\beta}_k,\boldsymbol{\alpha}-\boldsymbol{\alpha}_k{\rangle}]\}.
\end{equation}
The limit of the sequence $\{\boldsymbol{\alpha}_k\}$ is an approximation to the solution of the primal problem. The convergence analysis and other properties of Algorithm \ref{alg:DCAc} can be found in \cite{tao_duality_1988,dinh_convex_1997}.
\subsection{Disciplined Convex-Concave Programming}
Disciplined convex-concave programming (DCCP) refers to a methodology introduced by Shen et al. for solving the difference of convex problems \cite{shen_disciplined_2016}. In few words, DCCP combines concave-convex programming (CCP) \cite{yuille_concave-convex_2003} with disciplined convex programming (DCP), allowing the latter to deal with DC optimization problems. Let us briefly address some fundamental characteristics of the DCCP methodology. We begin by reviewing concave-convex programming.
Concave-convex programming is a majorization-minimization methodology that uses convex optimization tools to find local optimum for DC problems through of a sequence of convex subproblems \cite{yuille_concave-convex_2003,Grant2006DisciplinedProgramming}. The CCP methods can solve the non-convex problem whenever the objective and constraints are DC functions.
Consider the constrained DC problem given by \eqref{eq:dccp}.
Roughly speaking, a CCP method approximates the concave terms $-h$ in the objective and $-H$ in the constraints by convex majorant functions. Then, the resulting subproblem is a convex optimization problem that can be solved using convex optimization techniques.
In \cite{lipp_variations_2016} the authors introduced a variation of the CCP called penalty CCP, in which the convex majorant that approximates the concave terms are affine functions, that is, the functions $-h$ and $-H$ are approximated from below by affine functions. The penalty CCP method is presented described in Algorithm \eqref{alg:CCP} where the vector-valued functions $G,H:\mathds{R}^n\rightarrow \mathds{R}^m$ are written as $G(\boldsymbol{\alpha})=(g_1(\boldsymbol{\alpha}),...,g_m(\boldsymbol{\alpha}))$ and $H(\boldsymbol{\alpha})=(h_1(\boldsymbol{\alpha}),...,h_m(\boldsymbol{\alpha}))$. In Algorithm \eqref{alg:CCP}, the concave terms are explicitly linearized using subgradients. Moreover, to simplify the notation, the objective function is decomposed by $f = g_0 - h_0$, i.e., $g_0 =g$ and $h_0 = h$.
\begin{algorithm}
\KwInput{Convex functions: $g_0,\ldots,g_m$ and $f_0,\ldots,f_m$.}
\KwOutput{$\boldsymbol{\alpha}^*$ (Solution)}
\textbf{Initialize:} $\boldsymbol{\alpha}_0\in \mathds{R}^n$, $\mu>1$, $t_0>0$, $t_{max}>0$, and $k=0$.\\
\Repeat{converge}{
Compute $\boldsymbol{\beta}_i \in \partial h_i(\boldsymbol{\alpha}_k)$, for all $i=0,\ldots,m$. \\
Solve the convex problem:\\
$\quad $
$\begin{cases}
\boldsymbol{\alpha}_k = \mathop{\mbox{argmin}}_{\boldsymbol{\alpha}} & g_0(\boldsymbol{\alpha}) - h_0(\boldsymbol{\alpha}_k) - {\langle}\boldsymbol{\beta}_0,\boldsymbol{\alpha}-\boldsymbol{\alpha}_k{\rangle} + t_k\sum_{i=1}^ms_i\\
\qquad \qquad \mbox{s.t.} & g_i(\boldsymbol{\alpha}) \le h_i(\boldsymbol{\alpha}_k) + {\langle}\boldsymbol{\beta}_i,\boldsymbol{\alpha}-\boldsymbol{\alpha}_k{\rangle} + s_i, \quad \forall i=1,\ldots,m, \\
& s_i\ge0, \quad \forall i=1,\ldots,m.
\end{cases}$\\
$t_{k+1}=\min\{\mu t_k,t_{max}\}$\\
$k = k+1$}
\Return{$\boldsymbol{\alpha}^* = \boldsymbol{\alpha}_{k}$}
\caption{\textsc{Penalty CCP}}
\label{alg:CCP}
\end{algorithm}
As pointed out previously, DCCP is obtained including CCP in the disciplined convex programming (DCP) methodology \cite{Grant2006DisciplinedProgramming}. Briefly, DCP is a system of pre-established rules for constructing mathematical expressions with known curvatures widely used by convex optimization libraries such as \texttt{CVX}, \texttt{CVXPY}, and \texttt{Convex.jl} \cite{diamond_cvxpy_2016}. In mathematical terms, DCP deals with optimization problems of the following kind
\begin{equation}\label{eq:dcp}
\begin{tabular}{rl}
$\maxmin_{\boldsymbol{\alpha} \in \mathds{R}^n}$ & $f(\boldsymbol{\alpha})$\\
s.t. & $g_i(\boldsymbol{\alpha}) \sim h_i(\boldsymbol{\alpha}), \quad \forall i=1,\ldots,m$,
\end{tabular}
\end{equation}
where the curvature of the functions $f,g_1,...,g_m, h_1,...,h_m$ are known and the following statements must hold:
\begin{enumerate}
\item If \eqref{eq:dcp} is a minimization problem, then $f$ must be convex.
\item If \eqref{eq:dcp} is a maximization problem, then $f$ must be concave.
\item If $\sim$ equals $\leq$, $g_i$ must be convex and $h_i$ must be concave for all $i=1,\ldots,m$.
\item If $\sim$ equals $\geq$, $g_i$ must be concave and $h_i$ must be convex for all $i=1,\ldots,m$.
\item If $\sim$ equals $=$, then $g_i$ and $h_i$ must both be affine for all $i=1,\ldots,m$.
\end{enumerate}
The reference \cite{Grant2006DisciplinedProgramming} provides further details on disciplined convex programming.
Finally, a disciplined concave-convex programming (DCCP) problem is similar to \eqref{eq:dcp} but with some relaxed versions of the five statements listed above, which allows generalizing the use of DCP for DC problems. Like in DCP, the curvatures of the objective function and the constraints functions are previously known in a DCCP problem.
Knowing the curvatures, DCCP can cope with non-convex problems as long as the functions are written as DC functions in a disciplined way. Then, the Algorithm \ref{alg:CCP} is used to solve the DC problem.
\section{Linear Dilation-Erosion Regressor}\label{sec:lder}
Predictive classification models are used to categorize information based on a set of historical data. Predictive regression models are used to solve curve-fitting problems whose goal is to find a function that best fits a specific curve for a given set of data. This adjustment can be helpful in forecasts or estimates outside the data set.
Recently, \cite{oliveira_linear_2021} introduced the linear dilation-erosion perceptron ($\ell$-DEP) for classification tasks. A linear dilation-erosion perceptron is given by a convex combination of the composition of linear transformations and two elementary operators from mathematical morphology \cite{ritter96c,de_a_araujo_class_2011}. Let us review the main concepts from mathematical morphology and the $\ell$-DEP model. We will subsequently present the linear dilation-erosion regressor, the predictive model of the regression type corresponding to the $\ell$-DEP classifier.
Mathematical morphology is mainly concerned with non-linear operators defined on complete lattices \cite{heijmans_mathematical_1995,soille_morphological_1999}. Complete lattices are partially ordered sets with well-defined supremum and infimum operations \cite{birkhoff_lattice_1993}. Dilations and erosions are the elementary operators from mathematical morphology. Given complete lattices $\mathbb{L}$ and $\mathbb{M}$, a dilation $\delta:\mathbb{L} \to \mathbb{M}$ and an erosion ${\varepsilon:\mathbb{L} \to \mathbb{M}}$ are operators such that $\delta\left(\sup X\right)= \sup \{\delta({\bf x}):{\bf x} \in X\}$ and ${\varepsilon\left(\inf X\right)= \inf \{\varepsilon({\bf x}):{\bf x} \in X\}}$ for all $X \in \mathbb{L}$ \cite{heijmans_mathematical_1995}. For example, given vectors ${\bf a},{\bf b} \in \mathbb{R}^n$, the operators $\delta_{{\bf a}},\varepsilon_{{\bf b}}:\bar{\mathbb{R}}^n \to \bar{\mathbb{R}}$ given by
\begin{equation} \label{eq:erodil}
\delta_{{\bf a}}({\bf x})=\max_{j=1:n}\{a_j + x_j\} \quad \mbox{and} \quad \varepsilon_{{\bf b}}({\bf x})=\min_{j=1:n} \{b_j + x_j\},
\end{equation}
for all ${\bf x} \in\mathbb{\bar{R}}^n$ are respectively a dilation and an erosion \cite{sussner_morphological_2011}.
A dilation-erosion perceptron (DEP) is given by a convex combination of a dilation and an erosion defined by \eqref{eq:erodil}. The reduced dilation-erosion perceptron (r-DEP) proposed recently by Valle is an improved version of the DEP model obtained using concepts from vector-valued mathematical morphology \cite{valle_reduced_2020}. The $\ell$-DEP model is a particular but powerful r-DEP classifier \cite{oliveira_linear_2021}. Formally, given a one-to-one mapping $\sigma$ from the set of binary class labels $\mathbb{C}$ to $\{+1,-1\}$, a $\ell$-DEP classifier is defined by the equation $y=\sigma^{-1}f\tau^{\ell}({\bf x})$, where $f:\mathds{R}\to \{-1,+1\}$ is a threshold function and $\tau^{\ell}:\mathbb{R}^n \to \mathbb{R}$ is the decision function given by
\begin{align}\label{eq:tau-DC}
\tau^{\ell}({\bf x}) &= \delta_{{\bf a}}(W{\bf x}) - \delta_{{\bf b}}(M{\bf x}).
\end{align}
Equivalently, the decision function $\tau^{\ell}$ satisfies
\begin{align} \label{eq:tau-DC2}
\tau^{\ell}({\bf x}) &= \max_{i=1:r_1}\{{\bf w}_i^T{\bf x}+ a_i\} - \max_{j=1:r_2}\{{\bf m}_j^T{\bf x}+ b_j\},
\end{align}
where $\mathbf{a} = (a_1,\ldots,a_{r_1}) \in \mathbb{R}^{r_1}$ and $\mathbf{b} = (b_1,\ldots,b_{r_2}) \in \mathbb{R}^{r_2}$, and ${\bf w}_i^T$ and ${\bf m}_i^T$ are rows of $W \in \mathbb{R}^{r_1 \times n}$ and $M \in \mathbb{R}^{r_2 \times n}$, respectively. From the last identity, we can identify $\tau^{\ell}$ with a piece-wise linear function \cite{wang_general_2004}. Moreover, from Theorem 4.3 in \cite{goodfellow_maxout_2013}, the decision function $\tau^{\ell}$ is an universal approximator, i.e., it is able to approximate any continuous-valued function from a compact set on $\mathbb{R}^n$ to $\mathbb{R}$ \cite{goodfellow_maxout_2013,stone_generalized_1948}.
As a consequence, an $\ell$-DEP model can theoretically solve any binary classification problem.
Because the decision function of $\ell$-DEP model is a universal approximator, $\tau^\ell$ given by \eqref{eq:tau-DC} can also be used as a predictive model for regression tasks. In other words, it is possible to use the $\tau^{\ell}$ as the prediction function that maps a set of independent variables in $\mathds{R}^n$ to a dependent variable in $\mathds{R}$. In this case, we refer to $\tau^{\ell}:\mathds{R}^n \to \mathds{R}$ given by \eqref{eq:tau-DC} as a linear dilation-erosion regressor ($\ell$-DER). In this paper, the parameters $({\bf w}_i^T,a_i)\in\mathbb{R}^{n+1}$ and $({\bf m}_j^T,b_j)\in \mathbb{R}^{n+1}$, for $i=1:r_1$ and $j=1:r_2$, are determined
using a training set by minimizing the squares of the difference between the predicted and desired values. The following section address three different approaches for training an $\ell$-DER model.
\section{Three Approaches for Training $\ell$-DER Models}\label{sec:approaches}
In this section we present approaches for training an $\ell$-DER model using set ${\mathcal{T}=\{({\bf x}_i, y_i):i=1:m\}}\subset\mathds{R}^n \times \mathds{R}$, called the training set. Precisely, the goal is to find the parameters of an $\ell$-DER model such that the estimate $\tau^{\ell} ({\bf x}_i)$ approaches the desired output $y_i$ according to some loss function. Recall that the parameters of an $\ell$-DEP regressors are the matrices $W \in \mathbb{R}^{r_1 \times n}$ and $M \in \mathbb{R}^{r_2 \times n}$ as well as the vectors $\mathbf{a} = (a_1,\ldots,a_{r_1}) \in \mathbb{R}^{r_1}$ and $\mathbf{b} = (b_1,\ldots,b_{r_2}) \in \mathbb{R}^{r_2}$. To simplify the exposition, the parameters of an $\ell$-DER are also arranged in a vector
\begin{equation} \label{eq:alphav}
\boldsymbol{\alpha} = ({\bf w}^T_1,a_1,...,{\bf w}^T_{r_1},a_{r_1},{\bf m}^T_1,b_1,...,{\bf m}^T_{r_2},b_{r_2})\in\mathds{R}^{(r_1+r_2)(n+1)},
\end{equation}
where ${\bf w}_i^T$ and ${\bf m}_i^T$ are the rows of $W \in \mathbb{R}^{r_1 \times n}$ and $M \in \mathbb{R}^{r_2 \times n}$, respectively. During training, an $\ell$-DER is interpreted as a function of its parameters, that is, $\tau^\ell(\boldsymbol{x}) \equiv \tau^\ell(\boldsymbol{x};\boldsymbol{\alpha})$.
In this paper, the widely used mean squared error (MSE) defined as follows using the training set ${\mathcal{T}=\{({\bf x}_i, y_i):i=1,\ldots,m\}}\subset\mathds{R}^n \times \mathds{R}$:
\begin{equation}
MSE(\mathcal{T},\boldsymbol{\alpha})= \frac{1}{m}\sum_{i=1}^m (y_i-\tau^{\ell}({\bf x}_i;\boldsymbol{\alpha}))^2,
\end{equation}
is considered as the loss function.
As a consequence, the parameters of the $\ell$-DER are determined by solving the optimization problem
\begin{equation}\label{eq:mse}
\mathop{\mbox{minimize}}_{\boldsymbol{\alpha}} \frac{1}{m}\sum_{i=1}^m (y_i-\tau^{\ell}({\bf x}_i;\boldsymbol{\alpha}))^2.
\end{equation}
In the following subsections, we will present three approaches for solving \eqref{eq:mse}. The first two approaches deal with unconstrained optimization problems. Precisely, the first one applies an stochastic gradient descent (SGD) algorithm directly for solving \eqref{eq:mse} \cite{bottou_large-scale_2010}. The second approach, which has been proposed \cite{ho_dca-based_2021}, uses DCA. The last approach, inspired by the training of the $\ell$-DEP classifier \cite{oliveira_linear_2021}, uses DCCP for solving \eqref{eq:mse}.
\subsection{Approach Based on Stochastic Gradient Descent Method}
First of all, note that the $\ell$-DER model $\tau^\ell$ given by \eqref{eq:tau-DC} corresponds to a maxout network with two maxout units \cite{goodfellow_maxout_2013}. Like many modern neural networks, we may train an $\ell$-DER using the iterative method based on the descent gradient method. Precisely, we use the stochastic gradient descent (SGD) method to minimize \eqref{eq:mse}. At this point, we would like to recall that the SGD method uses gradients of the objective function at a point to find a local minimum of the loss function. Despite the maximum operation in $\tau^\ell$, the set of points where the loss function \eqref{eq:mse} is not differentiable has measure zero. In other words, the loss function is differentiable almost everywhere, and the non-differentiability of the maximum operation is usually not a problem for using this approach. The reader who wants to know more about the SGD method is encouraged reading \cite{bottou_large-scale_2010}.
Because SGD is implemented in machine learning libraries like \texttt{tensorflow} and \texttt{pytorch}, we believe this is the most straightforward procedure among the three approaches considered in this work. Therefore, let us turn our attention to the other two approaches.
\subsection{Approach Based on the Difference of Convex Algorithm}
Let us begin by noting that $\tau^{\ell}({\bf x})$ given by \eqref{eq:tau-DC} is a DC function because $\delta_{{\bf a}}(W{\bf x})$ and $\delta_{{\bf b}}(M{\bf x})$ are both convex functions.
In the following, we write the square of the difference $\tau^{\ell}({\bf x}_i;\boldsymbol{\alpha}) - y_i$ as a DC function for all $i=1,\ldots,m$.
Because there are infinite DC decompositions for a single DC function, it is possible to define a convex function $\phi_i$ such that
\begin{align*}
(\tau^{\ell}({\bf x}_i;\boldsymbol{\alpha}) - y_i)^2
&= (\tau^{\ell}({\bf x}_i;\boldsymbol{\alpha}) - y_i + \phi_i(\boldsymbol{\alpha}) - \phi_i(\boldsymbol{\alpha}))^2 \\
&= \big( (\delta_{{\bf a}}(W{\bf x}_i) - y_i + \phi_i(\boldsymbol{\alpha})) - (\phi_i(\boldsymbol{\alpha})+\delta_{{\bf b}}(M{\bf x}_i))\big)^2
\end{align*}
can be written as a DC function. From the identity $(x-y)^2 = 2(x^2+y^2)-(x+y)^2$, we conclude that
\begin{align*}
(\tau^{\ell}({\bf x}_i;\boldsymbol{\alpha}) - y_i)^2
&= 2\big((\tau_1({\bf x}_i;\boldsymbol{\alpha}) + \phi_i(\boldsymbol{\alpha}))^2+
(\phi_i(\boldsymbol{\alpha})+\tau_2({\bf x}_i;\boldsymbol{\alpha}))^2\big) \\
&\; - \big(\tau_1({\bf x}_i;\boldsymbol{\alpha}) + \tau_2({\bf x}_i;\boldsymbol{\alpha}) + 2 \phi_i(\boldsymbol{\alpha}) \big)^2
\end{align*}
where $\tau_1({\bf x}_i;\boldsymbol{\alpha})=\delta_{{\bf a}}(W{\bf x}_i)-y_i$ and $\tau_2({\bf x}_i;\boldsymbol{\alpha})=\delta_{{\bf b}}(M{\bf x}_i)$ are convex functions.
Thus, the mean squared error given by \eqref{eq:mse} admits a DC decomposition $MSE(\mathcal{T},\boldsymbol{\alpha})=G(\boldsymbol{\alpha}) - H(\boldsymbol{\alpha})$ where
\begin{align*}
G(\boldsymbol{\alpha}) &= \frac{2}{m}\sum_{i=1}^m\left[(\tau_1({\bf x}_i;\boldsymbol{\alpha})+\phi_i(\boldsymbol{\alpha}))^2 + (\tau_2({\bf x}_i;\boldsymbol{\alpha})+\phi_i(\boldsymbol{\alpha})^2\right], \\
H(\boldsymbol{\alpha}) &= \frac{1}{m}\sum_{i=1}^m[\tau_1({\bf x}_i;\boldsymbol{\alpha})
+\tau_2({\bf x}_i;\boldsymbol{\alpha})+2\phi_i(\boldsymbol{\alpha})]^2,
\end{align*}
with
\begin{equation}
\phi_i(\boldsymbol{\alpha})= \max\{\tau_1({\bf x}_i;\boldsymbol{\alpha}) + {\langle}\boldsymbol{\beta}_{i}^{1},\boldsymbol{\alpha}-\bar{\boldsymbol{\alpha}}{\rangle},\tau_2({\bf x}_i;\boldsymbol{\alpha}) + {\langle}\boldsymbol{\beta}_{i}^{2},\boldsymbol{\alpha}-\bar{\boldsymbol{\alpha}}{\rangle}\},
\end{equation}
for an arbitrary vector $\bar{\boldsymbol{\alpha}}\in\mathds{R}^{(r_1+r_2)(n+1)}$ and $\boldsymbol{\beta}_{i}^j \in \partial \tau_j(\bar{\boldsymbol{\alpha}};{\bf x}_i)$, $j=1,2$.
Because $MSE(T,\alpha)$ is a DC function, DCA can be used to minimize \eqref{eq:mse}.
As pointed out previously in Section \ref{sec:basic}, one of the challenges of the DCA algorithm is to find elements ${\boldsymbol{\beta}_t\in\partial H(\boldsymbol{\alpha}_t)}$ and ${\boldsymbol{\alpha}_{t+1}\in\partial G^*(\boldsymbol{\beta}_t)}$ in each iteration $t$. For training the $\ell$-DER, in particular, these elements are determined as follows: Let ${{\bf v}^{i,s}=({\bf v}^{i,s}_1,...,{\bf v}^{i,s}_{r_1+r_2})\in\mathds{R}^{(r_1+r_2)(n+1)}}$ for $i=1,\ldots,m$ and $s=1,\ldots,r_1+r_2$, where
\begin{equation}
{\bf v}^{i,s}_{k} = \begin{cases}
({\bf x}_i,1), & k=s,\\
({\bf 0},0), & \text{otherwise},
\end{cases}
\end{equation}
for $k=1,...,r_1+r_2$ and ${\bf 0}=(0,...,0)\in\mathds{R}^n$. Also, define ${\bf v}^i={\bf v}^{i,j_{i1}}-{\bf v}^{i,r_1+j_{i2}}$ where $$j_{i1}=\argmax_{j=1,\ldots,r_1}\{{\bf w}_j^T{\bf x}_i+ a_j\} \quad \mbox{and} \quad j_{i2}=\argmax_{j=1,\ldots,r_2}\{{\bf m}_j^T{\bf x}_i+ b_j\}.$$
Inspired by \cite{ho_dca-based_2021}, the choice of ${\boldsymbol{\beta}_t\in\partial H(\boldsymbol{\alpha}_t)}$ will be given by \begin{equation}
\boldsymbol{\beta}_t=2\sum_{i=1}^m(\tau^{\ell}({\bf x}_i;\boldsymbol{\alpha}_t)-y_i){\bf v}^i\in\mathds{R}^{(r_1+r_2)(n+1)}.
\end{equation}
From the properties of the conjugate functions, $\boldsymbol{\alpha}_{t+1}\in\partial G^*(\boldsymbol{\beta}_t)$ is obtained by solving the quadratic optimization problem
\begin{align*}
\mathop{\mbox{minimize }}_{\boldsymbol{\alpha},\boldsymbol{q},\boldsymbol{p}} & \|{\mbox{\boldmath$q$}}\|_2^2+\|{\mbox{\boldmath$p$}}\|_2^2 - {\langle}\boldsymbol{\beta}_t,\boldsymbol{\alpha}{\rangle} & \\
\mbox{s.t.} & {\langle} {\bf v}^{i,l} -{\bf v}^{i, j_{i1}},\boldsymbol{\alpha}{\rangle} \le q_i,& l=1,\ldots,r_1,\quad i=1,\ldots,m,\\
& {\langle} {\bf v}^{i,l} -{\bf v}^{i,r_1+j_{i1}},\boldsymbol{\alpha}{\rangle}\le q_i+y_i,& l=1,\ldots,r_1,\quad i=1,\ldots,m,\\
& {\langle} {\bf v}^{i,r_1+l}-{\bf v}^{i,j_{i2} },\boldsymbol{\alpha}{\rangle}\le p_i-y_i,& l=1,\ldots,r_2,\quad i=1,\ldots,m,\\
& {\langle} {\bf v}^{i,r_1+l}-{\bf v}^{i,r_1+j_{i2}},\boldsymbol{\alpha}{\rangle} \le p_i,& l=1,\ldots,r_2,\quad i=1,\ldots,m.
\end{align*}
The stopping criterion of DCA used for training the $\ell$-DER is $|MSE(\mathcal{T},\boldsymbol{\alpha}_t) - MSE(\mathcal{T},\boldsymbol{\alpha}_{t - 1}) |\le \epsilon (1 + MSE(\mathcal{T},\boldsymbol{\alpha}_{t - 1})),$ with $\epsilon=10^{-6}$.
\subsection{Approach Based on Disciplined Convex-Concave Programming}
Inspired by methodology developed by Charisopoulos and Maragos for training morphological perceptrons \cite{charisopoulos_morphological_2017}, we will reformulate the unrestricted optimization problem \eqref{eq:mse} as a constrained DC problem. Precisely, let $\xi_i = y_i-\tau^{\ell}({\bf x}_i)$, for $k=1, \ldots, m$. Then, the unrestricted problem \eqref{eq:mse} corresponds to minimizing $\frac{1}{m}\|{\boldsymbol{\xi}}\|_2^2
$ subject to the constraints $\tau^{\ell}({\bf x}_i) = y_i-\xi_i$ for all $i=1,\ldots,m$. In other words, the $\ell$-DER can be trained by solving the following DCCP problem
\begin{equation} \label{eq:DCCP}
\begin{cases}
\mathop{\mbox{minimize}}_{W,{\bf a},M,{\bf b},\boldsymbol{\xi}} & \frac{1}{m}\|{\boldsymbol{\xi}}\|_2^2 \\
\mbox{s.t.} & \delta_{{\bf a}}(W{\bf x}_i) + \xi_i= \delta_{{\bf b}}(M{\bf x}_i) + y_i, \quad i=1,...m.
\end{cases}
\end{equation}
Note that the objective function in \eqref{eq:DCCP} is a convex quadratic function. Moreover, the functions at both sides of the equality constraints have known concavity; they are convex functions. Therefore, the optimization problem \eqref{eq:DCCP} can be solved using Algorithm \ref{alg:CCP}.
\section{Computational Experiments}\label{sec:experiments}
Let us briefly evaluate the performance of the proposed $\ell$-DER model on several regression datasets from the Penn Machine Learning Benchmarks (PMLB), a significant benchmark suite for machine learning evaluation and comparison \cite{olson_pmlb_2017}. The chosen datasets have small or medium sizes. For simplicity, we fixed the parameters $r_1 = r_2 = 10$ of the {$\ell$-DER} models for all datasets.
We compared the performance of the $\ell$-DER model trained using the three approaches described in the previous section. The $\ell$-DER trained using the SGD method has implemented using the \texttt{TensorFlow API} (TF). Precisely, because $\ell$-DER is equivalent to a maxout network \cite{goodfellow_maxout_2013}, we used \texttt{tensorflow-addons}, which provides extra functionalities and include the maxout layers. For the other two approaches, we used the \texttt{CVXPY} package \cite{diamond_cvxpy_2016} with the \texttt{MOSEK} solver \cite{aps_mosek_2020}. For the DCCP problem, in particular, we used the DCCP extension for the \texttt{CVXPY} available at \url{https://github.com/cvxgrp/dccp}.
We would like to point out that we handled missing data using sklearn's \texttt{SimpleImputer()} command. Furthermore, we partitioned the data set into training and test sets using the sklearn's \texttt{StratifiedKFold()} command with $k=5$. Finally, we used the Mean Absolute Percentage Error (MAPE) to measure the performance of the regressor $\ell$-DER for each of the training approaches.
Table \ref{tab:score} contains the mean and the standard deviation of the MAPE obtained from the regressors using $5$-fold cross-validation. The boxplots shown in Figure \ref{fig:box_scores_times} summarizes the normalized scores depicted on this table as well as the execution time (in seconds) taken for training the regressors.
\begin{table}
\caption{Average and standard deviation of the MAPE Score.}
\begin{center}
\resizebox{\textwidth}{!}{
\scriptsize
\begin{tabular}{lr||c|c|c|c|c}
\toprule
Datasets (instances,features) && SGD & DCA & DCCP \\
\midrule
Analcatdata\_vehicle &(48,4) & 0.2750 $\pm$ 0.0495 & 0.2695 $\pm$ 0.0358 & \textbf{0.1570 $\pm$ 0.0529} \\
Bodyfat &(252,14) & 1.2e{\tiny +}14 $\pm$ 1.6e{\tiny +}14 & 5.5e{\tiny +}13 $\pm$ 3.2e{\tiny +}13 & \textbf{2.6e{\tiny +}13 $\pm$ 2.8e{\tiny +}13} \\
Cloud &(108,5) & 2.2e{\tiny +}12 $\pm$ 1.8e{\tiny +}12 & \textbf{1.2e{\tiny +}12 $\pm$ 1.0e{\tiny +}12} & 3.4e{\tiny +}12 $\pm$ 2.8e{\tiny +}12 \\
Elusage & (55,2) & 0.1875 $\pm$ 0.0361 & 0.2016 $\pm$ 0.0152 & \textbf{0.1452 $\pm$ 0.0143} \\
Pm10 & (500,7) & 0.2114 $\pm$ 0.0084 & 0.2444 $\pm$ 0.0156 & \textbf{0.1829 $\pm$ 0.0137} \\
Pollen &(3848,4) & 2.1041 $\pm$ 0.1791 & 2.0146 $\pm$ 0.1623 & \textbf{2.0117 $\pm$ 0.1660} \\
PwLinear & (200,10) & 1.0758 $\pm$ 0.2917 & 2.1620 $\pm$ 0.4312 & \textbf{0.3689 $\pm$ 0.0611} \\
Rabe\_266 & (120,2) & 0.0938 $\pm$ 0.0317 & 0.2630 $\pm$ 0.0587 & \textbf{0.0410 $\pm$ 0.0132} \\
Rmftsa\_ladata & (508,10) & 0.1427 $\pm$ 0.0097 & 0.1531 $\pm$ 0.0076 & \textbf{0.1099 $\pm$ 0.0025} \\
Sleuth\_ex1605 & (62,5) & 0.0482 $\pm$ 0.0077 & 0.0456 $\pm$ 0.0144 & \textbf{0.0179 $\pm$ 0.0076} \\
Vineyard & (52,2) & 0.0937 $\pm$ 0.0019 & 0.0949 $\pm$ 0.0035 & \textbf{0.0756 $\pm$ 0.0059} \\
Vinnie & (380,2) & 1.1e{\tiny +}14 $\pm$ 3.5e{\tiny +}13 & \textbf{1.0e{\tiny +}14 $\pm$ 2.4e{\tiny +}13} & 9.6e{\tiny +}13 $\pm$ 2.3e{\tiny +}13 \\
Visualizing\_environmental &(111,3) & 0.2278 $\pm$ 0.0127 & 0.2301 $\pm$ 0.0203 & \textbf{0.1856 $\pm$ 0.0209} \\
Visualizing\_galaxy & (323,4) & 0.0103 $\pm$ 0.0010 & 0.6026 $\pm$ 1.3183 & \textbf{0.0095 $\pm$ 0.0052} \\
\bottomrule
\end{tabular}
}
\end{center}
\label{tab:score}
\end{table}
\begin{figure}[h]
\centering
\includegraphics[width=.49\columnwidth]{BoxPlot_MAPE.pdf}
\includegraphics[width=.49\columnwidth]{BoxPlot_TimeLog.pdf}
\caption{ Boxplots of the normalized average MAPE score and average time required to train the $\ell$-DEP regressors.}
\label{fig:box_scores_times}
\end{figure}
As to the training execution time, the SGD is the fasted procedure. Despite its longer training time, the DCCP is not quite different from the SGD approach. The DCA proved to be slower than the other two approaches. Figure \ref{fig:box_scores_times} also provides a visual interpretation of the outcome of our computational experiment. Precisely, the boxplot on Figure \ref{fig:box_scores_times} has been obtained by normalizing the average MAPE scores produced by the three approaches for each dataset. From the boxplot depicted in Figure \ref{fig:box_scores_times}, the $\ell$-DER trained with the DCCP procedure achieved the best performance. The other two approaches proved to be competitive with each other. The non-parametric Wilcoxon hypothesis testing confirmed that the DCCP approach outperformed the other two approaches for training the $\ell$-DER, method with a confidence level of 95\%.
\section{Concluding Remarks}\label{sec:concluding}
This paper introduced the linear dilation-erosion regressor ($\ell$-DER), which is given by a convex combination of the composition of linear transformations and elementary morphological operators.
Precisely, an $\ell$-DER is defined by the DC function $\tau^{\ell}$ given by \eqref{eq:tau-DC}. Because $\tau^{\ell}$ is a continuous piecewise linear function, an $\ell$-DER is a universal approximator.
In this paper, we trained an $\ell$-DER model by minimizing the mean square error given by \eqref{eq:mse} using training set ${\mathcal{T}=\{({\bf x}_i, y_i):i=1:m\}}\subset\mathds{R}^n \times \mathds{R}$. Furthermore, we proposed to determine the parameters of the $\ell$-DER regressor $\tau^{\ell}$ using three different approaches. The first uses the SGD method, while the second approach is based on the DCA subgradient method. The third approach solves a constrained, disciplined convex-concave programming problem for training the $\ell$-DER. Both the methods using DCA and DCCP are DC optimization problems.
Finally, we compared the $\ell$-DER trained using three approaches using 13 regression tasks. According to the preliminary computational experiments, the DCCP-based approach yielded the best $\ell$-DER model in terms of the MAPE score. As to the training time, the SDG-based method outperformed the other two. In the future, we intend to investigate further the performance of the $\ell$-DER model. In particular, we plan to compare them with other machine learning models.
\bibliographystyle{splncs04}
| {'timestamp': '2021-07-14T02:01:58', 'yymm': '2107', 'arxiv_id': '2107.05682', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05682'} | arxiv |
\section{Introduction}
Error-correcting codes are among the most widely used tools and objects of study in information theory and theoretical computer science. The most common model of corruption that is studied in the TCS literature is that of errors or erasures. The model in which each symbol of the transmitted word is either replaced with a different symbol from the alphabet (an error) or with a `?' (an erasure). The theory of such codes began with the seminal work of Shannon, \cite{shannon1948mathematical}, who studied random errors and erasures and the work of Hamming \cite{hamming1950error} who studied the adversarial model for errors and erasures. These models are mostly well understood, and today we know efficiently encodable and decodable codes that are optimal for Shannon's model of random errors. For adversarial errors, we have optimal codes over large alphabets and good codes (codes of constant relative rate and relative distance) for every constant sized alphabet.
Another important model that has been considered ever since Shannon's work is that of \emph{synchronization} errors. These are errors that affect the length of the received word. The most common model for studying synchronization errors is the insertion-deletion model (insdel for short): an insertion error is when a new symbol is inserted between two symbols of the transmitted word. A deletion is when a symbol is removed from the transmitted word. For example, over the binary alphabet, when $100110$ is transmitted, we may receive the word $1101100$, which is obtained from two insertions ($1$ at the beginning and $0$ at the end) and one deletion (one of the $0$'s at the beginning of the transmitted word).
Observe that compared to the more common error model, if an adversary wishes to \emph{change} a symbol, then the cost is that of two operations - first deleting the symbol and then inserting a new one instead.
Insdel errors appear in diverse settings such as optical recording, semiconductor devices, integrated circuits, and synchronous digital communication networks. Another important example is the trace reconstruction problem, which has applications in computational biology and DNA-based storage systems \cite{bornholt2016dna,yazdi2017portable,heckel2019characterization}. See the surveys \cite{mitzenmacher2009survey,mercier2010survey} for a good picture of the problems and applications of error-correcting codes for the insdel model (insdel codes for short).
Reed-Solomon codes are the most widely used family of codes in theory and practice. Indeed, they have found many applications both in theory and in practice (their applications include QR codes \cite{soon2008qr}, secret sharing schemes \cite{mceliece1981sharing}, space transmission \cite{wicker1999reed}, encoding data on CDs \cite{wicker1999reed} and more. The ubiquity of these codes can be attributed to their simplicity as well as to their efficient encoding and decoding algorithms.
As such, it is an important problem to understand whether they can also decode from insdel errors. This problem received a lot of attention recently \cite{safavi2002traitor,wang2004deletion,tonien2007construction,duc2019explicit,liu20212,chen2021improved,liu2021bounds}, but besides very few constructions (i.e., evaluation points for Reed-Solomon codes), not much was known before our work. We discuss this line of work in more detail in Section~\ref{sec:prev-results}.
In this paper, we first prove that there are Reed-Solomon codes that achieve the half-Singleton bound. In other words, there are optimal Reed-Solomon codes also against insdel errors.
We also give a set of evaluation points that define a Reed-Solomon code that achieves this bound. As the field size that we get grows very fast, our construction runs in polynomial time only for very small values of $\delta$.
We also explicitly construct $2$-dimensional RS codes over a field size smaller than the previous known constructions.
Unfortunately, we could not develop efficient decoding algorithms for our Reed-Solomon constructions, and we leave this as an open problem for future research.
\subsection{Basic definitions and notation}
For an integer $k$, we denote $[k]=\{1,2,\ldots,k\}$.
Throughout this paper, $\log(x)$ refers to the base-$2$ logarithm. For a prime power $q$, we denote with $\mathbb{F}_q$ the field of size $q$.
We denote the $i$th symbol of a string $s$ (or of a vector $v$) as $s_i$ (equivalently $v_i$). Throughout this paper, we shall move freely between representations of vectors as strings and vice versa. Namely, we shall view each vector $v=(v_1, \ldots, v_n)\in \mathbb{F}_q^n$ also as a string by concatenating all the symbols of the vector into one string, i.e., $(v_1, \ldots, v_n) \leftrightarrow v_1 \circ v_2 \circ \ldots \circ v_n$. Thus, if we say that $s$ is a subsequence of some vector $v$, we mean that we view $v$ as a string and $s$ is a subsequence of that string.
An error correcting code of block length $n$ over an alphabet $\Sigma$ is a subset $\mathcal{C}\subseteq \Sigma^n$. The rate of $\mathcal{C}$ is $\frac{\log|\mathcal{C}|}{n\log|\Sigma|}$, which captures the amount of information encoded in every symbol of a codeword.
A linear code over a field $\mathbb{F}$ is a linear subspace $\mathcal{C}\subseteq \mathbb{F}^n$. The rate of a linear code $\mathcal{C}$ of block length $n$ is $\mathcal{R}=\dim(\mathcal{C})/n$. Every linear code of dimension $k$ can be described as the image of a linear map, which, abusing notation, we also denote with $\mathcal{C}$, i.e., $\mathcal{C} : \mathbb{F}^k \rightarrow \mathbb{F}^n$. Equivalently, a linear code $\mathcal{C}$ can be defined by a \emph{parity check matrix} $H$ such that $x\in\mathcal{C}$ if and only if $Hx=0$. When $\mathcal{C}\subseteq \mathbb{F}_q^n$ has dimension $k$ we say that it is an $[n,k]_q$ code. The minimal distance of $\mathcal{C}$ with respect to a metric $d(\cdot,\cdot)$ is defined as $\text{dist}_{\mathcal{C}}:= \min_{v\neq u \in \mathcal{C}}{d(v,u)}$.
Naturally, we would like the rate to be as large as possible, but there is an inherent tension between the rate of the code and the minimal distance (or the number of errors that a code can decode from).
In this work, we focus on codes against insertions and deletions.
\begin{defi}
Let $s$ be a string over the alphabet $\Sigma$. The operation in which we remove a symbol from $s$ is called a \emph{deletion} and the operation in which we place a new symbol from $\Sigma$ between two consecutive symbols in $s$, in the beginning, or at the end of $s$, is called an \emph{insertion}.
A \emph{substring} of $s$ is a string obtained by taking consecutive symbols from $s$.
A \emph{subsequence} of $s$ is a string obtained by removing some (possibly none) of the symbols in $s$.
\end{defi}
The relevant metric for such codes is the edit-distance that we define next.
\begin{defi}
Let $s,s'$ be strings over the alphabet $\Sigma$.
A \emph{longest common subsequence} between $s$ and $s'$, is a subsequence $s_\textup{sub}$ of both $s$ and $s'$, of maximal length. We denote by $ \textup{LCS}(s,s')$ the length of a longest common subsequence.\footnote{Note that a longest common subsequence may not be unique as there can be a number of subsequences of maximal length. For example in the strings $s=(1,0)$ and $s'=(0,1)$.}
The \emph{edit distance} between $s$ and $s'$, denoted by $\text{ED}(s,s')$, is the minimal number of insertions and deletions needed in order to turn $s$ into $s'$. One can verify that this measure indeed defines a metric (distance function).
\end{defi}
\begin{lemma}[See e.g. Lemma 12.1 in \cite{crochemore2003jewels}]\label{lem:lcs}
It holds that $\textup{ED}(s,s') = \left|s\right| + \left|s' \right| - 2 \textup{LCS}(s,s') $.
\end{lemma}
We next define Reed-Solomon codes (RS-codes from now on).
\begin{defi}[Reed-Solomon codes]
Let $\alpha_1, \alpha_2, \ldots, \alpha_n \in\mathbb{F}_q$ be distinct points in a finite field $\mathbb{F}_q$ of order $q\geq n$. For $k\leq n$ the $[n,k]_q$ RS-code
defined by the evaluation set $\{ \alpha_1, \ldots, \alpha_n \}$ is the set of codewords
\[
\left \lbrace c_f = \left( f(\alpha_1), \ldots, f(\alpha_n) \right) \mid f\in \mathbb{F}_q[x],\deg f < k \right \rbrace \;.
\]
\end{defi}
In words, a codeword of an $[n,k]_q$ RS-code is the evaluation vector of some polynomial of degree less than $k$ at $n$ predetermined distinct points.
It is well known (and easy to see) that the rate of $[n,k]_q$ RS-code is $k/n$ and the minimal distance, with respect to the Hamming metric, is $n-k+1$.
\subsection{Previous results}
\label{sec:prev-results}
Linear codes against worst-case insdel errors were recently studied by
Cheng, Guruswami, Haeupler, and Li \cite{cheng2020efficient}. Correcting an error in a preceding work, they proved that there are good linear codes against insdel errors.
\begin{thm}[Theorem 4.2 in \cite{cheng2020efficient}] \label{thm:random-code}
For any $\delta > 0$ and prime power $q$, there exists a family of linear codes over $\mathbb{F}_q$ that can correct up to $\delta n$ insertions and deletions, with rate $(1-\delta)/2 - h(\delta)/\log_2 (q)$.
\end{thm}
The proof of \Cref{thm:random-code} uses the probabilistic method, showing that, with high probability, a random linear map generates such code. Complementing their result, they proved that their construction is almost tight. Specifically, they provided the following upper bound, which they call ``half-Singleton bound,'' that holds over any field.
\begin{thm}[Half-Singleton bound: Corollary 5.1 in \cite{cheng2020efficient}]
Every linear insdel code which is capable of correcting a $\delta$ fraction of deletions has rate at most $(1-\delta)/2 + o(1)$.
\end{thm}
The performance of RS-codes against insdel errors was studied much earlier than the recent work of Cheng et al. \cite{cheng2020efficient}.
To the best of our knowledge, Safavi-Naini and Wang \cite{safavi2002traitor} were the first to study the performance of RS-codes against insdel errors. They gave an algebraic condition that is sufficient for an RS-code to correct from insdel errors, yet they did not provide any construction. In fact, in our work, we consider an almost identical algebraic condition, and by simply using the Schwartz-Zippel-Demillo-Lipton lemma, we prove that there are RS-codes that meet this condition and, in addition, achieve the half-Singleton bound. In particular, RS-codes are optimal for insdel errors (see discussion in \Cref{sec:rs-insdel}).
Wang, McAven, and Safavi-Naini \cite{wang2004deletion} constructed a $[5,2]$ RS-code capable of correcting a single deletion. Then, in \cite{tonien2007construction}, Tonien and Safavi-Naini constructed an $[n,k]$ generalized-RS-codes capable of correcting from $\log_{k+1} n - 1$ insdel errors. Similar to our results, they did not provide an efficient decoding algorithm.
In another line of work
Duc, Liu, Tjuawinata, and Xing \cite{duc2019explicit}, Liu and Tjuawinata \cite{liu20212}, Chen and Zhang \cite{chen2021improved}, and Liu and Xing \cite{liu2021bounds} studied the specific case of $2$-dimensional RS-codes.
In \cite{duc2019explicit,liu20212}, the authors presented constructions of $[n,2]$ RS-codes that for every $\varepsilon>0$ can correct from $(1-\varepsilon)\cdot n$ insdel errors, for codes of length $n=\poly(1/\varepsilon)$ over fields of size $\Omega(\exp((\log n)^{1/\varepsilon}))$ and $\Omega(\exp(n^{1/\varepsilon}))$, respectively. In \cite{duc2019explicit,chen2021improved}, the authors present constructions of two-dimensional RS-codes that can correct from $n-3$ insdel errors where the field size is exponential in $n$. After a draft of this work appeared online,
Liu and Xing \cite{liu2021bounds} constructed, using different approach than us, a two dimensional RS-codes over that can correct from $n-3$ insdel errors, over a field size $O(n^5)$. Specifically, they prove the following.
\begin{thm}\cite[Theorem 4.8]{liu2021bounds}
Let $n\geq 4$. If $q > \frac{n(n-1)^2(n-2)^2}{4}$, then there is an $[n,2]_q$ RS-code, constructed in polynomial time, that can decode from $n-3$ insdel errors.
\end{thm}
\subsection{Our results}
First, we prove that there are RS-codes that achieve the half-Singleton bound. Namely, they are optimal linear codes for insdel errors.
\begin{restatable}{thm}{rssz} \label{thm:rs-sz}
Let $k$ and $n$ be positive integers such that $2k - 1 \leq n$.
For $q = O(n^{4k-2})$ there exists
an $[n,k]_q$ RS-code defined by $n$ distinct evaluation points $\alpha_1, \ldots, \alpha_n\in\mathbb{F}_q$, that can recover from $n - 2k + 1$ adversarial insdel errors.
\end{restatable}
Observe that the constructed code achieves the half Singleton bound: its rate is $\mathcal{R} = k/n = (1-\delta)/2 + o(1)$ and $\delta=(n - 2k + 1)/n$.
\Cref{thm:rs-sz} is an existential result and does not give an explicit construction. Using ideas from number theory and algebra, we construct RS-codes that can decode from $n-2k+1$
adversarial insdel errors, in particular, they achieve the half-Singleton bound. Specifically,
\begin{restatable}{thm}{rsExpConst} \label{thm:rs-explicit-const}
Let $k$ and $n$ be positive integers, where $2k - 1 \leq n$. There is a deterministic construction of an $[n,k]_q$ RS-code that can correct from $n-2k+1$ insdel errors where $q = O\left(n^{k^2 \cdot ((2k)!)^2}\right)$. The construction runs in polynomial time for $k = O(\log(n)/\log(\log(n)))$.
\end{restatable}
We note that for $k = \omega(\log(n)/\log\log(n))$ the field size is $\exp(n^{\omega(1)})$ and in particular, there is no efficient way to represent arbitrary elements of $\mathbb{F}_q$ in this case.
As discussed before, special attention was given in the literature to the case of two dimensional RS-codes. By using Sidon spaces that were constructed in \cite{roth2017construction}, we explicitly construct a family of $[n,2]_q$ RS-codes that can decode from $n-3$ insdel errors for $q=O(n^4)$.
Besides improving on all previous constructions in terms of field size, our construction also requires a smaller field size than the one guaranteed by the randomized argument in \Cref{thm:rs-sz}. Such phenomena, where a deterministic algebraic construction outperforms the parameters obtained by a randomized construction, are scarce in coding theory and combinatorics.
Well-known examples are AG codes that outperform the GV-bound \cite{tsfasman1982modular} and constructions of extremal graphs with ``many'' edges that do not contain cycles of length $4$, $6$ or $10$ (see \cite{conlon}).
\begin{restatable}{thm}{rsTwoDimConst}
\label{thm:rs-twodim-const}
For any $n\geq 4$, there exists an explicit $[n,2]_{q}$ RS-code that can correct from $n - 3$ insdel errors, where $q = O(n^4)$.
\end{restatable}
We also prove a (very) weak lower bound on the field size.
\begin{restatable}{prop}{RSLowerBound}
\label{prop:lower-bound}
Any $[n,k]_q$ RS-code that can correct from $n - 2k +1$ worst case insdel errors must satisfy
\[q \geq \frac{1}{2} \cdot \left(\frac{n}{(2k-1)(k-1)}\right)^{\frac{2k-1}{k-1}} \;. \] \end{restatable}
While for large values of $k$, this bound is meaningless, it implies that when $k=2$, the field size must be $\Omega(n^3)$. Thus, the construction given in \Cref{thm:rs-twodim-const} is nearly optimal.
The gap between the field size in our construction and the one implied by the lower bound raises an interesting question: what is the minimal field size $q$ for which an optimal $[n,2]_q$ RS-code exists?
\subsection{Proof idea}
To show that RS-codes can be used against insdel errors, we first prove an algebraic condition that is sufficient for $n$ evaluation points to define an RS-code that can decode from insdel errors. This condition requires that a certain set of $n^{O(k)}$ matrices, determined by the evaluation points, must all have full rank. Then, a simple application of the Schwartz-Zippel-DeMilo-Lipton lemma \cite{DBLP:journals/jacm/Schwartz80,Zippel79,DBLP:journals/ipl/DemilloL78} implies the existence of good evaluation points over fields of size $n^{O(k)}$. To obtain a deterministic construction, we show that by going to much larger field size, one can find evaluation points satisfying the full-rank condition. While the field size needs to be of size roughly $\Omega(n^{k^k})$, we note that, for not too large values of $k$, it is of exponential size, and in this case, our construction runs in polynomial time. A key ingredient in the analysis of this construction is our use of the `abc theorem' for polynomials over finite fields \cite{vaserstein2003vanishing}.
For the case of $k=2$, we use a different idea that gives a better field size than the one implied by the probabilistic argument above. We do so by noting that in this case the full-rank condition can be expressed as the requirement that no two different triples of evaluation points $(x_1,x_2,x_3)$ and $(y_1,y_2,y_3)$ satisfy
\[
\frac{y_1 - y_2}{x_1 - x_2} = \frac{y_2 - y_3}{x_2 - x_3} \;.
\]
This condition is reminiscent of the condition behind the construction of Sidon spaces of \cite{roth2017construction}, and indeed, we build on their construction of Sidon spaces to define good evaluation points in a field of size $O(n^4)$.
\subsection{Organization}
The paper is organized as follows.
In \Cref{sec:rs-insdel}, we prove \Cref{thm:rs-sz}.
In \Cref{sec:det-any-k}, we prove \Cref{thm:rs-explicit-const}. Finally, in \Cref{sec:det-k-2}, we prove \Cref{thm:rs-twodim-const} and \Cref{prop:lower-bound}. \Cref{sec:open-que} is devoted to conclusion and open questions.
\section{Reed-Solomon codes achieving the half-Singleton bound}
\label{sec:rs-insdel}
In this section, we prove our results concerning RS-codes. Specifically, we prove that RS-codes achieve the half-Singleton bound and give some explicit constructions. The proofs will follow by standard analysis of the LCS between any two distinct codewords.
We begin by reformulating the condition on the maximum length of an LCS as an algebraic condition (invertibility of certain matrices). Then we show that an RS-code that satisfies this condition would have the maximum possible edit distance and hence would be able to decode from the maximum number of insdel errors.
We remark that a similar approach already appeared in \cite[Section 2.2]{safavi2002traitor} and we shall repeat some of the details here.
\subsection{An algebraic condition}
%
The following proposition is the main result of this section as it provides a sufficient condition for an RS-code to recover from the maximum number of insdel errors.
We first make the following definitions:
We say that a vector of indices $I\in [n]^s$ is an \emph{increasing} vector if its coordinates are monotonically increasing, i.e., for any $1\leq i<j\leq s$, $I_i<I_j$, where $I_i$ is the $i$th coordinate of $I$. For a codeword $c$ of length $n$ and an increasing vector $I$, let $c_I$ be the restriction of $c$ to the coordinates with indices in $I$, i.e., $c_I=(c_{I_1},\ldots,c_{I_s})$.
For two vectors $I,J\in [n]^{2k-1}$ with distinct coordinates we define the following (variant of a) vandermonde matrix of order $(2k-1)\times (2k-1)$ in the formal variables ${\bf X}=(X_1,\ldots,X_n)$:
\begin{equation} \label{eq:mat-lcs-eq}
V_{I,J}({\bf X})=\begin{pmatrix}
1 & X_{I_1} & \ldots & X_{I_1}^{k-1} & X_{J_1} &\ldots & X_{J_1}^{k-1} \\
1 & X_{I_2} & \ldots & X_{I_2}^{k-1} & X_{J_2} &\ldots & X_{J_2}^{k-1} \\
\vdots &\vdots & \ldots &\vdots &\vdots &\ldots &\vdots \\
1 & X_{I_{2k-1}} & \ldots & X_{I_{2k-1}}^{k-1} & X_{J_{2k-1}} &\ldots & X_{J_{2k-1}}^{k-1}\\
\end{pmatrix} .
\end{equation}
\begin{prop} \label{prop:cond-for-RS}
Consider the $[n,k]_q$ RS-code defined by an evaluation vector $\alpha=(\alpha_1,\ldots,\alpha_n)$.
If for every two increasing vectors $I,J\in [n]^{2k-1}$ that agree on at most $k-1$ coordinates, it holds that $\det(V_{I,J}(\alpha)) \neq 0$, then the code can correct any $n-2k+1$ insdel errors.
Moreover, if the code can correct any $n-2k+1$ insdel errors, then the only possible vectors in $\text{Kernel}\left(V_{I,J}(\alpha)\right)$ are of the form $(0,f_1,\ldots,f_{k-1},-f_1,\ldots,-f_{k-1})$.
\end{prop}
\begin{proof}
Assume that the claim does not hold; therefore, there exist two distinct codewords $c\neq c'$ whose LCS is at least $2k-1$, i.e.,
$c_I=c'_J$ for two increasing vectors $I,J\in [n]^{2k-1}$. Assume further that $c$ and $c'$ are the encodings of the degree $k-1$ polynomials $f=\sum_if_ix^i$ and $g=\sum_ig_ix^i$, respectively.
If $I_\ell=J_\ell$ for at least $k$ coordinates, then for every such $\ell$
$$f(\alpha_{I_\ell})=c_{I_\ell}=c'_{J_\ell}=g(\alpha_{I_\ell})\;.$$
Hence $f\equiv g$, in contradiction to the fact that $c\neq c'$. Thus, we can assume that $I,J$ agree on at most $k-1$ coordinates. In this case, $V_{I,J}(\alpha)$
is singular, since the vector $(f_0-g_0,f_1,\ldots,f_{k-1},-g_1,\ldots,-g_{k-1})^t$ is in its right kernel, which contradicts our assumption. From \Cref{lem:lcs} it follows that the code can correct $n-2k+1$ insdel errors.
\sloppy To prove the moreover part note that the argument above implies that if the code can correct any $n-2k+1$ insdel errors and $f\neq g$ then the vector $(f_0-g_0,f_1,\ldots,f_{k-1},-g_1,\ldots,g_{k-1})$ is not in the kernel.
\end{proof}
In \cite{safavi2002traitor} Safavi-Naini and Wang identified (almost) the same condition (see \Cref{rem:SNW} below) and used it in their construction of traitor tracing schemes. Interestingly, the later work of \cite{tonien2007construction}, which gave a construction of RS-codes capable of decoding from $\log_{k}(n+1)-1$ insdel errors, did not use this condition. In particular, as far as we know, prior to this work the condition in \Cref{prop:cond-for-RS} was not used in order to show the existence of optimal RS-codes.
The following remark explains the difference between \Cref{prop:cond-for-RS} and the condition in \cite{safavi2002traitor}.
\begin{remark}\label{rem:SNW}
The main difference between the condition presented in \cite{safavi2002traitor} and ours, is that they considered a $2k\times 2k$ matrix and a generalized RS-code. Given evaluation points $(\alpha_1,\ldots,\alpha_n)$ and a vector with nonzero coordinates $(v_1,\ldots,v_n)\in \mathbb{F}_q^n$, the generalized $[n,k]_q$ RS-code is defined as the set of all vectors $\left(v_1\cdot f(\alpha_1),\ldots,v_n\cdot f(\alpha_n)\right)$, such that $\deg(f)<k$. The matrix studied in \cite{safavi2002traitor} is:
\begin{equation} \label{eq:mat-SNW}
V_{I,J}^{v}({\bf X})=\begin{pmatrix}
v_{I_1} & v_{I_1}\cdot X_{I_1} & \ldots &v_{I_1}\cdot X_{I_1}^{k-1} & v_{J_1} & v_{J_1}\cdot X_{J_1} &\ldots &v_{J_1}\cdot X_{J_1}^{k-1} \\
v_{I_2} & v_{I_2}\cdot X_{I_2} & \ldots &v_{I_2}\cdot X_{I_2}^{k-1} & v_{J_2} & v_{J_2}\cdot X_{J_2} &\ldots &v_{J_2}\cdot X_{J_2}^{k-1} \\
\vdots &\vdots & \ldots& \ldots &\vdots &\vdots &\ldots &\vdots \\
v_{I_{2k}} &v_{I_{2k}}\cdot X_{I_{2k}} & \ldots &v_{I_{2k}}\cdot X_{I_{2k}}^{k-1} &v_{J_{2k}} &v_{J_{2k}}\cdot X_{J_{2k}} &\ldots &v_{J_{2k}}\cdot X_{J_{2k}}^{k-1}
\end{pmatrix} .
\end{equation}
In our matrix, we saved a coordinate (which leads to optimal codes) as we did not have two columns for the free terms of $f$ and $g$ (as defined in the proof). In contrast, the matrix \eqref{eq:mat-SNW} has a column for the free term of $f$ (the first) and a column for the free term of $g$ (the column $(v_{J_1},\ldots,v_{J_{2k}})$). This also leads to the requirement that $I$ and $J$ are of length $2k$ (they can still agree on at most $k-1$ indices).
\end{remark}
\subsection{Optimal Reed-Solomon codes exist}
\label{sec:randomized-const}
In this section, we show that over large enough fields, there exist RS-codes that attain the half-Singleton bound. Specifically, we show that there exist RS-codes that can decode from a $\delta$ fraction of insdel errors and have rate $\mathcal{R} = (1- \delta)/2 + o(1)$. For convenience, we repeat the statement of \Cref{thm:rs-sz}. \rssz*
For a vector $I$ and an element $a$, we write $a\in I$ if $a$ appears in one of the coordinates of $I$; otherwise, we write $a\notin I.$
\begin{lemma}
\label{best-lemma}
Let $s\geq 2$ be an integer and $I,J\in [n]^s$ two increasing vectors that do not agree on \emph{any} coordinate, i.e., $I_i\neq J_i$ for all $1\leq i\leq s$. Then, there are two distinct indices $i\neq j\in [s]$ such that $I_i\notin J$ and $J_j\notin I$.
\end{lemma}
\begin{proof}
W.l.o.g. assume that $I_1<J_1$. Since $J$ is an increasing vector, $I_1\notin J$. In addition, some coordinate among $\{J_1,\ldots,J_s\}$ does not appear in $\{I_2,\ldots,I_s\}$, and any such coordinate is clearly different from $I_1$.
\end{proof}
\begin{prop} \label{prop:formal-det}
Let $I,J\in [n]^{2k-1}$ be two increasing vectors that agree on at most $k-1$ coordinates.
Then, in the expansion of $\det(V_{I,J}({\bf X}))$ as a sum over permutations, there is a monomial that is obtained at exactly one of the $(2k-1)!$ different permutations. In particular, its coefficient is $\pm 1$, depending on the sign of its corresponding permutation. Consequently, $\det(V_{I,J}({\bf X}))\neq 0$.
\end{prop}
\begin{proof}
The result will follow by applying induction on $k$. For $k=1$, $V_{I,J}({\bf X})=1$ and the result follows. For the induction step, assume it holds for $k-1$, and we prove it for $k\geq 2$.
Consider two coordinates $i,j$, determined as follows. If $I$ and $J$ agree on some coordinate, say $j$, then we set $i$ to be such that $I_i\notin J$.
If they do not agree on any coordinate, then we let $i,j$ be the two coordinates guaranteed by Lemma \ref{best-lemma}.
Next, in the determinant expansion of $V_{I,J}$ as a sum of $(2k-1)!$ monomials, collect all the monomials that are divisible by $X_{I_i}^{k-1}X_{J_j}^{k-1}$, and write them together as
$$X_{I_i}^{k-1}X_{J_j}^{k-1}f({\bf X}),$$
for some polynomial $f$ in the variables $(X_\ell : \ell \in (I\setminus\{I_i\}) \cup (J\setminus\{J_j\}))$. Note that the choice of $i$ and $j$ guarantees that such monomials exist. Observe that any monomial in the determinant expansion of $V_{I,J}$ that is divisible by $X_{I_i}^{k-1}X_{J_j}^{k-1}$ must be obtained by picking the $(i,k)$ and the $(j,2k-1)$ entries in the matrix \eqref{eq:mat-lcs-eq}. Hence,
$f$ equals the determinant of the submatrix $V'_{I,J}$ obtained by removing rows $i, j$ and columns $k,2k-1$ from $V_{I,J}$. Note that $V'_{I,J}$ is a matrix satisfying the conditions of the claim: it is a $(2k-3)\times(2k-3)$ matrix defined by two increasing vectors of length $2k-3$ that agree on at most $k-2$ coordinates. Indeed, $i$ and $j$ were chosen so that by removing them we remove one agreement, if such existed.
Hence, by the induction hypothesis $\det(V'_{I,J})$ has a monomial $m$ (with a $\pm 1$ coefficient) that is uniquely obtained among the $(2k-3)!$ different monomials.
Therefore, $X_{I_i}^{k-1}X_{J_j}^{k-1}m$ is a monomial of $X_{I_i}^{k-1}X_{J_j}^{k-1}f$ with a $\pm 1$ coefficient. Since there is no other way to obtain this monomial in the determinant expansion of $V_{I,J}$, this monomial is uniquely obtained in $\det(V_{I,J})$, and the result follows.
\end{proof}
We proceed to prove \Cref{thm:rs-sz} by a standard application of the Schwartz-Zippel lemma.
\begin{proof}[Proof of \Cref{thm:rs-sz}]
Define
$$F({\bf X})=\prod_{i< j}(X_i-X_j)\prod_{I,J}\det(V_{I,J}({\bf X})),$$
where the second product runs over all possible pairs of increasing vectors that agree on no more than $k-1$ coordinates. Clearly, by \Cref{prop:formal-det}, $F({\bf X})$ is a nonzero polynomial in the ring
$ \mathbb{Z}[{\bf X}]$. Next, we make two observations regarding the polynomial $F$. First,
since there are $\binom{n}{2k-1}$ increasing vectors, and the degree of each $\det(V_{I,J}({\bf X}))$ is at most $k(k-1)$, it follows that
\[
\deg(F) \leq n^2 +\binom{n}{2k - 1} ^2 \cdot k(k-1) < n^{4k-2} \;.
\]
Second, as each $\det(V_{I,J}({\bf X}))$ is a nonzero polynomial with nonzero coefficients bounded in absolute values by $(2k-1)!$, the absolute value of any nonzero coefficients of $F$ is at most
\[
((2k-1)!)^{\binom{n}{2k-1}^2}\leq ((2k-1)!)^{\frac{n^{4k-2}}{((2k-1)!)^2}} < e^{n^{4k-2}}.
\]
We claim that there is a prime $q$ in the range $[n^{4k-2},2n^{4k-2}]$ that does not divide at least one of the nonzero coefficients of the polynomial $F$. Indeed, consider a nonzero coefficient of $F$, and assume towards a contradiction that it is divisible by all such primes. Then, by the growth rate of the primorial function, the absolute value of the coefficient is $\Omega(e^{n^{4k-2}(1+o(1))})$, in contradiction.
Now, it is easy to verify that $F$ is also a nonzero polynomial in $\mathbb{F}_q[{\bf X}]$, since the monomial whose nonzero coefficient is not divisible by $q$ does not vanish. Therefore, by the Schwarz-Zippel-Demillo-Lipton lemma, there is an assignment $\alpha=(\alpha_1,\ldots,\alpha_n)$ to ${\bf X}$ for which $F(\alpha)\neq 0 \mod q$.
This assignment clearly corresponds to $n$ \emph{distinct} evaluation points, which by \Cref{prop:cond-for-RS}, define an $[n,k]_q$ RS-code
that can correct any $n-2k+1$ worst-case insdel errors, as claimed.
%
\end{proof}
We remark again that \Cref{thm:rs-sz} merely shows the existence of $[n,k]_q$ RS-codes that can decode from the maximum number of insdel errors over a field of size $q=O\left(n^{4k-2}\right)$.
Further, the above argument is a standard union bound over all variable assignments that make the matrix defined in \eqref{eq:mat-lcs-eq} to be singular. This by no means implies that such a large finite field is necessary. For example, a similar union-bound argument that shows the existence of MDS codes would require an exponentially large field for codes with a constant rate. In contrast, it is well-known that MDS codes over linear field size exist (e.g., RS-codes). It would be interesting to explicitly construct codes with the same or even better parameters than the ones given in \Cref{thm:rs-sz}.
Unfortunately, we could not construct such codes, and this is left as an open question for further research.
Nonetheless, in the next section, we provide a deterministic construction of an RS-code for any admissible $n,k$, at the expense of a larger field size than the one guaranteed by \Cref{thm:rs-sz}.
\section{Deterministic construction for any $k$}
\label{sec:det-any-k}
In this section, we give our main construction of an $[n,k]$ RS-code that can correct any $n-2k+1$ insdel errors. Specifically, we prove Theorem \ref{thm:rs-explicit-const} which is restated for convenience
\rsExpConst*
\begin{remark}
The downside of this construction is the field size $q=n^{k^{O(k)}}$, which renders it to run in polynomial time only for $k = O(\log(n)/\log(\log(n)))$. For larger values of $k$, the representation of each field element requires a super polynomial number of bits.
\end{remark}
The Mason–Stothers theorem \cite{mason,stothers1981polynomial} is a result about polynomials that satisfy a non-trivial linear dependence, which is analogous to the well-known \emph{abc conjecture} in number theory \cite{Masser,oesterle1988nouvelles}. Our main tool is one of the many extensions in the literature to the Mason–Stothers theorem. For stating the theorem we need the following notation: For a polynomial $Y(x)\in \mathbb{F}[x]$ over a field with $\charac(\mathbb{F})=p\neq 0$, denote by $\nu (Y(x))$ the number of distinct roots of $Y(x)$ with multiplicity not divisible by $p$.
\begin{thm}[``Moreover part'' of Proposition 5.2 in \cite{vaserstein2003vanishing}] \label{thm:abc-poly}
Let $m \geq 2$ and $Y_0(x) = Y_1(x) + \ldots + Y_m(x)$ with $Y_j(x)\in \mathbb{F}_p [x]$. Suppose that $\gcd (Y_0(x), \ldots, Y_m(x)) = 1$, and that $Y_1(x), \ldots, Y_m(x)$ are linearly independent over $\mathbb{F}_p (x^p)$.\footnote{$\mathbb{F}_p (x^p)$ is the field of rational functions in $x^p$. Namely, its elements are $f(x^p)/g(x^p)$ where $f(x),g(x) \in \mathbb{F}_p[x]$ and $g(x)\not \equiv 0$.} Then,
\[
\deg (Y_0(x)) \leq -\binom{m}{2} + (m-1)\sum_{j=0}^{m} \nu (Y_j(x))\;.
\]
\end{thm}
\begin{cnst} \label{cnst:abc-rs}
Let $k$ be a positive integer and set $\ell = ((2k)!)^2$.
Fix a finite field $\mathbb{F}_p$ for a prime $p > k^2 \cdot \ell$ and let $n$ be an integer such that $2k-1< n \leq p$. Let $\mathbb{F}_q$ be a field extension of $\mathbb{F}_p$ of degree $k^2\cdot \ell$ and let $\gamma\in \mathbb{F}_q$ be such that $\mathbb{F}_q = \mathbb{F}_p(\gamma)$. Hence, each element of $\mathbb{F}_q$ can be represented as a polynomial in $\gamma$, of degree less than $k^2\ell$, over $\mathbb{F}_p$. Define the $[n,k]_q$ RS-code by setting
$\alpha_i := (\gamma-i)^{\ell}$ for $1\leq i\leq n$.
\end{cnst}
%
\begin{prop} \label{prop:abc-rs}
The $[n,k]_q$ RS-code defined in \Cref{cnst:abc-rs} can correct any $n - 2k +1$ worst case insdel errors.
\end{prop}
\begin{proof}
Let $I,J\in [n]^{2k-1}$ be two increasing vectors that agree on at most $k-1$ coordinates. By Proposition \ref{prop:cond-for-RS} it is enough to show that $V_{I,J}(\alpha)$ is non-singular, for every such $I,J$. By the Leibniz formula, $\det(V_{I,J}(\alpha))$ is a sum of $(2k-1)!$ terms corresponding to the different permutations. Denote these terms as $P_i(\gamma)$ for $i=0,\ldots,(2k-1)!-1$. Each of the terms is a product of the sign of the corresponding permutation with some $2k-1$ elements of the form $(\gamma - s)^{\ell \cdot j}$, for some $s\in I\cup J$ and $0\leq j \leq k-1$.
Assume towards a contradiction that $\det(V_{I,J}(\alpha)) = 0$ in $\mathbb{F}_q$, i.e.,
\begin{equation}
\label{good-eq2}
\det(V_{I,J}(\alpha)) = P_0(\gamma) + \ldots + P_{(2k-1)!-1}(\gamma) = 0 \;,
\end{equation}
in $\mathbb{F}_q$. By viewing every term in \eqref{good-eq2} as a univariate polynomial in $\gamma$ over $\mathbb{F}_p$, one can verify that, for any $ j$, $\deg (P_j)$ = $\ell \cdot k(k-1)<k^2\ell$. As $\mathbb{F}_q$ is an extension of $\mathbb{F}_p$ of degree $k^2\ell$, it follows that \eqref{good-eq2} holds also in $\mathbb{F}_p[\gamma]$, the ring of polynomials in the variable $\gamma$ over $\mathbb{F}_p$.
By Proposition \ref{prop:formal-det} the determinant of the variable matrix \eqref{eq:mat-lcs-eq} has a monomial that is uniquely obtained and therefore has a $\pm 1$ coefficient. Assume, without loss of generality, that
$P_0$ is the image of this monomial under the mapping defined by the assignment $X_i\mapsto (\gamma-i)^\ell$. Note that since this mapping is injective on the set of monomials, no other monomial is mapped to a scalar multiple of $P_0$.
In other words, $P_0$ and $P_i$ are linearly independent for any $i\geq 1$. Assume further that (without loss of generality) $P_1,\ldots, P_m$ is a minimal subset among $\{P_i\}_{i\geq 1}$ that spans $P_0$ over $\mathbb{F}_p$. The existence of such a set follows from \eqref{good-eq2}. Hence, we can write
\begin{equation}
\label{last-eq}
P_0=\sum_{i=1}^ma_iP_i,\text{ where } a_i\in \mathbb{F}_p \backslash \{0\}.
\end{equation}
Clearly, by minimality, $P_1,\ldots,P_m$ are linearly independent over $\mathbb{F}_p$. Further, $m\geq 2$, since otherwise there would be an $i>0$ such that $P_i$ is a multiple of $P_0$.
Since the $P_i$'s are of degree $\ell k(k-1)$, and $P_0$ was obtained from a unique monomial in the determinant expansion, it follows that the greatest common divisor
$Q:=\gcd(P_0,\ldots,P_m)$
has degree at most $\ell(k(k-1)-1)$. By dividing \eqref{last-eq} by $Q$ we have
\begin{equation}
\label{last-eq2}
\overline{P_0}=\sum_{i=1}^ma_i\overline{P_i},
\end{equation}
where $\overline{P_i}=P_i/Q$.
We will need the following claim, whose proof is deferred to the end of this section.
\begin{claim} \label{clm:poly-ind}
The polynomials $\overline{P_1}, \ldots, \overline{P_m}$ are linearly independent over $\mathbb{F}_p(\gamma^p)$.
\end{claim}
The contradiction will follow by invoking Theorem \ref{thm:abc-poly}. Towards this end note that (i) By Claim \ref{clm:poly-ind} the polynomials $\overline{P_1},\ldots,\overline{P_m}$ are linearly independent of $\mathbb{F}_p(\gamma^p)$ (ii) $\gcd(\overline{P_0},\ldots,\overline{P_m})=1$, and (iii) $\nu (\overline{P_j}) \leq 2k-2$, as $P_j$ is the multiplication of $2k-2$ non-constant polynomials, each having a single root.
Thus, by \eqref{last-eq2} and \Cref{thm:abc-poly}
\begin{align*}
\ell\leq \deg(P_0)-\deg(Q)= \deg(\overline{P_0})
&\leq -\binom{m}{2} + \left(m - 1 \right) \cdot \sum_{i=1}^m \nu(\overline{P_j})\\
&< m^2(2k-2)\\
&\leq ((2k-1)!)^2\cdot (2k-2)\;,
\end{align*}
which is a contradiction by the choice of $\ell$. This completes the proof.
\end{proof}
It remains to prove Claim \ref{clm:poly-ind}.
\begin{proof}[Proof of \Cref{clm:poly-ind}]
Assume towards a contradiction that there exist $\lambda_1,\ldots, \lambda_m \in \mathbb{F}_p(\gamma^p)$ not all zero, such that
\begin{equation} \label{eq:abc-ind-poly}
\sum_{j=1}^{m} \lambda_j(\gamma^p) \overline{P_j}(\gamma) = 0\;.
\end{equation}
By clearing the denominators of the $\lambda_j$'s and any common factor they might have, we can assume that the $\lambda_j$'s are polynomials in the variable $\gamma^p$ with no common factors. Since $\deg(\overline{P_j})\leq \deg(P_j)<p$, we get by reducing \eqref{eq:abc-ind-poly} modulo $\gamma^p$ that
$$\sum_{j=1}^{m} \lambda_j(0) \overline{P_j}(\gamma) = 0\;.$$
Note that $\lambda_j(0)\neq 0$ for some $j$, since otherwise $\gamma^p$ would be a common factor of the $\lambda_i$'s. Hence, $\overline{P_1},\ldots,\overline{P_m}$ are linearly dependent over $\mathbb{F}_p$, which contradicts the fact that $P_1,\ldots,P_m$ are linearly independent over $\mathbb{F}_p$.
\end{proof}
By setting $n = p$ in \Cref{cnst:abc-rs} it follows that the field size of Construction \ref{cnst:abc-rs} is roughly $n^{k^{O(k)}}$ which is much worse than the field size guaranteed by the existential result in Theorem \ref{thm:rs-sz}. Note, however, that the construction runs in polynomial time for RS-codes with dimension $O(\log(n)/\log(\log(n)))$. The proof of \Cref{thm:rs-explicit-const} immediately follows.
\section{Explicit construction for $k=2$ with quartic field size}
\label{sec:det-k-2}
%
In this section we prove \Cref{thm:rs-twodim-const}, which is restated for convenience.
\rsTwoDimConst*
The proof of \Cref{thm:rs-twodim-const} requires the notion of
Sidon spaces, which were introduced in a work of Bachoc, Serra and Z{\'e}mor
\cite{bachoc2017analogue} in the study of an analogue of Vosper's theorem for finite fields.
Later, Roth, Raviv and Tamo gave an explicit construction of Sidon spaces and used it to provide a construction of cyclic subspace codes \cite{roth2017construction}. Our construction relies on the construction of Sidon spaces of \cite{roth2017construction}, which was also recently used in \cite{DBLP:conf/pkc/RavivLT21} to construct a public-key cryptosystem. We believe that Sidon spaces in general, and specifically the construction of \cite{roth2017construction}, might find more applications in coding theory and cryptography in the future. We begin with a formal definition of a Sidon space.
\begin{defi}
An $\mathbb{F}_q$ linear subspace $S\subseteq \mathbb{F}_{q^n}$ is called a \emph{Sidon space} if for any nonzero elements $a,b,c,d \in S$ such that $ab=cd$, it holds that that $$\{a \mathbb{F}_q, b \mathbb{F}_q\} = \{c \mathbb{F}_q, d \mathbb{F}_q\},$$ where $x \mathbb{F}_q=\{x \cdot \alpha: \alpha\in \mathbb{F}_q\}$ .
\end{defi}
A Sidon space $S$ has the following interesting property, from which it draws its name: Given the product $a\cdot b$ of two nonzero elements $a,b\in S $, one can uniquely factor it to its two factors $a,b$ from $S$, up to a multiplication by a scalar from the base field. Clearly, this is the best one can hope for, since for any nonzero $\alpha\in \mathbb{F}_q$ the product of the elements $\alpha\cdot a, b/\alpha\in S$ also equals $a\cdot b$. A Sidon space can be viewed as a multiplicative analogue to the well-known notion of \emph{Sidon sets}, which is a common object of study in combinatorics, see e.g. \cite{erdos1941problem}.
We proceed to present the construction of a Sidon space given in \cite{roth2017construction}.
\begin{thm}[Construction 15, Theorem 16 in \cite{roth2017construction}] \label{thm:Sidon-tamo} \label{thm:sidon-space}
Let $q\geq 3$ be a prime power, $m\in \mathbb{N}$, and $n = 2m$. Then, there exists an explicit $\gamma \in \mathbb{F}_{q^n}$ such that $S = \{u + u^q \cdot \gamma \mid u\in \mathbb{F}_{q^m} \}$ is an $m$-dimensional Sidon space over $\mathbb{F}_q$.
\end{thm}
Another component in our construction is the ``long'' ternary code with minimum distance of at least $5$, given in \cite{gashkov1986linear}. We note that we could also use the codes given in \cite{danev2008family}.
\begin{thm} \cite{gashkov1986linear} \label{thm:bch}
For every $m \geq 1$, there exits an explicit $[(3^m+1)/2, (3^m+1)/2 - 2m]_3$ linear code with minimum distance at least $5$.
\end{thm}
We next combine the above two algebraic objects and construct an RS-code with the desired properties.
\begin{cnst}
\label{RS k=2}
For $q = 3$ and $m\in \mathbb{N}$. Let
$S \subset \mathbb{F}_{3^{4m}}$ be a $2m$-dimensional Sidon space over $\mathbb{F}_3$ as guaranteed by \Cref{thm:sidon-space}. Let $s_1, \ldots, s_{2m}$ be a basis of $S$.
Let $H = (h_{i,j})$ be a ${(2m) \times ((3^m +1)/2)}$ parity check matrix of the code given in \Cref{thm:bch}.
Our $[n,2]_{3^{4m}}$ RS-code of length $n=(3^m +1)/2$ is defined by the evaluation points
\[
\alpha_j = \sum_{i=1}^{2m}s_i h_{i,j} \text{ for } 1\leq j \leq (3^m+1)/2 \;.
\]
In other words, we can think of our evaluation points as the $n$ coordinates of the vector $\alpha=(s_1,\ldots,s_{2m})\cdot H$.
\end{cnst}
The following property of the evaluation points $\alpha_j$ follows easily from \Cref{thm:bch}.
\begin{lemma}
\label{158}
Any four distinct $\alpha_j$'s are linearly independent over $\mathbb{F}_3$.
\end{lemma}
\begin{proof}
Consider four distinct $\alpha_j$'s, say $\alpha_1, \alpha_2, \alpha_3, \alpha_4$, and assume towards a contradiction that there exist $\beta_1,\ldots,\beta_4\in \mathbb{F}_3$ not all zero, such that
$\sum_{i=1}^4\beta_i\alpha_i=0$. Then
$$
0=\sum_{i=1}^4\beta_i\alpha_i
=\sum_{i=1}^4\beta_i\sum_{j=1}^{2m}s_j h_{j,i}
=\sum_{j=1}^{2m}s_j\sum_{i=1}^{4}\beta_i h_{j,i} \;.
$$
Since the $s_j$'s are linearly independent over $\mathbb{F}_3$ it follows that $\sum_i\beta_ih_{j,i}=0$ for every $j=1,\ldots,2m$. Hence, the four columns $h_1,h_2, h_3, h_4$ of $H$ are linearly dependent over $\mathbb{F}_3$, which contradicts the fact that the minimum distance of the code checked by $H$ is at least $5$.
\end{proof}
We proceed to prove that the constructed RS-code can decode from the maximum number of insdel errors.
\begin{thm} \label{prop:k-2-explicit}
The $\left[n,2\right]_{3^{4m}}$ RS-code given in Construction \ref{RS k=2} can correct any $n-3$ worst case insdel errors.
\end{thm}
\begin{proof}
Assume towards a contradiction that this is not the case. \Cref{prop:cond-for-RS} implies that there must exist two triples of distinct evaluation points $(x_1,x_2,x_3),(y_1,y_2,y_3)$, that agree on at most one coordinate, such that
\[
\left|
\begin{pmatrix}
1 &x_1 &y_1 \\
1 &x_2 &y_2 \\
1 &x_3 &y_3 \\
\end{pmatrix}
\right|
= 0
\;.
\]
Equivalently,
$(y_1 - y_2)(x_2 - x_3) = (y_2 - y_3)(x_1 - x_2)$. Since the $x_i$'s are distinct elements of the Sidon space $S$, $x_2 - x_3$ and $x_1 - x_2$ are \emph{nonzero} elements in $S$. Similarly, $y_1 - y_2$ and $y_2 - y_3$ are nonzero elements in $S$. By definition of Sidon spaces, there exists a nonzero $\lambda\in \mathbb{F}_3$ such that
$$\lambda(y_1-y_2)=y_2-y_3\text{ or } \lambda(y_1-y_2)=x_1-x_2,$$
which contradicts Lemma \ref{158}. Indeed, each of the equations implies a nontrivial linear dependence over $\mathbb{F}_3$ between at least three and at most four evaluation points (here we used the facts that the elements of each triple are distinct and that the two triples agree on at most one coordinate).
%
%
\end{proof}
We conclude this section with the proof of
\Cref{thm:rs-twodim-const}.
\begin{proof}[Proof of \Cref{thm:rs-twodim-const}]
By \Cref{prop:k-2-explicit}, the code given in Construction \ref{RS k=2} is an RS-code of length $n = (3^m+1)/2$, defined over the field $\mathbb{F}_{3^{4m}}$, which is of order $O(n^4)$, as claimed.
\end{proof}
\phantom{We remark again that this proof is an existence proof, namely, we show that there are $[n,k]_q$ RS-codes that can correct from $n-2k+1$ worst-case insdel errors where $q = n^{O(k)}$. Unfortunately, for the case of $k > 2$, we did not manage to provide explicit construction that achieves this field size. }
\subsection{A lower bound on the field size}
\label{sec:rs-lower-bound}
In Section \ref{sec:randomized-const} we proved the existence of optimal $[n,k]_q$ RS-codes for worst-case insdel errors over fields of size $q=n^{O(k)}$.
This section complements this result by providing a lower bound on the field size for such codes. Specifically, we ask how large must $q$ be in an $[n,k]_q$ RS-code that can correct from $n-2k+1$ worst-case insdel errors. We prove the following.
\RSLowerBound*
\begin{proof}
Consider an $[n,k]_q$ RS-code, defined by evaluation points $\alpha_1, \ldots, \alpha_n$, that can correct any $n-2k+1$ insdel errors.
For a \emph{non-constant} polynomial $f$ of degree less than $k$ let $\mathcal{V}_f$ be the set of all subsequences of the codeword corresponding to $f$, of length $2k-1$:
$$\mathcal{V}_f=\{(f(\alpha_{i_1}),\ldots, f(\alpha_{i_{2k-1}})):1\leq i_1<\ldots<i_{2k-1}\leq n\}\subseteq \mathbb{F}_q^{2k-1}.$$
By Lemma \ref{lem:lcs}, since the code can decode from any $n-2k+1$ insdel errors, the sets $\mathcal{V}_f$ and $\mathcal{V}_g$ for two distinct polynomials $f, g$, are disjoint. Therefore,\footnote{This equation remains true also if we include the constant polynomials.}
\begin{equation}
\label{good-eq4}
\sum_{1\leq \deg(f)<k} |\mathcal{V}_f|\leq q^{2k-1}.
\end{equation}
Next, we provide a lower bound on the size of $\mathcal{V}_f$.
For any non-constant polynomial $f$, of degree less than $k$, and any $a\in \mathbb{F}_q$ there are at most $k-1$ indices $i$ such that $f(\alpha_i)=a$. Thus, for a fixed vector $(a_1,\ldots, a_{2k-1}) \in \mathcal{V}_f$ there are at most $(k-1)^{2k-1}$ increasing vectors of indices $(i_1,\ldots,i_{2k-1})$ such that
$$(f(\alpha_{i_1}),\ldots, f(\alpha_{i_{2k-1}}))=(a_1,\ldots ,a_{2k-1}).$$
Therefore $|\mathcal{V}_f|\geq \binom{n}{2k-1}(k-1)^{-(2k-1)}$. Combined with \eqref{good-eq4} we have
\[
\left( \frac{1}{k-1} \right)^{2k-1} \cdot \binom{n}{2k-1} \cdot \left(q^k - q\right) \leq q^{2k-1} \;,
\]
By rearranging and the fact that
$q^{2k-1}/{(q^k - q)} \leq 2q^{k-1}$ for $q,k\geq 2$, we have
\[
\left(\frac{1}{2}\right)^{\frac{1}{k-1}} \left(\frac{n}{(2k-1)(k-1)}\right)^{\frac{2k-1}{k-1}}\leq q \;.\qedhere
\]
\end{proof}
As one can easily verify, this bound is rather weak, as it provides an improvement over the trivial lower bound of $q\geq n$ only for the vanishing rate regime of $k=O(n^{1/4})$.
For codes of dimension $2$, the bound implies
$q = \Omega(n^3)$, and it slowly degrades as one increases $k$. Nevertheless, it is always at least $\Omega(n^2)$ for any constant $k$.
It is interesting to note that by combining
Proposition \ref{prop:lower-bound} and Theorem \ref{prop:k-2-explicit}
it follows that an $[n,2]_q$ RS-code that can decode from $n-3$ insdel errors requires that $\Omega(n^3)\leq q \leq O(n^4)$. Determining the minimum possible value of $q$ for this case is an interesting open problem.
\section{Open questions}
\label{sec:open-que}
This paper studies the performence of RS codes against insdel errors. We showed that there are RS-codes are optimal against insdel errors, i.e., they achieve the half-Singleton bound. We also construct explicit RS codes that achieve this bound and as far as we know, this is the first linear code that is shown to achieve this bound.
As discussed, \Cref{cnst:abc-rs} is not optimal in terms of the field size. It is a fascinating open question to find an RS-code with an optimal field size. Specifically, the challenge is to construct an RS-code that can correct from any $n-2k+1$ insdel errors, over a field of size $O(n^{O(k)})$ (\Cref{thm:rs-sz} proves the existence of such codes).
The lower bound on the field size proved in \Cref{prop:lower-bound} is far from giving a full picture of the tradeoff between dimension and field size. The natural open question is to significantly improve our lower bound or provide a better upper bound.
Finally, another interesting question is to provide an efficient decoding algorithm for our constructions of RS-codes.
\section*{Acknowledgement}
We thank Shu Liu, Ivan Tjuawinata and Chaoping Xing for spotting an inaccuracy in the original statement of \autoref{prop:cond-for-RS}.
\bibliographystyle{alpha}
| {'timestamp': '2022-01-19T02:25:26', 'yymm': '2107', 'arxiv_id': '2107.05699', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05699'} | arxiv |
\section{Introduction}
6G will intensify the handling of AI and ML for use cases from various corners of industry and life. 6G will be a network of "integrated intelligence" \cite{HexaX,AIaaSpaper} in which AI/ML algorithms are applied for autonomous networking and where the network will be redesigned to support the AI/ML based applications \cite{ITU2030,ITUTreport,3GPP2,ENI}.
The success of AI/ML algorithms requires large volume, updated data sets with similar statistical conditions in the training and testing phases \cite{8761327}. However, this is not the case for many real scenarios for two main reasons. First, collecting data and providing labeling are not always accessible (e.g., cyber attacks) and may involve high cost. Second, dynamic environments in real scenarios call for updating data sets regularly (e.g., fast and dynamic nature of the wireless channel and uncertainty in the behavior/mobility patterns of end users in intelligent transportation systems (ITS)). Re-collecting data in these scenarios and rebuilding models from scratch impose huge burdens for these use cases.
Transfer learning (TL) or knowledge transfer (KT) is a promising approach to handle both of the above-mentioned challenges \cite{5288526,Zhuang2019ACS,8761327,DBLP:journals/corr/abs-2102-07572}. In this context, it is possible to transfer lesson-learned parameters (knowledge) among learning algorithms that includes data sets, models, hyper parameters, and optimization approaches. In particular, each learning algorithm can be divided into two parts: 1) a domain containing feature data and its statistics; 2) a task involving models and labels. Typically in TL there are at least one source and one target AI/ML algorithms in TL where the knowledge of domain and/or task of the source is transferred to a target.
Experience with TL shows that sharing domains and tasks can improve the speed of convergence and learning accuracy. this case will be refereed to "a positive TL". However, when there is not enough similarity and correlation among domains and tasks of the source and the target, TL might have negative effect on the performance of the target.
Applications of TL in 6G and its positive potential in future networking has recently drawn a lot of attention, e.g., \cite{9388790, 6Gurrllcsurvey}. In this paper, our goal is to study how we can attain efficient TL in 6G.
We begin by looking at the TL categories. Then, we explain how 6G architecture planes can be modified to provide the efficient TL. We discuss the deployment of TL pipe-lines in the infrastructure, novel procedures in management plane to handle TL among sources and targets, new repositories and knowledge extraction modules in a training plane, and modifications in application plane. Based on the network layers, we provide examples about data sets and models that may be saved in repositories of the training plane in 6G.
Fortunately, in wireless networks, there exist spatio-temporal and hierarchical correlations among AI/ML algorithms running in different nodes that are conducive to positive and efficient TL. Despite its great potential, TL in 6G introduces various implementation challenges. For example, use cases can impose diverse granularity requirements of TL in 6G involving real time, online/offline, and on-demand TL. And there are concerns about robustness, reliability, security, and privacy of pipe-lines for TL. We will discuss these implementation challenges in 6G and highlight the overheads of TL in 6G. In an evaluation section, we show how quantization approaches can be used with TL to reduce the extra overhead inside of 6G.
The organization of this paper is as follows. In Section II, we briefly review TL. In Section III, we show how TL changes the 6G architecture. Section IV contains future research directions. In Section V, a deployment scenario for TL in 6G will be discussed; followed by conclusions in Section VI.
\section{Transfer Learning Preliminaries}
Consider an AI/ML algorithm $m$ that has \cite{5288526}:
\begin{itemize}
\item \textit{Domain}: consisting of a feature space $\mathcal{X}_m$ for algorithm $m$ and a marginal probability distribution $P_m(\textbf{X}_m)$, where $\textbf{X}_m = \{x^1_m,\cdots,x^n_m\} \in \mathcal{X}_m$, which constitute the domain $\mathcal{D}_m=\{\mathcal{X}_m,P_m(\textbf{X}_m)\}$
\item \textit{Task}: involving a label space $\mathcal{Y}_m$ and a predictive function $f_m(\dot)$ which shows the relation between $\mathcal{X}_m$ and $\mathcal{Y}_m$, and the task is denoted by $\mathcal{T}_m=\{\mathcal{Y}_m, f_m(.)\}$.
\end{itemize}
In supervised learning mode, the data set $m$ consists of $\mathfrak{D}_m=\{(x_m^1, y_m^1), \cdots (x_m^n, y_m^n)\}$ and $f_m(.)$ is found by minimizing the distance between the feature and the label spaces. In unsupervised learning mode, the task changes to $\mathcal{T}_m=\{ f_m()\}$ since the labels are not available and the best predictive function is matched to the feature space. Traditionally, the domain $\mathcal{D}_m$ and the task $\mathcal{T}_m$ are fully disjoint from any other $\mathcal{D}_n$ and $\mathcal{T}_n$ for $m \neq n$. However, in TL, parameters among domains and tasks $m$ and $n$ for all $m$ and $n$ can be shared, see Fig. \ref{TL3}. Any shared part of the domains or the tasks can be referred as "knowledge", e.g., all or the portion of the feature and the label spaces (data sets), or $f(.)$ and its hyper-parameters (models). TL aims to improve the performance of $\mathcal{T}_n$ with $\mathcal{D}_m$ and $\mathcal{T}_m$. We consider the following two key performance measures for target $n$:
\begin{itemize}
\item \textit{Accuracy, consistency and generalization} of learning in the target domain: $\eta^{TL}_n=\frac{P^{\text{TL}}_n}{P^{\text{Traditional}}_n}$ where $P^{\text{TL}}_n$ and $P^{\text{Traditional}}_n$ are the performance measures of the AI algorithm $n$ with and without TL, respectively.
\item Training time in the target domain: $\tau^{TL}_n=\frac{T^{\text{Traditional}}_n}{T^{\text{TL}}_n}$ where $T^{\text{TL}}_n$ and $T^{\text{Traditional}}_n$ are the training times of the AI algorithm $n$ with and without TL, respectively.
\end{itemize}
Now we can defined positive TL as a case that $\eta^{TL}_n>1$ and $\tau^{TL}_n>1$. The above definitions are for one source and one target and it can be extended to any set of sources and targets.
From 6G's preservatives, to have successful TL, required bandwidth, delay, the level of security and privacy of passed knowledge between sources and targets should be determined. Also, the granularity of TL algorithm and the iteration number to pass knowledge between source and target should be determined. For instance, we can have following classes of interaction among source and targets:
\begin{itemize}
\item \textit{Real-time TL} where the knowledge is passed between source and target as soon as a new update is available;
\item \textit{Non real-time or semi-real time TL }where the knowledge between the sources and the targets are passed according to a schedule;
\item\textit{ On-demand TL} where the knowledge is passed from the source to the target when a request from the target is initiated.
\end{itemize}
These types of interactions together with the end-to-end (E2E) delay determine the required bandwidth between each source-target pair. These parameters can be used to deploy the pipe-line for TL, demonstrated in Fig. \ref{TL3}. An important point is that the TL pipe-line causes additional overhead and cost for passing knowledge. Below we identify different types of overheads and costs are incurred in TL. One approach to obtaining a single measure for overhead and cost is to use a weighted sum of the components: \begin{eqnarray}
\lefteqn{\Theta^{\text{TL}}_{mn}=\alpha_1 f_1(W_{mn})+ \alpha_2 f_2(D_{mn})}\\&& \,\,\,\,\,\,\,\,\,\,\,\, + \alpha_3 g_{mn}(\text{ interaction}) +\alpha_4 h_{mn}(\text{security}), \nonumber
\end{eqnarray} where $\alpha_1, \alpha_2, \alpha_3, \alpha_4$ are regularization weights and functions are defined as:
\begin{itemize}
\item $f_1(W_{mn})$ and $f_2(D_{mn})$ are increasing and decreasing functions of required E2E bandwidth $W_{mn}$ and delay $D_{mn}$, respectively;
\item $g_{mn}(\text{ interaction})$ shows the cost per interaction class, defined as
$$g_{mn}(\text{ interaction}) =
\left\{\begin{array}{lr}
M_1, & \text{if} \,\, \text{Real-time},\\
M_2, & \text{if } \,\,\text{Non-Real time},\\
M_3 & \,\,\text{Otherwise,}
\end{array}\right.$$
where $M_1$, $M_2$, $M_3$ are positive values demonstrating the costs related to each class and they can be set as $M_1\geq M_2 \geq M_3$ by wireless network infrastructure providers. The good policy also can be designed to reduce the cost of overhead, for instance by sending the TL knowledge among the source and the target in non-rush hour time windows.
\item $h_{mn}(\text{security})$ is the security related cost function and it is an increasing function with the level of requested by source $m$ and target $n$.
\end{itemize}
Clearly, decreasing the overhead while attaining positive performance of the learning AI are major indicators of effectiveness of TL in 6G.
\begin{figure}
\begin{center}
\includegraphics[width=3.2 in]{figs/TL89}
\caption{Transfer learning and its pipe-line inside of 6G }
\label{TL3}
\end{center}
\end{figure}
There are several categories of TL based on \textit{what} can be transferred among sources and targets and the similarities and differences between their domains and tasks. For example, based on the availability of labels, there are three categories of TL:
\begin{itemize}
\item Transductive TL where the label data is available only from the source not the target and $\mathcal{D}_m\neq \mathcal{D}_n$ while $\mathcal{T}_m = \mathcal{T}_n$
\item Inductive TL where label data are available for the source and targets but the tasks are different, i.e., $\mathcal{T}_m \neq \mathcal{T}_n$
\item Unsupervised TL where the label data is not available in neither source or target
\end{itemize}
Based on domains, we have
\begin{itemize}
\item Heterogeneous TL where $\mathcal{D}_m \neq\mathcal{D}_n$
\item Homogeneous TL where $\mathcal{D}_m=\mathcal{D}_n$
\end{itemize}
and based on the solution approach, we have
\begin{itemize}
\item Instance-based TL where samples of data sets are shared between the source and target
\item Feature-based TL where original features of the source are matched to target ones, or where for both source and target features, latent features or common features are discovered.
\item Parameter-based TL which involves transferring the parameters of models
\item Relational-based TL which transfer the learned rules from source to the target
\end{itemize}
In the following, we will discuss how TL should be processed in 6G and give examples of the above categories of TL in 6G.
\section{Aspects of Efficient TL in 6G}
In this section, we study effects of TL in 6G and show how 6G should be adapted to serve AI/ML use cases. Many AI/ML use cases in 6G involve learning/control loops containing \textit{monitoring, analysis, policy, execution plus knowledge} steps, denoted as (MAPE-K) loops. A MAPE-K loop provides a unified way to represent these AI/ML based applications \cite{ENI,AIaaSpaper}. TL can be deployed between ML algorithms that are normally present in the analysis step of MAPE-K loops associated diverse services in OTT, and/or networking applications (NAL). In this paper, for simplicity, we assume there is one MAPE-K loop per each AI/ML algorithm which can be a target or a source of TL. Let's start our discussions with some examples to show how TL can be used in 6G.
\subsection{Examples of TL in 6G}
In 6G, many use cases in networking share the spatio-temporal features or similar information in performing various tasks. Let's focus on resource allocation (RA), energy efficiency (EE), and admission control (AC) of radio access networks (RANs) for one specific area in 6G. There are several access nodes, e.g., ORANs, in a region that provide coverage (see Fig. \ref{fig:TL4}).
All of these tasks utilize the mobility pattern and traffic pattern of end-users. Therefore, the domains are similar but the tasks are different. Any ORAN can share its own domain among its own different tasks. Also, ORAN 1 can share its own task and domain for the resource allocation (RA) with the resource allocation (RA) in ORAN 2; which is an example of to transduction TL where the source is RA in ORAN 1 and the target is RA in ORAN 2. If the resource allocation (RA) in RAN 2 also shares its domain or tasks with the resource allocation (RA) in RAN 1, we have inductive TL. If both RANs do not have labeled data, there is unsupervised learning among them. The resource allocation (RA) in ORAN 1 and ORAN 2 can share their knowledge in real-time, non-real time and on-demand cases. For the last two cases, depending on the amount of available bandwidth, TL among ORAN 1 and ORAN 2 can be scheduled to reduce $\Theta^{\text{TL}}_{\text{ORAN1}, \, \text{ORAN2}}$. The same is true for the energy efficiency (EE) in both ORAN 1 and ORAN 2. However, there is a chance that the energy efficiency (EE) decision is in contrast with an RA decision. For instance, the resource allocation (RA) requires more resource to guarantee the QoS while the energy efficiency (EE) asks for less power consumption and releasing some resources. These examples demonstrate the importance of interaction and TL management in 6G.
These AI/ML algorithms can share the domains and tasks with another part of the RAN in different cities or different locations. In this case, we can have parameter or instance or feature based TL. The resource allocation, admission control, and the energy efficiency in ORANs of one area can share their models and data sets with the core elements to derive more large scale mobility patterns and network user behaviors. In this case, one probable scenario is to share the domain of RANs with the core to increase the size of data sets of core elements without additional cost. The knowledge can be fully or partially shared among AI/ML algorithms in 6G.
\begin{figure}
\centering
\includegraphics[width=2.9 in]{figs/TL4}
\caption{One scheme of the TL examples in zone 1 and zone 2 of 6G}
\label{fig:TL4}
\end{figure}
The mobility pattern of 6G nodes, which arises from NAL applications, can be transferred to ITS, which is an OTT application, or vice versa. Various types of TL can be applied here. The similarity between these two use cases is obvious. However, 6G can encounter more complex scenarios. For example, for cyber-security, 6G may require a behaviour and traffic model of legitimate users of OTT use cases. In this case, the domains and the tasks of both cases are not correlated. Therefore, we have heterogeneous TL here, and any solution based categories of TL can be applied.
\subsection{Hierarchy and Spatio-temporal Features of 6G and TL}
Wireless networks have hierarchical structures. Also, our examples in the previous section show that there is an inherent spatio-temporal feature among different location zones, RANs, and core entities. These features help create positive TL in 6G for clustering and classifications AI/ML algorithms. Therefore, hierarchy and Spatio-temporal features of traffic of users in 6G can be used as the criteria for the clustering AI/ML algorithms for TL. In Figs. \ref{fig:TL2} (a) and (b), we plot some models of interaction of AI/ML algorithms for TL in 6G which can basically derived from both hierarchy or spatio-temporal feature of 6G. In Fig. \ref{fig:TL2}, we present three models:
\begin{itemize}
\item Cascade AI/ML algorithms in (i) which can show the neighboring ORANs transferring their models and data sets for mobility or traffic patterns of users
\item Hierarchical AI/ML algorithms in (ii) which can represent the interaction between access and core elements in TL
\item Parallel AI/ML algorithms (iii) belong to the case that the similar nodes (base stations, switches, storage devices) collaborate to learn the similar models based on their local data sets through the concept of federated learning (FL). Also, they can share their public (not very sensitive data sets in terms of privacy) with their peers.
\end{itemize}
This hierarchical structure inside of 6G can help to find the correlation, similarities, and relation among sources and targets.
\begin{figure}
\centering
\includegraphics[width=3.62 in]{figs/TL5}
\caption{The hierarchy and interaction among AI/ML use cases in 6G for three models of interaction (i) cascade model (ii) Hierarchical model, (iii) parallel model. }
\label{fig:TL2}
\end{figure}
\subsection{6G Architecture Modifications}
We see the 6G architecture as including four planes to serve these use cases and to handle their needs associated with TL \cite{9200631,AIaaSpaper}. We define responsibilities of each plane as follows:
\begin{itemize}
\item \textbf{Application Plane} which represents the MAPE-K loops as chains of functions/services that implement the data collection processing and action pipe-lines that implement the loops, along with their required QoS and QoE. The ML algorithm(s) in each MAPE-K loop can be the source or target for algorithms in other MAPE-K loops. Application plane determines following items for TL:
\begin{itemize}
\item A list of trustful targets;
\item A list of trustful sources;
\item Parts of models and tasks that are allowed to be shared;
\item Required levels of security and privacy;
\item TL angularity with any specific source and target;
\item Privacy and security level;
\item Required E2E delay for TL with any specific source and target;
\item Required bandwidth for any allowable TL.
\end{itemize}
The above parameters help to determine the service level agreement (SLA) for any pair of the source and target in TL. These SLAs will be used in 6G to establish appropriate pipe-lines per each MAPE-K loop.
\item \textbf{Infrastructure Plane} which is an E2E cloud-native, multi-tier, programmable structure with virtualized communication and computation resources. This plane inherits the software defined and virtualized structures of 5G and it is responsible to provide TL pipe-lines from sources and targets for both OTT and NAL applications. The request for setting up a TL pipe-line is sent by a management plane to the infrastructure plane. Other pipe-line parameters are derived from SLAs in application plane.
\item \textbf{Management Plane} which is in charge of monitoring all running services and Required admission for new requests of services in fully autonomous manner. In 6G, this plane should include procedures to handle the conflicts that may arise among MAPE-K loops, pertaining to the consistency and coherency of loops \cite{AIaaSpaper}, and TL management. These new procedures along with orchestrator and infrastructure management are shown in boxes in Fig. \ref{6Gtrainingmanagement}. TL manager has following tasks:
\begin{itemize}
\item Determining who can initiate TL among MAPE-K loops and services in 6G. For instance, among networking applications, TL request can be issued by network elements (decentralized manner) or can be handled by the orchestrator (centralized manner). For the OTT applications, the request can be originate with the OTT applications;
\item Determining authorized TLs among MAPE-K loops;
\item Initiating and handling TL for one or multiple service/infrastructure providers and OTT slices for different organizations.
\end{itemize}
The request for setting up TL pipe-line among MAPE-K loops can be initiated from use cases. For example in an OTT, an Intelligent Transportation System (ITS) may send a request for TL to get data about the mobility pattern of users. In a NAL setting, a request for TL can be started by network management plane. In both cases, the orchestartor will handle the setup procedure for providing the TL pipe-line in the infrastructure by monitoring security, reliability, and privacy. In general, all the \textit{coordination} among sources and targets are handled by this plane. This task is more complex when dealing with multi-source multi-task TL and when the sources and targets are in different networks or OTT applications.
\item \textbf{Training Plane} which is a new plane in 6G to integrate AI and ML into the network \cite{AIaaSpaper,ITUTreport} and to provide sandboxes that mimic the real environment with the goal of training, retraining and examining any AI based use cases in offline, near-online and online manner \cite{ITUTreport}. To support TL, this plane provides an environment to measure the TL positive effects on the targets' learning procedures. It should learn the similarity and correlations among sources and targets to attain positive TL for both NAL and OTT use cases. It also needs to be equipped with the means to extract the knowledge from domains and tasks of each AI based application. We represent these tasks in four boxes in Fig. \ref{6Gtrainingmanagement}, defined as: \\1)
\textit{Sandboxes} which are responsible to provide simulation/ emulation environments for TL, clustering and finding the beneficial correlation among sources and targets. These reports should be sent to the second box of the management plane. \\2) \textit{Knowledge extraction } which can provide parameters from domains and tasks of sources and targets for TL (knowledge). This knowledge is ready to transfer between source-target pairs depending on TL categories. \\3) \textit{Repositories of data and knowledge} which are storage units to store and retrieve knowledge for TL among sources and targets.
\end{itemize}
In 6G, the training and management plane have tight interaction to attain efficient TL. All actions in boxes in the training plane are sent to the management plane to execute the interaction and knowledge transfer among the MAPE-K loops. In Fig. \ref{6Gtrainingmanagement}, we show arrows between boxes to highlight the importance of these interfaces.
\begin{figure}
\begin{center}
\includegraphics[width=3.1 in]{figs/TL6}
\caption{Training and management aspects of 6G to provide TL. }
\label{6Gtrainingmanagement}
\end{center}
\end{figure}
\subsection{Repository of Knowledge of TL in 6G}
In the repository, the models and data sets of each target-source pair can be stored and used for TL among similar/correlated OTT and networking use cases when permitted. For instance, the following information can be stored in the repository:
\begin{itemize}
\item End-Users which are smart phones, IoT devices (e.g., smart watches), autonomous vehicles, and sensors. These devices can share the following:
\begin{itemize}
\item Models and data sets related to UE/Session related parameters, e.g., mobility pattern, spatio-temporal traffic model, wireless channel and coverage model, QoS, and QoE.
\end{itemize}
\item Radio-access level devices including base stations, radio remote heads (RRHs), cloud radio access networks (CRAN) or open RANs (ORANs) where they provide coverage for specific area. These entities can share the following:
\begin{itemize}
\item Models and data sets per each region for spatio-temporal traffic and mobility models of users in that area, network measurements and logs, RAN-related parameters (e.g., channel quality), load, interference, user density. resource condition parameters (e.g., availability of front-haul), reliability and robustness of services.
\end{itemize}
\item Core-level devices including switches, firewalls, packet gateways, computing devices, storage devices of the users' information, and clouds inside of the networks, which can share the following:
\begin{itemize}
\item Models and data sets for processing load and availability of core functions (both virtual and physical), load and availability of computing resources, large scale spatio-temporal traffic and mobility per zone for each type of services and slices, core network measurements and logs, and procedure level task information.
\end{itemize}
\item OTT and service applications including traditional data and voice services, smart services for different sectors of industry, and slices which can provide
\begin{itemize}
\item Models and data sets for slice QoS and QoE, slice isolation, spatio-temporal traffic and mobility per slice, measurements, and logs per slices,
\end{itemize}
\item Management level which includes all the OSS and BSS parameters and they can share the following parameters inside of the network or with another network provider:
\begin{itemize}
\item Models and data sets for fault, configuration, accounting, performance, and security (FCAPS) and the management reports
\end{itemize}
\end{itemize}
Repository of knowledge in TL can be handled by training plane where seasonal, daily, and weekly patterns of any knowledge, models and data sets can be provided for different MAPE-K loops. However, the management plane takes care of initiating and allowing the TL procedures between any source and target in private and secure manner.
\section{Challenges and Future Works }
TL will play an important role in simplifying and streamlining the use of AI and ML in 6G networks. One of the major challenges of deploying TL is to deal with the vast number of possible approaches and formulations, so choosing the best TL approach is a major implementation challenge in 6G. Also, TL mechanism should be tuned based on the use case which poses the challenge of finding new procedures to handle TL in more general manner.
There exist overlaps between TL and other concepts such as federated learning, semi-supervised learning, multi-view learning, and most importantly, multi-task learning. Having a unified view of TL and highlighting its overlaps with other context can unlock the potential of TL in 6G.
Adaptation of TL for reinforcement learning (RL) in dynamic environment is another challenge \cite{zhu2021transfer,JMLR09-taylor}. Here, to have positive TL, transformation of different parts of the information from the source (e.g., state-space, action-space, reward, and transition dynamics) to the target should be studied. Since there is more spatio-temporal dynamic behavior in the system, TL needs more adaptation of the parameters. Most of the recent works are well-tuned approaches for specific applications of TL in RL. Framework-agnostic TL for RL is of desirable in 6G.
Positive TL requires appropriate clustering, correlation, and similarity detection among sources and targets. This can be efficiently handled for homogeneous TL among sources and tasks. However, in heterogeneous scenarios, adapting the source and target domains and tasks are not trivial. Deriving latent variables in data sets of different AI/ML algorithms can also lead to positive TL and attain the better clustering and similarities among tasks.
In the most works, TL is used for a pair of one source and one target. However, as mentioned in the examples above, in 6G, there is a set of sources aiming to share their information with a set of targets. Expanding all the existing formulations of one source-target pair TL to multi-source multi-target TL in 6G can be considered as another future research direction.
Preserving the required security and privacy and preventing any threat from attackers during the knowledge transfer among AI/ML algorithms are also another important issue for efficient TL in 6G. TL in 6G should be immunized against eavesdropping, GAN attacks (for models and data sets), poisoning, and Sybil attacks.
\section{Deployment Scenario:\\ Quantization to Reduce TL Overhead}
To overcome TL extra overhead in 6G, in this section, we study how quantization algorithms can compensate this practical challenge. Quantization in this context is a class of techniques for performing computations and storing tensors at less number of bits than floating point case. Consequently, a quantized model executes some or all of the operations on tensors with integers rather than floating point values, leading to a more compact model representation for DNNs.
We implement TL pipe-line between two neural networks in
which one of them is trained on the CIFAR-10 data set and the neural network model is
MobileNetV2 \cite{mobilenet} and we apply \cite{quantization}. Fig. \ref{fig:quantization-acc} shows the performance of quantized algorithms with the case that the exact values of weights are passed
among neural networks, i.e., \textit{Floating point method} which requires 32 bits of
data per weights of neural networks. In
Fig. \ref{fig:quantization-acc}, the accuracy of training phase shows the
performance of floating point approach versus following quantization algorithms
for 8 bits per each weight \cite{quantization}:
\begin{itemize}
\item \textit{Default} quantization approach which applies uniform
quantization levels between minimum and maximum values of weights
\item \textit{FBGEMM} where by considering the
distribution of the weights, quantization levels is adjusted
which leads to better
accuracy compared to \textit{Default} quantization approach
\item \textit{Quantization aware training (QAT)} In the above
approaches, quantization is applied at the end of the model training.
In this approach, after that, the model is fine-tuned on the quantized weights by
training a couple of more iterations to improve the accuracy. In our experiments,
this method leads to 1\% better accuracy compared to \textit{FBGEMM} from Fig. \ref{fig:quantization-acc}.
\end{itemize}
Fig. \ref{fig:quantization-acc} highlights that by 75\% decreasing the load of the network (8 bits/32 bits) ($f_{mn}(\text{interaction})$), still the accuracy of training phase is in the acceptable range for \textit{QAT}. To demonstrate it figuratively, in Fig.
\ref{fig:quantization-size}, the size of the quantized model is compared to that
of the original model. As shown in this figure, the size of the model is reduced
to 75\%. This simulation shows that the quantization is an appropriate
method to make a trade-off between performance and amount of messages in the AI-aaS based networks.
After passing the quantized weights, we can re-tune the final layer of the model in the target to increase the accuracy. We use a Pytorch tutorial of "Quantized Transfer Learning for Computer Vision" and its colab version \cite{quantizationforTL}. By re-training the model at the target, the accuracy level will be increased up to the case without quantization. The re-training phase in the target takes $3$ m and $16$ sec versus while full training requires $10$ m and $16$ sec for convergence. On the other hand, we have $\tau^{\text{TL}}=3.142$, meaning that TL can improve the energy efficiency with the factor $\tau^{\text{TL}}$, and consequently, improving sustainability in 6G.
\begin{figure}
\centering
\includegraphics[width=0.45\textwidth]{figs/Q1}
\caption{Percentage of accuracy of target versus quantization approaches}
\label{fig:quantization-acc}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.45\textwidth]{figs/Q2}
\caption{The amount of overhead of quantized versus non-quantized TL in 6G}
\label{fig:quantization-size}
\end{figure}
\section{Conclusion }
In this paper, we address how efficient transfer learning (TL) in 6G can be attained. We introduce metrics to assess efficiency TL from both learning algorithm and networking aspects. We discuss possible modifications in 6G architecture to handle TL and we define new elements in the network management plane. We focus on new activities in training plane and its repositories for TL in 6G. With some examples and looking at spatio-temporal features of wireless networks, we show how classifications and clustering of algorithms in 6G can be attained to reach efficient TL. For positive TL, we require more unified view of TL approaches with security and privacy guarantees discussed in this paper.
\bibliographystyle{IEEEtran}
\section{Introduction}
6G will intensify the handling of AI and ML for use cases from various corners of industry and life. 6G will be a network of "integrated intelligence" \cite{HexaX,AIaaSpaper} in which AI/ML algorithms are applied for autonomous networking and where the network will be redesigned to support the AI/ML based applications \cite{ITU2030,ITUTreport,3GPP2,ENI}.
The success of AI/ML algorithms requires large volume, updated data sets with similar statistical conditions in the training and testing phases \cite{8761327}. However, this is not the case for many real scenarios for two main reasons. First, collecting data and providing labeling are not always accessible (e.g., cyber attacks) and may involve high cost. Second, dynamic environments in real scenarios call for updating data sets regularly (e.g., fast and dynamic nature of the wireless channel and uncertainty in the behavior/mobility patterns of end users in intelligent transportation systems (ITS)). Re-collecting data in these scenarios and rebuilding models from scratch impose huge burdens for these use cases.
Transfer learning (TL) or knowledge transfer (KT) is a promising approach to handle both of the above-mentioned challenges \cite{5288526,Zhuang2019ACS,8761327,DBLP:journals/corr/abs-2102-07572}. In this context, it is possible to transfer lesson-learned parameters (knowledge) among learning algorithms that includes data sets, models, hyper parameters, and optimization approaches. In particular, each learning algorithm can be divided into two parts: 1) a domain containing feature data and its statistics; 2) a task involving models and labels. Typically in TL there are at least one source and one target AI/ML algorithms in TL where the knowledge of domain and/or task of the source is transferred to a target.
Experience with TL shows that sharing domains and tasks can improve the speed of convergence and learning accuracy. this case will be refereed to "a positive TL". However, when there is not enough similarity and correlation among domains and tasks of the source and the target, TL might have negative effect on the performance of the target.
Applications of TL in 6G and its positive potential in future networking has recently drawn a lot of attention, e.g., \cite{9388790, 6Gurrllcsurvey}. In this paper, our goal is to study how we can attain efficient TL in 6G.
We begin by looking at the TL categories. Then, we explain how 6G architecture planes can be modified to provide the efficient TL. We discuss the deployment of TL pipe-lines in the infrastructure, novel procedures in management plane to handle TL among sources and targets, new repositories and knowledge extraction modules in a training plane, and modifications in application plane. Based on the network layers, we provide examples about data sets and models that may be saved in repositories of the training plane in 6G.
Fortunately, in wireless networks, there exist spatio-temporal and hierarchical correlations among AI/ML algorithms running in different nodes that are conducive to positive and efficient TL. Despite its great potential, TL in 6G introduces various implementation challenges. For example, use cases can impose diverse granularity requirements of TL in 6G involving real time, online/offline, and on-demand TL. And there are concerns about robustness, reliability, security, and privacy of pipe-lines for TL. We will discuss these implementation challenges in 6G and highlight the overheads of TL in 6G. In an evaluation section, we show how quantization approaches can be used with TL to reduce the extra overhead inside of 6G.
The organization of this paper is as follows. In Section II, we briefly review TL. In Section III, we show how TL changes the 6G architecture. Section IV contains future research directions. In Section V, a deployment scenario for TL in 6G will be discussed; followed by conclusions in Section VI.
\section{Transfer Learning Preliminaries}
Consider an AI/ML algorithm $m$ that has \cite{5288526}:
\begin{itemize}
\item \textit{Domain}: consisting of a feature space $\mathcal{X}_m$ for algorithm $m$ and a marginal probability distribution $P_m(\textbf{X}_m)$, where $\textbf{X}_m = \{x^1_m,\cdots,x^n_m\} \in \mathcal{X}_m$, which constitute the domain $\mathcal{D}_m=\{\mathcal{X}_m,P_m(\textbf{X}_m)\}$
\item \textit{Task}: involving a label space $\mathcal{Y}_m$ and a predictive function $f_m(\dot)$ which shows the relation between $\mathcal{X}_m$ and $\mathcal{Y}_m$, and the task is denoted by $\mathcal{T}_m=\{\mathcal{Y}_m, f_m(.)\}$.
\end{itemize}
In supervised learning mode, the data set $m$ consists of $\mathfrak{D}_m=\{(x_m^1, y_m^1), \cdots (x_m^n, y_m^n)\}$ and $f_m(.)$ is found by minimizing the distance between the feature and the label spaces. In unsupervised learning mode, the task changes to $\mathcal{T}_m=\{ f_m()\}$ since the labels are not available and the best predictive function is matched to the feature space. Traditionally, the domain $\mathcal{D}_m$ and the task $\mathcal{T}_m$ are fully disjoint from any other $\mathcal{D}_n$ and $\mathcal{T}_n$ for $m \neq n$. However, in TL, parameters among domains and tasks $m$ and $n$ for all $m$ and $n$ can be shared, see Fig. \ref{TL3}. Any shared part of the domains or the tasks can be referred as "knowledge", e.g., all or the portion of the feature and the label spaces (data sets), or $f(.)$ and its hyper-parameters (models). TL aims to improve the performance of $\mathcal{T}_n$ with $\mathcal{D}_m$ and $\mathcal{T}_m$. We consider the following two key performance measures for target $n$:
\begin{itemize}
\item \textit{Accuracy, consistency and generalization} of learning in the target domain: $\eta^{TL}_n=\frac{P^{\text{TL}}_n}{P^{\text{Traditional}}_n}$ where $P^{\text{TL}}_n$ and $P^{\text{Traditional}}_n$ are the performance measures of the AI algorithm $n$ with and without TL, respectively.
\item Training time in the target domain: $\tau^{TL}_n=\frac{T^{\text{Traditional}}_n}{T^{\text{TL}}_n}$ where $T^{\text{TL}}_n$ and $T^{\text{Traditional}}_n$ are the training times of the AI algorithm $n$ with and without TL, respectively.
\end{itemize}
Now we can defined positive TL as a case that $\eta^{TL}_n>1$ and $\tau^{TL}_n>1$. The above definitions are for one source and one target and it can be extended to any set of sources and targets.
From 6G's preservatives, to have successful TL, required bandwidth, delay, the level of security and privacy of passed knowledge between sources and targets should be determined. Also, the granularity of TL algorithm and the iteration number to pass knowledge between source and target should be determined. For instance, we can have following classes of interaction among source and targets:
\begin{itemize}
\item \textit{Real-time TL} where the knowledge is passed between source and target as soon as a new update is available;
\item \textit{Non real-time or semi-real time TL }where the knowledge between the sources and the targets are passed according to a schedule;
\item\textit{ On-demand TL} where the knowledge is passed from the source to the target when a request from the target is initiated.
\end{itemize}
These types of interactions together with the end-to-end (E2E) delay determine the required bandwidth between each source-target pair. These parameters can be used to deploy the pipe-line for TL, demonstrated in Fig. \ref{TL3}. An important point is that the TL pipe-line causes additional overhead and cost for passing knowledge. Below we identify different types of overheads and costs are incurred in TL. One approach to obtaining a single measure for overhead and cost is to use a weighted sum of the components: \begin{eqnarray}
\lefteqn{\Theta^{\text{TL}}_{mn}=\alpha_1 f_1(W_{mn})+ \alpha_2 f_2(D_{mn})}\\&& \,\,\,\,\,\,\,\,\,\,\,\, + \alpha_3 g_{mn}(\text{ interaction}) +\alpha_4 h_{mn}(\text{security}), \nonumber
\end{eqnarray} where $\alpha_1, \alpha_2, \alpha_3, \alpha_4$ are regularization weights and functions are defined as:
\begin{itemize}
\item $f_1(W_{mn})$ and $f_2(D_{mn})$ are increasing and decreasing functions of required E2E bandwidth $W_{mn}$ and delay $D_{mn}$, respectively;
\item $g_{mn}(\text{ interaction})$ shows the cost per interaction class, defined as
$$g_{mn}(\text{ interaction}) =
\left\{\begin{array}{lr}
M_1, & \text{if} \,\, \text{Real-time},\\
M_2, & \text{if } \,\,\text{Non-Real time},\\
M_3 & \,\,\text{Otherwise,}
\end{array}\right.$$
where $M_1$, $M_2$, $M_3$ are positive values demonstrating the costs related to each class and they can be set as $M_1\geq M_2 \geq M_3$ by wireless network infrastructure providers. The good policy also can be designed to reduce the cost of overhead, for instance by sending the TL knowledge among the source and the target in non-rush hour time windows.
\item $h_{mn}(\text{security})$ is the security related cost function and it is an increasing function with the level of requested by source $m$ and target $n$.
\end{itemize}
Clearly, decreasing the overhead while attaining positive performance of the learning AI are major indicators of effectiveness of TL in 6G.
\begin{figure}
\begin{center}
\includegraphics[width=3.2 in]{figs/TL89}
\caption{Transfer learning and its pipe-line inside of 6G }
\label{TL3}
\end{center}
\end{figure}
There are several categories of TL based on \textit{what} can be transferred among sources and targets and the similarities and differences between their domains and tasks. For example, based on the availability of labels, there are three categories of TL:
\begin{itemize}
\item Transductive TL where the label data is available only from the source not the target and $\mathcal{D}_m\neq \mathcal{D}_n$ while $\mathcal{T}_m = \mathcal{T}_n$
\item Inductive TL where label data are available for the source and targets but the tasks are different, i.e., $\mathcal{T}_m \neq \mathcal{T}_n$
\item Unsupervised TL where the label data is not available in neither source or target
\end{itemize}
Based on domains, we have
\begin{itemize}
\item Heterogeneous TL where $\mathcal{D}_m \neq\mathcal{D}_n$
\item Homogeneous TL where $\mathcal{D}_m=\mathcal{D}_n$
\end{itemize}
and based on the solution approach, we have
\begin{itemize}
\item Instance-based TL where samples of data sets are shared between the source and target
\item Feature-based TL where original features of the source are matched to target ones, or where for both source and target features, latent features or common features are discovered.
\item Parameter-based TL which involves transferring the parameters of models
\item Relational-based TL which transfer the learned rules from source to the target
\end{itemize}
In the following, we will discuss how TL should be processed in 6G and give examples of the above categories of TL in 6G.
\section{Aspects of Efficient TL in 6G}
In this section, we study effects of TL in 6G and show how 6G should be adapted to serve AI/ML use cases. Many AI/ML use cases in 6G involve learning/control loops containing \textit{monitoring, analysis, policy, execution plus knowledge} steps, denoted as (MAPE-K) loops. A MAPE-K loop provides a unified way to represent these AI/ML based applications \cite{ENI,AIaaSpaper}. TL can be deployed between ML algorithms that are normally present in the analysis step of MAPE-K loops associated diverse services in OTT, and/or networking applications (NAL). In this paper, for simplicity, we assume there is one MAPE-K loop per each AI/ML algorithm which can be a target or a source of TL. Let's start our discussions with some examples to show how TL can be used in 6G.
\subsection{Examples of TL in 6G}
In 6G, many use cases in networking share the spatio-temporal features or similar information in performing various tasks. Let's focus on resource allocation (RA), energy efficiency (EE), and admission control (AC) of radio access networks (RANs) for one specific area in 6G. There are several access nodes, e.g., ORANs, in a region that provide coverage (see Fig. \ref{fig:TL4}).
All of these tasks utilize the mobility pattern and traffic pattern of end-users. Therefore, the domains are similar but the tasks are different. Any ORAN can share its own domain among its own different tasks. Also, ORAN 1 can share its own task and domain for the resource allocation (RA) with the resource allocation (RA) in ORAN 2; which is an example of to transduction TL where the source is RA in ORAN 1 and the target is RA in ORAN 2. If the resource allocation (RA) in RAN 2 also shares its domain or tasks with the resource allocation (RA) in RAN 1, we have inductive TL. If both RANs do not have labeled data, there is unsupervised learning among them. The resource allocation (RA) in ORAN 1 and ORAN 2 can share their knowledge in real-time, non-real time and on-demand cases. For the last two cases, depending on the amount of available bandwidth, TL among ORAN 1 and ORAN 2 can be scheduled to reduce $\Theta^{\text{TL}}_{\text{ORAN1}, \, \text{ORAN2}}$. The same is true for the energy efficiency (EE) in both ORAN 1 and ORAN 2. However, there is a chance that the energy efficiency (EE) decision is in contrast with an RA decision. For instance, the resource allocation (RA) requires more resource to guarantee the QoS while the energy efficiency (EE) asks for less power consumption and releasing some resources. These examples demonstrate the importance of interaction and TL management in 6G.
These AI/ML algorithms can share the domains and tasks with another part of the RAN in different cities or different locations. In this case, we can have parameter or instance or feature based TL. The resource allocation, admission control, and the energy efficiency in ORANs of one area can share their models and data sets with the core elements to derive more large scale mobility patterns and network user behaviors. In this case, one probable scenario is to share the domain of RANs with the core to increase the size of data sets of core elements without additional cost. The knowledge can be fully or partially shared among AI/ML algorithms in 6G.
\begin{figure}
\centering
\includegraphics[width=2.9 in]{figs/TL4}
\caption{One scheme of the TL examples in zone 1 and zone 2 of 6G}
\label{fig:TL4}
\end{figure}
The mobility pattern of 6G nodes, which arises from NAL applications, can be transferred to ITS, which is an OTT application, or vice versa. Various types of TL can be applied here. The similarity between these two use cases is obvious. However, 6G can encounter more complex scenarios. For example, for cyber-security, 6G may require a behaviour and traffic model of legitimate users of OTT use cases. In this case, the domains and the tasks of both cases are not correlated. Therefore, we have heterogeneous TL here, and any solution based categories of TL can be applied.
\subsection{Hierarchy and Spatio-temporal Features of 6G and TL}
Wireless networks have hierarchical structures. Also, our examples in the previous section show that there is an inherent spatio-temporal feature among different location zones, RANs, and core entities. These features help create positive TL in 6G for clustering and classifications AI/ML algorithms. Therefore, hierarchy and Spatio-temporal features of traffic of users in 6G can be used as the criteria for the clustering AI/ML algorithms for TL. In Figs. \ref{fig:TL2} (a) and (b), we plot some models of interaction of AI/ML algorithms for TL in 6G which can basically derived from both hierarchy or spatio-temporal feature of 6G. In Fig. \ref{fig:TL2}, we present three models:
\begin{itemize}
\item Cascade AI/ML algorithms in (i) which can show the neighboring ORANs transferring their models and data sets for mobility or traffic patterns of users
\item Hierarchical AI/ML algorithms in (ii) which can represent the interaction between access and core elements in TL
\item Parallel AI/ML algorithms (iii) belong to the case that the similar nodes (base stations, switches, storage devices) collaborate to learn the similar models based on their local data sets through the concept of federated learning (FL). Also, they can share their public (not very sensitive data sets in terms of privacy) with their peers.
\end{itemize}
This hierarchical structure inside of 6G can help to find the correlation, similarities, and relation among sources and targets.
\begin{figure}
\centering
\includegraphics[width=3.62 in]{figs/TL5}
\caption{The hierarchy and interaction among AI/ML use cases in 6G for three models of interaction (i) cascade model (ii) Hierarchical model, (iii) parallel model. }
\label{fig:TL2}
\end{figure}
\subsection{6G Architecture Modifications}
We see the 6G architecture as including four planes to serve these use cases and to handle their needs associated with TL \cite{9200631,AIaaSpaper}. We define responsibilities of each plane as follows:
\begin{itemize}
\item \textbf{Application Plane} which represents the MAPE-K loops as chains of functions/services that implement the data collection processing and action pipe-lines that implement the loops, along with their required QoS and QoE. The ML algorithm(s) in each MAPE-K loop can be the source or target for algorithms in other MAPE-K loops. Application plane determines following items for TL:
\begin{itemize}
\item A list of trustful targets;
\item A list of trustful sources;
\item Parts of models and tasks that are allowed to be shared;
\item Required levels of security and privacy;
\item TL angularity with any specific source and target;
\item Privacy and security level;
\item Required E2E delay for TL with any specific source and target;
\item Required bandwidth for any allowable TL.
\end{itemize}
The above parameters help to determine the service level agreement (SLA) for any pair of the source and target in TL. These SLAs will be used in 6G to establish appropriate pipe-lines per each MAPE-K loop.
\item \textbf{Infrastructure Plane} which is an E2E cloud-native, multi-tier, programmable structure with virtualized communication and computation resources. This plane inherits the software defined and virtualized structures of 5G and it is responsible to provide TL pipe-lines from sources and targets for both OTT and NAL applications. The request for setting up a TL pipe-line is sent by a management plane to the infrastructure plane. Other pipe-line parameters are derived from SLAs in application plane.
\item \textbf{Management Plane} which is in charge of monitoring all running services and Required admission for new requests of services in fully autonomous manner. In 6G, this plane should include procedures to handle the conflicts that may arise among MAPE-K loops, pertaining to the consistency and coherency of loops \cite{AIaaSpaper}, and TL management. These new procedures along with orchestrator and infrastructure management are shown in boxes in Fig. \ref{6Gtrainingmanagement}. TL manager has following tasks:
\begin{itemize}
\item Determining who can initiate TL among MAPE-K loops and services in 6G. For instance, among networking applications, TL request can be issued by network elements (decentralized manner) or can be handled by the orchestrator (centralized manner). For the OTT applications, the request can be originate with the OTT applications;
\item Determining authorized TLs among MAPE-K loops;
\item Initiating and handling TL for one or multiple service/infrastructure providers and OTT slices for different organizations.
\end{itemize}
The request for setting up TL pipe-line among MAPE-K loops can be initiated from use cases. For example in an OTT, an Intelligent Transportation System (ITS) may send a request for TL to get data about the mobility pattern of users. In a NAL setting, a request for TL can be started by network management plane. In both cases, the orchestartor will handle the setup procedure for providing the TL pipe-line in the infrastructure by monitoring security, reliability, and privacy. In general, all the \textit{coordination} among sources and targets are handled by this plane. This task is more complex when dealing with multi-source multi-task TL and when the sources and targets are in different networks or OTT applications.
\item \textbf{Training Plane} which is a new plane in 6G to integrate AI and ML into the network \cite{AIaaSpaper,ITUTreport} and to provide sandboxes that mimic the real environment with the goal of training, retraining and examining any AI based use cases in offline, near-online and online manner \cite{ITUTreport}. To support TL, this plane provides an environment to measure the TL positive effects on the targets' learning procedures. It should learn the similarity and correlations among sources and targets to attain positive TL for both NAL and OTT use cases. It also needs to be equipped with the means to extract the knowledge from domains and tasks of each AI based application. We represent these tasks in four boxes in Fig. \ref{6Gtrainingmanagement}, defined as: \\1)
\textit{Sandboxes} which are responsible to provide simulation/ emulation environments for TL, clustering and finding the beneficial correlation among sources and targets. These reports should be sent to the second box of the management plane. \\2) \textit{Knowledge extraction } which can provide parameters from domains and tasks of sources and targets for TL (knowledge). This knowledge is ready to transfer between source-target pairs depending on TL categories. \\3) \textit{Repositories of data and knowledge} which are storage units to store and retrieve knowledge for TL among sources and targets.
\end{itemize}
In 6G, the training and management plane have tight interaction to attain efficient TL. All actions in boxes in the training plane are sent to the management plane to execute the interaction and knowledge transfer among the MAPE-K loops. In Fig. \ref{6Gtrainingmanagement}, we show arrows between boxes to highlight the importance of these interfaces.
\begin{figure}
\begin{center}
\includegraphics[width=3.1 in]{figs/TL6}
\caption{Training and management aspects of 6G to provide TL. }
\label{6Gtrainingmanagement}
\end{center}
\end{figure}
\subsection{Repository of Knowledge of TL in 6G}
In the repository, the models and data sets of each target-source pair can be stored and used for TL among similar/correlated OTT and networking use cases when permitted. For instance, the following information can be stored in the repository:
\begin{itemize}
\item End-Users which are smart phones, IoT devices (e.g., smart watches), autonomous vehicles, and sensors. These devices can share the following:
\begin{itemize}
\item Models and data sets related to UE/Session related parameters, e.g., mobility pattern, spatio-temporal traffic model, wireless channel and coverage model, QoS, and QoE.
\end{itemize}
\item Radio-access level devices including base stations, radio remote heads (RRHs), cloud radio access networks (CRAN) or open RANs (ORANs) where they provide coverage for specific area. These entities can share the following:
\begin{itemize}
\item Models and data sets per each region for spatio-temporal traffic and mobility models of users in that area, network measurements and logs, RAN-related parameters (e.g., channel quality), load, interference, user density. resource condition parameters (e.g., availability of front-haul), reliability and robustness of services.
\end{itemize}
\item Core-level devices including switches, firewalls, packet gateways, computing devices, storage devices of the users' information, and clouds inside of the networks, which can share the following:
\begin{itemize}
\item Models and data sets for processing load and availability of core functions (both virtual and physical), load and availability of computing resources, large scale spatio-temporal traffic and mobility per zone for each type of services and slices, core network measurements and logs, and procedure level task information.
\end{itemize}
\item OTT and service applications including traditional data and voice services, smart services for different sectors of industry, and slices which can provide
\begin{itemize}
\item Models and data sets for slice QoS and QoE, slice isolation, spatio-temporal traffic and mobility per slice, measurements, and logs per slices,
\end{itemize}
\item Management level which includes all the OSS and BSS parameters and they can share the following parameters inside of the network or with another network provider:
\begin{itemize}
\item Models and data sets for fault, configuration, accounting, performance, and security (FCAPS) and the management reports
\end{itemize}
\end{itemize}
Repository of knowledge in TL can be handled by training plane where seasonal, daily, and weekly patterns of any knowledge, models and data sets can be provided for different MAPE-K loops. However, the management plane takes care of initiating and allowing the TL procedures between any source and target in private and secure manner.
\section{Challenges and Future Works }
TL will play an important role in simplifying and streamlining the use of AI and ML in 6G networks. One of the major challenges of deploying TL is to deal with the vast number of possible approaches and formulations, so choosing the best TL approach is a major implementation challenge in 6G. Also, TL mechanism should be tuned based on the use case which poses the challenge of finding new procedures to handle TL in more general manner.
There exist overlaps between TL and other concepts such as federated learning, semi-supervised learning, multi-view learning, and most importantly, multi-task learning. Having a unified view of TL and highlighting its overlaps with other context can unlock the potential of TL in 6G.
Adaptation of TL for reinforcement learning (RL) in dynamic environment is another challenge \cite{zhu2021transfer,JMLR09-taylor}. Here, to have positive TL, transformation of different parts of the information from the source (e.g., state-space, action-space, reward, and transition dynamics) to the target should be studied. Since there is more spatio-temporal dynamic behavior in the system, TL needs more adaptation of the parameters. Most of the recent works are well-tuned approaches for specific applications of TL in RL. Framework-agnostic TL for RL is of desirable in 6G.
Positive TL requires appropriate clustering, correlation, and similarity detection among sources and targets. This can be efficiently handled for homogeneous TL among sources and tasks. However, in heterogeneous scenarios, adapting the source and target domains and tasks are not trivial. Deriving latent variables in data sets of different AI/ML algorithms can also lead to positive TL and attain the better clustering and similarities among tasks.
In the most works, TL is used for a pair of one source and one target. However, as mentioned in the examples above, in 6G, there is a set of sources aiming to share their information with a set of targets. Expanding all the existing formulations of one source-target pair TL to multi-source multi-target TL in 6G can be considered as another future research direction.
Preserving the required security and privacy and preventing any threat from attackers during the knowledge transfer among AI/ML algorithms are also another important issue for efficient TL in 6G. TL in 6G should be immunized against eavesdropping, GAN attacks (for models and data sets), poisoning, and Sybil attacks.
\section{Deployment Scenario:\\ Quantization to Reduce TL Overhead}
To overcome TL extra overhead in 6G, in this section, we study how quantization algorithms can compensate this practical challenge. Quantization in this context is a class of techniques for performing computations and storing tensors at less number of bits than floating point case. Consequently, a quantized model executes some or all of the operations on tensors with integers rather than floating point values, leading to a more compact model representation for DNNs.
We implement TL pipe-line between two neural networks in
which one of them is trained on the CIFAR-10 data set and the neural network model is
MobileNetV2 \cite{mobilenet} and we apply \cite{quantization}. Fig. \ref{fig:quantization-acc} shows the performance of quantized algorithms with the case that the exact values of weights are passed
among neural networks, i.e., \textit{Floating point method} which requires 32 bits of
data per weights of neural networks. In
Fig. \ref{fig:quantization-acc}, the accuracy of training phase shows the
performance of floating point approach versus following quantization algorithms
for 8 bits per each weight \cite{quantization}:
\begin{itemize}
\item \textit{Default} quantization approach which applies uniform
quantization levels between minimum and maximum values of weights
\item \textit{FBGEMM} where by considering the
distribution of the weights, quantization levels is adjusted
which leads to better
accuracy compared to \textit{Default} quantization approach
\item \textit{Quantization aware training (QAT)} In the above
approaches, quantization is applied at the end of the model training.
In this approach, after that, the model is fine-tuned on the quantized weights by
training a couple of more iterations to improve the accuracy. In our experiments,
this method leads to 1\% better accuracy compared to \textit{FBGEMM} from Fig. \ref{fig:quantization-acc}.
\end{itemize}
Fig. \ref{fig:quantization-acc} highlights that by 75\% decreasing the load of the network (8 bits/32 bits) ($f_{mn}(\text{interaction})$), still the accuracy of training phase is in the acceptable range for \textit{QAT}. To demonstrate it figuratively, in Fig.
\ref{fig:quantization-size}, the size of the quantized model is compared to that
of the original model. As shown in this figure, the size of the model is reduced
to 75\%. This simulation shows that the quantization is an appropriate
method to make a trade-off between performance and amount of messages in the AI-aaS based networks.
After passing the quantized weights, we can re-tune the final layer of the model in the target to increase the accuracy. We use a Pytorch tutorial of "Quantized Transfer Learning for Computer Vision" and its colab version \cite{quantizationforTL}. By re-training the model at the target, the accuracy level will be increased up to the case without quantization. The re-training phase in the target takes $3$ m and $16$ sec versus while full training requires $10$ m and $16$ sec for convergence. On the other hand, we have $\tau^{\text{TL}}=3.142$, meaning that TL can improve the energy efficiency with the factor $\tau^{\text{TL}}$, and consequently, improving sustainability in 6G.
\begin{figure}
\centering
\includegraphics[width=0.45\textwidth]{figs/Q1}
\caption{Percentage of accuracy of target versus quantization approaches}
\label{fig:quantization-acc}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.45\textwidth]{figs/Q2}
\caption{The amount of overhead of quantized versus non-quantized TL in 6G}
\label{fig:quantization-size}
\end{figure}
\section{Conclusion }
In this paper, we address how efficient transfer learning (TL) in 6G can be attained. We introduce metrics to assess efficiency TL from both learning algorithm and networking aspects. We discuss possible modifications in 6G architecture to handle TL and we define new elements in the network management plane. We focus on new activities in training plane and its repositories for TL in 6G. With some examples and looking at spatio-temporal features of wireless networks, we show how classifications and clustering of algorithms in 6G can be attained to reach efficient TL. For positive TL, we require more unified view of TL approaches with security and privacy guarantees discussed in this paper.
\bibliographystyle{IEEEtran}
| {'timestamp': '2021-07-14T02:04:20', 'yymm': '2107', 'arxiv_id': '2107.05728', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05728'} | arxiv |
\section{Padding}\label{sec:padding}
Recall that the goal is to reduce the problem of finding a
$(1/n^5)$-approximate HZ equilibrium to that of finding a $(1/n^c)$-approximate
HZ equilibrium, for some constant $c>0$.
Let $M$ be an HZ market with $n$ goods, $n$ agents and utilities $u_{i,j}$.
Let $N=n^{5/c}$. We create a new market $M^*$ with $nN$ goods and $nN$ agents.
This is done by replacing each good $j$ in $M$ by a group
of $N$ goods $G_j$ and replacing each agent $i$ in $M$ by a group
of $N$ agents.
Agents in each group $G_i$ have the same utility $u_{i,j}$ for goods in $G_j$.
Given that $c$ is a constant, $M^*$ can be constructed in polynomial time.
Now let $(x^*,p^*)$ be an $\epsilon$-approximate HZ equilibrium of $M^*$ with
$$
\epsilon=\frac{1}{(nN)^{c}}\le \frac{1}{n^5}.
$$
We derive a pair $(x,p)$ for the original market $M$ as follows:
set $p_j$ to be the minimum price of goods in $G_j$; set $x_{i,j}$ to be
the total allocation of goods in $G_j$ to agents in $A_i$ divided by $N$.
We prove that $(x,p)$ is an $\epsilon$-approximate HZ equilibrium of $M$.
The first two conditions hold trivially by the uniform scaling.
For the third condition we note that the total cost of bundles of
$A_i$ in $(x^*,p^*)$ is at most $N(1+\epsilon)$.
Therefore the cost of the bundle $x_i$ of agent $i$ is at most $1+\epsilon$
because prices of goods can only go down.
For the last property, we note that the utility of agent $i$ from $x_i$
is the same as the total utility of agents in $G_i$ divided by $N$.
On the other hand, the LP for agent $i$ (with respect to $p$)
is the same as the LP for each agent
in $G_i$ (with respect to $p^*$), after removing subsumed constraints.
So they have the same optimal value. This finishes the correctness proof of the reduction.
\section{Disconnected Equilibria}
\label{sec:disconnectedEq}
\begin{figure}[!ht]
\centering
\includegraphics[width=.6\textwidth]{multEq.png}
\vspace{0.2cm}\caption{Market with disconnected equilibria.}
\label{fig:galaxy1}
\end{figure}
We provide a simple example showing that there exists disconnected equilibria even when the HZ market contains only four agents (i.e., $n = 4$) and the utility is drawn from $\{0, 1/2, 1\}$. The example is indeed the variable gadget we used in Section~\ref{sec:np}, we present it here for completeness.
Consider the following HZ market. There are two groups of agents, $A_1$ and $A_2$, and there are three groups of goods, $G_1$, $G_2$ and $G_3$. Let $|A_1| = |A_2| = 2$, $|G_1| = |G_3| =1$ and $|G_2| = 2$. Each agent in $A_1$ has utility $1/2$ for goods $G_1$, utility $1$ for goods $G_2$ and utility $0$ for goods $G_3$. Each agent in $A_2$ has utility $0$ for goods $G_1$, utility $1$ for goods $G_2$ and utility $1/2$ for goods $G_3$.
In any (exact) equilibrium, all goods in the same group
must clearly have the same price, because otherwise the most expensive
good in the group will remain unsold.
Let $p = (p_1, p_2, p_3)$ denote an equilibrium price vector of $G_1, G_2, G_3$, with $\min_i p_i =0$.
Since both $A_1$ and $A_2$ have utility $1$ for $G_2$, the price $p_2 > 1$, because otherwise $G_2$ will be oversold.
\begin{claim}
There are three disconnected equilibria in the above HZ market, with equilibria prices $(0,2,0)$, $(0, 8/5, 4/5)$ and $(4/5, 8/5,0)$ respectively.
\end{claim}
\begin{proof}
Since goods $G_1$ and $G_3$ are symmetric, w.l.o.g., we can assume $p_1 = 0$. The optimal bundle of $A_1$ contains exactly goods $G_1$ and $G_2$ in this case, and we know agents $A_1$ purchase $2/p_2$ unit of goods $G_2$ and $2 - 2/p_2$ unit of goods $G_1$ in total.
We conclude $p_2 \leq 2$ since there is at most $1$ unit of goods $G_1$.
When $p_2 = 2$, agents $A_1$ get $1$ unit of $G_1$ and $1$ unit of $G_2$, and therefore, agents $A_2$ get $1$ unit of $G_2$ and $1$ unit of $G_3$. We have $p_3 = 0$ in this case. Thus, the price vector in
this case is $(0,2,0)$.
On the other hand, when $p_2 < 2$, the optimal bundle of agent $A_2$ must contain all three goods. Hence, we have $p_2 = 2p_3$ and $2p_2 + p_3 = 4$. This leads to $p_2 = 8/5$ and $p_3 = 4/5$. The equilibrium allocation of $A_1$ equals $(3/4,5/4, 0)$ for agents $A_1$ and $(1/4, 3/4, 1)$ for agents $A_2$.
The equilibrium price vector in this case is $(0, 8/5, 4/5)$.
Symmetrically, when $p_3=0$, there is an equilibrium price vector
$(4/5, 8/5,0)$.
\end{proof}
\begin{remark} If we consider also unnormalized prices (i.e. include price vectors with $\min_i p_i >0$), the set of equilibrium price vectors consists of three disjoint regions:
$\{ (p, 2-p, p) | p \geq 0 \}$, $\{ (1-q,1+3q,1-5q) | 0 < q \leq 1/5 \}$, and $\{ (1-5q,1+3q,1-q) | 0 < q \leq 1/5 \}$.
The equilibrium allocations are the same as in the normalized price vectors in the three cases.
\end{remark}
\section{Discussion}
In this paper we resolved the complexity of computing an approximate equilibrium in the Hylland-Zeckhauser scheme for one-sided matching markets: we showed that the problem is PPAD-complete, and this holds even for inverse polynomial approximation and four-valued utilities. We leave open the complexity of exact equilibria, in particular whether the problem is FIXP-complete. Another open question is whether the PPAD-hardness of the approximation problem holds also for 3-valued utilities.
\section{Introduction}
\label{sec:intro}
In a {\em one-sided matching} problem, there is a set $A$ of $n$ agents and a set $G$ of $n$ goods, and we are given a specification of the preferences of the agents for the goods.\footnote{In the statement of the problem, we have the same number of agents and goods for simplicity. In general there can be $n_1$ agents, each with their own demand $d_i$, and $n_2$ goods, each with its own supply, $s_j$,
where $\sum_{i \in n_1} d_i = \sum_{j \in n_2} s_j$.
It is clear that this setting reduces to the simpler case of equal numbers of agents and goods.}
The problem is to find a matching between the agents and the goods (assigning a distinct good to each agent) that has desirable properties, such as Pareto optimality, envy-freeness, incentive compatibility.
This situation, where only one side has preferences, arises in many settings, such as assigning students to schools, assigning faculty members to committees, workers to tasks, program committee members to papers, students to courses with limited capacity, etc.
Since many agents may have the same or similar preferences, it is usually not possible to offer everybody their favorite good. So a solution mechanism has to strive to be equitable, satisfy the agents as much as possible, and incentivize them to give their true preferences (i.e., not gain an advantage by lying).
Randomization is often useful to meet fairness requirements.
A randomized solution mechanism has probability $x_{i,j} \in [0,1]$ of matching each agent $i$ to each good $j$; these probabilities form a doubly stochastic matrix, i.e., a fractional perfect matching in the bipartite graph between agents and goods.
In some applications, the goods may be divisible, or they may represent tasks or resources that can be shared among agents;
in these cases the quantities $x_{i,j}$ represent the shares of the agents in the goods.
There are two main ways of specifying the preferences of each agent $i \in [n]$ for the goods: (1) {\em cardinal preferences}, where we
are given the utility $u_{i,j}$ of agent $i$ for each good $j \in [n]$,
or (2) {\em ordinal preferences}, where we are given the agent's total
ordering of the goods.
Cardinal preferences allow for a finer specification of the agents' preferences (although they may require more effort to produce them).
As a result, they can yield better assignments.
Consider for instance the following example from \cite{hz79}: There are 3 agents and 3 goods. The utilities of agents 1 and 2 for the three goods are 100, 10, 0, while agent 3 has utilities 100, 80, 0.
The ordinal preferences of the three agents are the same, so any fair mechanism will not distinguish between them, and will give them each probability 1/3 for each good.
The expected utilities of the three agents in this solution is
$36 \frac{2}{3}, 36 \frac{2}{3}, 60$.
This solution is not Pareto optimal, i.e., there is another solution where all agents are better off. Agent 3 is assigned good 2, and agents 1, 2 randomly split goods 1 and 3. The expected utilities of the three agents in this solution are $50, 50, 80$.
In 1979 Hylland and Zeckhauser proposed a, by now, classic scheme for the one-sided matching problem under cardinal preferences \cite{hz79}.
The scheme uses a pricing mechanism to produce an assignment of probability shares $\{ x_{i,j} | i,j \in [n] \}$ of goods to agents,
i.e. a fractional perfect matching, and these are then used in
a standard way to generate probabilistically an integral perfect matching. The basic idea is to imagine a market where
every agent has 1 dollar, and the goal is to find prices for the goods and (fractional) allocations $x_{i,j}$ of goods to the agents,
such that
the market clears (all goods are sold), while every agent maximizes
her utility subject to receiving a bundle of goods of size 1 and cost at most 1. Hylland and Zeckhauser showed that such an equilibrium
set of prices and allocations always exists, using Kakutani's fixed point theorem. Note that money here is fictitious; no money changes hands. The only goal is to produce the allocation (the shares $ x_{i,j}$) so that it reflects the preferences of the agents. The HZ scheme has several desirable properties: it is Pareto optimal, envy-free \cite{hz79}, and it is incentive compatible in the large \cite{he18}. The scheme has been extended and generalized in various ways since then.\newpage
Although the HZ scheme has several nice properties, one impediment is that, despite much effort, there is no efficient algorithm known to compute an equilibrium solution. This has remained an open problem till now. In \cite{akt17}, Alaei, Khalilabadi and Tardos gave polynomial-time algorithms for the case that the number of goods or the number of agents is a fixed constant (the case of a constant number of goods can be derived also from \cite{dk08}). Recently in \cite{vy21}, Vazirani and Yannakakis gave a polynomial-time algorithm for the bi-valued case, where every agent's utilities take only two values.
They also gave an example showing that the equilibrium prices and allocations can be inherently irrational. In the general case, they showed that the problem of computing an equilibrium solution is in the class FIXP. Furthermore, computing an $\epsilon$-approximate equilibrium is in the class PPAD, where in an approximate equilibrium an agent may get a slightly suboptimal allocation and may spend $1+\epsilon$ dollars. They leave open the problem whether computing an exact or approximate equilibrium is complete for the classes.
In this paper we resolve the complexity of computing an approximate equilibrium
of the HZ scheme. Our main result is:
\begin{theorem}[Main]
\label{thm:hz-equilibrium}
The problem of computing an $\epsilon$-approximate equilibrium
of the HZ scheme is PPAD-complete
when $\epsilon=1/n^c$ for any constant $c>0$.
\end{theorem}
In our construction, every agent has at most 4 different utilities for the goods. Thus, the problem is PPAD-complete even for 4-valued utilities\footnote{The case of a small number of values is natural. For example, the authors have been in committees that ask them to
rate their level of interest in the submissions by values in a limited range, e.g. 0-4.}. We leave the 3-valued case open. We give however a simple example with values in $\{0, 0.5, 1 \}$ showing that there can be multiple disconnected equilibria, thus suggesting that usual convex programming methods may not work (at least a convex program will not include all equilibria).
A given instance of the one-sided matching problem may have multiple HZ equilibria.
All of them are Pareto optimal, but some may be preferable to others when other criteria are considered.
One such criterion is the social welfare, i.e., the total weight of the matching
(or the sum of utilities of agents).
We study the problem of approximating the optimal social welfare achievable
by an HZ equilibrium.
We show that this is an NP-hard problem:
\begin{theorem}
\label{thm:social-welfare}
Given an instance of the one-side matching problem and a value $w$, it is NP-hard to distinguish the case that the maximum social welfare of an HZ equilibrium is at least $w$ from the case that it is at most
$(\frac{175}{176} + \epsilon)w$ for any constant $\epsilon>0$.
\end{theorem}
\section{Hardness of Approximating Optimal Social Welfare}
\label{sec:np}
In this section we study the problem of
approximating the optimal social welfare (defined as the total utility of all agents)
achievable by an HZ equilibrium.
For this purpose we study the following gap problem for a constant $\rho<1$:
the input is an HZ market $M$ together with a parameter $\textsf{SW}$, and it is promised
that the optimal social welfare achievable by an exact HZ equilibrium of $M$ is either at least $\textsf{SW}$
or at most $\rho\cdot \textsf{SW}$.
The goal is to tell which case it is.
We show that there is no polynomial-time algorithm
for the gap problem when $\rho>175/176$, assuming $\mathsf{NP}\ne \mathsf{P}$.
\begin{theorem}
\label{thm:np-hard}
Assuming $\mathsf{NP}\ne \mathsf{P}$, for any constant $\epsilon > 0$, there is no polynomial-time algorithm
for the gap problem when $\rho=({175}/{176}) + \epsilon$.
\end{theorem}
\subsection{Construction}
We reduce from $\mathsf{MAX}~3\mathsf{SAT}$, which is hard to approximate better than ${7}/{8}$ \cite{haastad2001some}: Given a $3\mathsf{SAT}$ instance, it is NP-hard to distinguish the case that the formula is satisfiable from the
case that every truth assignment satisfies at most a fraction $\frac{7}{8}+\epsilon$ of the clauses, for any $\epsilon>0$.
Given a $3\mathsf{SAT}$ instance with $m$ clauses and $n$ variables, we construct the following HZ market. Throughout the proof, we fix $K = m^3$.
\paragraph{Creating Variable Gadget} We first introduce the variable gadget. For convenience, we only list non zero utilities.
For each $i \in [n]$
\begin{enumerate}
\item Create three groups of goods $G_{i, 1}$, $G_{i, 2}$, $G_{i,3}$, and $|G_{i,1}| = K$, $|G_{i,2}| = 2K$ and $|G_{i,3}| = K$.
\item Create two groups of agents $A_{i,1}$, $A_{i,2}$, and $|A_{i,1}| = |A_{i,2}| = 2K$.
\item Agents in $A_{i,1}$ have utility $\frac{1}{2K^2}$ for $G_{i,1}$, $\frac{1}{K^2}$ for $G_{i,2}$. Agents in $A_{i,2}$ have utility $\frac{1}{2K^2}$ for $G_{i,3}$, $\frac{1}{K^2}$ for $G_{i,2}$.
\end{enumerate}
In an (exact) HZ equilibrium, all goods within a group have the same price. We use $p(G_{i, \ell})$ to denote the price, $\ell \in [3]$.
\paragraph{Creating Clause Gadget}
We next construct clause gadgets. For each $j \in [m]$,
\begin{enumerate}
\item Create a group $G_j$ of $K$ goods
\item Create a group $A_{j, *}$ of $2K$ agents, who have utility $1/K^2$ for $G_{j}$.
\item Create an agent $A_{j}$ with utility $1$ for $G_j$. It has utility $5/6$ for $G_{i, 1}$ if the $j$-th clause contains $x_i$ and utility $5/6$ for $G_{i, 3}$ if the $j$-th clause contains $\bar{x}_i$.
\end{enumerate}
\paragraph{Adding Dummy Goods}
Thus far, we have described $4Kn + Km$ goods and $4Kn + (2K+1)m$ agents. We add $(K +1)m$ extra dummy goods that have zero utilities for all agents. In a normalized (exact) HZ equilibrium, these goods have zero price.
\subsection{Proof of Correctness}
We provide the proof of completeness and soundness separately.
\paragraph{Completeness} Given a $3\mathsf{SAT}$ instance that has a satisfying assignment, we construct a HZ equilibrium with social welfare at least ${11}m/{12} - O(1/m^2)$. Fix a satisfying assignment.
We assign the $j$-th clause to the $\phi(j)$-th variable, if the latter satisfies the clause. If there are multiple such variables, we choose an arbitrary one.
We set $\ell(j) = 1$ if the $j$-th clause contains $x_{\phi(j)}$, otherwise $\ell(j) = 3$.
Let $s_i$ be the total number of clauses assigned to the $i$-th variable.
The equilibrium prices are as follows.
\begin{enumerate}
\item The price of dummy goods is $0$.
\item The price of $G_j$ is $p(G_j) = \frac{2K+1}{K}$, $j \in [m]$.
\item For variable gadget $i \in [n]$, if $x_i = 1$, then $(p(G_{i, 1}), p(G_{i, 3}), p(G_{i, 2})) = (0, \frac{8}{5}, \frac{4}{5})$, otherwise, we have $(p(G_{i, 1}), p(G_{i, 2}), p(G_{i, 3})) = (\frac{4}{5}, \frac{8}{5}, 0)$.
\end{enumerate}
Next, we specify the equilibrium allocation.
\begin{enumerate}
\item Agents of $A_{j, *}$ take $\frac{2K^2}{2K+1}$ of $G_j$ and $\frac{2K^2 + 2K}{2K+1}$ of dummy goods, $j \in [m]$.
\item Agent $A_j$ takes $\frac{K}{2K+1}$ of $G_j$ and $\frac{K+1}{2K+1}$ of $G_{\phi(j), \ell(j)}$, $j \in [m]$.
\item If $x_i = 1$, then agents in $A_{i, 1}$ obtain $\frac{5K}{4}$ of $G_{i, 2}$, $\frac{3K}{4}$ of $G_{i, 1}$; agents in $A_{i,2}$ obtain $\frac{3K}{4}$ of $G_{i,2}$, $K$ of $G_{i,3}$, $\frac{K}{4} - s_j\cdot \frac{K+1}{2K+1}$ of $G_{i, 1}$ and $s_j\cdot \frac{K+1}{2K+1}$ of the dummy good, $i \in [n]$. If $x_i=0$, then we define the allocation symmetrically, switching the groups of agents $A_{i, 1}$ and $A_{i,2}$, and the groups of goods $G_{i, 1}$ and $G_{i, 3}$.
\end{enumerate}
One can verify that this is indeed a HZ equilibrium. Agent $A_j$ has utility $\frac{K}{2K+1} + \frac{K+1}{2K+1}\cdot \frac{5}{6} = \frac{11K + 5}{12K+6}$, and hence, the social welfare is at least $m \cdot \frac{11K + 5}{12K+6} \geq \frac{11}{12}m - O(1/m^2)$.
\paragraph{Soundness} Consider any normalized HZ equilibrium $(x,p)$. We first characterize the equilibrium behaviour of variable gadgets. In an (exact) HZ equilibrium, we say a variable gadget is {\em vacant} if no agents outside of the gadget purchase goods inside the gadget, and we call other gadgets {\em non-vacant}. Loosely speaking, only non-vacant gadgets are of interest, as vacant gadgets do not interact with the rest of market and their utility is negligible.
\begin{lemma}
\label{lem:np-variable}
For any $i \in [n]$, suppose the $i$-th variable gadget is non-vacant. Then the equilibrium price is one of the following three cases.
\begin{align}
&p(G_{i,1}) = \frac{4}{5} \pm O\left(\frac{1}{m^2}\right), \quad p(G_{i,2}) = \frac{8}{5} \pm O\left(\frac{1}{m^2}\right), \quad p(G_{i,3}) = 0 \pm O\left(\frac{1}{m^2}\right)\label{eq:price-case1}\\
\text{or} \quad & p(G_{i,1}) = 0 \pm O\left(\frac{1}{m^2}\right),\quad p(G_{i,2}) = \frac{8}{5} \pm O\left(\frac{1}{m^2}\right), \quad p(G_{i,3}) = \frac{4}{5} \pm O\left(\frac{1}{m^2}\right) \label{eq:price-case2}\\
\text{or} \quad & p(G_{i,1}) = \frac{2}{3} \pm O\left(\frac{1}{m^2}\right), \quad p(G_{i,2}) = \frac{4}{3} \pm O\left(\frac{1}{m^2}\right), \quad p(G_{i,3}) = \frac{2}{3} \pm O\left(\frac{1}{m^2}\right) \label{eq:price-case3}
\end{align}
\end{lemma}
\begin{proof}
We have $p(G_{i, 2}) > 1$, otherwise $G_{i, 2}$ is oversold. Since there are outside agents that purchase goods inside the gadget, we conclude that one of the agents in $A_{i,1}$, $A_{i,2}$ must purchase goods outside the gadget, i.e. those zero-price zero-utility goods.
Assume that some agents in $A_{i,1}$ purchase such goods (the other case is symmetric.)
It is easy to see then that $p(G_{i, 1}) > 0$, and therefore, the optimal bundles of agents in $A_{i, 1}$ contain $G_{i,1}, G_{i,2}$ and zero-price zero-utility goods.
Hence, $p(G_{i,2}) = 2p(G_{i,1})$. We further divide into two cases based on the optimal bundle of $A_{i,2}$.
First, suppose agents in $A_{i,2}$ purchase $G_{i, 2}$, $G_{i,3}$ and zero-price zero-utility goods. Then we have $p(G_{i,2}) = 2p(G_{i,3})$. Note that there are at most $m$ agents outside the gadget that have nonzero utility for $G_{i, 1}$ or $G_{i, 3}$, and no such agents for $G_{i, 2}$. Hence, the agents in $A_{i,1}, A_{i,2}$ buy all the goods in the gadget except for at most $m$ units of $G_{i, 1}$ and $G_{i, 3}$. Therefore,
\begin{align*}
(K \pm O(m))p(G_{i,1}) + 2K p(G_{i,2}) + (K \pm O(m)) p(G_{i,3}) = 4K. \label{eq:constraint1}
\end{align*}
Solving the system of this and the previous two equations yields Eq.~\eqref{eq:price-case3}.
Second, suppose agents in $A_{i,2}$ only buy $G_{i, 2}$, $G_{i,3}$. Suppose $p(G_{i, 3}) > 0$. Then we know agents $A_{i,2}$ buy $K\pm O(m)$ of $G_{i,3}$, and therefore, $K\pm O(m)$ of $G_{i,2}$. Hence, we have
\begin{align}
&(K \pm O(m) ) p(G_{i,2}) + (K \pm O(m) )p(G_{i,3}) = 2K \notag\\
\text{and} \quad &(K \pm O(m) )p(G_{i,1}) + 2K p(G_{i,2}) + (K \pm O(m) )p(G_{i,3}) = 4K.
\end{align}
These equations, together with $p(G_{i,2}) = 2p(G_{i,1})$ yield the same solution, i.e., Eq.~\eqref{eq:price-case3}.
Finally, assume $p(G_{i, 3}) = 0$. Then we only have the constraint Eq.~\eqref{eq:constraint1}. These equations, together with
$p(G_{i,2}) = 2p(G_{i,1})$ yield Eq.~\eqref{eq:price-case1}.
The symmetric case, where some agents of $A_{i,2}$ buy some goods outside the gadget, yields Eq.~\eqref{eq:price-case2}.
\end{proof}
The following lemma follows a similar argument of Lemma~\ref{lem:goode}, we omit the proof
\begin{lemma}
\label{lem:np-price2}
The price of goods $G_{j}$ satisfies $p(G_{j}) = 2 + O({1}/{m^2})$, $j \in [m]$.
\end{lemma}
We are now ready to wrap up the proof of soundness.
Given an equilibrium $(x, p)$ that (approximately) maximizes the social welfare, we look at each non-vacant variable gadget.
Based on the three cases stated in Lemma~\ref{lem:np-variable}, we extract the $i$-th variable to be $1$ if Eq.~\eqref{eq:price-case2} holds and $0$ if Eq.~\eqref{eq:price-case1} holds. We do nothing for the case of Eq.~\eqref{eq:price-case3} and those vacant variables (gadgets).
The total utility of all agents in $A_{i, \ell}$ , $i \in [n], \ell \in [2]$, and all agents in $A_{j, *}$, $j \in [m]$ is at most $O({1}/{m^2})$. We focus on the utility of agents $A_j$, $j \in [m]$.
If the $j$-th clause is satisfied, then one of the $5/6$ utility goods has zero price, and one can see that the utility is (at most)
\[
\left(\frac{1}{2} \pm O\left(\frac{1}{m^2}\right)\right)\cdot 1 + \left(\frac{1}{2} \pm O\left(\frac{1}{m^2}\right)\right)\cdot \frac{5}{6} = \frac{11}{12} \pm O\left(\frac{1}{m^2}\right).
\]
On the other hand, if the $j$-th clause is not satisfied, we still don't need to consider the vacant gadgets (as there is no interactions), and the $5/6$ utility goods have price at least $({2}/{3})\pm O( {1}/{m^2})$.
Hence the utility is at most
\[
\left(\frac{1}{4} \pm O\left(\frac{1}{m^2}\right)\right)\cdot 1 + \left(\frac{3}{4} \pm O\left(\frac{1}{m^2}\right)\right)\cdot \frac{5}{6} = \frac{7}{8} \pm O\left(\frac{1}{m^2}\right).
\]
Thus, if the truth assignment satisfies at most $(\frac{7}{8}+\epsilon) m$ clauses then the social welfare is at most
\[
\left(\frac{7}{8}+\epsilon\right)m \cdot \left(\frac{11}{12} + O\left(\frac{1}{m^2}\right)\right) + \left(\frac{1}{8}-\epsilon\right)m\cdot \left(\frac{7}{8} + O\left(\frac{1}{m^2}\right)\right) + O\left(\frac{1}{m}\right) = \frac{175}{192}m +\frac{1}{24}\epsilon m + O\left(\frac{1}{m}\right).
\]
From \cite{haastad2001some}, it is NP-hard to distinguish the case that all clauses can be satisfied (in which case there is an equilibrium with social welfare $\frac{11}{12}m -O(1/m^2)$) from the
case that at most $(\frac{7}{8}+\epsilon) m$ clauses can be satisfied
(in which case the maximum social welfare is at most $\frac{175}{192}m +\frac{1}{24}\epsilon m + O(1/m)$). The theorem follows.
The construction can be easily modified, if desired, so that all
utilities are in $[0,1]$, and every agent has minimum utility 0 and maximum utility 1.
\section{PPAD-hardness}
\label{sec:ppad}
Our goal in this section is to prove the following theorem:
\begin{theorem}\label{theo:ppadhard}
The problem of finding a $(1/n^5)$-approximate HZ equilibrium in an HZ market
with $n$ agents and goods is PPAD-hard.
\end{theorem}
In Appendix \ref{sec:padding} (via a standard padding argument),
we give a polynomial-time reduction from
the problem of finding a $(1/n^5)$-approximate HZ equilibrium to
that of finding a $(1/n^c)$-approximate HZ equilibrium in an HZ market, for any positive constant $c$.
Theorem \ref{thm:hz-equilibrium} follows by combining the PPAD membership result of \cite{vy21}.
Our plan is as follows. Let $\epsilon=1/n^5$ throughout this section wherever an HZ market with
$n$~agents and goods is concerned.
We start with some basic facts about approximate HZ equilibria in~Section \ref{sec:basic}
(mainly about how to work with approximately optimal
bundles for agents).
Then we describe the polynomial-time reduction from threshold games to HZ markets
in Section \ref{sec:construction}. Our reduction constructs two types of gadgets,
\emph{variable gadgets} and \emph{edge gadgets},
which simulate variables $x_v$ and edges $(u,v)$ in a threshold game, respectively.
Using these gadgets, we finish the reduction's correctness proof in Section \ref{sec:correctness};
the analysis of these two gadgets is presented afterwards in Section \ref{sec:gadgets} and \ref{sec:edgegadgets}, respectively.
\subsection{Basic Facts}
\label{sec:basic}
Let $M$ be an HZ market with $n$ agents and goods.
As it will become clear later, the HZ market we construct in the reduction satisfies
$\max_{j\in [n]} u_{i,j}=1$ for every agent $i\in [n]$.
\emph{Hence we assume this is the case in every HZ market discussed in the rest of this section.}
In all lemmas of this subsection we assume $(x,p)$ to be an $\epsilon$-approximate HZ equilibrium
of $M$ (and skip it in their statements).
Recall that prices are normalized: $\min_i p_i =0$.
\begin{comment}
First let's recall a fact from \cite{vy21}:
After scaling the difference of $p$ from $1$,
the new price vector~$p'$ together with the allocation $x$ remain an $\epsilon$-approximate HZ equilibrium.
\begin{lemma
\label{fact:scale-invariant}
Let $p'$ be a nonnegative price vector such that
every $p_j'$ satisfies $p_j'-1=r(p_j-1)$ for some $r>0$.
Then $(x,p')$ is also an $\epsilon$-approximate HZ equilibrium of $M$.
\end{lemma}
\begin{proof}
\xnote{Add a proof.} \Thomas{proof from Mihalis' paper} For an agent $i$, $\sum_{j \in [n]} p_j x_{i, j} \leq 1$ and $\sum_{j \in [n]} x_{i, j} = 1$. Thus, $\sum_{j \in [n]} p_j' x_{ij} = \sum_{j \in [n]} (rp_j - r + 1) x_{ij} \leq r - (r - 1)$
\end{proof}
Using Lemma \ref{fact:scale-invariant}, one can assume without loss of generality
that
$\min_{j\in [n]} p_j=0$.
\emph{Indeed, we will assume this to be the case in the rest of the section whenever $p$ is the price vector
of an approximate HZ equilibrium.}
\end{comment}
We give first an upper bound on the sum of prices:
\begin{lemma}
\label{fact:maximum-price}
$\sum_{j\in [n]} p_j\le 2n$.
\end{lemma}
\begin{proof}
Since $(x,p)$ is an $\epsilon$-approximate HZ equilibrium, every good must be sold out
and no agent can spend more than $1+\epsilon$. Thus, $\sum_{j\in [n]} p_j\le n(1+\epsilon)< 2n$
using $\epsilon=1/n^5$.
\end{proof}
Next, we consider an optimal solution $(\alpha_i^*,\mu_i^*)$ to the dual LP for agent $i$
and prove the following:
\begin{lemma}\label{simplelemma1}
$\mu_i^*\ge 0$ and $\alpha_i^*\le 1$ for every $i\in [n]$.
\end{lemma}
\begin{proof}
Let $\ell$ be a good with $p_\ell=0$. From the dual LP constraints, we have
$ 0 \leq u_{i,\ell} \leq \alpha_i^* p_\ell + \mu^*_i = \mu_i^*.$
Moreover, since all utilities are in $[0,1]$ we have trivially that
$\alpha_i^*+\mu_i^*=\textsf{value}_p(i)\le 1$.
Therefore, we have $\alpha_i^* \leq 1$.
\end{proof}
\begin{lemma}\label{heheclaim1}
If $\emph{\textsf{value}}_p(i)\le 0.9$ then $\alpha_i^*\ge 1/(20n)$
and $\sum_{j\in [n]}p_j x_{i,j}\ge 1-20n\epsilon$.
\end{lemma}
\begin{proof}
Let $u_{i,\ell}=1$. It follows from Lemma \ref{fact:maximum-price} that $p_\ell\le 2n$ and thus,
$$1=u_{i,\ell}\le \alpha_i^* p_\ell+\mu_i^*\le 2n\alpha_i^*+\mu_i^*.$$
On the other hand, $\textsf{value}_p(i)=\alpha^*_i+\mu^*_i\le 0.9$. The first part of the lemma follows from adding these two inequalities.
Next, multiplying both sides of the inequalities
$\alpha_i^* p_j + \mu_i^* \ge u_{i,j}$ by $x_{i,j}$,
summing over all $j \in [n]$, and using $\sum_j x_{i,j}=1$, we have
$$
\sum_{j\in [n]} \alpha_i^* p_jx_{i,j}+\mu_i^*\ge \sum_{j\in [n]} u_{i,j}x_{i,j}
\ge \alpha_i^*+\mu_i^*-\epsilon.
$$
The second part of the lemma then follows from $\alpha_i^*\ge 1/(20n)$.
\end{proof}
Recall that all goods $j$ satisfy $u_{i,j} \leq \alpha_i^* p_j + \mu_i^*$.
We say a good $j$ is $\delta$-\emph{suboptimal} for agent $i$ if
$u_{i,j} + \delta \leq \alpha_i^* p_j + \mu_i^*$.
We show that agent $i$'s good-bundle, $x_i$, cannot contain significant quantities of suboptimal goods.
\begin{lemma}
\label{fact:subopt-goods}
For every $i\in [n]$, the
total allocation in $x_i$ to $\delta$-suboptimal goods is at most $2 \epsilon / \delta$.
\end{lemma}
\begin{proof}
Fix an agent $i\in [n]$.
We have $u_{i,j} \leq \alpha_i^* p_j + \mu_i^*$ for all $j\in [n]$, and
$u_{i,j}+\delta \le \alpha_i^* p_j+ \mu_i^*$ for $\delta$-suboptimal goods.
Let $W$ be the total allocation in $x_i$ to $\delta$-suboptimal goods.
Then $$\sum_{j\in [n]} u_{i,j} x_{i,j} + W \delta \leq \alpha_i^* \sum_{j\in [n]} p_j x_{i,j} + \mu_i^* \sum_{j\in [n]} x_{i,j}.$$
Using the definition of $\epsilon$-approximate HZ equilibria,
the LHS is at least
$$\textsf{value}_p(i)-\epsilon+W\delta=\alpha_i^*+\mu_i^*+W\delta-\epsilon$$
and the RHS is at most $\alpha_i^*(1+\epsilon)+\mu_i^*$.
The lemma follows from $\alpha_i^*\le 1$ by Lemma \ref{simplelemma1}.
\end{proof}
We use some of the lemmas above to obtain following corollaries:
\begin{corollary}\label{maincoro}
Let $J$ be the set of $j\in [n]$ that are \emph{not} $\delta$-suboptimal for $i$.
If $\emph{\textsf{value}}_p(i)\le 0.9$, then
\begin{align*}
1-2\epsilon/\delta\le \sum_{j\in J} x_{i,j}\le 1\quad\text{and}\quad
1-20n\epsilon -\frac{4n\epsilon}{\delta}\le
\sum_{j\in J} p_jx_{i,j}\le 1+\epsilon.
\end{align*}
\end{corollary}
\begin{proof}
The first part follows directly from Lemma \ref{fact:subopt-goods}.
The second part follows from Lemma \ref{fact:maximum-price}, Lemma \ref{heheclaim1},
and Lemma \ref{fact:subopt-goods}.
\end{proof}
\begin{corollary}\label{secondcoro}
Let $J$ be the set of goods $j\in [n]$ with $u_{i,j}>0$.
If $\emph{\textsf{value}}_p(i)\le 0.9$, then
$$
1-20n\epsilon-\frac{1}{n^2}\le \sum_{j\in J} p_jx_{i,j}\le 1+\epsilon.
$$
\end{corollary}
\begin{proof}
The second inequality clearly holds since $(x,p)$ is an $\epsilon$-approximate equilibrium. Suppose that the first inequality does not hold.
Then by Lemma \ref{heheclaim1}, agent $i$ spends more than
$1/n^2$ on zero-utility goods, hence she buys at least an amount $1/2n^3$ of these, since all prices are at most $2n$.
Consider a new bundle for $i$ obtained by replacing $1/2n^3$ of
the zero-utility goods by a good with utility 1.
The cost of the new bundle is still less than 1,
i.e. it is a feasible bundle, and
the value exceeds that of the original bundle $x_i$ by
$1/2n^3 > \epsilon$, contradicting the fact that
$(x,p)$ is an $\epsilon$-approximate equilibrium.
\end{proof}
Finally we include a simple lemma about the optimal value of an agent:
\begin{lemma}\label{simplesimplelemma}
Let $i\in [n]$ and $\ell\in [n]$ with $u_{i,\ell}=1$. Then
$\emph{\textsf{value}}_p(i)\ge \min(1,1/p_\ell)$.
\end{lemma}
\begin{proof}
If $p_\ell=0$, then agent $i$ can get value $1$ by buying one unit of good $\ell$ for free.
If $p_\ell>0$ then there is another good with zero price and thus, agent $i$ can
get value $\min(1,1/p_\ell)$ by buying $\min(1,1/p_\ell)$ unit of good $\ell$ and
$1-\min(1,1/p_\ell)$ unit of a zero price good.
\end{proof}
\def\text{in-deg}{\text{in-deg}}
\def\text{out-deg}{\text{out-deg}}
\subsection{The Construction}\label{sec:construction}
Let $\kappa\in (0,1)$ be the positive constant in Theorem \ref{thm:ppad-threshold}.
Recall that our goal is to give a polynomial-time reduction from the problem of finding a $\kappa$-approximate equilibrium
in a threshold game (with both in-degree and out-degree at most $3$) to that of finding an $\epsilon$-approximate HZ
equilibrium in an HZ market with $\epsilon=1/n^5$.
Let $C$ be a sufficiently large universal constant, and $m=\lceil C/\kappa \rceil$.
Let $H=(V, E)$ be a threshold game with $|V|=N$.
(Note that $N$ is asymptotically large and should be considered as larger than any function of $m$.)
We write $\text{in-deg}(v)$ and $\text{out-deg}(v)\le 3$ to denote the in-degree and out-degree of $v\in V$, respectively.
We construct an HZ market $M_H$ from $H$ in three steps as described below.
This is done by creating \emph{groups} of goods and \emph{groups} of agents, with
the guarantee that agents in the same group have the same utility for any good as each other, and that goods in the same group yield the same utility to any agent.
We say a group~$A_i$~of~agents have utility $u$ for a group $G_j$ of goods if all agents
in $A_i$ share the same utility $u$ for all goods in $G_j$.
(Intuitively we create a group $A_i$ of agents to simulate an agent with demand and budget $|A_i|$ instead of $1$, and
a group $G_j$ of goods to simulate a good with a supply of $|G_j|$ units in the market.
A technical subtlety though is that in an approximate HZ equilibrium, goods in the same group
may not share exactly the same price and agents in the same group may not have exactly the same allocation.)
\subsection*{Step 1: Creating Variable Gadgets}
We start with an empty market and create a \emph{variable gadget}
for each node $v\in V$ to simulate the variable $x_v$ in the threshold game $H$.
For each node $v \in V$, the variable gadget of $v$ consists of the following three groups of goods and one group of agents:
\begin{flushleft}\begin{enumerate}
\item Create three groups of goods $G_{v,1},G_{v,2}$ and $G_{v,3}$:
$G_{v,1}$ has $m^{10}+S_u$ goods, where
$$
S_{u}:= (24m^3 + 12m)\cdot \text{out-deg}(u) + (24m^3 + 15m)\cdot \text{in-deg}(u) -3m,$$
and $G_{v,2}$ and $G_{v,3}$ both have $2m^{10}$ goods.
Let $G_v$ denote the union of $G_{v,1}, G_{v,2}$ and $G_{v,3}$.
\item Create a group $A_v$ of $5m^{10}$ agents.
Each agent in $A_v$ has the following utilities for $G_{v}$:
\begin{equation}\label{utilityutility}
\frac{1}{2m^2-1}
\ \text{for}\ G_{v, 1 },\quad \frac{m^2+1}{4m^2 -2}\ \text{for}\ G_{v, 2 }, \quad
1\ \text{for}\ G_{v,3},
\end{equation}
and utility $0$ for every other good in the market (including those created later).
\end{enumerate}\end{flushleft}
Looking ahead, we will prove (in Lemma \ref{lem:variable-price}) that in any $\epsilon$-approximate HZ equilibrium $(x,p)$ of the final
HZ market $M_H$, $p(G_{v,1}),p(G_{v,2})$ and $p(G_{v,3})$ must satisfy \vspace{0.15cm}
$$
0\le p(G_{v,1})\lesssim \frac{1}{m^2},\quad p(G_{v,2})\approx \frac{1+p(G_{v,1})}{2}
\quad\text{and}\quad p(G_{v,3})\approx 2-p(G_{v,1}), \vspace{0.15cm}
$$
where $p(G_{v,\ell})$ denotes the minimum price of goods in $G_{v,\ell}$.
Indeed, $p(G_{v,1})$ will be used to simulate the variable $x_v$ in the threshold game $H$ and at the end,
we set $x_v\approx m^2 p(G_{v,1})$ for each $v\in V$ to obtain a
$\kappa$-approximate equilibrium of $H$.
\subsection*{Step 2: Creating Edge Gadgets}
Next we create an \emph{edge gadget} for each edge $e=(u,v)\in E$ to simulate the action of vertex $u$
sending a contribution $x_u$ to the summation at vertex $v$ in the threshold game $H$ (see definition \ref{def:threshold}).
For each (directed) edge $e=(u,v)\in E$, the edge gadget of $e$ consists of the following multiple
groups of goods and agents (for convenience, we only
list goods with positive utilities for each group of agents; every other good has utility $0$):
\begin{flushleft}\begin{enumerate}
\item Create a group $G_{e}$ of $32m^5$ goods.
\item Create a group $A_{e,* }$ of $64m^5$ agents. They
have utility $1$ for $G_e$. %
\item Create a group of $48m^3$ agents $A_{e,1}$.
They have utility $1$ for $G_{u, 3}$ and $1/2$ for $G_{v, 1}$.
\item Create $m$ groups $A_{e,2,\ell}$, $\ell\in [m]$, each of $6$ agents.
They have $1$ for $G_{e}$ and $\ell/(2m^3)$ for $G_{v,1}$.
\item Create $m$ groups $A_{e,3,\ell}$, $\ell\in [m]$, each of $8$ agents.
They have $1$ for $G_{e}$ and $\ell/(2m^3)$ for $G_{u,1}$.
\item Create $m$ groups $A_{e,4,\ell}$, $\ell\in [2m]$, each of $18$ agents. They have $1$ for $G_{e}$, $\ell/(2m^3)$ for $G_{v,1}$, $$\frac{1}{4}+ \frac{1}{4m^2} + \frac{1}{m^3}$$ for goods in $G_{u,2}$.
\end{enumerate}\end{flushleft}
For convenience we write $A_e$ to denote the union of groups $A_{e,1}, A_{e,2,\ell}, A_{e,3,\ell}$ and
$A_{e,4,\ell}$, for all $\ell$.
\subsection*{Step 3: Adding Dummy Goods}
So far we have created
\begin{equation}\label{eq:n}
5m^{10}\cdot |V|+(64m^5+48m^3+50m)\cdot |E|
\end{equation}
many agents and
$$
\sum_{u\in V} (5 m^{10}+S_u)+32m^5\cdot |E|= (5m^{10}-3m)\cdot |V|+(32m^5+48m^3+27m)\cdot |E|
$$
many goods.
To finish the construction (since the number of goods needs to match that
of agents), we create a group of $3m|V|+(32m^5+23m)|E|$ dummy goods,
which have utility $0$ to every agent in the market.
This finishes the construction of $M_H$ with $n$ agents and goods, where $n$ is given in (\ref{eq:n}).
It is clear that $M_H$ can be built in polynomial time.
Before moving forward,
we record a list of simple properties about $M_H$:
\begin{fact}\label{basicfact}
The HZ market $M_H$ satisfies the following properties:
\begin{flushleft}\begin{enumerate}
\item Every agent in the market has maximum utility $1$;
\item For each node $v\in V$,
the number of agents outside of $A_v$ that have a positive utility on
at least one group of goods in $G_v$ is at most
$288m^3+258m=O(m^3)$;
\item For each edge $e\in E$,
the number of agents outside of $A_{e,^*}$ that have a positive utility on $G_e$
is $50m=O(m)$.
\end{enumerate}\end{flushleft}
\end{fact}
\subsection{Proof of Correctness}\label{sec:correctness}
Let $\epsilon=1/n^5$.
We prove three lemmas about variable gadgets in $M_H$ in Section \ref{sec:gadgets}.
We use $p(G_i)$ to denote the minimum price of goods in a group $G_i$.
The first lemma shows that $p(G_{v,1})$ is between (roughly)
$0$ and $1/m^2$ and it determines $p(G_{v,2})$ and $p(G_{v,3})$ (approximately).
\begin{lemma}
\label{lem:variable-price}
Let $(x,p)$ be an $\epsilon$-approximate HZ equilibrium of $M_H$. Then $p(G_{v,1})$ satisfies
$$
0\le p(G_{v,1})\le \frac{1}{m^2}+O\left(\frac{1}{m^6}\right)
$$
for every $v\in V$.
Moreover, $p(G_{v,2})$ and $p(G_{v,3})$ satisfy\vspace{0.06cm}
\begin{equation}\label{heheeqeq}
p(G_{v,2}) = \frac{1+p(G_{v,1})}{2}\pm O\left(\frac{1}{m^7}\right)\quad\text{and}\quad
p(G_{v,3}) = 2 - p(G_{v,1}) \pm O\left(\frac{1}{m^7}\right).
\end{equation
\end{lemma}
We prove Lemma \ref{lem:variable-price} in Section \ref{sec:gadgets}.
We next show that the variable gadget created for each node $v\in V$ is
sensitive to demand from agents outside of $A_v$.
To state the lemma (and the next one), we introduce the following notation:
Let $G^*$ be a subset of goods (which could be a group or the union of multiple groups
of goods) and $A^*$ be a subset of agents in $M_H$
(which could be a group or the union of multiple groups).
We let
$$
x^+(G^*,A^*)=\sum_{\substack{i\in A^*\\ j\in G^*:\\
u_{i,j}>0}} x_{i,j},
$$
i.e., the total allocation of $G^*$ to $A^*$ but limited to those goods
in $G^*$ with positive utilities to each agent in $A^*$ only.
We also write $\overline{A}_v$ to denote all agents in $M_H$ outside of $A_v$.
The second lemma (which we also prove in Section \ref{sec:gadgets}) states that if the total allocation of
$G_v$ to agents outside of $A_v$ with positive utilities is
either more than $S_v+1$ or less than $S_v-1$,
then $p(G_{v,1})$ must be at one of the two extreme cases accordingly, i.e., either close to $0$
or close to $1/m^2$.
\begin{lemma}
\label{lem:demand}
Let $(x,p)$ be an $\epsilon$-approximate HZ equilibrium of $M_H$. Then for every $v\in V$:
\begin{flushleft}\begin{enumerate}
\item If $x^+(G_v,\overline{A}_v)\ge S_v+1$, then we have
$$
p(G_{v,1})=\frac{1}{m^2}\pm O\left(\frac{1}{m^9}\right);
$$
\item If $x^+(G_v,\overline{A}_v)\le S_v-1$, then we have
$p(G_{v,1})\le O(1/n^2)$.
\end{enumerate}\end{flushleft}
\end{lemma}
Finally we prove the following lemma about edge gadgets in $M_H$ in Section \ref{sec:edgegadgets}:
\begin{lemma}\label{lem:edgedemand}
Let $(x,p)$ be an $\epsilon$-approximate HZ equilibrium of $M_H$. For each $e=(u,v)\in E$,
$$x^+(G_u,A_e)= 24m^3+ 12m \pm O(1)\quad\text{and}\quad
x^+(G_v,A_e)=-6m^3p(G_{u,1}) + 24m^3 +15m\pm O(1).$$
\end{lemma}
We now use these lemmas to prove Theorem \ref{theo:ppadhard}:
\begin{proof}[Proof of Theorem \ref{theo:ppadhard} assuming Lemmas \ref{lem:variable-price},
\ref{lem:demand} and \ref{lem:edgedemand}]
Let $H=(V,E)$ be a\ threshold game, and
let $(x,p)$ be an $\epsilon$-approximate HZ equilibrium of $M_H$.
Let $(x_v:v\in V)$ be a profile for $H$ with
$$x_v=\min\big(1,m^2p(G_{v,1})\big)$$
for each $v\in V$.
We prove below that $(x_v:v\in V)$ is a $\kappa$-approximate equilibrium
of $H$.
Fix a node $v\in V$. We consider two cases.
\begin{flushleft}\begin{enumerate}
\item Case $1$: $\sum_{u\in N_v} x_u>0.5+\kappa$.
In this case, $x^+(G_v,\overline{A}_v)$ is at most
\begin{align*}
&\text{out-deg}(v)\cdot \big(24m^3+12m+O(1)\big)+\sum_{u\in N_v} \big(24m^3 +15m -6m^3p(G_{u,1}) + O(1)\big)\\
&\hspace{1cm}=S_v+3m-6m^3\sum_{v\in N_v} p(G_{u,1})+O(1)<S_v-1.
\end{align*}
It follows from Lemma \ref{lem:demand} that $p(G_{v,1})\le O(1/n^2)$ and thus, $x_v\le O(m^2/n^2)< \kappa$.
\item Case $2$: $\sum_{u\in N_v} x_u<0.5-\kappa$. Using $p(G_{u,1})\le 1/m^2+O(1/m^9)$, we have
$$\sum_{u\in N_v} m^2p(G_{u,1})<0.5-\kappa +O(1/m^7).$$
Similarly, $x^+(G_v,\overline{A}_v)$ is at least \begin{align*}
&\text{out-deg}(v)\cdot \big(24m^3+12m- O(1)\big)+\sum_{u\in N_v} \big( 24m^3 +15m- 6m^3p(G_{u,1})- O(1)\big)\\
&\hspace{1cm}=S_v+3m-6m^3\sum_{u\in N_v}p(G_{u,1})-O(1)>S_v+1.
\end{align*}
It follows from Lemma \ref{lem:demand} that $p(G_{v,1})\ge (1/m^2)-O(1/m^9)$ and thus, $x_v \ge 1-\kappa$.
\end{enumerate}\end{flushleft}
This finishes the proof of the theorem.
\end{proof}
\subsection{Analysis of Variable Gadgets}
\label{sec:gadgets}
We prove Lemma \ref{lem:variable-price} and
Lemma \ref{lem:demand} in this section. We start with some simple bounds on prices of
goods in $G_{e }$ and $ G_{v,3} $, $e\in E$ and $v\in V$:
\begin{lemma}\label{haheha22}
Let $(x,p)$ be an $\epsilon$-approximate HZ equilibrium of $M_H$.
We have
$p(G_e)\ge 2(1-2\epsilon)$ for every $e\in E$ and $p(G_{v,3})\ge 5/3$ for every $v\in V$.
\end{lemma}
\begin{proof}
Fix an $e\in E$.
The optimal value of each agent in $A_{e,*}$ is at most $0.5+\epsilon$;
otherwise each of them must receive a bundle with value more than $0.5$, which implies
that each of them gets more than $0.5$ unit of goods in $G_{e}$, contradicting with the fact that
there are $64m^5$ many agents in $A_{e,*}$ but only $32m^5$ many goods in $G_e$.
On the other hand, the optimal value of each agent in $A_{e,*}$ is at least
$\min(1,1/p(G_e))$ by Lemma \ref{simplesimplelemma} and thus,
$p(G_e)\ge 1/(0.5+\epsilon)>2(1-2\epsilon)$.
Next fix a $v\in V$.
With a similar argument, the optimal value of each agent in $A_v$ is at most
$$
\frac{1}{5m^{10}}\cdot \left(\frac{ m^{10}+S_v}{2m^2-1}+2m^{10}\cdot\frac{m^2+1}{4m^2-2}+2m^{10}\right)+\epsilon
< 3/5
$$
when $m$ is sufficiently large.
On the other hand, by Lemma \ref{simplesimplelemma} the optimal value of each agent in $A_v$ is at least
$\min(1,1/p(G_{v,3}))$ and thus, $p(G_{v,3})\ge 5/3$.
\end{proof}
From this we can show that every agent in $M_H$ has optimal value at most $0.9$:
\begin{lemma}
Let $(x,p)$ be an $\epsilon$-approximate HZ equilibrium of $M_H$.
Then every agent in $M_H$ has optimal value (with respect to $p$) at most $0.9$.
\end{lemma}
\begin{proof}
As shown in the previous lemma, the optimal value of each agent in a group $A_v$ of a variable gadget is at most 3/5, and the optimal value of each agent in a group $A_{e,*}$ of an edge gadget is at most $0.5+\epsilon$.
The claim for the agents in the groups $A_{e}$ follows from the
prices of the goods in $G_{u,3}$ and $G_e$, which are the goods that have utility 1 for these agents (the other goods have utility 1/2 or less).
\end{proof}
This allows us to apply lemmas in Section \ref{sec:basic}.
It immediately leads to the following corollary:
\begin{corollary}\label{closecoro}
For every group $G_j$ of goods, the maximum price in $G_j$ is at most
$p(G_j)+1/n^2$.
\end{corollary}
\begin{proof}
Assume for a contradiction that there is a good in $G_j$ with price at least $p(G_i)+1/n^2$.~Then for each agent $i$ in the market, we have $\alpha^*_i\ge 1/(20n)$ by Lemma \ref{heheclaim1}
and thus this good is $\Omega(1/n^3)$-suboptimal (by comparing with the
good in $G_j$ with price $p(G_j)$). Hence its allocation to agent $i$
is $O(1/n^2)$, and the total allocation of this good in $x$ is $O(1/n)$, a contradiction.
\end{proof}
Before proving Lemma \ref{lem:variable-price} we show that $p(G_e)$ is very close to $2$:
\begin{lemma}\label{lem:goode}
For every edge $e\in E$ we have $p(G_e)=2\pm O(1/m^4)$.
\end{lemma}
\begin{proof}
We have by Lemma \ref{haheha22} that $p(G_e)\ge 2-O(\epsilon)$.
For the upper bound note that by Lemma \ref{haheha22} and Lemma \ref{heheclaim1}, goods in
$G_e$ are $\Omega(1/n)$-suboptimal to agents with zero utility so their total
allocation to such agents is $O(n^2\epsilon)$ by Lemma \ref{fact:subopt-goods}.
By Fact \ref{basicfact} the total allocation of $G_e$ to agents outside $A_{e,*}$ with a positive utility is $O(m)$ and thus,
the rest of $32m^5-O(m)$ units of $G_e$ are allocated to agents in $A_{e,*}$.
So
$$
\left(32m^5-O(m)\right)p(G_e)\le 64m^5(1+\epsilon),
$$
which implies that $p(G_e)\le 2+O(1/m^4)$. This finishes the proof of the lemma.
\end{proof}
We are now ready to prove Lemma \ref{lem:variable-price}:
\begin{figure}[!ht]
\centering
\includegraphics[width=0.8\textwidth]{variable.png}
\vspace{0.2cm}\caption{The variable gadget.}
\end{figure}
\begin{proof}[Proof of Lemma \ref{lem:variable-price}]
Fixing any node $v\in V$, we let $q_\ell$ denote $p(G_{v,\ell})$ and $y_\ell$ to denote the
total allocation of $G_{v,\ell}$ to agents in $A_v$ in $x$, for each $\ell\in \{1,2,3\}$.
We also write $u_\ell$ to denote the utility of $G_{v,\ell}$ to agents in $A_{v}$
given in (\ref{utilityutility}).
We start by showing that most goods in $G_v$ go to $A_v$.
\begin{claim}\label{claim:recall}
We have $y_1\ge m^{10}-O(m^3)$ and $y_2,y_3\ge 2m^{10}-O(m^3)$.
\end{claim}
\begin{proof}
Let $\alpha^*$ and $\mu^*$ be an optimal solution to the dual LP of agents in $A_v$.
Then $\alpha^* q_\ell+\mu^*\ge u_\ell$ for each $\ell$.
We consider the following two cases.
First we consider the case when $\mu^*\ge u_1/2=\Omega(1/m^2)$.
This implies that goods outside of $G_v$ are $\Omega(1/m^2)$-suboptimal for $A_v$ and thus, by Lemma \ref{fact:subopt-goods},
the total allocation of them to agents in $A_v$ is $O(m^{10})\cdot O(m^2 \epsilon)<1$ .
As a result,
$y_1+y_2+y_3\ge 5m^{10}-1$ from which the claim follows.
Next consider the case when $\mu^*<u_1/2$. By Lemma \ref{simplelemma1} ($\alpha^*\le 1$) we have
$q_\ell\ge \Omega(1/m^2)$ for every~$\ell$.
This implies that agents with zero utilities to $G_v$ can be allocated only
$n\cdot O(n m^2 \epsilon) < 1$ units of $G_v$ given that they are $\Omega(1/nm^2)$-suboptimal by Lemma \ref{heheclaim1}.
On the other hand, by Fact \ref{basicfact} the allocation to agents outside $A_v$ with positive utilities for
$G_v$ is at most $O(m^3)$.
So all the rest of $G_v$ must be allocated to $A_v$ and the claim follows.
\end{proof}
Now that we have $y_\ell\ge m^{10}-O(m^3)$ for all $\ell\in \{1,2,3\}$, we proceed to prove (\ref{heheeqeq}).
Let $(\alpha^*,\mu^*)$ denote an optimal solution to the dual LP for $A_v$.
By Lemma~\ref{fact:subopt-goods} and taking $\delta = 20\epsilon$,
we have
\begin{equation}\label{blablabla}
u_\ell\le \alpha^*q_\ell +\mu^*\le u_\ell+\delta,\quad\text{for all $\ell\in \{1,2,3\}$.}
\end{equation}
If this were not the case (i.e. the second inequality is violated for some $\ell$), then goods in $G_{v,\ell}$ are
$\delta$-suboptimal to $A_v$ and their total allocation to agents in $A_v$
can be no more than
$
5m^{10}\cdot 2\epsilon/\delta=m^{10}/2,
$
a contradiction.
Combining (\ref{blablabla}) and $u_2=(3u_1+u_3)/4$, we have
$$
\alpha^*\left(\frac{3q_1+q_3}{4}\right)+\mu^*-\delta\le \alpha^*q_2+\mu^*
\le \alpha^*\left(\frac{3q_1+q_3}{4}\right)+\mu^*+\delta.
$$
Using $\alpha^*\ge 1/(20n)$ from Lemma \ref{heheclaim1}, we have
\begin{align}\label{hehehehehehe1}
q_2 = \frac{3q_1 + q_3}{4} \pm O(n\epsilon) .
\end{align}
Next, using Corollary \ref{secondcoro} and Corollary \ref{closecoro} we have
$$
5m^{10}(1-O(1/n^2))\le q_1y_1+q_2y_2+q_3y_3\le 5m^{10}(1+\epsilon+1/n^2).
$$
Plugging in $y_1=m^{10}\pm O(m^3)$ and $y_2,y_3=2m^{10}\pm O(m^3)$ and (\ref{hehehehehehe1}), we have
$
q_1+q_3=2\pm O(1/m^7).
$
Together with (\ref{hehehehehehe1}) again we obtain
$$q_3=2-q_1\pm O(1/m^7)\quad\text{and}\quad q_2=(1+q_1)/2\pm O(1/m^7).$$
Finally we give an upper bound on $q_1$. We first note that $q_1<q_3$; otherwise
goods in $G_{v,1}$ are $\Omega(1)$-suboptimal to agents in $A_v$, contradicting with $y_1=m^{10}\pm O(m^3)$.
Using (\ref{blablabla}) we have
$$
\mu^*\le \frac{u_1q_3-u_3q_1+ O(\delta)}{q_3-q_1}.
$$
But when $q_1\ge 1/m^2+1/m^6$ (and thus, $q_3\le 2-1/m^2 $), the nominator of the RHS is
$$
u_1q_3-u_3q_1\le \frac{1}{2m^2-1}\cdot \left(2-\frac{1}{m^2}\right)-1\cdot \left(\frac{1}{m^2}+\frac{1}{m^6}\right)\le -\frac{1}{m^6}.
$$
So we have $\mu^*<0$, in contradiction with $\mu^*\ge 0$ by Lemma \ref{simplelemma1}.
\end{proof}
Next we prove Lemma \ref{lem:demand}:
\begin{proof}[Proof of Lemma \ref{lem:demand}]
We use the same notation from the proof of the last lemma.
First given that $q_2$ and $q_3$ are $\Omega(1)$, the total allocation of
$G_{v,2}$ to agents with zero utility on $G_{v,2}$ is at most $n\cdot O(n\epsilon)$ using Lemma \ref{fact:subopt-goods};
the same applies to $G_{v,3}$.
Suppose that $x^+(G_v,\overline{A}_v)\le S_v-1$.
Because $G_v$ contains $5m^{10}+S_v$ goods while $A_v$ contains only $5m^{10}$ agents,
for $G_v$ to be fully sold out,
the total allocation of $G_{v,1}$ to agents with zero utility
on $G_{v,1}$ must be $1-o_n(1)$. This implies that $q_1\le 1/n^2$ since otherwise,
the total allocation for $G_{v,1}$ is at most $n\cdot O(n^3\epsilon)=o_n(1)$, using $\epsilon=1/n^5$.
Next, suppose $x^+(G_v,\overline{A}_v)\ge S_v+1$.
Given that there are $5m^{10}+S_v$ goods in $G_v$ and $5m^{10}$ agents in $A_v$,
there must be an agent in $A_v$ who is allocated
at least $1/(5m^{10})$-unit of goods outside of $G_v$ (for which it has zero utility).
Since such goods are $\mu^*$-suboptimal,
we have $\mu^*\le 5m^{10}\epsilon$.
On the other hand, recall (\ref{blablabla}) with
$\delta=20\epsilon$.
We have $\alpha^* (q_1+q_3)+2\mu^*=u_1+u_3\pm 2\delta$ and thus,
$$\alpha^*=\frac{u_1+u_3}{2}\left(1\pm O\left(\frac{1}{m^7}\right)\right)$$
using Lemma \ref{lem:variable-price}.
Then $q_1=(u_1-\mu^*\pm \delta)/\alpha^* = 1/m^2 \pm O(1/m^{9})$.
\end{proof}
\subsection{Analysis of Edge Gadgets}\label{sec:edgegadgets}
In this subsection we prove Lemma \ref{lem:edgedemand}.
Let $(x,p)$ be an $\epsilon$-approximate HZ equilibrium of $M_H$~and $e=(u,v)\in E$ be an edge in $H$.
We work on agents in
$A_{e,1},A_{e,2,\ell},A_{e,3,\ell}$ and $A_{e,4,\ell}$ to understand their allocations of goods
with non-zero utilitites.
We start with agents in $A_{e,1}$:
\begin{figure}[!ht]
\centering
\includegraphics[width=0.8\textwidth]{type1.png}
\vspace{0.15cm}\caption{Edge gadget: Agents $A_{e,1}$}
\end{figure}
\begin{lemma}
\label{lem:gadget1}
The allocation of $G_{u,3}$ and $G_{v,1}$ to each agent in $A_{e,1}$ is given by
$$\frac{1}{2} + \frac{p(G_{u,1}) - p(G_{v,1})}{4}+ O\left(\frac{1}{m^4}\right)\quad\text{and}\quad
\frac{1}{2} + \frac{p(G_{v,1}) - p(G_{u,1})}{4} + O\left(\frac{1}{m^4}\right),$$
respectively.
\end{lemma}
\begin{proof}
The dual LP for each agent in $A_{e,1}$ is to minimize $\alpha+\mu$ subject to the following constraints: $\alpha\ge 0$;
$\alpha p_j + \mu \geq 1$ for $j \in G_{u,3}$;
$\alpha p_j + \mu \geq 1/2$ for $j \in G_{v,1}$;
and $\alpha p_j + \mu \geq 0$ for $j \notin G_{u,3} \cup G_{v,1}$.
The constraints for the minimum-priced goods in the groups
$G_{u,3}$, $G_{v,1}$
dominate the constraints for the others goods in the groups
(since $\alpha \geq 0$),
hence these constraints
are equivalent to
\begin{equation}\label{hah}
\alpha\cdot p(G_{u,3})+\mu\ge 1\quad\text{and}\quad
\alpha\cdot p(G_{v,1})+\mu \ge 1/2.
\end{equation}
The constraint for the good $j$ with price $0$ yields $\mu \geq 0$,
and this subsumes the constraints for all $j \notin G_{u,3} \cup G_{v,1}$.
Thus, the dual LP is to minimize $\alpha+\mu$ subject to $\alpha\ge 0$, $\mu \geq 0$, and (\ref{hah}) above.
The optimal solution $\alpha^*, \mu^*$ satisfies the (\ref{hah}) as equalities.
Thus, solving the dual LP we get
$$
\alpha^*=\frac{1}{2(p(G_{u,3})-p(G_{v,1}))}\approx \frac{1}{4}\quad\text{and}\quad \mu^*=\frac{p(G_{u,3})-2p(G_{v,1})}{2(p(G_{u,3})-p(G_{v,1}))}\approx\frac{1}{2}.
$$
Consider an agent in $A_{e,1}$ and write
$x_u$ and $x_v$ respectively to denote her allocation of goods from $G_{u,3}$ and $G_{v,1}$.
Since every good that is not in $G_{u,3} \cup G_{v,1}$
is $\mu^*$-suboptimal for the agent,
it follows from Corollary \ref{maincoro} and Corollary \ref{closecoro} that
$$
x_u+x_v=1\pm O(\epsilon)\quad\text{and}\quad p(G_{u,3})x_u+p(G_{u,1})x_v=1\pm O(1/n^2).
$$
From Lemma \ref{lem:variable-price},
$p(G_{u,3})=2-p(G_{u,1})\pm O(1/m^7)$.
For ease of notation, let us use $p_v $ to denote $p(G_{v,1})$
and $p_u$ for $p(G_{u,1})$.
Solving the above equations for $x_u$ and $x_v$ gives us
\begin{align*}
x_v = \frac{1 - p_u}{2 - p_u - p_v} \pm O\left(\frac{1}{m^7}\right) \quad \text{and} \quad
x_u = \frac{1 - p_v}{2 - p_u - p_v} \pm O\left(\frac{1}{m^7}\right).
\end{align*}
Since $p_u, p_v \in [0, 1/m^2 \pm O(1/m^6)]$, by performing the first order approximation, we have
\begin{align*}
\frac{1 - p_u}{2 - p_u - p_v}
= \frac{(1 - p_u)(2+p_u + p_v)}{(2 - p_u - p_v)(2+p_u+p_v)}
= \frac{2 + p_v - p_u - p_u(p_u+p_v)}{4 - (p_u + p_v)^2}
= \frac{2+p_v - p_u}{4} \pm O\left(\frac{1}{m^4}\right).
\end{align*}
The result for $x_u$ can be shown similarly.
\end{proof}
Now we work on agents in $A_{e,2,\ell}$ for each $\ell\in [m]$:
\begin{figure}[!ht]
\centering
\includegraphics[width=\textwidth]{type2.png}
\vspace{-0.8cm}\caption{Edge gadget: Agents $A_{e,2,\ell}$ with $\ell\in [m]$.}
\end{figure}
\begin{lemma}
\label{lem:gadget2}
For each $\ell\in [m]$, the allocation of goods in $G_{v,1}$
to each agent in $A_{e,2,\ell}$ is $O( m^4\epsilon )$ if $\ell/m^3\le p(G_{v,1})-1/m^4$ and
$0.5 \pm O(1/{m^2})$
if $\ell/m^3\ge p(G_{v,1})+ 1/m^4$.
\end{lemma}
\begin{proof}
The dual LP of each agent in $A_{e,2,\ell}$ is to minimize $\alpha+\mu$ subject to the following constraints:
$\alpha\ge 0$; $\mu\ge 0$;
$\alpha\cdot p(G_e)+\mu\ge 1$;
$\alpha\cdot p(G_{v,1})+\mu\ge \ell/2m^3$.
(We have simplified the dual LP following similar arguments used at the beginning of the proof for the previous lemma.)
The optimal solution $(\alpha^*,\mu^*)$ now has two cases.
If $p(G_{v,1})\ge \ell/m^3+1/m^4$,
the optimal solution $(\alpha^*,\mu^*)$ is
$\alpha^*=1/p(G_e)$ and $\mu^*=0$. Thus,
$$
\alpha^*\cdot p(G_{v,1})+\mu^*=\frac{p(G_{v,1})}{p(G_e)} \ge \frac{\ell}{2m^3}+\Omega\left(\frac{1}{m^4}\right)
$$
using Lemma \ref{lem:goode}.
So goods in $G_{v,1}$ are $\Omega(1/m^4)$-suboptimal to the agent and it follows directly from
Lemma \ref{fact:subopt-goods} that the agent is allocated at most $O(m^4 \epsilon)$ units of $G_{v,1}$.
If $p(G_{v,1})< \ell/m^3-1/m^4$,
the optimal solution is given by
$$
\alpha^*=\frac{1-\ell/(2m^3)}{p(G_e)-p(G_{v,1})}\approx \frac{1}{2}\quad\text{and}\quad
\mu^*=\frac{(\ell/2m^3)p(G_e)-p(G_{v,1})}{p(G_e)-p(G_{v,1})}\ge \Omega\left(\frac{1}{m^4}\right).
$$
So goods not in $G_e \cup G_{v,1}$ are $\mu^*$-suboptimal.
Let $x_e$ and $x_v$ be respectively the allocation of goods in $G_e$ and $G_{v,1}$ to the agent.
It follows from Corollary \ref{maincoro} and Corollary \ref{closecoro} that
\begin{align*}
x_e+x_v&=1\pm O(m^4\epsilon)\quad\text{and}\quad
p(G_e)x_e+p(G_{v,1})x_v =1\pm O(1/n^2).
\end{align*}
Solving the above equations, and recalling
$p(G_e) = 2 \pm O(1/m^4)$ and $p(G_{v,1}) = O(1/m^2)$, we have
\begin{align*}
x_v = \frac{p(G_e)-1}{p(G_e)-p(G_{v,1})} \pm O\left(\frac{1}{n^2}\right) = \frac{2+p(G_{v,1})}{4} \pm O\left(\frac{1}{m^{4}}\right).
\end{align*}
This finishes the proof of the lemma.
\end{proof}
\begin{lemma}
\label{lem:gadget2-com}
The total allocation of goods in $G_{v,1}$ to all
agents in $A_{e,2,\ell}$, $\ell\in [m]$, is $$3m\big(1 - m^2 p(G_{v,1})\big) \pm O(1).$$
\end{lemma}
\begin{proof}
Let $\ell^*=\lfloor m^3 p(G_{v,1})\rfloor\in [0:m]$.
Then for each $\ell \in [m]$ with $\ell\le \ell^*-1$, the allocation of $G_{v,1}$ to each agent in $A_{e,2,\ell}$ is
$O(m^4\epsilon)$;
for each $\ell\in [m]$ with $\ell\ge \ell^*+2$, the allocation is $0.5 \pm O(1/m^2)$.
For $\ell^*$ and $\ell^*+1$, the allocation is between $0$ and $1$ trivially.
Since there are 6 agents in each group $A_{e,2,\ell}$, the total allocation to all agents in all groups is
$$
6\sum_{\ell\in [\ell^*-1]} O(m^4\epsilon)+6\sum_{\ell\in [\ell^*+2:m]} \left(\frac{1}{2}\pm O\left(\frac{1}{m^2}\right)\right)+ O(1)
=6\sum_{\ell\in [\ell^*+2:m]} \frac{1}{2} \pm O(1).
$$
The number of summands in the last expression is
$$\max(0,m-\ell^*-1)=
m \left( 1-m^2 p(G_{v,1})\right)\pm O(1) $$
and the lemma follows.
\end{proof}
The following lemma for agents in $A_{e,3,\ell}$ can be proved similarly:
\begin{lemma}\label{lem:similar}
The allocation of goods in $G_{u,1}$ to all
agents in $A_{e,3,\ell}$, $\ell\in [m]$, is $$4m\big(1 - m^2 p(G_{u,1})\big) \pm O(1).$$
\end{lemma}
Finally we work on agents in $A_{e,4,\ell}$, $\ell\in [2m]$:
\begin{figure}[!ht]
\centering
\includegraphics[width=\textwidth]{type3.png}
\vspace{-1.8cm}\caption{Edge gadget: Agents $A_{e,4,\ell}$ with $\ell\in [2m]$.}
\end{figure}
\begin{lemma}
\label{lem:gadget3}
For each $\ell\in [2m]$, we have the following two cases for an agent in $A_{e,4,\ell}$:
\begin{flushleft}\begin{enumerate}
\item The allocation of $G_{u,2}$ is $O(m^3\epsilon)$ and the allocation of $G_{v,1}$ is
$0.5\pm O(1/m^2)$, if $\ell$ satisfies
\begin{equation}\label{eq:case1}
\frac{\ell}{2m^3}\ge \frac{p(G_{v,1})}{2}-\frac{p(G_{u,1})}{3}+\frac{1}{3m^2}+\frac{2}{m^3}.
\end{equation}
\item The allocation of $G_{v,1}$ is $O(m^3\epsilon)$ and the allocation of $G_{u,2}$ is
$2/3\pm O(1/m^2)$, if $\ell$ satisfies
\begin{equation}\label{eq:case2}
\frac{\ell}{2m^3}\le \frac{p(G_{v,1})}{2}-\frac{p(G_{u,1})}{3}+\frac{1}{3m^2}.
\end{equation}
\end{enumerate}\end{flushleft}
\end{lemma}
\begin{proof}
The dual LP for an agent in $A_{e,4,\ell}$ is to minimize $\alpha +\mu $ subject to $\alpha \ge 0$, $\mu \ge 0$,
\begin{equation}\label{eq:lp}
\alpha \cdot p(G_e)+\mu \ge 1,\quad
\alpha \cdot p(G_{u,2})+\mu \ge \frac{1}{4}+\frac{1}{4m^2}+\frac{1}{m^3}\quad\text{and}\quad
\alpha \cdot p(G_{v,1})+\mu \ge \frac{\ell}{2m^3}.
\end{equation}
Geometrically, the feasible space of the LP is a region of
the $\alpha -\mu$ plane, bounded from below by a a piecewise linear
convex curve whose segments correspond to (some of)
the above constraints. The optimum is achieved at a vertex
of the boundary curve, where the constraints corresponding to the two adjacent segments are tight.
We consider the two cases.
First we consider the case of (\ref{eq:case1}).
In this case, the first and third inequalities of (\ref{eq:lp}) are tight at optimality,
and the optimal solution $(\alpha^*,\mu^*)$ is
$$
\alpha^*=\frac{1-(\ell/2m^3)}{p(G_e)-p(G_{v,1})}\quad\text{and}\quad
\mu^*=\frac{(\ell/2m^3)\cdot p(G_e)-p(G_{v,1})}{p(G_e)-p(G_{v,1})}.
$$
Using (\ref{eq:case1}) and $p(G_e) \approx 2$,
$p(G_{u,1}) \leq 1/m^2 \pm O(1/m^6)$, it is easy to check
that $\mu^* = \Omega(1/m^3)$.
Therefore, all goods that are not in $G_e \cup G_{v,1} \cup G_{u,2}$
are $\Omega(1/m^3)$-suboptimal.
Furthermore, also all goods in $G_{u,2}$ are $\Omega(1/m^3)$-suboptimal, i.e.,
$$
\alpha^*\cdot p(G_{u,2})+\mu^*-\left(\frac{1}{4}+\frac{1}{4m^2}+\frac{1}{m^3}\right) \ge \Omega\left(\frac{1}{m^3}\right),
$$
because multiplying the left-hand-side by $p(G_e)-p(G_{v,1})\approx 2$ we get
\begin{align*}
&\frac{1}{2}-\frac{\ell}{4m^3}+\frac{p(G_{u,1})}{2}+\frac{\ell}{m^3}-p(G_{v,1})
-\frac{1}{2}-\frac{1}{2m^2}-\frac{2}{m^3}+\frac{p(G_{v,1})}{4}\pm O\left(\frac{1}{m^4}\right)\\[0.8ex]
&\hspace{0.5cm}=\frac{3\ell}{4m^3}+\frac{p(G_{u,1})}{2}-\frac{3p(G_{v,1})}{4}-\frac{1}{2m^2}-\frac{2}{m^3}\pm O\left(\frac{1}{m^4}\right)
\ge \Omega\left(\frac{1}{m^3}\right).
\end{align*}
So it follows from Lemma \ref{fact:subopt-goods} that the total allocation to the agent (and the cost) of all goods that are not
in $G_e$ and $G_{v,1}$ is $O(m^3\epsilon)$.
Using $x_e$ and $x_v$ to denote the allocation of goods in $G_e$ and $G_{v,1}$ to the agent respectively,
it follows from Corollary \ref{maincoro} and Corollary \ref{closecoro} that
\begin{align*}
x_e + x_v &= 1 \pm O(m^3\epsilon ) \quad\text{and}\quad
p(G_{v,1}) x_v + p(G_{e})x_e = 1 \pm O(1/n^2)
\end{align*}
and using $p(G_e) \approx 2$ and $p(G_{v,1}) = O(m^2)$,
one can derive that $x_v = 0.5 \pm O(1/m^2)$.
Similarly, one can show that when (\ref{eq:case2}) holds,
then the first two inequalities of (\ref{eq:lp}) are tight at the optimal solution
$\alpha^*, \mu^*$. We have again $\mu^* = \Omega(1/m^3)$,
and thus all goods outside $G_e \cup G_{u,2} \cup G_{v,1}$ are $\Omega(1/m^3)$-suboptimal.
Furthermore, in this case all goods in $G_{v,1}$ are
also $\Omega(1/m^3)$-suboptimal. Hence the total allocation
(and cost) of these goods to the agent is $O(m^3\epsilon)$.
We can set up similarly as in the previous case
the equations for the allocations
$x_e, x_u$ of the goods in $G_e$, $G_{u,2}$ respectively to the agent,
and solve them to get $x_u = 2/3 \pm O(1/m^2)$.
This concludes the proof.
\end{proof}
\begin{lemma}
\label{lem:gadget3-com}
The total allocation of goods in $G_{v,1}$ to agents in $A_{e,4,\ell}$, $\ell\in [2m]$, is
\[
18m\left(\frac{2}{3} + \frac{m^2}{3}\cdot p(G_{u,1}) - \frac{m^2}{2}\cdot p(G_{v,1})\right) + O(1),
\]
and the total allocation of goods in $G_{u,2}$ to these agents is
\[
18m\left(\frac{4}{9} - \frac{4m^2}{9}\cdot p(G_{u,1}) + \frac{2m^2}{3}\cdot p(G_{v,1})\right) + O(1).
\]
\end{lemma}
\begin{proof}
Let $\ell^*$ be chosen as
$$
\ell^*=\left\lfloor m\left(\frac{2 }{3}+m^2\cdot p(G_{v,1})-
\frac{2m^2 }{3}\cdot p(G_{u,1})\right)\right\rfloor \le \frac{5m}{3}.
$$
We start with goods in $G_{v,1}$. By Lemma~\ref{lem:gadget3}, the total allocation is $18$ times
$$
\sum_{\ell\in [\ell^*]} O(m^3\epsilon)+\sum_{\ell\in [\ell^*+6:2m]}
\left(0.5\pm O\left(\frac{1}{m^2}\right)\right)+ O(1)
=\sum_{\ell\in [\ell^*+6:2m]}
0.5 \pm O(1).
$$
The number of terms in the last sum is
$$
2m-m\left(\frac{2 }{3}+m^2\cdot p(G_{v,1})-
\frac{2m^2}{3}\cdot p(G_{u,1})\right)
\pm O(1)
$$
It follows that the total allocation is
$$
18m\left(\frac{2}{3}+\frac{ m^2}{3}\cdot p(G_{u,1})-\frac{m^2}{2}\cdot p(G_{v,1})\right) \pm O(1).
$$
Similarly, the total allocation of goods $G_{u,2}$ is 18 times
$$
\sum_{\ell\in [\ell^*]} \left(\frac{2}{3}\pm O\left(\frac{1}{m^2}\right)\right)
+\sum_{\ell\in [\ell^*+6:2m]} O(m^3\epsilon)+ O(1)=\sum_{\ell\in [\ell^*]} \frac{2}{3} \pm O(1).
$$
The number of terms in the last sum is
$$
m\left(\frac{2 }{3}+m^2\cdot p(G_{v,1})-
\frac{2m^2}{3} \cdot p(G_{u,1})\right)\pm O(1)
$$
and the lemma follows.
\end{proof}
We are now ready to prove Lemma \ref{lem:edgedemand}:
\begin{proof}[Proof of Lemma \ref{lem:edgedemand}]
Combining Lemma~\ref{lem:gadget1}, Lemma~\ref{lem:gadget2-com}, Lemma \ref{lem:similar} and Lemma~\ref{lem:gadget3-com}, we have the total allocation of nonzero-utility goods in $G_v$ to agents in $A_e$ is
\begin{align*}
&~48m^3 \left(\frac{1}{2} + \frac{p(G_{v,1})- p(G_{u,1})}{4}\right) + 18m\left(
\frac{2}{3} + \frac{m^2}{3}\cdot p(G_{u,1}) - \frac{m^2}{2}
\cdot p(G_{v,1})\right) \\[0.6ex]
&~\hspace{3cm}+ 3m\big(1-m^2\cdot p(G_{v,1})\big) \pm O(1) \notag\\[0.8ex]
&\hspace{1cm}= -6m^3\cdot p(G_{u,1}) + 24m^3 +15m\pm O(1).
\end{align*}
The total allocation of nonzero-utility goods in $G_u$ to $A_e$ is
\begin{align}
&~48m^3 \left(\frac{1}{2} + \frac{p(G_{u,1}) - p(G_{v,1})}{4}\right) + 18m
\left(\frac{4}{9} - \frac{4m^2}{9}\cdot p(G_{u,1}) + \frac{2m^2}{3}\cdot p(G_{v,1})\right) \notag\\[0.6ex]
&~\hspace{4cm}+ 4m \big(1 - m^2\cdot p(G_{u,1})\big) \pm O(1) \notag\\[0.8ex]
&\hspace{1cm}= 24m^3+ 12m \pm O(1).
\end{align}
This finishes the proof of the lemma.
\end{proof}
\section{Preliminaries}
\label{sec:pre}
We write $[n]$ to denote $\{1,2,\ldots, n\}$. Given two integers $n$ and $m$ we use $[n:m]$
to denote integers between $n$ and $m$, with $[n:m]=\emptyset$ when $m<n$.
Given two real number $x, y \in \mathbb{R}$, we use $x = y\pm \epsilon$ to denote $x\in [y-\epsilon, y+\epsilon]$.
\subsection{The Hylland-Zeckhauser Scheme}
We provide a formal description of the Hylland-Zeckhauser scheme for one-sided matching markets
\cite{hz79, vy21}.
It will be convenient for us to describe it using the language of linear Fisher markets.
An \emph{HZ market} $M$ consists of
a set $A=[n]$ of $n$ agents and a set $G = [n]$ of $n$ (infinitely) divisible goods.
Each agent $i\in A$ has one dollar and there is one unit of each good $j\in G$ in the market.
We write $u_{i,j}\in [0,1]$\footnote{As it will become clear in Definition \ref{def:hz-equilibrium},
shifting and scaling utilities of agents does not change the set of HZ equilibria.
We assume utilities to lie in $[0,1]$ because we will consider an additive approximation
of HZ equilibria in Definition \ref{def:hz-approx-equilibrium}.}
to denote the utility of one unit of good $j$ to agent $i$, for each $i\in A$ and $j\in G$.
Hence an HZ market $M$ is specified by a positive integer $n$ and utilities $(u_{i,j}:i,j\in [n])$.
Given an HZ market $M$ with $n$ agents and goods, an \emph{HZ equilibrium} \cite{hz79}
consists of an allocation $x=(x_{i,j}:i,j\in [n])$ and a price vector $p=(p_j:j\in [n])$
that are nonnegative and satisfy a list of properties to be described in Definition \ref{def:hz-equilibrium}.
Given $x$ and $p$, we will refer to $x_i=(x_{i,j}:j\in [n])$ as the \emph{bundle of goods allocated to agent $i$}.
The \emph{cost} of the bundle $x_i$ is given by $\sum_{j\in [n]} p_j x_{i,j}$ and the \emph{value} of $x_i$ to agent $i$ is
$\sum_{j\in [n]} u_{i,j} x_{i,j}$.
We are ready to define HZ equilibria:
\begin{definition}[HZ Equilibria \cite{hz79}]
\label{def:hz-equilibrium}
A pair $(x,p)$, where $x=(x_{i,j}:i,j\in [n])\in \mathbb{R}_{\ge 0}^{n\times n}$ and $p=(p_i:i\in [n])\in \mathbb{R}^n_{\ge 0}$,
is an \emph{HZ equilibrium} of an HZ market $M$ if:
\begin{flushleft}\begin{enumerate}
\item The total allocation of each good $j\in [n]$ is $1$ unit, i.e., $\sum_{i\in [n]}x_{i,j} =1$.
\item The total allocation of each agent $i\in [n]$ is $1$ unit, i.e., $\sum_{j\in [n]}x_{i,j} =1$.
\item The cost of the bundle $x_i$ of each agent $i\in [n]$ is at most $1$, i.e.,
$\smash{\sum_{j \in [n]}p_jx_{i,j} \leq 1}$.
\item For each $i\in [n]$, $x_i$ maximizes its value
$\sum_{j\in [n]} u_{i,j}x_{i,j}$ to agent $i$ subject to 2 and 3 above.\footnote{We note that in \cite{hz79, vy21},
$x_i$ is required (as a tie-breaking rule) to minimize its cost among all those that maximize the value subject to items 2 and 3.
This is needed to ensure Pareto optimality of the equilibrium allocations. However, we
do not need this condition for our hardness results, and this only makes the results stronger. So for simplicity, we omit the condition
from the definition of exact and approximate equilibria.}
\end{enumerate}\end{flushleft}
\end{definition}
Equivalently the last condition in the definition above can be captured by the following LP:
\begin{align*}
\text{\emph{maximize}}\ \ &\sum_{j\in [n]} u_{i,j}x_{i,j}\\ \text{\emph{s.t.}}\ \
&\sum_{j\in [n]}x_{i,j} = 1,\
\sum_{j\in [n]}p_j x_{i,j} \leq 1,\ \text{and}\
x_{i,j} \geq 0\ \text{for all $j\in [n]$}.
\end{align*}
Taking $\mu_i$ and $\alpha_i$ to be the dual variables, one has the following dual LP that will be useful:
\begin{align*}
\text{\emph{minimize}}\ \ \hspace{0.05cm}&\alpha_i + \mu_i\\[0.3ex]
\text{\emph{s.t.}}\ \ \hspace{0.05cm}&\alpha_i \geq 0\ \text{and}\
\alpha_i p_j + \mu_i \geq u_{i,j},\ \text{for all $j\in [n]$}.
\end{align*}
We will refer to the LP (and its dual LP) above as the LP (or dual LP) for
agent $i$ with respect to the price vector $p$.
Let $\textsf{value}_p(i)$ denote their optimal value. Then it captures the optimal value of any bundle of goods
to agent $i$ subject to conditions 2 and 3 in Definition \ref{def:hz-equilibrium}.
Hylland and Zeckhauser \cite{hz79} showed that an HZ equilibrium always exists:
\begin{theorem}[Existence \cite{hz79}]
Every HZ market admits an HZ equilibrium.
\end{theorem}
If $(x,p)$ is an equilibrium, then it is easy to see that if we scale
the difference of all prices from 1, the resulting price vector $p'$
together with the same allocation $x$ forms also an equilibrium;
i.e. for any $r>0$ with $r \leq \min \{ 1/(1-p_j) | p_j <1 \}$, setting $p'_j = 1 + r(p_j -1)$ for all $j \in [n]$ yields a vector
$p'$ such that $(x,p')$ is also an equilibrium (see \cite{vy21}).
The reason is that this scaling does not affect the set of feasible allocations, as can be easily seen, and
$\textsf{value}_{p'}(i)=\textsf{value}_p(i)$ for all agents $i \in [n]$.
That is, price vectors related to each other by this scaling are in a sense equivalent. A consequence of this observation
is that we may always assume w.l.o.g. that an equilibrium contains a good with price 0 \cite{hz79}:
If one of the goods has price $<1$, then we can always scale the prices so that the minimum price is 0.
On the other hand if all prices in an equilibrium are $\ge 1$,
then all prices must be 1 (the sum of the prices must be $\leq n$,
the sum of the agents' budgets), and in this case the cost
condition 3 is redundant, and the all-0 vector forms also an equilibrium with the same allocation.
We say that a price vector $p$ is {\em normalized} if $\min_i p_i =0$.
We will restrict our attention henceforth to normalized price vectors, without always mentioning it explicitly.
Our hardness results hold for the following relaxation studied by
Vazirani and Yannakakis \cite{vy21}:
\begin{definition}[Approximate HZ Equilibria]
\label{def:hz-approx-equilibrium}
Given some $\epsilon>0$, a pair $(x,p)$, where $x=(x_{i,j}:i,j\in [n])\in \mathbb{R}_{\ge 0}^{n\times n}$~and $p=(p_i:i\in [n])\in \mathbb{R}^n_{\ge 0}$ (where $\min_{i\in [n]} p_i =0$)\footnote{The requirement that $p$ be normalized is important in the definition because otherwise condition 3 on the cost has no effect: if $(x,p)$ is any pair that satisfies conditions 1,2,4, then we can always scale $p$ as above
to a vector $p'$
where all prices are sufficiently close to 1 so that condition 3 is also satisfied for $(x,p')$.},
is an \emph{$\epsilon$-approximate HZ equilibrium} of an HZ market $M$ if:
\begin{flushleft}\begin{enumerate}
\item The total allocation of each good $j\in [n]$ is $1$ unit, i.e., $\sum_{i\in [n]}x_{i,j} =1$.
\item The total allocation of each agent $i\in [n]$ is $1$ unit, i.e., $\sum_{j\in [n]}x_{i,j} =1$.
\item The cost of $x_i$ is at most $1+\epsilon$ for each $i\in [n]$, i.e.,
$\smash{\sum_{j \in [n]}p_jx_{i,j} \leq 1+\epsilon}$.
\item The value $\sum_{j\in [n]} u_{i,j} x_{i,j}$ of $x_i$ to agent $i$ is at least $\emph{\textsf{value}}_p(i) - \epsilon$ for
each $i\in [n]$.
\end{enumerate}\end{flushleft}
\end{definition}
An alternative, more relaxed notion of an $\epsilon$-approximate equilibrium, where condition 1 is also relaxed to $|\sum_{i\in [n]}x_{i,j} -1| \leq \epsilon$ for all goods $j \in [n]$, is polynomially equivalent to the above notion \cite{vy21}. Thus, it follows that computing an $\epsilon$-approximate equilibrium under the more relaxed
notion is also PPAD-complete.
\subsection{Threshold Games}
Our PPAD hardness results use \emph{threshold games}, introduced recently by Papadimitriou and Peng \cite{pp21}.
They showed that the problem of finding an approximate equilibrium in a threshold game is PPAD-complete. %
\begin{definition}[Threshold game \cite{pp21}]
\label{def:threshold}
A threshold game is defined over a directed graph $H = (V, E)$. Each node $v\in V$ represents a player with strategy space $x_v\in [0,1]$.
Let $N_v$ be the set of nodes~$u\in V$ with $(u,v)\in E$.
Then $x = (x_v:v\in V) \in [0, 1]^{V}$ is a $\kappa$-\emph{approximate equilibrium} if every $x_v$ satisfies
\begin{align*}
x_v \in
\begin{cases}
[0,\kappa] & \sum_{u \in N_v} x_u > 0.5 + \kappa\\
[1-\kappa,1] & \sum_{u \in N_v} x_u < 0.5 - \kappa\\
[0,1] & \sum_{u \in N_v}x_u \in[ 0.5 - \kappa, 0.5+\kappa]
\end{cases}
\end{align*}
\end{definition}
\begin{theorem}[Theorem 4.7 of \cite{pp21}]
\label{thm:ppad-threshold}
There is a positive constant $\kappa$ such that the problem of
finding a $\kappa$-approximate equilibrium in a threshold game is PPAD-hard.
This holds even when the in-degree and out-degree of each node is at most $3$ in the threshold game.
\end{theorem}
\subsection{Related Work}
\label{sec:relate}
We have already mentioned the most relevant work on the complexity of the Hylland-Zeckhauser scheme. The problem of computing an exact HZ equilibrium is in FIXP, and computing an approximate equilibrium is in PPAD \cite{vy21}. Polynomial-time algorithms for a fixed number of agents~or goods were given in \cite{akt17}. It has been a longstanding open problem about whether there is a polynomial-time algorithm in the general case.
The input in the one-sided matching problem is the same as in the
classical assignment problem (equivalently, maximum weight perfect matching problem in bipartite graphs). This is one of the most well-studied problems in Operations Research and Computer Science, and several very efficient algorithms have been developed for it over the years. The difference in the one-sided matching problem is that the primary consideration is to produce a solution that has certain desirable fairness and optimality properties for the agents; the goal is not simply the maximization of the weight of the matching.
As we show in this paper, computing an HZ solution for the one-sided matching problem is probably computationally harder: it is PPAD-hard
to compute any approximate HZ solution, and if we want to maximize the total weight of the matching as a secondary criterion then the problem becomes NP-hard.
In the case of ordinal preferences for the agents in the one-sided matching problem, there are other schemes with nice properties: the Random Priority (also called Random Serial Dictatorship) scheme \cite{as98, moulin18} and the Probabilistic Serial scheme \cite{bm01}.
These have polynomial-time (randomized) algorithms. However, since they are based only on ordinal preferences, they are suboptimal with respect to the agents' utilities, as the earlier simple example shows.
The setting in the HZ scheme is the same as in the linear Fisher market model: the input consists of the utilities $u_{i,j}$ of the agents for the goods, and the problem is to compute equilibrium prices and allocations. The only difference is that when an agent picks her optimal bundle of goods, she must get exactly one unit (in addition to the cost being within the budget of 1 dollar), i.e. the solution must be a (fractional) perfect matching. Although this may seem like a small difference, it has a substantial effect both in the structure of the problem and in its computational complexity: exact solutions may be irrational, and as we show in this paper, finding an approximate solution is PPAD-hard. The linear Fisher model has been studied extensively and there are polynomial-time algorithms for computing equilibria in this model, as well as in the more general Arrow-Debreu model with linear utilities \cite{dpsv08,orlin10,jain07}.
There is furthermore extensive work on markets with more complex utility functions than linear, such as piecewise linear, Leontief, CES utilities and others, and for many of them it is PPAD-hard or FIXP-hard to compute an approximate or exact equilibrium
(e.g. \cite{cddt09,ct09,vy11,cpy17,ey10,gmv17}).
Several researchers have proposed Hylland-Zeckhauser-type mechanisms for a number of appli\-cations, e.g. see \cite{budish11,he18,le17,mclennan18}. There are also recent works that have generalized and extended the basic HZ scheme in several directions, for example to two-sided matching markets and to an Arrow-Debreu-type setting where the agents own initial endowments \cite{emz19a,emz19b,gtv20}. Note that in the case of initial endowments, an HZ equilibrium may not always exist, so some approximation or slack is needed to ensure existence
(see \cite{emz19a,gtv20}).
\subsection{Proof Overview}
\label{sec:overview}
We give an overview of the proof of Theorem \ref{thm:hz-equilibrium}.
To prove the problem of finding an approximate HZ equilibrium is PPAD-hard, we
give a polynomial-time reduction from
{\em threshold games}, introduced recently by Papadimitriou and Peng \cite{pp21}.
A threshold game is defined on a directed graph $G = (V, E)$, with a variable $x_v \in [0,1]$ associated with each node $v \in V$. The equilibrium condition is characterized by a comparison operator: $x_v = 1$ if $\sum_{ (u, v) \in E} x_u \leq 1/2 -\kappa$; $x_v = 0$ if $\sum_{ (u, v) \in E} x_u \geq 1/2 +\kappa$ and $x_v$ can take an arbitrary value in $[0,1]$, otherwise.
The PPAD-hardness of threshold game is proved in \cite{pp21}, and it holds for some positive constant $\kappa > 0$ and for sparse graphs.
As we will see later, the use of threshold games significantly simplifies the reduction.
From a high-level view, our reduction follows the general framework
of previous hardness results on market equilibria \cite{cddt09,ct09,vy11,cpy17}:
we use prices of an HZ market to simulate variables $x_v$ in a threshold game
and the construction is based on the design of two gadgets:
\emph{variable gadgets} for each $v\in V$ (to simulate variables $x_v$ and enforce the equilibrium condition at each node $v$) and \emph{edge gadgets} for each $e=(u,v)\in E$ (to simulate the action of sending
$x_u$ to the sum at $x_v$ in the threshold game).
However,
a major challenge of working with the HZ scheme is that it is difficult to characterize the equilibrium behavior of agents in this model, as it is complex, nonlinear, and does not admit a closed form solution. As a consequence, it is hard both, to analyze even small instances, and to synthesize instances with desired characteristics.
Below we discuss some of the key ideas behind the construction.
\vspace{+2mm}
{\bf \noindent Variable gadgets.}
To simulate variables $x_v$ of a threshold game,
our starting point is the following simple sub-market.
There are two agents and two goods. Both agents have utility $1$ for good $1$ and utility $\frac{1}{2\delta^{-1} - 1}$ for good $2$ ($0 < \delta < 1$ which should be considered as a small constant as discussed below).
It is easy to observe that the set of equilbrium prices are $(p, 2-p)$ for $p \in [0,\delta]$.
After scaling by $1/\delta$,
the price $p$ of good $1$ in this sub-market can be used to simulate
a variable $x_v\in [0,1]$ in the threshold game.
So we create such a sub-market $M_v$ for each node $v$ and
denote the price of good $1$ in $M_v$ by $p_v$.
To finish the reduction, it suffices to create agents that
are interested in goods in $M_u$ and $M_v$,
for each edge $e=(u,v)\in E$, such that
the total allocation of goods from $M_v$ to them is captured by
$-p_u$.\footnote{The negative allocation
may look strange but can be achieved (essentially) by offsetting the supply carefully.}
The agents created for this task are what we referred to earlier as the edge gadget for $e$.
If achieved, the total allocation of goods of $M_v$ to agents outside
would give the desired linear form $-\sum_{(u,v)\in E} p_u$ which is
a scaled version of $-\sum_{(u,v)\in E} x_u$.
The sub-market $M_v$ can help enforce the equilibrium condition of the
threshold game.
When $\sum_{(u,v)\in E} x_u$ is too small (so the allocation to agents outside
is high due to the negative sign), there is a
shortage of goods of $M_v$, which
would lead to $p_v\approx \delta$ and thus, $x_v\approx 1$; on the other hand, if the sum is too large, then there is a surplus of goods in the sub-market $M_v$, which forces
$p_v\approx 0$ and thus, $x_v\approx 0$.
\vspace{+2mm}
{\bf \noindent Edge gadgets.}
The key technical challenge lies in the construction of edge gadgets.
Our first attempt is to create an agent who has utility $1/2$ for good
$1$ in $M_u$ and utility $1$ for good $2$ in $M_v$ (with price $2-p_v$).
The optimal bundle for this agent, however, is not easy to work with
at first sight: for example, the agent is allocated
$\frac{1 -p_u}{2 - p_u - p_v}$ unit of good $2$ in $M_v$.
{{\bf The first key idea of our reduction is to use first order approximation to simplify a complex function}.
That is to say}, we set $\delta$ to be a sufficiently small constant and apply first-order
approximation on the allocation.
Ignoring constant factors and constant or lower-order terms,
the agent described earlier has $D_{u}\approx p_u - p_v$
unit of good $1$ in $M_u$ and $D_{v} \approx p_v - p_u$ unit of good $2$
in $M_v$ in her optimal bundle.
This, however, is far from what we hoped for, as (1) we don't want $p_v$ to appear in $D_v$, and (2) we want $D_u = 0$.
(Notably if we use this agent as our edge gadget for every $e\in E$, then they together
are essentially simulating a threshold game over an undirected graph, which
admits trivial equilibria.)
What about agents with a different set of utilities for goods in $M_u$ and $M_v$?
Perhaps surprisingly, all our attempts fail and there is a fundamental reason for that: it can be shown that, no matter how the utilities are set, the allocation of goods in $M_v$ is always monotonically increasing with $p_v$, which is undesirable for our purpose.
We circumvent this obstacle using the following three steps.
First, we introduce extra goods with a fixed price $2$ into the picture
(where the fixed price can be enforced easily by creating agents who
are interested in these goods only).
Second, we replace the current variable gadget with a richer
sub-market with three goods, with the price of the new good
set to be $\frac{(1+p_v)}{2}$.
Agents in our edge gadget can now have access to these new goods
which give us a larger design space for their utilities and equilibrium behavior.
The last step, which is {\bf the second key idea of our reduction, is to use discrete functions to approximate a continuous function}.
This is essential in our proof and we believe it might be of independent interest in reductions of similar settings.
Concretely, we design agents that perform
comparison operations: there are two possible optimal bundles for each
of these agents, and which one it is depends on the sign (in a robust sense)
of a certain affine linear form
of $p_u$ and $p_v$.
The agent behaves like a step function, which is not useful on its own. However, when combined, one can construct a series of agents by enumerating utilities; these lead to careful cancellations that make sure
the total allocation $D_u$ of goods from $M_u$ is $0$ as desired.
| {'timestamp': '2021-07-14T02:05:29', 'yymm': '2107', 'arxiv_id': '2107.05746', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05746'} | arxiv |
\section{Introduction}
This paper proposes and analyzes a strategy called \emph{monotonic filtering}, for removing large overestimates in distributed data collection.
Recent years have witnessed a proliferation of complex networked open systems comprising a plethora of heterogeneous devices like drones, smartphones, IoT devices, and robots.
These systems mandate the formulation of new strategies
of collective adaptation, with the ultimate goal of transforming these environments into \emph{pervasive computing fabric}. In these conditions, sensing, actuation, and computation are resilient and distributed across space \cite{bicocchi:selforganisation}.
The focus of this paper is on resilient \emph{distributed sensing}, which could be of physical environmental properties or of digital or virtual characteristics of computing resources.
By cooperation between physically proximate, interacting sets of mobile entities, distributed sensing can support complex situation recognition \cite{coutaz:contextkey}, monitoring \cite{bicocchi:selforganisation}, and observation and control of swarms of agents \cite{viroli:aggregate:plans}.
A defining coordination task in distributed sensing is data summarization from devices in a region.
From this, one can perform many other operations like count, integrate, average, and maximize. Data summarization is like the \emph{reduce} phase of MapReduce \cite{dean:mapreduce}. It is extended to agents communicating through their neighbors and spread across a region, e.g., in wireless sensor networks \cite{talele:aggregation:survey}.
A common implementation of data summarization is by \emph{distributed collection}, where information moves towards collector devices and aggregates \emph{en route} to produce a unique result.
Such self-organizing behavior (referred to as a ``C'' block in~\cite{vabdp:selfstabilisation}), is a fundamental and widely used component of collective adaptive systems (CASs). It can be instantiated for values of any data type with a commutative and associative aggregation operator, and can be applied in many diverse contexts.
Several papers have characterized the dynamics of data summarization algorithms \cite{vabdp:selfstabilisation,mo:collection:error} and on improving such dynamics \cite{ab:alp4iot:collection,abdv:aamas:collection,abdv:coord:collection}.
These papers all show that, though
self-stabilizing, these algorithms can give rise to large transient overestimates with potentially negative consequences.
For example, if the goal is collect the net resources in a network of devices, then overestimates, however fleeting, may cause a leader to commit to more tasks than is feasible.
For the example of a line graph, we showed in \cite{zainab:ecas} that collection can give overestimates that are quadratic in the network diameter. This is observed in face of a particular source switch after stabilization has occurred. We presented the notion of monotonic filtering as a potential amelioration. This technique prevents collection across devices whose distance towards a source or collector device is decreasing. With line graphs, \cite{zainab:ecas} showed that monotonic filtering prevents quadratic overestimates. In this paper, we analyze monotonic filtering for general graphs and the demonstrate that there are no quadratic overestimates in collection during the transient phase following a source switch. Rather, for an $ N $-device network the largest overestimate is at most $ 2N $.
Section \ref{sprel} gives preliminaries and Section \ref{sdist} provides results on distance estimates that are used to execute monononic filtering. Section \ref{smon} defines monotonic filtering.
Section \ref{sanalysis}, proves the main result. Section \ref{ssim} gives simulations. Section \ref{sconc} concludes.
\
\section{Preliminaries} \label{sprel}
We model a network of devices as an undirected graph $ G=(V,E) $, with $ V=\{0,\cdots, N-1\} $ being the set of devices that are the nodes in the graph and $ E $ being the edge set of connections between devices. We assume that device $ i\in V $ carries the value $ v_i $, and that there is a designated {\em source} set of nodes $ S(t)\subset V $. The goal is to aggregate the accumulation of the values $ v_i $ at the source set, i.e., generate accumulates $ a_i $ such that
\[ \sum_{i\in S}a_i=\sum_{i\in V}v_i.
\]
In particular, if there is only one source, then its accumulate should be the sum of all of the $ v_i $.
This is a special case of the data collection block (C-block) of \cite{vabdp:selfstabilisation}.
\subsection{The Basic Approach}\label{sbasic}
There are many ways to achieve this objective depending on the circumstances \cite{liu:pruteanu:dulman:gradient,adv:bisgradient,abdv:aamas:collection,abdv:coord:collection}. In this paper, we adaptively determine a spanning tree and accumulate values from children to parents. The spanning tree is determined by the \emph{Adaptive Bellman-Ford} (ABF) algorithm \cite{vabdp:selfstabilisation,mo:abf:stability} a special case of what is called a $ G $-block in
\cite{vabdp:selfstabilisation}; ABF estimates distances. Two nodes are neighbors if they share an edge. Define edge length between any two neighbors to be 1 and $ {\cal N}(i) $ to be the set of neighbors of $ i $.
Then with $ \hat{d}_i(t) $ the distance and $ S $ the source set, ABF proceeds as
\begin{align}\label{eq:distance:estimates}
\hat{d}_i(t) &=
\begin{cases}
0 & \textit{if } i \in S(t) \\
\min_{j\in {\cal N}(i)}\{ \hat{d}_j(t-1)+1\} & \mbox{otherwise}
\end{cases}.
\end{align}
The minimizing $ j $ in the second bullet is called a current constraining or simply, constraining node, of $ i $. More precisely the constraining node $ c_i(t) $ obeys:
\begin{align}
c_i(t) &= \label{eq:constraining:nodes:initial}
\begin{cases}
i & \textit{if } i \in S(t) \\
\underset{j\in {\cal N}(i)}{\mbox{argmin}} \{ \hat{d}_j(t-1)+e_{ji} \} \quad~~\, & \mbox{otherwise} \\
\end{cases}.
\end{align}
These constraining nodes set up the spanning tree: The set of children of $ i $ are the nodes they constrain:
\begin{align*}\numberthis{}\label{eq:set:of:constraining:nodes}
C_i(t)=\{j |~ c_j(t-1)=i\}.
\end{align*}
Then in keeping with the strategy outlined at the beginning of this section, we can update the accumulate at node $ i $ through the recursion:
\begin{align*}\numberthis{}\label{eq:accumulated:values}
a_i(t)=\sum_{j\in C_i(t)}a_j(t-1)+v_i.
\end{align*}
\subsection{Quadratic Overestimates}\label{squad}
\begin{figure}[htb]
\centering
\includegraphics[width=\linewidth]{Untitled.png}
\caption{Representation of an $N$-node line graph ($N$-line) with a source switch from time $t=0$ to $t=1$.}\label{fig:oline:graph}
\end{figure}
From \cite{mo:abf:stability}, one knows that ABF is self-stabilizing. This means in particular that both $ c_i(t) $ and $ C_i(t) $ must acquire steady state values and thus the recursion (\ref{eq:accumulated:values}) must also converge. For example, consider the line graph in Figure \ref{fig:oline:graph}. Suppose the source is the rightmost node with index $ N-1 $, and the nodes to the left of 0 are indexed in sequence as $ 1,\cdots, N-1. $
Assume that
\begin{equation}\label{eijvi}
v_i=1 ~\forall ~i\in V,
\end{equation}
i.e., all values are 1 and distances are hop lengths.
Then at steady state
one has
\begin{equation}\label{steady}
\hat{d}_i(t)=N-1-i \mbox{ and } a_i=i+1.
\end{equation}
Now suppose these values have been acquired at $ t=0 $, but the source switches from $ N-1 $ to zero at $ t=1 $. Then the following theorem from \cite{zainab:ecas} shows that \emph{en route} to self-stabilization $ a_i(t) $ suffer from quadratic overestimates in the transient phase.
\begin{theorem}\label{the:one}
Consider the line graph in Figure \ref{fig:oline:graph}, with (\ref{eijvi}) in force. Suppose at $ t=0 $ $ a_i(0) $ and $ \hat{d}_i(0) $ are as in (\ref{steady}). Suppose for all $ t\geq 1 $, $ S(t)=\{0\} $. Then under (\ref{eq:distance:estimates}) and (\ref{eq:accumulated:values}), the maximum partial accumulate $a_i(t)$ reached by the source is obtained at time $t=2N-2$ and is:
\begin{equation} \notag
a_0(2N-2) = \left\lceil \frac{N-1}{2} \right\rceil N + N - 1 \ge \frac{N(N+1)}{2} - 1
\end{equation}
before reaching the correct value at time $t = 2N-1$ i.e.,
\begin{equation}
a_0(2N-1)=N
\end{equation}
\end{theorem}
\subsection{Monotonic Filtering}\label{smon}
Monotonic filtering was proposed in \cite{zainab:ecas} as a remedy for such quadratic overestimation. Specifically, this device permits only a subset of the nodes that $ i $ constrains to be a valid children: only those $ c_i(t) $ whose distance estimate in the previous iteration was one more than $ \hat{d}_i(t) $ are allowed to be children. Thus the set of children in (\ref{eq:set:of:constraining:nodes}) is replaced by
\begin{align}
C_i(t) = \{j| i=c_j(t-1) \wedge \hat{d}_j(t-1)
=\hat{d}_i(t)+1\}.\label{eq:improved:C}
\end{align}
Neither the definition of constraining nodes, nor the underlying accumulation equation changes. The latter in particular remains as (\ref{eq:accumulated:values}). It should be noted that the self-stabilizing nature of ABF, per \cite{mo:abf:stability}, ensures that all distance estimates converge to their correct values. In such a steady state, under (\ref{eijvi}), every node that constrains another automatically satisfies the restriction on distance estimates given in (\ref{eq:improved:C}).
As proved in \cite{zainab:ecas}, this additional restriction is all that is needed to remove any overestimate from happening in a line graph. In this paper we show that this amelioration persists for general undirected graphs. The next subsection describes the analytical framework.
\subsection{Definitions and Assumptions}\label{ssetting}
We now make some definitions to set up the assumptions that underlie our analysis of monotonic filtering. Suppose $ d_i $ is the hop count of $ i $ from the source set $ S $. Then from Bellman's Principle of Optimality it obeys
\begin{equation}\label{eq:true:dist:2}
\begin{cases}
d_i= 0 & i\in S\\
\min_{j\in {\cal N}(i)} d_j+1 & \mbox{ otherwise }
\end{cases}.
\end{equation}
This leads to the definition of a \emph{true constraining node.}
\begin{definition}[True constraining node]\label{def:constraining:nodes}
A $k$ that minimizes the right hand side of (\ref{eq:true:dist:2}) is
a true constraining node of $i$. As there may be two
neighbors $j$ and $k$ of $ i $ such that $d_j =d_k$, a node may have
multiple true constraining nodes while the true constraining node of a source is itself.
\end{definition}
We now define the notion of {\em effective diameter} introduced in \cite{mo:abf:stability}.
\begin{definition}[Effective Diameter]\label{def:def1} Consider a sequence of nodes in a graph such that each node is a true constraining node of its successor. The effective diameter D is defined as the longest length such a sequence can have in the graph.
\end{definition}
Thus, if (\ref{eijvi}) holds then the effective diameter is
\[ 1+\max_{i\in V}d_{i}. \]
We also define some important sets that are critical for our analysis.
\begin{definition}\label{dF}
Define $ d_{ij} $ to be the minimum distance between nodes $ i $ and $ j. $ Further define $ {\cal F}_k(m) $ to be the set of nodes whose minimum distance from node $ k $ is $ m $, i.e.,
\[ {\cal F}_k(m)=\{i ~|~ d_{ik}=m\}. \]
\end{definition}
If a graph $G=(V,E)$ has an effective diameter $D$ with a single source node $ 0, $ then as depicted in Figure \ref{fig:general:graph} there is a sequence of nodes, without loss of generality $i=0,1,\ldots D-1$, such that node $i$ is the true constraining node of node $i+1$. Henceforth we assume the graph is as depicted in this figure. In fact, the following assumption holds.
\begin{figure}[htb]
\centering
\includegraphics[width=\linewidth]{G_graph.pdf}
\caption{Arbitrary graph $G$ with a sequence highlighted.} \label{fig:general:graph}
\end{figure}
\begin{assumption}\label{ass:assumption1}
The graph $ G=(V,E) $, is as in Figure \ref{fig:general:graph}. Further (\ref{eijvi}) holds and the shortest path from $ 0 $ to $ D-1 $ has $ D $ hops.
The algorithm used is defined by (\ref{eq:distance:estimates}, \ref{eq:constraining:nodes:initial}, \ref{eq:improved:C}).
For $ t\leq 0 $, $ D-1 $ is the source, and for $ t> 0 $, $ 0 $ is the source. Further $\hat{d}_i(0)$ and $ a_i(0) $ are steady state values of the algorithm assuming $ D-1 $ is the source. In particular,
\begin{equation}\label{initdhat}
\hat{d}_i(0)=m, ~\forall~i\in {\cal F}_{D-1}(m).
\end{equation}
Also, for every integer $ m $
\begin{equation}\label{samelevel}
\sum_{i \in {\cal F}_{D-1}(m)} a_i(0)\leq N.
\end{equation}
Further, the effective diameter when $ 0 $ is the only source is $ D $; when $ D-1 $ is the source, the effective diameter is $D_0$.
\end{assumption}
Observe that $ D_0\geq D. $ Also note that (\ref{samelevel}) is a trivial consequence of the steady values generated by (\ref{eq:accumulated:values}) and the fact that for all $ i $, $ v_i=1 $.
\section{Evolution of distance estimates}\label{sdist}
To understand the behavior of the accumulates after the source switch, one must first understand how distance estimates evolve subsequent to the switch.
To this end we have the following preparatory lemma describing the true distances of neighbors from the old and new source,
using Assumption \ref{ass:assumption1}, which ensures that all distances are hop lengths.
\begin{lemma}\label{lneighbor}
Suppose Assumption \ref{ass:assumption1} holds, $ D>2 $, and $ {\cal F}_k(m) $ are as in Definition \ref{dF}. (i) Then for all $ k\in V $, $ 0< m\leq D-1 $ and $ i\in {\cal F}_k(m) $ all neighbors of $ i $ are in $ {\cal F}_k(m-1) \bigcup {\cal F}_k(m) \bigcup{\cal F}_0(m+1) $. If $ {\cal F}_k(m)\neq \emptyset $, $ i $ has at least one neighbor in $ {\cal F}_0(m-1) $.
(ii) Moreover, $ 0 $ and $ D-1 $ are not neighbors.
\end{lemma}
\begin{proof}
Suppose for some $ 0< m< D-1 $ and $ \ell \notin \{m-1,m,m+1\} $, $ i\in {\cal F}_k(m) $ has a neighbor in $ {\cal F}_k(\ell) $. If $ \ell <m-1 $ then $ i\in {\cal F}_k(\ell+1) \neq {\cal F}_0(m), $ establishing a contradiction. Similarly, if $ \ell >m+1 $ then $ i\in {\cal F}_k(\ell-1) \neq {\cal F}_0(m), $ again establishing a contradiction.
Further, the fact that $ i $ must have at least one neighbor in each of the sets $ {\cal F}_j(m-1) $ follows from the fact that the graph is connected. That all neighbors of $ 0 $ and $ D-1 $ are in $ {\cal F}_0(1) $ and $ {\cal F}_{D-1}(1) $, respectively, follows similarly. As $ D>1 $, $ 0 $ and $ D-1 $ cannot be neighbors.
\end{proof}
We now provide a lemma that describes the evolution of distance estimates for $ t>0. $ To this end, we partition $ V $ into three sets ${\cal I}_i(t)$ for $i=0,1,2$. $ {\cal I}_0(t)$ comprises nodes that are less than $ t $ hops away from $ 0 $. In particular,
the distance estimates at these nodes have converged to their true distances from $ 0 $. The set $ {\cal I}_1(t)$ comprises nodes that are not in $ I_0(t) $ but have felt the effect of a change in source. The set $ {\cal I}_2(t) $ consists of the remaining nodes, whose distance estimates and accumulates are identical to what they were at $ t=0. $
\begin{lemma}\label{ldist}
Suppose Assumption \ref{ass:assumption1} holds and $ D>2 $.
For all $ t\geq 1 $ consider the following partitioning of $ V $:
\begin{equation}\label{I0}
{\cal I}_0(t)=\bigcup_{m=0}^{t-1}{\cal F}_0(m),
\end{equation}
\begin{equation}\label{I1}
{\cal I}_1(t)=\left (\bigcup_{m=0}^{t-1}{\cal F}_{D-1}(m)\right )\setminus {\cal I}_0(t)
\end{equation}
and
\begin{equation}\label{I2}
{\cal I}_2(t)=V\setminus \{{\cal I}_0(t)\cup {\cal I}_1(t)\},
\end{equation}
of $ V $.
Then under (\ref{eq:distance:estimates},\ref{eq:constraining:nodes:initial}), the following hold.
\begin{equation}\label{nearest}
\hat{d}_i (t)=m ~\forall~i\in {\cal F}_0 (m)\mbox{ and } 0\leq m<t,
\end{equation}
\begin{equation}\label{middle}
\hat{d}_i (t)=m ~\forall~i\in {\cal F}_{D-1} (m)\bigcap {\cal I}_2(t).
\end{equation}
and
\begin{equation}\label{furthest}
\hat{d}_i(t)\in \{t,t+1\} ~\forall~i\in {\cal I}_1(t).
\end{equation}
\end{lemma}
\begin{proof}
Use induction on $ t $ to prove (\ref{nearest})-(\ref{middle}). As $ 0 $ becomes the only source at $ t=0 $, $ \hat{d}_0(1)=0 $ verifying (\ref{nearest}).
From Lemma \ref{lneighbor}, 0 is not a neighbor of $ D-1 $ and $ {\cal N}(D-1)={\cal F}_{D-1}(1)$. Thus from Assumption \ref{ass:assumption1}, $ \hat{d}_i(0)=1 $ for all $ i\in {\cal N}(D-1) $. Thus
$ \hat{d}_{D-1}(1)=2, $ verifying (\ref{furthest}).
As $ {\cal I}_0(1)=\{0\}={\cal F}_0(0) $ and
$ {\cal I}_1(1)=\{D-1\}={\cal F}_{D-1}(0) $, $ {\cal I}_2(1)=V\setminus \{0,D-1\}. $ Thus
\begin{equation}\label{key}
{\cal I}_2(1)=\left (\bigcup_{m=1}^{D_1-1}{\cal F}_{D-1}(m)\right )\setminus \{0\}.
\end{equation}
From Assumption \ref{ass:assumption1}, $ \hat{d}_i(0)=m $ for all $ i\in {\cal F}_{D-1}(m) $. Thus from (\ref{eq:distance:estimates},\ref{eq:constraining:nodes:initial}), (\ref{middle}) holds.
Now suppose the result holds for some $ t=T \geq 1. $
By the induction hypothesis for
\begin{equation}\label{2T-1nearest}
\hat{d}_i(T)=m<T ~\forall~i\in {\cal F}_0 (m)\mbox{ and } 1\leq m<T.
\end{equation}
Further
\begin{equation}\label{2T-1midd}
\hat{d}_i(T)=m ~\forall~ i\in {\cal F}_{D-1} (m)\bigcap{\cal I}_2(T).
\end{equation}
Lastly
\begin{equation}\label{2T-1furthest}
\hat{d}_i(T)\in \{T,T+1\} ~\forall~ i\in {\cal I}_1(T).
\end{equation}
\vspace{2mm}
\noindent
{\bf Proof of (\ref{nearest}):}
Suppose now $$ i\in {\cal I}_0(T+1)=\bigcup_{m=0}^T {\cal F}_0(m), $$ in particular for some $ 0\leq m\leq T $, $ i\in {\cal F}_0(m). $ From (i) of Lemma \ref{lneighbor},
\[ {\cal N}(i)\subset \bigcup_{k=m-1}^{m+1}{\cal F}_0(k) \]
with at least one $ j\in {\cal N}(i)\bigcap {\cal F}_0(m-1). $ From (\ref{2T-1nearest}), $ \hat{d}_j(T)=m-1. $ Thus $ \hat{d}_j(T+1)\leq m. $ To establish a contradiction, suppose for some other $ n\in {\cal N}(i) $,
\begin{equation}\label{ncontra}
\hat{d}_n(T)<m-1\leq T-1.
\end{equation}
From (\ref{2T-1furthest}), $ n\notin {\cal I}_1(T) $.
Further, from (i) of Lemma \ref{lneighbor}, $ n\notin {\cal F}_0(\ell) $, for $ \ell<m-1. $ Thus from (\ref{2T-1nearest}), $ n\notin {\cal I}_0(T) $ and
$ n $ must be in $ {\cal I}_2(T). $ From (\ref{middle})
\[ \hat{d}_n(T)=d_{n,D-1}\geq T \]
violating (\ref{ncontra}). Thus $ \min_{k\in {\cal N}(i)}\{\hat{d}_k(T)\}=m-1 $ and from (\ref{eq:distance:estimates},\ref{eq:constraining:nodes:initial}), $ \hat{d}_i(T+1)=m $, proving (\ref{nearest}).
\vspace{2mm}
\noindent
{\bf Proof of (\ref{furthest}):}
Now consider
\begin{equation}\label{indI1}
i\in {\cal I}_1(T+1)=\left (\bigcup_{m=0}^{T}{\cal F}_{D-1}(m)\right )\setminus {\cal I}_0(T+1).
\end{equation}
To establish a contradiction, first assume that $ \hat{d}_i(T+1)>T+2. $ This implies
\[ \min_{k\in {\cal N}(i)}\{\hat{d}_k(T)\}>T+1. \]
From (\ref{2T-1midd}), no neighbor of $ i $ is in $ {\cal I}_1(T) $.
As from
(i) of Lemma \ref{lneighbor} and (\ref{indI1}), $ i $ must have at least one neighbor in
\[ \bigcup_{m=0}^{T-1} {\cal F}_{D-1}(m), \]
Because of (\ref{furthest}) and (\ref{I2}) any
\[j\in {\cal N}(i) \bigcap \left \{\bigcup_{m=0}^{T-1} {\cal F}_{D-1}(m)\right \}\]
must be in $ {\cal I}_0(T) $ and additionally $ \hat{d}_j(T)>T+1 $. This violates (\ref{nearest}), i.e., the upper bound of (\ref{furthest}) holds.
Thus, to prove (\ref{furthest}) for $ t=T+1 $ we need to show that
\begin{equation}\label{1minbd}
\hat{d}_i(T+1)\geq T.
\end{equation}
To establish a contradiction suppose (\ref{1minbd}) is false. Then
\begin{equation}\label{thereexists}
\exists ~j\in{\cal N}(i) \mbox{ such that } \hat{d}_j(T)<T.
\end{equation}
In view of (\ref{2T-1furthest}), $ j\notin {\cal I}_1(T) $.
Thus suppose $ j\in{\cal I}_0(T) $. Then because of (\ref{nearest}), $ j\in {\cal F}_0(\ell) $ for some $ \ell<T. $ As $ i\in {\cal N}(j) $ this means $ i\in {\cal F}_0(m) $ for some $ m\leq T. $ Thus from (\ref{I0}), $ i\in {\cal I}_0(T+1) $. From (\ref{I1}), $ i\notin {\cal I}_1(T+1)$, establishing a contradiction.
Thus $ j\in {\cal I}_2(T). $ From (\ref{I2}), for some $ m\geq T $,
$ j\in {\cal F}_{D-1}(m)\bigcap{\cal I}_2(T). $ Thus from (\ref{2T-1midd}), $ \hat{d}_j(T)\geq T $, violating (\ref{thereexists}). Thus (\ref{furthest}) holds for $ t=T+1. $
\vspace{2mm}
\noindent
{\bf Proof of (\ref{middle}):}
Finally consider $ i\in {\cal I}_2(T+1) $, i.e., from
(\ref{I1}, \ref{I2})
\begin{equation}\label{2indI}
i\in {\cal F}_{D-1}(m), \mbox{ for some } m>T.
\end{equation}
From (i) of Lemma \ref{lneighbor} there exists
\begin{equation}\label{jnew}
j\in {\cal N}(i)\bigcap {\cal F}_{D-1}(m-1).
\end{equation}
As $ m-1>T-1 $, from (\ref{I1}) $ j\notin {\cal I}_1(T) $. Suppose $ j\in {\cal I}_0(T) $, then from (\ref{2T-1nearest})
\[
\hat{d}_j(T) \leq T-1<m-1. \]
If $ j\in {\cal I}_2(T) $, then from (\ref{2T-1midd}) $ \hat{d}_j(T)=m-1 $. Thus
$ \hat{d}_i(T+1)\leq m. $
Thus the violation of (\ref{middle}) implies
\begin{equation}\label{2contra}
\hat{d}_j(T)<m.
\end{equation}
Then we assert that
\begin{equation}\label{notI0}
j\notin {\cal I}_0(T).
\end{equation}
To establish a contradiction, suppose (\ref{2contra}) holds but (\ref{notI0}) does not.
Then from (\ref{2T-1nearest}), $ j\in {\cal F}_0(\ell) $ for some
$ \ell<T. $ As $ i\in{\cal N}(j) $ from (i) of Lemma \ref{lneighbor}, $ i\in {\cal F}_0(k) $, with $ k\leq T $, i.e., $ i\in {\cal I}_0(T+1) $. This leads to a contradiction as $ {\cal I}_1(T+1) $ and $ {\cal I}_0(T+1) $ and $ i\in{\cal I}_1(T+1) $ are disjoint.bThus (\ref{notI0}) holds. Consequently, $ j\in {\cal I}_2(T) $ and $ \hat{d}_j(T)=m-1 $ and
$ \hat{d}_i(T+1)= m $, proving (\ref{middle}).
\end{proof}
\section{Accumulates Under Monotonic Filtering} \label{sanalysis}
We now compute the partial accumulates under the new definition of children given in (\ref{eq:improved:C}), using the distance estimates characterized in Lemma \ref{ldist}, and the evolution of accumulates defined in (\ref{eq:accumulated:values}). The added constraint in (\ref{eq:improved:C}), which intuitively ensures that data is collected by always descending distances, is satisfied by every node in a stable state; however, it may not be satisfied during transients. We will show that monotonic filtering suffices to eliminate quadratic overestimates in a general graph.
We consider the partial accumulates in each of our partitioned sets individually. The following lemma characterizes the accumulates in ${\cal I}_1(t)$.
\begin{lemma}\label{lem:a_i at I_1}
Under Assumption \ref{ass:assumption1}, the partial accumulates in ${\cal I}_1(t)$ defined in (\ref{I1}), obey
\begin{equation}\label{eq:lem4}
a_i(t)=1 \text{ }\forall \text{ } i \in {\cal I}_1(t)
\end{equation}
\end{lemma}
\begin{proof}
Our new definition of the set $C_i(t)$ given in (\ref{eq:improved:C}) requires that $C_i(t)$ accept a node $j\in {\cal N}(i)$ only if $\hat{d}_j(t-1)=\hat{d}_i(t)+1$.
%
The partial accumulates are given in (\ref{eq:accumulated:values}) with $v_i=1$ as
\begin{equation}\label{eq:ais_improvedC}
a_i(t)=\sum_{j \in C_i(t)} a_j(t-1)+1
\end{equation}
To prove (\ref{eq:lem4}), we need to show that $C_i(t) = \emptyset$ for all $i \in {\cal I}_1(t)$. To prove this, it suffices to show that $\hat{d}_j(t-1)\neq \hat{d}_i(t)+1$ for all $j \in {\cal N}(i).$
From (\ref{furthest}) in Lemma \ref{ldist}, we know that the distance estimates for nodes in $i \in {\cal I}_1(t)$ satisfy
\begin{equation}\label{eq:lem4proof1}
\hat{d}_i(t)+1 \in \{t+1,t+2\}
\end{equation}
Thus, if $\hat{d}_j(t-1) \notin \{t+1,t+2\}$, then $j \notin C_i(t)$. Consider cases depending on whether a neighbour $j \in {\cal N}(i)$ is in sets ${\cal I}_0(t-1)$, ${\cal I}_1(t-1)$ and ${\cal I}_2(t-1)$.
\textbf{Case I $ j \in {\cal I}_1(t-1) $:} Then $\hat{d}_j(t-1)\in \{t-1,t\} \notin \{t+1,t+2\}$ from (\ref{furthest}) in Lemma \ref{ldist}. Hence $j \notin C_i(t)$.
\textbf{Case II $ j \in {\cal I}_0(t-1) $:} Then $\hat{d}_j(t-1)= d_{0j} \notin \{t+1,t+2\}$ as $0 \leq d_{0j} <t-1$ from (\ref{nearest}) in Lemma \ref{ldist}. Hence $j \notin C_i(t)$.
\textbf{Case III $ j \in {\cal I}_2(t-1) $:} The nodes contained in the set ${\cal I}_2(t-1)$ are given by (\ref{I2}), that is:
\begin{equation}\label{eq:lem4c31}
{\cal I}_2(t-1)= V \setminus \{{\cal I}_0(t-1) \cup {\cal I}_1(t-1)\}
\end{equation}
The distance estimates for these nodes from Lemma \ref{ldist} and (\ref{middle}) are as follows:
\begin{equation}\label{eq:lem4case31}
\hat{d}_j(t-1) = d_{D-1, j}.
\end{equation}
As $i \in {\cal I}_1(t)$, then $d_{D-1, i} \le t-1$ by (\ref{I1}). For $j$ to be a neighbor of a node in set ${\cal I}_1(t)$, $d_{D-1, j} \leq d_{D-1, i}+1 \leq t$ must hold. But $t \notin \{t+1,t+2\}$ and hence $j \notin C_i(t)$ concluding the proof.
\end{proof}
To characterize the accumulates of nodes in ${\cal I}_0(t)$, we need information on how accumulates evolve in the neighboring nodes that are part of the set ${\cal I}_2(t)$. The following lemma gives an upper bound on that.
\begin{lemma}\label{lem:lem5:distI0nI2}
Under Assumption \ref{ass:assumption1}, nodes $j \in C_i(t) \bigcap {\cal I}_2(t) $ for all $i \in {\cal I}_0(t)$ obey:
\begin{equation}\label{eq:lem5dist}
\sum_{i \in {\cal I}_0(t)} \sum_{j \in C_i(t) \bigcap {\cal I}_2(t) } a_j(t-1) \leq N
\end{equation}
\end{lemma}
\begin{proof}
Suppose $ i\in {\cal I}_0(t) $ has a neighbor $ j\in {\cal I}_2(t). $ Then $ d_{j,0}\geq t. $ Thus from Lemma \ref{lneighbor}, $ d_{i,0}=t-1 $. From Lemma \ref{ldist}, $ \hat{d}_i(t)=t-1 $. Thus,
\[ \hat{d}_j(t)=t-1+1=t, \forall i \in {\cal I}_0(t) \mbox{ and } j \in C_i(t) \bigcap {\cal I}_2(t). \]
Thus from Lemma \ref{ldist} all such $ j $ have the same distance from $ D-1. $ As accumulates at these $ j $ are the value they had at the steady state at $ t=0 $, the result follows from (\ref{samelevel}).
\end{proof}
Given the information regarding neighbors of ${\cal I}_0(t)$ in other sets, we can now characterize the accumulates in ${\cal I}_0(t)$ according to the following lemma.
\begin{lemma}\label{lem:a_i at I_0}
Under Assumption \ref{ass:assumption1}, the partial accumulates at nodes in the set ${\cal I}_0(t)$ obey
\begin{equation}\label{eq:lem5}
a_i(t) \leq 2N \text{ }\forall \text{ } i \in {\cal I}_0(t)
\end{equation}
\end{lemma}
\begin{proof}
The result holds for all $ t>0 $, if the sum of all partial accumulates at a given distance $ x < t$ from new source node $0$ is bounded by the following,
\begin{equation}\label{eq:lem6prop}
\sum_{i \in {\cal F}_0(x)} a_i(t) \leq N + \sum_{y=x}^{D-1} |{\cal F}_0(y)|.
\end{equation}
We prove (\ref{eq:lem6prop}) by induction on decreasing $x$.
To initiate the induction, for any consider $x = t-1$ and $ x=t-2 $ in the latter case provided $ t\geq 2. $
We know from (\ref{eq:accumulated:values}) that
\begin{equation}\label{eq:lem6indhyp1}
a_i(t)= \sum_{j \in C_i(t)} a_j(t-1)+1
\end{equation}
Then taking a sum on the left hand side of (\ref{eq:lem6prop}), we have
\begin{align}
\sum_{i \in {\cal F}_0(x)}a_i(t)= \sum_{i \in {\cal F}_0(x)}\left ( \sum_{j \in C_i(t)} a_j(t-1)+1 \right )\label{eq:lem6indhypess}\\
= \sum_{i \in {\cal F}_0(x)} \sum_{j \in C_i(t)} a_j(t-1)+|{\cal F}_0(x)|\label{eq:lem6indhypess1}
\end{align}
Since $x = t-1$ or $t-2$, $j \in C_i(t)$ cannot be in ${\cal I}_0(t-1)$. If $j \in C_i(t)$ are in ${\cal I}_2(t-1)$ then from Lemma \ref{lem:lem5:distI0nI2}
\begin{align*}
\sum_{i \in {\cal F}_0(x)} \sum_{j \in C_i(t) \bigcap {\cal I}_2(t-1)} a_j(t-1) \\
\leq \sum_{i \in {\cal I}_0(t)} \sum_{j \in C_i(t) \bigcap {\cal I}_2(t-1) } a_j(t-1) \leq N
\end{align*}
The contribution from ${\cal I}_1(t-1)$ excludes all nodes from ${\cal I}_0(t-1)$, and everything that is a distance $t-1$ or less away from source node $0$ is in ${\cal I}_0(t-1)$. It follows that the total contribution from nodes in ${\cal I}_1(t-1)$ must be
\begin{equation}\label{eq:lem6:jinI1}
\sum_{i \in {\cal F}_0(x)} \sum_{j \in C_i(t) \bigcap {\cal I}_1(t-1)} \!\! a_j(t-1) \leq \sum_{y=x+1}^{D-1} |{\cal F}_0(y)|.
\end{equation}
Thus (\ref{eq:lem6indhypess1}) simplifies to
\begin{align*}\label{eq:lem6indhypess121}\numberthis
\sum_{i \in {\cal F}_0(x)}a_i(t) \leq N+\sum_{y=x+1}^{D-1} |{\cal F}_0(y)| + |{\cal F}_0(x)| \\
\leq N+\sum_{y=x}^{D-1} |{\cal F}_0(y)|.
\end{align*}
Now suppose (\ref{eq:lem6prop}) holds for all $ t \geq 3 $.
For all other $x<t-3$ for any $t$, the set $C_i(t) \subseteq {\cal F}_0(x+1) \subseteq {\cal I}_0(t-1)$). The double sum in (\ref{eq:lem6indhypess1}) simplifies to
\begin{equation}\label{eq:lem6simp}
\sum_{i \in {\cal F}_0(x)} \sum_{j \in C_i(t)} a_j(t-1) = \sum_{j \in {\cal F}_0(x+1)} a_j(t-1)
\end{equation}
The inductive hypothesis in (\ref{eq:lem6prop}) can be applied directly to (\ref{eq:lem6simp}) in (\ref{eq:lem6indhypess1}) as
\begin{align*}\label{eq:lem6:t2}\numberthis
\sum_{i \in {\cal F}_0(x)}a_i(t)= \sum_{j \in {\cal F}_0(x+1)} a_j(t-1)+|{\cal F}_0(x)| \\
\leq N + \sum_{y=x+1}^{D-1} |{\cal F}_0(y)| +|{\cal F}_0(x)|.
\end{align*}
Then the following holds
\begin{equation}\label{eq:lem6inhypcase322ineq}
\sum_{i \in {\cal F}_0(x)}a_i(t) \leq N + \sum_{y=x}^{D-1} |{\cal F}_0(y)|
\end{equation}
completing the proof of (\ref{eq:lem6prop}).
\end{proof}
We now have the main result.
\begin{theorem}\label{the:1}
In a general graph, with monotonic filtering the partial accumulations $a_i(t)$ in sets ${\cal I}_0(t)$, ${\cal I}_1(t)$ and ${\cal I}_2(t)$ for any time $t$, have an upper bound that is given as:
\begin{equation}\label{eq:th:11}
a_i(t) \leq 2N \text{ } \forall \text{ } i \in {\cal I}_0(t)
\end{equation}
\begin{equation}\label{eq:th:12}
a_i(t) =1 \text{ } \forall \text{ } i \in {\cal I}_1(t)
\end{equation}
and
\begin{equation}\label{eq:th:13}
a_i(t) \leq N \text{ } \forall \text{ } i \in {\cal I}_2(t)
\end{equation}
\end{theorem}
\begin{proof}
The first two expressions follow directly from lemma \ref{lem:a_i at I_0} and \ref{lem:a_i at I_1} respectively.
The proof of (\ref{eq:th:13}) is trivial as nodes in the set ${\cal I}_2(t)$ have not been affected yet by the source switch. They maintain partial accumulate values attained at the previous steady state, and these values never exceed $N$, the total number of nodes in the graph.
\end{proof}
\section{Simulation}\label{ssim}
In order to evaluate the performance of monotonic filtering in a more general setting, we simulated a network of 100 to 1000 nodes, randomly displaced in a square, with a connection range such that the average number of neighbours per node is about 10. We performed 1000 simulations and averaged the results. The simulation is publicly available online.\footnote{https://github.com/Harniver/monotonic-filtering-dynamics}
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth]{screenshot.jpg}
\caption{Simulation of collection algorithms on a random bidimensional arrangement. Colors of nodes are tuned from red (estimate 1) to magenta (correct estimate) to black (infinitely large estimate); and the central color corresponds to the basic approach while the color of the sides corresponds to monotonic filtering. The screenshot is taken during a transient recovery, in which the source (big square) has a very large overestimate with the basic approach (black central color) while it is almost correct with monotonic filtering (magenta sides).}
\label{fig:screenshot}
\end{figure}
\begin{figure*}[h]tb
\centering
\includegraphics[width=0.49\linewidth]{batch-timcoll-spe0dev100.pdf}
\includegraphics[width=0.49\linewidth]{batch-timcoll-spe0dev1000.pdf}
\\[5pt]
\includegraphics[width=0.49\linewidth]{batch-timcoll-spe1dev100.pdf}
\includegraphics[width=0.49\linewidth]{batch-timcoll-spe1dev1000.pdf}
\\[5pt]
\includegraphics[width=0.49\linewidth]{batch-timcoll-spe2dev100.pdf}
\includegraphics[width=0.49\linewidth]{batch-timcoll-spe2dev1000.pdf}
\\[5pt]
\includegraphics[scale=1.5]{batch-legenda.pdf}
\caption{Average collection results (counting device number) in source nodes over simulated time, where the source is periodically switching to different devices (at times matching the periodic spikes). The lines correspond to the number of devices (\emph{ideal}, in red), to the basic approach (\emph{simple}, in blue), and to monotonic filtering (\emph{filtered}, in green). The basic approach suffers from significant overestimates at every source change, while monotonic filtering provides underestimates instead. In mobile networks (\emph{speed} greater than zero) with a sufficient number of devices, the underestimates given by monotonic filtering become systematic, while the basic approach is still able to reach a reasonably correct value.}
\label{fig:plots}
\end{figure*}
A sample screenshot of the simulation is depicted in Figure \ref{fig:screenshot}, while synthetic plots of the average collection results in source nodes are given in Figure \ref{fig:plots}.
When the position of the nodes is fixed (\emph{speed} is zero), monotonic filtering can prevent any overestimate from occurring.
The estimate still converges to the correct result as fast as with the basic approach, which instead suffers from high peaks during reconfiguration. When nodes are steadily moving (\emph{speed} is positive), both algorithms start underestimating the true count as the speed increases and number of devices increase. However, the underestimates are much more pronounced with monotonic filtering, while the basic approach is able to tolerate small speeds.
\section{Conclusion}\label{sconc}
In this paper, we investigated the effect of a monotonic filtering condition on the transient values of a single-path collection algorithm during recovery from a source switch. In a static graph, the monotonic filtering condition is proved to bound overestimates to at most $2N$, while single-path collection without it is showed to reach quadratic overestimates in some cases. By evaluating the algorithms in simulation, we show that in practice transient large overestimates do occur without filtering, while no overestimate at all is present with monotonic filtering. Finally, we also simulate the behavior of the algorithms under persistent perturbations, i.e., steady movement of the nodes. In this scenario, both algorithms degrade their quality towards underestimates; however, with monotonic filtering the degradation occurs much sooner, with lower movement speeds and lower number of devices.
In future work, monotonic filtering should be compared with existing strategies \cite{abdv:list:collection}, in its ability to avoid overestimates under persistent perturbations.
\bibliographystyle{IEEEtran}
| {'timestamp': '2021-07-14T02:07:00', 'yymm': '2107', 'arxiv_id': '2107.05791', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05791'} | arxiv |
\section{Acknowledgements}
ZSW, KH, DN, LS were supported in part by the NSF FAI Award \#1939606, NSF SCC Award \#1952085, a Google Faculty Research Award, a J.P. Morgan Faculty Award, a Facebook Research Award, and a Mozilla Research Grant. HH acknowledges support from NSF (\#IIS2040929), J.P. Morgan, CyLab, Meta, and PwC. Any opinions, findings, conclusions, or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation and other funding agencies.
Finally, the authors would like to thank Yonadav Shavit and John Miller for insightful conversations about \citet{shavit2020strategic} and \citet{miller2021outside}, respectively.
\section{Agent Outcome Improvements}\label{sec:agent-outcome}
In the strategic learning setting, the goal of each agent is clear: they aim to achieve the highest prediction $\hat{y}$ possible, regardless of their true label $y$. On the other hand, what the goal should be for the principal is less clear, and depends on the specific setting being considered. For example, in some settings it may be enough to discover the causal relationships between observable features and outcomes. However in other settings, the principal may wish to take a more active role. In particular, when making decisions which have real-world consequences, it may be in the principal's best interest to use a decision rule which promotes desirable behavior \cite{kleinberg2020classifiers, shavit2020strategic, harris2021stateful}, i.e., behavior which has the potential to improve the \emph{actual outcome} of an agent.
In the agent outcome improvement setting, the goal of the principal is to maximize the expected outcome $\mathbb{E}[y]$ of an agent drawn from the agent population. In our college admissions example, this would correspond to deploying an assessment rule with the goal of \emph{maximizing} expected student college GPA. Formally, we aim to find $\boldsymbol{\theta}^{AO}$ in a convex set $\mathcal{S}$ of feasible assessment rules such that the induced expected agent outcome $\mathbb{E}[y]$ is maximized.
After some algebraic manipulation, the optimization becomes $\boldsymbol{\theta}^{AO} = \arg \max_{\boldsymbol{\theta} \in \mathcal{S}} \boldsymbol{\theta}^\top \boldsymbol{\lambda},$
\iffalse
\small
\begin{equation}
\begin{aligned}
\boldsymbol{\theta}^{AO} = \arg \max_{\boldsymbol{\theta} \in \mathcal{S}} \quad & \boldsymbol{\theta}^\top \boldsymbol{\lambda},
\end{aligned}
\label{eq:ao-lp}
\end{equation}
\normalsize
\fi
where $\boldsymbol{\lambda} = \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top]\boldsymbol{\theta}^*$.
For the full derivation, see \Cref{sec:AO-derivation}. Note that while the principal never directly observes $\mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top]$ nor $\boldsymbol{\theta}^*$, they estimate $\boldsymbol{\lambda} = \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top]\boldsymbol{\theta}^*$ during the second stage of the 2SLS procedure. Therefore, if the principal has already run 2SLS to recover a sufficiently accurate estimate of the causal parameters $\boldsymbol{\theta}^*$, they can estimate the agent outcome-maximizing decision rule by solving the above optimization.
\iffalse
While $\boldsymbol{\theta}^{AO}$ is generally not equal to $\boldsymbol{\theta}^*$, one may wonder if the agent improvement from playing $\boldsymbol{\theta}^*$ is ``close to'' the improvement from playing $\boldsymbol{\theta}^{AO}$. The following example shows that this is generally not the case.
\begin{example}
Consider the setting in which $\boldsymbol{\theta}^* = [0.774, 0.633]^\top$, $\mathcal{E}_t = \begin{bmatrix} 3000 & 0\\ 0 & 100\end{bmatrix}$ $\forall t$, and $\|\boldsymbol{\theta}\|_2 \leq 1$. Solving Optimization \ref{eq:ao-lp}, we see that $\boldsymbol{\theta}^{AO} = [1.0, 0.0]^\top$. We can calculate the \emph{expected agent improvement} due to assessment rule $\boldsymbol{\theta}$ as
\begin{equation*}
\mathop{\mathbb{E}}[y_t - y_{t,0}] = \mathop{\mathbb{E}}[\mathbf{x}_t - \mathbf{b}_t]^\top \boldsymbol{\theta}^* = \boldsymbol{\theta}^\top \mathop{\mathbb{E}}[\mathcal{E}_t \mathcal{E}_t^\top] \boldsymbol{\theta}^*,
\end{equation*}
and the \emph{percent improvement} from playing assessment rule $\boldsymbol{\theta}''$ instead of $\boldsymbol{\theta}'$ as
\begin{equation*}
\delta_{\boldsymbol{\theta}', \boldsymbol{\theta}''} = \frac{\mathop{\mathbb{E}}[y_t - y_{t,0}|\boldsymbol{\theta} = \boldsymbol{\theta}''] - \mathop{\mathbb{E}}[y_t - y_{t,0}|\boldsymbol{\theta} = \boldsymbol{\theta}']}{\mathop{\mathbb{E}}[y_t - y_{t,0}|\boldsymbol{\theta} = \boldsymbol{\theta}']} \cdot 100\%.
\end{equation*}
Plugging $\boldsymbol{\theta}' = \boldsymbol{\theta}^*$ and $\boldsymbol{\theta}'' = \boldsymbol{\theta}^{AO}$ into the expression for $\delta_{\boldsymbol{\theta}', \boldsymbol{\theta}''}$, we see that $\boldsymbol{\theta}^{AO}$ is $29\%$ better than $\boldsymbol{\theta}^*$ at incentivizing improvements in agent outcomes in this setting.
\end{example}
\fi
\iffalse
\xhdr{Fairness in the Outcome Improvement Setting}
It is important to note that when there are multiple agent subpopulations which are capable of manipulating their observable features in different ways, $\boldsymbol{\theta}^{AO}$ will generally \emph{not} maximize agent outcomes for all subpopulations. Additionally, when used in setting such as the one considered in Example \ref{ex:2}, $\boldsymbol{\theta}^{AO}$ has the potential to \emph{amplify} existing disparities between subpopulations. (This follows straightforwardly from the derivations in \Cref{sec:AO-derivation}.) However, it may be possible for the principal to optimize for agent outcome improvement while still maintaining the fairness metrics he/she cares about by further constraining Optimization \ref{eq:ao-lp}. (For example, they could maximize agent outcome for the most disadvantaged subpopulation.)
\fi
\iffalse
\khedit{
It is important to note that when there are multiple agent subpopulations which are capable of manipulating their observable features in different ways, $\boldsymbol{\theta}^{AO}$ will generally \emph{not} maximize agent outcomes for each subpopulation individually. Additionally, when used in settings such as the one considered in Section \ref{sec:fairness}, $\boldsymbol{\theta}^{AO}$ has the potential to \emph{amplify} existing disparities between subpopulations. (This follows straightforwardly from the derivations in \Cref{sec:AO-derivation}.) On this note, one may be interested in bounding the expected difference in \emph{true outcomes} $\mathop{\mathbb{E}}_A[y] - \mathop{\mathbb{E}}_{D}[y]$ for the two subpopulations $A$ and $D$ introduced in Section \ref{sec:fairness}. As it turns out, this difference is always non-negative and grows as a function of the number of observable features, number of actions available to the agents, and the minimum weights that $\boldsymbol{\theta}^*$ and $\widehat{\boldsymbol{\theta}}$ place on causally and non-causally relevant features, respectively.
\begin{proposition}\label{thm:dif-y-bound}
The difference between $\mathop{\mathbb{E}}_A[y]$ and $\mathop{\mathbb{E}}_D[y]$ can be lower bounded as
\begin{equation*}
\mathop{\mathbb{E}}_A[y] - \mathop{\mathbb{E}}_D[y] \geq (n - n_C) n_C d \delta \varepsilon_{NC} \varepsilon_C,
\end{equation*}
where $n$ is the number of observable features, $n_C$ is the number of causally-relevant observable features, $d$ is the number of actions each agent can invest effort in, $\delta = \min_{i \not\in \mathcal{C}, j \in \mathcal{C}, k \in \{1, \ldots, d\}} \mathop{\mathbb{E}}_A[w_{ik}w_{jk}] - \mathop{\mathbb{E}}_D[w_{ik}w_{jk}]$, $\varepsilon_C = \min_{i \in \mathcal{C}} \theta_i^*$ is the minimum weight $\boldsymbol{\theta}^*$ places on causally-relevant observable features, and $\varepsilon_{NC} = \min_{i \not\in \mathcal{C}} \widehat{\theta}_i$ is the minimum weight $\widehat{\boldsymbol{\theta}}$ places on observable features which are not causally relevant.
\end{proposition}
See Appendix \ref{sec:dif-y-bound} for the full derivations.
Under this setting, the difference in true outcomes is always non-negative. However, in general it is possible for the principal to optimize for agent outcome improvement while still maintaining the fairness metrics he/she cares about by further constraining Optimization \ref{eq:ao-lp}. (For example, they could maximize agent outcome for the most disadvantaged subpopulation.)
}
\fi
\section{Risk Minimization and Causal Parameter Recovery}\label{sec:algs}
\subsection{Algorithms}
\iffalse
\begin{algorithm}[H]
\label{alg:cpe}
\SetAlgoLined
\textbf{Input:} $T$\\
Play $T$ uniform random decision rules $\{\boldsymbol{\theta}_i\}_{i=1}^T$ where $\boldsymbol{\theta}_i^{(j)} \sim_{iid} \text{Unif}(-1,1)$ for each $i$ and $j$\\
Estimate $\boldsymbol{\theta}^*$ via 2SLS: $\widehat{\boldsymbol{\theta}} = (\Theta^\top X)^{-1} \Theta^\top \mathbf{y}$\\
\textbf{return} $\widehat{\boldsymbol{\theta}}$\\
\caption{Causal Parameter Estimation (CPE)}
\end{algorithm}
\begin{algorithm}[H]
\label{alg:ogd}
\SetAlgoLined
\textbf{Input:} $T$, $\{\eta\}_{t=1}^T, \widehat{\boldsymbol{\theta}}$\\
\For{$t = 1, 2, ..., T$}{
$\boldsymbol{\theta}_{t+1} = \Pi (\boldsymbol{\theta}_{t} - \eta_t \widehat{\Delta}_t(\widehat{\boldsymbol{\theta}}, \boldsymbol{\theta}_{t}, \mathbf{x}_{t}, y_{t}))$
}
$\widehat{\Delta}_t:$ unbiased estimate of $\nabla_{\boldsymbol{\theta}_t} f(\boldsymbol{\theta}_t)$\\
\caption{Online Gradient Descent (OGD)}
\end{algorithm}
\begin{algorithm}[H]
\label{alg:full}
\SetAlgoLined
\textbf{Input:} $T_1$, $T_2$, $\boldsymbol{\eta}$\\
$\widehat{\boldsymbol{\theta}}_1 =$ CPE$(T_1)$\\
OGD$(T_2, \{\eta\}_{t=1}^T, \widehat{\boldsymbol{\theta}}_1)$\\
Re-run CPE using all samples collected during CPE and OGD to get final estimate $\widehat{\boldsymbol{\theta}}_2$
\textbf{return} $\widehat{\boldsymbol{\theta}}_2$\\
\caption{Combined Risk Minimization and Causal Parameter Recovery}
\end{algorithm}
\subsection{Risk Minimization Derivation}
The loss for playing decision rule $\boldsymbol{\theta}_t$ is defined as
\begin{equation} \label{eq:risk}
\begin{aligned}
f(\boldsymbol{\theta}_t) &= \left( \boldsymbol{\theta}_t^\top \mathbf{x}_t(\boldsymbol{\theta}_t) - y \right)^2 \\
&= \left(\boldsymbol{\theta}_t^\top \mathbf{x}_t(\boldsymbol{\theta}_t) - \boldsymbol{\theta}^{*\top} \mathbf{x}_t(\boldsymbol{\theta}_t) - g(u_t) \right)^2 \\
&= \left( (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*)^\top \mathbf{x}_t(\boldsymbol{\theta}_t) - g(u) \right)^2 \\
\end{aligned}
\end{equation}
$\mathbf{x}_t(\boldsymbol{\theta}_t) = \mathbf{z}_t + \Omega \boldsymbol{\theta}_t$, where $\Omega = W W^\top$. Substituting this into Equation \ref{eq:risk}, we obtain
\begin{equation}
f(\boldsymbol{\theta}_t) = \left( (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*)^\top (\mathbf{z}_t + \Omega \boldsymbol{\theta}_t) - g(u) \right)^2
\end{equation}
The gradient of the loss with respect to $\boldsymbol{\theta}_t$ is
\begin{equation} \label{eq:true-grad}
\begin{aligned}
\nabla_{\boldsymbol{\theta}_t} f(\boldsymbol{\theta}_t) &= \nabla_{\boldsymbol{\theta}_t} \left((\boldsymbol{\theta}_t - \boldsymbol{\theta}^*)^\top (\mathbf{z}_t + \Omega \boldsymbol{\theta}_t) - g(u) \right)^2 \\
&= 2\left( (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*)^\top (\mathbf{z}_t + \Omega \boldsymbol{\theta}_t) - g(u) \right) \left((\mathbf{z}_t + \Omega \boldsymbol{\theta}_t) + \Omega^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*) \right) \\
&= 2 \left((\boldsymbol{\theta}_t - \boldsymbol{\theta}^*)^\top \mathbf{x}_t(\boldsymbol{\theta}_t) - g(u) \right) \left(\mathbf{x}_t(\boldsymbol{\theta}_t) + \Omega^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*) \right) \\
&= 2 \left(\boldsymbol{\theta}_t^\top \mathbf{x}_t(\boldsymbol{\theta}_t) - y \right) \left(\mathbf{x}_t(\boldsymbol{\theta}_t) + \Omega^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*) \right) \\
\end{aligned}
\end{equation}
\subsection{Regret Analysis}
\iffalse
\begin{equation}
|\widehat{\boldsymbol{\theta}}^* - \boldsymbol{\theta}^*| \leq \frac{\sigma_g\sqrt{2nk\log(k/\delta)}}{|\sum_{i=1}^T (\boldsymbol{\theta}_i - \Bar{\boldsymbol{\theta}})(x_i - \Bar{x})|}
\end{equation}
\fi
\subsubsection{Regret due to Algorithm \ref{alg:cpe}}
\begin{definition} (Regret)
The regret of \Cref{alg:full} is
\begin{equation*}
R(T) = T f(\boldsymbol{\theta}^*) - \sum_{i = 1}^T f(\boldsymbol{\theta}_t)
\end{equation*}
\end{definition}
$O(T_1)$
\subsubsection{Bounding $\| \widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^* \|_2$} \label{sec:theta}
Recall that $\widehat{\boldsymbol{\theta}} = (\Theta^\top X)^{-1} \Theta^\top \mathbf{y}$. Plugging this into $\| \widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^* \|_2$, we get
\begin{equation}
\| \widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^* \|_2 = \| (\Theta^\top X)^{-1} \Theta^\top \mathbf{y} - \boldsymbol{\theta}^* \|_2
\end{equation}
Next, we substitute in our expression for $\mathbf{y}$:
\begin{equation} \label{eq:bound1}
\begin{aligned}
\| \widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^* \|_2
&= \| (\Theta^\top X)^{-1} \Theta^\top (X \boldsymbol{\theta}^* + \mathbf{g}) - \boldsymbol{\theta}^* \|_2\\
&= \| (\Theta^\top X)^{-1} \Theta^\top X \boldsymbol{\theta}^* + (\Theta^\top X)^{-1} \Theta^\top \mathbf{g} - \boldsymbol{\theta}^* \|_2\\
&= \| \boldsymbol{\theta}^* + (\Theta^\top X)^{-1} \Theta^\top \mathbf{g} - \boldsymbol{\theta}^* \|_2\\
&= \| (\Theta^\top X)^{-1} \Theta^\top \mathbf{g} \|_2\\
& \leq \| (\Theta^\top X)^{-1} \|_2 \| \Theta^\top \mathbf{g} \|_2\\
& \leq \frac{\| \Theta^\top \mathbf{g} \|_2}{\sigma_{min}(\Theta^\top X)}
\end{aligned}
\end{equation}
Focusing on the numerator, note that
\begin{equation}
\| \Theta^\top \mathbf{g} \|_2 = \sqrt{\sum_{j=1}^m \left(\sum_{i=1}^n \theta_i^{(j)} g(u_i) \right)^2}
\end{equation}
Since $g(u_i)$ is a zero-mean sub-Gaussian random variable with variance parameter $\sigma_g$ and for each $j$, the $j$th entry of $\theta_i$, denoted $\theta_i^{(j)}$, is drawn uniformly from $\{\frac{-1}{\sqrt{m}}, \frac{1}{\sqrt{m}} \}$ (with variance $1/4$), thus for any $i$, the product $\theta_i^{(j)} g(u_i)$ will also be a sub-Gaussian random variable. Because $\theta_i^{(j)}$ and $g(u_i)$ are zero-mean and $g(u_i)$ is independent from $\theta_i^{(j)}$ for all $j$, the variance of $\theta_i^{(j)} g(u_i)$ is $\sigma_g^2/4$. In order to bound $\sum_{i=1}^n \theta_i^{(j)} g(u_i)$ with high probability, we make use of the following lemma:
\begin{lemma}[High probability bound on the sum of unbounded sub-Gaussian random variables] \label{lemma:chernoff}
Let $x_i \sim \text{subG}(0, \sigma^2)$. For any $\delta \in (0, 1)$, with probability at least $1 - \delta$,
\begin{equation}
\Big|\sum_{i=1}^n x_i\Big| \leq \sigma \sqrt{2n\log(1/\delta)}
\end{equation}
\end{lemma}
Applying Lemma \ref{lemma:chernoff}, we get
\begin{align*}
\left \| \Theta^\top \mathbf{g} \right \|_2
&\leq \sqrt{\sum_{j=1}^m \left(\sigma_g \sqrt{(1/2)n\log(1/\delta_j)} \right)^2}\\
&\leq \sqrt{\sum_{j=1}^m \sigma_g^2 (1/2)n\log(m/\delta)} \tag{by a union bound, where $\delta_j=\delta/m$ for all $j$}\\
&\leq \sigma_g \sqrt{(1/2)nm\log(m/\delta)}\\
\end{align*}
with probability at least $1 - \delta$. Substituting this back into Equation \ref{eq:bound1}, we get
\begin{equation}
\| \widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^* \|_2 \leq \frac{\sigma_g \sqrt{(1/2)nm\log(m/\delta)}}{\sigma_{min}(\Theta^\top X)}
\end{equation}
with probability at least $1 - \delta$. Next we bound the denominator, $\sigma_{min}(\Theta^\top X)$.
\fi
\begin{equation}
\begin{aligned}
\sigma_{min}(\Theta^\top X)
&= \sigma_{min}(\sum_{i=1}^n \mathbf{x}_i \boldsymbol{\theta}_i^\top)\\
&= \sigma_{min}(\sum_{i=1}^n \mathbf{z}_i \boldsymbol{\theta}_i^\top + WW^\top \boldsymbol{\theta}_i \boldsymbol{\theta}_i^\top)\\
&= \sigma_{min}(A + B),
\end{aligned}
\end{equation}
where $A = \sum_{i=1}^n \mathbf{z}_i \boldsymbol{\theta}_i^\top$ and $B = \sum_{i=1}^n WW^\top \boldsymbol{\theta}_i \boldsymbol{\theta}_i^\top$. By definition,
\begin{equation}
\sigma_{min}(A+B) = \min_{\mathbf{a}, \|\mathbf{a}\|_2 = 1} \|(A + B)\mathbf{a}\|_2.
\end{equation}
By the triangle inequality,
\begin{equation} \label{eq:triangle}
\begin{aligned}
\sigma_{min}(A+B)
&\geq \min_{\mathbf{a}, \|\mathbf{a}\|_2 = 1} \left( \|B\mathbf{a}\|_2 - \|A\mathbf{a}\|_2 \right)\\
&\geq \min_{\mathbf{a}, \|\mathbf{a}\|_2 = 1} \|B\mathbf{a}\|_2 - \|A\|_2\\
&\geq \sigma_{min}(B) - \|A\|_2\\.
\end{aligned}
\end{equation}
We start by bounding $\|A\|_2$.
\begin{lemma}[Matrix Bernstein]\cite{tropp2015introduction} \label{lemma:bernstein}
Consider a finite sequence $\{S_i\}_{i=1}^n$ of independent, random matrices with common dimension $d_1 \times d_2$. Assume that $\mathbb{E}[S_i] = 0_{d_1 \times d_2}$ and $\|S_i\|_2 \leq L$ for each index $i$.
Introduce the random matrix $A = \sum_{i=1}^n S_i$. Let $v(A)$ be the matrix variance statistic of the sum:
\begin{equation*}
\begin{aligned}
v(A)
&= \max\left\{ \left\|\mathbb{E}[AA^\top]\|_2, \|\mathbb{E}[A^\top A] \right\|_2 \right\}\\
&= \max\left\{ \left\| \sum_{i=1}^n \mathbb{E}[S_i S_i^\top]\|_2, \| \sum_{i=1}^n \mathbb{E}[S_i S_i^\top] \right\|_2 \right\}.
\end{aligned}
\end{equation*}
Then for all $t \geq 0$,
\begin{equation*}
P(\|A\|_2 \geq t) \leq (d_1 + d_2) \exp \left( \frac{-t^2/2}{v(A) + Lt/3} \right)
\end{equation*}
\end{lemma}
Let $S_i = \mathbf{z}_i \boldsymbol{\theta}_i^\top$. $\|\mathbb{E}[S_i]\| = 0$, since $\mathbb{E}[\boldsymbol{\theta}_i] = \mathbf{0}$, and $\boldsymbol{\theta}_i$ is independent from $\mathbf{z}_i$.
\begin{equation*}
\begin{aligned}
v(A)
&= \max\left\{ \left\| \sum_{i=1}^n \mathbb{E}[S_i S_i^\top]\|_2, \| \sum_{i=1}^n \mathbb{E}[S_i S_i^\top] \right\|_2 \right\}\\
&\leq n\max\left\{ \left\|\mathbb{E}[S_i S_i^\top]\|_2, \| \mathbb{E}[S_i S_i^\top] \right\|_2 \right\}\\
&\leq n
\end{aligned}
\end{equation*}
$\|S_i\|_2 \leq \sqrt{m}$, so $L = \sqrt{m}$.
Applying Lemma \ref{lemma:bernstein}, we obtain
\begin{equation}
P(\|A\|_2 \geq t) \leq 2m \exp \left( \frac{-t^2/2}{n + \sqrt{m}t/3} \right)
\end{equation}
By setting the RHS equal to $\delta$ and rearranging terms, we get
\begin{equation}
\|A\|_2 \leq \sqrt{2n \log \left(\frac{2m}{\delta}\right)}
\end{equation}
with probability at least $1 - \delta$.
Plugging this into Equation \ref{eq:triangle}, we get
\begin{equation} \label{eq:triangle-A}
\sigma_{min}(A+B) \geq \sigma_{min}(B) - \sqrt{2n \log \left(\frac{2m}{\delta}\right)}.
\end{equation}
Next we bound $\sigma_{min}(B)$.
\begin{equation}
\begin{aligned}
\sigma_{min}(B)
&= \sigma_{min}(WW^\top \sum_{i=1}^n \boldsymbol{\theta}_i \boldsymbol{\theta}_i^\top)\\
&\geq \sigma_{min}(WW^\top) \sigma_{min}(\sum_{i=1}^n \boldsymbol{\theta}_i \boldsymbol{\theta}_i^\top)
\end{aligned}
\end{equation}
Since $WW^\top$ and $\sum_{i=1}^n \boldsymbol{\theta}_i \boldsymbol{\theta}_i^\top$ are both symmetric matrices with non-negative eigenvalues, $\sigma_{min}(WW^\top) = \lambda_{min}(WW^\top)$ and $\sigma_{min}(\sum_{i=1}^n \boldsymbol{\theta}_i \boldsymbol{\theta}_i^\top) = \lambda_{min}(\sum_{i=1}^n \boldsymbol{\theta}_i \boldsymbol{\theta}_i^\top)$. $\lambda_{min}(WW^\top) \geq 1$ by assumption, so
\begin{equation}
\sigma_{min}(B) \geq \lambda_{min}(\sum_{i=1}^n \boldsymbol{\theta}_i \boldsymbol{\theta}_i^\top).
\end{equation}
We now use the Matrix Chernoff bound to get a lower bound for $\lambda_{min}(\sum_{i=1}^n \boldsymbol{\theta}_i \boldsymbol{\theta}_i^\top)$.
\iffalse
\subsubsection{Bounding $\| \Delta_t - \widehat{\Delta}_t \|_2$}
Loss function (Equation \ref{eq:risk}):
\begin{equation}
f(\boldsymbol{\theta}_t) = (\boldsymbol{\theta}_t^\top \mathbf{x}_t - y_t)^2
\end{equation}
True Derivative (Equation \ref{eq:true-grad}):
\begin{equation}
\Delta_t = \nabla_{\boldsymbol{\theta}_t} f(\boldsymbol{\theta}_t) = 2(\boldsymbol{\theta}_t^\top \mathbf{x}_t - y_t)(\mathbf{x}_t + \Omega^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*))
\end{equation}
Estimate of Derivative:
\begin{equation}
\widehat{\Delta}_t = \widehat{\nabla_{\boldsymbol{\theta}_t} f(\boldsymbol{\theta}_t)} = 2(\boldsymbol{\theta}_t^\top \mathbf{x}_t - y_t)(\mathbf{x}_t + \Omega^\top (\boldsymbol{\theta}_t - \widehat{\boldsymbol{\theta}}))
\end{equation}
Bound on Estimate:
\begin{equation}
\begin{aligned}
\| \Delta_t - \widehat{\Delta}_t \|_2
&= 2\left \| \left(\boldsymbol{\theta}_t^\top \mathbf{x}_t - y_t \right) \left(\mathbf{x}_t + \Omega^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*) \right) - \left(\boldsymbol{\theta}_t^\top \mathbf{x}_t - y_t \right) \left(\mathbf{x}_t + \Omega^\top (\boldsymbol{\theta}_t - \widehat{\boldsymbol{\theta}}) \right) \right \|_2 \\
&= 2\left\| \left(\boldsymbol{\theta}_t^\top \mathbf{x}_t - y_t \right) \Omega^\top \left(\widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^* \right) \right \|_2 \\
&\leq 2\left \| (\boldsymbol{\theta}_t^\top \mathbf{x}_t - y_t) \Omega^\top \right \| \left \| \widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^* \right \|_2
\end{aligned}
\end{equation}
\subsubsection{Regret due to Algorithm \ref{alg:ogd}}
Next we use our bound for $\| \Delta_t - \widehat{\Delta}_t \|_2$ to bound the regret achieved by Algorithm \ref{alg:ogd}. Let $\boldsymbol{\theta}^R$ denote the optimal $\boldsymbol{\theta}$ parameter for risk minimization. Note that $\boldsymbol{\theta}^R$ does not necessarily equal $\boldsymbol{\theta}^*$. If the loss function $f$ is convex, then
\begin{equation}
\begin{aligned}
f(\boldsymbol{\theta}_t) - f(\boldsymbol{\theta}^R) &\leq \Delta_t^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^R) \\
&= (\widehat{\Delta}_t + \Delta_t - \widehat{\Delta}_t)^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^R) \\
&= \widehat{\Delta}_t^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^R) + (\Delta_t - \widehat{\Delta}_t)^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^R)
\end{aligned}
\end{equation}
\begin{equation}
\begin{aligned}
\|\boldsymbol{\theta}_{t+1} - \boldsymbol{\theta}^R\|^2 &= \| \Pi(\boldsymbol{\theta}_t - \eta_t \widehat{\Delta}_t) - \boldsymbol{\theta}^R \|^2_2 \\
&\leq \| \boldsymbol{\theta}_t - \eta_t \widehat{\Delta}_t - \boldsymbol{\theta}^R \|^2_2 \\
&= \|\boldsymbol{\theta}_t - \boldsymbol{\theta}^R \|^2_2 + \eta_t^2 \|\widehat{\Delta}_t \|^2_2 - 2\eta_t \widehat{\Delta}_t^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^R)
\end{aligned}
\end{equation}
\begin{equation}
\widehat{\Delta}_t^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^R) \leq \frac{\|\boldsymbol{\theta}_t - \boldsymbol{\theta}^R \|^2_2 - \|\boldsymbol{\theta}_{t+1} - \boldsymbol{\theta}^R\|^2_2}{2\eta_t} + \frac{1}{2} \eta_t \|\widehat{\Delta}_t \|^2_2
\end{equation}
Plugging this into our expression for $f(\boldsymbol{\theta}_t) - f(\boldsymbol{\theta}^R)$, we obtain
\begin{equation}
f(\boldsymbol{\theta}_t) - f(\boldsymbol{\theta}^R) \leq \frac{\|\boldsymbol{\theta}_t - \boldsymbol{\theta}^R \|^2_2 - \|\boldsymbol{\theta}_{t+1} - \boldsymbol{\theta}^R\|^2_2}{2\eta_t} + \frac{1}{2} \eta_t \|\widehat{\Delta}_t \|^2_2 + (\Delta_t - \widehat{\Delta}_t)^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^R)
\end{equation}
Let $\widehat{G} = \max_t \|\widehat{\nabla}_t \|_2$, $D = \max_t \| \boldsymbol{\theta}_t - \boldsymbol{\theta}^R \|^2_2$, $C = 2\max_t \|(\boldsymbol{\theta}_t^\top \mathbf{x}_t - y_t) \Omega^\top \|_2$, and define $\frac{1}{\eta_0} = 0$. Then,
\begin{equation}
\begin{aligned}
\sum_{t=1}^{T_2} f(\boldsymbol{\theta}_t) - f(\boldsymbol{\theta}^R) &\leq \sum_{t=1}^{T_2} \frac{\|\boldsymbol{\theta}_t - \boldsymbol{\theta}^R \|^2_2 - \|\boldsymbol{\theta}_{t+1} - \boldsymbol{\theta}^R\|^2}{2\eta_t} + \frac{1}{2} \eta_t \widehat{G}^2 + (\Delta_t - \widehat{\Delta}_t)^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^R) \\
&\leq \frac{1}{2} \sum_{t=1}^{T_2} \|\boldsymbol{\theta}_t - \boldsymbol{\theta}^R \|^2 (\frac{1}{\eta_t} - \frac{1}{\eta_{t-1}}) + \frac{1}{2} \widehat{G}^2 \sum_{t=1}^{T_2} \eta_t + \sum_{t=1}^{T_2} (\Delta_t - \widehat{\Delta}_t)^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^R) \\
&\leq \frac{1}{2} D^2 \frac{1}{\eta_T} + \frac{1}{2} \widehat{G}^2 \sum_{t=1}^{T_2} \eta_t + \sum_{t=1}^{T_2} (\Delta_t - \widehat{\Delta}_t)^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^R) \\
&\leq \frac{1}{2} D^2 \frac{1}{\eta_T} + \frac{1}{2} \widehat{G}^2 \sum_{t=1}^{T_2} \eta_t + \sum_{t=1}^{T_2} \|(\Delta_t - \widehat{\Delta}_t)^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^R) \|_2 \\
&\leq \frac{1}{2} D^2 \frac{1}{\eta_T} + \frac{1}{2} \widehat{G}^2 \sum_{t=1}^{T_2} \eta_t + \sum_{t=1}^{T_2} \|\Delta_t - \widehat{\Delta}_t \|_2 \| \boldsymbol{\theta}_t - \boldsymbol{\theta}^R \|_2 \\
&\leq \frac{1}{2} D^2 \frac{1}{\eta_T} + \frac{1}{2} \widehat{G}^2 \sum_{t=1}^{T_2} \eta_t + D \max_t \|\Delta_t - \widehat{\Delta}_t \|_2 T_2 \\
&\leq \frac{1}{2} D^2 \frac{1}{\eta_T} + \frac{1}{2} \widehat{G}^2 \sum_{t=1}^{T_2} \eta_t + CD \| \widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^* \|_2 T_2 \\
\end{aligned}
\end{equation}
\khcomment{In the traditional setting, pick $\eta_t = \frac{G}{D \sqrt{t}}$}
\subsubsection{Regret due to Algorithm \ref{alg:full}}
\begin{equation}
R(T) \leq C_1 T_1 + \frac{1}{2} D^2 \frac{1}{\eta_T} + \frac{1}{2} \widehat{G}^2 \sum_{t=1}^{T_2} \eta_t + C_2 D \| \widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^* \|_2 T_2
\end{equation}
\fi
\section*{Checklist}
\begin{enumerate}
\item For all authors...
\begin{enumerate}
\item Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope?
\answerYes{}
\item Did you describe the limitations of your work?
\answerYes{} See Conclusion.
\item Did you discuss any potential negative societal impacts of your work?
\answerYes{} No immediate negative societal impacts come to mind.
\item Have you read the ethics review guidelines and ensured that your paper conforms to them?
\answerYes{}
\end{enumerate}
\item If you are including theoretical results...
\begin{enumerate}
\item Did you state the full set of assumptions of all theoretical results?
\answerYes{}
\item Did you include complete proofs of all theoretical results?
\answerYes{} See Appendix.
\end{enumerate}
\item If you ran experiments...
\begin{enumerate}
\item Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)?
\answerYes{} We included links to the publicly available datasets we begin with. See \Cref{sec:experiment} for an abridged description of how we modify this data and run our methods. See \Cref{sec:omitted-experiments} for a full description.
\item Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)?
\answerYes{} See \Cref{sec:omitted-experiments} for all training details and justifications for how they were chosen.
\item Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)?
\answerYes{} See \Cref{fig:estimation_error,fig:ols-2sls-estimates,fig:credit-estimation_error,fig:credit-outcome} for all estimates with error bars (after 10 runs with different random seeds).
\item Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)?
\answerYes{} See Appendix \ref{sec:answers}.
\end{enumerate}
\item If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
\begin{enumerate}
\item If your work uses existing assets, did you cite the creators?
\answerYes{} See \Cref{sec:experiment}
\item Did you mention the license of the assets?
\answerYes{} We cite the creators or authors of the two datasets we use and link to where they can be publicly accessed. See Appendix \ref{sec:answers}.
\item Did you include any new assets either in the supplemental material or as a URL?
\answerNA{} We do not provide any new assets. We use publicly-accessed data and provide code for modifying it before applying our methods.
\item Did you discuss whether and how consent was obtained from people whose data you're using/curating?
\answerYes{} See Appendix \ref{sec:answers}.
\item Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content?
\answerYes{} See Appendix \ref{sec:answers}.
\end{enumerate}
\item If you used crowdsourcing or conducted research with human subjects...
\begin{enumerate}
\item Did you include the full text of instructions given to participants and screenshots, if applicable?
\answerNA{}
\item Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable?
\answerNA{}
\item Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation?
\answerNA{}
\end{enumerate}
\end{enumerate}
\section{Conclusion}
In this work, we establish the possibility of recovering the causal relationship between observable attributes and the outcome of interest in settings where a decision-maker utilizes a series of linear assessment rules to evaluate strategic individuals. Our key observation is that in strategic settings, assessment rules serve as valid instruments (because they causally impact observable attributes but do not directly affect the outcome). This observation enables us to present a 2SLS method to correct for confounding bias in causal estimates.
We then demonstrate the potential of the recovered causal coefficients to be utilized for preventing individual-level disparities, improving agent outcomes, and reducing predictive risk minimization.
While our work offers an initial step toward extracting causal knowledge from automated assessment rules, we rely on several simplifying assumptions---all of which mark critical directions for future work. In particular, we assume all assessment rules and the underlying causal model are linear. This assumption allows us to utilize linear IV methods. Extending our work to \emph{non-linear} assessment rules and IV methods is necessary for the applicability of our method to real-world settings. Another critical assumption is the agent's \emph{full knowledge} of the assessment rule and their \emph{rational} response to it, subject to a \emph{quadratic effort cost}. While these are standard assumptions in economic modeling, they need to be empirically verified in the particular decision-making context at hand before our method's outputs can be viewed as reliable estimates of causal relationships.
\iffalse
\begin{itemize}
\item Non-linear assessment rules and non-linear IV
\item Different randomizing schemes (e.g., one in which the amount of perturbation needed goes down with time?)
\item Further connections to performative prediction: is there a one-to-one mapping in our setting between performatively stable points and local minima? (have observed this in practice in 1D)
\item alternative agent cost formulations (i.e. budget)
\end{itemize}
\fi
\section{The Disparate Effects of Using Non-Causal Assessments}\label{sec:fairness}
While making predictions based on causal relationships is important from an ML perspective for reasons of generalization and robustness, the societal implications of using non-causal relationships to make decisions are perhaps an even more persuasive reason to use causally-relevant attributes when making predictions in consequential domains. In particular, it could be the case that a certain portion of the population is worse at strategically manipulating features which are not causally relevant than the rest of the population. If non-causally relevant attributes are used in the decision-making process, these individuals will be unfairly seen by the decision-maker as less qualified than their peers, even if their initial features and ability for improvement are the same.
\xhdr{Disparity Between Agents.} A basic desideratum for fairness in our setting is that two individual decision-subjects with the same \khedit{outcome $y$ for any deployed assessment rule $\boldsymbol{\theta}$} should receive similar predictions. As we will illustrate in the following example, this is the case if the assessment rule $\boldsymbol{\theta}$ used to make predictions is equal to $\boldsymbol{\theta}^*$. Throughout this section we use $\mathcal{C} \subseteq \{1, \ldots, n\}$ to denote the indices of observable features $\mathbf{x}$ which are causally relevant (i.e., $\theta^*_i > 0$ for $i \in \mathcal{C}$) to outcomes $y$.
\khedit{Consider the problem of assigning predictions to two agents $\mathbf{u}$ and $\mathbf{u}'$ with attributes $\mathbf{b} = \mathbf{b}'$, $o = o'$, and $(\mathcal{E}\mathcal{E}^\top)_{ij} = (\mathcal{E}'\mathcal{E}'^\top)_{ij}$ if $i \in \mathcal{C}$ or $j \in \mathcal{C}$. Otherwise, $(\mathcal{E}\mathcal{E}^\top)_{ij} \geq (\mathcal{E}'\mathcal{E}'^\top)_{ij}$ with equality holding for at least one $(i,j)$ pair. Intuitively, this corresponds to a setting in which the initial observable features and mapping between the deployed assessment rule $\boldsymbol{\theta}$ and changes in causally-relevant observable features $\mathbf{x}_\mathcal{C}$ are the same for each agent, but one agent is better at manipulating non-causally relevant observable features than the other. Under such a setting, $y = y'$ no matter what assessment rule is used to make predictions, and $\hat{y} = \hat{y}'$ if $\boldsymbol{\theta} = \boldsymbol{\theta}^*$. On the other hand, if $\boldsymbol{\theta} \neq \boldsymbol{\theta}^*$, $\hat{y} \geq \hat{y}'$ even though $y = y'$!. Moreover, the difference between $\hat{y}$ and $\hat{y'}$ grows with how much better agent $\mathbf{u}$ is compared to $\mathbf{u}'$ at manipulating features which are not causally relevant, the number of features which are not causally relevant, the number of actions available to the agents, and the weight that the assessment rule $\boldsymbol{\theta}$ places on non-causally relevant attributes. Formally, we lower-bound this difference as follows.
\begin{proposition}\label{thm:nec}
The gap in predictions can be bounded as
\small
\begin{equation*}
\begin{aligned}
&\hat{y}_1 - \hat{y}_2 \geq d \delta (n - n_C)^2 \varepsilon^2
\end{aligned}
\end{equation*}
\normalsize
if $\boldsymbol{\theta}^* \succcurlyeq \mathbf{0}_m$, where $n$ is the number of observable features, $n_C$ is the number of causally relevant observable features, $d$ is the number of actions each agent can invest effort in, $\delta = \min_{i \not\in \mathcal{C}, j \not\in \mathcal{C}, k \in \{1, \ldots, d\}} \mathcal{E}_{ik} \mathcal{E}_{jk} - \mathcal{E}'_{ik} \mathcal{E}'_{jk}$, and $\varepsilon = \min_{i \not\in \mathcal{C}} \theta_i$ is the minimum weight $\boldsymbol{\theta}$ places on observable features which are not causally relevant.
\end{proposition}
}
See Appendix \ref{sec:nec-derivations} for full derivations, which follow from straightforward algebraic manipulation.
\iffalse
\xhdr{Disparity Between subpopulations.} An analogous bound holds when different \emph{subpopulations} of agents differ only in non-causal ways. In order to see how using non-causal relationships to make predictions may lead to inequality across different subpopulations, consider the following example, which is an extension of the previous example to the population setting.
Consider the setting in which the agent population consists of two different subpopulations: an ``advantaged group'' $A$ which is better at manipulating features which are not causally relevant than a ``disadvantaged group'' $D$. Intuitively, this difference in ability to manipulate features which are not causally relevant should have no impact on the expected predicted outcome, as both populations have equal ability when it comes to altering their causally-relevant attributes. \khedit{In particular, we study the setting in which $\mathop{\mathbb{E}}_A[o] = \mathop{\mathbb{E}}_D[o]$, $\mathop{\mathbb{E}}_A[\mathbf{b}] = \mathop{\mathbb{E}}_D[\mathbf{b}]$, $\mathop{\mathbb{E}}_A[\mathcal{E}\mathcal{E}^\top]_{ij} = \mathop{\mathbb{E}}_D[\mathcal{E}\mathcal{E}^\top]_{ij}$ for $i$ or $j \in \mathcal{C}$, and $\mathop{\mathbb{E}}_A[\mathcal{E}\mathcal{E}^\top]_{ij} \geq \mathop{\mathbb{E}}_D[\mathcal{E}\mathcal{E}^\top]_{ij}$ for $i,j \not \in \mathcal{C}$. Note that in this setting, $\mathop{\mathbb{E}}_A[y] = \mathop{\mathbb{E}}_D[y]$ always, but the expected prediction for both subpopulations need not be the same. Formally, we can lower-bound the difference between $\mathbb{E}_A[\hat{y}]$ and $\mathbb{E}_D[\hat{y}]$ as follows:
\begin{proposition}
The gap in expected prediction between subpopulations $A$ and $D$ is at least
\small
\begin{equation*}
\begin{aligned}
&\mathop{\mathbb{E}}_A[\hat{y}] - \mathop{\mathbb{E}}_D[\hat{y}] \geq d \delta (n - n_C)^2 \varepsilon^2
\end{aligned}
\end{equation*}
\normalsize
if $\boldsymbol{\theta}^* \succcurlyeq \mathbf{0}_m$, where $n$ is the number of observable features, $n_C$ is the number of causally-relevant observable features, $d$ is the number of actions each agent can invest effort in, $\delta = \min_{i \not\in \mathcal{C}, j \not\in \mathcal{C}, k \in \{1, \ldots, d\}} \mathop{\mathbb{E}}_A[\mathcal{E}_{ik}\mathcal{E}_{jk}] - \mathop{\mathbb{E}}_D[\mathcal{E}_{ik}\mathcal{E}_{jk}]$, and $\varepsilon = \min_{i \not\in \mathcal{C}} \theta_i$ is the minimum weight $\boldsymbol{\theta}$ places on observable features which are not causally relevant.
\end{proposition}
}
Much like the bound in Lemma \ref{thm:nec}, the bound on $\mathop{\mathbb{E}}_A[\hat{y}] - \mathop{\mathbb{E}}_D[\hat{y}]$ will never be negative, and will grow with the gap in ability between $A$ and $D$ to manipulate features which are not causally relevant, the number of such features, the number of actions available to the agents, and the weight that $\boldsymbol{\theta}$ places on attributes which are not causally relevant. The derivation is analogous to the derivation of Lemma \ref{thm:nec}.
\fi
We also note that if causal relationships are used to make predictions (i.e., if $\boldsymbol{\theta} = \boldsymbol{\theta}^*$), statistical parity is satisfied between subpopulations which differ only in their ability to manipulate attributes which are not causally relevant.
\begin{definition}[Statistical Parity]
A predictor $\boldsymbol{\theta}$ is said to satisfy statistical parity for two subpopulations $G$ and $G'$ if
\small
\begin{equation*}
\mathbb{P}_G(\widehat{y} \leq t) = \mathbb{P}_{G'}(\widehat{y} \leq t), \forall t.
\end{equation*}
\normalsize
\end{definition}
\begin{proposition}
If the joint distribution over $\mathbf{b}$, $o$, and $[\mathcal{E}\mathcal{E}^\top]_{ij}$ ($i$ or $j \in \mathcal{C}$) is the same for subpopulations $G$ and $G'$, then statistical parity between $G$ and $G'$ is satisfied if $\boldsymbol{\theta} = \boldsymbol{\theta}^*$.
\end{proposition}
See Appendix \ref{sec:statistical-parity} for the proof, which follows straightforwardly from algebraic manipulation.
\iffalse
\subsection{The Effects of Overestimation on Different Subpopulations}
Another way to characterize the (un-)fairness of a deployed decision rule $\boldsymbol{\theta}$ is to compare the expected amount of over/under-estimation of an agent's outcome across different agent subpopulations. To formalize this notion of fairness, we make use of the notion of an \emph{overestimation gap} between the expected outcome and expected predicted outcome.
\begin{definition}[Overestimation Gap]
For a given subpopulation $G$, define the overestimation gap between the expected outcome and expected predicted outcome as $\mathop{\mathbb{E}}_G[\hat{y}_t - y_t]$. Moreover, define the \emph{difference in overestimation gap} between any two subpopulations $G$ and $G'$ as
\begin{equation*}
\Delta(G,G') = \mathop{\mathbb{E}}_G[\hat{y}_t - y_t] - \mathop{\mathbb{E}}_{G'}[\hat{y}_t - y_t].
\end{equation*}
\end{definition}
In order to illustrate the potential differences in overestimation gap that $\boldsymbol{\theta} \neq \boldsymbol{\theta}^*$ may cause, we return to the setting introduced in Example \ref{ex:2}.
\begin{example}[Example \ref{ex:2}, continued]
Under this setting, we can bound the difference in overestimation gap as follows:
\begin{theorem}\label{thm:dif-in-pred-gap}
If the principal uses a decision rule $\boldsymbol{\theta} \neq \boldsymbol{\theta}^*$ to make predictions, then
\begin{equation*}
\Delta(A,D) = \Omega((n - n_{\mathcal{C}})n_{\mathcal{C}} d \gamma_1 (2\gamma_2 - \gamma_3) + (n - n_{\mathcal{C}})^2 d \gamma_1^2),
\end{equation*}
where $n$ is the number of observable features, $n_\mathcal{C}$ is the number of causal observable features, $d$ is the number of actions each agent can invest effort in, and $\gamma_1, \gamma_2, \gamma_3$ are positive, instance-dependent constants.
\end{theorem}
See Appendix \ref{sec:pred-gap-derivations} for the full derivations. Note that in some special cases (namely when $\gamma_2 << \gamma_3$), the difference in overestimation gap can actually be negative. Intuitively, this can occur whenever $\boldsymbol{\theta}$ induces the advantaged decision-subjects to invest efforts which greatly improve their true outcome, but only slightly improve their predicted outcome when compared to the effort investments made by the disadvantaged population. For more details, see Appendix \ref{sec:neg-pred-gap}.
While it is possible for the difference in overestimation gap to be negative under certain special settings, it is important to note that the statistical parity gap and difference between $\mathop{\mathbb{E}}_A[y]$ and $\mathop{\mathbb{E}}_D[y]$ are always positive, even when the difference in overestimation gap is negative. Additionally, this difference is strictly non-negative under many common situations. In particular, the difference in overestimation gap for two subpopulations is non-negative whenever $\boldsymbol{\theta}$ \emph{overestimates} the causal effects of observable features (i.e., $\boldsymbol{\theta} = \boldsymbol{\theta}^* + \boldsymbol{\varepsilon}$, $\boldsymbol{\varepsilon} \succcurlyeq 0$), or whenever $\boldsymbol{\theta}$ \emph{underestimates} the causal effects, but the amount of underestimation is bounded below some threshold. The proofs of the following two corollaries follow straightforwardly from the derivation of Theorem \ref{thm:dif-in-pred-gap}.
\begin{corollary}\label{cor:1}
If $\boldsymbol{\theta} = \boldsymbol{\theta}^* + \boldsymbol{\varepsilon}$ ($\boldsymbol{\varepsilon} \succcurlyeq 0$), the difference in overestimation gap is strictly non-negative and is lower-bounded as $\Delta(A,D) \geq \Omega((n - n_\mathcal{C})^2 d \gamma_1^2)$.
\end{corollary}
\begin{corollary}\label{cor:2}
If $\boldsymbol{\theta} \geq \frac{1}{2} \boldsymbol{\theta}^*$, the difference in overestimation gap is strictly non-negative and is lower-bounded as $\Delta(A,D) \geq \Omega((n - n_\mathcal{C})^2 d \gamma_1^2)$.
\end{corollary}
\end{example}
\fi
\section{Finite Sample IV Estimate Bound for General Setting}
\subsection{Model}
We present our model as a system of linear equations expressed as such
\begin{equation}
\begin{cases}
y_i = \mathbf x^\top \mathbf \theta^* + g(u_i)\\
\mathbf x_i = \mathbf z_t + WW^\top \mathbf\theta_i = \mathbf z_t + \Omega \mathbf\theta_i
\end{cases}
\end{equation}
where $g(u_i)\in\RR^k$ is a mean-zero sub-Gaussian random variable with variance parameter $\sigma_g$.
Now, we can rewrite the reward $y_i$ as
\begin{align*}
y_i &= (\mathbf z_t + WW^\top \mathbf\theta_i)^\top \mathbf\theta^* + g(u_i)\\
&= \mathbf\theta_i^\top WW^\top \mathbf\theta^* + \mathbf z_t\top \mathbf\theta^* + g(u_i)\\
&= \mathbf\theta_i^\top \Gamma + \mathbf z_t\top \mathbf\theta^* + g(u_i), \tag{where $\Gamma = WW^\top \mathbf\theta^*$}
\end{align*}
\subsection{Finite Sample Analysis}
\begin{restatable}[Treatment effect approximation bound for General Model]{theorem}{generaltreatmentapproximationbound}\label{thm:general-treatment-approximation-bound}
Let $\theta_1,\dots,\theta_n\in[0,1]^k$ be a sequence of instruments. Suppose there is a sequence of $n$ agents such that each agent $i$ has private type $u_i$ drawn independently from $\cU$, plays features $x_i$ under instrument $\theta_i$, and receives reward $y_i$. Let sample set $S=(x_i,y_i,\theta_i)_{i=1}^n$. For any $\delta\in(0,1)$, the difference between the true causal effect $\theta^*$ and its IV estimate $\hat{\theta}_S^*$ based on sample set $S$ satisfies the following approximation bound $A(S,\delta)$:
\[\norm{\hat{\theta}_S^*-\theta^*}_2 \leq A(S,\delta) := \frac{\sigma_g\sqrt{2nk\log(k/\delta)}}{\sigma_{\min}\left\{\sum_{i=1}^n x_i\theta_i^{\intercal}\right\}},\]
where $\sigma_{\min}\{\cdot\}$ denotes the smallest singular value.
\end{restatable}
\begin{proof}
See \cref{sec:general-approximation-bound-proof} for a proof.
\end{proof}
\subsection{Finite Sample Analysis Proof}
\label{sec:general-approximation-bound-proof}
Given $n \in \RR$ samples $\left\{(\theta_i, x_i, y_i)\right\}_{i=1}^n$, of the revealed treatment effect $\theta_i$, chosen features $x_i$, and reward $y_i$ at each round $i$, we would like to bound the difference between the predicted exogenous treatment effect, denoted $\hat{\theta}_S^*$, and the true treatment effect $\theta^*$.
\subsubsection{IV Estimate}
First, we form the estimate $\hat{\theta}_S^*$ of $\theta$ via Two-Stage Least Squares (2SLS) regression. In the first stage, we form the OLS estimate $\hat{\Gamma}_S$ of $\Gamma$ by regressing $y_i$ onto $\theta_i$ and the OLS estimate $\hat{\omega}_S$ of $\omega$ by regressing $x_i$ onto $\theta_i$:
\begin{equation}
\hat{\Gamma}_S = \bigg(\sum_{i=1}^n\theta_i\theta_i^\intercal\bigg)^{-1}\sum_{i=1}^n\theta_iy_i
\hspace{.4cm}
\text{ and }
\hspace{.4cm}
\hat{\omega}_S = \bigg(\sum_{i=1}^n\theta_i\theta_i^\intercal\bigg)^{-1}\sum_{i=1}^n\theta_ix_i^\intercal
\end{equation}
Second, we take the inverse of $\hat{\Gamma}_S$ times $\hat{\omega}_S$ as the predicted causal effect vector $\hat{\theta}_S^*$:
\begin{align*}
\hat{\theta}_S^*
&= (\hat{\omega}_S^\intercal)^{-1}\hat{\Gamma}_S\\
&= \left(\bigg(\sum_{i=1}^n\theta_ix_i^\intercal\bigg)^{-1}\right)^\intercal\bigg(\sum_{i=1}^n\theta_i\theta_i^\intercal\bigg)^\intercal\bigg(\sum_{i=1}^n\theta_i\theta_i^\intercal\bigg)^{-1}\sum_{i=1}^n\theta_iy_i\\
&= \bigg(\sum_{i=1}^nx_i\theta_i^\intercal\bigg)^{-1}\bigg(\sum_{i=1}^n\theta_i\theta_i^\intercal\bigg)\bigg(\sum_{i=1}^n\theta_i\theta_i^\intercal\bigg)^{-1}\sum_{i=1}^n\theta_iy_i\\
&= \bigg(\sum_{i=1}^nx_i\theta_i^\intercal\bigg)^{-1}\sum_{i=1}^n\theta_iy_i
\end{align*}
Finally, we take the norm of the difference between $\theta^*$ and IV estimate $\hat{\theta}_S^*$
\begin{align*}
\norm{\hat{\theta}_S^* - \theta^*}_2 &= \norm{\bigg(\sum_{i=1}^nx_i\theta_i^\intercal\bigg)^{-1}\sum_{i=1}^n\theta_i(\theta^*^\intercal x_i + g(u_i))^\intercal}_2\\
&= \norm{\bigg(\sum_{i=1}^nx_i\theta_i^\intercal\bigg)^{-1}\bigg(\sum_{i=1}^n\theta_i(\theta^*^\intercal x_i)^\intercal + \sum_{i=1}^n\theta_ig(u_i)\bigg)}_2\\
&= \norm{\bigg(\sum_{i=1}^nx_i\theta_i^\intercal\bigg)^{-1}\bigg(\sum_{i=1}^n\theta_ix_i^\intercal\theta^* + \sum_{i=1}^n\theta_ig(u_i)\bigg)}_2\\
&= \norm{\bigg(\sum_{i=1}^nx_i\theta_i^\intercal\bigg)^{-1}\bigg(\sum_{i=1}^nx_i\theta_i^\intercal\bigg)\theta^* + \bigg(\sum_{i=1}^nx_i\theta_i^\intercal\bigg)^{-1}\sum_{i=1}^n\theta_ig(u_i)}_2\\
&= \norm{\theta^* + \bigg(\sum_{i=1}^nx_i\theta_i^\intercal\bigg)^{-1}\sum_{i=1}^n\theta_ig(u_i)}_2\\
&= \norm{\bigg(\sum_{i=1}^nx_i\theta_i^\intercal\bigg)^{-1}\sum_{i=1}^n\theta_ig(u_i)}_2\\
&\leq \norm{\bigg(\sum_{i=1}^nx_i\theta_i^\intercal\bigg)^{-1}}_2\norm{\sum_{i=1}^n\theta_ig(u_i)}_2\tag{by Cauchy-Schwarz}\\
&= \frac{\norm{\sum_{i=1}^n\theta_ig(u_i)}_2}{\sigma_{\min}\bigg\{\sum_{i=1}^nx_i\theta_i^\intercal\bigg\}},\\
\end{align*}
where $\sigma_{\min}\{\cdot\}$ denotes the minimum singular value.
Now, we upper bound the numerator of the last line above in the following \Cref{eq:general-approximation-bound-numerator}:
\begin{lemma}\label{eq:general-approximation-bound-numerator}
For any $\delta \in (0,1)$, with probability at least $1-\delta$, the numerator of the approximation bound $A(S,\delta)$ given in \Cref{thm:general-treatment-approximation-bound} is
\begin{equation}
\norm{\sum_{i=1}^n\theta_ig(u_i)}_2 \leq \sigma_g\sqrt{2nd\log(d/\delta)}
\end{equation}
where $g(u_i)$ is a zero mean sub-Gaussian random variable with variance $\sigma_g$.
\begin{proof}
Since $\theta_i$ is chosen independently from each agent's type $u_i$, the variables $g(u_i)$ and $\theta_i$ are independent. Furthermore, we assume that the expected value $\mathop{\mathbb{E}}[g(u_i)]=0$.\footnote{Without this assumption, we run into identifiability issues: we cannot reconstruct the individual treatment effects $\left(\theta^*\right)^1,\dots,\left(\theta^*\right)^k$ without fixing some mean $\mathop{\mathbb{E}}[g(u)]$. For purposes of regret minimization, assuming $\mathop{\mathbb{E}}[g(u)]=0$ does not change our results.} Thus, we apply a high probability bound on the sum $\sum_{i=1}^n g(u_i)\theta_i$:
\begin{align*}
\norm{\sum_{i=1}^n g(u_i)\theta_i}_2
&=\sqrt{\sum_{j=1}^k\left(\sum_{i=1}^n g(u_i)\theta^j_i\right)^2}\\
&\leq \sqrt{\sum_{j=1}^k\left(\sum_{i=1}^n g(u_i)\right)^2} \tag{since, by assumption, $0\leq\theta^j_i\leq1$}\\
&\leq \sqrt{\sum_{j=1}^k\left(\sigma_g\sqrt{2n\log(1/\delta_j)}\right)^2} \tag{by Chernoff Bound \lscomment{refer to theorem}}\\
&\leq \sqrt{\sum_{j=1}^k\left(\sigma_g\sqrt{2n\log(k/\delta)}\right)^2} \tag{by Union Bound with $\delta_j=\delta/k$ for all $1\leq j\leq k$}\\
&\leq \sigma_g\sqrt{2nk\log(k/\delta)}
\end{align*}
\end{proof}
\end{lemma}
\section{Ideas}
\begin{enumerate}
\item Setting: Privacy (based on https://arxiv.org/pdf/1506.03489.pdf)\\
Motivation:
Fitting a linear model to a dataset from a privacy-concerned source. Data holders may want to influence the outcome of the computation on this dataset, so it is insufficient to run just linear regression.\\
Goal: Design mechanism that incentivize the players to provide information that allows for accurate computation, while minimizing the payment.\\
Problem: Seems like we can apply 2SLS to this setting (with some assumptions modification so it makes sense to use 2SLS), but otherwise it's similar to the original work.
\item Setting: Causal strategic classification with a linear model (Based on https://arxiv.org/pdf/2002.10066.pdf)\\
Problem: Same as above. It seems like we can apply the 2SLS, but it's still similar to the original work (and we do not know if it improves on the result or not.)
\end{enumerate}
\section{Omitted experiments}
\label{sec:omitted-experiments}
In this section, we present additional details for our experiments in \Cref{sec:experiment}. At the end, we provide more information regarding the dataset and computation resources used.
\begin{figure}[ht]
\centering
\includegraphics[width=\linewidth]{figures/fg-ls_shifted_features.png}
\caption{Distributions of unobserved features $\mathbf{b}$ (in lighter colors), i.e. initial HS GPA (two left figures) and SAT (two right figures), and observed features $\mathbf{x}$ (darker colors) for disadvantaged (two top figures in yellow and orange) and advantaged students (two bottom figures in green).}
\label{fig:features-shift}
\end{figure}
\iffalse
\begin{figure}[ht]
\centering
\begin{subfigure}[t]{0.45\textwidth}
\includegraphics[width=\linewidth]{figures/college-admission-y-plot.png}
\caption{Distribution of college GPAs (outcomes $y$) for disadvantaged students (orange), advantaged students (green), and both combined (blue).}
\label{fig:outcomes}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\linewidth]{figures/all_outcome_credit.png}
\caption{Distribution of semi-synthetic credit card default rates (outcomes $y$) for young (green), older (young), and all applicants (blue). Default rates are shown on a logarithmic scale.}
\label{fig:credit-outcomes}
\end{subfigure}
\caption{Outcome distributions for semi-synthetic datasets. Left: college GPA for university admissions data. Right: credit card default rates for credit risk assessment data.}
\label{fig:both-outcomes}
\end{figure}
\fi
\begin{figure}
\centering
\includegraphics[width=0.6\linewidth]{figures/college-admission-y-plot.png}
\caption{Distribution of college GPAs (outcomes $y$) for disadvantaged students (orange), advantaged students (green), and both combined (blue).}
\label{fig:outcomes}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{figures/estimate_convergence-HS-GPA.png}
\caption{OLS versus 2SLS estimates for high school GPA effect on college GPA over 5000 rounds. Results are averaged over 10 runs, with the error bars (in lighter colors) representing one standard deviation. The red dashed line is the true causal effect of each high school GPA on college GPA.}
\label{fig:gpa-estimates}
\end{figure}
\subsection{University admissions full experimental description} We construct a semi-synthetic dataset based on an example of university admissions with disadvantaged and advantaged students from \citet{hu2018disparate}. From a real dataset of the high school (HS) GPA, SAT score, and college GPA of 1000 college students, we estimate the causal effect of observed features $[\text{SAT}, \text{HS GPA}]$ on college GPA to be $\boldsymbol{\theta}^*=[0.00085, 0.49262]^\top$ using OLS (which is assumed to be consistent, since we have yet to modify the data to include confounding). We then use this dataset to construct synthetic data which looks similar, yet incorporates confounding factors. For simplicity, we let the true causal effect parameters $\boldsymbol{\theta}^*=[0, 0.5]^\top$. That is, we assume there is a significant causal relationship between college performance and HS GPA, but not SAT score.\footnote{Though this assumption may be contentious, it is based on existing research \cite{allensworth2020gpasat}.} We consider two types of student backgrounds, those from a \textit{disadvantaged group} and those from an \textit{advantaged group}. We assume disadvantaged applicants have, on average, lower HS GPA and SAT $\mathbf{b}_t$, lower baseline college GPA $o_t$, and require more effort to improve observable features (reflected in $\mathcal{E}_t$): this could be due to disadvantaged groups being systemically underserved, marginalized, or abjectly discriminated against (and the converse for advantaged groups). Initial features $\mathbf{b}_t$ are constructed as such: For any disadvantaged applicant $t$, their initial SAT features $z_t^{\text{SAT}} \sim \mathcal{N}(800,200)$ and initial HS GPA $z_t^{\text{HS GPA}} \sim \mathcal{N}(1.8,0.5)$. For any advantaged applicant $t$, $z_t^{\text{SAT}} \sim \mathcal{N}(1000,200)$ and $z_t^{\text{HS GPA}} \sim \mathcal{N}(2.2,0.5)$. We truncate SAT scores between 400 to 1600 and HS GPA between 0 to 4. For any applicant $t$, we randomly deploy assessment rule $\boldsymbol{\theta}_t = [\theta_t^{\text{SAT}},\theta_t^{\text{HS GPA}}]^\top$ where $\theta_t^{\text{SAT}}\sim \mathcal{N}(1,10)$ and $\theta_t^{\text{HS GPA}}\sim \mathcal{N}(1,2)$. $\boldsymbol{\theta}_t$ need not be zero-mean, so universities can play a reasonable assessment rule with slight perturbations while still being able to perform unbiased causal estimation. Components of the average effort conversion matrix $\mathop{\mathbb{E}}[\mathcal{E}_t]$ are smaller for disadvantaged applicants, which makes their mean improvement worse (see \Cref{fig:features-shift}). We set the expected effort conversion term $\mathop{\mathbb{E}}[\mathcal{E}_t] = \begin{pmatrix} 10 & 0 \\ 0 & 1 \end{pmatrix}$ for simplicity. Each row of $\mathop{\mathbb{E}}[\mathcal{E}_t]$ corresponds to effort expended to change a specific feature. For example, entries in the first row of $\mathop{\mathbb{E}}[\mathcal{E}_t]$ correspond to effort expended to change one's SAT score. For each applicant $t$, we perturb $\mathop{\mathbb{E}}[\mathcal{E}_t]$ with random noise drawn from $\mathcal{N}(0.5,0.25)$ to the top left entry and noise drawn from $\mathcal{N}(0.1,0.01)$ the bottom right entry to produce $\mathcal{E}_t$. We add this noise to $\mathop{\mathbb{E}}[\mathcal{E}_t]$ to produce $\mathcal{E}_t$ for advantaged applicants and subtract for disadvantaged applicants: thus, it takes more effort, on average, for members of disadvantaged groups to improve their HS GPA and SAT scores than members of advantaged groups. Finally, we construct college GPA (true outcome $y_t$) by multiplying observed features $\mathbf{x}_t$ by the true effect parameters $\boldsymbol{\theta}^*$. We then add confounding error $o_t$ where $o_t\sim\mathcal{N}(0.5,0.2)$ for disadvantaged applicants and $o_t\sim\mathcal{N}(1.5,0.2)$ for advantaged applicants. Disadvantage applicants could have lower baseline outcomes, e.g. due to institutional barriers or discrimination. While the setting we consider is simplistic, \Cref{fig:outcomes,fig:features-shift} demonstrate that our semi-synthetic admissions data behaves reasonably.\footnote{For example, the mean shift in SAT scores from the first to second exam is 46 points \cite{goodman2020sat}. In our data, the mean shift for disadvantaged and advantaged applicants is about 36 points and 91 points, respectively.}
\iffalse
\begin{figure}
\centering
\includegraphics[width=0.45\linewidth]{figures/estimate_convergence-HS-GPA.png}
\caption{OLS versus 2SLS estimates for high school GPA effect on college GPA over 5000 rounds. Results are averaged over 10 runs, with the error bars (in lighter colors) representing one standard deviation. The red dashed line is the true causal effect of each high school GPA on college GPA.}
\label{fig:my_label}
\end{figure}
\fi
\iffalse
\subsection{Taiwan credit full experimental description} Next, we construct a semi-synthetic dataset based on credit default risk assessment. The TAIWAN-CREDIT dataset includes 23 observed features and one outcome. There are 4 demographic features: client age, gender, education level, and marital status. The rest of the features describe clients' credit information: one feature is the total credit limit. There are three other kinds of features (payment status, monthly bill amount, and monthly payment amount) for each of 6 months from April to September 2005 (making 18 features total). In the original dataset, the outcome variable is binary: either the client defaults on the credit card or they do not.
In order to fit our regression task, we translate the binary outcome variable (1 for default, 0 for not) into a continuous probability of defaulting (default rate) by dividing all original outcome variable in half and adding uniformly random noise on the interval $[0.01,0.49]$. Next, we construct features: from the original 18 credit history features, we aggregated and created a set of 6 \textit{initial features} ($\mathbf{b}$) containing the amount of unpaid balance and the ratio of payment for each of the first three months (from April 2005 to June 2005). Similarly, we took the last three months (from July 2005 to September 2005) to be a set of $6$ \textit{observable features} ($\mathbf{x}$). We normalize all initial and observable features on the interval $[-1,1]$. Using OLS, we regress our constructed outcome ($y$) onto our observable features ($\mathbf{x}$) to solve for the true causal effect of payment history on default rate $\boldsymbol{\theta}^*$. We also assume randomly deployed assessment rule $\boldsymbol{\theta}_t$ and estimate the expected effort conversion matrix $\mathop{\mathbb{E}}[\mathcal{E}_t\mathcal{E}_t^\top]$ using OLS, as well.
Next, we modify the data to add confounding. For simplicity, we focus on only two \textit{types} ($u_t$) of clients for this experiment: clients younger than $35$ years old, and clients older than $35$ years old. For any younger client $t$, we construct their effort conversion matrix $\mathcal{E}_t\mathcal{E}_t^T$ by adding random Gaussian noise to $\mathop{\mathbb{E}}[\mathcal{E}_t\mathcal{E}_t^\top]$; for any older client $t$, we subtract noise. This way, older clients need expend less effort to decrease their default rates than younger clients. In the original dataset, younger clients have worse credit history than older clients. We (artificially) exacerbate this as such: for any younger client $t$, their initial features $\mathbf{b}_t$ are shifted by noise $\eta_\text{young-feature} \sim \mathcal{N}(-0.6, 1)$. For any older client $t$, their initial features $\mathbf{b}_t$ are shifted by noise $\eta_\text{old-feature} \sim \mathcal{N}(0.6,1)$. We assume that younger clients have a higher probability of default, e.g. because younger clients do not have an established credit history and they are more likely to make bigger purchases that require many months of payment. Hence, for any younger client $t$, their baseline default rate error $o_t^\text{young} \sim \mathcal{N}(0.4, 0.2)$. On the other hand, for any older client $t$, $o_t \sim \mathcal{N}(-0.4,0.2)$. For any client $t$, we randomly deploy assessment rule $\theta_t$, where each coordinate $\theta_{t,j} \sim \mathcal{N}(0,1)$. With these assessment rules, we construct new observed features $x_t$ by adding the improvement $\mathcal{E}_t \mathcal{E}_t^\top \theta_t$ to the initial features $z_t$. Finally, we construct the true default rate $y_t$ by multiplying the observed features $x_t$ by the true effect parameters $\theta^*$ and adding confounding error $o_t$ (which is described above). This produces somewhat realistic outcome data, \dndelete{: the mean default rate in the original TAIWAN-CREDIT dataset is 0.2212; in our semi-synthetic data, the mean default rate is 0.2652.} \Cref{fig:credit-outcomes} shows the distribution of our semi-synthetic outcome variables.
\fi
\subsection{Experimental Details}\label{sec:answers}
We evaluate our model on a semi-synthetic dataset based on our running university admission example \cite{Dua:2019}. The dataset we base our experiments off of is publicly available at \url{www.openintro.org/data/index.php?data=satgpa}. This dataset does not contain personally identifiable information or offensive content. Since this is a publicly available dataset, no consent from the people whose data we are using was required. We ran our experiments on a 2020 MacBook Air laptop with 16GB of RAM.
\section{Experiments}\label{sec:experiment}
We empirically evaluate our model on a semi-synthetic dataset inspired by our running university admissions example. We compare our 2SLS-based method against ordinary least squares (OLS), which directly regresses observed outcomes $y$ on observable features $\mathbf{x}$. We show that even in our stylized setting with just two observable features, OLS does not recover $\boldsymbol{\theta}^*$, whereas our method does
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{figures/college-admission-SAT-plot.png}
\caption{OLS versus 2SLS estimates for SAT effect on college GPA over 5000 rounds. Results are averaged over 10 runs, with the error bars (in lighter colors) representing one standard deviation. The red dashed line is the true causal relationship between SAT score and college GPA.}
\label{fig:sat-estimates}
\end{figure}
\iffalse
\begin{figure}[ht]
\centering
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=0.95\textwidth]{figures/college-admission-SAT-plot.png}
\caption{OLS versus 2SLS estimates for SAT effect on college GPA over 5000 rounds. Results are averaged over 10 runs, with the error bars (in lighter colors) representing one standard deviation. The red dashed line is the true causal relationship between SAT score and college GPA.}
\label{fig:sat-estimates}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\linewidth]{figures/estimate_convergence-HS-GPA.png}
\caption{OLS versus 2SLS estimates for high school GPA effect on college GPA over 5000 rounds. Results are averaged over 10 runs, with the error bars (in lighter colors) representing one standard deviation. The red dashed line is the true causal relationship between high school GPA and college GPA.}
\label{fig:gpa-estimates}
\end{subfigure}
\caption{Evaluation of strategic IV regression on our semi-synthetic university admissions data. Left: True effect of SAT on college GPA vs. OLS and 2SLS estimates. Right: True effect of high school GPA on college GPA vs. OLS and 2SLS estimates.}
\label{fig:admission}
\end{figure}
\fi
\begin{figure}[ht]
\centering
\includegraphics[width=0.5\linewidth]{figures/college-admission-estimation-error-plot.png}
\caption{OLS effect estimate error $\|\widehat{\boldsymbol{\theta}}_{\text{OLS}} - \boldsymbol{\theta}^* \|_2$ (in orange) and 2SLS estimate error $\|\widehat{\boldsymbol{\theta}}_{\text{2SLS}} - \boldsymbol{\theta}^* \|_2$ (in blue) over 5000 rounds. Results are averaged over 10 runs. Error bars (in lighter colors) represent one standard deviation. 2SLS estimate error decreases at a rate of about $\frac{1}{\sqrt{T}}$ (red dashed line). }
\label{fig:estimation_error}
\end{figure}
\xhdr{University admissions experimental description} We constructed a semi-synthetic dataset based on the SATGPA dataset, a collection of real university admissions data.\footnote{Originally collected by the Educational Testing Service, the SATGPA dataset is publicly available and can be found here: \url{https://www.openintro.org/data/index.php?data=satgpa}.} The SATGPA dataset contains 6 variables on 1000 students. We use the following: two features (high school (HS) GPA and SAT score) and an outcome (college GPA). Using OLS (which is assumed to be consistent since we have yet to modify the data to include confounding), we find that the effect of $[\text{SAT}, \text{HS GPA}]$ on college GPA in this dataset is $\boldsymbol{\theta}^*=[0.0015, 0.5895]^\top$. We then construct synthetic data that is based on this original data, yet incorporates confounding factors. For simplicity, we let the true effect $\boldsymbol{\theta}^*=[0, 0.5]^\top$. That is, we assume HS GPA is causally related to college GPA, but SAT score is not.\footnote{Though this assumption may be contentious, it is based on existing research (e.g., \citet{allensworth2020gpasat}).} We consider two private types of applicant backgrounds: \textit{disadvantaged} and \textit{advantaged}. Disadvantaged applicants have lower initial HS GPA and SAT ($\mathbf{b}$), lower baseline college GPA ($o$), and need more effort to improve observable features ($\mathcal{E}$).\footnote{For example, this could be due to the disadvantaged group being systemically underserved or marginalized (and the converse for advantaged group).} Each applicants' initial features are randomly drawn from one of two Gaussian distributions, depending on background. Applicants may manipulate both of their features. See \Cref{sec:omitted-experiments} for a full experimental description.
\xhdr{Results.} In \Cref{fig:sat-estimates}, we compare the true effect of SAT score on college GPA ($\boldsymbol{\theta}^*$) with the estimates of these quantities given by our method of 2SLS from \Cref{sec:main} ($\hat{\boldsymbol{\theta}}_{\text{2SLS}}$) and with the estimates given by OLS ($\hat{\boldsymbol{\theta}}_{\text{OLS}}$). (An analogous figure for the effects of HS GPA is included in the appendix.) In \Cref{fig:estimation_error}, we compare the estimation errors of OLS and 2SLS, i.e. $\|\widehat{\boldsymbol{\theta}}_{\text{OLS}} - \boldsymbol{\theta}^* \|_2$ and $\|\widehat{\boldsymbol{\theta}}_{\text{2SLS}} - \boldsymbol{\theta}^* \|_2$.
We find that our 2SLS method converges to the true causal relationship (at a rate of about $\frac{1}{\sqrt{T}}$), whereas OLS has a constant bias. Although our setting assumes that SAT score has no causal relationship with college GPA, OLS mistakenly predicts that, on average, a 100 point increase in SAT score leads to about a 0.05 point increase in college GPA. If SAT were not causally related to collegiate performance in real life, these biased estimates could lead universities to erroneously use SAT scores in admissions decisions. This highlights the advantage of our method, since using a naive parameter estimation method like OLS in the presence of confounding could cause decision-making institutions to deploy assessments which don't accurately reflect the characteristics they are trying to measure.
\iffalse
\begin{table}[h]
\centering
\begin{tabular}{|c|c|c|}
\hline & $G = A$ & $G = D$ \\ \hline
$\widehat{\boldsymbol{\theta}} = \hat{\boldsymbol{\theta}}_{2SLS}$ & $\mathop{\mathbb{E}}[\hat{y}] = $ & $\mathop{\mathbb{E}}[\hat{y}] = $ \\ \hline
$\widehat{\boldsymbol{\theta}} = \hat{\boldsymbol{\theta}}_{OLS}$ & $\mathop{\mathbb{E}}[\hat{y}] = $ & $\mathop{\mathbb{E}}[\hat{y}] = $ \\ \hline
\end{tabular}
\caption{}\label{table:fairness}
\end{table}
\fi
\section{Individual Fairness Derivations}\label{sec:fairness-derivations}
\subsection{Proof of Theorem \ref{thm:IF}}
\begin{proof}
\begin{equation*}
\begin{aligned}
&|\hat{y} - \hat{y}'| =\\ &|(\mathbf{b} - \mathbf{b}')^\top \boldsymbol{\theta}^* + \boldsymbol{\theta}^{*\top} (\mathcal{E}\mathcal{E}^\top - \mathcal{E}' \mathcal{E}^{'\top}) \boldsymbol{\theta}^* |\\
&= |(\mathbf{b}_{\mathcal{C}} - \mathbf{b}_{\mathcal{C}}')^\top \boldsymbol{\theta}^* + \boldsymbol{\theta}^{*\top} ((\mathcal{E}\mathcal{E}^\top)_{\mathcal{C}} - (\mathcal{E}'\mathcal{E}^{'\top})_{\mathcal{C}} ) \boldsymbol{\theta}^* |\\
&\leq \| \mathbf{b}_{\mathcal{C}} - \mathbf{b}_{\mathcal{C}}' \|_2 \| \boldsymbol{\theta}^* \|_2 + \| \boldsymbol{\theta}^* \|_2 \| ((\mathcal{E}\mathcal{E}^\top)_{\mathcal{C}} - (\mathcal{E}'\mathcal{E}^{'\top})_{\mathcal{C}}) \boldsymbol{\theta}^* \|_2\\
&\leq \| \mathbf{b}_{\mathcal{C}} - \mathbf{b}_{\mathcal{C}}' \|_2 + \max_{\boldsymbol{\theta}, \|\boldsymbol{\theta}\|_2 = 1} \| ((\mathcal{E}\mathcal{E}^\top)_{\mathcal{C}} - (\mathcal{E}'\mathcal{E}^{'\top})_{\mathcal{C}}) \boldsymbol{\theta}^* \|_2\\
&\leq \| \mathbf{b}_{\mathcal{C}} - \mathbf{b}_{\mathcal{C}}' \|_2 + \| ((\mathcal{E}\mathcal{E}^\top)_{\mathcal{C}} - (\mathcal{E}'\mathcal{E}^{'\top})_{\mathcal{C}})\|_2\\
\end{aligned}
\end{equation*}
\end{proof}
\subsection{Proof of Theorem \ref{thm:IF-bound}}
\begin{proof}
Let
\begin{align*}
b_{\widetilde{\mathcal{C}},i} &=
\begin{cases}
b_i & \text{if } i \not\in \mathcal{C}\\
0 & \text{otherwise}
\end{cases}
, &\\
(\mathcal{E}\mathcal{E}^\top)_{\widetilde{\mathcal{C}},ij} &=
\begin{cases}
(\mathcal{E}\mathcal{E}^\top)_{ij} & \text{if } i,j \not\in \mathcal{C}\\
0 & \text{otherwise}.
\end{cases}
\end{align*}
\begin{equation*}
\begin{aligned}
&|\hat{y} - \hat{y}'| = |(\mathbf{b}_{\mathcal{C}} - \mathbf{b}_{\mathcal{C}}')^\top \boldsymbol{\theta} + \boldsymbol{\theta}^\top ((\mathcal{E}\mathcal{E}^\top)_\mathcal{C} - (\mathcal{E}'\mathcal{E}^{'\top})_\mathcal{C})\boldsymbol{\theta}\\
&+ (\mathbf{b}_{\widetilde{\mathcal{C}}} - \mathbf{b}_{\widetilde{\mathcal{C}}}')^\top \boldsymbol{\theta} + \boldsymbol{\theta}^\top ((\mathcal{E}\mathcal{E}^\top)_{\widetilde{\mathcal{C}}} - (\mathcal{E}'\mathcal{E}^{'\top})_{\widetilde{\mathcal{C}}})\boldsymbol{\theta}|\\
&= |(\mathbf{b}_{\widetilde{\mathcal{C}}} - \mathbf{b}_{\widetilde{\mathcal{C}}}')^\top \boldsymbol{\theta} + \boldsymbol{\theta}^\top ((\mathcal{E}\mathcal{E}^\top)_{\widetilde{\mathcal{C}}} - (\mathcal{E}'\mathcal{E}^{'\top})_{\widetilde{\mathcal{C}}})\boldsymbol{\theta}|\\
&= \left| \sum_{i \not \in \mathcal{C}} (b_i - b_i') \theta_i + \sum_{i \not \in \mathcal{C}} \sum_{j \not \in \mathcal{C}} ((\mathcal{E}\mathcal{E}^\top)_{ij} - (\mathcal{E}'\mathcal{E}^{'\top})_{ij}) \theta_i \theta_j \right|\\
\end{aligned}
\end{equation*}
\end{proof}
\subsection{Example \ref{ex:fairness} Derivations}
\begin{equation*}
\begin{aligned}
d(\mathbf{u}, \mathbf{u}') &= \|b_{\mathcal{C}} - b'_{\mathcal{C}}\|_2 + \| (\mathcal{E} \mathcal{E}^\top)_\mathcal{C} - (\mathcal{E}' \mathcal{E}'^\top)_\mathcal{C} \|_2\\
&= \| (\boldsymbol{\delta} - \boldsymbol{\delta}')_\mathcal{C} I_{n \times n} \|_2 = \|\mathbf{0}_{n \times n}\|_2 = 0,\\
\end{aligned}
\end{equation*}
where
\begin{equation*}
\delta_{\mathcal{C}, i} =
\begin{cases}
\delta_i & \text{if } i \in \mathcal{C}\\
0 & \text{otherwise}.
\end{cases}
\end{equation*}
\begin{equation*}
\begin{aligned}
|\hat{y} - \hat{y}'| &= \left| 0 + \sum_{i \not \in \mathcal{C}} (n - 0) \theta_i^2 \right|
= n \sum_{i =1}^{n/2} \theta_i^2\\
\end{aligned}
\end{equation*}
\iffalse
\begin{equation*}
\begin{aligned}
\hat{y} - \hat{y}' &= \widehat{\boldsymbol{\theta}}^\top (\mathbf{b} - \mathbf{b}') + \sum_{k=1}^d \sum_{i=1}^n \sum_{j=1}^n (\mathcal{E}_{ik} \mathcal{E}_{jk} - \mathcal{E}'_{ik} \mathcal{E}'_{jk}) \hat{\theta}_i \hat{\theta}_j + o - o'\\
&= \sum_{k=1}^d \sum_{i \in \mathcal{C}} \sum_{j \in \mathcal{C}} (\mathcal{E}_{ik} \mathcal{E}_{jk} - \mathcal{E}'_{ik} \mathcal{E}'_{jk}) \hat{\theta}_i \hat{\theta}_j\\
&+ 2\sum_{k=1}^d \sum_{i \in \mathcal{C}} \sum_{j \not \in \mathcal{C}} (\mathcal{E}_{ik} \mathcal{E}_{jk} - \mathcal{E}'_{ik} \mathcal{E}'_{jk}) \hat{\theta}_i \hat{\theta}_j\\
&+ \sum_{k=1}^d \sum_{i \not \in \mathcal{C}} \sum_{j \not \in \mathcal{C}} (\mathcal{E}_{ik} \mathcal{E}_{jk} - \mathcal{E}'_{ik} \mathcal{E}'_{jk}) \hat{\theta}_i \hat{\theta}_j\\
&= \sum_{k=1}^d \sum_{i \not \in \mathcal{C}} \sum_{j \not \in \mathcal{C}} (\mathcal{E}_{ik} \mathcal{E}_{jk} - \mathcal{E}'_{ik} \mathcal{E}'_{jk}) \hat{\theta}_i \hat{\theta}_j\\
\end{aligned}
\end{equation*}
\fi
\iffalse
\begin{equation*}
\begin{aligned}
&\hat{y}_1 - \hat{y}_2\\ = &(\mathbf{b}_1 - \mathbf{b}_2)^\top \widehat{\boldsymbol{\theta}} + \widehat{\boldsymbol{\theta}}^\top (\mathcal{E}_1 \mathcal{E}_1^\top - \mathcal{E}_2 \mathcal{E}_2^\top) \widehat{\boldsymbol{\theta}} + o_1 - o_2\\
&= \sum_{i \in \mathcal{C}} \widehat{\theta}_i (z_{1,i} - z_{2,i})\\ &+ 2 \sum_{i \in \mathcal{C}} \sum_{j \not\in \mathcal{C}} \sum_{k=1}^d \mathcal{E}_{ik}(\mathcal{E}_{1,jk} - \mathcal{E}_{2,jk}) \widehat{\theta}_i \widehat{\theta}_j\\ &+ \sum_{i \not\in \mathcal{C}} \sum_{j \not\in \mathcal{C}} \sum_{k=1}^d (\mathcal{E}_{1,ik}\mathcal{E}_{1,jk} - \mathcal{E}_{2,ik}\mathcal{E}_{2,jk})\widehat{\theta}_i \widehat{\theta}_j\\
\end{aligned}
\end{equation*}
Lemma \ref{thm:nec} immediately follows. Note that $\mathcal{E}_{1,ik} = \mathcal{E}_{2, ik}$ if $i \in \mathcal{C}$.
\fi
\iffalse
\section{Statistical Parity Proof}\label{sec:statistical-parity}
In order to show that statistical parity holds, we need to show that $ \mathbb{P}_A(\widehat{y} \leq t) = \mathbb{P}_{D}(\widehat{y} \leq t), \forall t$.
\begin{equation*}
\begin{aligned}
&\mathbb{P}_A(\widehat{y} \leq t) = \mathbb{P}_A(\mathbf{b}^\top \boldsymbol{\theta}^* + \boldsymbol{\theta}^{*\top} \mathcal{E} \mathcal{E}^\top \boldsymbol{\theta}^* + o \leq t)\\
&= \mathbb{P}_A(\sum_{i \in \mathcal{C}} z_{i} \theta^*_i + \sum_{i \in \mathcal{C}} \sum_{j \in \mathcal{C}} \sum_{k=1}^d \mathcal{E}_{ik}\mathcal{E}_{jk} + o \leq t)\\
\end{aligned}
\end{equation*}
Similarly,
\begin{equation*}
\begin{aligned}
&\mathbb{P}_D(\widehat{y} \leq t) =\\ &\mathbb{P}_D(\sum_{i \in \mathcal{C}} z_{i} \theta^*_i + \sum_{i \in \mathcal{C}} \sum_{j \in \mathcal{C}} \sum_{k=1}^d \mathcal{E}_{ik}\mathcal{E}_{jk} + o \leq t)\\
\end{aligned}
\end{equation*}
$\mathbb{P}_A(\widehat{y} \leq t) = \mathbb{P}_D(\widehat{y} \leq t)$, $\forall t$ follows from the fact that the joint distribution over $z_i$, $\mathcal{E}_{jk}$, and $g$ is the same for both sub-populations, for all $i, j \in \mathcal{C}$.
\fi
\iffalse
\section{Lower Bound for $\mathop{\mathbb{E}}_A[y] - \mathop{\mathbb{E}}_D[y]$}\label{sec:dif-y-bound}
\begin{equation*}
\begin{aligned}
&\mathop{\mathbb{E}}_A[y_t] - \mathop{\mathbb{E}}_D[y_t] = (\mathop{\mathbb{E}}_A[z_t] - \mathop{\mathbb{E}}_D[z_t])^\top \boldsymbol{\theta}^*\\ &+ \widehat{\boldsymbol{\theta}}^\top (\mathop{\mathbb{E}}_A[\mathcal{E}_t \mathcal{E}_t^\top] - \mathop{\mathbb{E}}_D[\mathcal{E}_t \mathcal{E}_t^\top]) \boldsymbol{\theta}^* + \mathop{\mathbb{E}}_A[o_t] - \mathop{\mathbb{E}}_D[o_t]\\
&= \sum_{i=1}^n \sum_{j=1}^n \sum_{k=1}^d (\mathop{\mathbb{E}}_A[w_{ik} w_{jk}] - \mathop{\mathbb{E}}_D[w_{ik} w_{jk}]) \widehat{\theta}_i \theta^*_j\\
&= \sum_{i \not\in \mathcal{C}} \sum_{j \in \mathcal{C}} \sum_{k=1}^d (\mathop{\mathbb{E}}_A[w_{ik} w_{jk}] - \mathop{\mathbb{E}}_D[w_{ik} w_{jk}]) \widehat{\theta}_i \theta^*_j\\
\end{aligned}
\end{equation*}
The bound in Theorem \ref{thm:dif-y-bound} immediately follows.
\fi
\iffalse
\section{Overestimation Gap Derivations}\label{sec:pred-gap-derivations}
$\mathop{\mathbb{E}}_A[\hat{y}_t - y_t]$ is defined as follows:
\begin{equation*}
\begin{aligned}
&\mathop{\mathbb{E}}[\hat{y}_t - y_t]_A =\\ &\mathop{\mathbb{E}}_A[(z_t + \mathcal{E}_t \mathcal{E}_t^\top \widehat{\boldsymbol{\theta}})^\top \hat{\boldsymbol{\theta}} + \hat{g} - (z_t + \mathcal{E}_t \mathcal{E}_t^\top \widehat{\boldsymbol{\theta}})^\top \boldsymbol{\theta}^* - o_t]
\end{aligned}
\end{equation*}
Similarly,
\begin{equation*}
\begin{aligned}
&\mathop{\mathbb{E}}_D[\hat{y} - y] =\\ &\mathop{\mathbb{E}}_D[(z_t + \mathcal{E}_t \mathcal{E}_t^\top \widehat{\boldsymbol{\theta}})^\top \hat{\boldsymbol{\theta}} + \hat{g} - (z_t + \mathcal{E}_t \mathcal{E}_t^\top \widehat{\boldsymbol{\theta}})^\top \boldsymbol{\theta}^* - o_t]
\end{aligned}
\end{equation*}
Assuming $\mathop{\mathbb{E}}_A[\mathbf{b}_t] = \mathop{\mathbb{E}}_D[\mathbf{b}_t]$ and $\mathop{\mathbb{E}}_A[o_t] = \mathop{\mathbb{E}}_D[o_t]$, we can write the difference in overestimation gap as
\begin{equation*}
\begin{aligned}
\Delta(A,D) &= \mathop{\mathbb{E}}_A[\hat{y} - y] - \mathop{\mathbb{E}}_D[\hat{y} - y]\\
&= \widehat{\boldsymbol{\theta}}^\top (\mathop{\mathbb{E}}_A[\mathcal{E}_t \mathcal{E}_t^\top] - \mathop{\mathbb{E}}_D[\mathcal{E}_t \mathcal{E}_t^\top])(\widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^*)
\end{aligned}
\end{equation*}
Let $\mathcal{C}$ denote the set of causal features.
\begin{equation*}
\begin{aligned}
\Delta(A,D) &= \sum_{i \in \mathcal{C}} \sum_{j \in \mathcal{C}} \sum_{k=1}^d (\mathop{\mathbb{E}}_A[w_{ik} w_{jk}] - \mathop{\mathbb{E}}_D[w_{ik} w_{jk}])\widehat{\theta}_i (\widehat{\theta}_j - \theta^*_j)\\
&+ \sum_{i \in \mathcal{C}} \sum_{j \not\in \mathcal{C}} \sum_{k=1}^d (\mathop{\mathbb{E}}_A[w_{ik} w_{jk}] - \mathop{\mathbb{E}}_D[w_{ik} w_{jk}])\widehat{\theta}_i (\widehat{\theta}_j - 0)\\
&+ \sum_{i \not\in \mathcal{C}} \sum_{j \in \mathcal{C}} \sum_{k=1}^d (\mathop{\mathbb{E}}_A[w_{ik} w_{jk}] - \mathop{\mathbb{E}}_D[w_{ik} w_{jk}])\widehat{\theta}_i (\widehat{\theta}_j - \theta^*_j)\\
&+ \sum_{i \not\in \mathcal{C}} \sum_{j \not\in \mathcal{C}} \sum_{k=1}^d (\mathop{\mathbb{E}}_A[w_{ik} w_{jk}] - \mathop{\mathbb{E}}_D[w_{ik} w_{jk}])\widehat{\theta}_i (\widehat{\theta}_j - 0)\\
\end{aligned}
\end{equation*}
Assuming that $\mathop{\mathbb{E}}_A[w_{ik} w_{jk}] = \mathop{\mathbb{E}}_D[w_{ik} w_{jk}]$ if $i,j \in \mathcal{C}$,
\begin{equation*}
\begin{aligned}
\Delta(A,D) &= \sum_{i \not\in \mathcal{C}} \sum_{j \in \mathcal{C}} \sum_{k=1}^d (\mathop{\mathbb{E}}_A[w_{ik} w_{jk}] - \mathop{\mathbb{E}}_D[w_{ik} w_{jk}])\widehat{\theta}_i (2\widehat{\theta}_j - \theta^*_j)\\
&+ \sum_{i \not\in \mathcal{C}} \sum_{j \not\in \mathcal{C}} \sum_{k=1}^d (\mathop{\mathbb{E}}_A[w_{ik} w_{jk}] - \mathop{\mathbb{E}}_D[w_{ik} w_{jk}])\widehat{\theta}_i \widehat{\theta}_j\\
\end{aligned}
\end{equation*}
Note that the second term will always be $\geq 0$ by assumption. Let $\delta_1 = \max_{i \in \mathcal{C},j \not\in \mathcal{C},k} (\mathop{\mathbb{E}}_A[w_{ik} w_{jk}] - \mathop{\mathbb{E}}_D[w_{ik} w_{jk}])$ if the first term is $< 0$ and $\delta_1 = \min_{i \in \mathcal{C},j \not\in \mathcal{C},k} (\mathop{\mathbb{E}}_A[w_{ik} w_{jk}] - \mathop{\mathbb{E}}_D[w_{ik} w_{jk}])$ o.w.
\begin{equation}\label{eq:d1}
\begin{aligned}
\Delta(A,D) &\geq d \delta_1 \sum_{i \not\in \mathcal{C}} \sum_{j \in \mathcal{C}} \widehat{\theta}_i (2\widehat{\theta}_j - \theta^*_j)
+ d \delta_2 \sum_{i \not\in \mathcal{C}} \sum_{j \not\in \mathcal{C}} \widehat{\theta}_i \widehat{\theta}_j\\
\end{aligned}
\end{equation}
Denote the number of causal features as $n_\mathcal{C}$. Note that Equation \ref{eq:d1} is symmetric with respect to $\widehat{\theta}_i, i \not\in \mathcal{C}$, $\widehat{\theta}_j, j \not\in \mathcal{C}$, $\widehat{\theta}_j, j \in \mathcal{C}$, and $\theta_j^*$. Therefore,
\begin{equation}\label{eq:dpg-bound}
\Delta(A,D) \geq d (n - n_\mathcal{C}) n_\mathcal{C} \widehat{\theta}_{NC} (2 \widehat{\theta}_{C} - \theta^*_C) + d (n - n_\mathcal{C})^2 \delta_2 \widehat{\theta}_{NC}^2,
\end{equation}
where $\theta^*_C = \max_i \theta^*_i$, $\widehat{\theta}_{NC} = \min_{i \not\in \mathcal{C}} \widehat{\theta}_i$, and $\widehat{\theta}_{C} = \max_{i \in \mathcal{C}} \widehat{\theta}_i$ if $\sum_{i \not\in \mathcal{C}} \sum_{j \in \mathcal{C}} \sum_{k=1}^d (\mathop{\mathbb{E}}_A[w_{ik} w_{jk}] - \mathop{\mathbb{E}}_D[w_{ik} w_{jk}])\widehat{\theta}_i (2\widehat{\theta}_j - \theta^*_j) < 0$ and $\min_{i \in \mathcal{C}} \widehat{\theta}_i$ otherwise.
\subsection{Negative Difference in Overestimation Gap}\label{sec:neg-pred-gap}
Note that lower bound on the difference in overestimation gap in Equation \ref{eq:dpg-bound} can sometimes be negative. In particular, this happens whenever $\widehat{\boldsymbol{\theta}}$ is selected such that
\begin{equation*}
\widehat{\theta}_C < \frac{1}{2} \left(\theta^*_C - \frac{n - n_\mathcal{C}}{n_\mathcal{C}} \frac{\delta_2}{\delta_1} \widehat{\theta}_{NC} \right).
\end{equation*}
Note that in some cases this bound is tight, meaning that it generally is possible for the difference in overestimation gap to be negative.
\fi
\section{(Un)fairness of (Non-)causal Assessments}\label{sec:fairness}
While making predictions based on causal relationships is important from an ML perspective for reasons of generalization and robustness, the societal implications of using non-causal relationships to make decisions are perhaps an even more persuasive reason to use causally-relevant assessments.
In particular, it could be the case that a certain individual is worse at strategically manipulating features which are not causally relevant when compared to their peers. If these attributes are used in the decision-making process, this agent may be unfairly seen by the decision-maker as less qualified than their peers, even if their initial features and ability for improvement is similar to others.
One important criterion for assessing the fairness of a machine learning model at the individual level is that two individuals who have similar merit should receive similar predictions. \citet{dwork2012fairness} formalize this intuition through the notion of \emph{individual fairness}, which is formally defined as follows.
\begin{definition}[Individual Fairness \cite{dwork2012fairness}]
A mapping $M: \mathcal{U} \rightarrow \Delta (Y)$ is individually fair if for every $\mathbf{u}, \mathbf{u}' \in \mathcal{U}$, we have
\begin{equation*}
D(M(\mathbf{u}), M(\mathbf{u}')) \leq d(\mathbf{u}, \mathbf{u}'),
\end{equation*}
where $\mathbf{u}, \mathbf{u}' \in \mathcal{U}$ are individuals in population $\mathcal{U}$, $\Delta (Y)$ is the probability distribution over predictions $Y$, $D(M(\mathbf{u}), M(\mathbf{u}'))$ is a distance function which measures the similarity of the predictions received by $\mathbf{u}$ and $\mathbf{u}'$, and $d(\mathbf{u}, \mathbf{u}')$ is a distance function which measures the similarity of the two individuals.
\end{definition}
Recall that in the setting we consider, the mapping between individuals and predictions is defined to be $M(\mathbf{u}) := \mathbf{x}^\top \boldsymbol{\theta} + \hat{o} = (\mathbf{b} + \mathcal{E}\mathcal{E}^\top)^\top \boldsymbol{\theta} + \hat{o}$. The prediction an individual receives is deterministic, so a natural choice for $D(M(\mathbf{u}), M(\mathbf{u}'))$ is $|\hat{y} - \hat{y}'|$. We take a causal perspective when defining a metric $d(\mathbf{u}, \mathbf{u}')$ to measure the similarity of two individuals $\mathbf{u}$ and $\mathbf{u}'$. Intuitively, individuals that have similar initial causally-relevant features and ability to modify causally-relevant features should be treated similarly. Therefore, we define $d(\mathbf{u}, \mathbf{u}')$ to reflect the difference in causally-relevant components of $\mathbf{b}$ \& $\mathbf{b}'$ (initial feature values) and $\mathcal{E}\mathcal{E}^\top$ \& $\mathcal{E}'\mathcal{E}^{'\top}$ (ability to manipulate features).
With this in mind, we are now ready to define the criterion for individual fairness to be satisfied in the strategic learning setting.
\begin{definition}\label{def:IF}
In the strategic learning setting, individual fairness is satisfied if
\small
\begin{equation*}
\begin{aligned}
|\hat{y} - \hat{y}'| &\leq d(\mathbf{u}, \mathbf{u}')\\ &= \|\mathbf{b}_\mathcal{C} - \mathbf{b}'_\mathcal{C}\|_2 + \|(\mathcal{E}\mathcal{E}^\top)_\mathcal{C} - (\mathcal{E}'\mathcal{E}^{'\top})_\mathcal{C}\|_2,
\end{aligned}
\end{equation*}
\normalsize
where
\small
\begin{align*}
b_{\mathcal{C},i} &=
\begin{cases}
b_i & \text{if } i \in \mathcal{C}\\
0 & \text{otherwise}
\end{cases}
, &\\
(\mathcal{E}\mathcal{E}^\top)_{\mathcal{C},ij} &=
\begin{cases}
(\mathcal{E}\mathcal{E}^\top)_{ij} & \text{if } i \in \mathcal{C} \text{ or } j \in \mathcal{C}\\
0 & \text{otherwise}.
\end{cases}
\end{align*}
\normalsize
\end{definition}
Recall that $\mathcal{C} \subseteq \{1, \ldots, n\}$ denotes the set of indices of observable features $\mathbf{x}$ which are causally relevant to $y$ (i.e., $\theta^*_i \neq 0$ for $i \in \mathcal{C}$).
\begin{theorem}\label{thm:IF}
Assessment $\boldsymbol{\theta} = \boldsymbol{\theta}^*$ satisfies individual fairness for any two agents $\mathbf{u}$ and $\mathbf{u}'$.
\end{theorem}
\emph{Proof Sketch.} See Appendix \ref{sec:fairness-derivations} for the full proof, which follows straightforwardly from the Cauchy-Schwarz inequality and the definition of the matrix operator norm. (Our results are not dependent upon the specific matrix or vector norms used, analogous results will hold for other popular choices of norm.) Throughout the proof we assume that $\|\boldsymbol{\theta}^*\|_2 = 1$ by definition, although our results hold up to constant multiplicative factors if this is not the case.
While $\boldsymbol{\theta} = \boldsymbol{\theta}^*$ satisfies the criterion for individual fairness, this will generally not be the case for an arbitrary assessment $\boldsymbol{\theta} \neq \boldsymbol{\theta}^*$. For instance, consider the case where $d(\mathbf{u}, \mathbf{u}') = 0$ for two agents $\mathbf{u}$ and $\mathbf{u}'$. Under this setting, it is possible to express $|\hat{y} - \hat{y}'|$ using quantities which do not depend on $d(\mathbf{u}, \mathbf{u}')$. As these quantities increase, $|\hat{y} - \hat{y}'|$ increases as well, despite the fact that $d(\mathbf{u}, \mathbf{u}')$ remains constant.
\begin{theorem}\label{thm:IF-bound}
For any deployed assessment rule $\boldsymbol{\theta}$, the gap in predictions between two agents $\mathbf{u}$ and $\mathbf{u}'$ such that $d(\mathbf{u}, \mathbf{u}') = 0$ is
\begin{equation*}
\begin{aligned}
|\hat{y} - \hat{y}'| = &\left| \sum_{i \not \in \mathcal{C}} (b_i - b_i') \theta_i \right. \\ &\left.+ \sum_{i \not \in \mathcal{C}} \sum_{j \not \in \mathcal{C}} ((\mathcal{E}\mathcal{E}^\top)_{ij} - (\mathcal{E}'\mathcal{E}^{'\top})_{ij}) \theta_i \theta_j \right|\\
\end{aligned}
\end{equation*}
\end{theorem}
See Appendix \ref{sec:fairness-derivations} for the full derivation. Note that all components of $\boldsymbol{\theta}$ which appear in Theorem \ref{thm:IF-bound} are outside of the support of $\boldsymbol{\theta}^*$.
In order to illustrate how $|\hat{y} - \hat{y}'|$ can grow while $d(\mathbf{u}, \mathbf{u}')$ remains constant, consider the following example.
\begin{example}\label{ex:fairness}
Consider a setting in which the distance $d(\mathbf{u}, \mathbf{u}') = 0$ between agents $\mathbf{u}$ and $\mathbf{u}'$, and there is a one-to-one mapping between actions and observable features for each agent, with one agent having an advantage when it comes to manipulating features which are not causally relevant. Formally, let $\boldsymbol{\theta}^* = [\mathbf{0}_{n/2}^\top \;\; \sqrt{\frac{2}{n}} \mathbf{1}_{n/2}^\top]^\top$, $\mathbf{b} = \mathbf{b}'$, $\mathcal{E} = \boldsymbol{\delta} I_{n \times n}$, and $\mathcal{E}' = \boldsymbol{\delta}' I_{n \times n}$, where $\boldsymbol{\delta} = [\sqrt{n} \mathbf{1}_{n/2}^\top \;\; \mathbf{1}_{n/2}^\top]^\top$ and $\boldsymbol{\delta}' = [\mathbf{0}_{n/2}^\top \;\; \mathbf{1}_{n/2}^\top]^\top$.
Under such a setting, the equation in Theorem \ref{thm:IF-bound} simplifies to
\begin{equation*}
|\hat{y} - \hat{y}'| = n \sum_{i \not \in \mathcal{C}} \theta_i^2 = n \sum_{i = 1}^{n/2} \theta_i^2.
\end{equation*}
For the full derivation, see Appendix \ref{sec:fairness-derivations}. Suppose now that the assessment $\boldsymbol{\theta}$ puts weight at least $1/\sqrt{n}$ on each observable feature which is not causally relevant. Under such a setting, $|\hat{y} - \hat{y}'| \geq n/2$, meaning that the difference in predictions tends towards infinity as $n$ grows large, despite the fact that $d(\mathbf{u}, \mathbf{u}') = 0$ and $y = y'$!
\end{example}
\section{Impossibility of Recovering True Causal Effect under Changing Hidden Features}
\label{sec:impossibility}
Assume we have the one-dimensional setting
\begin{equation} \label{eq:x-and-h}
y_t = \theta^*x_t + \beta^* h_t + g(u_t),
\end{equation}
where $x_t$ are agent $t$'s observable, modifiable features, $h_t$ are the agent's unobsevable, modifiable features, and $g(u_t)$ is a function of agent $t$'s unobservable, unmodifiable features. We can assume $g(u_t) = 0$ in this section without loss of generality. If the relationship between $x_t$ and $h_t$ is unknown, then it is generally impossible to recover the true causal parameters $\theta^*$ and $\beta^*$ since $h_t$ is never observed and any assessment rule $\theta$ deployed by the decision maker affects both $x_t$ and $h_t$, meaning that $\theta$ is not a valid instrument variable. This behavior can be seen in \Cref{fig:general-model-dag}. \khcomment{maybe say something about how this shows up in the Shavit paper}\\
On the other hand, if the relationship between $x$ and $h$ is known, there exist situations for which it is impossible to recover $\theta^*$ and $\beta^*$, even in the limit of infinite data. For example, if $x \in \mathbb{R}$ and $h = x$, the models $\theta^* = 1$, $\beta^* = 1$ and $\theta^* = 1.5$, $\beta^* = 0.5$ produce the same output for all $x \in \mathbb{R}$, making it impossible to distinguish between the two.
\section{Introduction}\label{sec:intro}
\dndelete{
\begin{figure}
\begin{subfigure}[c]{0.48\textwidth}
\centering
\includegraphics[width=.8\textwidth]{figures/sciv-small-dag.png}
\caption{model}
\label{fig:model-dag}
\end{subfigure}
\hfill
\begin{subfigure}[c]{0.48\textwidth}
\centering
\includegraphics[width=\textwidth]{figures/sciv-example-dag.png}
\caption{example}
\label{fig:example-dag}
\end{subfigure}
\caption{Graphical model for our setting.\hhcomment{Where is effort in these diagrams?} Grey nodes are observed, white unobserved. Observable features $\mathbf{x}_t$ (such as high school GPA in different subjects, SAT scores, etc.) depend on both the agent's private type $u_t$ (e.g., first-generation vs. non-first-generation students) \hhdelete{via initial features $\mathbf{z}_t$ (e.g. the score student $t$ would receive on the SAT without studying)} and effort \hhdelete{conversion matrix $W_t$ (e.g. how much studying translates to an increase in SAT score for student $t$)} and assessment rule $\boldsymbol{\theta}_t$ (via action $\mathbf{a}_t$, which could correspond to studying, taking an SAT prep course, etc.). An agent's outcome $y_t$ (e.g. their college GPA) is determined by their observable features $\mathbf{x}_t$ (via causal relationship $\boldsymbol{\theta}^*$) and type $u_t$ (via confounding term $g_t$, e.g. lack of resources, discrimination, etc). \hhcomment{We are still introducing new notation in a caption! We should simplify this caption to the extent possible. Do not add new parts to the example here.}}
\label{fig:intro-dags}
\end{figure}
}
\begin{figure}
\begin{subfigure}[c]{0.42\textwidth}
\centering
\includegraphics[width=\textwidth]{figures/sciv-model-full-dag.png}
\caption{model}
\label{fig:model-dag}
\end{subfigure}
\hfill
\begin{subfigure}[c]{0.57\textwidth}
\centering
\includegraphics[width=1.1\textwidth]{figures/sciv-example-full-dag.png}
\caption{example}
\label{fig:example-dag}
\end{subfigure}
\caption{Full graphical model for our setting with accompanying example. Grey nodes are observed, white unobserved. Observable features $\mathbf{x}_t$ (e.g. high school GPA, SAT scores, etc.) depend on both the agent's private type $u_t$ (e.g., first-generation vs. non-first-generation students) via initial features $\mathbf{z}_t$ (e.g. the SAT score or HS GPA student $t$ would get without studying) and effort conversion matrix $W_t$ (e.g. how much studying translates to an increase in SAT score for student $t$) and assessment rule $\boldsymbol{\theta}_t$ via action $\mathbf{a}_t$, which could correspond to studying, taking an SAT prep course, etc). An agent's outcome $y_t$ (e.g. college GPA) is determined by their observable features $\mathbf{x}_t$ (via causal relationship $\boldsymbol{\theta}^*$) and type $u_t$ (via confounding term $g_t$, e.g. lack of resources, discrimination, etc).}
\label{fig:intro-dags}
\end{figure}
Machine learning (ML) algorithms increasingly automate or inform consequential decision-making processes such as college admissions, credit scoring, and resume screening. In many of these settings, the deployed predictive models or assessment rules may prompt the assessed individuals to strategically adapt their behavior to receive more favorable predictions. Motivated by this type of behavior, a long line of work on ``strategic learning'' studies machine learning problems where models make predictions on strategic agents \citep{dong2018strategic,hardt2016strategic, mendler2020stochastic, shavit2020strategic}. At a high level, much of the existing work in this literature has focused on developing robust algorithms that optimize predictive accuracy, while taking into account that agents will manipulate their features presented to the model.
Even though these algorithms for strategic learning can optimize predictive accuracy, they do not necessarily provide insights into the \emph{causal} relationships between the observable features and the outcomes, which are critical for many reasons. For example, knowledge of causal relationships can help agents identify meaningful interventions that can improve their outcomes, not just their assigned scores. Policymakers may use causal relationships to inform policy decisions and examine potential unfairness against certain sub-populations. \lsedit{For example, research showing the lack of causal effect that standardized test scores have on college performance has led many U.S. universities to abandon SAT and ACT scores in their admissions process \citep{allensworth2020gpasat,brooks2020cbsactsat}.} \swcomment{the refs are good, but the sentence seems a bit disconnected} Causal relationships can also help ensure robustness in predictive models so that they can reliably make accurate predictions even if the underlying covariate distributions have shifted over time.
In this work, we provide a general method for inferring causal relationships by establishing a novel connection between strategic learning and instrumental variable (IV) regression. By viewing the set of deployed predictive models as a form of instrumental variables, our framework can provably recover the causal relationships between the observable features and outcomes even in the presence of potential unobserved confounders. To describe our results, we will first introduce our model with college admissions as our running example.
\xhdr{Our model.} Consider the setting in which a university decides whether to admit or reject applicants on a rolling basis (for example, \cite{psbwebsite}) based (in part) on how well they are predicted to perform {if admitted to the} university. We model such interactions as a game between a \emph{principal} (e.g. a university) and a population of \emph{agents} (e.g. applicants) {who arrive} sequentially over $T$ rounds. In each round $t$, the principal deploys a linear assessment rule $\boldsymbol{\theta}_t$ that maps observable features $\mathbf{x}_t$ (e.g. applicants' standardized test scores, math GPA, science GPA, humanities GPA, number of extracurricular activities, etc.) to a \emph{predicted outcome} $\hat{y}_t$ (e.g. an applicant's predicted college GPA). Then given this deployed rule, the agent at round $t$ arrives with their (unobserved) private type $u_t$. {For example, the type may indicate whether or not an applicant is a \emph{first-generation} college student.} Agent types are drawn independently from a fixed distribution. Each agent $t$ aims to optimize their predicted outcome by putting forth effort $\mathbf{a}_t$, which changes their observable features $\mathbf{x}_t$ and subsequently their true outcome $y_t$. For instance, a student may choose to study individual subjects to improve their mastery of knowledge and relevant course grades, or they can take prep courses to improve their standardized test taking strategies and test scores. \khedit{\hhdelete{Even though one may ideally want to estimate the causal effect of each action or intervention available to each agent,} It is often unrealistic for the principal to directly observe efforts. Instead, the effort expended by an agent is reflected in their observable features. For example, a college application does not ask how much time an applicant has spent studying a certain subject, but it collects grades on relevant coursework. There is an underlying \emph{causal relationship} $\boldsymbol{\theta}^*$ between observable features $\mathbf{x}_t$ and outcome $y_t$, through these actions (reference figure here). In light of this, our goal is to recover the true causal relationship $\boldsymbol{\theta}^*$ between observable features and outcome.}
\hhcomment{If by 'action', you mean 'effort investment', use 'effort investment' consistently. }
\xhdr{Strategic regression as instruments.}
\iffalse
Under our model, we provide a general method to infer the causal relationship parameter $\boldsymbol{\theta}^*$. The main challenge in estimating $\boldsymbol{\theta}^*$ is that the features $\mathbf{x}_t$ correlate with the ``noise'' term $g_t$, since they are both associated with the agent's private type $u_t$\lsedit{, e.g. the mean college GPA for first-generation students (with no college-educated family) may be lower than other students, due to institutional barriers}. As a result, standard techniques like ordinary least squares (OLS) will generally recover a biased estimate. To overcome this bias, we make the novel observation that the principal's assessment rule $\boldsymbol{\theta}_t$ is a valid \emph{instrument}, since $\boldsymbol{\theta}_t$ is independent of $g_t$ and $\boldsymbol{\theta}_t$ influences the outcome $y_t$ only through its influences on an agent's action $\mathbf{a}_t$ and observable features $\mathbf{x}_t$. By leveraging this observation, we can perform two-stage least squares (2SLS) to recover the causal relationship $\boldsymbol{\theta}^*$. Our method applies to both \emph{off-policy} and \emph{on-policy} settings: one can directly apply 2SLS on historical data $\{(\boldsymbol{\theta}_t, \mathbf{x}_t, y_t) \}_{t=1}^T$, or the principal can intentionally deploy a sequence of varying assessment rules (by e.g., making small perturbations on a fixed rule $\boldsymbol{\theta}_t$) and then apply 2SLS on the collected data.
\fi
Under our model, we provide a general method to infer the causal relationship parameter $\boldsymbol{\theta}^*$. {Since} the agent's private type $u_t$ may introduce a \emph{confounding effect} on the outcome, standard regression techniques like ordinary least squares (OLS) will generally recover a \emph{biased} estimate. To overcome this bias, we make the novel observation that the principal's assessment rule $\boldsymbol{\theta}_t$ is a valid \emph{instrument}, and leverage this observation to perform two-stage least squares regression (2SLS) and recover the causal relationship $\boldsymbol{\theta}^*$. Our method applies to both \emph{off-policy} and \emph{on-policy} settings: one can directly apply 2SLS on historical data $\{(\boldsymbol{\theta}_t, \mathbf{x}_t, y_t) \}_{t=1}^T$, or the principal can intentionally deploy a sequence of varying assessment rules (by e.g., making small perturbations on a fixed rule $\boldsymbol{\theta}_t$) and then apply 2SLS on the collected data. \khcomment{What do you guys think now? I cut out a fair bit of the technical details to make it easier to understand for the reader. I'm hoping that keeping things general, along with our "simple" figures will be enough for the reader to get a high-level idea of what we're doing.}
\xhdr{Two relevant optimization problems.} We then study two natural optimization objectives, for which we can build our solutions given our knowledge of the causal relationship $\boldsymbol{\theta}^*$. We first study \emph{agent outcome maximization}: how to use assessment rules $\boldsymbol{\theta}_t$ as a form of intervention that incentivizes the population of agents to invest their efforts optimally so that their average outcomes ($y$) are maximized. Using parameters estimated during our 2SLS procedure, we can solve an optimization problem to recover an estimate of the assessment rule which maximizes expected agent outcome.
\iffalse
We show that our 2SLS method nicely recovers \khedit{an estimate of $\mathop{\mathbb{E}}[W_t W_t^\intercal] \boldsymbol{\theta}^*$ in its second stage} \khdelete{the two relevant estimates $\mathop{\mathbb{E}}[W_t W_t^\intercal]$ and $\boldsymbol{\theta}^*$ in its stages}, which allows us to maximize the expected agent outcome objective, which can be re-written as $\langle \boldsymbol{\theta}_t, \mathop{\mathbb{E}}[W_t W_t^\intercal] \boldsymbol{\theta}^* \rangle$.
\fi
We then study the problem of \emph{predictive risk minimization} that aims to minimize $\mathop{\mathbb{E}}[(\hat y_t - y_t)^2]$\khedit{, the expected squared difference between an agent's \emph{true} outcome and the outcome predicted by the principal}. Compared to standard regression, this is a more challenging objective since both the prediction $y_t$ and outcome $\hat y_t$ depend on the deployed rule $\boldsymbol{\theta}_t$, which leads to a non-convex risk function. We show that the knowledge of $\boldsymbol{\theta}^*$ enables us to compute an unbiased estimate of the gradient of the predictive risk. As a result, we can apply stochastic gradient descent to find a local minimum of the predictive risk function. \khcomment{Would like to say that performative prediction does not work well in practice in our setting.}
\iffalse
\khcomment{
Storyline:
\begin{itemize}
\item A growing line of work advocates for studying people's responses to algorithmic decision making tools---e.g., ways in which decision subjects can change their attributes to receive more desirable decisions.
\item The reasons that are often cited to support this call are: (1) investigating the ethicality (e.g., fairness) of a decision rule often requires knowledge of the \emph{true} relationships among certain variables of interest. (2) A good decision rule is one that contributes to better societal outcomes in the \emph{long-run}---by encouraging people to take steps that improve their future welfare.
\item Viewed in this light, algorithmic decision rules can serve as a means for social scientists and policy makers alike to understand and improve social outcomes.
\item Social scientists can treat these tools as a form of intervention that allows them to causally reason about the underlying dynamics (recovering true relationship between observable features and outcomes). Policy makers can design dynamic decision rules that nudge the population in their planned direction (maximizing social welfare in the long-run).
\end{itemize}}
\subsection{Running Example}
\khcomment{This section is for our benefit only}
Consider a university that admits students on a rolling basis and decides which applicants to admit based (in part) on how well they expect them to perform in university. The university uses an assessment based on standardized test scores, high school GPA (consisting of \emph{math}, \emph{science}, and \emph{humanities} GPA), number of extra-curricular activities, etc. for their admissions policy. There are two types of applicants: 1) \textit{first-generation students} who are the first of their family to go to college and 2) non-first generation students. These two types may have different distributions on their initial features, e.g. first-generation students may start off with lower standardized test scores or high school GPA, on average. The two different groups may also expend different amounts of effort to improve their features, e.g. a higher proportion of non-first generation students may have access to private tutoring, making it easier for them to improve their standardized test scores or GPA than first-generation students who need to study on their own. Finally, the true baseline outcome (success at university, measured by college GPA) of the two groups may differ beyond the causal effects of their observable features as well. These differing baseline outcomes can be modeled by a confounding term $g_t$ for each of the two types. In our college admissions example, the baseline university GPA for first-generation students may be lower due to institutional barriers --e.g. discrimination, lack of resources, etc.-- may not be present for non-first generation students.
Consider the setting in which a university decides whether to admit or reject applicants on a rolling basis (for example, \cite{psbwebsite}) based (in part) on how well they are predicted to perform in university. We study a game between a \emph{principal} (e.g. a university) and a population of \emph{agents} (e.g. applicants) over $T$ rounds. In each round $t$, the principal chooses to deploy an assessment rule $\boldsymbol{\theta}_t \in \mathbb{R}^m$ that \textit{linearly} maps an agent's observable features to a \emph{predicted outcome} $\hat{y}_t \in \mathbb{R}$ (e.g. an applicant's predicted college GPA). At time $t$, a new agent indexed by $t$ arrives with their \emph{observable} features $\mathbf{x}_t \in \mathbb{R}^m$ (e.g. applicants' standardized test scores, math GPA, science GPA, humanities GPA, number of extracurriculars, etc.). The principal assesses the applicant by computing
\begin{equation}\label{eq:predicted-outcome}
\hat{y}_t = \mathbf{x}_t^\top \boldsymbol{\theta}_t.
\end{equation}
The linearity assumption on the relationship between observable features $\mathbf{x}_t$ and the predicted outcome $y_t$ has been adopted in practice, e.g. in college GPA prediction based on high school GPA and SAT scores \citep{zwich} and is reflected in prior models of strategic learning~\citep{shavit2020strategic, dong2018strategic, BechavodLWZ21}.
\xhdr{Agent features and causal actions.}
If an applicant knows what features they will be evaluated on, they can do things to improve their chances of being admitted, like studying physics to improve their science GPA, taking an SAT prep course, or joining more extracurriculars. While some actions may be \emph{causally} related to college success, others may not be. For example, studying physics could be considered causally related to success in college, since this improves a student's knowledge and background on subjects they may learn more about at university. Even a student chooses not to study science in college, developing good problem solving techniques may be useful for other domains such as economics or computer programming. On the other hand, taking an SAT prep course may \emph{not} be causally related to success in college, especially if the prep course teaches students test-specific strategies that don't generalize well to other learning settings. Let agent $t$'s \emph{causal} relationship between actions and outcomes be defined by the vector $\boldsymbol{\mu}_t^*$. In our example, $\mu_{t,SAT}^*$ would be near zero for each student $t$.
While the principal may want to incentivize agents to invest effort in actions which are causally related to positive outcomes (e.g. those with high $\mu^*$ values), it is usually hard to learn which actions are causal in practice since agent actions are rarely observed. Instead, the principal usually only has access to the agent's observable features. With this in mind, a natural goal for the principal is to \emph{learn} the true underlying relationship between observable features and positive outcomes, and \emph{incentivize} agents to invest effort to improve these features by placing high emphasis on them in the assessment rule they choose to deploy. For example, if a university knew that studying for science coursework was causally related to success in college and studying for the SAT was not, they would want to increase the weight they place on science GPA and decrease the weight they place on students' SAT scores when making admissions decisions.
\fi
\section{Introduction}\label{sec:intro}
Machine learning (ML) predictions increasingly inform high-stakes decisions for people in areas such as college admissions~\citep{pangburn2019,Somvichian2021}, credit scoring~\citep{whitecase,rice2013discriminatory}, employment~\citep{sanchez2020does}, and beyond. One of the major criticisms against the use of ML in socially consequential domains is the failure of these technologies to identify \emph{causal} relationships among relevant attributes and the outcome of interest~\citep{kusner2017counterfactual}. The single-minded focus of ML on predictive accuracy has given rise to brittle predictive models that learn to rely on spurious correlations---and at times, harmful stereotypes---to achieve seemingly accurate predictions on held-out test data~\citep{sweeney2013discrimination,kusner2020long}. The resulting models frequently underperform in deployment, and their predictions can negatively impact decision subjects.
As an example of the long-term negative consequences of ML-based decision-making systems, they often prompt individuals to modify their observable attributes \emph{strategically} to receive more favorable predictions---and subsequently, decisions~\citep{hardt2016strategic}. These strategic responses are among the primary causes of distribution shifts (and subsequently, the unsatisfactory performance) of ML in high-stakes decision-making domains. Moreover, recent work has established the potential of these tools to amplify existing social disparities by \emph{incentivizing different effort investments} across distinct groups of subjects~\citep{liu2020disparate,heidari2019long,mouzannar2019fair}.
The above challenges have led to renewed calls on the ML community to strengthen their understanding of the connections between ML and causality~\citep{pearl2019seven,scholkopf2019causality}. Knowledge of causal relationships among predictive attributes and outcomes of interest promotes several desirable aims: First, ML practitioners can use this knowledge to debug their models and ensure robustness even if the underlying population shifts over time.
Second, policymakers can utilize the causal understanding of a domain in their policy choices and examine a decision-making system's compliance with policy goals and societal values (e.g., they can audit the system for unfairness against particular populations~\citep{loftus2018causal}).
Finally, predictions rooted in causal associations block undesirable pathways of gaming and manipulation and, instead, encourage decision subjects to make meaningful interventions that improve their actual outcomes (as opposed to their assessments alone).
Our work responds to the above calls by offering a new approach to recover causal relationships between observable features and the outcome of interest in the presence of strategic responses---without substantially hampering predictive accuracy. We consider settings where a decision-maker deploys a sequence of models to predict the outcome for a sequence of strategic decision subjects. Often in high-stakes decision-making settings such as the ones mentioned earlier, there are unobserved confounding variables that influence subjects' attributes and outcomes simultaneously. Our key observation is that we can correct for the effect of such confounders by viewing the sequence of \textbf{assessment rules as valid \emph{instruments}} which affect subjects' observable features but do not \emph{directly} influence their outcomes. Our main contribution is a general framework that recovers the causal relationships between observed attributes and the outcome of interest by treating assessment rules as instruments.
\iffalse
\hhdelete{
In numerous real-world applications, confounders taint the causal interpretation of data-driven decision-making tools, leading to the unwanted consequences outlined above (e.g., lack of robustness, gaming). For example, in the context of university admissions, research has shown that the socioeconomic background of a student can impact both their SAT scores and success in college~\citep{sackett2009socioeconomic}. In credit lending, lack of access to affordable credit affects not just the applicant's debt but also their likelihood of default~\citep{collard2005affordable}.
For concreteness, in the remainder of this section, we describe our setting and research problem using a stylized university admissions scenario as the running example. }
\fi
\subsection{Our Setting}
Next, we describe our theoretical setup in further detail, then proceed to an overview of our findings. For concreteness, we utilize a stylized university admissions scenario as our running example for the remainder of this section. However, the reader should note that our model is applicable to other real-world applications in which confounders taint the causal interpretation of predictive models. For example, in credit lending, lack of access to affordable credit affects not only the applicant's debt, but also their likelihood of default~\citep{collard2005affordable}.
In university admissions (which will be our running example), research has shown that the socioeconomic background of a student can impact both their SAT scores and success in college~\citep{sackett2009socioeconomic}.
With the running example in mind,
consider a stylized setting in which a university decides whether to admit or reject applicants on a rolling basis\footnote{See \citet{psbwebsite} for a list of such universities in the United States.} based (in part) on how well they are predicted to perform if admitted to the university (See \Cref{fig:intro-dags}). We model such interactions as a game between a \emph{principal} (here, the university) and a population of \emph{agents} (here, university applicants) who arrive sequentially over $T$ rounds, indexed by $t=1,2, \cdots, T$.
In each round $t$, the principal deploys an {assessment rule $\boldsymbol{\theta}_t \in \mathbb{R}^m$, which is used to assign agent $t$ a predicted outcome $\widehat{y}_t \in \mathbb{R}$}. In our running example, $\widehat{y}$ could correspond to the applicant's predicted college GPA if admitted. The predicted outcome is calculated based on certain observable/measured attributes of the agent, denoted by $\mathbf{x}_t \in \mathbb{R}^m$. For example, in the case of a university applicant, these attributes may include the applicants' standardized test scores, high school math GPA, science GPA, humanities GPA, and their extracurricular activities. For simplicity, we assume all assessment rules are \emph{linear}, that is, $\hat{y}_t = \mathbf{x}_t^\top \boldsymbol{\theta}_t + \hat{o}_t$ for all $t$. (Where $\hat{o}_t$ is the current estimate of the expected offset term $\mathop{\mathbb{E}}[o_t]$.) This linear setup corresponds to an instance of the \emph{partially linear regression model} (originally due to \citet{robinson1988root}), a commonly studied setting in both the causal inference and strategic learning literature (e.g., \citet{shavit2020strategic, kleinberg2020classifiers, BechavodLWZ21}).
\xhdr{Measured vs. latent variables.}
We assume that the agent best-responds to the assessment rule $\boldsymbol{\theta}_t$ by strategically modifying their observable attributes $\mathbf{x}_t$ to receive a more favorable predicted outcome. Often agents cannot modify the value of their measured attributes (e.g., SAT score) directly, but only through investing effort in certain activities that are difficult to measure.
For example, a student might take standardized test preparation courses to improve their SAT scores, or they may spend time studying the respective subjects to improve their math and humanities GPA.
\xhdr{Latent variables: effort investments.} We formalize the above hidden investments with a vector $\mathbf{a}_t \in \mathbb{R}^d$, capturing the unobservable efforts agent $t$ invests in $d$ \emph{activities} in response to the assessment rule $\boldsymbol{\theta}_t$. We assume there exists a linear mapping $\mathcal{E}_t$ which translates efforts to changes in observable attributes for agent $t$. The $(k,j)$-th entry of this effort conversion matrix defines the change in the $k$-th observable attribute of agent $t$, $\mathbf{x}_{t}$, for one unit increase in the $j$th coordinate of their effort vector $\mathbf{a}_t$.
\begin{figure*}
\centering
\includegraphics[width=\textwidth]{figures/sciv-dag.png}
\caption{Graphical model for our setting (left) along with the way it corresponds to the admissions running example (right). Grey nodes are observed, white unobserved. Observable features $\mathbf{x}_t$ (e.g. high school GPA, SAT scores, etc.) depend on both the agent's private type $\mathbf{u}_t$ (e.g. a student's background) via initial features $\mathbf{b}_t$ (e.g. the SAT score or HS GPA student $t$ would get without studying) and effort conversion matrix $\mathcal{E}_t$ (e.g. how much studying translates to an increase in SAT score for student $t$) and assessment rule $\boldsymbol{\theta}_t$ via action $\mathbf{a}_t$, which could correspond to studying, taking an SAT prep course, etc). An agent's outcome $y_t$ (e.g. college GPA) is determined by their observable features $\mathbf{x}_t$ (via causal relationship $\boldsymbol{\theta}^*$) and type $\mathbf{u}_t$ (via baseline outcome error term $o_t$, which could be lower for students from underserved groups due to institutional barriers, discrimination, etc).}
\label{fig:intro-dags}
\end{figure*}
\xhdr{Latent variables: agent types.}
Each agent $t$ has an unobserved private type $\mathbf{u}_t$ that can impact both their observed attributes $\mathbf{x}_t$ and true outcomes $y_t$. (The type is the confounder we would like to correct for.) In our running example, the type may broadly refer to the student's relevant background factors that cannot be directly observed or measured. For example, the student's type can specify their socioeconomic background factors (including the level of educational support they receive within their immediate family), as well as their interest and skills in specific subjects such as English or Mathematics.\footnote{Note that later in Section \ref{sec:experiment}, we use the terminology of agent \emph{subpopulations}. Subpopulations are distinct from types in that subpopulations determine the \emph{distribution} of types, but individual agents belonging to the same subpopulation may have different types. We will elaborate on this in Section \ref{sec:experiment}.}
Formally, we assume the type $\mathbf{u}_t$ characterizes several relevant latent attributes of the agent, which we refer to using the tuple $\mathbf{u}_t := (\mathbf{b}_t, \mathcal{E}_t, o_t)$:
\begin{itemize}[noitemsep,nolistsep]
\item $\mathbf{b}_t \in \mathbb{R}^m$ specifies agent $t$'s baseline observable attribute values. For example, it can specify the baseline values of high school grades and SAT score the student would have received without any effort spent studying or preparing for standardized tests.
\item $\mathcal{E}_t$ specifies agent $t$'s \emph{effort conversion matrix}---that is, how various effort investments in unobservable activities translate to changes in observable features.
\item $o_t$ summarizes all other environmental factors that can impact the agent's true outcome when we control for observable attributes. For example, it may reflect the effect of the institutional barriers the student faces on their actual college GPA.
\end{itemize}
We assume agent $t$'s observable features are affected by their type and effort investments. In particular, we assume they take the form $\mathbf{x}_t = \mathbf{b}_t + \mathcal{E}_t \mathbf{a}_t$.
\xhdr{Agent best responses.}
We assume the agent selects their effort profile $\mathbf{a}_t$ in order to maximize their predicted outcome $\hat{y}_t$, subject to some \emph{effort} cost $c(\cdot)$ associated with modifying their observable attributes. In particular, we assume the cost function is quadratic, that $c(\mathbf{a}_t) = \frac{1}{2} \|\mathbf{a}_t\|^2_2$. (Note that this assumption is common in the strategic learning literature; see, e.g., \cite{shavit2020strategic, mendler2020stochastic, dong2018strategic}). Formally, we assume agent $t$ selects their effort $\mathbf{a}_t$ by solving the following optimization problem: $\max_{\mathbf{a}} \left\{ \hat{y}_t - \frac{1}{2} \|\mathbf{a}\|^2_2 \right\}$.
It is easy to see that for a given deployed assessment rule $\boldsymbol{\theta}_t$, the agent's best-response effort investment is $\mathbf{a}_t = \mathcal{E}_t^\top \boldsymbol{\theta}_t$.
\xhdr{True causal outcome model.} \emph{After} each round, the principal gets to observe the agent's true outcome $y_t \in \mathbb{R}$, which takes the form $y_t = \mathbf{x}_t^\top \boldsymbol{\theta}^{*} + o_t$.
\iffalse
\small
\begin{equation*}
y_t = \mathbf{x}_t^\top \boldsymbol{\theta}^{*} + o_t.
\end{equation*}
\normalsize
\fi
Here $\boldsymbol{\theta}^*$ is the \emph{true causal} relationship between an agent's observable features and outcome. (Recall that $o_t \in \mathbb{R}$ captures the dependence of agent $t$'s outcome $y_t$ on unobservable or unmeasured factors.)
We are interested in learning $\boldsymbol{\theta}^* \in \mathbb{R}^m$, which can be interpreted as specifying how interventions impacting the value of $\mathbf{x}$ lead to changes in $y$. Therefore, we say that an observable feature $x_i$ is \emph{causally relevant} if $\theta^*_i \neq 0$. For convenience, throughout we denote the subset of causally-relevant features by $\mathbf{x}_\mathcal{C}$, where $\mathcal{C} \subseteq [n], \forall i \in \mathcal{C}$ if $\theta^*_i \neq 0$.
\iffalse
\lsdelete{\begin{figure}
\begin{subfigure}[t]{0.4\textwidth}
\centering
\includegraphics[width=\textwidth]{figures/sciv-model-full-dag.png}
\caption{model}
\label{fig:model-dag}
\end{subfigure}
~
\begin{subfigure}[t]{0.55\textwidth}
\centering
\includegraphics[width=\textwidth]{figures/sciv-example-full-dag.png}
\caption{example}
\label{fig:example-dag}
\end{subfigure}
\caption{Graphical model for our setting with accompanying example. Grey nodes are observed, white unobserved. Observed features $\mathbf{x}_t$ (e.g. high school GPA, SAT scores, etc.) depend on both the agent's private type $\mathbf{u}_t$ (e.g., first-generation vs. non-first-generation students) via initial features $\mathbf{b}_t$ (e.g. the SAT score or HS GPA student $t$ would get without studying) and effort conversion matrix $\mathcal{E}_t$ (e.g. how much studying translates to an increase in SAT score for student $t$) and assessment rule $\boldsymbol{\theta}_t$ via action $\mathbf{a}_t$, which could correspond to studying, taking an SAT prep course, etc.). An agent's outcome $y_t$ (e.g. college GPA) is determined by their observable features $\mathbf{x}_t$ (via causal relationship $\boldsymbol{\theta}^*$) and type $\mathbf{u}_t$ (via confounding term $o_t$, e.g. lack of resources, discrimination, etc.).}
\label{fig:intro-dags}
\end{figure}
\fi
\subsection{Overview of Results}
%
\xhdr{Strategic regression as instruments.}
Since $\mathbf{b}_t$, $\mathcal{E}_t$, and $o_t$ may be correlated with one another, ordinary least squares generally will \emph{not} produce a consistent estimator for $\boldsymbol{\theta}^*$ (see \Cref{sec:ols} for details).
We make the novel observation that the principal's assessment rule $\boldsymbol{\theta}_t$ is a valid \emph{instrument}, and leverage this observation to recover $\boldsymbol{\theta}^*$ via Two-Stage Least Squares regression (2SLS). Our method applies to both \emph{off-policy} and \emph{on-policy} settings: one can directly apply 2SLS on historical data $\{(\boldsymbol{\theta}_t, \mathbf{x}_t, y_t) \}_{t=1}^T$, or the principal can intentionally deploy a sequence of varying assessment rules (e.g., by making small perturbations on a fixed rule) and then apply 2SLS on the collected data.
Additionally, we show that our recovery of $\boldsymbol{\theta}^*$ can be utilized to improve decision-making across several desired criteria, namely, individual fairness, agent outcomes, and predictive risk.
\xhdr{(Non-)causal assessment rules and fairness.}
In Section~\ref{sec:fairness}, we analyze the individual-level disparities that may result if the assessment rule deviates from $\boldsymbol{\theta}^*$. Unlike most existing definitions of individual fairness, which rely on the observed characteristics of individuals, our definition measures the similarity between two individuals solely by comparing their $\mathbf{b}$'s and $\mathcal{E}$'s---that is, we consider two individuals to be similar if they have the same baseline values for causally relevant observable features and similar potentials for improving these observable attributes through effort investments. Individual fairness then requires similar individuals to receive similar decisions. (We note that while our notion of individual fairness may not be easy to estimate using observational data, it is a more fine-grained---and arguably better justified---notion of individual fairness, as it distinguishes between the causally relevant and causally irrelevant facets of observable features.) We show that when making predictions using $\boldsymbol{\theta} = \boldsymbol{\theta}^*$, our notion of individual fairness is satisfied, but when the assessment rule deviates from $\boldsymbol{\theta}^*$, i.e., $\boldsymbol{\theta} \neq \boldsymbol{\theta}^*$, individual fairness may be violated by an arbitrarily large amount.
%
\iffalse
\hhdelete{
\xhdr{Additional optimization objectives.} Beyond causal recovery, we show that one can build on our 2SLS method estimating $\boldsymbol{\theta}^*$ and address two relevant optimization problems: \emph{agent outcome maximization} and \emph{predictive risk minimization}. }
\fi
\xhdr{Agent outcome maximization.}
Note that a decision-maker can use the assessment rule $\boldsymbol{\theta}$ as a form of intervention to incentivize agents to invest their efforts optimally toward maximizing their outcomes ($y$). In Section~\ref{sec:agent-outcome}, we show that utilizing the causal parameters recovered during our 2SLS procedure, one can find the assessment rule maximizing expected agent outcomes.
\xhdr{Predictive risk minimization.}
Another commonly-studied goal for decision-makers is \emph{predictive risk minimization},
which aims to minimize $\mathop{\mathbb{E}}[(\hat y_t - y_t)^2]$, the expected squared difference between an agent's \emph{true} outcome and the outcome predicted by the assessment. Compared to standard regression, this is a more challenging objective since both the prediction $\hat y_t$ and outcome $y_t$ depend on the deployed rule $\boldsymbol{\theta}_t$. This leads to a non-convex risk function. In Section~\ref{sec:prm}, we show that the knowledge of $\boldsymbol{\theta}^*$ enables us to compute an unbiased estimate of the gradient of the predictive risk. As a result, we can apply stochastic gradient descent to find a local minimum of predictive risk function.
\xhdr{Empirical observations.}
In Section~\ref{sec:experiment}, we empirically confirm and illustrate the performance of our algorithm. In particular,
for a semi-synthetic dataset inspired by our university admissions example, we observe that our methods consistently estimate the true causal relationship between observable features and outcomes (at a rate of $\mathcal{O}(1/\sqrt{T})$), whereas OLS does not. Notably, OLS mistakenly estimates that SAT is causally related to college GPA, even though our experimental setup assumes it is not. On the other hand, our 2SLS-based method avoids this erroneous estimation. We also show that our methods outperform standard SGD methods in the predictive risk minimization setting.
\input{related_short}
\section{Model}\label{sec:model}
In our model, the principal deploys a linear assessment rule $\boldsymbol{\theta}_t \in \mathbb{R}^m$ at each time-step, and assigns agent $t$ a predicted outcome $\widehat{y}_t = \mathbf{x}_t^\top \boldsymbol{\theta}_t \in \mathbb{R}$, where $\mathbf{x}_t \in \mathbb{R}^m$ are the agent's observable features.
We assume that the agent best-responds to the assessment rule $\boldsymbol{\theta}_t$ by strategically playing a set of observable features $\mathbf{x}_t$ in order to receive a favorable predicted outcome $\hat{y}_t$, subject to some \emph{effort} cost $c(\cdot)$ associated with modifying their feature values. For example, a prospective student might take more standardized test preparation, which could significantly improve their SAT scores, as well as have a slight positive impact on their math and humanities GPA. Specifically, we assume agent $t$'s observable features take the form
\begin{equation*}
\mathbf{x}_t = \mathbf{z}_t + W_t \mathbf{a}_t,
\end{equation*}
where $\mathbf{z}_t \in \mathbb{R}^m$ are agent $t$'s initial, \emph{unobserved} feature values, $W_t$ is agent $t$'s \emph{effort conversion matrix}, and $\mathbf{a}_t \in \mathbb{R}^d$ is the \emph{action} agent $t$ takes in response to the assessment rule $\boldsymbol{\theta}_t$. The effort conversion matrix $W_t$ maps changes in effort to changes in observable features. The $(k,j)$-th entry of $W$ defines the change in the $k$-th observable feature $x_{t,k}$ for a one unit increase in the $j$th coordinate of the effort vector $\mathbf{a}_t$. \swdelete{For example, studying for a standardized test might correspond to a column $W_1 = (10, 0.4, 0, 0.3)^\intercal$ in the effort conversion matrix, in which the four entries represent a large increase in SAT score, small increase in math GPA, no change in science GPA, and a small increase in humanities GPA, respectively.} Importantly, our model allows for the effort conversion matrix $W_t$ to vary between different types.\swcomment{we didn't define types}
We assume that the agent selects their effort profile $\mathbf{a}_t$ in order to maximize their predicted outcome $\hat{y}_t$, subject to a quadratic cost penalty, a common assumption in the strategic classification literature (\cite{shavit2020strategic, mendler2020stochastic, dong2018strategic}). In this work, we choose the quadratic cost $c(\mathbf{a}_t) = \frac{1}{2} \|\mathbf{a}_t\|^2_2$. Specifically, we assume that agents select their action $\mathbf{a}_t$ by solving the following optimization problem:
\begin{equation*}
\mathbf{a}_t = \argmax_{\mathbf{a}} \left\{ \hat{y}_t - \frac{1}{2} \|\mathbf{a}\|^2_2 \right\}
\end{equation*}
We can obtain a closed-form solution for agent $t$'s action $\mathbf{a}_t$ by substituting in the expression for agent $t$'s predicted outcome $\hat{y}_t$ and observable features $\mathbf{x}_t$. Doing this, we see that $\mathbf{a}_t$ takes the form
\begin{equation*}
\mathbf{a}_t = W_t^\top \boldsymbol{\theta}_t.
\end{equation*}
\iffalse
It is now possible to formally define the causal relationship $\boldsymbol{\mu}^*_t$ between actions and outcomes for an agent $t$ as
\begin{equation*}
\boldsymbol{\mu}^*_t = W_t^\top \boldsymbol{\theta}^*.
\end{equation*}
$\boldsymbol{\mu}^*_t$ represents how much actions are causally related to outcomes for agent $t$. Note that $\boldsymbol{\mu}^*_t$ may vary from agent to agent. For example, some students may have an easier time mastering the subjects necessary for success in college than others, meaning that they need to expend less effort in order to achieve the same collegiate success.
In order for a unique $\boldsymbol{\theta}^*$ to exist, the following condition on observable features $\mathbf{x}_t$ and actions $\mathbf{a}_t$ must hold.
\begin{assumption}[Identifiability]
For every agent $t$, no two different actions should be able to produce the same set of observable features. In other words, if $\mathbf{a}_t \neq \mathbf{a}_t'$ then $\mathbf{x}_t \neq \mathbf{x}_t'$.
\end{assumption}
\hhcomment{Doesn't this assumption imply that one can uniquely infer actions from observables? If so, this casts doubt on our premise that the principal cannot observe the actions directly.} \khcomment{I don't think so, since the principal never gets to observe $W_t$.}
If this assumption does not hold, there could be multiple $\boldsymbol{\theta}^*$ which map to the same $\boldsymbol{\mu}_t^*$. However, as long as the principal has access to sufficiently many observable features when predicting agent outcome this assumption should hold.
\hhcomment{So the above assumption is stronger than invertibility of $W$, right? If so, we should clearly say why we need this extra strong assumption.}
\fi
\iffalse
The agent's private type $u_t$ includes their unmodified feature $\mathbf{z}_t \in \mathbb{R}^m$ before any effort $\mathbf{a}_t$, their effort conversion matrix $W_t \in \mathbb{R}^{m \times d}$, which determines how their efforts translate to changes in $\mathbf{x}_t$, and their baseline outcome $g_t$, that captures other unobserved factors that influence the outcome.
\fi
\xhdr{True outcome model.} \emph{After} each round, the principal gets to observe the agent's true outcome $y_t \in \mathbb{R}$ (e.g. an applicant's true college GPA), which takes the form
\begin{equation*}
y_t = \mathbf{x}_t^\top \boldsymbol{\theta}^{*} + g_t
\end{equation*}
Here $\boldsymbol{\theta}^*$ is the \emph{true} relationship between an agent's observable features and outcome, and $g_t \in \mathbb{R}$ is an unobserved confounding term which captures the dependence of agent $t$'s outcome $y_t$ on factors other than their observable features.
An example of a confounding term in our college admissions example may be institutional barriers --e.g. discrimination or lack of resources, which could cause first-generation students to have less collegiate success than non-first generation students students, irregardless of their observable features. In this setting, $g_t$ would be negative for first-generation students and positive for non-first generation students, on average.
\hhcomment{The example above should have appeared way earlier.}
\dndelete{
\begin{figure}
\begin{subfigure}[c]{0.42\textwidth}
\centering
\includegraphics[width=\textwidth]{figures/sciv-model-full-dag.png}
\caption{model}
\label{fig:model-dag}
\end{subfigure}
\hfill
\begin{subfigure}[c]{0.57\textwidth}
\centering
\includegraphics[width=1.1\textwidth]{figures/sciv-example-full-dag.png}
\caption{example}
\label{fig:example-dag}
\end{subfigure}
\caption{Full graphical model for our setting with accompanying example. Grey nodes are observed, white unobserved. Observable features $\mathbf{x}_t$ (e.g. high school GPA, SAT scores, etc.) depend on both the agent's private type $u_t$ (e.g., first-generation vs. non-first-generation students) via initial features $\mathbf{z}_t$ (e.g. the SAT score or HS GPA student $t$ would get without studying) and effort conversion matrix $W_t$ (e.g. how much studying translates to an increase in SAT score for student $t$) and assessment rule $\boldsymbol{\theta}_t$ via action $\mathbf{a}_t$, which could correspond to studying, taking an SAT prep course, etc). An agent's outcome $y_t$ (e.g. college GPA) is determined by their observable features $\mathbf{x}_t$ (via causal relationship $\boldsymbol{\theta}^*$) and type $u_t$ (via confounding term $g_t$, e.g. lack of resources, discrimination, etc).}
\label{fig:intro-dags}
\end{figure}
}
\lsdelete{
\begin{figure}[]
\centering
\begin{tikzpicture}[node distance={15mm}, thick, main/.style = {draw, circle}]
\node[draw,circle,fill=lightgray] (1) {$\boldsymbol{\theta}_t$};
\node[draw,circle,fill=lightgray] (2) [right of=1] {$\mathbf{x}_t$};
\node[main] (3) [below of=2] {$u_t$};
\node[draw,circle,fill=lightgray] (4) [right of=2] {$y_t$};
\draw[->] (1) -- node[above] {$\mathbf{a}_t$} (2);
\draw[->] (3) -- node[left] {$\mathbf{z}_t$, $W_t$} (2);
\draw[->] (3) -- node[below right=-0.15cm] {$g_t$} (4);
\draw[->] (2) -- node[above] {$\boldsymbol{\theta}^*$} (4);
\end{tikzpicture}
\caption{Graphical model for our setting. Grey nodes are observed, white unobserved. Observable features $\mathbf{x}_t$ (such as high school GPA in different subjects, SAT scores, etc.) depend on both the agent's private type $u_t$ (e.g., first-generation vs. non-first-generation students) via initial features $\mathbf{z}_t$ (e.g. the score student $t$ would receive on the SAT without studying) and effort conversion matrix $W_t$ (e.g. how much studying translates to an increase in SAT score for student $t$) and assessment rule $\boldsymbol{\theta}_t$ (via action $\mathbf{a}_t$, which could correspond to studying, taking an SAT prep course, etc.). An agent's outcome $y_t$ (e.g. their college GPA) is determined by their observable features $\mathbf{x}_t$ (via causal relationship $\boldsymbol{\theta}^*$) and type $u_t$ (via confounding term $g_t$, e.g. lack of resources, discrimination, etc.).}
\label{fig:model-dag}
\end{figure}
\iffalse
When thinking about $g_t$, it helps to consider two types of applicants ---\textit{first-generation} students (the first in their family to go to college) and non-first-generation students (who are not): first-generation students may have lower baseline college GPA than legacy students due to institutional barriers or lack of resources. Together these factors determine the observable features and outcomes via two equations (also see Figure~\ref{fig:model-dag}):
\begin{equation*}
\mathbf{x}_t = \mathbf{z}_t + W_t \mathbf{a}_t, \qquad y_t = \langle \boldsymbol{\theta}^*, \mathbf{x}_t \rangle + g_t,
\end{equation*}
where $\boldsymbol{\theta}^* \in \mathbb{R}^m$ is the \emph{causal relationship parameters} between the observable features and outcome we wish to recover. For example, first-generation students and non-first-generation students may have substantially different effort-conversion matrices $W_t$, since a smaller proportion of first-generation students may have access to resources such as private tutoring which could help them improve their test scores and course grades more efficiently.
\fi
The agent's private type $u_t$, drawn from some arbitrary distribution $\mathcal{P}$, specifies the agent's $(\mathbf{z}_t, W_t, g_t)$ tuple. Note that we make no assumptions on the distribution over $\mathcal{P}$, meaning $\mathbf{z}_t$, $W_t$, and $g_t$ may be correlated with one another. Because of this, ordinary least squares will generally \emph{not} be a consistent estimator for $\boldsymbol{\theta}^*$ (see \Cref{sec:ols} for more details). Instead, if we wish to estimate the true relationship between observable features and outcomes, a method which decouples the contributions of the agent's observable features $\mathbf{x}_t$ and confounder $g_t$ to his outcome, such as instrumental variable regression, must be used. Estimating this true relationship is important because features which are primarily modifiable through causal actions will have a strong relationship with positive agent outcomes, whereas features which are easily modifiable through non-causal actions will not.
\iffalse
\khcomment{old summary of Shavit}
They provide algorithms for optimizing three decision-maker objectives: agent outcome maximization, prediction risk minimization, and parameter estimation. Our setting differs from theirs in a number of important aspects. First, \cite{shavit2020strategic} assume an agent's hidden features can be changed through strategic manipulation, while we assume that an agent's private type (which includes the agent's unobservable features) is an unmodifiable property of the agent. Ours is ostensibly a less general setting than \cite{shavit2020strategic}: however, we demonstrate that parameter recovery is, in general, impossible if agents' hidden features can be manipulated. This is likely why \cite{shavit2020strategic} assume that all features of an agent are observable to do causal inference. This illuminates a second difference, that we can recover causal parameters without observing all agent features (their private type captures unobservable features). Third, whereas \cite{shavit2020strategic} optimize for a single objective at a time, we identify natural learning dynamics which either minimize prediction risk or maximize agent outcome while estimating causal parameters. Moreover, we provide a regret-based analysis: \cite{shavit2020strategic} do not.
Finally, \cite{shavit2020strategic} assume a homogeneous population wherein agents’ initial features are identically distributed. However, this may not be a realistic assumption in many cases: \cite{hu2020disparate} explicitly consider strategic learning in a ``world of social stratification'' wherein an advantaged group of people has (on average) better initial features and exerts less effort to change their features than a disadvantaged group (p.2). Our work extends this heterogeneous setting so that an agent's \emph{unobserved type} determines how their initial features are distributed, influences the reward that the agent receives and how much effort is needed to change their features (see \Cref{fig:model-dag} for our model). \dncomment{Currently using same effort conversion matrix for everyone, but if we can have different matrices, then add to this sentence?} Consider an example to justify this setting: first-generation students, on average, have worse educational records when applying to university than continuing-generation students; also, first-generation students generally perform worse than continuing-generation students in university ---possibly due to discrimination or other institutional barriers. Due to the confounding between agents' unobserved initial features and the true outcomes they receive, ordinary least squares regression ---such as in \cite{shavit2020strategic}--- will produce a biased estimator of agents' causal parameters in this case. We remedy this problem by considering the assessment rule an instrumental variable (IV) and consistently recovering causal parameters via IV regression.
\fi
\section{Introduction}
\swcomment{
\begin{itemize}
\item Related work.
\item describe how this model can still be viewed as an MAB problem if we have fully BIC---that is, we average out the baseline reward across types
\end{itemize}
}
In many online recommendation systems, including Netflix, Amazon, Yelp, Stubhub, and Waze, users are both consumers and producers of information. Users make their selections based on recommendations from the system, and the system collects data about the users' experiences to provide better-quality recommendations for future users. To ensure the quality of its recommendations, the system typically needs to balance between \emph{exploration}---selecting potentially suboptimal options for the sake of acquiring new information---and \emph{exploitation}---selecting the best option given the available information. However, there is an inherent tension between exploration and the users' incentives---since each user is primarily concerned with their short-term utility, their incentives naturally favor exploitation.
To resolve this tension between exploration and incentives, a long line of work started by~\cite{KremerMP13, mansour2015bic} has studied mechanisms that incentivize users to explore by leveraging the information asymmetry between the recommendation system and users \citep{MansourSSW16, ImmorlicaMSW19, SS20}. These papers consider a simple multi-armed bandit model, where the recommendation system is a social planner who interacts with a sequence of self-interested agents. The agents arrive one by one to choose from a given set of alternatives (or called actions or arms) and receive a reward for their choice. Upon the arrival of each agent, the social planner provides a recommendation (one of the alternatives) that influences the agent's selection. The problem is to design a recommendation policy that incentivizes the agents to perform exploration and in the long run maximize the cumulative rewards of all the agents.
Prior work on "incentivizing exploration" typically approaches the problem by enforcing \emph{Bayesian incentive-compatibility} (BIC) for every agent---that is, it is in each agent's interest to follow the planner's recommendation even if such action is inferior according to their prior belief. To achieve BIC, these mechanisms typically need to assume a strong assumption that all of the agents and the planner share a \emph{common prior} over the rewards of actions. However, in reality, agents tend to be inherently heterogeneous in terms of their beliefs and perceived rewards. In particular, some agents can have a stronger bias that favors one action over others and different agents. Moreover, even if the actions have the same effects on all of the agents, their realized or observed utilities can be different. For example, different patients taking the same drug may report levels of pain and different drivers taking the same route may have different commute time.
\begin{example}[Motivating Example: Sales Campaign] A bank wants to estimate the return on investment (ROI) of a sales intervention wherein a salesperson offers a high rate of return on a savings account if a client deposits a large sum of money into the account.
On each day $t$, a client is assigned a particular sales person, who may or may not take the intervention. If the salesperson offers the intervention ($x_t=1$ in our model) the bank incurs a cost $c_t$ to pay out on the savings account (which is given by the rate of return and the deposit amount) and generates revenue $r_t$, since the clients may be more likely to open up other accounts, e.g. credit cards or investment accounts, which generate profit over time. If the salesperson takes the control ($x_t=0$ in our model), the cost and revenue are zero. In our model, the population return caused by the intervention is given by $\theta = \mathop{\mathbb{E}}[r_t-c_t | x_t=1]$ and the instances of $r_t-c_t$ are randomly given by $\theta x_t + \varepsilon_t$.
As such, the bank could estimate the return $\theta$ caused by the intervention by simply calculating the mean return under the intervention or the control. However, the clients also generate some baseline revenue, which is independent from the sales intervention. This baseline revenue $g(u_t)$ is given by the client’s \textit{type} ($u_t$ in our model), which also determines the salesperson’s expectation of the cost and revenue of the sales intervention. For example, the client’s type could be that they're a wealthy law firm with a lot of investable assets: the client generates high baseline revenue because they have a lot of money invested in the bank, of which the bank takes a percentage fee; as well, the salesperson anticipates that the law firm will deposit a lot of money into the savings account --incurring high cost $c_t$-- without opening any additional accounts --low revenue $r_t$.
Notably, the bank only observes whether or not the salesperson takes the intervention and the net revenue $y_t$ (given in equation~\eqref{eq:reward-model}). Since the unobserved baseline revenue $g(u_t)$ is correlated with the salesperson’s choice $x_t$, this causes confounding and the bank can no longer estimate the intervention return by simply taking the mean.
As such, the bank deploys a daily recommendation platform for the sales team, so as to optimize the bank's overall net revenue. Each day, the recommendation $z_t$ is based on the history $H_t$ of the intervention, i.e. all the past recommendations $z_t$, actions taken $x_t$, and the net revenues $y_t$.
Each salesperson $t$, considers this recommendation and their prior belief about the expected net revenue caused by the sales intervention, to decide whether to take the intervention or not, as in equation~\eqref{eq:two-arm-general-selection-function}. \lscomment{The recommendation may sway some risk-averse salespeople to take the intervention and some risky salespeople to take the control, causing more variability over the types.} The bank uses the recommendation $z_t$ as an instrument to better estimate the net revenue caused by the intervention $\theta$, as we expand upon in the following section.
\lscomment{End of bank example}
\iffalse
Consider a corporation that wants to estimate the average effect of interventions that the sales team can take on their customers (e.g. outreach phone calls, offering discounts or free credits), on the revenue of their customers. The corporation wants to deploy a daily recommendation platform for the sales team, so as to optimize operations and learn best practices. We consider a simplified setting where there is only a single type of intervention and the corporation does not know its return on investment (ROI). On each day $t$, a customer is assigned a particular sales person, who may or may not take the intervention. We assume that the effect of the intervention is observed at the end of the day (e.g. whether a purchase was made; this can also be replaced by some other short-term proxy/signal of long-term revenue, if long-term revenue is the goal).\footnote{The setting can also be easily relaxed with batches of customers each day (this can be thought as a method of online experimentation and active learning from the corporation).} The corporation is trying to identify the net effect of the intervention: this corresponds to some revenue lift $\delta$ minus a (potentially known) intervention cost $c$.
We model this scenario as bandits learning of two actions, where action 1 is "not taking intervention" and action 2 is "taking intervention". Then the net effect of the intervention is $\theta^2 = \delta - c$. Moreover, when no intervention is taken, then no lift in the revenue is observed and no cost is paid, rather the customer is expected to generate an organic, baseline amount of revenue $g(u_t)$, and so $\theta^1 = 0$. Here $u_t$ is an unobserved type of the customer, that is not known to the principal, but is observed by the sales person. This signal $u_t$ essentially captures the information asymmetry of the setting: sales people know more about the customers that they are working with than the corporation (e.g. whether they are about to grow, whether they are about to sign a big contract, whether they are about to make a big purchase because of increase in demand on the customer side). So at the end of the day, the customer generates revenue:
$y_t = \theta^{a} + g(u_t) + \varepsilon_t$,
where $a\in \{1, 2\}$. The information asymmetry (i.e. that the agents know $u_t$ but the principal doesn't) is exactly what causes the endogeneity problem in the choice of the agents and why an instrumental variable approach is necessary. The goal of the principal is to maximize revenue, or more concretely minimize expected regret in terms of revenue, i.e.:
\begin{equation}
R(T) = T\theta^{a^*} - \sum_{t} \theta_t^{X_t}
\end{equation}
where $a^*=1$ if $\delta<c$ and $a^*=2$ if $\delta\geq c$.
The principal does not know the ROI $\theta^2$, and as is typical in corporate settings, will compensate the salesperson as a fraction of the observed revenue $y_t$, whenever an intervention is made.\footnote{Potentially this compensation structure could change once the ROI is estimated by the principal, which would then remove the endogeneity problem, but until the ROI is pin-pointed, this is a typical compensation schemes in corporate settings.} Thus, the salesperson receives reward:
\begin{equation}
r_t = \beta\, y_t
\end{equation}
for some $\beta\in (0, 1]$. We also assume that each sales person has some outside option of collecting a reward $\pi$ (e.g. by doing what they would normally be doing and not following the principals recommendation). Thus the salesperson will take the action $a=1$ only if they expect a positive net benefit:
\begin{equation}
X_t = 1 + \mathbbm{1}\left\{\mathop{\mathbb{E}}_{\theta\sim \cP}[\theta^2] + g(u_t) \geq \pi/\beta\right\} = 1 + \mathbbm{1}\left\{\mathop{\mathbb{E}}_{\delta\sim \cP}[\delta] - c + g(u_t) \geq \pi/\beta \right\}
\end{equation}
In the case of two types $u_t\in \{1, 2\}$, We will also assume for simplicity that a priori both types will prefer to take the intervention. However, we assume that there is a probability under their prior beliefs that $\theta^2+g(u_t) \leq \pi/\beta$ for both types. At the end of the day the principal and the salesperson observe $y_t=\theta^a + g(u_t) + \varepsilon_t$. This example is a special case of our framework, where $\theta^2=\delta - c$ and all agents have a uniform prior $\cP$ on $\delta$, with $c$ known. Moreover, $\phi(u_t)=\pi/\beta + c - g(u_t)$, for a known $\pi$, but a type $u_t$ unobserved by the principal and only observed by the agent.\fi
\end{example}
To explicitly capture the underlying heterogeneity across agents, we study a new model in which each agent has unobserved private type that determines both their prior preferences across the actions and their action-independent confounding shift in the rewards. Since the heterogeneity of the agents confounds the observed rewards, we draw techniques from instrumental variable regression to estimate the reward effects across the actions.
In particular, we take a novel view that the planner’s recommendations can serve as a form of instrumental variables (IV) that only affect agents’ arm selection but not the observed rewards. We construct such IVs by carefully mapping the history–the interactions between the planner and the previous agents to a random recommendation. By running IV regression, our mechanism obtains a reliable estimate of reward effect of each action and in turn incentivize the agents' selections to converge on the optimal action.
A major advantage of our IV-based mechanism is that we no longer need to enforce BIC for all agents. Our algorithm can estimate the action effects accurately, as long as the recommendations induce variability in the agents' selections. An important special case is when a fraction of the types are more willing to explore an action that a-priori inferior. Furthermore, as soon as the mechanism obtains a sufficiently accurate estimate on the action effects, the policy can then be BIC for the remaining types. We demonstrate such partially BIC policy can significantly improve the regret bounds of a fully BIC policy obtained by extending the algorithm of \cite{mansour2015bic} to our setting. Moreover, our IV-based mechanism also mitigates the negative externality that their fully BIC policy imposes on a subgroup of agents. The reason is that their fully BIC policy will necessarily impose a longer exploration phase on agents of all types, which incurs unnecessary additional regret on agents who are more willing to follow the planner's recommendations. Since our IV-based mechanism does not require fully BIC to obtain accurate estimates, it also mitigates such unfair externality.
\paragraph{Additional motivating examples}
The trade-off between exploration and exploitation in the bandit setting could be observed in various scenarios that highlights the need for a natural instrument to help estimate the reward of each arm.\\
One such scenario concerns the lending discriminatory of a bank to different businesses, big and small. A bank is trying a sales campaign where a loan officer can offers a business client a low interest loan as an intervention. If they offer the loan, the bank incurs cost based on how much money the business takes out and if they default. Businesses generate baseline revenue that depends on its type and is independent of the intervention, i.e. big businesses already have more investment with the bank. so they generate more revenue regardless of the loan offer. Whether the loan officer offers the loan depends on the business type: they are biased against small businesses since they are more likely to default. The intervention choice is correlated with the baseline revenue and causes confounding effect. This calls for an instrument, which in this case is the bank's recommendation, to accurately estimate the effectiveness of the loan. By giving recommendation to induces variability, the bank can incentivizes loan officers to lend to small businesses. Thus, we can also prevent the discrimination against one type of business in this setting.
\subsection{Related Work}
\textbf{Organization.} In this workshop version, we will present our formal model (Sec.\ref{sec:model}) and illustrate key ideas of our mechanism in a simple setting of two private types and two arms (Sec. \ref{sec:two-arms-two-priors}). We defer the fully general results and details to the full version.
\section{Model}\label{sec:old-model}
\paragraph{} We study a sequential game between a \textit{learner} and a sequence of strategic \textit{agents} over $T$ rounds, where $T$ is known to the learner. In each round $t$, an entirely new agent indexed by $t$ arrives with their \emph{private type} $u_t$ drawn independently from a distribution $\cU$ defined over the set $U$ of all privates types, as well as their \emph{private true features} $x_t\in\mathbb{R}^n$, where $n$ is the total number of features.
Each agent $t$ receives a signal which contains the \emph{revealed treatment effect} $\tilde{\theta}\in\mathbb{R}^n$ from the learner, the agent strategically selects a set of features $\tilde{x}_t(\tilde{\theta})\in\mathbb{R}^n$ --which is a function of the learner's revealed $\tilde{\theta}$-- to disclose to the learner, and receives a reward $y_t\in\mathbb{R}$.
\paragraph{Reward} Given the agent's choice of feature vector $\tilde{x}_t\in\mathbb{R}^n$, the observed outcome $y_t$ for each agent $t$ is given by
\begin{equation}
\label{eq:reward-model}
y_t = \langle \theta, \tilde{x}_t \rangle + g(u_t) + \varepsilon_t,
\end{equation}
where $\theta\in\mathbb{R}^n$ denotes the unknown exogenous \emph{treatment effect}, the term $g(u_t)$ denotes an unobservable \emph{confounding variable} that depends on the agent's private type $u_t$, and the term $\varepsilon_t$ denotes an independent reward noise vector with a subgaussian norm of $\sigma_{\varepsilon}$ and conditional expectation $\mathop{\mathbb{E}}[\varepsilon_t \mid x_t, u_t] = 0$.
Both $g(u_t)$ and $\varepsilon_t$ are unobserved by the learner. The learner's objective is to maximize the expected observed reward of all agents over all $T$ rounds, i.e. the learner's objective is to find a set $\tilde{\theta}^*$ of revealed $\tilde{\theta}_t$ over all rounds $t$ such that
\begin{equation}
\label{eq:learner-objective}
\tilde{\theta}^* \in \argmax_{\tilde{\theta}}\, \mathop{\mathbb{E}}\left[ \langle \theta, \tilde{x}_t(\tilde{\theta}_t)\rangle \right]
\end{equation}
The utility for an agent $t$ is different than the observed reward insofar as the agent incurs some cost for revealing a set of features $\tilde{x}_t$ that deviates from their true features $x_t$. Let the utility for agent $t$ be:
\begin{align}
\label{eq:reward-model-agent}
y_t^{\text{agent}} :=&\, y_t - (\tilde{x}_t-x_t)^\intercal\,A(u_t)(\tilde{x}_t-x_t)\\
=&\, \langle\tilde{\theta}_t,\tilde{x}_t\rangle - (\tilde{x}_t-x_t)^\intercal\,A(u_t)(\tilde{x}_t-x_t), \nonumber
\end{align}
where $A(u_t)\in\mathbb{R}^{n\times\,n}$ is a positive symmetric matrix, dependent on the agent's private type $u_t$, which expresses the cost for an agent to reveal features that are different than their true features. Neither the cost matrix $A(u_t)$ nor agent reward $y_t^{\text{agent}}$ are observed by the learner.
While the learner is interested in maximizing the long-term cumulative rewards --or equivalently treatment effects-- across all agents, the agents are self-interested individuals whose objective is to maximize their own expected reward $y_t^{\text{agent}}$, i.e.
\begin{equation}
\label{eq:x-selection}
\tilde{x}_t \in \argmax_{x_t'} y_t^{\text{agent}} = \argmax_{x_t'}\,\langle\tilde{\theta}_t,x_t'\rangle - (x_t'-x_t)^\intercal\,A(u_t)(x_t'-x_t)
\end{equation}
We can solve for $\tilde{x}_t$ in terms of $A(u_t), \tilde{\theta}_t$, and $x_t$ here by finding the inflection point of the gradient of the agent's objective function with respect to $\tilde{x}_t$, i.e.
\begin{align*}
\nabla_{x_t}\,\langle\tilde{\theta}_t,\tilde{x}_t\rangle - (\tilde{x}_t-x_t)^\intercal\,A(u_t)(\tilde{x}_t-x_t)
&= \tilde{\theta}_t - 2(\tilde{x}_t-x_t) = 0\\
\Rightarrow \tilde{x}_t = \frac{[A(u_t)]^{-1}\tilde{\theta}_t}{2} + x_t.
\end{align*}
\xhdr{History}
The interaction between the planner and the agent $t$ is given by the tuple $(\tilde{\theta}_t, \tilde{x}_t, y_t)$.
For each $t$, let $H_t$ denote the history from round 1 to $t$, that is the sequence of interactions between the social planner and first $t$ agents: $\left\{ (\tilde{\theta}_1, \tilde{x}_1, y_1), \ldots ,(\tilde{\theta}_t, \tilde{x}_t, y_t) \right\}$.
\textbf{Working}
\section{Agent outcome maximization derivations}
\subsection{Derivation of $\boldsymbol{\theta}^{AO}$} \label{sec:AO-derivation}
\begin{equation*}
\begin{aligned}
\boldsymbol{\theta}^{AO} = \arg \max_{\boldsymbol{\theta} \in \mathcal{S}} \quad & \mathbb{E}[y_t]\\
\end{aligned}
\end{equation*}
Substituting in for $y_t$:
\begin{equation*}
\begin{aligned}
\boldsymbol{\theta}^{AO} = \arg \max_{\boldsymbol{\theta} \in \mathcal{S}} \quad & \mathbb{E}[\mathbf{x}_t^\top \boldsymbol{\theta}^* + o_t]\\
\end{aligned}
\end{equation*}
\begin{equation*}
\begin{aligned}
\boldsymbol{\theta}^{AO} = \arg \max_{\boldsymbol{\theta} \in \mathcal{S}} \quad & \mathbb{E}[\mathbf{x}_t^\top \boldsymbol{\theta}^*] + \mathbb{E}[o_t]\\
\end{aligned}
\end{equation*}
\begin{equation*}
\begin{aligned}
\boldsymbol{\theta}^{AO} = \arg \max_{\boldsymbol{\theta} \in \mathcal{S}} \quad & \mathbb{E}[\mathbf{x}_t^\top \boldsymbol{\theta}^*]\\
\end{aligned}
\end{equation*}
Substitute in for $\mathbf{x}_t$:
\begin{equation*}
\begin{aligned}
\boldsymbol{\theta}^{AO} = \arg \max_{\boldsymbol{\theta} \in \mathcal{S}} \quad & \mathbb{E}[(\mathbf{b}_t^\top + \boldsymbol{\theta}^\top \mathcal{E}_t \mathcal{E}_t^\top) \boldsymbol{\theta}^*]\\
\end{aligned}
\end{equation*}
\begin{equation*}
\begin{aligned}
\boldsymbol{\theta}^{AO} = \arg \max_{\boldsymbol{\theta} \in \mathcal{S}} \quad & \mathbb{E}[\mathbf{b}_t^\top \boldsymbol{\theta}^*] + \mathbb{E}[\boldsymbol{\theta}^\top \mathcal{E}_t \mathcal{E}_t^\top \boldsymbol{\theta}^*]\\
\end{aligned}
\end{equation*}
\begin{equation*}
\begin{aligned}
\boldsymbol{\theta}^{AO} = \arg \max_{\boldsymbol{\theta} \in \mathcal{S}} \quad & \mathbb{E}[\boldsymbol{\theta}^\top \mathcal{E}_t \mathcal{E}_t^\top \boldsymbol{\theta}^*]\\
\end{aligned}
\end{equation*}
\begin{equation*}
\begin{aligned}
\boldsymbol{\theta}^{AO} &= \arg \max_{\boldsymbol{\theta} \in \mathcal{S}} \quad \boldsymbol{\theta}^\top \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top]\boldsymbol{\theta}^*\\
&= \arg \max_{\boldsymbol{\theta} \in \mathcal{S}} \quad \sum_{i \in \mathcal{C}} \sum_{j \in \mathcal{C}} \sum_{k=1}^d \mathop{\mathbb{E}}[w_{ik} w_{jk}] \theta_i \theta_j^*\\ &+ \sum_{i \not\in \mathcal{C}} \sum_{j \in \mathcal{C}} \sum_{k=1}^d \mathop{\mathbb{E}}[w_{ik} w_{jk}] \theta_i \theta_j^*
\end{aligned}
\end{equation*}
\iffalse
\subsection{Proof of Theorem \ref{thm:ao-bound}} \label{sec:AO-cor}
\begin{lemma}\label{lemma:ao-bound}
Given a sequence of bounded decision rules $\{\boldsymbol{\theta}_t\}_{t=1}^T$ and the observable features $\{\mathbf{x}_t\}_{t=1}^T$ they induce, the distance between $\boldsymbol{\lambda} = \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top]\boldsymbol{\theta}^*$ and the estimate $\widehat{\boldsymbol{\lambda}}$ obtained in the second stage of IV regression is bounded as
\begin{equation*}
\| \widehat{\boldsymbol{\lambda}} - \boldsymbol{\lambda} \|_2 = \mathcal{O} \left( \frac{\|\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top(\mathcal{E}_t \mathcal{E}_t^\top - \mathbb{E}[\mathcal{E}_t\mathcal{E}_t^\top]) \boldsymbol{\theta}^* \|_2 + \|\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{b}_t - \Bar{z})^\top \boldsymbol{\theta}^* \|_2 + \|\sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \Bar{g}) \|_2}{\sigma_{min}\left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \right)} \right).
\end{equation*}
with high probability.
\end{lemma}
\begin{proof}
The derivation follows very closely that of Theorem \ref{thm:theta-bound}.
We start by plugging in the definitions for $\boldsymbol{\lambda}$ and $\widehat{\boldsymbol{\lambda}}$ into the $\|\widehat{\boldsymbol{\lambda}} - \boldsymbol{\lambda}\|_2$ bound.
\begin{equation*}
\|\widehat{\boldsymbol{\lambda}} - \boldsymbol{\lambda}\|_2 =
\left\| \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \right)^{-1} \sum_{t=1}^T \boldsymbol{\theta}_t (y_t - \Bar{g} - \Bar{\mathbf{b}}^\top \boldsymbol{\theta}^*) - \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top]\boldsymbol{\theta}^* \right\|_2
\end{equation*}
Next, we substitute in for $y_t$.
\begin{equation*}
\|\widehat{\boldsymbol{\lambda}} - \boldsymbol{\lambda}\|_2 =
\left\| \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \right)^{-1} \sum_{t=1}^T \boldsymbol{\theta}_t ((\mathbf{x}_t - \Bar{\mathbf{b}})^\top \boldsymbol{\theta}^* + (o_t - \Bar{g})) - \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top]\boldsymbol{\theta}^* \right\|_2
\end{equation*}
Substituting in for $\mathbf{x}_t$ and simplifying, we obtain
\begin{equation*}
\|\widehat{\boldsymbol{\lambda}} - \boldsymbol{\lambda}\|_2 =
\left\| \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \right)^{-1} \sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top (\mathcal{E}_t \mathcal{E}_t^\top - \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top]) \boldsymbol{\theta}^* + \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \boldsymbol{\theta}^* + \sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \Bar{g}) \right\|_2,
\end{equation*}
which can be upper-bounded as
\begin{equation*}
\|\widehat{\boldsymbol{\lambda}} - \boldsymbol{\lambda}\|_2 \leq \frac{\left\| \sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top (\mathcal{E}_t \mathcal{E}_t^\top - \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top]) \boldsymbol{\theta}^* \right\|_2 + \left\| \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{b}_t - \Bar{\mathbf{b}})^\top \boldsymbol{\theta}^* \right\|_2 + \left\| \sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \Bar{g}) \right\|_2}{\sigma_{min}\left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \right)}
\end{equation*}
\end{proof}
Next we bound $\left \| \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{b}_t - \Bar{\mathbf{b}})^\top \boldsymbol{\theta}^* \right\|_2$.
\begin{equation*}
\begin{aligned}
\left \| \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{b}_t - \Bar{\mathbf{b}})^\top \boldsymbol{\theta}^* \right \|_2
&\leq \left \| \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{b}_t - \Bar{\mathbf{b}})^\top \right \|_F \left\| \boldsymbol{\theta}^* \right\|_2\\
&= \beta \sqrt{m} \left\| \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{b}_t - \Bar{\mathbf{b}})^\top \right\|_F\\
&\leq 2m^{3/2} \beta^2 \sigma_{z} \sqrt{2T \log(m^2/\delta)}\\
\end{aligned}
\end{equation*}
Recall from the proof of Corollary \ref{cor:theta-bound} that $\left\| \sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \Bar{g}) \right\|_2 \leq 2\beta \sigma_g \sqrt{2Tm \log(m/\delta)}$, and $\sigma_{min}\left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \right) \geq \frac{1}{2}T \sigma_{\theta}^2$, each with probability at least $1 - \delta$. Plugging these into our bound, we can see that
\begin{equation*}
\|\widehat{\boldsymbol{\lambda}} - \boldsymbol{\lambda}\|_2 \leq \frac{\left\| \sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top (\mathcal{E}_t \mathcal{E}_t^\top - \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top]) \boldsymbol{\theta}^* \right\|_2 + 2\beta^2 m^{3/2} \sigma_z \sqrt{2 T\log(m^2/\delta)} + 2\beta \sigma_g \sqrt{2Tm \log{(m/\delta)}}}{\frac{1}{2}T \sigma_{\theta}^2},
\end{equation*}
with probability at least $1 - 5\delta$.
Let $\varepsilon_t = \mathcal{E}_t \mathcal{E}_t^\top - \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top] \in \mathbb{R}^{m \times m}$. By expanding terms and rearranging, we can see that
\begin{equation*}
\left\| \sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \varepsilon_t \boldsymbol{\theta}^* \right\|_2 = \sqrt{\sum_{k=1}^m \left( \sum_{t=1}^T \sum_{j=1}^m \sum_{i=1}^m \theta_{t,k} \theta_{t,j} \theta^{*}_i \varepsilon_{t,(i,j)} \right)^2}
\end{equation*}
If each element of $\mathcal{E}_t \mathcal{E}_t^\top$ is independently drawn from a bounded distribution with common variance $\sigma_\mathcal{E}^2$, then $\varepsilon_{t,(i,j)}$ is a zero-mean random variable with variance $\sigma_\mathcal{E}^2$. Therefore, $\theta_{t,k} \theta_{t,j} \theta^{*}_i \varepsilon_{t,(i,j)}$ is also a zero-mean random variable, with variance at most $\beta^6 \sigma_\mathcal{E}^2$. We can now use the Chernoff bound from Appendix \ref{sec:theta-bound-proof} (Lemma \ref{lemma:chernoff}). Doing so, we see that
\begin{equation*}
\sqrt{\sum_{k=1}^m \left( \sum_{t=1}^T \sum_{j=1}^m \sum_{i=1}^m \theta_{t,k} \theta_{t,j} \theta^{*}_i \varepsilon_{t,(i,j)} \right)^2} \leq \beta^3 \sigma_\mathcal{E} \sqrt{2m^3T\log{(m/\delta)}}
\end{equation*}
with probability at least $1 - \delta$. Putting everything together, we see that
\begin{equation*}
\|\widehat{\boldsymbol{\lambda}} - \boldsymbol{\lambda}\|_2 \leq \frac{\beta^3 \sigma_\mathcal{E} \sqrt{2m^3T\log{(m/\delta)}} + 2\beta^2 m^{3/2} \sigma_z \sqrt{2 T\log(m^2/\delta)} + 2\beta \sigma_g \sqrt{2Tm \log{(m/\delta)}}}{\frac{1}{2}T \sigma_{\theta}^2},
\end{equation*}
with probability at least $1 - 6\delta$.
\fi
\section{Predictive risk minimization derivations}
\subsection{Population gradient derivation} \label{sec:pop-grad-derivation}
The gradient of the population risk function $f(\boldsymbol{\theta}_t) = \mathbb{E}[(\widehat{y}_t - y_t)^2]$ can be derived as follows
\begin{equation*}
\begin{aligned}
\nabla_{\boldsymbol{\theta}_t}f(\boldsymbol{\theta}_t) &= \mathbb{E}[\nabla_{\boldsymbol{\theta}_t} (\widehat{y}_t - y_t)^2]\\
&= 2\mathbb{E}[(\widehat{y}_t - y_t)\nabla_{\boldsymbol{\theta}_t} (\widehat{y}_t - y_t)]\\
&= 2\mathbb{E}[(\widehat{y}_t - y_t)\nabla_{\boldsymbol{\theta}_t} (\mathbf{x}_t^\top \boldsymbol{\theta}_t - \mathbf{x}_t^\top \boldsymbol{\theta}^* - o_t)]\\
&= 2\mathbb{E}[(\widehat{y}_t - y_t)\nabla_{\boldsymbol{\theta}_t} (\mathbf{x}_t^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*))]\\
&= 2\mathbb{E}[(\widehat{y}_t - y_t)\nabla_{\boldsymbol{\theta}_t} ((\mathbf{b}_t^\top + \boldsymbol{\theta}_t \mathcal{E}_t \mathcal{E}_t^\top) (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*))]\\
&= 2\mathbb{E}[(\widehat{y}_t - y_t)(\mathbf{b}_t + \mathcal{E}_t \mathcal{E}_t^\top (2\boldsymbol{\theta}_t - \boldsymbol{\theta}^*))]\\
&= 2\mathbb{E}[(\widehat{y}_t - y_t)(\mathbf{x}_t + \mathcal{E}_t \mathcal{E}_t^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*))]\\
\end{aligned}
\end{equation*}
\iffalse
\subsection{Proof of Theorem \ref{thm:homo}} \label{sec:homo-proof}
\begin{proof}
If $\nabla_{\boldsymbol{\theta}_t} f(\boldsymbol{\theta}_t) = 2(\widehat{y}_t - y_t)(\mathbf{x}_t + \mathcal{E}\mathcal{E}^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*)) = \mathbf{0}$, then either $\widehat{y}_t - y_t = 0$ or $\mathbf{x}_t + \mathcal{E}\mathcal{E}^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*) = \mathbf{0}$.
\xhdr{Case 1: There exist $\boldsymbol{\theta}_t$ such that $\widehat{y}_t - y_t = 0$.}
It is easy to verify that if $\widehat{y}_t - y_t = 0$, then $f(\boldsymbol{\theta}_t) = 0$. By definition, the population risk function risk function must take values $\geq 0$, so all $\boldsymbol{\theta}_t$ which satisfy $\widehat{y}_t - y_t = 0$ are global minima. In this setting, the other extrema (the $\boldsymbol{\theta}_t$ that satisfies $\mathbf{x}_t + \mathcal{E}\mathcal{E}^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*) = \mathbf{0}$) is either a global minima or local maximum. Either way, all local minima are global minima, so stochastic gradient descent will converge to performatively optimal points \emph{almost surely}.
\xhdr{Case 2: There exist no $\boldsymbol{\theta}_t$ such that $\widehat{y}_t - y_t = 0$.}
In this scenario, there is only one exrema, so the $\boldsymbol{\theta}_t$ which satisfies $\mathbf{x}_t + \mathcal{E}\mathcal{E}^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*) = \mathbf{0}$ \emph{must} be a global minima due to the structure of the risk function $f(\boldsymbol{\theta}_t)$.
Note that in the homogeneous population setting, the stochasticity due to the population is absent, so adding a decaying random noise term to the gradient at each time-step may be required to guarantee \emph{almost sure} convergence.
\end{proof}
\fi
\section{Parameter estimation in the causal setting}\label{sec:IV}
\subsection{Ordinary least squares is not consistent} \label{sec:ols}
The least-squares estimate of $\boldsymbol{\theta}^*$ is given as
\begin{equation*}
\widehat{\boldsymbol{\theta}}_{LS} = \left(\sum_{t=1}^T \mathbf{x}_t \mathbf{x}_t^\top \right)^{-1} \sum_{t=1}^T \mathbf{x}_t y_t.
\end{equation*}
However, $\widehat{\boldsymbol{\theta}}_{LS}$ is not a consistent estimator of $\boldsymbol{\theta}^*$. To see this, let us plug in our expression for $y_t$ into our expression for $\widehat{\boldsymbol{\theta}}_{LS}$. We get
\begin{equation*}
\widehat{\boldsymbol{\theta}}_{LS} = \left(\sum_{t=1}^T \mathbf{x}_t \mathbf{x}_t^\top \right)^{-1} \sum_{t=1}^T \mathbf{x}_t (\mathbf{x}_t^\top \boldsymbol{\theta}^* + o_t)
\end{equation*}
After distributing terms and simplifying, we get
\begin{equation*}
\widehat{\boldsymbol{\theta}}_{LS} = \boldsymbol{\theta}^* + \left(\sum_{t=1}^T \mathbf{x}_t \mathbf{x}_t^\top \right)^{-1} \sum_{t=1}^T \mathbf{x}_t o_t.
\end{equation*}
$\mathbf{x}_t$ and $o_t$ are not independent due to their shared dependence on the agent's private type $u_t$. Because of this, $\left(\sum_{t=1}^T \mathbf{x}_t \mathbf{x}_t^\top \right)^{-1}\sum_{t=1}^T \mathbf{x}_t o_t$ will generally not equal $\mathbf{0}_m$, even as the number of data points (agents) grows large. To see this, recall that $\mathbf{x}_t = \mathbf{b}_t + \mathcal{E}_t \mathbf{a}_t$, so $\sum_{t=1}^T \mathbf{x}_t o_t = \sum_{t=1}^T (\mathbf{b}_t + \mathcal{E}_t \mathcal{E}_t^\top \boldsymbol{\theta}_t) o_t$. $o_t$ and $\mathbf{b}_t$ are both determined by the agent's private type. Take the example where $\mathbf{b}_t = [o_t, 0, \ldots, 0]^\top$. In this setting, $\sum_{t=1}^T \mathbf{b}_t o_t = [o_t^2, 0, \ldots, 0]^\top$, which will always be greater than 0 unless $o_t = 0$, $\forall t$.
\subsection{2SLS derivations} \label{sec:2SLS-derivations}
Define $\widetilde{\boldsymbol{\theta}}_t = \begin{bmatrix} \boldsymbol{\theta}_t\\ 1\end{bmatrix}$. $\mathbf{x}_t$ can now be written as $\mathbf{x}_t = \begin{bmatrix} \mathcal{E}_t \mathcal{E}_t^\top & \mathbf{b}_t\end{bmatrix} \begin{bmatrix} \boldsymbol{\theta}_t\\ 1 \end{bmatrix}$.
\begin{lemma}
Using OLS, we can estimate $\begin{bmatrix}\mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top]\\ \mathbb{E}[\mathbf{b}_t]^\top \end{bmatrix}$ as
\begin{equation*}
\begin{aligned}
\begin{bmatrix}\widehat{\Omega}\\ \Bar{\mathbf{b}}^\top \end{bmatrix} &= \left(\sum_{t=1}^T \widetilde{\boldsymbol{\theta}}_t \widetilde{\boldsymbol{\theta}}_t^\top \right)^{-1} \sum_{t=1}^T \widetilde{\boldsymbol{\theta}}_t \mathbf{x}_t^\top\\ &= \left(\sum_{t=1}^T \widetilde{\boldsymbol{\theta}}_t \widetilde{\boldsymbol{\theta}}_t^\top \right)^{-1} \begin{bmatrix} \sum_{t=1}^T \boldsymbol{\theta}_t \mathbf{x}_t^\top \\ \sum_{t=1}^T \mathbf{x}_t^\top \end{bmatrix},
\end{aligned}
\end{equation*}
where $\widehat{\Omega} = \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \right)^{-1} \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top$.
\end{lemma}
\begin{proof}
In order to calculate $\widehat{\Omega}$, we will make use of the following fact:
\begin{fact}[Block Matrix Inversion (\cite{bernstein2009matrix})]
If a matrix $P$ is partitioned into four blocks, it can be inverted blockwise as follows:
\begin{equation*}
\begin{aligned}
P &= \begin{bmatrix} A & B\\ C & D\end{bmatrix}^{-1}\\ &= \begin{bmatrix} A^{-1} + A^{-1}BE^{-1} CA^{-1} & -A^{-1}BE^{-1}\\ -E^{-1} CA^{-1} & E^{-1}\end{bmatrix},
\end{aligned}
\end{equation*}
where A and D are square matrices of arbitrary size, and B and C are conformable for partitioning. Furthermore, A and the Schur complement of A in P ($E = D-CA^{-1}B$) must be invertible.
\end{fact}
Let $A = \sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top$, $B = \sum_{t=1}^T \boldsymbol{\theta}_t$, $C = \sum_{t=1}^T \boldsymbol{\theta}_t^\top$, and $D = \sum_{t=1}^T 1 = T$. Note that $A$ is invertible by assumption and $E$ is a scalar, so is trivially invertible unless $CA^{-1}B = T$.
Using this formulation, observe that
\begin{equation*}
\Bar{\mathbf{b}}^\top = -E^{-1} CA^{-1}\sum_{t=1}^T \boldsymbol{\theta}_t \mathbf{x}_t^\top + E^{-1} \sum_{t=1}^T \mathbf{x}_t^\top
\end{equation*} and
\begin{equation*}
\begin{aligned}
\widehat{\Omega} &= A^{-1}\sum_{t=1}^T \boldsymbol{\theta}_t \mathbf{x}_t^\top + A^{-1}BE^{-1} CA^{-1}\sum_{t=1}^T \boldsymbol{\theta}_t \mathbf{x}_t^\top\\ &- A^{-1}BE^{-1} \sum_{t=1}^T \mathbf{x}_t^\top\\
\end{aligned}
\end{equation*}
Rearranging terms, we see that $\widehat{\boldsymbol{\lambda}}$ can be written as
\begin{equation*}
\begin{aligned}
\widehat{\Omega} &= A^{-1}\sum_{t=1}^T \boldsymbol{\theta}_t \mathbf{x}_t^\top\\ &+ A^{-1}B (E^{-1} CA^{-1}\sum_{t=1}^T \boldsymbol{\theta}_t \mathbf{x}_t^\top - E^{-1} \sum_{t=1}^T \mathbf{x}_t^\top)\\
&= A^{-1}\sum_{t=1}^T \boldsymbol{\theta}_t \mathbf{x}_t^\top - A^{-1}B \Bar{\mathbf{b}}^\top
\end{aligned}
\end{equation*}
Finally, plugging in for $A$ and $B$, we see that
\begin{equation*}
\begin{aligned}
\widehat{\Omega} &= \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \right)^{-1}\sum_{t=1}^T \boldsymbol{\theta}_t \mathbf{x}_t^\top\\ &- \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \right)^{-1}\sum_{t=1}^T \boldsymbol{\theta}_t \Bar{\mathbf{b}}^\top\\
&= \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \right)^{-1}\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{z})^\top
\end{aligned}
\end{equation*}
\end{proof}
Similarly, we can write $y_t$ as $y_t = \begin{bmatrix}\boldsymbol{\theta}_t^\top & 1 \end{bmatrix} \begin{bmatrix}\mathcal{E}_t \mathcal{E}_t^\top \boldsymbol{\theta}^*\\ o_t + \mathbf{b}_t^\top \boldsymbol{\theta}^* \end{bmatrix}$.
\begin{lemma}
Using OLS, we can estimate $\begin{bmatrix} \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top] \boldsymbol{\theta}^*\\ \mathbb{E}[o_t] + \mathbb{E}[\mathbf{b}_t^\top] \boldsymbol{\theta}^* \end{bmatrix}$ as
\begin{equation*}
\begin{aligned}
\begin{bmatrix}\widehat{\boldsymbol{\lambda}}\\ \Bar{o} + \Bar{\mathbf{b}}^\top \boldsymbol{\theta}^* \end{bmatrix} &= \left(\sum_{t=1}^T \widetilde{\boldsymbol{\theta}}_t \widetilde{\boldsymbol{\theta}}_t^\top \right)^{-1} \sum_{t=1}^T \widetilde{\boldsymbol{\theta}}_t y_t\\ &= \left(\sum_{t=1}^T \widetilde{\boldsymbol{\theta}}_t \widetilde{\boldsymbol{\theta}}_t^\top \right)^{-1} \begin{bmatrix} \sum_{t=1}^T \boldsymbol{\theta}_t y_t^\top \\ \sum_{t=1}^T y_t^\top \end{bmatrix},
\end{aligned}
\end{equation*}
where $\widehat{\boldsymbol{\lambda}} = \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \right)^{-1} \sum_{t=1}^T \boldsymbol{\theta}_t (y_t - \Bar{o} - \Bar{\mathbf{b}}^\top \boldsymbol{\theta}^*)$.
\end{lemma}
\begin{proof}
The proof follows similarly to the proof of the previous lemma. Let $A = \sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top$, $B = \sum_{t=1}^T \boldsymbol{\theta}_t$, $C = \sum_{t=1}^T \boldsymbol{\theta}_t^\top$, and $D = \sum_{t=1}^T 1 = T$. Note that $A$ is invertible by assumption and $E$ is a scalar, so is trivially invertible unless $CA^{-1}B = T$.
Using this formulation, observe that
\begin{equation*}
\Bar{o}^\top + \Bar{z}^\top \boldsymbol{\theta}^* = -E^{-1} CA^{-1}\sum_{t=1}^T \boldsymbol{\theta}_t y_t + E^{-1} \sum_{t=1}^T y_t
\end{equation*} and
\begin{equation*}
\begin{aligned}
\widehat{\boldsymbol{\lambda}} &= A^{-1}\sum_{t=1}^T \boldsymbol{\theta}_t y_t\\ &+ A^{-1}B \left(E^{-1} CA^{-1}\sum_{t=1}^T \boldsymbol{\theta}_t y_t - E^{-1} \sum_{t=1}^T y_t \right)\\
&= A^{-1}\sum_{t=1}^T \boldsymbol{\theta}_t y_t - A^{-1}B \left(\Bar{o}^\top + \Bar{z}^\top \boldsymbol{\theta}^* \right)\\
&= \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \right)^{-1} \sum_{t=1}^T \boldsymbol{\theta}_t \left(y_t - \Bar{o}^\top - \Bar{z}^\top \boldsymbol{\theta}^* \right)
\end{aligned}
\end{equation*}
\end{proof}
\begin{theorem}
We can estimate $\boldsymbol{\theta}^*$ as
\begin{equation*}
\widehat{\boldsymbol{\theta}} = \widehat{\Omega}^{-1} \widehat{\boldsymbol{\lambda}} = \left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)^{-1} \sum_{t=1}^T \boldsymbol{\theta}_t (y_t - \Bar{o} - \Bar{z}^\top \boldsymbol{\theta}^*)
\end{equation*}
\end{theorem}
\begin{proof}
This follows immediately from the previous two lemmas.
\end{proof}
\subsection{2SLS is consistent} \label{sec:iv-regression}
Consider the two-stage least squares (2SLS) estimate of $\boldsymbol{\theta}^*$,
\begin{equation*}
\widehat{\boldsymbol{\theta}}_{IV} = \left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)^{-1} \sum_{t=1}^T \boldsymbol{\theta}_t (y_t - \Bar{o} - \Bar{z}^\top \boldsymbol{\theta}^*)
\end{equation*}
Plugging in for $y_t$ and simplifying, we get
\begin{equation*}
\widehat{\boldsymbol{\theta}}_{IV} = \boldsymbol{\theta}^* + \left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)^{-1} \sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \Bar{o})
\end{equation*}
To see that $\widehat{\boldsymbol{\theta}}_{IV}$ \emph{is} a consistent estimator of $\boldsymbol{\theta}^*$, we show that $\lim_{T \to \infty} \mathbb{E} \|\widehat{\boldsymbol{\theta}}_{IV} - \boldsymbol{\theta}^*\|_2^2 = 0$.
\begin{equation*}
\mathbb{E} \|\widehat{\boldsymbol{\theta}}_{IV} - \boldsymbol{\theta}^*\|_2^2 = \mathbb{E} \left \| \left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)^{-1} \sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \Bar{o}) \right \|_2^2
\end{equation*}
$o_t - \Bar{o}$ and $\boldsymbol{\theta}_t$ are uncorrelated, so $\sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \Bar{o})$ will go to zero as $T \rightarrow \infty$. On the other hand, $\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top$ will approach $T \mathbb{E}[\boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top]$. $\boldsymbol{\theta}_t$ and $\mathbf{x}_t - \Bar{\mathbf{b}}$ \emph{are} correlated, so $\mathbb{E}[\boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top] \neq \mathbf{0}$ in general.
\section{Performative prediction in our setting}\label{sec:pp}
Performative prediction methods perform repeated gradient descent \emph{without} taking into account $\mathbf{x}_t$ and $y_t$'s explicit dependence on $\boldsymbol{\theta}_t$. Because of this, their gradient (denoted by $\Delta_{PP}$) takes the form
\begin{equation*}
\boldsymbol \Delta_{PP} = \nabla_{\boldsymbol{\theta}_t} f(\boldsymbol{\theta}_t) = 2\mathbb{E}[(\widehat{y}_t - y_t)\mathbf{x}_t].
\end{equation*}
This is in contrast to our gradient, $\Delta$, which takes the explicit dependence of $\mathbf{x}_t$ and $y_t$ on $\boldsymbol{\theta}_t$ into account.
\begin{equation*}
\boldsymbol \Delta = \nabla_{\boldsymbol{\theta}_t} f(\boldsymbol{\theta}_t) = 2\mathbb{E}[(\widehat{y}_t - y_t)(\mathbf{x}_t + W_tW_t^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*))].
\end{equation*}
We now show that the sign of $\boldsymbol \Delta$ and $\boldsymbol \Delta_{PP}$ can differ, using a simple 1D example. By writing $\mathbf{x}_t$, $\hat y_t$, and $y_t$ in terms of $\boldsymbol{\theta}_t$ and simplifying, we can see that for zero-mean $\mathbf{z}_t$ and $g_t$,
\begin{equation*}
\Delta_{PP} = 2\mathbb{E}[x_t^2](\theta_t - \theta^*) - \mathbb{E}[z_t g_t],
\end{equation*}
and
\begin{equation*}
\Delta = 2\mathbb{E}[x_t^2](\theta_t - \theta^*) - \mathbb{E}[z_t g_t] + W^4 \theta_t (\theta_t - \theta^*)^2.
\end{equation*}
Notice that if $\theta_t > 0$, $\theta^* > \theta_t$, $\mathbb{E}[z_t g_t] > 0$, and $W$ is large enough, then $\Delta > 0$ but $\Delta_{PP} < 0$.
\subsection{Predictive Risk Minimization}\label{sec:prm}
Analogous to recovering causal relationships and improving agent outcomes, another common goal of the principal in the strategic learning setting is to \emph{minimize predictive risk}. Formally, the goal of the principal in the predictive risk minimization setting is to learn the assessment rule that minimizes the expected squared difference between an agent's true outcome and the outcome predicted by the principal, i.e., $f(\boldsymbol{\theta}_t) = \mathbb{E}[(\widehat{y}_t - y_t)^2]$.
Due to the dependence of $\mathbf{x}_t$ and $y_t$ on $\boldsymbol{\theta}_t$, $f(\boldsymbol{\theta}_t)$ will be non-convex in general, and can have several extrema which are not global minima, even in the case of just one observable feature. When faced with such non-convex optimization problems, gradient descent is often a popular approach due to its simplicity and convergence to local minima in practice.
\iffalse
Under certain smoothness and convexity assumptions on the population risk function, \cite{mendler2020stochastic} show that running repeated stochastic gradient descent using just the $(\mathbf{x}_t, y_t)$ data (i.e. without writing $\mathbf{x}_t$ and $y_t$ in terms of $\boldsymbol{\theta}_t$ before computing the gradient) can converge to \emph{performatively stable} points, (essentially local minima of the population risk function) in strategic classification settings. However, running repeated stochastic gradient descent on $(\mathbf{x}_t, y_t)$ data in our setting may fail to converge, due to the possibility of multiple performatively stable points. In contrast, we show that by running online gradient descent directly on $f(\boldsymbol{\theta}_t)$, it is generally possible to converge to performatively stable points. Additionally, we identify several special cases in which running online gradient descent converges to a \emph{performatively optimal} point. (i.e. global minima of the population risk function).
\fi
\iffalse
\dndelete{
\begin{figure}
\centering
\begin{subfigure}[t]{0.35\textwidth}
\includegraphics[width=\textwidth, height=\textheight,keepaspectratio]{figures/risk-1d.png}
\caption{1D example of a population risk function $f(\theta_t)$ with several extrema. While there are two local minima, there is only one global minima (on the right).}
\label{fig:non-convex}
\end{subfigure}
~
\begin{subfigure}[t]{0.35\textwidth}
\includegraphics[width=\textwidth, height=\textheight,keepaspectratio]{figures/risk-1d-invex.png}
\caption{1D example of a population risk function $f(\theta_t)$ with only one extrema. Note that if there is only one extrema, it will always be a global minima due to the structure of the population risk function.}
\label{fig:invex}
\end{subfigure}
\end{figure}}
\fi
\iffalse
The gradient of the population risk function takes the form
\small
\begin{equation*}
\nabla_{\boldsymbol{\theta}_t} f(\boldsymbol{\theta}_t) = 2\mathbb{E}[(\widehat{y}_t - y_t)(\mathbf{x}_t + \mathcal{E}_t\mathcal{E}_t^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*))].
\end{equation*}
\normalsize
\fi
If the effort conversion matrix $\mathcal{E}$ is the same for all agents, the gradient of population risk function can be written as
\begin{equation*}
\nabla_{\boldsymbol{\theta}_t} f(\boldsymbol{\theta}_t) = 2(\mathbb{E}[(\widehat{y}_t - y_t) \mathbf{x}_t] + \mathbb{E}[\widehat{y}_t - y_t]\mathcal{E}\mathcal{E}^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*).
\end{equation*}
See Appendix \ref{sec:pop-grad-derivation} for the derivation. In our college admissions example, this would correspond to the setting in which all students' math GPA, SAT scores, etc. improve the same amount given the same effort: this may be a reasonable assumption if the students being considered have the same ability to learn, despite other differences in background they may have. If $\mathcal{E}\mathcal{E}^\top$ is known to the principal (e.g. through the 2SLS procedure in Section \ref{sec:main}), then each $(\boldsymbol{\theta}_t, \mathbf{x}_t, y_t)$ tuple can be used to compute an unbiased estimate of $\nabla_{\boldsymbol{\theta}_t} f(\boldsymbol{\theta}_t)$ for use in online gradient descent.
\iffalse
If $\mathcal{E}$ is unknown, the principal can use $\widehat{\Omega}$, the estimate of $\mathcal{E}\mathcal{E}^\top$ computed during the first step of 2SLS, as a consistent estimate of $\mathcal{E}\mathcal{E}^\top$. Note that $\|\widehat{\Omega}(\boldsymbol{\theta}_t - \boldsymbol{\theta}^*) - \mathcal{E}\mathcal{E}^\top(\boldsymbol{\theta}_t - \boldsymbol{\theta}^*) \|_2 = \mathcal{O}(\frac{1}{\sqrt{T}})$ can be bounded analogously to Theorem \ref{thm:ao-bound} and Corollary \ref{cor:ao-bound} by following the same steps (where $T$ refers to the number of agents seen in the 2SLS estimate).
\fi
Recent work on \textit{performative prediction} \cite{perdomo2020performative, mendler2020stochastic, miller2021outside} examines the use of repeated gradient descent in the strategic learning setting and finds that repeated gradient descent generally converges to \emph{performatively stable} points. There is no direct comparison between performatively stable points and local minima in our setting. In fact, performatively stable points can actually \emph{maximize} predictive risk under some settings. (See \citet{miller2021outside} for such an example.) Our methods differ from this line of work because we take $\mathbf{x}_t$, $y_t$, and $\widehat{y}_t$'s \emph{direct dependence} on the assessment rule $\boldsymbol{\theta}_t$ into account when calculating the gradient of the risk function, whereas these performative prediction models (henceforth \textit{simple stochastic gradient descent} or \textit{SSGD}) do not. While SSGD may be satisfactory for some settings, it produces a biased estimate of the gradient in general, which can lead to unexpected behavior under our setting; by contrast, our gradient estimate is unbiased (see \Cref{fig:pp-vs-us}). Even in situations which SSGD \emph{does} get the sign of the gradient correct, it may converge at a much slower rate, due to its incomplete estimate of the gradient (see \Cref{fig:pp-vs-us-convergence-rate} in Appendix \ref{sec:figure-setting}).
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{figures/SGD_SSGD_convergence_plot.png}
\caption{Stochastic Gradient Descent (SGD, takes into account $x_t$, $y_t$, $\widehat{y}_t$'s dependence on $\theta_t$) vs Simple Stochastic Gradient Descent (SSGD, does not). In the 1D setting, it is possible for the gradient of SSGD to have the wrong sign. When both are initialized at $\theta_0 = 0.5$, SGD is able to follow the gradient and converge to the global minima, while SSGD is not. We ran each method for $1000$ time-steps with a decaying learning rate of $\frac{0.001}{\sqrt{T}}$.}
\label{fig:pp-vs-us}
\end{figure}
\iffalse
\begin{figure}
\centering
\includegraphics[width=0.45\textwidth]{figures/SGD_SSGD_distance_plot.png}
\caption{Convergence rate of Stochastic Gradient Descent vs Simple Stochastic Gradient Descent for simple 1D setting. Even when SSGD converges, it may do so at a much slower rate, due to the inexact measure of the gradient. We ran both methods for $1000$ time-steps with a decaying learning rate of $\frac{0.001}{\sqrt{T}}$. Results are averaged over 10 runs, with the error bars (in lighter colors) representing one standard deviation.}
\label{fig:pp-vs-us-convergence-rate}
\end{figure}
\fi
\iffalse
\begin{figure}[ht]
\centering
\begin{subfigure}[t]{0.45\textwidth}
\includegraphics[width=\textwidth]{figures/SGD_SSGD_convergence_plot.png}
\caption{Stochastic Gradient Descent (SGD, takes into account $x_t$, $y_t$, $\widehat{y}_t$'s dependence on $\theta_t$) vs Simple Stochastic Gradient Descent (SSGD, does not). In the 1D setting, it is possible for the gradient of SSGD to have the wrong sign. When both are initialized at $\theta_0 = 0.5$, SGD is able to follow the gradient and converge to the global minima, while SSGD is not. We ran each method for $1000$ time-steps with a decaying learning rate of $\frac{0.001}{\sqrt{T}}$.}
\label{fig:pp-vs-us}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{figures/SGD_SSGD_distance_plot.png}
\caption{Convergence rate of Stochastic Gradient Descent vs Simple Stochastic Gradient Descent for simple 1D setting. Even when SSGD converges, it may do so at a much slower rate, due to the inexact measure of the gradient. We ran both methods for $1000$ time-steps with a decaying learning rate of $\frac{0.001}{\sqrt{T}}$. Results are averaged over 10 runs, with the error bars (in lighter colors) representing one standard deviation.}
\label{fig:pp-vs-us-convergence-rate}
\end{subfigure}
\caption{Left: Evaluation of SGD versus SSGD for a simple 1D setting. Right: Convergence rate of SGD versus SSGD for a simple 1D setting.}
\end{figure}
\fi
\iffalse
While online gradient descent is only guaranteed to converge to local minima in general, we identify two cases in which online gradient descent will converge to \emph{global} minima.
Since the population risk function is a quartic function of $\boldsymbol{\theta}_t$, it can be sometimes be \emph{invex}, depending on the distribution over the agents' private types $u_t$. Invexity is a generalization of convexity. In particular, a function is invex if all extrema of the function are \emph{global} minima.
\begin{theorem}
Online gradient descent converges to global minima almost surely if the population predictive risk is invex.
\end{theorem}
\begin{proof}
The proof follows straightforwardly from the fact that online gradient descent will converge to local minima \emph{almost surely} (\cite{mertikopoulos2020almost}), and all extrema of invex functions are global minima.
\end{proof}
\fi
\iffalse
While stochastic gradient descent is only guaranteed to converge to local minima in general, we show that it will converge to a global minima when the population is \emph{homogeneous}, i.e. when the type of every agent is the same. In this setting all expectation signs go away, and the gradient of the risk function takes the following form
\begin{equation*}
\nabla_{\boldsymbol{\theta}_t} f(\boldsymbol{\theta}_t) = 2(\widehat{y}_t - y_t)(\mathbf{x}_t + \mathcal{E}\mathcal{E}^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*)).
\end{equation*}
\begin{theorem}\label{thm:homo}
Online gradient descent converges to a global minima if the agent population is homogeneous.
\end{theorem}
\emph{Proof Sketch.} We present the full proof in Appendix \ref{sec:homo-proof}. The general idea is as follows. Extrema can occur at $\boldsymbol{\theta}_t$ which cause $\widehat{y}_t - y_t = 0$ or $\mathbf{x}_t + \mathcal{E}\mathcal{E}^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*) = \mathbf{0}$. We show that if $\widehat{y}_t - y_t = 0$, all extrema are global minima. Similarly, we show that if $\mathbf{x}_t + \mathcal{E}\mathcal{E}^\top (\boldsymbol{\theta}_t - \boldsymbol{\theta}^*) = \mathbf{0}$, there is only one extrema, which must be a global minima.
\fi
\subsection{Recommendations as Instruments}
We model the \dncomment{observed} reward $y_t$ and action $x_t$ in the presence of confounding variables that depend on the type $u_t$. In a standard bandits setting, without confounding variables, one would find \dncomment{the treatment effect} $\theta$ by taking the mean over sufficiently many observed rewards of each arm. However, because of the unknown confounding variable $g(u_t)$ that is correlated with $x_t$, such simple estimation does not work. Instead, we will use \textit{instrumental variable (IV) regression} to estimate the exogenous treatment effect $\theta$. Note that each recommendation $z_t$ can be viewed an \textit{instrumental variable} because: (1) $z_t$ influences the selection $x_t$; and (2) $z_t$ is independent from the endogenous error term $g(u_t)$. Criterion (2) follows because planner chooses $z_t$ randomly independent of the type $u_t$.
\iffalse
IV regression estimates the treatment effect when the explanatory variable is correlated with the error term. The reward model in equation~\eqref{eq:reward-model} follows the form of a model for treatment effect: the treatment $x_t$, the exogenous treatment effect $\theta$, and the error term $g(u_t) + \varepsilon_t$ determine the response variable $y_t$. Both the treatment $x_t$ and the reward $y_t$ are correlated with the endogenous error term $g(u_t)$.
\fi
Our mechanism periodically solves the following IV regression problem:
given a set of $n$ observations $\{(x_i, y_i, z_i)\}_{i=1}^n$, find an accurate estimator $\hat \theta_n$ of $\theta$. To derive the estimator, we will rewrite the selection and reward functions in~\eqref{eq:reward-model} and \eqref{eq:two-arm-general-selection-function} as a linear relationship between $x_i$, $y_i$ and $z_i$. Then
\begin{align}
y_i &= \theta x_i + g(u_i) + \varepsilon_i \label{eq:reward-iv-model}\\
x_i &= \gamma_1 z_i + \gamma_0(1-z_i) + \eta_i \nonumber\\
&= \gamma z_i + \gamma_0 + \eta_i \label{eq:treatment-iv-model}
\end{align}
where $\eta_i=\mathop{\mathbb{E}}_\cU[x \mid z_i] - x_i$ and $\gamma_1=\mathop{\mathbb{P}}_{\cU}[x_i=1 \mid z_i=1]$ and $\gamma_0=\mathop{\mathbb{P}}_{\cU}[x_i=1 \mid z_i=0]$ make up the \emph{compliance coefficient} $\gamma$, which is given by:
\begin{equation}
\label{eq:compliance-coefficient}
\gamma=\gamma_1-\gamma_0=\mathop{\mathbb{P}}_{\cU}[x_i=1 \mid z_i=1]-\mathop{\mathbb{P}}_{\cU}[x_i=1 \mid z_i=0]
\end{equation}
Let the operator $\bar{\cdot}$ denote the mean, such that $\bar{y}:=\frac{1}{n}\sum_{i=1}^n y_i$ and $\bar{g}:=\frac{1}{n}\sum_{i=1}^n g(u_i)$, etc. Then, the average observed reward is
\begin{align*}
\bar{y} &= \beta\bar{z} + \theta\gamma_0 + \theta\bar{\eta} + \bar{g} + \bar{\varepsilon}
\end{align*}
Thus, the centered reward and treatment choice at round $i$ are given as:
\begin{equation}
\begin{cases}
\label{eq:centered-reward-treatment-choice}
y_i - \bar{y}_i = \beta(z_i-\bar{z}) + \theta(\eta_i-\bar{\eta}) + g(u_i)-\bar{g} + \varepsilon_i-\bar{\varepsilon}\\
x_i - \bar{x}_i = \gamma(z_i-\bar{z}) + \eta_i-\bar{\eta}
\end{cases}
\end{equation}
\textbf{Instrumental Variable Estimator.} Using these formulations of the centered reward $y_i-\bar{y}$ and treatment choice $x_i-\bar{x}$, we form the estimate $\hat{\theta}_n$ via \textit{Instrumental Variable (IV) regression}. We first form empirical estimates $\hat{\gamma}_n$ and $\hat{\beta}_n$ by regressing the centered treatment choice $x_i-\bar{x}$ and the centered reward $y_i-\bar{y}$ over the centered recommendation $z_i-\bar{z}$, respectively. These estimates are formed over $n$ samples $\{x_i,z_i,y_i\}_{i=1}^n$ as such:
\begin{equation}
\hat{\beta}_n := \frac{\sum_{i=1}^n (y_i - \bar{y})(z_i - \bar{z})}{\sum_{i=1}^n (z_i -\bar{z})^2} \hspace{1cm}\text{and}\hspace{1cm} \hat{\gamma}_n := \frac{\sum_{i=1}^n (x_i - \bar{x})(z_i - \bar{z})}{\sum_{i=1}^n (z_i -\bar{z})^2}
\label{eq:beta-gamma-hat}
\end{equation}
Second, we take their quotient as the predicted treatment effect $\hat{\theta}_n$, i.e.
\begin{align}
\hat{\theta}_n &= \frac{\hat{\beta}_n}{\hat{\gamma}_n}\\
&= \frac{\sum_{i=1}^n (y_i - \bar{y})(z_i - \bar{z})}{\sum_{i=1}^n (z_i -\bar{z})^2} \frac{\sum_{i=1}^n (z_i -\bar{z})^2}{\sum_{i=1}^n (x_i - \bar{x})(z_i - \bar{z})} \nonumber\\
&= \frac{\sum_{i=1}^n (y_i - \bar{y})(z_i - \bar{z})}{\sum_{i=1}^n (x_i - \bar{x})(z_i - \bar{z})}
\end{align}
We provide a finite-sample \textit{approximation bound} on $\hat{\theta}_n$, which may be of independent interest.
\begin{restatable}[Treatment effect approximation bound]{theorem}{treatmentapproximationbound}\label{thm:treatment-approximation-bound}
Given a sample set $(z_i, x_i, y_i)_n$, which contains $n$ samples of instrument $z$, treatment $x$, and reward $y$, we bound the difference between the true treatment effect $\theta$ and the predicted treatment effect $\hat{\theta}_n$ derived via IV regression over $(z_i, x_i, y_i)_n$. Let $\Upsilon$ be a upper bound on the confounding term $g(u_i)$. For some confidence $\delta>0$, with probability at least $1 - \delta$:
\[\left|\hat{\theta}_n-\theta\right| \leq \frac{\left(2\sigma_{\varepsilon}+2\Upsilon\right)\sqrt{2n\log(5/\delta)}}{\left|\sum_{i=1}^n(x_i-\bar{x})(z_i-\bar{z})\right|}\]
\end{restatable}
\begin{proof}
See \cref{sec:approximation-bound-proof} for a proof.
\end{proof}
\section{Related Work}
\subsection{Comparison with \cite{shavit2020strategic}}
The setting most similar to ours is that of \cite{shavit2020strategic}. They consider a strategic classification setting in which an agent's outcome is a linear function of features --some observable and some not (see \Cref{fig:shavit-model-dag} for a graphical representation of their model). While they assume that an agent's hidden attributes can be modified strategically, we choose to model the agent as having an unmodifiable private \emph{type}. Both of these assumptions are reasonable, and some domains may be better described by one model than the other. For example, the model of \cite{shavit2020strategic} may be useful in a setting such as car insurance pricing, where some unobservable factors which lead to safe driving are modifiable. On the other hand, settings like our college admissions example in which the unobservable factors which contribute to college success (i.e. socioeconomic status, lack of resources, etc., captured in $g_t$) are not easily modifiable.
\hhcomment{The preceeding claim does not appear to be true. In our setting, action/effort is modifiable and unobservable.}
One benefit of our setting is that we are able to use $\boldsymbol{\theta}_t$ as a valid instrument to recover the true relationship $\boldsymbol{\theta}^*$ between observable features and outcomes. This is generally not possible in the model of \cite{shavit2020strategic}, since $\boldsymbol{\theta}_t$ violates the backdoor criterion as long as there exists any hidden features $\mathbf{h}_t$ and is therefore not a valid instrument. Another difference between our setting and theirs is that we allow for a heterogeneous population of agents, while they do not. Specifically, they assume that each agent's mapping from actions to features is the same, while our model is capable of handling mappings which vary from agent-to-agent.
A natural question is whether or not there exists a general model which captures the setting of both \cite{shavit2020strategic} and ours. We provide such a model in \Cref{fig:general-model-dag}. In this setting, an agent has both observable and unobservable features, both of which are affected by the assessment rule $\boldsymbol{\theta}_t$ deployed and the agent's private type $u_t$. However, much like the setting of \cite{shavit2020strategic}, $\boldsymbol{\theta}_t$ violates the backdoor criterion, so it cannot be used as a valid instrument in order to recover the true relationship between observable features and outcomes. Moreover, the following toy example illustrates that \emph{no} form of true parameter recovery can be performed when an agent's unobservable features are modifiable.
\begin{figure}
\begin{subfigure}[t]{0.49\textwidth}
\centering
\begin{tikzpicture}[node distance={22mm}, thick, main/.style = {draw, circle}]
\node[draw,circle,fill=lightgray] (1) {$\boldsymbol{\theta}_t$};
\node[draw,circle,fill=lightgray] (2) [right of=1,yshift=0.65cm] {$\mathbf{x}_t$};
\node[node distance={15mm}, thick,draw,circle] (3) [below of=2] {$\mathbf{h}_t$};
\node[draw,circle,fill=lightgray,,yshift=-0.65cm] (4) [right of=2] {$y_t$};
\draw[->] (1) -- node[above left,xshift=0.35cm] {$\mathbf{a}_t$, $W_t$} (2);
\draw[->] (1) -- node[below left,xshift=0.35cm] {$\mathbf{a}_t$, $W_t$} (3);
\draw[->] (3) -- node[below right=-0.15cm] {$\boldsymbol{\theta}^*$} (4);
\draw[->] (2) -- node[above] {$\boldsymbol{\theta}^*$} (4);
\end{tikzpicture}
\caption{Graphical model of \cite{shavit2020strategic}. Observable features $\mathbf{x}_t$ (e.g. the type of car a person drives) and unobservable features $\mathbf{h}_t$ (e.g. how defensive of a diver someone is) are affected by $\boldsymbol{\theta}_t$ through action $\mathbf{a}_t$ (e.g. buying a new car) and common action conversion matrix $W$ (representing, in part, the cost to a person of buying a new car). Outcome $y_t$ (in this example, the person's chance of getting in an accident) is affected by $\mathbf{x}_t$ and $\mathbf{h}_t$ through the true causal relationship $\boldsymbol{\theta}_t$. Note that causal parameter recovery is not possible in this setting unless all features are observable.}
\label{fig:shavit-model-dag}
\end{subfigure}
~
\begin{subfigure}[t]{0.49\textwidth}
\centering
\begin{tikzpicture}[node distance={25mm}, thick, main/.style = {draw, circle}]
\node[draw,circle,fill=lightgray] (1) {$\boldsymbol{\theta}_t$};
\node[draw,circle,fill=lightgray] (2) [right of=1] {$\mathbf{x}_t$};
\node[node distance={20mm},draw,circle,fill=lightgray,yshift=-1.2cm] (3) [right of=2] {$y_t$};
\node[main] (4) [below of=1] {$u_t$};
\node[main] (5) [right of=4] {$\mathbf{h}_t$};
\draw[->] (1) -- node[above] {$\mathbf{a}_t$} (2);
\draw[->] (2) -- node[above] {$\boldsymbol{\theta}^*$} (3);
\draw[->] (1) -- node[above right,yshift=0.5cm,xshift=-0.55cm] {$\mathbf{a}_t$} (5);
\draw[->] (4) -- node[above,yshift=-.7cm,xshift=-1cm] {$\mathbf{z}_t,W_t$} (2);
\draw[->] (5) -- node[below] {$\boldsymbol{\theta}^*$} (3);
\draw[->] (4) edge[bend right=2cm] node [below right]{$g_t$} (3);
\draw[->] (4) -- node[above] {$\mathbf{z}_t,W_t$} (5);
\end{tikzpicture}
\caption{Graphical model which captures both our setting and that of \cite{shavit2020strategic}. In this setting, observable features $\mathbf{x}_t$ \emph{and} unobservable features $\mathbf{h}_t$ are affected by $\boldsymbol{\theta}_t$ through action $\mathbf{a}_t$. The agent's private type $u_t$ affects $\mathbf{x}_t$ and $\mathbf{h}_t$ through initial feature values $\mathbf{z}_t$ and action conversion matrix $W_t$. The agent's outcome $y_t$ depends on $\mathbf{x}_t$ and $\mathbf{h}_t$ through the causal relationship $\boldsymbol{\theta}^*$ and $u_t$ through confounding term $g_t$. Note that much like the setting of \cite{shavit2020strategic}, causal parameter recovery is not possible in this setting unless all features are observable.}
\label{fig:general-model-dag}
\end{subfigure}
\end{figure}
\begin{example}
Consider the one-dimensional setting
\begin{equation*}
y_t = \theta^*x_t + \beta^* h_t,
\end{equation*}
where $x_t$ is an agent's observable, modifiable feature and $h_t$ is an unobservable, modifiable feature. If the relationship between $x_t$ and $h_t$ is unknown, then it is generally impossible to recover the true relationship between $x_t$, $h_t$, and outcome $y_t$. To see this, consider the setting where $h_t$ and $x_t$ are highly correlated. In the extreme case, take $h_t = x_t, \; \forall t$. (Note we use equality to indicate identical feature values, not a causal relationship.) In this setting, the models $\theta^* = 1$, $\beta^* = 1$ and $\theta^* = 2$, $\beta^* = 0$ produce the same outcome $y_t$ for all $x \in \mathbb{R}$, making it impossible to distinguish between the two models, even in the limit of infinite data.
\end{example}
\subsection{Comparison with Performative Prediction}
A recent line of work (\cite{perdomo2020performative, mendler2020stochastic, miller2021outside}) examines the use of repeated gradient descent in strategic learning setting and finds that under certain conditions on the predictive risk function, performative prediction methods converge to \emph{performatively stable} or \emph{performatively optimal} points. Performatively optimal points are analogous to global minima in our setting, but there is no direct comparison between performatively stable points and local minima in our setting. Our methods differ from this line of work because we take $\mathbf{x}_t$, $y_t$, and $\widehat{y}_t$'s \emph{direct dependence} on the assessment rule $\boldsymbol{\theta}_t$ into account when calculating the gradient of the risk function, whereas these performative prediction models do not. Because of this, we can guarantee convergence to local minima of the predictive risk function, whereas this is generally not guaranteed under the performative prediction framework. For a more detailed analysis of performative prediction repeated gradient descent in our setting, see Appendix \ref{sec:pp}.
\subsection{Related Work}
An active area of research on \emph{strategic learning} aims to develop machine learning algorithms that are capable of making accurate predictions about decision subjects even if they respond \emph{strategically} and potentially \emph{untruthfully} to the choice of the predictive model~ \citep{dong2018strategic,hardt2016strategic, mendler2020stochastic, shavit2020strategic, grinder, CummingsIL15, CaiDP15, MEIR2012123, hu2018disparate}. Generalizing strategic learning, \citet{perdomo2020performative} propose a framework called \emph{performative predictions}, which broadly studies settings in which the act of predicting influences the prediction target. Several recent papers have investigated the relationship between strategic learning and causality~\citep{shavit2020strategic,BechavodLWZ21,miller2020strategic}.
The setting most similar to ours is that of \citet{shavit2020strategic}. They consider a strategic classification setting in which an agent's outcome is a linear function of features --some observable and some not (see \Cref{fig:shavit-model-dag} in the appendix for a graphical representation of their model). While they assume that an agent's latent attributes can be modified strategically, we choose to model the agent as having an unmodifiable private \emph{type}. Both of these assumptions are reasonable, and some domains may be better described by one model than the other. For example, the model of \citeauthor{shavit2020strategic} may be useful in a setting such as car insurance pricing, where some unobservable factors related to safe driving are modifiable. On the other hand, our model captures settings like university admissions, where confounding factors (e.g., socioeconomic background) are not easily modifiable. Both models are special cases of a broader causal graph (described in Appendix \ref{sec:shavit}). Note that in the model of \citeauthor{shavit2020strategic}, $\boldsymbol{\theta}_t$ violates the backdoor criterion and therefore cannot serve as a valid instrument. \cite{BechavodLWZ21} consider a setting simpler than ours in which there are no confounding effects from agents’ unobserved types on their observable features and outcomes. As a result, the authors can apply standard least squares regression techniques to recover causal parameters.
Our work is also related to
\citet{miller2020strategic}, which shows that designing good incentives for agent improvement in strategic classification is at least as hard as orienting edges in the corresponding causal graph. In contrast to their work, we make the observation that the assessment rule deployed by the principal can be actively used as a valid \emph{instrument}, which allows us to circumvent this hardness result by performing an \emph{intervention} on the causal graph of the model.
Instrumental variable (IV) regression \citep{angrist2001iv, angrist1995tsls,angrist1996iv} has mostly been used for observational studies (see e.g., \cite{angrist06, bloom}). Similar to ours, there is recent work on constructing instruments through dynamic action recommendations in multi-armed bandits settings \cite{ngo2021ivbandits,Kallus2018InstrumentArmedB}.
We consider an orthogonal direction: constructing instruments through assessment rules in the strategic learning setting.
\section{IV Regression through Strategic Learning}\label{sec:main}
Instrumental variable (IV) regression allows for consistent estimation of the relationship between an outcome and observable features in the presence of confounding terms. In this setting, we view the assessment rules $\{\boldsymbol{\theta}_t\}_{t=1}^T$ as algorithmic instruments and perform IV regression to estimate the true causal relationship $\boldsymbol{\theta}^*$.
There are three criteria for $\boldsymbol{\theta}_t$ to be a valid instrument: (1) $\boldsymbol{\theta}_t$ influences the observable features $\mathbf{x}_t$, (2) $\boldsymbol{\theta}_t$ only influences the outcome $y_t$ through $\mathbf{x}_t$, and (3) $\boldsymbol{\theta}_t$ is independent from the private type $\mathbf{u}_t$. By design, criterion (1) and (2) are satisfied. We aim to design a mechanism that satisfies criterion (3) by choosing the assessment rule $\boldsymbol{\theta}_t$ independently of the private type $\mathbf{u}_t$. As can be seen by \Cref{fig:intro-dags}, the principal's assessment rule $\boldsymbol{\theta}_t$ satisfies these criteria.
We focus on two-stage least-squares regression (2SLS), a family of techniques for IV estimation.
Intuitively, 2SLS can be thought of as estimating the causal relationship $\boldsymbol{\theta}^*$ between $\mathbf{x}_t$ and $y_t$ by perturbing the instrument $\boldsymbol{\theta}$ and measuring the change in $\mathbf{x}_t$ and $y_t$. This enables us to account for the change in $y_t$ \emph{as a result of} the change in $\mathbf{x}_t$. 2SLS does this by independently estimating the relationship between an \emph{instrumental variable} $\boldsymbol{\theta}_t$ and the observable features $\mathbf{x}_t$, as well as the relationship between $\boldsymbol{\theta}_t$ and the outcome $y_t$ via simple least squares regression. For more background on the specific version of 2SLS we use, see Section 4.8 of \cite{cameron2005microeconometrics}.
Formally, given a set of observations $\{\boldsymbol{\theta}_t, \mathbf{x}_t, y_t\}_{t=1}^T$, we compute the estimate $\widehat{\boldsymbol{\theta}}$ of the true casual parameters $\boldsymbol{\theta}^*$ from the following process of two-stage least squares regression (2SLS). We use $\widetilde{\boldsymbol{\theta}}_t$ to denote the vector $\begin{bmatrix} \boldsymbol{\theta}_t & 1 \end{bmatrix}^\top$.
\begin{enumerate}[noitemsep,nolistsep]
\item Estimate $\Omega = \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top]$, $\mathbb{E}[\mathbf{b}_t^\top]$ using
\begin{equation*}
\begin{bmatrix}\widehat{\Omega}\\ \Bar{\mathbf{b}}^\top \end{bmatrix} = \left(\sum_{t=1}^T \widetilde{\boldsymbol{\theta}}_t \widetilde{\boldsymbol{\theta}}_t^\top \right)^{-1} \sum_{t=1}^T \widetilde{\boldsymbol{\theta}}_t \mathbf{x}_t^\top
\end{equation*}
\item Estimate $\boldsymbol{\lambda} = \Omega \boldsymbol{\theta}^*$, $(\mathbb{E}[o_t] + \mathbb{E}[\mathbf{b}_t^\top] \boldsymbol{\theta}^*)$ using
\begin{equation*}
\begin{bmatrix}\widehat{\boldsymbol{\lambda}}\\ \Bar{o} + \Bar{\mathbf{b}}^\top \boldsymbol{\theta}^* \end{bmatrix} = \left(\sum_{t=1}^T \widetilde{\boldsymbol{\theta}}_t \widetilde{\boldsymbol{\theta}}_t^\top \right)^{-1} \sum_{t=1}^T \widetilde{\boldsymbol{\theta}}_t y_t
\end{equation*}
\item Estimate $\boldsymbol{\theta}^*$ as $\widehat{\boldsymbol{\theta}} = \widehat{\Omega}^{-1} \widehat{\boldsymbol{\lambda}}$
\end{enumerate}
We assume that $\sum_{t=1}^T \widetilde{\boldsymbol{\theta}}_t \widetilde{\boldsymbol{\theta}}_t^\top$ is invertible, as is standard in the 2SLS literature. For proof that IV regression produces a consistent estimator of $\boldsymbol{\theta}^*$ under our setting, see Appendix \ref{sec:iv-regression}.
\begin{theorem}\label{thm:theta-bound}
Given a sequence of bounded assessment rules $\{\boldsymbol{\theta}_t\}_{t=1}^T$ and the (observable feature, outcome) pairs $\{(\mathbf{x}_t, y_t)\}_{t=1}^T$ they induce, the distance between the true causal relationship $\boldsymbol{\theta}^*$ and the estimate $\widehat{\boldsymbol{\theta}}$ obtained via IV regression is bounded as
\begin{equation*}
\| \widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^* \|_2 = \widetilde{\mathcal{O}}\left( \frac{ \sqrt{mT \log(1/\delta) }}{\sigma_{min}\left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)} \right)
\end{equation*}
with probability $1 - \delta$, if $o_t$ is a bounded random variable.
\end{theorem}
\emph{Proof Sketch.} While similar bounds exist for traditional IV regression problems, they do not apply to the strategic learning setting we consider. See Appendix \ref{sec:theta-bound-proof} for the full proof. The bound follows by substituting our expressions for $\mathbf{x}_t$, $y_t$ into the IV regression estimator, applying the Cauchy-Schwarz inequality to split the bound into two terms (one dependent on $\{(\boldsymbol{\theta}_t, \mathbf{x}_t)\}_{t=1}^T$ and one dependent on $\{(\boldsymbol{\theta}_t, o_t)\}_{t=1}^T$), and using a Chernoff bound to bound the term dependent on $\{(\boldsymbol{\theta}_t, o_t)\}_{t=1}^T$ with high probability.
While in some settings, the principal may only have access to \emph{observational} (e.g., batch) data, in other settings, the principal may be able to actively deploy assessment rules on the agent population. We show that in scenarios in which this is possible, the principal can play random assessment rules centered around some ``reasonable'' assessment rule to achieve an $\mathcal{O}\left(\frac{1}{\sigma_{\theta}^2 \sqrt{T}} \right)$ error bound on the estimated causal relationship $\widehat{\boldsymbol{\theta}}$, where $\sigma_{\theta}^2$ is the variance in each coordinate of $\boldsymbol{\theta}_t$. Note that while playing random assessment rules may be seen as unfair in some settings, the principal is free to set the variance parameter $\sigma_{\theta}^2$ to an ``acceptable'' amount for the domain they are working in. We formalize this notion in the following corollary.
\begin{corollary} \label{cor:theta-bound}
If each $\theta_{t,j}$, $j \in {1, \ldots, m}$, is drawn independently from some distribution $\mathcal{P}_j$ with variance $\sigma_{\theta}^2$, $\mathbf{b}_t$ and $\mathcal{E}_t$ are bounded random variables, $\mathcal{E}_t \mathcal{E}_t^\top$ is full-rank, and $\sigma_{min}(\mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top]) > 0$, then
\begin{equation*}
\| \widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^* \|_2 = \widetilde{\mathcal{O}} \left( \frac{\sqrt{m \log(1/\delta) }}{\sigma_{\theta}^2 \sqrt{T}} \right)
\end{equation*}
with probability $1 - \delta$.
\end{corollary}
\emph{Proof Sketch.} We begin by breaking up $\sigma_{min}\left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)$ into two terms, $\|A\|_2$ and $\sigma_{min}(B)$, where $A$ and $B$ are functions of $\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top$. We use the Chernoff and matrix Chernoff inequalities to bound $\|A\|_2$ and $\sigma_{min}(B)$ with high probability respectively. For the full proof, see Appendix \ref{sec:denom}.
\section{Setting of SGD comparison}\label{sec:figure-setting}
In 1D, the derivative of $\mathbb{E}[(\widehat{y}_t - y_t)]^2$ which accounts for $x_t$ and $y_t$'s dependence on $\boldsymbol{\theta}_t$ takes the form
\begin{equation*}
\begin{aligned}
\Delta &= 2(\mathbb{E}[(\widehat{y}_t - y_t) x_t] + \mathbb{E}_{x_t}[\widehat{y}_t - y_t]\mathcal{E}^2 (\theta_t - \theta^*)).
\end{aligned}
\end{equation*}
By plugging in for $x_t$, $y_t$, $\widehat{y}_t$ and simplifying, we can write the derivative as
\begin{equation*}
\begin{aligned}
\Delta &= 2 \left(\mathbb{E}[b_t^2] + \mathcal{E}^4 \theta_t^2 (\theta_t - \theta^*) - \mathbb{E}[o_t b_t] + \mathcal{E}^4 \theta_t (\theta_t - \theta^*)^2 \right).
\end{aligned}
\end{equation*}
The derivative of $\mathbb{E}[(\widehat{y}_t - y_t)]^2$ which does \emph{not} account for $x_t$ and $y_t$'s dependence on $\boldsymbol{\theta}_t$ can be written as
\begin{equation*}
\begin{aligned}
\Delta' &= 2 \left(\mathbb{E}[(\widehat{y}_t - y_t) x_t] \right)\\
&= 2 \left(\mathbb{E}[b_t^2] + \mathcal{E}^4 \theta_t^2 (\theta_t - \theta^*) - \mathbb{E}[o_t b_t] \right).
\end{aligned}
\end{equation*}
As can be seen by comparing the two equations, there is an extra $\mathcal{E}^4 \theta_t (\theta_t - \theta^*)^2$ term present in $\Delta$ that is not in $\Delta'$. This can cause $\Delta$ and $\Delta'$ to have opposite signs under certain scenarios, e.g. when $\mathbb{E}[b_t^2] + \mathcal{E}^4 \theta_t^2 (\theta_t - \theta^*) - \mathbb{E}[o_t b_t]$ is negative and $\mathcal{E}^4 \theta_t (\theta_t - \theta^*)^2$ is sufficiently large. To generate Figure \ref{fig:pp-vs-us}, we set $\mathbb{E}[b_t] = 0$, $\mathbb{E}[b_t^2] = 0.3$, $\mathbb{E}[o_t] = 0$, $\mathbb{E}[g^2_t] = 15$, $\mathbb{E}[o_t b_t] = -6.5$, $\mathcal{E} = 3$, $\theta^* = 1$, and $\theta_0 = 0.5$. To generate Figure \ref{fig:SGD-conv-invex} and \ref{fig:SSGD-conv-invex}, we changed $\theta^*$ to be $0.7$.
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{figures/SGD_convergence_plot_invex.png}
\caption{SGD with invex function}
\label{fig:SGD-conv-invex}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.5\linewidth]{figures/SGD_PP_convergence_plot_invex.png}
\caption{SSGD with invex function}
\label{fig:SSGD-conv-invex}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.5\textwidth]{figures/SGD_SSGD_distance_plot.png}
\caption{Convergence rate of Stochastic Gradient Descent vs Simple Stochastic Gradient Descent for simple 1D setting. Even when SSGD converges, it may do so at a much slower rate, due to the inexact measure of the gradient. We ran both methods for $1000$ time-steps with a decaying learning rate of $\frac{0.001}{\sqrt{T}}$. Results are averaged over 10 runs, with the error bars (in lighter colors) representing one standard deviation.}
\label{fig:pp-vs-us-convergence-rate}
\end{figure}
\iffalse
\begin{figure}
\centering
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{figures/SGD_convergence_plot_invex.png}
\caption{SGD with invex function. We ran SGD for $1000$ time-steps with a learning rate of $0.001$.}
\label{fig:SGD-conv-invex}
\end{subfigure}
~
\centering
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{figures/SGD_PP_convergence_plot_invex.png}
\caption{SSGD with invex function. Even when SSGD converges (right), it may do so at a much slower rate, due to the inexact measure of the gradient. We ran SSGD for $1000$ time-steps with a learning rate of $0.001$.}
\label{fig:SSGD-conv-invex}
\end{subfigure}
\caption{Even when SSGD converges (right), it may do so at a much slower rate, due to the inexact measure of the gradient. We ran both methods for $1000$ time-steps with a learning rate of $0.001$.}
\label{fig:pp-vs-us-3}
\end{figure}
\fi
\section{Comparison with \citeauthor{shavit2020strategic}}\label{sec:shavit}
The setting most similar to ours is that of \citeauthor{shavit2020strategic}. They consider a strategic classification setting in which an agent's outcome is a linear function of features --some observable and some not (see \Cref{fig:shavit-model-dag} for a graphical representation of their model). While they assume that an agent's hidden attributes can be modified strategically, we choose to model the agent as having an unmodifiable private \emph{type}. Both of these assumptions are reasonable, and some domains may be better described by one model than the other. For example, the model of \citeauthor{shavit2020strategic} may be useful in a setting such as car insurance pricing, where some unobservable factors which lead to safe driving are modifiable. On the other hand, settings like our college admissions example in which the unobservable features which contribute to college success (i.e. socioeconomic status, lack of resources, etc., captured in $o_t$) are not easily modifiable.
One benefit of our setting is that we are able to use $\boldsymbol{\theta}_t$ as a valid instrument to recover the true relationship $\boldsymbol{\theta}^*$ between observable features and outcomes. This is generally not possible in the model of \cite{shavit2020strategic}, since $\boldsymbol{\theta}_t$ violates the backdoor criterion as long as there exists any hidden features $\mathbf{h}_t$ and is therefore not a valid instrument. Another difference between our setting and theirs is that we allow for a heterogeneous population of agents, while they do not. Specifically, they assume that each agent's mapping from actions to features is the same, while our model is capable of handling mappings which vary from agent-to-agent.
A natural question is whether or not there exists a general model which captures the setting of both \citeauthor{shavit2020strategic} and ours. We provide such a model in \Cref{fig:general-model-dag}. In this setting, an agent has both observable and unobservable features, both of which are affected by the assessment rule $\boldsymbol{\theta}_t$ deployed and the agent's private type $u_t$. However, much like the setting of \citeauthor{shavit2020strategic}, $\boldsymbol{\theta}_t$ violates the backdoor criterion, so it cannot be used as a valid instrument in order to recover the true relationship between observable features and outcomes. Moreover, the following toy example illustrates that \emph{no} form of true parameter recovery can be performed when an agent's unobservable features are modifiable.
\begin{figure}
\centering
\begin{tikzpicture}[node distance={22mm}, thick, main/.style = {draw, circle}]
\node[draw,circle,fill=lightgray] (1) {$\boldsymbol{\theta}_t$};
\node[draw,circle,fill=lightgray] (2) [right of=1,yshift=0.65cm] {$\mathbf{x}_t$};
\node[node distance={15mm}, thick,draw,circle] (3) [below of=2] {$\mathbf{h}_t$};
\node[draw,circle,fill=lightgray,,yshift=-0.65cm] (4) [right of=2] {$y_t$};
\draw[->] (1) -- node[above left,xshift=0.35cm] {$\mathbf{a}_t$, $\mathcal{E}_t$} (2);
\draw[->] (1) -- node[below left,xshift=0.35cm] {$\mathbf{a}_t$, $\mathcal{E}_t$} (3);
\draw[->] (3) -- node[below right=-0.15cm] {$\boldsymbol{\theta}^*$} (4);
\draw[->] (2) -- node[above] {$\boldsymbol{\theta}^*$} (4);
\end{tikzpicture}
\caption{Graphical model of \citeauthor{shavit2020strategic}. Observable features $\mathbf{x}_t$ (e.g. the type of car a person drives) and unobservable features $\mathbf{h}_t$ (e.g. how defensive of a diver someone is) are affected by $\boldsymbol{\theta}_t$ through action $\mathbf{a}_t$ (e.g. buying a new car) and common action conversion matrix $\mathcal{E}$ (representing, in part, the cost to a person of buying a new car). Outcome $y_t$ (in this example, the person's chance of getting in an accident) is affected by $\mathbf{x}_t$ and $\mathbf{h}_t$ through the true causal relationship $\boldsymbol{\theta}_t$. Note that causal parameter recovery is not possible in this setting unless all features are observable.}
\label{fig:shavit-model-dag}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}[node distance={25mm}, thick, main/.style = {draw, circle}]
\node[draw,circle,fill=lightgray] (1) {$\boldsymbol{\theta}_t$};
\node[draw,circle,fill=lightgray] (2) [right of=1] {$\mathbf{x}_t$};
\node[node distance={20mm},draw,circle,fill=lightgray,yshift=-1.2cm] (3) [right of=2] {$y_t$};
\node[main] (4) [below of=1] {$u_t$};
\node[main] (5) [right of=4] {$\mathbf{h}_t$};
\draw[->] (1) -- node[above] {$\mathbf{a}_t$} (2);
\draw[->] (2) -- node[above] {$\boldsymbol{\theta}^*$} (3);
\draw[->] (1) -- node[above right,yshift=0.5cm,xshift=-0.55cm] {$\mathbf{a}_t$} (5);
\draw[->] (4) -- node[above,yshift=-.7cm,xshift=-1cm] {$\mathbf{b}_t,\mathcal{E}_t$} (2);
\draw[->] (5) -- node[below] {$\boldsymbol{\theta}^*$} (3);
\draw[->] (4) edge[bend right=2cm] node [below right]{$o_t$} (3);
\draw[->] (4) -- node[above] {$\mathbf{b}_t,\mathcal{E}_t$} (5);
\end{tikzpicture}
\caption{Graphical model which captures both our setting and that of \citeauthor{shavit2020strategic}. In this setting, observable features $\mathbf{x}_t$ \emph{and} unobservable features $\mathbf{h}_t$ are affected by $\boldsymbol{\theta}_t$ through action $\mathbf{a}_t$. The agent's private type $u_t$ affects $\mathbf{x}_t$ and $\mathbf{h}_t$ through initial feature values $\mathbf{b}_t$ and action conversion matrix $\mathcal{E}_t$. The agent's outcome $y_t$ depends on $\mathbf{x}_t$ and $\mathbf{h}_t$ through the causal relationship $\boldsymbol{\theta}^*$ and $u_t$ through confounding term $o_t$. Note that much like the setting of \cite{shavit2020strategic}, causal parameter recovery is not possible in this setting unless all features are observable.}
\label{fig:general-model-dag}
\end{figure}
\iffalse
\begin{figure}
\begin{subfigure}[t]{0.48\textwidth}
\centering
\begin{tikzpicture}[node distance={22mm}, thick, main/.style = {draw, circle}]
\node[draw,circle,fill=lightgray] (1) {$\boldsymbol{\theta}_t$};
\node[draw,circle,fill=lightgray] (2) [right of=1,yshift=0.65cm] {$\mathbf{x}_t$};
\node[node distance={15mm}, thick,draw,circle] (3) [below of=2] {$\mathbf{h}_t$};
\node[draw,circle,fill=lightgray,,yshift=-0.65cm] (4) [right of=2] {$y_t$};
\draw[->] (1) -- node[above left,xshift=0.35cm] {$\mathbf{a}_t$, $\mathcal{E}_t$} (2);
\draw[->] (1) -- node[below left,xshift=0.35cm] {$\mathbf{a}_t$, $\mathcal{E}_t$} (3);
\draw[->] (3) -- node[below right=-0.15cm] {$\boldsymbol{\theta}^*$} (4);
\draw[->] (2) -- node[above] {$\boldsymbol{\theta}^*$} (4);
\end{tikzpicture}
\caption{Graphical model of \citeauthor{shavit2020strategic}. Observable features $\mathbf{x}_t$ (e.g. the type of car a person drives) and unobservable features $\mathbf{h}_t$ (e.g. how defensive of a diver someone is) are affected by $\boldsymbol{\theta}_t$ through action $\mathbf{a}_t$ (e.g. buying a new car) and common action conversion matrix $\mathcal{E}$ (representing, in part, the cost to a person of buying a new car). Outcome $y_t$ (in this example, the person's chance of getting in an accident) is affected by $\mathbf{x}_t$ and $\mathbf{h}_t$ through the true causal relationship $\boldsymbol{\theta}_t$. Note that causal parameter recovery is not possible in this setting unless all features are observable.}
\label{fig:shavit-model-dag}
\end{subfigure}
~
\begin{subfigure}[t]{0.48\textwidth}
\centering
\begin{tikzpicture}[node distance={25mm}, thick, main/.style = {draw, circle}]
\node[draw,circle,fill=lightgray] (1) {$\boldsymbol{\theta}_t$};
\node[draw,circle,fill=lightgray] (2) [right of=1] {$\mathbf{x}_t$};
\node[node distance={20mm},draw,circle,fill=lightgray,yshift=-1.2cm] (3) [right of=2] {$y_t$};
\node[main] (4) [below of=1] {$u_t$};
\node[main] (5) [right of=4] {$\mathbf{h}_t$};
\draw[->] (1) -- node[above] {$\mathbf{a}_t$} (2);
\draw[->] (2) -- node[above] {$\boldsymbol{\theta}^*$} (3);
\draw[->] (1) -- node[above right,yshift=0.5cm,xshift=-0.55cm] {$\mathbf{a}_t$} (5);
\draw[->] (4) -- node[above,yshift=-.7cm,xshift=-1cm] {$\mathbf{b}_t,\mathcal{E}_t$} (2);
\draw[->] (5) -- node[below] {$\boldsymbol{\theta}^*$} (3);
\draw[->] (4) edge[bend right=2cm] node [below right]{$o_t$} (3);
\draw[->] (4) -- node[above] {$\mathbf{b}_t,\mathcal{E}_t$} (5);
\end{tikzpicture}
\caption{Graphical model which captures both our setting and that of \citeauthor{shavit2020strategic}. In this setting, observable features $\mathbf{x}_t$ \emph{and} unobservable features $\mathbf{h}_t$ are affected by $\boldsymbol{\theta}_t$ through action $\mathbf{a}_t$. The agent's private type $u_t$ affects $\mathbf{x}_t$ and $\mathbf{h}_t$ through initial feature values $\mathbf{b}_t$ and action conversion matrix $\mathcal{E}_t$. The agent's outcome $y_t$ depends on $\mathbf{x}_t$ and $\mathbf{h}_t$ through the causal relationship $\boldsymbol{\theta}^*$ and $u_t$ through confounding term $o_t$. Note that much like the setting of \cite{shavit2020strategic}, causal parameter recovery is not possible in this setting unless all features are observable.}
\label{fig:general-model-dag}
\end{subfigure}
\end{figure}
\fi
\begin{example}
Consider the one-dimensional setting
\begin{equation*}
y_t = \theta^*x_t + \beta^* h_t,
\end{equation*}
where $x_t$ is an agent's observable, modifiable feature and $h_t$ is an unobservable, modifiable feature. If the relationship between $x_t$ and $h_t$ is unknown, then it is generally impossible to recover the true relationship between $x_t$, $h_t$, and outcome $y_t$. To see this, consider the setting where $h_t$ and $x_t$ are highly correlated. In the extreme case, take $h_t = x_t, \; \forall t$. (Note we use equality to indicate identical feature values, not a causal relationship.) In this setting, the models $\theta^* = 1$, $\beta^* = 1$ and $\theta^* = 2$, $\beta^* = 0$ produce the same outcome $y_t$ for all $x \in \mathbb{R}$, making it impossible to distinguish between the two models, even in the limit of infinite data.
\end{example}
\section{Causal parameter recovery derivations}
\subsection{Proof of Theorem \ref{thm:theta-bound}} \label{sec:theta-bound-proof}
Recall that $\widehat{\boldsymbol{\theta}} = \left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)^{-1} \sum_{t=1}^T \boldsymbol{\theta}_t (y_t - \Bar{o} - \Bar{\mathbf{b}}^\top \boldsymbol{\theta}^*)$ from Appendix \ref{sec:2SLS-derivations}. Plugging this into $\|\widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^*\|_2$, we get
\begin{equation*}
\begin{aligned}
&\left\| \widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^* \right\|_2 =\\ &\left\| \left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)^{-1} \left(\sum_{t=1}^T \boldsymbol{\theta}_t (y_t - \Bar{o} - \Bar{\mathbf{b}}^\top \boldsymbol{\theta}^*) \right) - \boldsymbol{\theta}^* \right\|_2
\end{aligned}
\end{equation*}
Next, we substitute in our expression for $y_t$ and simplify, obtaining
\begin{equation*} \label{eq:bound-main}
\begin{aligned}
&\| \widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^* \|_2\\
&= \left\| \left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)^{-1} \right.\\ &\left. \left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t^\top \boldsymbol{\theta}^* + o_t - \Bar{o} - \Bar{\mathbf{b}}^\top \boldsymbol{\theta}^*) \right) - \boldsymbol{\theta}^* \right\|_2\\
&= \left\| \left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)^{-1} \left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \boldsymbol{\theta}^* \right) \right.\\ &\left.+ \left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t- \Bar{\mathbf{b}})^\top \right)^{-1} \left(\sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \Bar{o}) \right) - \boldsymbol{\theta}^*\right\|_2\\
&= \left\| \boldsymbol{\theta}^* + \left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)^{-1} \left(\sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \Bar{o}) \right) - \boldsymbol{\theta}^*\right\|_2\\
&= \left\|\left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)^{-1} \left(\sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \Bar{o}) \right) \right\|_2\\
& \leq \left\|\left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)^{-1} \right\|_2 \left \|\sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \Bar{o}) \right\|_2\\
& \leq \frac{\left \|\sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \Bar{o}) \right\|_2}{\sigma_{min}\left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)}
\end{aligned}
\end{equation*}
We now bound the numerator and denominator separately with high probability.
\subsection{Bound on numerator}
\begin{equation*}
\begin{aligned}
&\left \|\sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \Bar{o}) \right\|_2 = \left \|\sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \mathbb{E}[o_t] + \mathbb{E}[o_t] - \Bar{o}) \right\|_2\\
&\leq \left \|\sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \mathbb{E}[o_t]) \right \|_2 + \left \|\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbb{E}[o_t] - \Bar{o}) \right\|_2\\
\end{aligned}
\end{equation*}
\subsubsection{Bound on first term}
\begin{equation*}
\begin{aligned}
&\left \|\sum_{t=1}^T \boldsymbol{\theta}_t (o_t - \mathbb{E}[o_t]) \right \|_2\\ &= \left(\sum_{j=1}^m \left(\sum_{t=1}^T \theta_{t,j} (o_t - \mathbb{E}[o_t]) \right)^2\right)^{1/2}
\end{aligned}
\end{equation*}
Since $(o_t - \mathbb{E}[o_t])$ is a zero-mean bounded random variable with variance parameter $\sigma_g^2$, the product $\theta_{t,j} (o_t - \mathbb{E}[o_t])$ will also be a zero-mean bounded random variable with variance at most $\beta^2 \sigma_g^2$. In order to bound $\left(\sum_{j=1}^m \left(\sum_{t=1}^T \theta_{t,j} (o_t - \mathbb{E}[o_t]) \right)^2\right)^{1/2}$ with high probability, we make use of the following lemma. Note that bounded random variables are sub-Gaussian random variables.
\begin{lemma}[High probability bound on the sum of unbounded sub-Gaussian random variables] \label{lemma:chernoff}
Let $x_t \sim \text{subG}(0, \sigma^2)$. For any $\delta \in (0, 1)$, with probability at least $1 - \delta$,
\begin{equation*}
\Big|\sum_{t=1}^T x_t\Big| \leq \sigma \sqrt{2T\log(1/\delta)}
\end{equation*}
\end{lemma}
Applying Lemma \ref{lemma:chernoff} to $\left(\sum_{j=1}^m \left(\sum_{t=1}^T \theta_{t,j} (o_t - \mathbb{E}[o_t]) \right)^2\right)^{1/2}$, we get
\begin{align*}
&\sqrt{\sum_{j=1}^m \left(\sum_{t=1}^T \theta_{t,j} (o_t - \mathbb{E}[o_t]) \right)^2}\\
&\leq \sqrt{\sum_{j=1}^m \left(\beta \sigma_g \sqrt{2T\log(1/\delta_j)} \right)^2}\\
&\leq \sqrt{\sum_{j=1}^m \beta^2 \sigma_g^2 2T\log(m/\delta)} \tag{by a union bound, where $\delta_j=\delta/m$ for all $j$}\\
&\leq \beta \sigma_g \sqrt{2Tm\log(m/\delta)}\\
\end{align*}
with probability at least $1 - \delta$.
\subsubsection{Bound on second term}
\begin{equation*}
\begin{aligned}
&\left \|\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbb{E}[o_t] - \Bar{o}) \right\|_2\\
&= \left \|\sum_{t=1}^T \boldsymbol{\theta}_t \left(\mathbb{E}[o_t] - \frac{1}{T} \sum_{s=1}^T o_s \right) \right\|_2\\
&= \left \|\sum_{t=1}^T \boldsymbol{\theta}_t \frac{1}{T} \sum_{s=1}^T \left(\mathbb{E}[o_t] - o_s \right) \right\|_2\\
&= \left(\sum_{j=1}^m \left( \sum_{t=1}^T \theta_{t,j} \frac{1}{T} \sum_{s=1}^T \left(\mathbb{E}[o_t] - o_s \right)\right)^2\right)^{1/2}\\
&\leq \left(\sum_{j=1}^m \left( \sum_{t=1}^T |\theta_{t,j}| \frac{1}{T} \left| \sum_{s=1}^T \mathbb{E}[o_t] - o_s \right| \right)^2\right)^{1/2}\\
\end{aligned}
\end{equation*}
After applying Lemma \ref{lemma:chernoff}, we get
\begin{equation*}
\begin{aligned}
&\left \|\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbb{E}[o_t] - \Bar{o}) \right\|_2\\
&\leq \left(\sum_{j=1}^m \left( \sum_{t=1}^T |\theta_{t,j}| \frac{1}{T} \sigma_g \sqrt{2T \log(1/\delta_j)} \right)^2\right)^{1/2}\\
&\leq \left(\sum_{j=1}^m \left( \beta \sigma_g \sqrt{2T \log(1/\delta_j)} \right)^2\right)^{1/2}\\
&\leq \left(\sum_{j=1}^m \beta^2 \sigma_g^2 2T \log(m/\delta) \right)^{1/2}\\
&\leq \beta \sigma_g \sqrt{2Tm \log(m/\delta)}\\
\end{aligned}
\end{equation*}
with probability at least $1 - \delta$
\subsection{Proof of Corollary \ref{cor:theta-bound}} \label{sec:denom}
Next let's bound the denominator. By plugging in the expression for $\mathbf{x}_t$, we see that
\begin{equation*}
\begin{aligned}
&\sigma_{min}\left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{x}_t - \Bar{\mathbf{b}})^\top \right)\\
&= \sigma_{min}\left(\sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{b}_t- \Bar{\mathbf{b}})^\top + \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \mathcal{E}_t \mathcal{E}_t^\top \right)\\
&= \sigma_{min}\left(A + B\right),
\end{aligned}
\end{equation*}
where $A = \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{b}_t- \Bar{\mathbf{b}})^\top$ and $B = \sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \mathcal{E}_t \mathcal{E}_t^\top$. By definition,
\begin{equation*}
\sigma_{min}(A+B) = \min_{\mathbf{a}, \|\mathbf{a}\|_2 = 1} \|(A + B)\mathbf{a}\|_2.
\end{equation*}
Via the triangle inequality,
\begin{equation*} \label{eq:triangle}
\begin{aligned}
\sigma_{min}(A+B)
&\geq \min_{\mathbf{a}, \|\mathbf{a}\|_2 = 1} \left( \|B\mathbf{a}\|_2 - \|A\mathbf{a}\|_2 \right)\\
&\geq \min_{\mathbf{a}, \|\mathbf{a}\|_2 = 1} \|B\mathbf{a}\|_2 - \|A\|_2\\
&\geq \sigma_{min}(B) - \|A\|_2\\.
\end{aligned}
\end{equation*}
\subsubsection{Bounding $\|A\|_2$}
\begin{equation*}
\begin{aligned}
\|A\|_2 &= \left \| \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{b}_t - \mathbb{E}[\mathbf{b}_t] + \mathbb{E}[\mathbf{b}_t] - \Bar{\mathbf{b}})^\top \right \|_2\\
&\leq \left \| \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{b}_t - \mathbb{E}[\mathbf{b}_t])^\top \right \|_2 + \left \| \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbb{E}[\mathbf{b}_t] - \Bar{\mathbf{b}})^\top \right \|_2\\
\end{aligned}
\end{equation*}
\xhdr{Bound on first term}
\begin{equation*}
\begin{aligned}
&\left \| \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{b}_t - \mathbb{E}[\mathbf{b}_t])^\top \right \|_2
\leq \left \| \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{b}_t - \mathbb{E}[\mathbf{b}_t])^\top \right \|_F\\
&\leq \left( \sum_{i=1}^m \sum_{j=1}^m \left ( \sum_{t=1}^T \theta_{t,i} (z_{t,j} - \mathbb{E}[z_{t,j}]) \right )^2 \right)^{1/2}\\
\end{aligned}
\end{equation*}
Notice that $\theta_{t,i} (z_{t,j} - \mathbb{E}[z_{t,j}])$ is a zero-mean bounded random variable with variance at most $\beta^2 \sigma_z^2$. Applying Lemma \ref{lemma:chernoff}, we can see that
\begin{equation*}
\begin{aligned}
&\left \| \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{b}_t - \mathbb{E}[\mathbf{b}_t])^\top \right \|_2\\
&\leq \left( \sum_{i=1}^m \sum_{j=1}^m \left ( \beta \sigma_z \sqrt{2T \log(1/\delta_{i,j})} \right )^2 \right)^{1/2}\\
&\leq \left( \sum_{i=1}^m \sum_{j=1}^m \beta^2 \sigma_z^2 2T \log(m^2/\delta) \right)^{1/2}\\
&\leq \left( m^2 \beta^2 \sigma_z^2 2T \log(m^2/\delta) \right)^{1/2}\\
&\leq m \beta \sigma_z \sqrt{2T \log(m^2/\delta)}\\
\end{aligned}
\end{equation*}
with probability at least $1 - \delta$.
\xhdr{Bound on second term}
\begin{equation*}
\begin{aligned}
&\left \| \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbb{E}[\mathbf{b}_t] - \Bar{\mathbf{b}})^\top \right \|_2\\
&= \left \| \sum_{t=1}^T \boldsymbol{\theta}_t \frac{1}{T} \sum_{s=1}^T (\mathbb{E}[\mathbf{b}_t] - \mathbf{b}_j)^\top \right \|_2\\
&\leq \left \| \sum_{t=1}^T \boldsymbol{\theta}_t \frac{1}{T} \sum_{s=1}^T (\mathbb{E}[\mathbf{b}_t] - \mathbf{b}_j)^\top \right \|_F\\
&\leq \left( \sum_{i=1}^m \sum_{j=1}^m \left ( \sum_{t=1}^T \theta_{t,i} \frac{1}{T} \sum_{s=1}^T (\mathbb{E}[z_{t,j}] - z_j) \right )^2 \right)^{1/2}\\
&\leq \left( \sum_{i=1}^m \sum_{j=1}^m \left ( \sum_{t=1}^T |\theta_{t,i}| \frac{1}{T} \left|\sum_{s=1}^T (\mathbb{E}[z_{t,j}] - z_j) \right| \right )^2 \right)^{1/2}\\
\end{aligned}
\end{equation*}
By applying Lemma \ref{lemma:chernoff}, we obtain
\begin{equation*}
\begin{aligned}
&\left \| \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbb{E}[\mathbf{b}_t] - \Bar{\mathbf{b}})^\top \right \|_2\\
&\leq \left( \sum_{i=1}^m \sum_{j=1}^m \left ( \sum_{t=1}^T |\theta_{t,i}| \frac{1}{T} \sigma_{z} \sqrt{2T \log(1/\delta_{i,j})} \right )^2 \right)^{1/2}\\
&\leq \left( \sum_{i=1}^m \sum_{j=1}^m \left ( \beta \sigma_{z} \sqrt{2T \log(1/\delta_{i,j})} \right )^2 \right)^{1/2}\\
&\leq \left( \sum_{i=1}^m \sum_{j=1}^m \beta^2 \sigma_{z}^2 2T \log(m^2/\delta) \right)^{1/2}\\
&\leq m \beta \sigma_{z} \sqrt{2T \log(m^2/\delta)}\\
\end{aligned}
\end{equation*}
\iffalse
In order to bound $\|A\|_2 = \| \sum_{t=1}^T \boldsymbol{\theta}_t (\mathbf{b}_t - \Bar{\mathbf{b}})^\top \|_2$, we make use of the following lemma.
\begin{lemma}[Matrix Bernstein]\cite{tropp2015introduction} \label{lemma:bernstein}
Consider a finite sequence $\{S_i\}_{t=1}^T$ of independent, random matrices with common dimension $d_1 \times d_2$. Assume that $\mathbb{E}[S_t] = 0_{d_1 \times d_2}$ and $\|S_t\|_2 \leq L$ for each index $t$.
Introduce the random matrix $A = \sum_{t=1}^T S_t$. Let $v(A)$ be the matrix variance statistic of the sum:
\begin{equation*}
\begin{aligned}
v(A)
&= \max\left\{ \left\|\mathbb{E}[AA^\top]\|_2, \|\mathbb{E}[A^\top A] \right\|_2 \right\}\\
&= \max\left\{ \left\| \sum_{t=1}^T \mathbb{E}[S_t S_t^\top]\|_2, \| \sum_{t=1}^T \mathbb{E}[S_t^\top S_t] \right\|_2 \right\}.
\end{aligned}
\end{equation*}
Then for all $\alpha \geq 0$,
\begin{equation*}
P(\|A\|_2 \geq \alpha) \leq (d_1 + d_2) \exp \left( \frac{-\alpha^2/2}{v(A) + L\alpha/3} \right)
\end{equation*}
\end{lemma}
Let $S_t = \boldsymbol{\theta}_t \mathbf{b}_t^\top$. $\|\mathbb{E}[S_t]\|_2 = 0$, since $\mathbb{E}[\mathbf{b}_t] = \mathbf{0}$ w.l.o.g., and $\boldsymbol{\theta}_t$ is independent from $\mathbf{b}_t$. Let $\eta_1 = \mathbb{E}[\mathbf{b}_t^\top \mathbf{b}_t]$, $\rho_1 = \| \mathbb{E}[\mathbf{b}_t \mathbf{b}_t^\top] \|_2$, $\eta_2 = \mathbb{E}[\boldsymbol{\theta}_t^\top \boldsymbol{\theta}_t]$, $\rho_2 = \| \mathbb{E}[\boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top] \|_2$, and $\nu = \max\left\{\eta_1 \rho_2, \eta_2 \rho_1 \right\}$. The matrix variance statistic $v(A)$ can be upper bounded as follows:
\begin{equation*}
\begin{aligned}
v(A)
&= \max\left\{ \left\| \sum_{t=1}^T \mathbb{E}[S_t S_t^\top]\|_2, \| \sum_{t=1}^T \mathbb{E}[S_t^\top S_t] \right\|_2 \right\}\\
&\leq T\max\left\{ \left\|\mathbb{E}[S_t S_t^\top]\|_2, \| \mathbb{E}[S_t^\top S_t] \right\|_2 \right\}\\
&\leq T\max\left\{ \left\|\mathbb{E}[\boldsymbol{\theta}_t \mathbf{b}_t^\top \mathbf{b}_t \boldsymbol{\theta}_t^\top] \right\|_2, \left\| \mathbb{E}[\mathbf{b}_t \boldsymbol{\theta}_t^\top \boldsymbol{\theta}_t \mathbf{b}_t^\top] \right\|_2 \right\}\\
&\leq T\max\left\{ \left\|\mathbb{E}[\mathbf{b}_t^\top \mathbf{b}_t] \mathbb{E}[\boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top] \right\|_2, \left\| \mathbb{E}[\boldsymbol{\theta}_t^\top \boldsymbol{\theta}_t] \mathbb{E}[\mathbf{b}_t \mathbf{b}_t^\top] \right\|_2 \right\}\\
&\leq T\max\left\{\mathbb{E}[\mathbf{b}_t^\top \mathbf{b}_t] \left\|\mathbb{E}[\boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top] \right\|_2, \mathbb{E}[\boldsymbol{\theta}_t^\top \boldsymbol{\theta}_t]\left\| \mathbb{E}[\mathbf{b}_t \mathbf{b}_t^\top] \right\|_2 \right\}\\
&\leq T\max\left\{\eta_1 \rho_2, \eta_2 \rho_1 \right\}\\
&\leq \nu T \\
\end{aligned}
\end{equation*}
Next we pick an appropriate value for $L$.
\begin{equation*}
\begin{aligned}
\|S_t\|_2
&= \|\boldsymbol{\theta}_t \mathbf{b}_t^\top \|_2\\
& \leq \beta \|\mathbf{1}_m \mathbf{b}_t^\top\|_2\\
& \leq \gamma \beta m,
\end{aligned}
\end{equation*}
so we set $L = \gamma \beta m$.
Applying Lemma \ref{lemma:bernstein}, we obtain
\begin{equation*}
P(\|A\|_2 \geq \alpha) \leq 2m \exp \left( \frac{-\alpha^2/2}{\nu T + \gamma \beta m \alpha/3} \right)
\end{equation*}
Next we set the RHS equal to $\delta$ and lower bound $\alpha$:
\begin{equation*}
\exp{\frac{-\alpha^2/2}{\nu T + \gamma \beta m \alpha/2}} = \frac{\delta}{2m}
\end{equation*}
\begin{equation*}
\frac{\alpha^2}{\nu T + \gamma \beta m \alpha/2} = 2 \log{\frac{2m}{\delta}}
\end{equation*}
\begin{equation*}
\frac{\alpha^2}{\nu T} \geq 2 \log{\frac{2m}{\delta}}
\end{equation*}
\begin{equation*}
\alpha \geq \sqrt{2T \nu \log{\frac{2m}{\delta}}}
\end{equation*}
Therefore,
\begin{equation*}
\|A\|_2 \leq \sqrt{2T \nu \log{\frac{2m}{\delta}}}
\end{equation*}
with probability at least $1 - \delta$.
\fi
\subsubsection{Bounding $\sigma_{min}(B)$}
Next we bound $\sigma_{min}(B) = \sigma_{min}(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \mathcal{E}_t \mathcal{E}_t^\top)$. We can write $\mathcal{E}_t \mathcal{E}_t^\top$ as $\mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top] + \varepsilon_t$. Note that since each element of $\mathcal{E}_t$ is bounded, each element of $\varepsilon_t \in \mathbb{R}^{m \times m}$ will be bounded as well. Using this formulation,
\begin{equation*}
\begin{aligned}
\sigma_{min}(B)
&= \sigma_{min} \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top( \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top] + \varepsilon_t) \right)\\
&= \sigma_{min} \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top] + \sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \varepsilon_t) \right)\\
&\geq \sigma_{min} \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top] \right) - \left\|\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \varepsilon_t \right\|_2\\
&\geq \sigma_{min} \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top] \right) - \left\|\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \varepsilon_t \right\|_F\\
\end{aligned}
\end{equation*}
We proceed by bounding each term separately.
\xhdr{Bound on first term}
\begin{equation*}
\begin{aligned}
&\sigma_{min} \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top] \right)\\ &\geq \sigma_{min}(\mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top])\sigma_{min}(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top)
\end{aligned}
\end{equation*}
Let $c = \sigma_{min}(\mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top])$. We assume that $\mathcal{E}_t$ is distributed such that $c > 0$. Therefore,
\begin{equation*}
\sigma_{min} \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \mathbb{E}[\mathcal{E}_t \mathcal{E}_t^\top] \right) \geq c\sigma_{min}(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top).
\end{equation*}
Next, we use the matrix Chernoff bound to bound $c \sigma_{min}(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top) = c \lambda_{min}(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top)$ with high probability.
\begin{theorem}[Matrix Chernoff]
Consider a finite sequence $\{X_t\}_{t=1}^T$ of independent, random, Hermitian matrices with common dimension $d$. Assume that
\begin{equation*}
0 \leq \lambda_{min}(X_t) \text{ and } \lambda_{max}(X_t) \leq L \text{ for each index } t
\end{equation*}
Introduce the random matrix
\begin{equation*}
Y = \sum_{t=1}^T X_t.
\end{equation*}
Define the minimum eigenvalue $\mu_{min}$ of the expectation $\mathbb{E}[Y]$:
\begin{equation*}
\begin{aligned}
\mu_{min} &= \lambda_{min}(\mathbb{E}[Y]) = \lambda_{min} \left(\sum_{t=1}^T \mathbb{E}[X_t] \right)
\end{aligned}
\end{equation*}
Then,
\begin{equation*}
P(\lambda_{min}(Y) \leq (1 - \varepsilon)\mu_{min}) \leq d\left(\frac{e^{-\varepsilon}}{(1 - \varepsilon)^{1-\varepsilon}} \right)^{\mu_{min}/L}
\end{equation*}
for $\varepsilon \in [0, 1)$.
\end{theorem}
Let $Y = \sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top$. In our setting,
\begin{equation*}
\begin{aligned}
\mu_{min} &= \lambda_{min}\left(\sum_{t=1}^T \mathbb{E}[\boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top] \right)\\
&= T \lambda_{min}\left(\mathbb{E}[\boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top] \right)\\
&= T \lambda_{min}\left(\sigma_{\theta}^2 \mathbb{I}_{m \times m} + \mathbb{E}[\boldsymbol{\theta}_t] \mathbb{E}[\boldsymbol{\theta}_t^\top] \right)\\
\end{aligned}
\end{equation*}
$\sigma_{\theta}^2 \mathbb{I}_{m \times m}$ and $\mathbb{E}[\boldsymbol{\theta}_t] \mathbb{E}[\boldsymbol{\theta}_t^\top]$ commute, so
\iffalse
\lscomment{Can we say $\mu_{\min} \geq T \left( \lambda_{min}\left(\sigma_{\theta}^2 \mathbb{I}_{m \times m} \right) + \lambda_{min}\left(\mathbb{E}[\boldsymbol{\theta}_t] \mathbb{E}[\boldsymbol{\theta}_t^\top] \right) \right)$? That way, $\lambda_{\min}(Y)\leq(1-\varepsilon)\left(T \left( \lambda_{min}\left(\sigma_{\theta}^2 \mathbb{I}_{m \times m} \right) + \lambda_{min}\left(\mathbb{E}[\boldsymbol{\theta}_t] \mathbb{E}[\boldsymbol{\theta}_t^\top] \right) \right)\right)\leq(1-\varepsilon)\mu_{\min}$}
\fi
\begin{equation*}
\begin{aligned}
\mu_{min} &= T \left( \lambda_{min}\left(\sigma_{\theta}^2 \mathbb{I}_{m \times m} \right) + \lambda_{min}\left(\mathbb{E}[\boldsymbol{\theta}_t] \mathbb{E}[\boldsymbol{\theta}_t^\top] \right) \right)\\
&= T \lambda_{min}\left(\sigma_{\theta}^2 \mathbb{I}_{m \times m} \right)\\
&= T \sigma_{\theta}^2 \lambda_{min}\left(\mathbb{I}_{m \times m} \right)\\
&= T \sigma_{\theta}^2\\
\end{aligned}
\end{equation*}
\begin{equation*}
\lambda_{max}(\boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top) = \beta m,
\end{equation*}
so let $L = \beta m$.
Picking $\varepsilon = 1/2$ and applying the matrix Chernoff bound to $ \lambda_{min}(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top)$, we obtain
\begin{equation*}
P\left(\lambda_{min} \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \right)\leq \frac{1}{2}T \sigma_{\theta}^2 \right) \leq d\left(\frac{1}{2}e \right)^{-\frac{T \sigma_{\theta}^2}{2\beta m}}
\end{equation*}
By rearranging terms, we see that if $T \geq \frac{2 \beta m}{\sigma_{\theta}^2 \log{ \frac{1}{2}e}}\log{\frac{d}{\delta}}$, then
\begin{equation*}
\lambda_{min} \left(\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \right) \geq \frac{1}{2}T \sigma_{\theta}^2
\end{equation*}
with probability at least $1 - \delta$.
\xhdr{Bound on second term}
\begin{equation*}
\begin{aligned}
\left\|\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \varepsilon_t \right\|_F
&= \left(\sum_{i=1}^m \sum_{j=1}^m \left(\sum_{t=1}^T \theta_{t,i} \theta_{t,j} \varepsilon_{t,i,j} \right)^2 \right)^{1/2}\\
\end{aligned}
\end{equation*}
Since each $\varepsilon_{t,i,j}$ is a bounded zero-mean random variable, $\theta_{t,i} \theta_{t,j} \varepsilon_{t,i,j}$ is also a bounded zero-mean random variable, with variance at most $\beta^4 \sigma_{\mathcal{E}}^2$ We can now apply Lemma \ref{lemma:chernoff}:
\begin{equation*}
\begin{aligned}
&\left\|\sum_{t=1}^T \boldsymbol{\theta}_t \boldsymbol{\theta}_t^\top \varepsilon_t \right\|_F\\
&\leq \left(\sum_{i=1}^m \sum_{j=1}^m \left(\beta^2 \sigma_{\mathcal{E}} \sqrt{2T \log (1/\delta_{i,j})} \right)^2 \right)^{1/2}\\
&\leq \left(\sum_{i=1}^m \sum_{j=1}^m \beta^4 \sigma_{\mathcal{E}}^2 2T \log (m^2/\delta) \right)^{1/2}\\
&\leq \left(m^2 \beta^4 \sigma_{\mathcal{E}}^2 2T \log (m^2/\delta) \right)^{1/2}\\
&\leq m \beta^2 \sigma_{\mathcal{E}} \sqrt{2T \log (m^2/\delta)}\\
\end{aligned}
\end{equation*}
with probability at least $1 - \delta$.
\xhdr{Putting everything together}
Putting everything together, we have that
\begin{equation*}
\begin{aligned}
&\| \widehat{\boldsymbol{\theta}} - \boldsymbol{\theta}^* \|_2 \leq\\ &\frac{2\beta \sigma_g \sqrt{2m\log(m/\delta)} }{\frac{1}{2}c \sqrt{T} \sigma_{\theta}^2 - m \beta^2 \sigma_{\mathcal{E}} \sqrt{2 \log (m^2/\delta)} - 2m \beta \sigma_z \sqrt{2 \log(m^2/\delta)}}
\end{aligned}
\end{equation*}
with probability at least $1 - 6\delta$. | {'timestamp': '2022-06-10T02:05:52', 'yymm': '2107', 'arxiv_id': '2107.05762', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05762'} | arxiv |
\section{Introduction}
Stress describes bodily reactions to perceived physical or psychological threats \cite{b0} and is defined as the transition from a calm state to an excited state triggering a cascade of physiological response \cite{b1}. In the United States of America, around $77\%$ people suffer from headaches and insomnia for reasons related to stress, and there has been a steady increase in the number of people suffering from stress-related issues each year \cite{b2}.
Furthermore, stress plays a critical role in many health problems, such as depression, anxiety, high blood pressure, heart attacks, and stroke \cite{b3}. Stress also influences a person's decision-making capability, attention span, learning, and problem-solving capacity \cite{b4}. Stress detection and monitoring is an active research area with important implications for the personal, professional, and social health of an individual. Stress detection and monitoring can help prevent dangerous stress-related diseases. Towards this end, in this paper we propose, a novel Convolutional Neural Network (CNN) based framework for stress detection and classification, which uses raw Electrodermal Activity (EDA) sensor data without feature computation. Our approach is competitive with other state-of-the-art methods and does not suffers from many limitations inherent in earlier works. Figure \ref{fig:system} shows the general overview of a stress detection system used for real-time interventions to support the health of an individual. In this paper, we implement the stress classification pipeline, and in the future, we aim to use our classification model for strategic real-time interventions.
\begin{figure}[!tbh]
\centering
\includegraphics[width=\linewidth]{images/general_system_block_diagram.png}
\caption{A stress detection and context recognition framework using sensor systems and machine learning algorithms.}
\label{fig:system}
\end{figure}
\label{related_work}
Usually, for stress detection and classification data from multiple sensor modalities such as heart rate variability (HRV), body acceleration (ACC), skin temperature, electrodermal activity (EDA), blood volume pulse (BVP), respiration rate, and electrocardiogram (ECG) are used to compute a large number of statistical and structural features to train machine learning algorithms. In \cite{b6}, the authors computed $67$ features from $7$ sensor modalities to train a stress classification model with the best accuracy of $92.28\%$. Using the same dataset, the authors in \cite{b3} used Deep Neural Networks (DNN) and $40$ statistical features to achieve an accuracy of $95.21\%$. In \cite{b4} the authors used statistical features and representation learned by a deep learning model as features to train the stress classification model with accuracy up to $92\%$ with just EDA data. Motivated by the results from \cite{b6}, the authors in \cite{b7} computed $195$ features in time, frequency, entropy, and wavelet domain from EDA data to train the XGBoost algorithm with the highest accuracy of $92\%$. Feature selection was used to reduce the number of features to $9$ for the best possible classification accuracy. Furthermore, some works have also explored ways not to use electrodermal activity for stress classification since most commercial smartwatches and smart health devices don't have sensors to measure galvanic skin response. In \cite{b8}, authors used data from the built-in smartphone accelerometer sensor to identify activity that corresponds with stress levels and achieved an accuracy of $71\%$. Also, in \cite{b9} data from a commercial smartwatch was used for binary stress classification with accuracy up to $83\%$.
Using data from multiple sensors and computing a large number of features to train machine learning algorithms for stress classification has several disadvantages. Using numerous sensor modalities makes the system design complicated and expensive and hence unfit to be used in everyday lives. Also, sensors need power to operate, and more sensors draw more power, which is a big issue in battery-powered wearable systems. Computing features require domain knowledge, and extensive testing is needed to find the best set of features for optimal classification performance. Furthermore, computing a large number of complex features makes the classification algorithm less efficient in terms of run-time, energy, and memory. Besides, feature selection is needed to select the most meaningful features and adds an extra processing step to an already complex machine learning pipeline. Motivated by these drawbacks of multi-modal feature-based stress classification algorithms, in this paper, we propose a CNN-based stress detection and classification system which takes raw EDA sensor segments as inputs and learns and select the dominant features automatically during the training process. Our primary objective is to implement a stress detection and classification system using only the EDA data. The secondary goal was to explore the personalization of stress models. Perception and effects of stress are subjective in nature. The same external stimuli can have a varying degree of effect on different individuals in terms of stress and emotional arousal. Hence, we also investigate whether stress detection algorithms need personalization or not.
\section{Methodology}
\subsection{Dataset}
The Wearable Stress and Affect Detection (WESAD) dataset \cite{b6} is a publicly available dataset with ECG, EDA, BVP, respiration (RESP), skin temperature (TEMP), and motion (Acceleration) (ACC) sensor data obtained from the RespiBan (chest-worn) and Empatica E4 (wrist-worn) devices. The dataset was collected from $15$ subjects (3 female) in a laboratory setting, and each subject experienced three main affect conditions: baseline or normal (neutral reading), stress (exposed to Tier Social Stress Test (TSST)), and amusement (watching funny videos). In our analysis, we only use the EDA data from the Empatica E4 sampled at $4$Hz. Approximately the length of the stressed condition was $10$ minutes, amusement $6.5$ minutes, and baseline situation was $20$ minutes.
\subsection{Segmentation and Normalization}
For each subject, we have approximately $37$ minutes of EDA data. We segment the EDA data for the three affective states into $60$ seconds overlapping segments with $50\%$ overlap between consecutive segments. We settled on the window size of $60$ seconds because of available literature that has also used $60$ seconds window size for the WESAD dataset \cite{b3, b4, b5, b6}. Before segmentation, we normalize the data for each subject using the min-max normalization to spread the data in the range of $[0, 1]$. After segmentation, we obtain $564$ samples for the baseline class, $311$ samples for the stressed class, and $165$ samples for the amusement class. In our analysis, we have not used any method to deal with class imbalance and machine learning models are trained on the imbalance data for the worst case scenario.
\begin{figure}[!tbh]
\centering
\includegraphics[width=0.8\linewidth]{images/model_arc_neo.png}
\caption{The architecture of the convolutional neural network used for stress classification. Input sensor segment is fed into the convolutional stack to extract features. Extracted features are passed into the dense stack to learn the associations between the input and output classes. The recognition layer predicts stress classes for the input EDA segment.}
\label{fig:methodology}
\end{figure}
\vspace{-2.5mm}
\subsection{Convolutional Neural Network}
Data-driven learning algorithms learn associations between input and outputs directly from the sensor data without feature computation. These methods learn features and classifier simultaneously from the sensor data. A convolutional neural network (CNN) is a data-driven learning algorithm capable of learning local dependency and scale invariance in the input data without feature computation. In CNN, the convolution operation is used between the input and a weight matrix or filters to assemble complex features by successively learning smaller and simpler features. Consequently, CNN is suitable for our approach towards stress detection and classification, and hence we have used $1D$ CNN as the learning algorithm in our work. We have used a ConvNet architecture composed of two $1D$ convolutional layers with $100$ filters each and kernel size of $5$ and $10$ respectively. This is followed by a global max-pooling layer and two fully connected layers with $128$ and $64$ neurons. We also have drop-out layers after each fully connected layer with drop-out values $0.3$ and $0.2$. The output layer has Softmax activation, and all other layers have ReLU \cite{b10} activation. Figure \ref{fig:methodology} shows the graphical representation of the proposed CNN used in this paper.
\subsection{Hyperparameters and Training}
The hyperparameters in our framework were selected after extensive trial and error. The CNN models were trained for $200$ epochs with a batch size of $32$ and a fixed learning rate of $0.001$. Out of $876$ samples in the dataset, $657$ or $75\%$ was included in the training set, and $219$ or $25\%$ belonged to the test set. For bi-affective state classification, data from the baseline (not-stress) and stressed classes were used to create the training and test sets. For tri-affective state classification data for all three classes: baseline, stressed, and amusement were used to create the training and test sets.
\section{Results and Observations}
Due to the lack of space, we have omitted training curves of the CNN models and we want to confirm we observed no overfitting during training.
\subsection{Stress Classification}
First, we present the results for the bi-affective state classification i.e., the binary case of stress Vs. not-stress classification. The trained CNN model achieved the best classification accuracy of $94.8\%$ on the training set and $90.9\%$ on the test set. Table \ref{tab:bi-affective}, shows the value of other performance metrics.
\vspace{-2.5mm}
\begin{table}[htbp]
\caption{Results for the bi-affective stress state classification.}
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
Dataset & Accuracy & Precision & Recall & f1-Score \\
\hline
Training Set & $94.8\%$ & $0.96$ & $0.88$ & $0.92$ \\
\hline
Testing Set & $90.9\%$ & $0.91$ & $0.82$ & $0.87$ \\
\hline
\end{tabular}
\label{tab:bi-affective}
\end{center}
\end{table}
\vspace{-2.5mm}
In the second case, we consider the tri-affective state classification, a multi-class classification problem with $3$ classes: stress, not-stress, and amusement. Table \ref{tab:tri-affective} shows the values of performance metrics for this case. Note that the performance of the CNN model has decreased in the tri-affective case compared to the bi-affective case. We suspect this is because the model doesn't have enough training samples to learn the distinction between the three classes.
\vspace{-2.5mm}
\begin{table}[htbp]
\caption{Results for the tri-affective stress state classification.}
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
Dataset & Accuracy & Precision & Recall & f1-Score \\
\hline
Training Set & $85.1\%$ & $0.83$ & $0.79$ & $0.80$ \\
\hline
Testing Set & $82\%$ & $0.82$ & $0.72$ & $0.76$ \\
\hline
\end{tabular}
\label{tab:tri-affective}
\end{center}
\end{table}
\vspace{-2.5mm}
Furthermore, to account for the variance in performance, we conducted $10-$fold cross-validation for both cases of affective state classification. Table \ref{tab:cv_results} shows the average classification accuracy and f1-score for bi-affective and tri-affective cases.
\vspace{-2.5mm}
\begin{table}[htbp]
\caption{Average classification accuracy and f1-score.}
\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline
& Dataset & Accuracy & f1-Score \\
\hline
\multirow{ 2}{*}{Bi-affective} & Training Set & $93\%$ & $0.9$ \\
& Testing Set & $90\%$ & $0.86$ \\
\hline
\multirow{ 2}{*}{Tri-affective} & Training Set & $84\%$ & $0.79$ \\
& Testing Set & $80\%$ & $0.75$ \\
\hline
\end{tabular}
\label{tab:cv_results}
\end{center}
\end{table}
\vspace{-2.5mm}
Finally, we present comparisons of our results with other state-of-the-art works on stress classification with the WESAD dataset in table \ref{tab:comp_SOTA}. WESAD dataset has the following modalities ACC, EDA, TEMP, ECG, BVP, and RESP, and is represented by \textit{All} in the table. All other compared approaches, details in \ref{related_work}, computes statistical or representational features from sensor data to train stress classification models. Our method, does not involves computation intensive feature computation and selection stages and uses the raw sensor data for training. Also, our approach is based on CNNs whereas compared methods are based on neural networks as well as statistical learning algorithms. We found our proposed approach to be competitive with state-of-the-art methods with the added advantage of being data-driven without needing any specialized domain knowledge for feature computation and selection.
\vspace{-2.5mm}
\begin{table}[htbp]
\caption{Comparisons of our proposed approach with state-of-the-art methods.}
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
Method & Model Type & Modalities & Accuracy (\%) & f1-Score \\
\hline
\cite{b6} & Feature & All & $93$ & $0.9$ \\
\hline
\cite{b4} & Feature & EDA & $91.60$ & - \\
\hline
\cite{b7} & Feature & EDA & $-$ & $0.92$ \\
\hline
\cite{b3} & Feature & All & $95.21$ & $0.94$\\
\hline
\textbf{Our's} & \textbf{Data} & \textbf{EDA} & \mbox{\boldmath$92.85$} & \mbox{\boldmath $0.89$} \\
\hline
\end{tabular}
\label{tab:comp_SOTA}
\end{center}
\end{table}
\vspace{-2.5mm}
\subsection{Personalization of Stress Models}
To investigate the subjective nature of stress and determine whether we need personalized models for stress detection and classification, we present the results of leave-one-subject-out (LOSO) analysis on the binary WESAD dataset. In LOSO analysis, data from one subject is removed from the training set and kept as the test set to evaluate the trained machine learning model. The WESAD dataset was collected from $15$ subjects and we present the results of LOSO analysis for each subjects. Figure \ref{fig:loso_acc} shows the classification accuracy and figure \ref{fig:loso_f1} shows the f1-score of the trained models on the test and training sets. The x-axis represents the subject whose data was not included in the training set and was used as the test set. Based on our results, we can confirm that stress is subjective, and the same external stimuli can have varying effects on different individuals.
On the test data for left out subjects \textit{S2, S3, S7, S11, S14,} and \textit{S17} the trained models performed poorly, but for subjects \textit{S4, S5, S6, S8, S9, S13} and \textit{S15} the trained model performed better compared to the training set. Furthermore, the performance of the model on the test data for left out subjects \textit{S10} and \textit{S16} was similar to that on the training set. The discrepancies in the results of LOSO analysis can be attributed to many different reasons such as physical characteristics, emotional endurance, stress management skills, personality traits, and noise in the sensor data.
For example, subject $S3$ was looking forward to stress conditions and was cheerful during data collection. Subject $S5$ might have fallen asleep during the first meditation phase and subject $S6$ had a stressful week, and the study was relaxing and not very stressful. Also, subject $S8$ already had a stressful day before the study and felt cold in the study room. These observations suggest that to better account for the differences between individuals towards the perception of stressful events and to build a general model for stress classification personalization of stress models is needed.
The authors in \cite{b3} also used LOSO for cross-validation and were able to achieve a classification accuracy of $95.21\%$ and f1-score of $0.94$ with a neural network trained on features data computed from all sensor modalities. In \cite{b7} the authors, computed various features from EDA data, and were able to achieve an average f1-score of $0.89$ with the XGBoost algorithm. Our LOSO analysis is based on just EDA data without any feature computing, and on average, across subjects, our method has the classification accuracy of $85.44\%$ and f1-score of $0.75$.
\vspace{-2.5mm}
\begin{figure}[!tbh]
\centering
\includegraphics[width=0.9\linewidth]{images/loso_acc.pdf}
\caption{Classification accuracy on the training and test sets for leave-one-subject-out analysis. The x-axis represents the subject whose data was not included in the training set and was used as the test set. }
\label{fig:loso_acc}
\end{figure}
\vspace{-2.5mm}
\begin{figure}[!tbh]
\centering
\includegraphics[width=0.9\linewidth]{images/loso_f1_score.pdf}
\caption{f1-score on the training and test sets for the leave-one-subject-out analysis to investigate the subjective nature of stress. The x-axis represents the subject whose data was not included in the training set and was used as the test set.}
\label{fig:loso_f1}
\end{figure}
\vspace{-1.5mm}
To personalize the stress models for left-out subjects whose test set performance was lower than the training set, we re-trained the machine learning models on the left-out subject data. Starting from $1$ sample from the test set, we successively increased the number of samples used for re-training the model until the performance of the model on the test set was greater or equal to that on the original training set. Table \ref{tab:personalization_samples} shows the number of samples needed for each left-out subject and the final test set accuracy after re-training. The performance of the model on the test set increased significantly after re-training, suggesting we need personalized stress models for maximum performance.
\vspace{-3.5mm}
\begin{table}[htbp]
\caption{Number of samples needed to personalize stress models for left out subjects with test accuracy lower than training accuracy.}
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
Subject & \multicolumn{1}{|p{1.3cm}|}{\centering Original \\ Test Set \\ Accuracy} & \multicolumn{1}{|p{1.3cm}|}{\centering Total Samples} & \multicolumn{1}{|p{1.3cm}|}{\centering Re-training \\ Sample Size} & \multicolumn{1}{|p{1.3cm}|}{\centering Final \\ Test Set \\ Accuracy} \\
\hline
S2 & $76.8$ & $56$ & $43$ & $96.4$ \\
\hline
S3 & $67.9$ & $56$ & $56$ & $83.9$ \\
\hline
S7 & $84.5$ & $58$ & $40$ & $98.3$ \\
\hline
S11 & $66.1$ & $59$ & $52$ & $98.3$ \\
\hline
S14 & $55.9$ & $59$ & $42$ & $94.9$ \\
\hline
S17 & $57.4$ & $61$ & $43$ & $93.4$ \\
\hline
\end{tabular}
\label{tab:personalization_samples}
\end{center}
\end{table}
\vspace{-2.5mm}
\section{Conclusion}
In this work, we proposed a novel CNN-based stress detection and classification framework that uses raw EDA sensor data without feature computation and selection for affective states (stressed vs. normal vs. amusement) classification. We used the EDA data because EDA is found to be the best indicator of stress. Our approach can be adapted to include other sensor modalities for possible performance improvement also extended to other datasets. We also showed the need for a personalized stress model with our leave one subject analysis. Our approach is competitive with other state-of-the-art methods and does not suffer from many disadvantages such as feature computation and selection, multi-modal input data, and complex system design.
| {'timestamp': '2021-07-14T02:01:13', 'yymm': '2107', 'arxiv_id': '2107.05666', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05666'} | arxiv |
\section{Introduction}
To draw conclusions about individual variables of interest in a task, one builds structured probabilistic graphical models to describe statistical relations among all variables and marginalizes out all other unobserved variables. Such exact inference computations are infeasible in general, due to exponential complexity in practice when the latent space is large. Often the latent space to be marginalized is decomposable due to conditional independencies between variables, allowing us to represent the full distribution as a probabilistic graphical model (PGM) \cite{koller2009probabilistic}. This may allow us to perform difficult global calculations using simpler integrations on subsets of variables. Such approaches are used by message-passing algorithms like Belief Propagation (BP) \cite{pearl1988probabilistic} and Expectation Propagation (EP) \cite{minka2001expectation}, widely used approaches to computing or approximating marginal probabilities using distributed computation. BP is guaranteed to yield exact results if the graph has a tree structure. However, on general graphs with loops, which are likely to be better descriptors of real data, BP can give approximate posteriors or even fail to converge.
Graphical models with pairwise interactions like Hopfield network \cite{hopfield1982neural} and Boltzmann machine \cite{sherrington1975solvable} have provided us with intriguing models for memory and learning, and has developed to layered neural networks which are widely used nowadays. However, sometimes basic pairwise interaction models do not suffice to explain real data patterns like neuronal avalanches \cite{beggs2003neuronal}, retinal activity patterns when exposing to natural stimuli \cite{Ganmor.Schneidman.2011}, and simultaneous silence of cultured hippocampal neurons \cite{shimazaki2015simultaneous}. Taking one step further, structured third-order interactions have been proposed for general probabilistic models \cite{sejnowski1986higher}, and have been used to model conditional correlation structure in movies \cite{memisevic2010learning}.
Including higher-order interactions increases model flexibility, but the number of possible interactions grows combinatorially with the interaction order. This makes exact inference problems intractable with limited computational resources and numbers of data points. Thus prior knowledge like locality or sparsity of interactions must be used, resulting in a structured factor graph.
Higher-order factor graph may have more loops compared to a pairwise graph with as many interactions. Local message-passing algorithms like BP suffer in the presence of loops and are thus likely to perform worse on many real-world graphical models. Even when applied to higher-order trees, message updates for BP usually don't have closed-form solutions, so running BP on these graphs becomes impractical.
To mitigate these drawbacks of BP and to provide an alternative on loopy graphs even without analytical update formulas, in this work we present a method to learn a recursive message-passing algorithm for fast approximate inference. Our method applies to a large family of higher-order graphical models with a wide range of graph structures and parameter values including very loopy ones. In the spirit of BP, we use a Graph Neural Network (GNN) \cite{scarselli2009graph,li2015gated} to perform message-passing on factor graphs. We train this network to compute sufficient statistics of all univariate marginal distributions simultaneously for each instance sampled from a parametrized family of PGMs.
To study the performance of our method, we perform experiments on two artificial datasets where we can calculate ground truth, and compare performance to BP: Gaussian Graphical Models (GGM) and a small binary spin-glass system with third-order interactions. GGMs only have pairwise interactions, but the ground truth marginals can easily be computed without message-passing for very large graphs. The graph size is kept under 15 for the binary spin-glass dataset for exact calculation of marginal probabilities by enumeration \cite{Yoon.Pitkow.2018}.
In addition, we construct a dataset of continuous PGMs with pairwise and third-order interactions. Since closed-form marginals do not exist for this interesting model class, we train our model to predict univariate statistics calculated by Markov Chain Monte Carlo (MCMC) sampling.
Our experiments show that the learnt algorithm has better performance than BP on an in-distribution test dataset, even when excluding those graphs on which BP dynamics don't converge.
We also show that our model generalizes reliably out of distribution to probabilistic graphical models of different sizes than the training set.
By looking at the error distribution for two graph metrics---average shortest path length and cluster coefficient---we find that our method outperforms BP particularly well on graphs with small average shortest path length and large cluster coefficients, which are the properties of many real world graphs \cite{watts1998collective}.
This suggests there is potential for using our model as an approximation inference method on real-world PGMs with higher-order interactions.
\section{Related Work}
Previous work has explored learning to pass messages that calculate marginal probabilities in graphical models. Some examined fast and approximate calculation of Belief Propagation or Expectation Propagation updates when analytical integration is not feasible for computing on the level of single factor \cite{Heess.Winn.2013, Eslami.Winn.2014, Jitkrittum.Szabo.2015}. Others created message-passing algorithms for inference in probabilistic graphical models, trying to learn an algorithm that is more accurate than Belief Propagation when the underlying graph is loopy \cite{Yoon.Pitkow.2018}.
The most related work to ours uses stacked bi-directional GNNs on factor graphs to perform maximum {\em a posteriori} estimation on binary graphical models \cite{Zhang.Lee.2019eqj}. One major difference is that we use a recurrent network instead of a feedforward one, so our method uses far fewer parameters and scales to larger graphs without adding new layers. Another difference is that we incorporate an attentional mechanism \cite{Velickovic.Bengio.2017} to increase model flexibility. Another related study puts a factor graph NN layer within a recurrent algorithm to calculate marginal probabilities in binary graphical models, applying them to low density parity check codes and Ising models \cite{Satorras.Welling.2020}. Instead of using a GNN to learn a novel message-passing algorithm from scratch, the authors build their algorithm on top of Belief Propagation and let GNN serve as an error-correction module for loopy BP.
Traditional Graph Neural Networks are defined on regular graphs with nodes and edges, and thus best work with models with only pairwise interactions. On the other hand, factor graphs or hypergraphs, which represent higher-order interactions directly, are usually preferred for message-passing algorithms like BP. Factor graphs \cite{frey1997factor} use two types of nodes: variable nodes (circles) for each variable, and factor nodes (squares) for each subset of directly interacting variables; edges connect factors to their constituent variables.
Some work has been done to extend GNNs to such higher-order graphs \cite{Bai.Torr.2019,Zhang.Ye.2019}, including studies aiming to solve graph isomorphism tasks \cite{Morris.Grohe.2019}, and others applying GNNs to data living on simplicial complexes \cite{Ebli.Spreemann.2020}.
\section{Methods}
\subsection{Probabilistic Graphical Models and Factor Graphs}
Probabilistic graphical models describe the conditional dependence structure among random variables using graphs.
We describe higher-order interactions using a factor graph \cite{frey1997factor}, which expresses the joint probability density as a product of local factors, $p({\mathbf{x}})\propto \prod_i f_i({\mathbf{x}}_i)$, each involving only a subset of variables ${\mathbf{x}}_i$
Exact inference in tree graphs can be performed by iteratively marginalizing out the leaves of the tree and propagating this information along the graph. This iterative algorithm is called belief propagation (BP), and has been applied with some success even on graphs with loops \cite{pearl1988probabilistic,bishop:2006:PRML}. Message updates in BP include multivariate integration, and don't always have close-form solutions. (Fully factorized) Expectation Propagation (EP) \cite{minka2001expectation} is an approximation to mitigate this issue by projecting the outgoing message to some user-chosen parametric family.
\subsection{Graph Neural Networks}
Graph Neural Networks (GNN) are artificial neural networks implementing a message-passing operation on a graph \cite{scarselli2009graph}. A GNN updates each node's representation based on aggregated messages from its neighbours.
Each node $i$ represents information as a vector ${\mathbf{h}}_i^t$ that evolves over time (or layer) $t$, and edges are assigned a vector weight ${\mathbf{e}}_{ij}$. The updated representation at time/layer $t+1$ can be described by:
\begin{equation}
{\mathbf{h}}_i^{t+1} = \mathcal{U}\left({\mathbf{h}}_i^t\,, \!\!\!\bigsqcup_{j\in N(i)\backslash\{j\}}\!\!\!\!\!\! \mathcal{M}({\mathbf{h}}_j^t, {\mathbf{h}}_i^t, {\mathbf{e}}_{ij})\right)
\end{equation}
where every message $\mathcal{M}({\mathbf{h}}_j^t, {\mathbf{h}}_i^t, {\mathbf{e}}_{ij})$ from neighbour $j$ to node $i$ along edge $ij$ is first calculated using a common trainable nonlinear function $\mathcal{M}$, then messages from all neighbours are aggregated together by a permutation-invariant function $\bigsqcup$ (e.g. summation), before being used to update each target node through another trainable function $\mathcal{U}$.
We recommend \cite{Zhou.Sun.2020} for a review of methods and application of GNNs.
\subsection{Factor Graph Neural Network}
In order to implement a message-passing algorithm on factor graphs, we first define a Graph Neural Network on bipartite graphs, unlike a typical GNN that treats all nodes equally \cite{Kipf.Welling.2016,gori2005new,li2015gated}. We thus define two distinct node types for variables and factors, represented by hidden vectors ${\mathbf{h}}_{v,i}^{(t)}$ and ${\mathbf{h}}_{f,i}^{(t)}$, with corresponding message and update functions for each. We also augment our GNN functions with a few extra operations. We reasoned that it would be beneficial if our network could identify loops and re-weight incoming messages accordingly, since Belief Propagation \cite{pearl1988probabilistic,wainwright2003tree} applied to loopy graphs exhibits errors traced back to the assumption of independent neighbors.
To this end we use the attention mechanism \cite{Velickovic.Bengio.2017} when aggregating message functions and we update hidden node representations using Gated Recurrent Unit (GRU) \cite{Cho2014} with LayerNorm \cite{Ba.Hinton.2016} to embue nodes with a long-term memory. In summary, our iterative algorithm is an RNN, with the activation layer being a bi-directional graph neural network with self-attention, as described mathematically below.
Our target inferences are over graphical models within the exponential family \cite{pitman1936sufficient,Koopman.1936.sufficient}, a broad class of probability distributions widely used in statistical analysis. The density of such a distribution can be parameterized by a vector of natural parameters $\boldsymbol{\eta}$:
\begin{equation}
p({\mathbf{x}}) = \frac{1}{Z(\boldsymbol{\eta})}\exp(\boldsymbol{\eta}^\top {\mathbf{T}}({\mathbf{x}}))
\end{equation}
where ${\mathbf{T}}({\mathbf{x}})$ is the vector of sufficient statistics and $Z(\boldsymbol{\eta})$ is a normalization constant. Combined with the factorization of the joint density, each individual factor can also be parametrized with its own vector of natural parameters $\boldsymbol{\eta}_i$:
\begin{equation}
p({\mathbf{x}}) = \frac{1}{Z(\boldsymbol{\eta})} \prod_i \exp(\boldsymbol{\eta}_i^\top {\mathbf{T}}_i({\mathbf{x}}_i))
\end{equation}
A PGM is then represented by sets of factor nodes, variable nodes, edges, and all natural parameters, $\{\mathcal{F},\mathcal{V},\mathcal{E}, H \}$. The process of marginalization converts the natural parameters to expectation parameters \cite{wainwright2008graphical,koller2009probabilistic}.
We use a MultiLayer Perceptron (MLP) to initialize the hidden states for factor nodes based on the natural parameters of the target graphical model. Separate MLPs are used for different types of factors, e.g., pairwise factors and third-order factors. The hidden states for variable nodes are initialized as a zero vector.
\begin{align}
&{\mathbf{h}}_{f,i}^{(0)} = \text{Encoder1}(\boldsymbol{\eta}_f) \\
&{\mathbf{h}}_{v,j}^{(0)} = \mathbf{0}
\end{align}
After initialization, we then update each node's hidden representation recurrently for $N$ time steps. In each step, a bi-directional Graph Attention Network (GAT) \cite{Velickovic.Bengio.2017} layer is used to calculate messages and they are aggregated as the activation for a GRU unit to compute the hidden state for the next step. Separate multi-head GAT networks are used for two types of messages: from variable node to factor node, and from factor node to variable node.
Likewise, we use different trainable weights for different factor types since they may behave differently.
For the factor node updates, we take a similar approach as in \cite{Gilmer.Dahl.2017} and transform the aggregated incoming message from neighboring variables by a factor-specific feature matrix ${\mathbf{F}}_i \in \mathbb{R}^{H\times H}$ as a constant input, which is mapped from its natural parameter $\boldsymbol{\eta}_i$ by a shared MLP for each type of factors.
\begin{align}
{\mathbf{F}}_i = \text{Encoder2}(\boldsymbol{\eta}_i)
\end{align}
The following equations show one-step message-passing for factor nodes. The updates for variable nodes are similar except for that there is no variable node feature, so \cref{eq:activation} is replaced by ${\mathbf{a}}_{i}^{(t+1)} ={\mathbf{m}}_{i}^{(t+1)}$. \cref{eq:message,eq:attention} reflect only one attention head. For multi-head attention, we simply duplicate $M_{f\leftarrow v}$ and $W_{f\leftarrow v}$ modules and the multi-head weighted summation in \cref{eq:summ-attention} is averaged over all heads. In our experiments, we use 5 attention heads for smoother learning.
\begin{align}
&\text{raw message from variable $j$ to factor $i$: } & &{\mathbf{m}}_{f\leftarrow v,ij}^{(t+1)} = M_{f\leftarrow v}({\mathbf{h}}_{f,i}^{(t)}, {\mathbf{h}}_{v,j}^{(t)})\label{eq:message} \\
&\text{attention weight from variable $j$ to factor $i$: } & &\alpha_{f\leftarrow v,ij}^{(t+1)} = \frac{W_{f\leftarrow v}({\mathbf{h}}_{f,i}^{(t)}, {\mathbf{h}}_{v,j}^{(t)})}{\sum_{k\in N(i)}W_{f\leftarrow v}({\mathbf{h}}_{f,i}^{(t)}, {\mathbf{h}}_{v,j}^{(t)}) } \label{eq:attention}\\
&\text{weighted summary message from variable $j$ to factor $i$: } & &{\mathbf{m}}_{i}^{(t+1)} = \sum_{k\in N(i)} \alpha_{f\leftarrow v,ik}^{(t+1)}{\mathbf{m}}_{f\leftarrow v,ik}^{(t+1)} \label{eq:summ-attention} \\
&\text{incorporate local factor features: } & & {\mathbf{a}}_{i}^{(t+1)} = {\mathbf{F}}_i {\mathbf{m}}_{i}^{(t+1)} \label{eq:activation}\\
&\text{update hidden state of factor $i$: } & &{\mathbf{h}}_{f,i}^{(t+1)} = \text{GRU}_f({\mathbf{a}}_{i}^{(t+1)},{\mathbf{h}}_{f,i}^{(t)} )
\end{align}
We would like our model to learn an iterative algorithm that converges to the target. So instead of choosing the number of time steps $N$ to be fixed, which we found often yielded RNN dynamics that passed through the target output without stopping, we randomly sample a readout time $N$ from a range, so the network cannot rely on any particular readout time. At that point we use a decoder MLP to read out expectation parameters of the univariate marginal distributions for each variable:
\begin{equation}
{\mathbf{y}}_j = \text{Decoder}({\mathbf{h}}_{v,j}^{(N)})
\end{equation}
\subsection{Datasets\label{sec:dataset}}
There are two practical use cases for applying our methods to improve on BP. First is to improve inference accuracy on loopy graphs where BP starts to perform poorly, and second is to make fast but approximate inferences on PGMs for which algorithms like BP or even Expectation Propagation \cite{minka2001expectation} become infeasible to run.
For tractability, most probabilistic models are based on pairwise interactions. But pairwise models would require many nonlinear auxiliary hidden variables to capture real-world data complexity such as multiplicative lighting, perspective transforms, triple synapses, or especially gating. In contrast, higher-order interactions could capture some of these interactions directly. Gating is a crucial, common operation in machine learning, as seen in LSTMs \cite{hochreiter1997long}, GRUs \cite{Cho2014}, and attention networks. Third-order multiplicative interactions can be effectively viewed as soft gating operations thus provide more modeling power while remaining interpretable. Thus here we choose continuous graphical models with third-order interactions as a distribution family of high interest. Such distributions fall into the latter category of application where traditional models are infeasible but our GNNs could apply.
Firstly, as a proof of concept, we construct two datasets of PGMs with known ground truth marginal distributions and closed-form BP update formulas so that we can compare the performance of our model with Belief Propagation. Second, we build a dataset of continuous PGMs with third-order interactions to test our model on this more complicated and interesting class of PGMs.
\subsubsection{Gaussian Graphical Model\label{dataset:ggm}}
As a toy example, we generate a dataset of random Gaussian Graphical Models (GGM). Since both marginalization and BP have closed-form solutions on GGMs, it becomes a convenient test for comparing our method with BP, and to test the generalization performance of our method to much larger out-of-distribution graphs.
We use the random graph generator algorithm WS-flex proposed in \cite{You.Xie.2020} to generate diverse graph structures parametrized by average shortest path length and cluster coefficient.
To generate a random graph, we first sample the average degree $k$ and rewiring probability $p$ parameters for the WS-flex algorithm from a uniform distribution over $[2,n-1]$ and $[0,1]$ where $n$ is the number of variables, and then construct a random graph using these parameters.
Each GGM has a precision matrix with non-zero entries randomly sampled by the WS-flex algorithm and eigenvalues uniformly drawn from $[0.1,10.0]$.
In order to achieve certain connectivity matrix with desired eigenvalues, we start from a positive-definite diagonal matrix, apply a random orthogonal rotation to make it dense, and then iteratively apply Jacobi rotations to zero out elements according to the connectivity matrix until we achieve the desired structure. We concentrate on inferring the node variances and give all GGMs mean of zero, since the hard part of calculating both marginal means and variances is the inversion of the precision matrix.
\subsubsection{Binary third-order factor graph \label{dataset:3spin}}
Our method works with general factor graphs, especially those with higher-order interactions, but GGMs have only pairwise interactions and can also be modeled by regular GNNs. To test our model on graphs with higher-order factors, we construct a dataset composed of binary graphical models with only third-order interactions.
For the sake of exact solutions of marginal probabilities, we choose small binary spin glass models whose structures and connectivity strengths are randomly sampled so that exact marginal probabilities can be calculated by brute-force enumeration. The joint probability mass function is expressed as
\begin{align}
p(\{{\mathbf{s}}\}) \propto \exp\Big( \beta (\sum_{p=1}^{3}\sum_{i\in \mathds{1}_{\mathcal{V}}} b_{i,p} s_i^p + \sum_{(ijk) \in \mathcal{N}(\mathcal{F})}J_{ijk}s_is_js_k)\Big)
\end{align}
$\mathcal{N}(\mathcal{F})$ is the set of neighbor variable indices for each factor. We generate these random factor graphs using a generalization of the WS-flex generator, parameterized by average variable node degree $k_3$ and rewiring probability $p$. Details of the algorithm could be found in the supplementary material. The singleton potential coefficients $b_i^p$ and 3-way coupling coefficients $J_{ijk}$ are randomly drawn from a standard Gaussian distribution and the inverse temperature, $\beta$, is chosen to be $0.5$.
\subsubsection{Continuous third-order factor graph \label{dataset:3continuous}}
We are interested in continuous graphical models with third-order interactions, and we propose to use our method as an approximate inference algorithm for this model class. We construct a dataset of random continuous PGMs with third-order interactions and evaluate the accuracy of our message-passing algorithm against an expensive sampling approach. For each inference problem, a factor graph is randomly constructed such that 3-factors are generated using the aforementioned WS-flex variant, and 2-factors are generated using the regular WS-flex algorithm. Each graph structure is parametrized by three numbers: the average outdegree of variable nodes to 2-factor nodes $k_2$, the average outdegree of variable nodes to 3-factor nodes $k_3$, and the rewiring probability $p$. $k_2$ is uniformly sampled from $[2,n-1]$, $k_3$ is uniformly sampled from $[2,\floor{(n-1)(n-2)/6}]$, and $p$ is uniformly sampled from $[0,1]$. An isotropic 4th-order base measure is added to ensure the joint density is normalizable:
\begin{align}
p({\mathbf{x}}) \propto \exp\Big[ - \beta \Big(\sum_{p=1}^{3}\sum_{i\in \mathds{1}_{\mathcal{V}}} b_{i,p} x_i^p + \sum_{(ij)\in \mathcal{N}(\mathcal{F}_2)}K_{ij}x_ix_j + \sum_{(ijk)\in \mathcal{N}(\mathcal{F}_3)}J_{ijk}x_ix_jx_k + \alpha \lVert {\mathbf{x}} \rVert_{\ell_4}^4 \Big) \Big]
\end{align}
Bias parameters $\{b_{i,p}\}$ and interaction strengths $\{K_{ij}\},\{J_{ijk}\}$ are sampled from a standard normal distribution $\mathcal{N}(0,1)$. The strength of the 4th-order term and the inverse temperature were $\alpha=1.0$ and $\beta=0.3$.
Note that this exponential family of distributions is not closed under marginalization: marginals are not in the same family as the joint.
We run an MCMC algorithm, the No-U-Turn Sampler (NUTS) \cite{hoffman2014no}, using the Stan \cite{standev2021stancore,stansamplejl} software for a large number of steps as an approximate ground truth. Our readout targets are summary statistics computed from those generated samples. For each random structure generated, we run 8 MCMC chains with 10000 warmup steps and 10000 sampling step each for a random set of parameter values and keep drawing new parameters until the potential scale reduction factor (PSRF) \cite{gelman1992inference} falls below $1.2$, indicating convergence has been reached for the MCMC chains. Here we choose the first four central moments as our targets since the Jensen-Shannon divergence between the empirical sample distribution and corresponding moment-matched maximum-entropy distribution does not decrease substantially when including more moments. \cref{fig:marginal} shows random examples of sampled univariate marginals, the corresponding singleton distributions obtained by ignoring all multivariate interactions, and their maximum entropy counterparts by matching the first four central moments.
\begin{figure}
\centering
\includegraphics[width=\textwidth]{figures/Fig4-3cont-marginal.pdf}
\caption{Example univariate marginal distributions from the continuous 3rd-order dataset. Shaded blue curves represents empirical marginal distributions from samples. Shaded orange curves are empirical single-variate distributions by only considering singleton potentials. Green dots represent the maximum entropy fit of the sample marginal distributions by matching first four central moments.}
\label{fig:marginal}
\end{figure}
\subsection{Training\label{sec:training}}
We implement our models\footnote{Code is at \url{https://github.com/fy0cc/factor-inference-net/}} in PyTorch \cite{NEURIPS2019_9015} and PyTorch Geometric \cite{Fey/Lenssen/2019} and perform all experiments on internal clusters equipped with NVIDIA GTX 1080Ti and Titan RTX GPUs. We randomly split eash dataset into a training and a validation set of ratio 4:1. The testing sets are constructed separately for different graph sizes. In every experiment, we use the ADAM \cite{Kingma.Ba.2014} optimizer with batch size 100 and initial learning rate $0.001$. We multiply the learning rate by a factor of $0.2$ if there is no improvement in 20 epochs, and perform early-stopping if there is no improvement in 40 epochs.
We choose the dimension of hidden states for both variable and factor nodes ${\mathbf{h}}_v,{\mathbf{h}}_f$ to be 64, and 5 attention heads are used for all experiments. For the encoder and decoder MLPs, we insert a BatchNorm \cite{ioffe2015batch} layer after the input layer and each hidden layer.
We use mean-squared error (MSE) as loss on single-variate marginal precision values for the Gaussian dataset and on the first four central moments calculated from MCMC samples for the continuous third-order factor graph dataset respectively. As of the the binary spin-glass dataset, we use binary cross entropy as loss.
\section{Experiments and Results\label{sec:experiment} }
All GNNs are trained on graphs with size 10 solely, but are tested on graphs of various sizes. We uniformly draw the number of recurrent steps $N$ from $[30,50]$. $N$ is set as 30 during testing. We repeat all experiments 10 times from different random seeds and report the mean and standard error on a held-out test set in \cref{result-table}.
Additionally, for each dataset, we pick the GNN with the lowest validation error among 10 run, and then compare their in-sample and out-of-sample error against BP in the space of graph metrics.
As a baseline to show how strong the interactions are in each dataset, we also train a separate GNN (singleton GNN) that tries to predict the same target, but only sees singleton factors in the graphical model. Singleton GNN would have lower performance on graphs whose marginal distributions are strongly affected by multivariate interactions.
Results of BP, full GNN, and singleton GNN are shown in \cref{fig:ggm-spin}. Each point along with its error bar represents the bootstrapped mean and 95\% confidence interval of the mean calculated from 100 resampling of the corresponding test set. Some error bars may be too small to see.
\subsection{Gaussian Graphical Models\label{results:ggm}}
\subsubsection{Loopy Graphs\label{results:ggm-all}}
In this experiment we tested the performance of our model on Gaussian Graphical Models with zero mean, random precision matrices, and various structures generated as described in \cref{dataset:ggm}.
For a single GGM, the inverse variance of each variable's marginal Gaussian distribution is used as target for supervised learning. 10000 random graphs with 10 variables are generated as a training dataset.
Additionally, we generate various testing datasets with 10 to 50 variables, each consisting of 2000 random graphs.
\cref{fig:ggm-spin}(b), shows that our model trained on a dataset of GGMs with 10 variables has average KL divergence 6-fold smaller than Belief Propagation on a in-sample test set.
When generalizing to larger graphs, our model still has smaller error than BP on graphs up to 30 variables. Other metrics, including $R^2$ score and MSE (the training objective), are also shown in \cref{fig:ggm-spin}(a)(c).
Since BP doesn't always converge on loopy graphs, all metrics are calculated on the subset of test graphs with convergent BP dynamics, which compose 73.2\% to 71.2\% of test set as graph size varies from 10 to 50. BP is considered non-convergent if the absolute error of beliefs between two adjacent BP updates still exceeds $10^{-5}$ after 1000 cycles.
It is well known that Belief Propagation becomes non-exact on loopy graphs. Here we empirically investigate how BP and GNN performance depends on the graph structure by examining graph metrics. We choose two independent structural features that quantify the loopiness of a graph: average shortest path length and cluster coefficient \cite{watts1998collective}.
The former quantifies the average loop length between any two nodes, and the latter describes the small-world property of a graph.
Graphs in the test set are binned into 10 equal bins according the the graph metric, and for each bin we report the bootstrapped mean and its 95\% CI for BP and GNN performance metrics (\cref{fig:ggm-spin}(d-g)). Many real-world graphs have a small average path length and a large cluster coefficient \cite{watts1998collective}, and this is the region where our model outperforms BP.
BP can be viewed as an algorithm that finds local minima of the Bethe free energy by iteratively update messages until convergence \cite{heskes2003stable}. Similarly, we also define our algorithm to be recursive. However, as comparison, we also constructed a feedforward model with 10 Factor-GNN layers stacked together. \cref{fig:ggm-spin}(a-g) and \cref{result-table} shows that although the feedforward model has almost 10 times more parameters, the performance is worse than the recurrent one.
\subsubsection{Tree Graphs\label{results:ggm-tree}}
BP is exact on tree graphs, so we also trained a model with a dataset of 10000 Gaussian tree graphs with size 10 using the eigenvalue distribution in \cref{dataset:ggm}. A random tree structure is constructed by converting from a random Pr{\"u}fer sequence \cite{prufer1918neuer}, which is sampled uniformly from the symmetry group $S_{n-2}$ where $n$ is the number of nodes in the tree.
BP is exact on trees with zero error, but our model also achieves excellent generalization performance with an in-distribution $R^2$ score $0.9995\pm 0.0001$ and out-of-sample $R^2$ score $0.9996\pm 0.0002$ even when generalizing to graphs with size 50.
\begin{figure}
\centering
\makebox[\textwidth][c]{\includegraphics[width=1.2\textwidth]{figures/Fig3-gaussian-3spin.pdf}}
\caption{Performance on Gaussian, third-order spin, and third-order continuous datasets. Each row shows results of one dataset.In the first three columns, we compare the generalization performance of GNN and BP to larger graphs. All GNNs are trained on graphs with size 10. We also consider an additional 10-layer stacked GNN for the Gaussian dataset as a comparison. Three metrics-$R^2$, KL divergence and MSE-are shown for the Gaussian and spin datasets. KL divergence is not available for the third-order continuous dataset thus omitted. Column 4 and 5 show how error of different methods depends on graph structures. We plot error against the average shortest path length in column 4, and against cluster coefficient in column 5. For each dataset, we show the in-sample results in the first row and generalization results on larger graphs in the second row.}
\label{fig:ggm-spin}
\end{figure}
\subsection{Spin systems with third-order interactions\label{result:3spin}}
For the binary spin systems with only third-order interactions and no pairwise interactions, we train our model on a dataset of size 10 and test on graphs with sizes from 6 to 15. We didn't test on larger graphs because it becomes impractical to enumerate all spin configurations in order to compute exact marginal probabilities.
For binary graphical models, unlike in \ref{results:ggm}, non-convergent BP dynamics won't diverge, but may oscillate. Thus we take the beliefs from the last cycle if the dynamics does not converge in 1000 cycles. There is no qualitative difference when evaluating model performance using the whole test dataset or just BP-convergent ones, so we report the metrics on BP-convergent graphs to maintain consistency with \ref{results:ggm}.
Within the range of testing graphs, our model consistently outperforms BP on average(\cref{fig:ggm-spin}(h-j)).
In the space of graph structures parametrized by average shortest path length and cluster coefficient, our model performs better than BP in regions with smaller average shortest path length and larger cluster coefficient, which agrees with the result of \cref{results:ggm}(\cref{fig:ggm-spin}(k-n)).
\subsection{Continuous third-order graphical model\label{result:3cont}}
For general continuous non-Gaussian graphical models it is not feasible to compare our method with BP because the BP message update neither an explicit formula, nor could be calculated exactly by enumeration. Even the EP message update needs to be approximated \cite{Heess.Winn.2013,Eslami.Winn.2014,Jitkrittum.Szabo.2015}.
Like these approximation methods, we also train a predictor to calculate approximate marginal distributions. However, instead of approximating the EP message-passing for a specific type of factors within the EP framework, we learn a new message-passing algorithm end-to-end that works with many factor types and doesn't share EP's limitations. This approach is more applicable to loopy graphs where BP and EP struggle.
For this experiment we constructed a continuous graphical model with third-order interactions and train our model to predict the first four central moments of every univariate marginal distribution (see Section \ref{dataset:3continuous}).
Since BP or EP is not feasible for this dataset, we only compare our model with the singleton GNN as our baseline.
A model trained on graphs with 10 variables achieves an in-sample $R^2$ score of $0.911\pm 0.005$, while the baseline model without interactions has an $R^2$ of only $0.654\pm 0.001$. We test the generalization performance of our model with a dataset of graphs of size 20. For the MCMC algorithm to produce convergent chains, we shrink the interaction strengths by a factor of 2 but keep the singleton parameter distribution unchanged so that both input and output values fall in the training ranges. On a test set of 1000 graphs,
the full model has an $R^2$ score of $0.582\pm 0.021$, while the baseline model has an $R^2$ score of $0.495\pm 0.000$. Qualitatively similar to the Gaussian and spin dataset, model performance drops when generalizing to larger graphs (\cref{fig:ggm-spin}(o-p)), and our model has larger error on loopy graphs (\cref{fig:ggm-spin}(q-t)) since these are hard ones.
\begin{table}
\caption{Experiment results on 4 PGM datasets}
\label{result-table}
\makebox[\textwidth][c]{
\begin{tabular}{llcccc}
\toprule
metric & \diagbox[dir=SE]{method}{dataset}& GGM-tree & GGM-all & 3rd-order binary & 3rd-order continuous \\
\midrule
\multirow{3}{*}{KL} & BP & $\textbf{0}$ & $0.0065$ & $0.0269$ & N/A\\
& GNN & $0.0013 \pm 0.0004$ & $\textbf{0.0051}\pm 0.0008$ & $\textbf{0.0152}\pm 0.0005$ & N/A\\
& Singleton & N/A & $0.0460\pm 0.0001$ &$0.0528\pm0.0000$ & N/A\\
\midrule
\multirow{3}{*}{MSE} & BP & $\textbf{0}$ & $0.1416$ & $0.0094$ & N/A\\
& GNN & $0.0044 \pm 0.0013$ & $\textbf{0.0705} \pm 0.0128$ & $\textbf{0.0057}\pm 0.0002$ & $0.0498\pm 0.0009$ \\
& Singleton & NA & $ 0.9027 \pm 0.0006 $ & $ 0.0215\pm 0.0000$ & $ 0.1930\pm0.0000$\\
\midrule
\multirow{3}{*}{$R^2$} & BP & $\textbf{1}$ & $0.9719$ & $0.8290$ & N/A\\
& GNN & $0.9995 \pm 0.0001 $ &$\textbf{0.9876}\pm 0.0023$ & $\textbf{0.9311}\pm 0.0014$ & $0.9107\pm0.0017$\\
& Singleton & N/A & $0.8329 \pm 0.0000$ & $0.7352\pm 0.0000$ & $0.6543\pm0.0001$ \\
\bottomrule
\end{tabular}
}
\end{table}
\section{Discussion\label{sec:discussion}}
In this paper we show that GNN is an alternative to traditional message-passing algorithms like Belief Propagation as an approximate inference engine on graphical models.
It outperforms BP on some loopy graphs, and offers a practical way to perform fast inference for continuous non-Gaussian graphical models like those in \ref{result:3cont}. In contrast, previous data-driven methods \cite{barthelme2011abc,Heess.Winn.2013,Jitkrittum.Szabo.2015} were proposed to approximate the EP message passing for a single factor type, thus still shares the weakness of EP on loopy graphs.
Although our method achieves promising results and does generalize to graphs of different sizes, it naturally performs better within its training distribution. However, almost no performance drop on Gaussian tree graphs when generalizing to 5x larger graphs (\cref{results:ggm-tree} and promising generalization results on loopy graphs (\cref{results:ggm-all},\cref{result:3spin}) suggest the potential usage of our methods for inference on large graphs by training on smaller ones.
Compared to a 10-layer stacked GNN \ref{fig:ggm-spin}, our method achieves better performance with substantially fewer parameters. However, in our experiment we just simply stack the Factor-GNN layers with out any further tricks like skip connection, pooling layer, etc., as in \cite{Zhang.Lee.2019eqj}. Despite that, learning a recursive message-passing algorithm has advantages over a feedforward one when generalizing to larger graphs: the number of layers must scale with graph size for a feedforward network in order to distribute information throughout the graph, whereas a recurrent algorithm could run until convergence regardless of the graph size.
A limitation of our method is that a separate GNN needs to be learnt from scratch whenever encountering a new parametric family of graphical models. One exciting but speculative possibility is to extend this framework such that whenever a new type of factor is encountered, the model only trains a dedicated new encoder/decoder, and reuses a shared core message-passing module, perhaps implementing a more universal inference engine akin to a shared language model \cite{denkowski2014meteor}.
This can be useful when data is limited, since the difficult message-passing core could be learnt from multiple rich datasets. The general form of Belief Propagation takes this universal form, and have some multifactor extensions like Generalized BP \cite{yedidia2000generalized}. We hypothesize that Factor Graph Neural Networks could potentially extend this universality while compensating for the challenges of inference in a loopy world.
Creation of smarter artificial intelligence would have major impacts on human life, through communication, industry, infrastructure, robotics, and many more aspects of life. Our work aims to refine the theoretical foundations for intelligence. Thoughtless or naive application of these scientific advances could lead to unanticipated consequences and increase social inequality.
\section{Acknowledgements}
The authors thank Kijung Yoon for helpful conversations about graph metrics. YF and XP were supported in part by NSF NeuroNex grant 1707400. XP was supported in part by NSF CAREER award 1552868 and a grant from the McNair Foundation.
\bibliographystyle{unsrt}
| {'timestamp': '2021-07-14T02:04:25', 'yymm': '2107', 'arxiv_id': '2107.05729', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05729'} | arxiv |
\section{Introduction}
\IEEEPARstart{R}{ate}-compatible (RC) error-control codes are a set of codes with the same dimension but various code lengths and accordingly rates, where all symbols of the higher-rate code are a subset of the lower rate code \cite{davida1972forward}. Combined with RC codes, hybrid automatic repeat request (HARQ) schemes have been used in wireless communication systems to match the code rate to the channel condition by retransmitting incremental redundancy (IR) to the receiver \cite{huang2020syndrome}. The rate-matching procedure is crucial to support various requirements and be able to adapt to varying channel conditions. This becomes even more important for modern wireless systems, like the fifth generation (5G) of mobile communications standard that has established a framework to include services with a diverse range of requirements, such as ultra-reliable and low-latency communications (URLLC) and massive machine-type communications (mMTC), in addition to the traditional enhanced mobile broadband (eMBB) \cite{shirvanimoghaddam2018short}.
The most common way to construct RC codes is to use puncturing. A good low-rate code, referred to as the mother-code, is first constructed, and then some of the coded symbols are discarded to construct higher-rate codes. This approach has been applied to almost all codes and in particular to algebraic codes \cite{davida1972forward,wicker1994type}, convolutional codes \cite{hagenauer1988rate,lee1994new}, Turbo codes \cite{liu2003punctured,rowitch2000performance}, low-density parity-check (LDPC) codes \cite{ha2004rate,el2009design}, and Polar codes \cite{hong2017capacity,niu2013beyond}. The performance of the resulting code depends mainly on the puncturing pattern \cite{wang2021some}. Finding the best puncturing pattern is usually nontrivial and carried out through computer search. Moreover, most puncturing techniques are optimized according to the set of information bits; therefore, these methods cannot be used to design a family of rate-compatible punctured codes for IR-HARQ, which requires the same information set that should be used for all punctured codes from a mother code in the family \cite{hong2017capacity}. Furthermore, if the rate of the mother code is too low, puncturing is not likely to yield good high-rate codes. For example, although Polar codes can achieve the capacity of any specific binary-input symmetric channel, the rate-compatible construction
via successive puncturing is generally not capacity-achieving \cite{hong2017capacity}.
Extending is another approach to construct RC codes \cite{krishna1987new}. A good high-rate code is first constructed, then parity-check symbols are successively added to generate lower-rate codes. The construction of lower rate codes is to find new codes with a good minimum Hamming weight. This approach has been used to construct RC-LDPC codes \cite{chen2015protograph,van2012design} and RC- Polar codes \cite{hong2017capacity,li2016capacity}. RC codes constructed using extending do not usually guarantee high minimum Hamming weight at lower rates, as the minimum weight at a particular rate depends on the original code. Protograph-based Raptor-like LDPC (PBRL) codes were proposed in \cite{chen2015protograph}, which are a class of rate-compatible LDPC codes with extensive rate compatibility. The design of PBRL codes at short and long block lengths \cite{ranganathan2019quasi} have been based on optimizing the iterative decoding threshold of the protograph at various design rates. In particular, each additional parity bit in the protograph is explicitly designed to optimize the density evolution threshold. These codes have been standardized for 5G enhanced mobile broadband \cite{shirvanimoghaddam2018short} for the data channel.
A more general approach based on extending is to use rateless codes. Also known as Fountain codes, rateless codes can generate a potentially limitless number of coded symbols for a given set of input symbols. The coded symbols are usually produced independently and randomly. The receiver can then recover the original input symbols from any subset of received symbols given the length of the subset is sufficiently large. Luby transform (LT) codes \cite{luby2002lt} were the first practical realization of Fountain codes, where each output symbol is generated by adding $d$ randomly chosen input symbols, where $d$ is obtained from a predefined probability distribution function, referred to as the degree distribution. LT codes suffer from error-floor, which is mainly due to random selection of input symbols when generating coded symbols. Rapid tornado (Raptor) codes \cite{shokrollahi2006raptor} solve this problem by adding a high-rate precoder, usually a LDPC code, to an LT code. When the degree distribution is chosen properly, the decoder can recover the original $k$ input symbols from any $n$ Raptor coded symbols as long as $n$ is slightly larger than $k$. The encoding and decoding complexity of Raptor codes increases linearly with the message length \cite{shokrollahi2006raptor}.
Raptor codes can be used over noisy channels \cite{palanki2004rateless,Shirvani2016Low}. Authors in \cite{etesami2006raptor} showed that unlike the erasure channel where a universal degree distribution can be optimized for all erasure rates, the optimized degree distributions of Raptor codes over BI-AWGN and binary symmetric channel (BSC) depend on the channel; therefore, non-universal. To address this problem, several approaches based on adaptive degree distribution design were proposed in the literature \cite{kuo2014design,jayasooriya2018design}. The design and analysis are, however, valid only for asymptotically long block lengths. In binary rateless codes, such as Raptor and LT codes, each new coded symbol is generated through a random process. However, this does not guarantee that the minimum Hamming weight of the code is increased by adding a new parity symbol. It is also probable that a redundant coded symbol is being generated. In fact, the code weight spectrum or the minimum Hamming weight have not been the design criteria for these codes, as they were mainly designed for asymptotically long message sizes.
It is now recognized that bit-level granularity of the codeword size and code operating rate is desired for 5G and beyond \cite{3gppchannelcode}. The actual coding rate used in transmission could not be restricted and optimized for specified ranges \cite{3gppchannelcode}. Designing and optimizing short block length codes have been recently attracted for being implemented on memory or power-constrained devices, mainly in the context of the Internet of Things applications and services. Existing RC codes are mainly constructed using puncturing and extending, which are shown to be sub-optimal for short block lengths. Therefore, designing RC codes for short messages that support bit-level granularity of the codeword size and maintain a large minimum Hamming weight at various rates is still open.
In this paper, we propose primitive rateless (PR) codes, which are mainly characterized by the message length $k$ and a primitive polynomial of degree $k$ over $\mathbf{GF}(2)$. We show that PR codes can be represented by using 1) a linear-feedback shift-register (LFSR) with connection polynomial $x^kp(1/x)$ and 2) Boolean functions. In fact, the codewords of a PR code are subsequences of a maximum-length sequence ($m$-sequence). We show that any two PR codes of dimension $k$ and truncated at length $n\ge 2k$, which are constructed by using two distinct primitive polynomials, do not have any non-zero codeword in common. We also characterize the average Hamming weight distribution of PR codes and develop a lower bound on the minimum Hamming weight which is very close to the Gilbert-Varshamov bound \cite{Jiang2004}. We show that for any $k$, there exists at least one PR code that can meet this bound. We further find some good primitive polynomials for PR codes of dimension $k\le 40$, which can closely approach the Gilbert-Varshamov bound at various rates. Simulation results show that the PR code with a properly chosen primitive polynomial can achieve a similar block error rate (BLER) performance as the extended Bose, Chaudhuri, and Hocquenghem (eBCH) code counterpart. This is because while a PR codes has a lower minimum Hamming weight than the eBCH code, it has a lower number of low-weight codewords. Simulation results show that PR codes in a rateless setting can achieve a very high realized rate over a wide range of SNRs. PR codes can be designed for any message length and arbitrary rate and perform very close to finite block length bounds. They are rate-compatible and have a very simple encoding structure, unlike most rate-compatible codes designed based on puncturing a low-rate mother code, with mostly sub-optimal performance at various rates.
The rest of the paper is organized as follows. Section II introduces primitive rateless (PR) codes and discusses some of their important properties. In Section III, we characterize the Hamming weight distribution of the dual of the PR code and then find the average Hamming weight distribution of PR codes. We also characterize the minimum Hamming weight of the PR codes. In Section IV, we explain how to choose the primitive polynomial for PR codes and provide a list of good primitive polynomials for message lengths up to $40$. Numerical results are presented in Section V. Finally, Section VI concludes the paper.
\section{Construction of the Primitive Rateless Code}
A primitive rateless (PR) code, denoted by $\mathrm{PR}(k,p(x))$, is characterized by the information block length $k$ and a binary primitive polynomial $p(x)=\sum_{i=0}^{k}p_{i}x^{i}$ of degree $k$, for $p_0=p_k=1$, which is the minimal polynomial of a primitive element $\alpha$ over $\mathbf{GF}(2^k)$. The generator matrix of a PR code $\mathrm{PR}(k,p(x))$ truncated at length $n$, which is denoted by $\mathrm{PR}(k,n,p(x))$, is constructed as follows:
\begin{align}
\mathbf{G}_n=\left[\alpha^0, \alpha^1, \cdots, \alpha^{n-1}\right],
\end{align}
where the $i^{th}$ column is the binary representation of $\alpha^{i-1}$, for $1\le i\le n$. Since $\alpha$ is a primitive element of $\mathbf{GF}(2^k)$, $\{0,1,\alpha,\alpha^2,\cdots,\alpha^{2^k-2}\}$ is the entire field $\mathbf{GF}(2^k)$ \cite{Lidl1997}. The parity check matrix of $\mathrm{PR}(k,n,p(x))$ is given by:
\begin{equation}
\mathbf{H}_n=
\begin{bmatrix}
p_0&p_1&\cdots&p_{k}&0&0&\cdots\\
0&p_0&p_1&\cdots&p_{k}&0&\cdots\\
&\ddots&&\ddots&&\ddots&\\
0&\cdots&0&p_0&p_1&\cdots&p_{k}
\end{bmatrix},
\label{pmat}
\end{equation}
where the $i^{th}$ row is the $(i-1)^{th}$-order cyclic shift of the first row, for $2\le i\le n-k$. Since $\alpha$ is a primitive element and $\sum_{i=0}^{k-1}p_{i}\alpha^{i}=\alpha^{k}$, it can be easily verified that $\mathbf{G}_n\mathbf{H}_n^{\top}=\mathbf{0}$, where$~^\top$ is the matrix transpose operand. It is important to note that since $\alpha$ is a primitive $(2^k-1)$-root of unity in $\mathbf{GF}(2^k)$, i.e., $\alpha^{2^k-1}=1$, the columns of the generator matrix will be repeating for $n\ge 2^k-1$.
\begin{remark}[LFSR-based construction of PR codes]
From \eqref{pmat}, it can be easily observed that for the PR code $\mathrm{PR}(k,n,p(x))$, the codeword associated with the message $\mathbf{b}$, satisfies the linear recurrence which is characterized by $p(x)$. That is for any codeword $\mathbf{c}$, $p_0c_0\oplus p_1c_{1}\oplus\cdots\oplus p_kc_{k}=0$. In other words, each codeword of a PR code is a subsequence of length $n$ of a maximum-length sequence ($m$-sequence) with connection polynomial $x^kp(1/x)$. The encoding circuit of the PR code can then be represented by a LFSR \cite{Fredricsson1975}. It is important to note that LFSRs with connection polynomials $p(x)$ and $x^{k}p(1/x)$ are backward version of each other and hence have identical subsequence statistics \cite{Wainberg1970}. Therefore, their equivalent PR codes have the same Hamming weight distributions.
\end{remark}
\begin{remark}
\label{dualprlfsr}
The PR code with any primitive polynomial $p(x)$ of degree $k$ and truncated at length $n=2^k-1$ is equivalent to the dual of the binary Hamming code of codeword length $2^{k}-1$ and message length $2^k-k-1$ with generator polynomial $p(x)$, also referred to as the Simplex code. Further, a PR code $\mathrm{PR}(k,n,p(x))$ is a dual of a shortened Hamming code $(n,n-k)$, where all codewords corresponding to polynomials of degree greater than or equal to $n$ are deleted from the original Hamming code \cite{Fredricsson1975}. A PR code $\mathrm{PR}(k,n,p(x))$ can be also realized as a punctured Simplex code\footnote{In general, every linear code over $\mathbf{GF}(q)$ with dual distance at least 3 is a punctured code of a Simplex code over $\mathbf{GF}(q)$ \cite[Corollary 10]{liu2020shortened}. Moreover, every linear code with minimum distance at least 3 is a shortened code of a Hamming code over $\mathbf{GF}(q)$ \cite[Theorem 11]{liu2020shortened}.}.
\end{remark}
\begin{remark}[Boolean function construction of PR codes]
Let $f:\mathbf{GF}(2^k)\to\mathbf{GF}(2^k)$ denote a linear Boolean function \cite{Ding2016}; that is for any $\beta$ and $\gamma$ from $\mathbf{GF}(2^k)$ and $v$ and $u$ from $\mathbf{GF}(2)$, we have $f(v\beta+u\gamma)=vf(\beta)+uf(\gamma)$ and $f(\mathbf{0})=0$. We develop a code using a primitive polynomial $p(x)$ and primitive element $\alpha$, that is for any information block $\mathbf{b}=\alpha^j$, the $i^{th}$ coded symbol is $c_i=f(\alpha^{j+i-1})$. The code is then equivalent to the PR code $\mathrm{PR}(k,p(x))$\footnote{A more generic construction of a PR code over $\mathbf{GF}(p)$ where $p$ is prime, can be explained as follows. Let $D=\{d_1,d_2,\cdots,d_n\}\subseteq\mathbf{GF}(p^k)$. A PR code of length $n$ over $\mathbf{GF}(p)$ is constructed by
$\mathcal{C}_D=\{\left(\mathrm{Tr}(xd_1),\mathrm{Tr}(xd_2),\cdots,\mathrm{Tr}(xd_n)\right):~x\in\mathbf{GF}(p^k)\}$
where $D$ is called the defining set of the code and $\mathrm{Tr}$ denotes the trace function from $\mathbf{GF}(p^k)$ onto $\mathbf{GF}(p)$ \cite{Ding2016}.}.
\end{remark}
\begin{IEEEproof}
It is easy to show that for this code we have $\sum_{i=0}^{k}p_if(\alpha^{j+i})=f(\sum_{i=0}^{k}p_i\alpha^{j+i})=0$, which follows directly from the fact that $f$ is linear and $p(\alpha)=0$. It is then straightforward that the parity check matrix of this code is \eqref{pmat}. This completes the proof.
\end{IEEEproof}
\begin{example} We assume that $k=4$ and the primitive polynomial is $p(x)=1+x+x^4$. The binary function $f$ is defined as $f(\mathbf{b})=b_0\oplus b_1\oplus b_2 \oplus b_3$. We list all non-zero elements of $\mathbf{GF}(2^4)$ over a circle as shown in Fig. \ref{figring} and calculate the binary value of each element subject to function $f$. The codeword associated with each message can be easily found by all values on a semi-ring started from the corresponding element of the field to the message vector and terminated at the desired length. For example, for the message $b=(1100)$ the codeword of length $n=11$ is $c=(01001101011)$.
\end{example}
\begin{figure}[t]
\centering
\includegraphics[width=0.55\columnwidth]{ring.eps}
\caption{The encoding ring for a PR code generated by $p(x)=1+x+x^4$ and $f(\mathbf{b})=b_0\oplus b_1\oplus b_2 \oplus b_3$ and terminated at length $n=11$.}
\label{figring}
\end{figure}
\begin{remark}
\label{remarkpoly}
Any PR code $\mathrm{PR}(k,n,p(x))$ is the dual of a polynomial code of codeword length $n$, message length $n-k$, and generator polynomial $p(x)$.
\end{remark}
\begin{IEEEproof}
The codewords of a polynomial code with generator polynomial $p(x)$ are obtained by $c(x)=b(x)p(x)$, where $b(x)=\sum_{i=0}^{n-k-1}b_ix^i$ is the message vector. The polynomial multiplication $b(x)p(x)$ is equivalent to the row-wise operation of $\mathbf{H}_n$. That is $c(x)=\sum_{i=0}^{n-k-1}b_ix^ip(x)$, which is equivalent to the product $\mathbf{b}\mathbf{H}_n$. In other words, $\mathbf{H}_n$ is the generator matrix of the polynomial code of codeword length $n$, message length $n-k$, and generator polynomial $p(x)$.
\end{IEEEproof}
\begin{lemma}
\label{lemma:disjoint}
Let $\mathrm{PR}(k,n,p_1(x))$ and $\mathrm{PR}(k,n,p_2(x))$ denote two PR codes that are generated with primitive polynomials $p_1(x)$ and $p_2(x)$, respectively, where $p_1(x)\ne p_2(x)$ and $n\ge 2k$. For simplicity of notations, we denote their respective codebooks by $\mathcal{C}_1$ and $\mathcal{C}_2$. Then, these codes do not have any non-zero codeword in common, i.e., $\mathcal{C}_1\bigcap \mathcal{C}_2=\{\mathbf{0}\}$.
\end{lemma}
\begin{IEEEproof}
Let us assume that $n=2k$ and $\mathbf{c}\ne \mathbf{0}$ is a codeword, which belongs to both $\mathcal{C}_1$ and $\mathcal{C}_2$. Therefore, $\mathbf{c}$ will satisfy parity check constraints for both $\mathcal{C}_1$ and $\mathcal{C}_2$. In particular, we have
\begin{align}
\left[\begin{array}{ccccccc}
p_{1,0}&\cdots&p_{1,k-1}&p_{1,k}&0&\cdots&0\\
&&&\vdots&&&\\
0&\cdots&0&p_{1,0}&\cdots&p_{1,k-1}&p_{1,k}\\
p_{2,0}&\cdots&p_{2,k-1}&p_{2,k}&0&\cdots&0\\
&&&\vdots&&&\\
0&\cdots&0&p_{2,0}&\cdots&p_{2,k-1}&p_{2,k}\\
\end{array}\right]\mathbf{c}=\mathbf{0}_{2k}.
\label{eq:bigH}
\end{align}
A linear combination of some rows of this matrix can be written as
\begin{align}
g_1(x)p_1(x)+g_2(x)p_2(x),
\end{align}
where $g_1(x)$ and $g_2(x)$ are binary polynomials of degrees at most $k-1$. Let us assume that there are $g_1(x)$ and $g_2(x)$ such that $h(x)=g_1(x)p_1(x)+g_2(x)p_2(x)=0$. Therefore, $h(\alpha_1)=0$, where $\alpha_1$ is the primitive root of $p_1(x)$. We therefore have $g_2(\alpha_1)p_2(\alpha_1)=0$. Since $p_2(x)$ is a primitive polynomial other than $p_1(x)$, we have $p_2(\alpha_1)\ne0$, which results in $g_2(\alpha_1)=0$. This contradicts the fact that $p_1(x)$ is a primitive polynomial with primitive element $\alpha_1$, as the degree of $g_2(x)$ is less than $k$. Thus, every linear combination of rows of the parity check matrix above is non-zero. Therefore, the above parity check matrix is full-rank and the only solution to (\ref{eq:bigH}) is $\mathbf{c}=\mathbf{0}$. Since the first subsequence of length $2k$ of any non-zero codeword of $\mathcal{C}_1$ is different than the first subsequence of length $2k$ of any non-zero codeword of $\mathcal{C}_2$, we can conclude that $\mathcal{C}_1\bigcap\mathcal{C}_2=\{\mathbf{0}\}$, for $n\ge 2k$.
\end{IEEEproof}
\begin{remark}
Lemma \ref{lemma:disjoint} can be generalized as follows. Any two PR codes $\mathrm{PR}(k_1,n,p_1(x))$ and $\mathrm{PR}(k_2,n,p_2(x))$ do not have any non-zero codeword in common, when $n\ge2\max\{k_1,k_2\}$ and $p_1(x)\ne p_2(x)$. This follows from the fact that the minimal polynomial\footnote{The minimal polynomial of sequence $\mathbf{c}$ is the connection polynomial of the shortest LFSR capable of producing $\mathbf{c}$ \cite{massey1969shift}.} of any codeword of length $n\ge 2k_1$ of $\mathrm{PR}(k_1,n,p_1(x))$ is unique and equals to $p_1(x)$ \cite{massey1969shift}. Similarly the minimal polynomial of any codeword of length $n\ge 2k_2$ of $\mathrm{PR}(k_2,n,p_2(x))$ is unique and equals to $p_2(x)$. However, if a non-zero codeword $\mathbf{c}$ of length $n\ge\max\{k_1,k_2\}$ belongs to both codebooks, it will have two distinct minimal polynomials, which contradicts with the uniqueness of the minimal polynomial.
\end{remark}
\begin{lemma}
\label{lemma:euler}
There are $\frac{\varphi(2^k-1)}{k}$ PR codes of message length $k$, where $\varphi(.)$ is the Euler's totient function.
\end{lemma}
\begin{IEEEproof}
The number of primitive polynomials over $\mathbf{GF}(2)$ having degree $k$ is given by $\varphi(2^k-1)/k$ \cite{Helleseth1991}. Each primitive polynomial generates a PR code. This completes the proof.
\end{IEEEproof}
\section{Hamming Weight Distribution of Primitive Rateless Codes}
In this section, we will characterize the Hamming weight distribution of PR codes. Authors in \cite{Fredricsson1975} introduced an ideal distribution for the Hamming weight of the non-zero $n$-tuples of an $m$-sequence (equivalent to a PR code) as follows:
\begin{align}
\hat{A}_t=\frac{2^k-1}{2^n-1}\dbinom{n}{t}, ~~~ 1\le t\le n,
\label{eq:idealdist}
\end{align}
where they tried to characterize the deviation of the Hamming weight distribution of the $n$-tuples from the ideal distribution. In particular, they found that if the minimum Hamming weight of the shortened Hamming code is greater than $L$, the deviation from the ideal distribution is lower bounded by
\begin{align}
||A||^2\ge \frac{(1-2^{k-n})(2^{n-k}-1)}{(1-2^{-k})(2^n-1)}\sum_{i=1}^{L}\dbinom{n}{i},
\end{align}
where $||A||$ is the Euclidean norm of the gap between the Hamming weight distribution and the ideal distribution. The Hamming weight distribution of the $n$-tuples was also characterized, which relies on the Hamming weight distribution of the shortened Hamming code and thus cannot be scaled to moderate and large codes. Moreover, according to Remark \ref{dualprlfsr}, a PR code $\mathrm{PR}(n,k,p(x))$ can be realized as a punctured Simplex code, for which the weight distribution at block lengths $n>2^{k-1}$ has been studied in \cite{baldi2012class}. The approach however cannot be extended for an arbitrary $n$ and in particular for $2k\le n\le 2^k-1$, which is the primary focus of this work.
Authors in \cite{Lidl1997} provided a bound for the weight of subsequences of a $m$-sequence. That is for every $n$, we have \cite[Theorem 8.85]{Lidl1997}:
\begin{align}
\left| w_{\mathrm{H}}(\mathbf{c})-\frac{n}{2}\right|\le\sqrt{k}\left(\frac{\log\left(2^k-1\right)}{\pi}+1\right),
\end{align}
and when $n$ goes large, we have ${w_\mathrm{H}(\mathbf{c})}\approx\frac{n}{2}$ \cite{wang2017quickest}, where ${w_\mathrm{H}(\mathbf{c})}$ is the Hamming weight of the subsequnce $\mathbf{c}$ of length $n$. This means that for a sufficiently large $n$, the Hamming weight distribution of PR codes is concentrated around $n/2$. The following lemma characterises the first and second moments of the Hamming weight distribution of PR codes.
\begin{lemma}
\label{lemma:avgweigth}
A PR code $\mathrm{PR}(n,k,p(x))$ with $n\le2^k-1$ has the average Hamming weight equals to $\mu_n=\frac{n}{2}$ and the variance of the Hamming weights is $\sigma^2_n=\frac{n}{4}$\footnote{Lemma \ref{lemma:avgweigth} was previously presented in \cite{Lindholm1968}, which stated that the first and second moments of the distribution of the number of 1s in a subsequence of length $n$ of an $m$-sequence with primitive connection polynomial $p(x)$ of degree $k$, are $n/2$ and $n/4$, respectively. We however provide our proof for the completeness of the discussion.}.
\end{lemma}
\begin{IEEEproof}
The dual of the PR code $\mathrm{PR}(n,k,p(x))$ with $n\le2^k-1$ has a minimum Hamming weight of at least 3. This can be easily proved as $p(x)$ is primitive and does not have any binomial multiple with degree less than $2^k-1$. Because otherwise there would exist $0\le i_1<i_2<2^k-1$ such that $\alpha^{i_1}+\alpha^{i_2}=0$ for $\alpha$ being the root of $p(x)$. This implies that $\alpha^{i_2-i_1}=1$, which contradicts the fact that $\alpha$ is primitive. Let $A(z)=\sum_{i=0}^nA_iz^i$ and $B(z)=\sum_{i=0}^nB_iz^i$ denote the weight enumerator function of the PR code and its dual code, respectively. By using the MacWilliams identity \cite{MacWilliams1962}, we will have
\begin{align}
B_1=\frac{1}{2^k}\sum_{j=0}^{n}A_j(n-2j),
\end{align}
which results in $\mu_n=\frac{1}{2^k}\sum_{j=0}^njA_j=\frac{n}{2}$, since $B_1=0$. Similarly, for $B_2=0$ we have
\begin{align}
B_2=\frac{1}{2^k}\sum_{j=0}^{n}A_j\left(2\left(j-\frac{n}{2}\right)^2-\frac{n}{2}\right),
\end{align}
which results in $\sigma^2_n=\frac{1}{2^k}\sum_{j=0}^nA_j(j-\mu_n)^2=\frac{n}{4}$.
\end{IEEEproof}
\begin{corollary}
The average Hamming weight of any PR code $\mathrm{PR}(k,n,p(x))$ increases by 1 when $n$ is increased by 2.
\end{corollary}
Let $A^{(i)}(z)$ denote the weight enumerator of the PR code $\mathrm{PR}(n,k,p_i(x))$. As we have $M_k=\varphi(2^k-1)/k$ of such codes (Lemma \ref{lemma:euler}), we can define the average weight enumerator of PR codes of dimension $k$ truncated at length $n$ as follows:
\begin{align}
\Bar{A}(z)=\frac{1}{M_k}\sum_{i=1}^{M_k}\sum_{j=0}^{n}A^{(i)}_jz^j,
\end{align}
where for simplicity, we define $\Bar{A}_j=\frac{1}{M_k}\sum_{i=1}^{M_k}A^{(i)}_j$. By using the MacWilliams identity \cite{MacWilliams1962}, we will have
\begin{align}
\Bar{A}_j= \frac{1}{M_k}\sum_{i=1}^{M_k}\sum_{t=0}^{n}\frac{B^{(i)}_t}{2^{n-k}}K_j(t)
=\frac{1}{2^{n-k}}\sum_{t=0}^{n}\Bar{B}_tK_j(t),
\label{eq:mcwilliam}
\end{align}
where $\Bar{B}_t=\frac{1}{M_k}\sum_{i=1}^{M_k}B^{(i)}_t$ and
\begin{align}
K_j(t)=\sum_{\ell=0}^{j}(-1)^{\ell}\dbinom{t}{\ell}\dbinom{n-t}{j-\ell}
\end{align}
is the Krawtchouk polynomial \cite{BenHaim2006}, where $t$ is an integer, $0\le t\le n$. We commonly use the following identities in the rest of the paper \cite{Krasikov1995}:
$K_j(0)=\dbinom{n}{j}$, $K_n(t)=(-1)^t$, and $K_j(n)=(-1)^n\dbinom{n}{j}$.
We are interested in the \emph{average} Hamming weight distribution of all ensembles of PR codes. For this we consider all possible $\varphi(2^k-1)/k$ ensembles of PR codes and their dual codes to characterize the average Hamming weight distributions at any desired codeword length.
\subsection{Average Weight Distribution of Dual of PR Codes}
As stated in Remark \ref{remarkpoly}, the dual of a PR code is a polynomial code with generator polynomial $p(x)$. In other words, every codeword of the dual code is a product of $p(x)$. It is then clear that $\Bar{B}_t$ is equivalent to the expected number of all weight-$t$ multiples with degree at most $n-1$ of every primitive polynomial of degree $k$. The following lemma characterizes $\Bar{B}_t$.
\begin{lemma}
For the dual of PR codes of dimension $k$ and truncated at length $n$, the expected number of codewords of weight $t$, for $3\le t\le n$, is given by:
\begin{align}
\bar{B}_t\approx\frac{N_{k,t}}{\dbinom{2^k-2}{t-1}}D^{(k)}_{n,t},
\label{eq:dualweigth}
\end{align}
where
\begin{align}
D^{(k)}_{n,t}=\sum_{c=\max(k,t-1)}^{n-1}\dbinom{c-1}{t-2}(n-c),
\end{align}
and
\begin{align}
N_{k,t}=\frac{\dbinom{2^k-2}{t-2}-N_{k,t-1}}{t-1}-\frac{\left(2^k-t+1\right)N_{k,t-2}}{t-2},
\label{eq:tnomial}
\end{align}
and $N_{k,2}=N_{k,1}=0$.
\end{lemma}
\begin{IEEEproof}
Let $N_{k,t}$ denotes the number of $t$-nomial multiples (having constant term 1) of a primitive polynomial $p(x)$ of degree $k$, with initial condition $N_{k,2}=N_{k,1}=0$. It was shown in \cite{Maitra2002} that $N_{k,t}$ can be precisely characterized by (\ref{eq:tnomial}). It was further elaborated in \cite{Gupta2001} that the distribution of $t$-nomial multiples of degree less than or equal to $2^k-2$ is very close to the distribution of all distinct ($t-1$) tuples from $1$ to $2^k-2$. Under this assumption, referred to as \emph{Random Estimate} in \cite{Gupta2001}, the probability that a randomly chosen $t$-nomial of degree at most $2^k-2$ is a multiple of a primitive polynomial is given by $N_{k,t}/{\dbinom{2^k-2}{t-1}}$ \cite{Gupta2001,Maitra2002,Venkateswarlu2002}. The expected number of $t$-nomial multiples having degree equals to $c$, for $c\ge\max(k,t-1)$ is then given by $N_{k,t}\dbinom{c-1}{t-2}/\dbinom{2^k-2}{t-1}$. This follows from the fact that there are exactly $\dbinom{c-1}{t-2}$ many $t$-nomials of degree $c$.
It is also clear that when a $t$-nomial $r(x)=1+x^{i_1}+\cdots+x^{i_{t-2}}+x^{c}$ is a multiple of $p(x)$, then $x^{i}r(x)$ for $0\le i\le n-c-1$ is also a multiple of $p(x)$ and has weight $t$. There are $n-c$ of such multiples, where $\max\{k,t-1\}\le c\le n-1$. Therefore, the expected number of weight $t$ polynomials of maximum degree $n-1$, which are multiples of primitive polynomial $p(x)$, is given by (\ref{eq:dualweigth}).
\end{IEEEproof}
Authors in \cite{Gupta2001} further approximated $N_{k,t}$ by $\dbinom{2^k-2}{t-2}/(t-1)$, which is tight when $t\ll 2^k$. By using this approximation, we can further simplify (\ref{eq:dualweigth}) as follows:
\begin{align}
\bar{B}_t\approx\frac{1}{2^k-t}D^{(k)}_{n,t},~~3\le t\le n.
\label{eq:dualweigth2}
\end{align}
\begin{prop}
\label{prop:1}
For $t\ge k+1$, we have $D^{(k)}_{n,t}=\dbinom{n}{t}$.
\end{prop}
\begin{IEEEproof}
Let $\xi:=c-1$ and $\eta:=t-2$, we then have
\begin{align}
\nonumber D^{(k)}_{n,t}&=\sum_{c=t-1}^{n-1}\dbinom{c-1}{t-2}(n-c)=\sum_{\xi=\eta}^{n-2}\dbinom{\xi}{\eta}\dbinom{n-1-\xi}{t-1-\eta}\\
\nonumber &\overset{(a)}{=}\sum_{\xi=0}^{n-1}\dbinom{\xi}{\eta}\dbinom{n-1-\xi}{t-1-\eta}-\dbinom{n-1}{\eta}\dbinom{0}{t-1-\eta}\\
\nonumber&~~~-\sum_{\xi=0}^{\eta-1}\dbinom{\xi}{\eta}\dbinom{n-1-\xi}{t-1-\eta}\\
&\overset{(b)}{=}\dbinom{n}{t},
\end{align}
where step $(a)$ expands the summation into three overlapping terms, and step $(b)$ follows from the fact that $\dbinom{0}{t-1-\eta}=0$, and for $\eta>\xi$, we have
\begin{align}
\dbinom{\xi}{\eta}=\frac{\xi\times(\xi-1)\cdots\times0\times\cdots(\xi-\eta+1)}{\eta!}=0,
\end{align}
and $\sum_{\xi=0}^{n-1}\dbinom{\xi}{\eta}\dbinom{n-1-\xi}{t-1-\eta}=\dbinom{n-1+1}{t-1+1}$ due to the Chu–Vandermonde identity \cite{Askey1975}.
\end{IEEEproof}
\begin{prop}
\label{prop:2}
For $t\le k$, $D^{(k)}_{n,t}$ is given by
\begin{align}
D^{(k)}_{n,t}=\dbinom{n}{t}-\sum_{c=t-1}^{k-1}\dbinom{c-1}{t-2}(n-c).
\label{eq:dktb}
\end{align}
\end{prop}
\begin{IEEEproof}
For $t\le k$, we have
\begin{align}
\nonumber D&^{(k)}_{n,t}=\sum_{c=k}^{n-1}\dbinom{c-1}{t-2}(n-c)\\
&=\sum_{c=t-1}^{n-1}\dbinom{c-1}{t-2}(n-c)-\sum_{c=t-1}^{k-1}\dbinom{c-1}{t-2}(n-c),
\end{align}
which reduces to (\ref{eq:dktb}) following the proof of Proposition \ref{prop:1}.
\end{IEEEproof}
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{AvgWeightDual.eps}
\vspace{-2ex}
\caption{The average weight enumerator $\Bar{B}_t$ of duals of PR codes. Solid and dashed curves show the exact and approximate weight distributions, respectively.}
\label{fig:avgweightdual}
\end{figure}
Fig. \ref{fig:avgweightdual} shows the average Hamming weight distribution of the dual of PR codes when $k=10$, $n=25$ and $k=15$, $n=31$. It is important to note that there are $M_{10}=60$ and $M_{15}=1800$ different PR codes of dimension $k=10$ and $k=15$, respectively. Fig. \ref{fig:avgweightdual} is produced by generating all the dual codes and their weight distributions and taking average to find the average weight distribution. As can be seen in this figure, (\ref{eq:dualweigth}) provides a tight approximation for the average weight distribution of duals of PR codes.
Fig. \ref{fig:weightdual} shows the Hamming weight distribution of the dual of a PR code at different lengths, when $k=10$ and $k=19$, with primitive polynomials $p(x)=1+x^2+x^4+x^5+x^7+x^9+x^{10}$ and $p(x)=1+x+x^2+x^5+x^7+x^8+x^{12}+x^{13}+x^{14}+x^{17}+x^{19}$, respectively. As can be seen, (\ref{eq:dualweigth}) also provides a very tight approximation of the Hamming weight distribution of duals of PR codes. To better characterize the approximation in (\ref{eq:dualweigth2}), we use the Kullback-Leibler Divergence (KLD)\footnote{For discrete probability distributions $P$ and $Q$ defined on the same probability space, $\mathcal{X}$, the KLD (or relative entropy) from $Q$ to $P$ is defined to be $\mathrm{KLD}(P \parallel Q) = \sum_{x\in\mathcal{X}} p(x) \log\left(p(x)/q(x)\right)$ \cite{MacKay2003}.} to measure the distance between the exact weight distribution of the dual code and the approximations. In particular, when $k=10$, we have $\mathrm{KLD}(B_t\parallel\Bar{B}_t)=1.1\times 10^{-5}$ and when $k=19$, we have $\mathrm{KLD}(B_t\parallel\Bar{B}_t)=6.7\times 10^{-5}$.
\subsection{Average Weight Distribution of PR Codes}
The following lemma characterises the average Hamming weight distribution of PR codes.
\begin{lemma}
\label{lem:WeightEnum}
The average number of codewords of Hamming weight $j\ge 3$ of all PR codes $\mathrm{PR}(k,n,p(x))$ is approximated by:
\begin{align}
\Bar{A}_j\approx-2^{-n}\sum_{t=0}^{k}F^{(k)}_{n,t}K_j(t),
\label{eq:avgWeightPR}
\end{align}
where $F^{(k)}_{n,t}$ is given below
\begin{align}F^{(k)}_{n,t}=\left\{\begin{array}{ll}
1-2^k;&t=0,\\
\dbinom{n}{t};&t=1,2,\\
\sum_{c=t-1}^{k-1}\dbinom{c-1}{t-2}(n-c);&3\le t\le k.\end{array}\right.\label{eq:fnkt}\end{align}
\end{lemma}
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{WeightDual-10-19.eps}
\vspace{-2ex}
\caption{The weight distribution of the dual of the PR code. The primitive polynomials for $k=10$ and $k=19$ are respectively $p(x)=1+x^2+x^4+x^5+x^7+x^9+x^{10}$ and $p(x)=1+x+x^2+x^5+x^7+x^8+x^{12}+x^{13}+x^{14}+x^{17}+x^{19}$. }
\label{fig:weightdual}
\end{figure}
\begin{IEEEproof}
By using the MacWilliams Identity (\ref{eq:mcwilliam}) \cite{MacWilliams1963}, the approximation for $\Bar{B}_t$ in (\ref{eq:dualweigth2}), and the fact that $\Bar{B}_0=1$ and $\Bar{B}_1=\Bar{B}_2=0$ (see the proof of Lemma \ref{lemma:avgweigth}), we have
\begin{align}
\nonumber\Bar{A}_j&\approx \frac{1}{2^{n-k}}K_j(0)+\frac{1}{2^{n-k}}\sum_{t=3}^{n}\frac{1}{2^k-t}D^{(k)}_{n,t}K_j(t)\\
\nonumber&\overset{(a)}{\approx}\frac{1}{2^{n-k}}K_j(0)+\frac{1}{2^{n-k}}\sum_{t=3}^{n}\frac{1}{2^k}D^{(k)}_{n,t}K_j(t)\\
\nonumber&\overset{(b)}{=}\frac{1}{2^{n-k}}K_j(0)+\frac{1}{2^n}\sum_{t=0}^{n}\dbinom{n}{t}K_j(t)-\frac{1}{2^n}\sum_{t=0}^{2}\dbinom{n}{t}K_j(t)\\
\nonumber&-\frac{1}{2^n}\sum_{t=3}^{k}K_j(t)\sum_{c=t-1}^{k-1}\dbinom{c-1}{t-2}(n-c)\\
\nonumber&\overset{(c)}{=}\delta_j-\frac{1-2^k}{2^n}K_j(0)-\frac{1}{2^n}\sum_{t=1}^{2}\dbinom{n}{t}K_j(t)\\
\nonumber&-\frac{1}{2^n}\sum_{t=3}^{k}K_j(t)\sum_{c=t-1}^{k-1}\dbinom{c-1}{t-2}(n-c)\\
&\overset{(d)}{=}\delta_j-2^{-n}\sum_{t=0}^{k}F^{(k)}_{n,t}K_j(t).
\end{align}
where step $(a)$ follows from the fact that $t\le n\ll 2^k$, step $(b)$ follows from Proposition \ref{prop:1} and Proposition \ref{prop:2}, step $(c)$ follows from $\sum_{t=0}^{n}\dbinom{n}{t}K_j(t)=2^n\delta_j$ \cite{BenHaim2006}, where $\delta_j$ is the Kronecker delta function, i.e., $\delta_0=1$ and $\delta_j=0$ for $j>0$, and step $(d)$ follows from the definition of $F^{(k)}_{n,t}$ in \eqref{eq:fnkt}.
\end{IEEEproof}
Following Lemma \ref{lem:WeightEnum}, the average weight enumerator of PR codes of dimension $k$ and truncated at length $n$ is given by:
\begin{align}
\Bar{A}(z)\approx 1-{2^{-n}}\sum_{t=0}^{k}F^{(k)}_{n,t}(1-z)^t(1+z)^{n-t}.
\end{align}
Fig. \ref{fig:avgWeightPR} shows the average weight distribution of PR codes of dimension $k=10$ and $k=15$ at different lengths. As can be seen, (\ref{eq:avgWeightPR}) provides a tight approximation for the average weight distribution of PR codes.
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{AvgWeightPR.eps}
\vspace{-2ex}
\caption{The average weight distribution $\Bar{A}_t$ of PR codes. Solid and dashed curves show the exact and approximate weight distributions, respectively. The approximate weight distribution is obtained via (\ref{eq:avgWeightPR}).}
\label{fig:avgWeightPR}
\end{figure}
Fig. \ref{fig:weightdist39} shows the Hamming weight distribution of a PR code when $k=39$ and $p(x)=x^{39} + x^{38} + x^{35} + x^{32} + x^{27} + x^{25} + x^{24} + x^{23} + x^{20} + x^{19} + x^{16} + x^{15} + x^{11} + x^{9} + x^8 + x^4 + x^3 + x^2 + 1$. As can be seen, the wight distribution can be well approximated by (\ref{eq:avgWeightPR}). When $k=39$ and $n=49$, we have $\mathrm{KLD}(A_t\parallel\Bar{A}_{t})=8.6\times 10^{-11}$, when $n=64$, $\mathrm{KLD}(A_t\parallel\Bar{A}_{t})=1.4\times 10^{-10}$, and when $n=128$, $\mathrm{KLD}(A_t\parallel\Bar{A}_{t})=5.4\times 10^{-10}$. We used MAGMA calculator \cite{MR1484478} to obtain the Hamming weight distribution of PR codes.
In the following theorem, we prove the existence of a PR code for any $k$ and $n\ge 2k$, that has a minimum Hamming weight large than a certain value.
\begin{theorem}
For given $k$ and $n\ge2k$, there is at least one PR code with the minimum Hamming weight lower bounded by $d_{\min}$, where
\begin{align}
d_{\min}=\max_d\left\{d\left|-2^{-n}\sum_{j=3}^{d}\sum_{t=0}^{k}F_{n,t}^{(k)}K_j(t)\le 1 \right.\right\}.
\label{eq:mindisbound}
\end{align}
\end{theorem}
\begin{IEEEproof}
Let $d_{\min}=\max_d\{d|\sum_{j=3}^d\Bar{A}_j\le 1\}$. Since $\Bar{A}_j=\frac{1}{M_k}\sum_{i=1}^{M_k} A_j^{(i)}$ and $M_k=\varphi(2^k-1)/k$, we have
\begin{align}
\sum_{j=3}^{d_{\min}}\sum_{i=1}^M A_j^{(i)}\le M_k.
\end{align}
This means that the total number of codewords with Hamming weight less than or equal to $d_{\min}$ of all PR codes of dimension $k$ and truncated at length $n$ is less than $M_k$. Since the sets of non-zero codewords of any two PR codes of dimension $k$ and truncated at length $n\ge 2k$ are disjoint (Lemma \ref{lemma:disjoint}), there should be at least one PR code of dimension $k$ and length $n$ that has a minimum Hamming weight larger than or equal to $d_{\min}$. This completes the proof.
\end{IEEEproof}
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{WeightDistributionk39.eps}
\vspace{-2ex}
\caption{The weight distribution of a PR code with $k=39$ and $p(x)=x^{39} + x^{38} + x^{35} + x^{32} + x^{27} + x^{25} + x^{24} + x^{23} + x^{20} + x^{19} + x^{16} + x^{15} + x^{11} + x^{9} + x^8 + x^4 + x^3 + x^2 + 1$. Solid and dashed lines respectively show the exact and approximate (obtained via (\ref{eq:avgWeightPR})) weight distributions.}
\label{fig:weightdist39}
\end{figure}
\begin{remark}
\label{rem:gv}
The average number of codewords of Hamming weight $j\ge 3$ of all PR codes of dimension $k$ truncated at length $n$ is upper bounded by:
\begin{align}
\Bar{A}_j\le \frac{1}{2^{n-k}}\dbinom{n}{j}.
\label{eq:binoapp}
\end{align}
\end{remark}
This can be verified from $\Bar{A}_j$ for $j\ge3$ in (\ref{eq:avgWeightPR}) as follows:
\begin{align}
\nonumber\bar{A}_j&=\frac{2^k-1}{2^{n}}K_j(0)-\frac{1}{2^{n}}\sum_{t=1}^k
F_{n,t}^{(k)}K_j(t)\\
&\overset{(a)}{=}\frac{1}{2^{n-k}}\dbinom{n}{j}-\frac{1}{2^{n}}\left(\dbinom{n}{j}+\sum_{t=1}^k
F_{n,t}^{(k)}K_j(t)\right),
\end{align}
where step $(a)$ follows from the fact that $K_j(0)=\dbinom{n}{j}$. When $n$ is sufficiently large, we have
\begin{align}
x_1^{(j)}=\frac{n}{2}-\sqrt{j(n-j)}+o(n),
\end{align}
where $x_1^{(j)}$ is the smallest root of $K_j(x)$. For $n$ sufficiently large and $j$ sufficiently small, we will have $K_j(t)\ge0$; therefore, $\Bar{A}_j\le 2^{k-n}\dbinom{n}{j}$. It is important to note that as can be seen in Fig. \ref{fig:avgWeightPR} and Fig. \ref{fig:weightdist39}, the Hamming weight distribution of PR codes can be well approximated by the ideal distribution \eqref{eq:idealdist}, which is similar to the truncated binomial distribution \eqref{eq:binoapp}\footnote{Authors in \cite[Eq. 38]{Jordan1973} tried to compare the probability that there are exactly $t$ ones in $n$ successive bits of an $m$-sequence and the ideal distribution. The approach, however, depends on the primitive polynomial used to generate the $m$-sequence and is computationally complex when $k$ is large.}.
According to Remark \ref{rem:gv}, one can conclude that
\begin{align}
d_{\min}\ge d_{\mathrm{GV}},
\label{eq:boundgvmin}
\end{align}
where $d_{\mathrm{GV}}$ is the minimum Hamming weight obtained from the Gilbert-Varshamov bound \cite{Jiang2004}:
\begin{align}
d_{\mathrm{GV}}=\max_d\left\{d\left|\sum_{j=0}^{d-1}\dbinom{n}{j}\le 2^{n-k} \right.\right\}.
\label{eq:GVdisbound}
\end{align}
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{MinDistBound.eps}
\vspace{-2ex}
\caption{The minimum Hamming weight of PR codes of dimension $k=16$, $k=20$, and $k=39$ at different block lengths. The primitive polynomials are taken from Table \ref{tab:primpoly} and minimum Hamming weights were calculated by MAGMA \cite{MR1484478}.}
\label{fig:mindistbound}
\end{figure}
\begin{figure*}
\centering
\subfloat[Low density primitive polynomial \label{fig:wdPlow}]{%
\includegraphics[width=0.325\textwidth]{WeightDistk23Plow.eps}}
\hfill
\subfloat[Moderate density primitive polynomial \label{fig:wdPMod}]{%
\includegraphics[width=0.325\textwidth]{WeightDistk23PMod.eps}}
\hfill
\subfloat[High density primitive polynomial \label{fig:wdPHigh}]{%
\includegraphics[width=0.325\textwidth]{WeightDistk23PHigh.eps}}
\hfill
\caption{The Hamming weight distribution of PR code when $k=23$ and a) $p(x)=1+x^5+x^{23}$, b) $p(x)=1+x^2+x^3+x^5+x^9+x^{10}+x^{12}+x^{14}+x^{16}+x^{18}+x^{23}$, and c) $p(x)=1+x^2+x^4+x^5+x^6+x^8+x^9+x^{10}+x^{11}+x^{15}+x^{16}+x^{17}+x^{18}+x^{19}+x^{21}+x^{22}+x^{23}$. Solid and dashed lines show the Hamming weight distribution and binomial distribution, respectively.}
\label{fig:wdLMH}
\end{figure*}
Fig. \ref{fig:mindistbound} shows the minimum Hamming weight for three PR codes of dimension $k=16$, $k=20$, and $k=39$ at different block length. As can be seen in this figure, a PR code with a properly chosen primitive polynomial will have a minimum Hamming weight close to the bound (\ref{eq:mindisbound}) at any block length $n\ge2k$. It is also important to note that the bound obtained in (\ref{eq:mindisbound}) and (\ref{eq:GVdisbound}) are identical for the cases in Fig. \ref{fig:mindistbound}. One can search for other primitive polynomials to achieve higher minimum Hamming weight at a given block length. This also shows that a PR code with a properly chosen primitive polynomial can meet the Gilbert-Varshamov bound.
In this paper, we use MAGMA \cite{MR1484478} to calculate the minimum Hamming weight of PR codes. MAGMA is using an algorithm described in \cite{betten2013codierungstheorie} to find the minimum Hamming weight of linear codes. It generates several generator matrices for the same code, such that these codes have disjoint information sets. The algorithm proceeds by enumerating all combinations derived from $r$ information symbols in all generator matrices, for each successive $r$. Once the lower and upper bounds on the minimum weight meet, the computation is complete. For PR codes, the codeword with the minimum weight usually corresponds to a low-weight message word; thus, MAGMA easily finds the minimum weight of PR codes.
\section{Selecting Primitive Polynomials for PR codes}
S. Wainberg and J. K Wolf \cite{Wainberg1970} studied the properties of subsequences of long $m$-sequences using the moments of the subsequence weight distribution. The moments were used for selecting good $m$-sequences for correlation-detection problem. Authors in \cite{Matsumoto1996} showed that for some bad initial vectors, terrible non-randomness continues for extraordinary long time in the sequences generated by the LFSRs with primitive polynomials with three terms. The bad behaviour of primitive trinomials and $t$-nomials with small $t$ was studies in \cite{Compagner1991,Fredricsson1975,Lindholm1968}.
For PR codes to have the Hamming weight distribution closely approach the binomial distribution and accordingly a minimum Hamming weight lower bounded by \eqref{eq:boundgvmin}, the subsequences of the LFSR should preserve randomness for almost all initial conditions. Otherwise, the subsequences will have too many zeros or ones. Therefore, the primitive polynomial should be chosen properly to preserve randomness for subsequences of moderate length. Authors in \cite{Jordan1973} showed (via numerical results) that the probability distribution of the number of ones in $n$ successive bits of an $m$-sequence with primitive polynomial $p(x)$, which is equivalent to the Hamming weight distribution of the PR code with the same primitive polynomial, can be well approximated by the binomial distribution, when 1) the length $k$ of the shift-register is sufficiently large, 2) the sequence length $n$ satisfies $144\le n\ll 2^k$, and 3) the primitive polynomial should be chosen such that the number of subsequences of length $n$ with Hamming weight $\ell$ is small for $\ell$ near zero and $\ell$ near $n$ \cite{Jordan1973}. We however found that in most cases when the primitive polynomial is chosen properly, the Hamming weight distribution closely approaches the binomial distribution for a sufficiently large $n$.
LFSRs with their connection polynomials very sparse are very vulnerable to various known attacks. On the other hands, a very dense primitive polynomial might be a factor of a low density polynomial of moderate degree, which makes the LFSR vulnerable to various attacks, such as the correlation attack \cite{Jambunathan2000}. When the primitive polynomial is sparse or has a multiple with only a few non-zero elements, the dual of the PR code will have a relatively low minimum Hamming weight. In particular, as shown in \cite{Matsumoto1996} when the primitive polynomial is $p(x)=1+x^{\ell}+x^k$, with $k\ge 2\ell$, the initial vector for the characteristic sequence has at most two 1's, where the characteristic sequences satisfies $x_i=x_{2i}$ for every integer $i$ \cite{Golomb1967}. This means that the sequence is not completely random; therefore, the Hamming weight distribution of the respective PR code deviates from the binomial distribution.
\begin{table}[t]
\centering
\caption{The KLD of the Hamming weight distribution and the binomial distribution, $f_{\mathrm{bin}}(n,d)=\dbinom{n}{d}2^{-n}$.}
\label{tab:kldLMH}
\scriptsize
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{$n$} & \multicolumn{2}{c|}{Low-density $p(x)$} & \multicolumn{2}{c|}{Moderate-density $p(x)$}& \multicolumn{2}{c|}{High-density $p(x)$}\\
\cline{2-7}
& $\mathrm{KLD}$&$d_{\min}$& $\mathrm{KLD}$&$d_{\min}$& $\mathrm{KLD}$&$d_{\min}$ \\
\hline
\hline
50&$2.53e{-2}$&3& $7.29e{-6}$&7&$5.24e{-6}$&8\\
\hline
100&$5.07e{-2}$&10&$2.55e{-5}$&28&$2.46e{-5}$&26\\
\hline
200&$8.72e{-2}$&30&$3.84e{-5}$&68&$9.58e{-5}$&67\\
\hline
\end{tabular}
\end{table}
\begin{table*}
\centering
\caption{Some of good primitive polynomials for PR codes and their minimum Hamming weights at different rates. The block length at each rate is set to $n=\lceil k/R\rceil$, where $\lceil .\rceil$ is the ceiling operand. The MAGMA calculator \cite{MR1484478} was used to obtain the primitive polynomials and the minimum Hamming weights.}
\label{tab:primpoly}
\scriptsize
\begin{tabular}{|c|p{8.5cm}|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{$k$} &\multirow{2}{*}{$p(x)=1+x^k+$}& \multicolumn{6}{c|}{$d_{\min}$ ($d_{\mathrm{GV}}$)} \\
\cline{3-8}
&&$R=0.6$&$R=0.5$&$R=0.4$&$R=0.3$&$R=0.2$&$R=0.1$\\
\hline
\hline
2&$x$&2 (3)&2 (3)&3 (3)&4 (4)&6 (5)&13 (10)\\
\hline
3&$x$&2 (3)&3 (3)&4 (4)&5 (5)&8 (7)&16 (14)\\
\hline
4&$x$&2 (3)&3 (3)&4 (4)&7 (6)&9 (9)&20 (19)\\
\hline
5&$x^2$&2 (3)&3 (3)&4 (5)&6 (6)&11 (10)&24 (23)\\
\hline
6&$x^2+x^3+x^5$&2 (3)&3 (4)&5 (5)&6 (7)&11 (11)&29 (26)\\
\hline
7&$x^1+x^3+x^6$&2 (3)&4 (4)&6 (5)&9 (7)&13 (12)&30 (29)\\
\hline
8&$x^2+x^3+x^5$&3 (4)&4 (4)&5 (5)&8 (8)&14 (13)&32 (29)\\
\hline
9&$x+x^3+x^4$&3 (4)&4 (4)&6 (6) &10 (8)&16 (14) &36 (32)\\
\hline
10&$x+x^2+x^3+x^5+x^6$&3 (4)&5 (4)&6 (6)&10 (9)&16 (15)&39 (36)\\
\hline
11&$x+x^3+x^5$&3 (4)&5 (5)&7 (7)&10 (10)&19 16)&43 (39)\\
\hline
12&$x+x^3+x^4+x^5+x^6$&3 (4)&5 (5)&7 (7)&10 (10)&17 (18)&45 (42)\\
\hline
13&$x+x^3+x^4+x^5+x^8$ &4 (4)&6 (5)&8 (7)&13 (11)&20 (19)&48 (45)\\
\hline
14&$x+x^3+x^5+x^6+x^7$&4 (4)&6 (5)&8 (8)&13 (12)&21 (20)&51 (48)\\
\hline
15&$x+x^2+x^5+x^7+x^8$&4 (4)&6 (6)&8 (8)&13 (12)&23 (21)&56 (52)\\
\hline
16&$x+x^4+x^6+x^8+x^9+x^{11}+x^{13}$&5 (4)&7 (6)&9 (8)&14 (13)&23 (23)&57 (55)\\
\hline
17&$x+x^2+x^3+x^6+x^{12}$&4 (5)&5 (6)&9 (9)&15 (14)&24 (24)&59 (58)\\
\hline
18&$x+x^2+x^4+x^6+x^7+x^8+x^9$&4 (5)&5 (6)&9 (9)&14 (14)&26 (25)&66 (61)\\
\hline
19&$x^2+x^3+x^4+x^5+x^6+x^7+x^8+x^9+x^{11}$&4 (5)&5 (6)&9 (10)&15 (15)&28 (26)&69 (64)\\
\hline
20&$x^2+x^3+x^4+x^7+x^{10}+x^{14}+x^{17}$&4 (5)&6 (7)&10 (10)&15 (16)&29 (28)&69 (68)\\
\hline
21&$x+x^2+x^3+x^6+x^7+x^{10}+x^{13}+x^{15}+x^{16}+x^{17}+x^{19}$&5 (5)&6 (7)&11 (10)&17 (16)&28 (29)&70 (71)\\
\hline
22&$x^7+x^{11}+x^{12}+x^{14}+x^{15}+x^{16}+x^{17}+x^{19}+x^{21}$&5 (5)&8 (7)&10 (11)&16 (17)&31 (30)&78(74)\\
\hline
23&$x^2+x^3+x^5+x^9+x^{10}+x^{12}+x^{14}+x^{16}+x^{18}$&5 (5)&6 (7)&12 (11)&18 (17)&32 (31)&78 (77)\\
\hline
24&$x+x^2+x^3+x^4+x^6+x^8+x^9+x^{14}+x^{21}+x^{22}+x^{23}$&5 (5)&7 (8)&11 (12)&17 (18)&33 (33)&82 (80)\\
\hline
25&$x^2+x^3+x^5+x^8+x^{11}+x^{15}+x^{16}+x^{17}+x^{18}+x^{20}+x^{21}+x^{23}+x^{24}$&5 (6)&7 (8)&12 (12)&21 (19)&35 (34)&84 (84)\\
\hline
26&$x^3+x^5+x^6+x^9+x^{13}+x^{14}+x^{16}+x^{17}+x^{19}+x^{24}+x^{25}$&5 (6)&7 (8)&12 (12)&20 (19)&35 (35)&91 (87)\\
\hline
27&$x^4+x^5+x^9+x^{12}+x^{15}+x^{16}+x^{18}+x^{22}+x^{24}+x^{25}+x^{26}$&6 (6)&9 (8)&13 (13)&21 (20)&37 (36)&94 (90)\\
\hline
28&$x+x^2+x^4+x^6+x^{10}+x^{11}+x^{16}+x^{19}+x^{21}+x^{22}+x^{23}+x^{25}+x^{26}$&5 (6)&9 (8)&13 (13)&20 (21)&38 (37)&93 (93)\\
\hline
29&$x^6+x^8+x^9+x^{10}+x^{12}+x^{18}+x^{22}+x^{24}+x^{26}$&6 (6)&8 (9)&14 (13)&21 (21)&40 (39)&100 (96)\\
\hline
30&$x^3+x^4+x^6+x^9+x^{11}+x^{12}+x^{16}+x^{18}+x^{23}+x^{26}+x^{27}$&5 (6)&9 (9)&14 (14)&22 (22)&42 (40)&103 (99)\\
\hline
31&$x+x^6+x^8+x^9+x^{12}+x^{13}+x^{18}+x^{19}+x^{21}+x^{22}+x^{25}+x^{26}+x^{27}+x^{28}+x^{30}$ &5 (6)&8 (9)&14 (14)&23 (23)&42 (41)&105 (100)\\
\hline
32&$x+x^2+x^5+x^7+x^8+x^9+x^{11}+x^{12}+x^{14}+x^{16}+x^{20}+x^{22}+x^{23}+x^{26}+x^{30}$&6 (7)&9 (9)&14 (14)&23 (23)&41 (42)&109 (106)\\
\hline
33&$x^2+x^3+x^4+x^5+x^7+x^9+x^{13}+x^{15}+x^{19}+x^{22}+x^{23}+x^{24}+x^{25}+x^{27}+x^{28}+x^{30}+x^{31}$&6 (7)&9 (10)&15 (15)&23 (24)&45 (44)&111 (109)\\
\hline
34&$x+x^5+x^8+x^{11}+x^{13}+x^{15}+x^{17}+x^{19}+x^{20}+x^{21}+x^{22}+x^{24}+x^{25}+x^{26}+x^{27}+x^{29}+x^{30}+x^{31}+x^{32}$ &6 (7)&10 (10)&15 (15)&25 (25)&45 (45)&116 (112)\\
\hline
35&$x^2+x^4+x^5+x^7+x^8+x^{10}+x^{11}+x^{12}+x^{13}+x^{14}+x^{16}+x^{18}+x^{19}+x^{21}+x^{23}+x^{25}+x^{27}+x^{29}+x^{34}$&7 (7)&9 (10)&15 (15)&26 (25)&47 (46)&118 (115)\\
\hline
36&$x^3+x^4+x^{10}+x^{12}+x^{13}+x^{14}+x^{15}+x^{16}+x^{17}+x^{21}+x^{22}+x^{23}+x^{24}+x^{26}+x^{27}+x^{28}+x^{29}+x^{30}+x^{31}+x^{32}+x^{34}$&6 (7)&9 (10)&16 (16)&26 (26)&48 (47)&120 (119)\\
\hline
37&$x^{5}+x^{9}+x^{12}+x^{13}+x^{16}+x^{17}+x^{19}+x^{20}+x^{21}+x^{22}+x^{25}+x^{26}+x^{27}+x^{28}+x^{31}+x^{32}+x^{33}$&7 (7)&10 (11)&16 (16)&26 (27)&49 (49)&124 (122)\\
\hline
38&$x+x^{4}+x^{5}+x^{7}+x^{11}+x^{14}+x^{16}+x^{18}+x^{19}+x^{21}+x^{23}+x^{26}+x^{27}+x^{28}+x^{29}+x^{31}+x^{35}$&6 (7)&10 (11)&16 (17)&28 (27)&52 (50)&122 (125)\\
\hline
39&$x+x^{2}+x^{3}+x^{4}+x^{6}+x^{8}+x^{10}+x^{12}+x^{13}+x^{14}+x^{16}+x^{18}+x^{20}+x^{26}+x^{29}+x^{32}+x^{33}+x^{34}+x^{38}$&7 (7)&11 (11)&17 (17)&28 (28)&52 (51)&128 (128)\\
\hline
40&$x+x^{4}+x^{6}+x^{7}+x^{8}+x^{10}+x^{12}+x^{15}+x^{16}+x^{17}+x^{19}+x^{20}+x^{21}+x^{24}+x^{25}+x^{26}+x^{27}+x^{30}+x^{31}+x^{32}+x^{33}+x^{35}+x^{37}+x^{38}+x^{39}$&8 (8)&11 (11)&18 (18)&29 (29)&52 (52)&131 (131)\\
\hline
\end{tabular}
\end{table*}
\begin{example} Let $k=23$ and we consider three primitive polynomials, $p_1(x)=1+x^5+x^{23}$, $p_2(x)=1+x^2+x^3+x^5+x^9+x^{10}+x^{12}+x^{14}+x^{16}+x^{18}+x^{23}$, and $p_3(x)=1+x^2+x^4+x^5+x^6+x^8+x^9+x^{10}+x^{11}+x^{15}+x^{16}+x^{17}+x^{18}+x^{19}+x^{21}+x^{22}x^{23}$. The first primitive polynomial is of low density and has only three terms. The second and third polynomials have respectively 11 and 17 terms. Fig. \ref{fig:wdPlow} shows the Hamming weight distribution of the PR code with $p_1(x)$ at block lengths $n=50, ~100$, and $200$. As can be seen, the weight distribution clearly deviates from the binomial distribution. However, as can be seen in Fig. \ref{fig:wdPMod} and Fig. \ref{fig:wdPHigh}, when the density of the primitive polynomial is moderate or high, the Hamming weight distribution of the PR code at different block lengths closely approach the binomial distribution. To better characterise the mismatch between the Hamming weight distribution and binomial distribution, we list the KLD between the distributions in Table \ref{tab:kldLMH}. As can be seen the KLD for PR codes with the moderate/high density primitive polynomial is significantly lower than that for PR codes with low-density primitive polynomials. It is also clear from Table \ref{tab:kldLMH} that the PR code with moderate to high density primitive polynomials achieve larger minimum Hamming weights.
\end{example}
We found some good primitive polynomials for PR codes which can closely achieve the bound \eqref{eq:mindisbound} developed in Theorem 1. In particular, first a random irreducible polynomial of degree $k$ and weight larger than or equal to $k/2$ is generated. Then, the polynomial will be tested for primitivity. If the polynomial is not primitive, another random irreducible polynomial will be generated. If the polynomial is primitive, then the minimum Hamming weight of the code is calculated at different rates. If the calculated Hamming weights are close to the bound in \eqref{eq:mindisbound}, then the polynomial will be considered as good primitive polynomial. Usually, the good polynomial is found after generating up to 5 random irreducible polynomials. When $k$ increases, the number of primitive polynomials of degree $k$ also increases, therefore, the search space for finding a better primitive polynomial also scales.
Table \ref{tab:primpoly} lists some of good primitive polynomials for PR codes of dimension up to $k=40$. For most of the primitive polynomials, the density of the primitive polynomial is almost $0.5$, which means that it has almost $k/2$ terms. As can be seen in this table, the PR code with these primitive polynomials can closely approach the Gilbert-Varshamov bound \eqref{eq:GVdisbound} at different rates. It is important to note that one may find other primitive polynomials which can achieve higher minimum Hamming weights at some code rates. Our results show that for sufficiently large $k$ ($k\ge20$) a randomly chosen primitive polynomial of degree $k$ with almost $k/2$ terms can generate PR codes with Hamming weight distribution closely approaching the Binomial distribution and accordingly minimum Hamming weights close to the bound \eqref{eq:mindisbound}, when $n\ge 2k$.
\section{Numerical Results}
In this section, we study the block error rate (BLER) performance of PR codes at fixed block lengths and compare them with eBCH codes with the same dimensions and block lengths. We also provide some results on the rateless performance of PR codes.
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{BLER_k8_BCHvsPR_NEW.eps}
\vspace{-2ex}
\caption{The block error rate performance of the PR and eBCH codes at different block lengths when $k\approx7$. The decoding was performed by using an order-5 OSD.}
\label{fig:bler7}
\end{figure}
\subsection{Fixed-rate Performance}
A message $\mathbf{b}$ of length $k$ is encoded by using a PR code $\mathrm{PR}(k,n,p(x))$ to generate a codeword $\mathbf{c}$. Each coded symbol $c_i$, for $1\le i\le n$, is then modulated to $x_i=(-1)^{c_i}$ and sent over a binary-input additive white Gaussian noise (BI-AWGN) channel, $y_i=x_i+w_i$, where $y_i$ is the $i^{th}$ channel output and $w_i$ is the AWGN with variance $N_0/2$. The channel signal-to-noise ratio (SNR) is then given by $\gamma=2/N_0$.
By using the average weight enumerator of PR codes obtained in \eqref{eq:avgWeightPR}, we can derive a union bound (UB) for the BLER as follows:
\begin{align}
\epsilon_{\mathrm{UB}}=\sum_{i=d_{min}}^{n}\frac{i}{n} \Bar{A}_iQ\left(\sqrt{i\gamma}\right),
\label{eq:unionbound}
\end{align}
where $Q(.)$ is the standard $Q$-function, $d_{\min}$ is obtained from \eqref{eq:mindisbound}, and $\Bar{A}_i$ is given by \eqref{eq:avgWeightPR}.
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{BLER_k16_BCHvsPR_NEW.eps}
\vspace{-2ex}
\caption{The block error rate performance of the PR and eBCH codes at different block lengths when $k\approx16$. The decoding was performed by using an order-5 OSD.}
\label{fig:bler16}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{BLER_k24_BCHvsPR_NEW.eps}
\vspace{-2ex}
\caption{The block error rate performance of the PR and eBCH codes at different block lengths when $k\approx24$. The decoding was performed by using an order-7 OSD.}
\label{fig:bler24}
\end{figure}
\begin{table*}[t]
\centering
\caption{The weight enumerator of PR codes and eBCH codes. The primitive polynomial for PR codes are obtained from Table II.}
\label{tab3}
\scriptsize
\begin{tabular}{p{0.1cm}p{0.1cm}p{0.6cm}p{14cm}}
$n$&$k$&Code&Weight Enumerator Polynomial\\
\hline
32&6&eBCH&$1+62x^{16} + x^{32}$\\
&&PR&$1+2x^{12}+4x^{13}+7x^{14}+8x^{15}+14x^{16}+12x^{17}+5x^{18}+8x^{19}+3x^{20}$\\
\hline
64&7&eBCH&$1+126x^{32} + x^{64}$\\
&&PR&$1+2x^{27}+8x^{28}+17x^{29}+23x^{30}+9x^{31}+6x^{32}+7x^{33}+13x^{34}+25x^{35}+13x^{36}+4x^{37}$\\
\hline
128&8&eBCH&$1+254x^{64} + x^{128}$\\
&&PR&$1+3x^{55}+2x^{56}+12x^{57}+7x^{58}+6x^{59}+13x^{60}+14x^{61}+27x^{62}+30x^{63}+17x^{64}+25x^{65}+32x^{66}+\cdots$\\
\hline
\hline
32&16&eBCH&$1+620x^8+13888x^{12}+36518x^{16}+13888x^{20}+620x^{24}+x^{32}$\\
&&PR& $1+50x^{7}+175x^{8}+455x^{9}+999x^{10}+1953x^{11}+3493x^{12}+5248x^{13}+6944x^{14}+8684x^{15}+9543x^{16}+\cdots$\\
\hline
64&16&eBCH&$1+5040x^{24}+12544x^{28}+30366x^{32}+12544x^{36}+5040x^{40}+x^{64}$\\
&&PR&$ 1+5x^{18}+35x^{19}+79x^{20}+129x^{21}+268x^{22}+525x^{23}+963x^{24}+1485x^{25}+2070x^{26}+2929x^{27}+3889x^{28}+\cdots$\\
\hline
128&15&eBCH&$1+8128x^{56}+16510x^{64}+8128x^{72}+x^{128}$\\
&&PR&$1+x^{46}+7x^{47}+33x^{48}+95x^{49}+135x^{50}+192x^{51}+257x^{52}+397x^{53}+526x^{54}+637x^{55}+935x^{56}+1085x^{57}+\cdots$\\
\hline
\hline
64&24&eBCH&$1+2604x^{16}+10752x^{18}+216576x^{22}+291648x^{24}+1645056x^{26}+888832x^{28}+4419072x^{30}+1828134x^{32}+\cdots$\\
&&PR&$1+9x^{13}+44x^{14}+112x^{15}+382x^{16}+1180x^{17}+3348x^{18}+8234x^{19}+17863x^{20}+37820x^{21}+73272x^{22}+\cdots$\\
\hline
128&22&eBCH&$1+42672x^{48}+877824x^{56}+2353310x^{64}+877824x^{72}+42672x^{80}+x^{128}$\\
&&PR&$1+2x^{37}+5x^{38}+4x^{39}+12x^{40}+49x^{41}+115x^{42}+275x^{43}+576x^{44}+931x^{45}+1739x^{46}+3155x^{47}+5242x^{48}+\cdots$
\end{tabular}
\end{table*}
Fig. \ref{fig:bler7} shows the BLER performance of PR codes when the message length is $k\approx7$. The primitive polynomial for PR codes are obtained from Table \ref{tab:primpoly}. We use an order-5 ordered statistic decoding (OSD) \cite{Fossorier1995} algorithm for decoding both PR and eBCH codes. As can be seen in this figure, PR codes achieve almost the same BLER as their eBCH counterparts in different SNRs and code rates. The results in Fig. \ref{fig:bler16} and Fig. \ref{fig:bler24} for $k\approx 16$ and $k\approx 24$, respectively, also confirm that PR codes with properly chosen primitive polynomials can achieve BLERs close to their eBCH counterparts. It is important to note that while eBCH codes have relatively larger minimum Hamming weights, PR codes achieves almost the same BLER performance, which is mainly due to the fact the Hamming weight distribution of PR codes is very close to the binomial distribution (when the primitive polynomial is chosen properly), which means that the PR code has a small number of codewords with low Hamming weights. This can be clearly seen in Table \ref{tab3}, that shows the Hamming weight distribution of eBCH and PR codes at different block lengths and rates.
\subsection{Rateless Performance}
We now consider a rateless setting, where we assume that the transmitter wants to deliver a message of length $k$ symbols at the receiver. We assume that the receiver can estimate the channel SNR accurately, however the transmitter does not have any knowledge of the channel SNR. The transmitter uses a PR code $\mathrm{PR}(k,p(x))$ to generate a potentially limitless number of PR coded symbols and continuously send to the receiver. The receiver sends an acknowledgement to the sender when it collected a sufficient number of coded symbols. We use the Polyanskiy-Poor-Verdu (PPV) normal approximation \cite{polyanskiy2010channel} to estimate the number of coded symbols to perform a successful decoding at the desired block error rate. Let $n_s$ denote the number of coded symbols required to perform a successful decoding at the target block error rate $\epsilon_{\mathrm{th}}$. It can be estimated as follows \cite{erseghe2016coding}:
\begin{align}
n_s=\min_n\left\{n: \epsilon(k,n,\gamma)\le\epsilon_{\mathrm{th}}\right\},
\label{eq:blppv}
\end{align}
where
\begin{align}
\epsilon(k,n,\gamma)=Q\left(\sqrt{\frac{1}{nV(\gamma)}}\left(\frac{nC(\gamma)-k}{\log_2(e)}+\frac{\ln(n)}{2}\right)\right),
\label{eq:ppvbound}
\end{align}
where for a BI-AWGN channel at SNR $\gamma$, we have
\begin{align}
C(\gamma)=1+\frac{H^{(1)}(0)}{\ln(2)}, ~~~V(\gamma)=H^{(2)}(0)-\left(H^{(1)}(0)\right)^2,
\end{align}
and
\begin{align}
H^{(\ell)}(0)=\frac{1}{\sqrt{2\pi\gamma}}\int_{-\infty}^{-\infty}e^{-\frac{(x-\gamma)^2}{2\gamma}}(-h(x))^\ell dx,
\end{align}
and $h(x)=\ln\left(1+e^{-2x}\right)$ \cite{erseghe2016coding}.
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{Ratelessk8PPV.eps}
\vspace{-2ex}
\caption{The achievable BLER performance of PR codes at different SNRs for different target BLERs, when $k=8$, $k=16$, and $k=24$. }
\label{fig:ratelessBLER}
\end{figure}
\begin{figure*}
\centering
\subfloat[BI-AWGN channel. \label{fig:ratelessCRC}]{%
\includegraphics[width=0.49\textwidth]{CRCRatelessk61.eps}}
\hfill
\subfloat[Rayleigh block fading channel with QPSk modulation. \label{fig:ratelessfading}]{%
\includegraphics[width=0.49\textwidth]{RealizedRateFading.eps}}
\hfill
\caption{The achievable throughput of PR code $\mathrm{PR}(61,p(x))$ with 2-bit CRC with the increment of block length $\delta=5$ and initial block length $n_1=n_s$ \eqref{eq:blppv} when an order-4 OSD algorithm was used. $p(x)=1+x+x^{3}+x^{4}+x^{5}+x^{6}+x^{7}+x^{15}+x^{16}+x^{17}+x^{18}+x^{21}+x^{23}+x^{27}+x^{28}+x^{30}+x^{33}+x^{35}+x^{36}+x^{37}+x^{39}+x^{40}+x^{41}+x^{44}+x^{47}+x^{48}+x^{52}+x^{54}+x^{56}+x^{57}+x^{61}$.}
\label{fig:ratelssfigures}
\end{figure*}
We consider three message lengths, i.e, $k=8,~15$, and $24$, and simulate the PR code in a rateless manner and find the block error rates in various SNRs at block lengths obtained by \eqref{eq:blppv}. Fig. \ref{fig:ratelessBLER} shows the results for the target BLER of $10^{-2}$ and $10^{-4}$ when an order-5 OSD decoder was used for $k=15$ and $k=24$, while the maximum-likelihood (ML) decoder was used for $k=8$. As can be seen the proposed PR code performs very close to the normal approximation bound \eqref{eq:ppvbound} and achieves the target BLER. It is important to note that the approximation (\ref{eq:ppvbound}) looses accuracy at low SNRs, low rates, and very short block lengths; therefore, the estimated number of coded symbols required for a successful decoding may not be accurate. This is the main reason why at high SNRs, there is a large gap between the BLER of PR codes and the target BLER. In particular, when SNR is 5dB, $n_s$ will be very close to $k$, which is very short. The bound in \eqref{eq:ppvbound} is therefore loose and $n_s$ will be inaccurate. It is also important to note that for codes operating at low SNRs, a higher order OSD may be required. This is because for a linear block code $\mathcal{C}(n,k)$ with minimum distance $d_{\mathrm{H}}$ it has been proven that an OSD with the order of $m=\lceil (d_{\mathrm{H}}-1)/4\rceil$ is asymptotically optimum, which means that it can achieve the maximum-likelihood performance. For example, when $\epsilon_{\mathrm{th}}=10^{-4}$, $k=24$, and SNR$=-5$dB, the number of coded symbols obtained by \eqref{eq:blppv} is $n_s=323$ and the respective PR code will have a minimum Hamming weight of $d_{\mathrm{H}}=116$. Therefore, an OSD with an order much larger than 5 is required to have a near optimal performance. The gap at low SNRs for $k=15$ and $k=24$ is mainly due to the low order of the OSD decoder.
We consider another rateless scenario, where the receiver attempts the first decoding when it collected $n_1$ symbols and if successful, it sends an acknowledgment to the transmitter to stop the transmission. We assume that the feedback is instantaneous and error-free. However, if the decoding failed, the receiver collects $\delta>0$ additional symbols and reattempts the decoding using a codeword with $n_1+\delta$ symbols. In particular, in the $i^{th}$ decoding attempt, the receiver has already collected $n_i=n_1+(i-1)\delta$ PR coded symbols and performs the decoding using a codeword of length $n_i$. The transmitter terminates the transmission upon receiving the acknowledgement or when a predetermined number of symbols are sent. We use a $k_c$-bit CRC check to decide whether the decoding in each attempt is successful or not. The throughput or the realize rate of the PR code is then defined as follows:
\begin{align}
\mathcal{R}=\frac{(k-k_c)(1-\epsilon)}{\mathbb{E}[n]},
\end{align}
where $\mathbb{E}$ is the expectation operand, $n$ is the number of coded symbols collected until the CRC bits are checked, and $\epsilon$ is the block error rate. It is clear that $n$ is random and depends on the noise realization. Fig. \ref{fig:ratelessCRC} shows that the PR code with $k=61$ and 2-bit CRC over the BI-AWGN channel can closely approach the normal approximation bound in a wide range of SNRs at different target BLERs. We also show the performance of the PR code over the Rayleigh block fading channel with QPSK modulation in Fig. \ref{fig:ratelessfading}. We assumes that the channel state information is available at the receiver, therefore it can determine the initial codeword length $n_1=n_s$ according to \eqref{eq:blppv} to start the decoding. We also assume that the channel remains fixed for the entire duration of decoding a message block of length $k$ bits. As can be seen, the PR code with $k=61$ and 2-bit CRC can closely approach the normal approximation bound in a wide range of SNRs over the fading channel. The performance can be improved by using a higher order OSD algorithm, which in turns increases the complexity.
\subsection{OSD Decoding of PR codes}
Designing an efficient decoding algorithm for PR codes is of critical importance. While this is out of the scope of this paper, we provide some notes on the use of low-complexity OSD algorithms for decoding PR codes.
In OSD, the received coded symbols are first ordered in descending order of their reliability. The generator matrix of the code is accordingly permuted. Next, Gaussian elimination (GE) is performed to obtain the systematic form of the permuted generator matrix. A second permutation may be required during the GE to ensure that the first $k$ columns are linearly independent. The first $k$ bit positions are referred to as the most reliable basis (MRB). Then, MRB will be XORed with a set of test error patterns (TEP) with the Hamming weight up to a certain degree, referred to as the order of OSD. Then the vectors obtained by XORing the MRB are re-encoded using the permuted generator matrix to generate candidate codeword estimates. The codeword estimate with the minimum distance from the received signal is selected as the decoding output.
OSD is an approximate maximum likelihood (ML) decoder for block codes \cite{Fossorier1995}. More specifically, for a linear block code $(n, k)$ with minimum Hamming weight $d_{\min}$, it is proven that an OSD with order $m = \lceil d_{\min}/4 - 1\rceil$ is asymptotically optimum \cite{Fossorier1995}. OSD is, however, complex and its algorithmic complexity can be up to $\mathcal{O}(k^m)$ for an order-$m$ OSD. Several approaches have been recently proposed to reduce the number of TEPs required to be re-encoded to find the best codeword estimate. Authors in \cite{Chentao2021OSD} characterized the evolution of the distance distribution during the reprocessing stage of the OSD algorithm. They accordingly proposed several decoding rules, namely sufficient and necessary conditions, to reduce the complexity significantly. These are mainly to terminate the decoding early, when a suitable candidate codeword is found, and to discard TEPs, which are less likely to generate promising codeword candidates. Other approaches introduced in \cite{Chentao2019SDOSD,Chentao2020PBOSD} can also be used to further reduce the complexity by searching through the TEPs in an optimal manner, which will result in finding the best codeword estimate faster. An efficient implementation in C has shown that the OSD decoding with sufficient and necessary conditions can run an order-5 OSD in a few $\mu$s per codeword \cite{Choi2019FastOSD}.
For the simulations in this paper, we used the simple probabilistic necessary condition (PNC) proposed in \cite{Choi2019FastOSD} to terminate the decoding when a candidate codeword is found with the distance to the received signal lower than a certain threshold. The threshold value for the $i^{th}$ reprocessing order is calculated as $S_i = \sum_{k-1-i}^{k-1}|\bar{y}_i| + \beta(n - k)$, where $\bar{y}_i$ is the re-ordered received signal. In the $i^{th}$ reprocessing stage, once a codeword with distance to the received codeword less than $S_i$ is found, the decoder terminates and skips the remaining orders. For example, when decoding the PR code with $k=22$ and $n=128$ (Fig. \ref{fig:bler24}) using an order-7 OSD with PNC \cite{Choi2019FastOSD} and $\beta=0.08$, we only need to check on average 1265 TEPs at SNR$=-1$dB. This is a significant reduction from 280599 TEPs in the original order-7 OSD, while achieving the same BLER performance. The decoding run-time per codeword is accordingly reduced by two orders of magnitude. Further reductions in the number of TEPs and running time can be achieved by using approaches proposed in \cite{Chentao2021OSD}.
We note that other decoding approaches, such as the Berlekamp–Massey algorithm \cite{massey1969shift}, can be modified to decode PR codes. This is however out of the scope of this work and will be discussed in future works.
\section{Conclusions and Future Works}
In this paper, primitive rateless (PR) codes were proposed. A PR code is mainly characterized by the message length $k$ and a primitive polynomial of degree $k$, where the $i^{th}$ columns of the generator matrix is the binary representation of $\alpha^{i-1}$, where $\alpha$ is a primitive element of $\mathbf{GF}(2^k)$ and is the root of $p(x)$. We showed that a PR code can be also constructed 1) by using a linear-feedback shift-register (LFSR) with connection polynomial $x^kp(1/x)$ and 2) by using Boolean functions. We proved that any two PR codes of dimension $k$ and truncated at length $n\ge 2k$, which are constructed by using two distinct primitive polynomials, do not have any non-zero codeword in common. We characterized the average Hamming weight distribution of PR codes and developed a lower bound on the minimum Hamming weight which is very close to the Gilbert-Varshamov bound. We proved that for any $k$, there exists at least one PR code that can meet this bound. We further found some good primitive polynomials for PR codes of dimension $k\le 40$ which can closely approach the Gilbert-Varshamov bound. Simulation results show that the PR code with a properly chosen primitive polynomial can achieve similar block error rate performance as the eBCH code counterpart. We further simulated the PR code in a rateless setting and showed that it can achieve very high realized rates over a wide range of SNRs. PR codes can be designed for any message length and the primitive polynomial can be optimized for any block length. Potential future directions could be finding a framework to optimized the primitive polynomial and devising novel on-the-fly decoding approaches for PR codes.
\bibliographystyle{IEEEtran}
\footnotesize
| {'timestamp': '2021-07-14T02:06:37', 'yymm': '2107', 'arxiv_id': '2107.05774', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05774'} | arxiv |
\section{Introduction}
After receiving paper reviews, authors may optionally submit a rebuttal to address the reviewers' comments, which will be limited to a {\bf one page} PDF file. Please follow the steps and style guidelines outlined below for submitting your author response.
Note that the author rebuttal is optional and, following similar guidelines to previous CVPR conferences, it is meant to provide you with an opportunity to rebut factual errors or to supply additional information requested by the reviewers. It is NOT intended to add new contributions (theorems, algorithms, experiments) that were not included in the original submission. You may optionally add a figure, graph or proof to your rebuttal to better illustrate your answer to the reviewers' comments.
Per a passed 2018 PAMI-TC motion, reviewers should not request additional experiments for the rebuttal, or penalize authors for lack of additional experiments. This includes any experiments that involve running code, e.g., to create tables or figures with new results. \textbf{Authors should not include new experimental results in the rebuttal}, and reviewers should discount any such results when making their final recommendation. Authors may include figures with illustrations or comparison tables of results reported in the submission/supplemental material or in other papers.
The rebuttal must adhere to the same blind-submission as the original submission and must comply with this rebuttal-formatted template.
\subsection{Response length}
Author responses must be no longer than 1 page in length including any references and figures. Overlength responses will simply not be reviewed. This includes responses 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.
\section{Formatting your Response}
{\bf Make sure to update the paper title and paper ID in the appropriate place in the tex file.}
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 top margin should begin
1.0 inch (2.54 cm) from the top edge of the page. 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.
Please number all of your sections and any displayed equations. It is important
for readers to be able to refer to any particular equation.
Wherever Times is specified, Times Roman may also be used. Main text should be
in 10-point Times, single-spaced. Section headings should be in 10 or 12 point
Times. All paragraphs should be indented 1 pica (approx. 1/6 inch or 0.422
cm). Figure and table captions should be 9-point Roman type as in
Figure~\ref{fig:onecol}.
List and number all bibliographical references in 9-point Times, single-spaced,
at the end of your response. 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{figure}[t]
\begin{center}
\fbox{\rule{0pt}{1in} \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{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 response. 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 response 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}
}
{\small
\bibliographystyle{ieee_fullname}
\section{Introduction}
\label{intro}
Recently, deep neural networks~(DNNs) became the dominant paradigm in various real-world applications, for example, image classification~\cite{He_2016_CVPR,huang2020dianet,huang2020efficient,hu2018squeeze,huang2020convolution}, semantic segmentation~\cite{zhang2018context,noh2015learning,long2015fully}, object detection~\cite{viola2001robust,hu2018relation,szegedy2013deep,zhao2019object,redmon2016you}. Typically, the DNN is trained offline by a huge data set sampled independently from the real-world, and it is commonly not feasible when we counter new data which is out-of-distribution with respect to the old data. Therefore, many areas in the Artificial Intelligence seek for the solution by learning new knowledge incrementally without forgetting the learned ones, also known as the continual learning~(CL).
In this paper, we study the class continual learning~(CCL), where we will incrementally update the DNN to learn a new set of classes disjointed with the learned classes. To reflect the sequential manner of the CCL, we use the term \textit{session} to represent the learning step of each set of classes. For a new session, the corresponding training data is disjoint with all the previous one, which means the new dataset may not have any trained image from previous sessions. However, this is challenging for the DNN since it has intrinsic catastrophic forgetting problem when the DNN is updated incrementally, as pointed in~\cite{kirkpatrick2017overcoming}. In the CCL, the model is trained to learn a new session sequentially with new data which is not seen in previous sessions. At each session, the model needs to adapt to the changes from the new data's distribution, which may potentially lead to the forgetting of the seen class.
\begin{figure}[t]
\centering
\includegraphics[width=1\linewidth]{syt.jpg}
\caption{Illustration of AlterSGD. After the normal training of current session tends to converge, AlterSGD conducts gradient descent and ascent alternatively. We show in Theorem~\ref{theo:similarity-layer} that AlterSGD is approximately equal to minimizing $\left\|\nabla_{\theta} L(\theta)\right\|_{2}^{2}$, where $L$ represents the loss function. The smaller gradient norm $\left\|\nabla_{\theta} L(\theta)\right\|_{2}^{2}$ represents flatter the region, e.g., region A has smaller gradient norm than region B. Therefore, AlterSGD tends to converge to a region with a flatter minima, e.g., region A.}
\label{fig:minimal}
\end{figure}
On the other hand, in the non-continual learning scenario, \textit{i.e}., learning all the classes at once, we know that when the batch size is too small, the distribution of each batch may extremely vary and cause the shifting of the loss landscape, leading to lousy generalization after training~\cite{keskar2016large,liang2020instance}. One of the solutions for mitigating the distribution variation problem is to seek the flat-minimal region in the loss landscape~\cite{keskar2016large,he2019asymmetric,kleinberg2018alternative,jia2020information}, as illustrated in Figure~\ref{fig:flataharp}. Similarly, in the context of continual learning, such distribution variation will also happen because the training set of current session is disjoint with all the previous data. Hence, we attempt to search for the flat minima in order to potentially benefit the CL. Actually, there are some concurrent works also associating the flat local minimal with forgetting mitigation in CL from different viewpoints (e.g., in CPR~\cite{cha2021cpr} and stable SGD~\cite{NEURIPS2020_518a38cc}). They both verify that maintaining flat local minima can further mitigate the forgetting issue in CL.
\begin{figure}[t]
\centering
\includegraphics[width=1\linewidth]{flatsharp.jpg}
\caption{Illustration of loss function shift. The solid curve and the dotted curve represent the loss function over training data of current session and next session respectively. Due to the shift of training data distribution of different sessions, the loss function will shift accordingly. If the training of current session achieves a flat local minima, the training of next session may start from a small error.}
\label{fig:flataharp}
\end{figure}
However, these methods have the disadvantages as follows: (1) \textbf{Tedious hyperparameters tuning}. As they may include different regularization methods, it is unavoidable to finely tune the hyperparameter for different vision tasks (e.g. image classification, semantic segmentation) and different continual learning protocols. As pointed out in CPR, they need totally different hyperparameter even for different protocols in the same benchmark dataset (e,g, CIFAR100), which will be laborious and lack of principle to readily make the method work. (2) \textbf{Additional computational cost}. Since the additional regularization methods are existing throughout the new class training, it may inevitably introduce much more computation during training.
Therefore, in this paper, we propose method called AlterSGD: When the network tends to converge at each session, we alternate the gradient direction between descent and ascent such that we can search for the flat local minimal region before training on the next new session. Compared to the existing method, our method is efficient since the alternating of the gradient may not include additional computation and time. Moreover, we theoretically prove that such a strategy can encourage the optimization to converge to a flat minima.
Finally, we verify our method on class continual learning~(CCL) for semantic segmentation and the empirical results show that we can significantly mitigate the forgetting of the classes learned in the initial session, and outperform the state-of-the-art~(SOTA) for a large margin under challenging protocols. To summarize, the contributions of this paper include:
\begin{itemize}
\item We propose a simple and effective method to search for a flat local minimal region such that the forgetting of the learned class can be further mitigated on CCL.
\item We provide the theoretical insight about why the AlterSGD may encourage the optimization to converge to the flat minima. We also conduct extensive experiments to verify the effectiveness of our method on CCL for semantic segmentation.
\end{itemize}
\section{Related Works}
\subsection{Continual Learning}
Aiming to mitigate the \textit{Catastrophic Forgetting} problem, continual learning has been widely discussed on image classification~\cite{kirkpatrick2017overcoming,de2019continual}, which can be divided into replay methods, parameter isolation methods and regularization-based methods~\cite{delange2021continual}. Replay methods~\cite{rebuffi2017icarl,isele2018selective,lopez2017gradient} utilize data samples in the previous session as either the network inputs or the constraints for optimization in the new session. In parameter isolation methods~\cite{xu2018reinforced,mallya2018piggyback}, model parameters are independent for each session, and one can freeze parameters for the previous session to avoid forgetting. Regularization-based methods~\cite{chaudhry2018riemannian,li2017learning,zenke2017continual,kirkpatrick2017overcoming} mostly introduce an extra regularization term in the objective function, so as to strengthen the previously-learned knowledge when training on new session.
Another type of method is promoting wide local minima in continual learning. CPR~\cite{cha2021cpr} proves that maximizing the entropy of the output probability can also improve the accuracy for continual learning. In addition, motivated by the importance of learning stability, stable SGD~\cite{NEURIPS2020_518a38cc} forms the suitable training regimes to widen the local minima in each learning session.
Despite the progress on image classification, recent works further investigate continual learning on object detection~\cite{shmelkov2017incremental} and semantic segmentation~\cite{cermelli2020modeling} with knowledge distillation. In particular, the latter one introduces two novel loss terms to mitigate semantic distribution shift within the background.
\subsection{Semantic Segmentation}
With the advancement of Fully Convolution Network (FCN) \cite{long2015fully}, recent deep-learning-based approaches on semantic segmentation have achieved impressive progress on several popular benchmarks~\cite{Everingham15,zhou2017scene}. For example, encoder-decoder architectures~\cite{ronneberger2015u, badrinarayanan2017segnet} are the commonly-used and efficient design for the segmentation networks, which share the internal features or information between layers to improve network representation ability. The atrous-convolution-based methods~\cite{zhao2017pyramid, chen2017deeplab,chen2017rethinking} leverage the dilated filters to enlarge the receptive field of the network and utilize different pooling mechanisms~(e.g., atrous spatial pyramid pooling) to acquire richer contextual information. In order to better aggregate semantic context or feature dependencies, other recent works~\cite{YuanW18,fu2020scene} employ self-attention modules on semantic segmentation networks. In addition, to improve the segmentation network efficiency for applications, light-weight design~\cite{paszke2016enet,zhao2018icnet} and network compression~\cite{He_2021_WACV} can also incorporate and boost the advances for this task.
\section{Proposed Method}
In this section, we systematically introduce our proposed AlterSGD for continual learning as outlined in Section~\ref{intro}. The workflow of AlterSGD consists of two phases, the normal training and the alternative training. In the first phase, the model parameters are optimized by normal gradient descent for learning new classes while the second phase is to alternatively conduct gradient descent and ascent such that the optimizer searches for a flat local minima. We summarize our method in Algorithm~\ref{alg:alg}.
We consider a continual learning problem with $S$ sessions. The empirical loss on the training set at the $s^{\text{th}}$ session is denoted by $L$. We denote $\theta_0$ as the model parameters from the previous session, \textit{i.e.}, $(s-1)^{\text{th}}$ session. Our objective is to learn new classes effectively and simultaneously mitigate forgetting the old classes. Let $T$ be the number of total iterations for parameter update and $p$ be the ratio for normal training. Now we introduce the training details for each phase as follows:
\paragraph{Normal training phase.} In the first phase, the model is trained to learn the new classes at the current session. Therefore, the loss function $L$ is optimized by the normal gradient descent for the first $\fl{pT}$ iterations, \textit{i.e.},
\begin{equation}
\theta_{t}=\theta_{t-1} - \eta \cdot \nabla_{\theta} L\left(\theta_{t-1}\right),
\label{eq:AlterSGD}
\end{equation}
where $t=1,2,\cdots, \lfloor pT\rfloor$, $\fl{\cdot}$ denotes the floor function which outputs the greatest integer less than or equal to the input, and $\eta$ is learning rate.
\paragraph{Alternative training phase.} Though gradient descent converges to a local minima for learning a new session after the first phase, it may fall into the sharp minima which possibly aggravate catastrophic forgetting of previous sessions. In the second phase, the proposed AlterSGD utilizes the alternative gradient descent and ascent update rule for $T-\fl{pT}$ iterations, \textit{i.e.},
\begin{equation}
\left\{\begin{array}{l}
\theta_{t}=\theta_{t-1}-\eta \cdot \nabla_{\theta} L\left(\theta_{t-1}\right),\\
\theta_{t+1}=\theta_{t} + \eta \cdot \nabla_{\theta} L\left(\theta_{t}\right),
\end{array}\right.
\label{eq:AlterSGD}
\end{equation}
where $t=\fl{pT}+1,\fl{pT}+3,\cdots,T$.
Intuitively, the repeat oscillation by conducting gradient descent and ascent in the parameter space has potential to enable AlterSGD to escape the sharp local minima and approach an equilibrium state where the landscape of the loss function $L$ is relatively flat.
In fact, we show in Theorem~\ref{theo:similarity-layer} that the update rule in Eq.~(\ref{eq:AlterSGD}) is approximately equal to minimizing $\left\|\nabla_{\theta} L\left(\theta\right)\right\|_2^2$, which means AlterSGD prefers a small norm of $\nabla_{\theta} L\left(\theta\right)$ during alternative training.
\begin{algorithm}[t]
\caption{AlterSGD training at the $s^{\text{th}}$ session }\label{alg:alg}
\textbf{Input:} The network parameters from the $(s-1)^{\text{th}}$ session, $\theta_0$; Loss function $L(\cdot)$; Learning rate $\eta$; The number of iterations $T$; The alternative ratio $p$.
\textbf{Output:} The network parameters at the $s^{\text{th}}$ session.
\begin{algorithmic}[1]
\State\algorithmiccomment{Normal Training}
\For{$t$ from 1 to $\lfloor pT \rfloor$}
\State $\theta_{t}=\theta_{t-1}-\eta \cdot \nabla_{\theta} L\left(\theta_{t-1}\right)$
\EndFor
\State\algorithmiccomment{Alternative Training}
\For{$t=\lfloor pT \rfloor$+1, $\lfloor pT \rfloor+3$, $\cdots, T$}
\State $\theta_{t}=\theta_{t-1}-\eta \cdot \nabla_{\theta} L\left(\theta_{t-1}\right)$
\State $\theta_{t+1}=\theta_{t} {\color{red}{+}} \eta \cdot \nabla_{\theta} L\left(\theta_{t}\right)$
\EndFor
\State\Return $\theta_T$
\end{algorithmic}
\end{algorithm}
\begin{theorem}\label{theo:similarity-layer}
The update rule of the alternative training in Eq.~(\ref{eq:AlterSGD}) is approximately equal to minimizing the square of $\nabla_{\theta} L\left(\theta\right)$, i.e., $\left\|\nabla_{\theta} L\left(\theta\right)\right\|_2^2$, by gradient descent with learning rate $\frac{\eta^2}{2}$.
\end{theorem}
\begin{proof}
From the update rule~(\ref{eq:AlterSGD}), we have
\begin{equation}
\begin{aligned}
\theta_{t+1} &=\theta_{t}+\eta \cdot \nabla_{\theta} L\left(\theta_{t}\right) \\
&=\theta_{t-1}-\eta \nabla_{\theta} L\left(\theta_{t-1}\right)+\eta\nabla_{\theta} L\left(\theta_{t-1}-\eta \nabla_{\theta} L\left(\theta_{t-1}\right)\right).
\end{aligned}
\end{equation}
Since $\eta$ is small, $\nabla_{\theta} L\left(\theta_{t-1}-\eta \nabla_{\theta} L\left(\theta_{t-1}\right)\right)$ can be approximated by its Taylor expansion. Then we have
\begin{equation}
\begin{aligned}
\theta_{t+1} \approx \theta_{t-1} &-\eta \nabla_{\theta} L\left(\theta_{t-1}\right)+\eta\nabla_{\theta} L\left(\theta_{t-1}\right) \\
&-\eta \cdot \eta \cdot \nabla_{\theta}^{2} L\left(\theta_{t-1}\right)^{\top} \nabla_{\theta} L\left(\theta_{t-1}\right).\\
\end{aligned}
\label{eqn:taylor}
\end{equation}
By~\eqref{eqn:taylor},
$\theta_{t+1} \approx \theta_{t-1}-\frac{\eta^{2}}{2} \nabla_{\theta}\left\|\nabla_{\theta} L\left(\theta_{t-1}\right)\right\|^{2}$, which indicates the update rule~(\ref{eq:AlterSGD}) is approximately equal to minimizing $\left\|\nabla_{\theta} L\left(\theta\right)\right\|_2^2$.
\qedhere
\end{proof}
Now we illustrate the behavior of AlterSGD using the conclusion of Theorem~\ref{theo:similarity-layer} and how it is related to our goal: As shown in Figure~\ref{fig:minimal}, both region A and B have a local minima but the local minima in region A is flatter than that in region B. Also, since the slope of region B is steeper than region A, the norm of gradient in region A is smaller than that in region B. Finally, AlterSGD tends to converge to region A, a flatter minima, where the norm of gradient is smaller.
\begin{table*}[htbp]
\centering
\small
\caption{Per class mean IoU on 15-1 setting of PASCAL VOC for the first 15 classes for different continual learning methods. }
\begin{tabular}{c|ccccccccccccccc}
\toprule
\textbf{Method} & aero & bike & bird & boat & bottle & bus & car & cat & chair & cow & table & dog & horse & mbike & person \\
\midrule
FT & 0.3 & 0.0 & 0.0 & 2.5 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\
PI & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\
EWC & 0.0 & 0.0 & 0.0 & 1.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 3.6 & 0.0 & 0.0 & 0.0 & 0.0 \\
RW & 0.0 & 0.0 & 0.0 & 0.2 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 2.2 & 0.0 & 0.0 & 0.0 & 0.0 \\
LwF & 0.0 & 0.0 & 0.0 & 0.0 & 0.6 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\
LwF-MC & 0.0 & 6.3 & 0.8 & 0.0 & 1.1 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\
ILT & 3.7 & 0.0 & 2.9 & 0.0 & 12.8 & 0.0 & 0.0 & 0.1 & 0.0 & 0.0 & \textbf{21.2} & 0.1 & 0.4 & 0.6 & 13.6 \\
\midrule
MiB & 53.8 & 38.7 & 35.5 & 25.9 & 45.3 & 14.2 & 71.5 & 71.5 & 0.3 & 22.6 & 12.6 & 62.6 & 52.3 & 48.8 & \textbf{79.8} \\
Ours & \textbf{64.6} & \textbf{39.4} & \textbf{44.5} & \textbf{39.1} & \textbf{56.4} & \textbf{57.4} & \textbf{78.5} & \textbf{74.5} & \textbf{2.4} & \textbf{51.7} & 14.2 & \textbf{66.2} & \textbf{60.2} & \textbf{62.5} & 78.6 \\
\midrule
Joint & 90.2 & 42.2 & 89.5 & 69.1 & 82.3 & 92.5 & 90.0 & 94.2 & 39.2 & 87.6 & 56.4 & 91.2 & 86.8 & 88.0 & 86.8 \\
\bottomrule
\end{tabular}%
\label{tab:1-15}%
\end{table*}%
\begin{table}[htbp]
\centering
\small
\caption{Per class mean IoU for the last 5 classes.}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{c|c|c|c|c|c|c|c|c}
\toprule
\textbf{Method} & plant & sheep & sofa & train & tv & \textbf{1-15} & \textbf{16-20} & \textbf{all} \\
\midrule
FT & 0.0 & 0.0 & 0.0 & 0.0 & 8.8 & 0.2 & 1.8 & 0.6 \\
PI & 0.0 & 0.0 & 0.0 & 0.3 & 8.6 & 0.0 & 1.8 & 0.4 \\
EWC & 0.0 & 0.0 & 7.3 & 7.0 & 7.4 & 0.3 & 4.3 & 1.3 \\
RW & 0.0 & 0.0 & 8.1 & 10.5 & 8.2 & 0.2 & 5.4 & 1.5 \\
LwF & 0.0 & 0.0 & 1.9 & 8.2 & 7.9 & 0.8 & 3.6 & 1.5 \\
LwF-MC & 0.0 & 0.0 & 2.9 & 11.9 & 11.0 & 4.5 & 7.0 & 5.2 \\
ILT & 0.0 & 0.0 & 11.6 & 8.3 & 8.5 & 3.7 & 5.7 & 4.2 \\
\midrule
MiB & \textbf{10.9} & 13.3 & \textbf{10.7} & 18.1 & 10.1 & 42.4 & 12.6 & 34.9 \\
Ours & 8.4 & \textbf{13.6} & 8.8 & \textbf{22.9} & \textbf{10.7} & \textbf{52.7} & \textbf{12.9} & \textbf{42.7} \\
\midrule
Joint & 62.3 & 88.4 & 49.5 & 85.0 & 78.0 & 79.1 & 72.6 & 77.4 \\
\bottomrule
\end{tabular}%
}
\label{tab:15-20}%
\end{table}%
\section{Experiments}
In this section, we demonstrate the effectiveness of our proposed AlterSGD as presented in Algorithm~\ref{alg:alg}. The performance is evaluated on the continual class learning~(CCL) in semantic segmentation.
To compare with popular methods on CCL, we use the baselines as suggested in \cite{michieli2019incremental}, including Elastic Weight
Consolidation~(EWC)~\cite{kirkpatrick2017overcoming}, Path Integral~(PI)~\cite{zenke2017continual}, Riemannian Walks~(RW)~\cite{chaudhry2018riemannian}, Learning without Forgetting~(LwF)~\cite{li2017learning}, LwF-MC~\cite{rebuffi2017icarl}, ILT\cite{michieli2019incremental}, and MiB~\cite{cermelli2020modeling}. To the best of our knowledge, MiB is the state-of-the-art~(SOTA) technique on CCL in semantic segmentation, and we show that AlterSGD can even outperform MiB.
The regularization-based methods~\cite{kirkpatrick2017overcoming,zenke2017continual,chaudhry2018riemannian,michieli2019incremental,cermelli2020modeling} mitigate forgetting by imposing a regularization to restrain the model parameters. At the $s^\text{th}$ session, we denote $D^{s}$ as the training set with $|D^{s}|$ samples and $\theta^s$ as the model parameters. The objective function of regularization-based methods can be formulated as,
\begin{equation}
\frac{1}{\left|D^{s}\right|} \sum_{\left(x, y^{g t}\right) \in D^{s}}\left(\ell_{s e g}^{\theta^{s}}\left(x, y^{g t}\right)+\lambda_{reg} R^{\theta^s}(x) \right),
\label{eq:ss_cl}
\end{equation}
where $\ell_{s e g}^{\theta^{s}}\left(\cdot \right)$ and $R^{\theta^s}(\cdot)$ represent the segmentation loss and
the regularization term respectively, $y^{gt}$ is the ground-truth segmentation map of the input image $x$, and
$\lambda_{reg}$ is the regularization coefficient. In our experiments, we apply AlterSGD to Eq.~(\ref{eq:ss_cl}) on the supervised loss term $\ell_{s e g}^{\theta^{s}}\left(\cdot \right)$, which utilizes the update rule as follows,
\begin{equation}
\left\{\begin{array}{l}
\theta_{t}^s=\theta_{t-1}^s-\eta \cdot \nabla_{\theta} \big[\ell_{s e g}^{\theta}\left(\theta_{t-1}^s\right) + \lambda_{reg} R^{\theta}\left(\theta_{t-1}^s\right) \big], \\
\theta_{t+1}^s=\theta_{t}^s-\eta \cdot \nabla_{\theta} [{\color{red}{-}}\ell_{s e g}^{\theta}\left(\theta_{t}^s\right) + \lambda_{reg} R^{\theta}\left(\theta_{t}^s\right) ]
\end{array}\right.
\label{eq:6}
\end{equation}
where $\ell_{s e g}^{\theta}\left(\theta_{t}^s\right) = \frac{1}{\left|D^{s}\right|} \sum_{\left(x, y^{g t}\right) \in D^{s}}\ell_{s e g}^{\theta_{t}^s}\left(x, y^{g t}\right)$, and $R^{\theta}\left(\theta_{t}^s\right) = \frac{1}{\left|D^{s}\right|} \sum_{\left(x, y^{g t}\right) \in D^{s}}R^{\theta_{t}^s}(x)$.
\paragraph{Dataset \& settings.}
We evaluate the performance on the benchmark dataset for semantic segmentation, PASCAL VOC 2012~\cite{Everingham15}. PASCAL VOC contains 20 foreground semantic classes and a background class.
For each experiment, we report the mean Intersection-over-Union~(mIoU) in percentage on the validation set. The CCL experiments are conducted on 15-1 setting where the model is trained on first 15 classes in the initial session and then trained on another 5 classes sequentially. For each session, we only provide the label of the classes we will learn in the current session and the learned classes from the previous sessions will be masked as background. Following the settings in~\cite{cermelli2020modeling}, in the initial session, the model is trained for 30 epochs with initial learning rate 0.01 to well-train the 15 classes; For the 5 continual sessions, the learning rate is changed to 0.001 and the model is still trained for 30 epochs in each session. We choose $\lambda_{reg}$ to be 100 according to~\cite{cermelli2020modeling} and choose $p=25/30$. As the old data is not allowed to be accessed during new classes training, therefore we do not consider the replay method for comparison as they may store the old data.
\begin{figure*}
\centering
\includegraphics[width=0.9\linewidth]{seg.png}
\caption{Visualization results on the 15-1 setting of PASCAL VOC test set using MiB and AlterSGD (ours).}
\label{fig:seg}
\end{figure*}
\paragraph{Experimental results.}
Table~\ref{tab:1-15} displays the result for the first 15 classes using different methods, and Table~\ref{tab:15-20} presents the result of the last 5 classes and the overall results. To fairly compare our method with MiB~\cite{cermelli2020modeling}, we use the same pretrained model obtained from the initial session, and use it to continually learn for five sessions under MiB~\cite{cermelli2020modeling} and our method respectively, reported in Table~\ref{tab:1-15} and~\ref{tab:15-20}.
In Table~\ref{tab:1-15} and Table~\ref{tab:15-20}, the regularization-based methods, like EWC~\cite{kirkpatrick2017overcoming}, PI~\cite{zenke2017continual}, RW~\cite{chaudhry2018riemannian}, LwF~\cite{li2017learning}, LwF-MC~\cite{rebuffi2017icarl}, ILT\cite{michieli2019incremental} obtain the extremely poor results. The mIoU of both the first 15 classes and the last 5 classes are small~(closed to zero in most classes), which means that these methods are not directly effective in the continual learning for semantic segmentation, though they perform well on image classification.
Compared with MiB, AlterSGD achieves comparable results on the newly learned classes. Moreover, AlterSGD significantly outperforms MiB on the first 1-15 classes. On average over the first 15 classes, we improve the mIoU of MiB from 42.4 to 52.7, which means AlterSGD is capable of mitigating forgetting effectively. To sum up, the proposed AlterSGD is able to achieve satisfactory results on both newly learned session and mitigating forgetting.
In Figure~\ref{fig:seg}, we show a qualitative analysis through visualizing the predicted segmentation map of the test images under MiB and our method respectively. Although MiB is the SOTA technique on CCL in semantic segmentation, from the visualization results we can observe that there is still a large segmentation error compared with ground-truth image, while this error can be significantly alleviated by the AlterSGD.
\begin{table}[tbp]
\centering
\small
\caption{Mean IoUs of PASCAL VOC for different regularization coefficient $\lambda_{reg}$. }
\begin{tabular}{c|cc|cc|cc}
\toprule
& \multicolumn{2}{c|}{1-15} & \multicolumn{2}{c|}{16-20} & \multicolumn{2}{c}{all} \\
\cmidrule{2-7} $\lambda_{reg}$ & MiB & Ours & MiB & Ours & MiB & Ours \\
\midrule
$10^0$ & 30.9 & \textbf{36.1} & 11.4 & \textbf{11.8} & 26.1 & \textbf{30.0}~({\color{red}{$\uparrow$ 3.9}}) \\
$10^1$ & 36.3 & \textbf{48.9} & \textbf{13.9} & 13.7 & 30.7 & \textbf{40.1}~({\color{red}{$\uparrow$ 9.4}}) \\
$10^2$ & 42.4 & \textbf{52.7} & 12.6 & \textbf{12.9 } & 34.9 & \textbf{42.7}~({\color{red}{$\uparrow$ 7.8}}) \\
$10^3$ & 16.8 & \textbf{19.5} & \textbf{5.6} & \textbf{5.6} & 13.9 & \textbf{16.0}~({\color{red}{$\uparrow$ 2.1}}) \\
\bottomrule
\end{tabular}%
\label{tab:diffreg}%
\end{table}%
\begin{table*}[t]
\centering
\caption{Mean IoUs of PASCAL VOC for different regularization coefficient combination $(\lambda_a, \lambda_b)$.}
\begin{tabular}{c|cccc|cccc|cccc}
\toprule
& \multicolumn{4}{c|}{\textbf{1-15}} & \multicolumn{4}{c|}{\textbf{16-20}} & \multicolumn{4}{c}{\textbf{all}} \\
\midrule
$\lambda_b \backslash \lambda_a$ & $10^0$ & $10^1$ & $10^2$ & $10^3$ & $10^0$ & $10^1$ & $10^2$ & $10^3$ & $10^0$ & $10^1$ & $10^2$ & $10^3$ \\
\midrule
$10^0$ & 36.1 & 45.2 & \cellcolor[rgb]{ 1, .114, .114}\textbf{55.1} & 18.4 & 11.8 & \cellcolor[rgb]{ 1, .294, .294}\textbf{14.4} & 9.5 & 3.9 & 30.0 & 37.5 & \cellcolor[rgb]{ 1, .294, .294}\textbf{43.7} & 14.8 \\
$10^1$ & 46.7 & 48.9 & \cellcolor[rgb]{ 1, .294, .294}\textbf{55.0} & 17.7 & \cellcolor[rgb]{ 1, .788, .788}\textbf{11.9} & \cellcolor[rgb]{ 1, .506, .506}\textbf{13.7} & 9.7 & 4.2 & 38.0 & 40.1 & \cellcolor[rgb]{ 1, .294, .294}\textbf{43.7} & 14.4 \\
$10^2$ & 46.2 & \cellcolor[rgb]{ 1, .506, .506}\textbf{53.2} & \cellcolor[rgb]{ 1, .655, .655}\textbf{52.7} & 17.2 & 9.6 & \cellcolor[rgb]{ 1, .114, .114}\textbf{14.8} & \cellcolor[rgb]{ 1, .655, .655}\textbf{12.9} & 4.9 & 37.1 & \cellcolor[rgb]{ 1, .506, .506}\textbf{43.6} & \cellcolor[rgb]{ 1, .655, .655}\textbf{42.7} & 14.1 \\
$10^3$ & 42.3 & \cellcolor[rgb]{ 1, .788, .788}\textbf{51.1} & 49.0 & 19.5 & 2.3 & 8.5 & 13.7 & 5.6 & 32.3 & \cellcolor[rgb]{ 1, .788, .788}\textbf{40.5} & 40.2 & 16.0 \\
\bottomrule
\end{tabular}%
\label{tab:reg combi}%
\end{table*}%
\section{Analysis}
\subsection{Varying the alternative ratio $p$}
In Algorithm~\ref{alg:alg}, we use the hyperparamter $p$ to control the ratio of the length of normal training in each session. To study the appropriate $p$ for AlterSGD, we conduct CCL on 15-1 setting of PASCAL VOC for different ratio $p$. The number of epoch is 30 for each session and we present the results of $p=5/30,10/30,\cdots,30/30$ for conducting alternative training phase after the $5, 10, \cdots, 30$ epoch respectively. When $p=30/30$, AlterSGD only contains the normal training phase.
When $p$ is small (like $p=5/30,10/30$), the mIoUs of all 20 classes are almost zero. Besides, when $p = 15/30$, though mIoUs of the first 15 classes are 14.1, the mIoUs of the last 5 classes are still almost 0 (see Figure~\ref{fig:p}).
These phenomena reveal that $p$ should not be too small. This is because when $p$ is small, on one hand, the model does not have enough epochs to train the model in the normal training phase, which is not conducive to the learning of the current class. On the other hand, according to Theorem \ref{theo:similarity-layer}, the optimizer almost always searches for a relatively flat local minima, which affects finding a small enough local minima for the current class.
Therefore, we suggest to start alternative training phase only after sufficient normal training, \textit{i.e.}, the training of the current class is close to convergence. Generally, $p$ can be selected in $[0.8,0.9]$.
\subsection{Varying the penalty coefficient $\lambda_{reg}$}
\label{sec:reg influence}
The regularization items $R^{\theta^s}(\cdot)$ in \eqref{eq:6} are usually designed to maintain the performance of the old classes. The penalty coefficient $\lambda_{reg}$ represents the intensity of the penalty, which has a great impact on the performance of regularization methods for continual learning~\cite{hsu2018re}. In this section, we study the influence of $\lambda_{reg}$ in AlterSGD. Table~\ref{tab:diffreg} displays results of $\lambda_{reg}$ of different magnitude.
Since AlterSGD is applied to MiB, the trend of performance change of AlterSGD and MiB presented in Table~\ref{tab:diffreg} is consistent, \textit{i.e.}, the large mIoU of MiB, the larger mIoU of AlterSGD. Further, under different choose of $\lambda_{reg}$, AlterSGD can consistently improve the performance. Specifically, AlterSGD significantly outperforms MiB on the first 15 classes and maintains the performance of last 5 classes.
\begin{figure}
\centering
\includegraphics[width=1\linewidth]{p.png}
\caption{Mean IoU of the first 15 classes (1-15), last 5 classes (16-20), and all 20 classes (all) for different alternative ratio $p$. We use $p$ to denote the ratio of the length of normal training.}
\label{fig:p}
\end{figure}
\subsection{Varying $\lambda_{reg}$ in the training phase}
In our original setting in Eq.~\ref{eq:6}, $\lambda_{reg}$ is the same for gradient descent and ascent. In this section, we explore the impact of using separately different $\lambda_{reg}$ for gradient ascent and gradient descent. Eq.~(\ref{eq:6}) can be rewritten as
\begin{equation}
\left\{\begin{array}{l}
\theta_{t}^s=\theta_{t-1}^s-\eta \cdot \nabla_{\theta} \big[\ell_{s e g}^{\theta}\left(\theta_{t-1}^s\right) + {\color{red}{\lambda_{a}}} R^{\theta}\left(\theta_{t-1}^s\right) \big], \\
\theta_{t+1}^s=\theta_{t}^s-\eta \cdot \nabla_{\theta} [-\ell_{s e g}^{\theta}\left(\theta_{t}^s\right) + {\color{red}{\lambda_{b}}} R^{\theta}\left(\theta_{t}^s\right) ]
\end{array}\right.
\end{equation}
Table~\ref{tab:reg combi} shows the results of different combination of $\lambda_a$ and $\lambda_b$.
The different combination of $(\lambda_{a},\lambda_b)$ for gradient ascent and gradient descent can indeed bring some performance improvements. However, compared with Table~\ref{tab:diffreg} where $\lambda_a = \lambda_b$, the improvements are marginal. It suggests that we can keep the same $\lambda_{reg}$ in AlterSGD when using gradient ascent and gradient descent alternatively.
\section{Conclusion}
In this paper, we study the class continual learning on semantic segmentation under the setting that the old data is inaccessible. In particular, we propose a simple and effective method to search for a flat local minimal region such that the forgetting problem of the learned class can be mitigated during the learning of new session. Moreover, we provide the theoretical insight to illustrate that our method can encourage the optimization to converge toward the flat minima. The extensive experiments verify the effectiveness of our method on CCL for semantic segmentation.
| {'timestamp': '2021-07-14T02:07:44', 'yymm': '2107', 'arxiv_id': '2107.05804', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05804'} | arxiv |
\section{Load Balancing in Quantum Chemistry}
\label{sec:lbr}
\input{nwchem}
\subsection{Performance Results}
As a representative bio-molecular system we chose the Ubiquitin protein to test performance, varying the basis functions used in the computation to represent molecular orbitals, and to demonstrate the capability of our implementation to handle large problem sizes.
The assignment algorithm is general enough to be applied to any scenario where such computational patterns exist, and does not depend on the molecule or the basis functions used.
\begin{comment}
Current load balancing for Self-Consistent-Field (SCF) computations in NWChemE
is based on
each processor dynamically choosing iteration indices to execute using an atomic counter; this causes load imbalance and limits the scalability of the Fock matrix build.
Hence the task assignment is recorded prior to the first iteration and then reused across all SCF iterations.
\end{comment}
We visualize the load on the processors in Fig.~\ref{fig:load-bal}.
The standard deviation for the current assignment is $10^5$, and the coefficient of variation (Std./Avg.) is $7.5 \times 10^{-2}$;
while these quantities for the submodular assignment are $436$ and $3
\times 10^{-4}$, respectively. It is clear that the latter assignment achieves much better load balance than the former.
The run time is plotted against the number of processors in Figure~
\ref{fig:scale_nwchem_6-31g}. It can be seen that the current assignment does not scale beyond $3000$ processors, where as the submodular assignment scales to $8000$ processors of Summit. The better load balance also leads to a four-fold speedup over the default assignment.
Since the Fock matrix computation takes about fifty iterations, we reduce
the total run time from $30$ minutes to $8$ minutes on Summit.
\begin{comment}
\begin{figure}[p]
\centering
\includegraphics[width=1.1\columnwidth]{fig/load-dist-ubi_sto3g_4000.pdf}
\caption{Load distribution for 4000 compute nodes for the ubiquitin Molecule. Top: Results from current scheduling, Bottom: submodular scheduling.}
\label{fig:load-bal}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=1.1\columnwidth]{fig/scaling-nwchem-ubi_sto3g.pdf}
\caption{Runtime comparison per iteration for the default and proposed scheduling with the sto3g basis functions.}
\label{fig:scale_nwchem_sto3g}
\end{figure}
\begin{figure}[p]
\centering
\includegraphics[width=1.1\columnwidth]{fig/scaling-nwchem-ubi_6-31g.pdf}
\caption{Runtime comparison per iteration for the default and proposed scheduling with the 6-31g basis functions.}
\label{fig:scale_nwchem_6-31g}
\end{figure}
\end{comment}
\section{Background and Motivation}
\section{Background}
\label{sec:bck}
\smf{
In this section we describe
submodular functions and their properties, formulate the submodular \mbox{\sc $b$-Matching}\ problem, and discuss approximation algorithms for the problem.}
\subsection{Submodular \mbox{\sc $b$-Matching}}
\begin{Definition}[Marginal gain]
Given a ground set $X$, the marginal gain of adding an element $e \in X$ to a set $A \subseteq X$ is
$$
\rho_{e}(A) = f(A \cup \{e\}) - f(A).
$$
\end{Definition}
The marginal gain may be viewed as the discrete derivative of the set $A$ for the element $e$.
Generalizing, the marginal gain of adding a subset $Q$ to another subset $A$ of the ground set $X$ is
$$
\rho_{Q}(A) = f(A \cup Q) - f(A).$$
\begin{Definition}[Submodular set function]
Given a set $X$, a real-valued function $f$ defined on the subsets of $X$ is submodular if
$$
\rho_e(A) \geq \rho_e(B)
$$
for all subsets $A \subseteq B \subseteq X$, and elements $e \in X \setminus B$.
The function $f$ is monotone if for all sets $A \subseteq B \subseteq X$, we have $f(A) \leq f(B)$; it is normalized if $f(\emptyset) = 0$.
\end{Definition}
We will assume throughout this paper that $f$ is normalized.
The concept of submodularity also extends to the addition of a set. Formally, for $Q \subseteq X\setminus B$, $f$ is submodular if $\rho_Q(A) \geq \rho_Q(B)$.
If $f$ is monotone then $\rho_e(A) \geq 0$, $\forall A \subseteq X$ and $\forall e \in X$.
\begin{proposition}
\label{prop:sum}
Let $S = \{e_1,\ldots,e_k\}$, $S_i$ be the subset of $S$ that contains the first $i$ elements of $S$, and $f$ be a normalized submodular function. Then $f(S) = \sum_{i=1}^k \rho_{e_i}(S_{i-1})$.
\end{proposition}
\begin{proposition}
\label{prop:monotone}
For sets $A \subseteq B \subseteq X$, and $e \in X$,
a monotone submodular function $f$ defined on $X$ satisfies
$ \rho_e(A) \geq \rho_e(B) $.
\end{proposition}
\begin{proof}
There are three cases to consider. i) $e \in X\setminus B$:
The inequality holds by definition of a submodular function. ii) $e \in A$: Then both sides of the inequality equal zero and the inequality holds again. iii) $e \in B\setminus A$:
Then $\rho_e(B) = 0$, and since $f$ is monotone, $\rho_e(A)$ is non-negative.
\end{proof}
Proposition \ref{prop:monotone} extends to a set, i.e., monotonicity of $f$ implies that for every $A \subseteq B \subseteq X$, and $Q \subseteq X$, $\rho_Q(A) \geq \rho_Q(B)$. Informally Proposition~\ref{prop:monotone} states that if $f$ is monotone then the diminishing marginal gain property holds for every subset of $X$.
We are interested in maximizing a monotone submodular function with \mbox{\sc $b$-Matching} \ constraints. Let $G(V,E,W)$ be a simple, undirected, and edge-weighted graph, where $V,E,W$ are the set of vertices, edges, and non-negative edge weights, respectively.
For each $e \in E$ we define a variable $x(e)$ that takes values from $\{0,1\}$. Let $M \subseteq E$ denote the set of edges for which $x(e)$ is equal to $1$, and
let $\delta(v)$ denote the set of edges incident on the vertex $v \in V$. The submodular \mbox{\sc $b$-Matching}\ problem is
\begin{align}
\label{sub_b-match}
&\max f(M) \nonumber \\
&\text {subject to} \nonumber\\
&\sum_{e \in \delta(v)}x(e) \leq b(v) \ \ \forall v \in V,\\
&x(e) \in \{0,1\}. \nonumber
\end{align}
Here $f$ is a non-negative monotone submodular set function, and $0 \leq b(v) \leq |\delta(v)|$ is the integer degree bound on $v$. Denote $\beta = \max_{v \in V} b(v)$.
We now consider the \mbox{\sc $b$-Matching} \ problem on a bipartite graph with two parts in the vertex set, say, $U$ and $V$,
where the objective function is a concave polynomial.
\begin{align}
\label{sub_b-match_bip}
f = \max &\sum_{u \in U} \left (\sum_{e \in \delta(u)} W(e)x(e) \right )^\alpha \\ \nonumber
&+ \sum_{v \in V} \left (\sum_{e \in \delta(v)} W(e)x(e)\right)^\alpha \nonumber\\
\text {subject to}& \nonumber\\
&\sum_{e \in \delta(u)}x(e) \leq b(u) \ \ \forall u \in U, \nonumber\\
&\sum_{e \in \delta(v)} x(e) \leq b(v) \ \ \forall v \in V, \nonumber\\
&x(e) \in \{0,1\}. \nonumber
\end{align}
\smf {The objective function Problem~\ref{sub_b-match_bip} becomes submodular when $\alpha \in [0,1]$}. This formulation has been used for peptide identification in tandem mass spectrometry \cite{Bai16,Bai19}, and word alignment in natural language processing~\cite{Lin11}.
\begin{comment}
\begin{Example}(Clustering)
Another example of submodular matching comes from assuming a clustering on the $V$, the set of vertices of a graph, where $V$ could be a set of resources that could be clustered. This clustering naturally arises in applications such as movie or reviewer assignments \cite{ahmadi2019algorithm,Dickerson18}.
Problem \ref{sub_b-match} now becomes
\begin{align}
Z = \max &\sum_{c \in C} \left (\sum_{v \in c} \sum_{e \in \delta(v)} W(e)x(e) \right )^\alpha \nonumber\\
\text {subject to}& \nonumber\\
&\sum_{e \in \delta(v)}x(e) \leq b(v) \ \ \forall v \in V,\\
&x(e) \in \{0,1\}. \nonumber
\end{align}
\end{Example}
\end{comment}
\subsection{Complexity of Submodular \mbox{\sc $b$-Matching}\
and Approximation}
A \emph{subset system} is a pair $(X,\mathcal{I})$, where $X$ is a finite set of elements and $\mathcal{I}$ is a collection of subsets
of $X$ with the property that if $A \in \mathcal{I}$ and $A' \subseteq A$ then $A' \in \mathcal{I}$. A \emph{matroid} is a subset system $(X,\mathcal{I})$ which satisfies the property that
$\forall A,B \in \mathcal{I}$ and $|A|<|B|$, $\exists e \in B \setminus A$ such that $A \cup \{e\} \in \mathcal{I}$. Here the sets in $\mathcal{I}$ are called
\emph{independent sets}.
A \emph{subset system} is $k$-\emph{extendible}~\cite{mestre2006greedy} if the following holds: let $A \subseteq B$, $A,B \in \mathcal{I}$ and $A \cup \{e\} \in \mathcal{I}$, where $e \notin A$, then there is a set $Y \subseteq B \setminus A$ such that $|Y| \leq k$ and $B \setminus Y \cup \{e\} \in \mathcal{I}$.
Maximizing a monotone submodular function with constraints is NP-hard in general; indeed, it is NP-hard for the simplest constraint of cardinality for many classes of submodular functions \cite{Feige98,Krause05}. A Greedy algorithm that repeatedly chooses an element with the maximum marginal gain is known to achieve
$(1-1/e)$-approximation ratio \cite{nemhauser1978analysis}, and this is tight \cite{nemhauser1978best}. The Greedy algorithm with matroid constraints is $1/2$-approximate. More generally, with $k$-matroid intersection and $k$-extendible system constraints, the approximation ratio of the Greedy algorithm becomes $1/(k+1)$ \cite{Calinescu11}.
\section{Experimental Results}
The experiments on the serial algorithm were run on an Intel Haswell
CPUs with 2.60 GHz clock speed and 512 GB memory.
The parallel algorithm was executed on an Intel Knights Landing node
with a Xeon Phi processor (68 physical cores per node) with 1.4 GHz clock speed and 96 GB DDR4 memory.
\subsection{Dataset}
We tested our algorithm on both real-world and synthetic graphs shown in Table~\ref{tab:Problems}. (All Tables and Figures from this section are at the end of the paper.) We generated two classes of RMAT graphs: (a) G500, representing graphs with skewed degree distributions from the Graph 500 benchmark \cite{graph500} and (b) SSCA, from the HPCS Scalable Synthetic Compact Applications graph analysis (SSCA\#2) benchmark using the following parameter settings: (a) $a=0.57$, $b=c= 0.19$, and $d=0.05$ for G500, and (b) $a=0.6$, and $b=c=d=0.4/3$ for SSCA.
Moreover, we considered eight problems taken from the SuiteSparse Matrix Collection \cite{FMC11} covering application areas such as medical science, structural engineering, and sensor data. We also included a large web-crawl graph(\textit{eu-2015})~\cite{BMSB} and a movie-interaction network(\textit{hollywood-2011})~\cite{BoVWFI}.
\begin{comment}
\begin{table}[]
\begin{tabular}{lrrr}
\hline
\textrm{Problems} & \textrm{Vertices} & \textrm{Edges} & \textrm{Mean} \\
& & & \textrm{Degree} \\
\hline
Fault\_639 & 638,802 & 13,987,881 & 44 \\
mouse\_gene & 45,101 & 14,461,095 & 641 \\
Serena & 1,391,349 & 31,570,176 & 45 \\
bone010 & 986,703 & 35,339,811 & 72 \\
dielFilterV3real & 1,102,824 & 44,101,598 & 80 \\
Flan\_1565 & 1,564,794 & 57,920,625 & 74 \\
kron\_g500-logn21 & 2,097,152 & 91,040,932 & 87 \\
hollywood-2011 & 2,180,759 & 114,492,816 & 105 \\
G500\_21 & 2,097,150 & 118,594,475 & 113 \\
SSA21 & 2,097,152 & 123,097,397 & 117 \\
eu-2015 & 11,264,052 & 257,659,403 & 46 \\
nlpkkt240 & 27,993,600 & 373,239,376 & 27 \\
\hline
\end{tabular}
\caption{The properties of the test graphs listed by increasing number of edges.}
\label{tab:Problems}
\end{table}
\end{comment}
\subsection{Serial Performance}
In Table~\ref{tab:ser}
we compare the \mbox{\sc Local Lazy Greedy}\ algorithm with the \mbox{\sc Lazy Greedy}\ algorithm.
Each edge weight is chosen uniformly at random from the set $[1,5]$. The submodular function employed here is the concave polynomial with $\alpha = 0.5$, and $b=5$ for each vertex. Since both \mbox{\sc Lazy Greedy}\ and \mbox{\sc Local Lazy Greedy}\ algorithms have equal approximation ratios, the objective function values computed by them are equal, but the \mbox{\sc Local Lazy Greedy}\ algorithm is faster. For the largest problem in the dataset, the \mbox{\sc Local Lazy Greedy}\ algorithm is about five times faster than the \mbox{\sc Lazy Greedy}, \Alex{and it is about three times faster in geometric mean.}
\begin{comment}
\begin{table}[]
\centering
\begin{tabular}{lrrrrr}
\hline
Problems & \multicolumn{1}{l}{Weight} & \multicolumn{2}{l}{Time (sec.)} & \multicolumn{1}{l}{Rel. Perf} \\
\hline
& \multicolumn{1}{l}{LLG} & \multicolumn{1}{l}{LG} & \multicolumn{1}{l}{LLG} & \multicolumn{1}{l}{LG/LLG} \\ \hline
Fault\_639 & 3.07E+06 & 61.05 & 16.83 & 3.63 \\
mouse\_gene & 1.90E+05 & 50.68 & 22.41 & 2.26 \\
Serena & 6.69E+06 & 155.81 & 40.27 & 3.87 \\
bone010 & 4.80E+06 & 177.37 & 44.15 & 4.02 \\
dielFilterV3real & 5.35E+06 & 221.92 & 62.22 & 3.57 \\
Flan\_1565 & 7.63E+06 & 310.31 & 72.00 & 4.31 \\
kron\_g500-logn21 & 3.69E+06 & 304.85 & 105.58 & 2.89 \\
hollywood-2011 & 8.59E+06 & 622.73 & 163.26 & 3.81 \\
G500\_21 & 3.93E+06 & 344.13 & 137.06 & 2.51 \\
SSA21 & 9.46E+06 & 588.16 & 285.79 & 2.06 \\
eu-2015 & 2.40E+07 & 1098.40 & 396.16 & 2.77 \\
nlpkkt240 & 1.31E+08 & 2456.34 & 465.30 & 5.28 \\
\hline
Geo. Mean & & & & \textbf{3.29} \\
\hline
\end{tabular}
\caption{Comparison of the objective function values and the (serial) run times for the \mbox{\sc Lazy Greedy}\ and \mbox{\sc Local Lazy Greedy}\ algorithms.}
\label{tab:ser}
\end{table}
\end{comment}
\subsection{Parallel Performance}
Performance of the parallel implementations of the \mbox{\sc Local Lazy Greedy}\ algorithm is shown
by a scalibility plot in
Figure~\ref{fig:shm2}.
Figure~\ref{fig:shm2} reports results from a machine with $68$ threads, with all the cores on a single socket. We see that all problems show good speedups, and all but three problems
show good scaling with high numbers of threads.
\begin{comment}
\begin{figure}[]
\centering
\includegraphics[width=\columnwidth]{fig/shm_llg_scaling_snyder_without_init.pdf}
\caption{Shared memory performance result for eighteen threads on Snyder. }
\label{fig:shm1}
\end{figure}
\end{comment}
\begin{comment}
\begin{figure}[]
\centering
\includegraphics[width=\columnwidth]{fig/shm_llg_scaling_snyder_with_init.pdf}
\caption{Shared memory performance result (with the initialization runtime) for eighteen threads.}
\label{fig:shm2}
\end{figure}
\begin{figure}[]
\centering
\includegraphics[width=\columnwidth]{fig/bottleneck_plot_nlpkkt240.pdf}
\caption{Time plots of initialization and main steps of the algorithm for nlpkkt240 graph}
\label{fig:shm1}
\end{figure}
\begin{figure}[p]
\centering
\includegraphics[width=\columnwidth]{fig/shm_llg_scaling_cori_without_init.pdf}
\caption{Shared memory performance result for 67 threads on Cori.}
\label{fig:shm2}
\end{figure}
\end{comment}
\begin{comment}
\subsection{Effect of $\alpha$ in Concave Polynomial}
In this experiment we vary $\alpha$ of the concave polynomial function from 0.1 to 1 with spacing of 0.1. In Figure~\ref{fig:card-weight}, we plot the $\alpha$ Vs. linear weight (the left axis) and Cardinality (the right axis) of the matching. we observe how the weight function and cardinality of the matching changes with $\alpha$. The weight function here is the linear weight of the corresponding matching. We see that, for all the problems decreasing $\alpha$ increases the cardinality of the matching. We also see that for many problems decreasing $\alpha$ also increases the linear weight. It is surprising that although we are solving for the submodular maximization, the matching output is a better alternative than the greedy matching algorithm for linear objective function.
\begin{figure*}[]
\centering
\includegraphics[width=1.4\columnwidth]{fig/quality_result.pdf}
\caption{Cardinality and weight of matching comparison for various $\alpha$}
\label{fig:card-weight}
\end{figure*}
\end{comment}
\section{Greedy and Lazy Greedy Algorithms}
A popular algorithm for maximizing submodular \mbox{\sc $b$-Matching}\ is the \mbox{\sc Greedy} \ algorithm \cite{nemhauser1978analysis}, where in each iteration, an edge with the maximum marginal gain is added to the matching. In its simplest form
the \mbox{\sc Greedy} \ algorithm could be expensive to implement, but submodularity
can be exploited to make it efficient. The efficient implementation is known as the \mbox{\sc Lazy Greedy} \ algorithm \cite{krause2008near,minoux1978accelerated}. As the maximum gain of each edge decreases monotonically in the course of the algorithm, we can employ a maximum heap to store the gains of the edges. Since the submodular function is normalized, the initial gain of each edge is just the function applied on the edge,
and at each iteration we pop an edge $e$ from the heap. If $e$ is an \emph{available edge}, i.e., $e$ can be added to the current matching without violating \mbox{\sc $b$-Matching} \ constraints, we update its marginal gain $g(e)$. We compare $g(e)$ with the next best marginal gain of an edge, available as the heap's current top.
If $g(e)$ is greater than or equal to the marginal gain of the current top, we add $e$ to the matching; otherwise we push $e$ to the heap. We iterate on the edges until the heap becomes empty. Algorithm~\ref{alg:lz} describes the \mbox{\sc Lazy Greedy} \ approach.
\begin{algorithm}
\caption{\mbox{\sc Lazy Greedy}\ Algorithm ($G(V,E,W)$)}
\label{alg:lz}
\begin{algorithmic}
\STATE $pq$ = max heap of the edges keyed by marginal gain
\WHILE{$pq$ is not empty}
\STATE Edge $e$ = pq.pop()
\STATE Update marginal gain of $e$
\IF{ $e$ is available}
\IF{ marg\_gain of $e \geq $ marg\_gain of pq.top()}
\STATE Add $e$ to the matching
\STATE update $b(.)$ values of endpoints of $e$
\ELSE
\STATE push $e$ and its updated gain into $pq$
\ENDIF
\ENDIF
\ENDWHILE
\end{algorithmic}
\end{algorithm}
The maximum cardinality of a \mbox{\sc $b$-Matching} \ is bounded by $\beta\, n$.
In every iteration of the \mbox{\sc Greedy} \ algorithm, an edge with maximum marginal gain can be chosen in $O(m)$ time. Hence the time complexity of the \mbox{\sc Greedy} \ algorithm is $O(\beta\, n \,m)$. The worst-case running time of the \mbox{\sc Lazy Greedy} \ algorithm is no better than the
\mbox{\sc Greedy} \ algorithm \cite{minoux1978accelerated}. However,
by making a reasonable assumption we can show a better time complexity bound for the \mbox{\sc Lazy Greedy} \ algorithm.
The adjacent edges of an edge $e = (u,v)$ constitute the set $N(e) = \{e^\prime: e^\prime \in \delta(u)\ \textrm{or}\ e^\prime \in \delta(v) \}$. Likewise, the adjacent vertices of a vertex $u$ are defined as the set $N(u) = \{v: (u,v) \in \delta(u)\}$.
\begin{Assumption}
\label{assump:local}
The marginal gain of an edge $e$ depends only on its adjacent edges.
\end{Assumption}
With this assumption, when an edge is added to the matching only the marginal gains of adjacent edges change.
We make this assumption only to analyze the runtime of the algorithms but not to obtain the quality of the approximation. \smf{This assumption is applicable to the objective function in Problem~\ref{sub_b-match_bip} that has been used in many applications, including the one considered in this paper of load balancing Fock matrix computations.}
\begin{Lemma}
Under Assumption~\ref{assump:local}, the time complexity of Algorithm~\ref{alg:lz} is $O(\beta\, m \, \log m)$.
\end{Lemma}
\begin{proof}
The time complexity of Algorithm~\ref{alg:lz} depends on the number of push and pop operations in the max heap. We bound how many times an edge $e$ is pushed into the heap. The edge $e$ is pushed when its updated marginal gain is less than the current top's marginal gain, and thus the number of times the marginal gain of $e$ is updated is an upper bound on the number of push operations on it. From our assumption, the update of the marginal gain of an edge $e$ can happen at most $2 \beta$
times.
Hence an edge is pushed into the priority queue O($\beta$) times, and each of these pushes can take $O(\log m)$ time. Thus the runtime for the all pushes is $O(\beta \, m \log m)$. The number of pop operations are at most the number of pushes. Thus the overall runtime of the \mbox{\sc Lazy Greedy}\ algorithm for \mbox{\sc $b$-Matching} \ is $O(\beta\, m \log m)$.
\end{proof}
\section{Introduction}
We describe new serial and parallel approximation algorithms for computing a maximum weight \mbox{\sc $b$-Matching} \ in an edge-weighted graph with a submodular objective function. This problem is NP-hard; the new algorithms have approximation ratio $1/3$, and are variants of the Greedy algorithm that rely only on local information in the graph, making them parallelizable. We apply the approximate submodular
\mbox{\sc $b$-Matching} \ algorithm to assign tasks to processors in the computation of Fock matrices in quantum chemistry on parallel computers, in order to balance the computational load on the processors and bound the number of messages that a processor sends.
A \mbox{\sc $b$-Matching} \ is a subgraph of the given input graph, where the degree of each vertex $v$ is bounded by a given natural number $b(v)$.
In linear (or modular) \mbox{\sc $b$-Matching} \ the objective function is the
sum of the weights of the edges in a \mbox{\sc $b$-Matching}, and we seek to maximize this weight. The well-known maximum edge-weighted matching problem is the $1$-matching problem. Although these problems can be solved in polynomial time, in recent years a number of approximation algorithms have been developed since the run time of exact algorithms can be impractical on massive graphs.
These algorithms are based on the paradigms of short augmentations
(paths that increase the cardinality or weight of the matching)~\cite{pettie2004simpler};
relaxations of a global ordering (by non-increasing weights) of edges to local orderings~\cite{preis1999linear}; partitioning heavy weight paths in the graph into matchings~\cite{drake2003simple}; proposal making algorithms similar to stable matching~\cite{khan2016efficient,manne2014new}, etc. Some, though not all, of these algorithms are concurrent and can be implemented on parallel computers; a recent survey is available in ~\cite{pothen2019approximation}.
\Alex{
Our algorithm employs the concept of an edge being locally dominant in its neighborhood that
was first employed by Preis \cite{preis1999linear} to design the $1/2$-approximate matching algorithm for (modular or linear) maximum weighted $1$-matching; the approximation ratio is as good as the Greedy algorithm, and Preis showed that the algorithm could be implemented in time linear in the size of the graph. Since then there has been much work in implementing variants of the locally dominant edge algorithm for $1$-matching and $b$-matching on both serial and parallel computational models (e.g., \cite{khan2016efficient,manne2014new}). More details
are included in~\cite{pothen2019approximation}.
}
In this paper we employ the local dominance technique, relaxing global orderings to local orderings, to the \mbox{\sc $b$-Matching}\ problem with submodular objective.
We exploit the fact that the \smf{ \mbox{\sc $b$-Matching}\ problem may be viewed as a 2-extendible system, which is a \Alex{relaxation} of a matroid}.
We show that any algorithm that adds locally optimal edges, with respect to the marginal gain for a submodular objective function, to the matching preserves the approximation ratio of the corresponding global Greedy algorithm. This result offers a blueprint to design many approximation algorithms, of which we develop one: \mbox{\sc Local Lazy Greedy} \ algorithm. Testing for local optimality in the submodular objective is more expensive than in the linear case due to the variability of the marginal gain. To efficiently maintain marginal gains, we borrow an idea from the lazy evaluation of the Greedy algorithm. Combining local dominance and lazy Greedy techniques, we develop a \mbox{\sc Local Lazy Greedy} \ algorithm, which is theoretically and practically faster than the Lazy Greedy algorithm. \smf{The runtime of both these algorithms are analyzed under a natural local dependence assumption on the submodular function.} Since our algorithm is parallelizable thanks to the local orderings, we show good scaling performance on a shared memory parallel environment. To the best of our knowledge, this is the first parallel implementation of a submodular \mbox{\sc $b$-Matching}\ algorithm.
Submodular \mbox{\sc $b$-Matching}\ has applications in many real-life problems.
Among these are content spread maximization in social networks~\cite{chaoji2012recommendations},
peptide identification in tandem mass spectrometry \cite{Bai16,Bai19}, word alignment in natural language processing \cite{Lin11}, and diversity maximizing assignment \cite{ahmadi2019algorithm,Dickerson18}. Here we show another application of submodular \mbox{\sc $b$-Matching} \ in load balancing the Fock matrix computation in quantum chemistry on a multiprocessor environment. Our approach enables the assignment of tasks to processors leading to scalable Fock matrix computations.
We highlight the following contributions:
\begin{itemize}
\item We show that any \mbox{\sc $b$-Matching}\ that is $\epsilon$-locally dominant w.r.t the marginal gain is $\frac{\epsilon}{2+\epsilon}$-approximate for submodular objective functions, and devise an algorithm, \mbox{\sc Local Lazy Greedy} \ to compute such a matching. Under \smf{a natural local dependence assmption on the submodular function}, this algorithm runs in $O( \beta \, m \log \Delta)$ time and is theoretically and practically faster than the popular \mbox{\sc Lazy Greedy}\ algorithm. (Here $m$ is the number of edges, $\Delta$ is the maximum degree of a vertex, and $\beta$ is the maximum value of $b(v)$ over all vertices $v$.)
\item We provide a shared memory parallel implementation of the \mbox{\sc Local Lazy Greedy}\ algorithm. Using several real-world and synthetic graphs, we show that our parallel implementation scales to more than sixty-five cores.
\item We apply submodular \mbox{\sc $b$-Matching}\ to generate an assignment of tasks to processors for building Fock matrices in the NWChemEx quantum chemistry software. The current assignment method used there does not scale beyond $3000$ processors, but our assignment shows a four-fold speedup per iteration of the Fock matrix computation, and scales to $8000$ cores of the Summit supercomputer at ORNL.
\end{itemize}
\begin{comment}
Graphs are mathematical objects that encode different relationships between entities; this model many real-life applications. Optimizing over graphs is challenging due to its discrete nature. Typically a graph optimization problem seeks to i) find a subgraph with some desired property, and ii) optimize an objective function defined over vertices or edges. The classic objective function here is the linear one. Recently optimizing a submodular function over graphs have received increasing attention. Submodular functions share similarities to both convexity and concavity. These characteristics of submodular function are shown to be useful in many applications. Submodularity is applied to placing sensors under communication constraints\cite{krause2011robust}, planning informative paths for mobile sensors\cite{singh2007efficient}, finding influential nodes in a social network \cite{kempe2005influential,mossel2007submodularity}, debunking rumors in Social networks \cite{wu2019debunking}, and so on.
\end{comment}
\begin{comment}
Maximizing a linear weight on \mbox{\sc $b$-Matching} is Since the exact algorithm is expensive and non-concurrent, several approximation approaches have been developed. One of the critical ingredients for approximate matching is local dominance. A locally dominant matching algorithm works only on an edge's local neighborhood (typically the adjacent edges) instead of the global order. Preis \cite{preis1999linear} developed the first locally dominant matching algorithm for 1-matching and showed that the approximation ratio is as good as the standard greedy algorithm. Since locally dominant algorithms are concurrent, several parallel algorithms have since developed \cite{}. The best performing parallel approximation algorithm for \mbox{\sc $b$-Matching} is the b-Suitor \cite{}, a variant of locally dominant algorithms.
\end{comment}
\section{Locally Dominant Algorithm}
We introduce the concept of $\epsilon$-local dominance,
use it to design an approximation algorithm for submodular
\mbox{\sc $b$-Matching}, and prove the correctness of the algorithm.
\subsection{$\epsilon$-Local Dominance and Approximation Ratio}
The \mbox{\sc Lazy Greedy}\ algorithm presented in Algorithm~\ref{alg:lz} guarantees a $\frac{1}{3}$ approx. ratio \cite{Calinescu11,Fisher1978} by choosing
an edge with the highest marginal gain at each iteration, and thus it is
an instance of a globally dominant algorithm. We will show that it is unnecessary to select a globally best edge because the same approximation ratio could be achieved by choosing an edge that is best in its neighborhood.
Recall that given a matching $M$, an edge $e$ is \emph{available w.r.t $M$} if both of its end-points are unsaturated in $M$.
\begin{Definition}[Locally dominant matching]
An edge $e$ is \emph{locally dominant} if it is available w.r.t a matching $M$, and the marginal gain of $e$ is greater than or equal to all available edges adjacent to it. Similarly, for an $\epsilon \in (0,1]$, an edge $e$ is \emph{$\epsilon$- locally dominant} if its marginal gain is at least $\epsilon$ times the marginal gain of any of its available adjacent edges. A matching $M$ is \emph{$\epsilon$-locally dominant} if every edge of $M$ is $\epsilon$-locally dominant when it is added to the matching.
\end{Definition}
A globally dominant algorithm is also a locally dominant one. Thus our analysis of locally dominant matchings would establish the same approximation ratio for the \mbox{\sc Greedy}\ and \mbox{\sc Lazy Greedy}\ algorithms.
\begin{comment}
\begin{figure}[t!]
\centering
\centering
\begin{tikzpicture}[on grid, thick, node distance=2 cm]
\tikzset{VertexStyle/.style = {shape = circle,
draw,
minimum width =0.6 cm,
text = black}}
\node [VertexStyle](a){$a$};
\node (b)[VertexStyle,below left=of a]{$b$};
\node (c)[VertexStyle,below right=of a]{$c$};
\node (d) [VertexStyle,above right=of c]{$d$};
\node (e) [VertexStyle,below right=of d]{$e$};
\node (f) [VertexStyle,above right=of e]{$f$};
\node (g) [VertexStyle,below right=of f]{$g$};
\draw[dashed] (a) to [edge label' = $10$] (b);
\draw[dashed] (a) to [edge label = $10$] (c);
\draw [dashed] (b) to [edge label' = $10$] (c);
\draw (c) to [edge label' = $10$] (d);
\draw (c) to [edge label' = $10$] (e);
\draw (d) to [edge label' = $10$] (e);
\draw[dashed] (e) to [edge label' = $10$] (f);
\draw[dashed] (e) to [edge label' = $10$] (g);
\draw[dashed] (f) to [edge label' = $10$] (g);
\end{tikzpicture}
\caption{The original graph.}
\label{graph:lemma}
\end{figure}
\begin{figure}[]
\centering
\resizebox{\columnwidth}{!}{%
\subfloat[Case i. $e_i \in T_{i-1}$]{
\begin{tikzpicture}
\begin{scope} [fill opacity = 1.0]
\draw (-5,5) rectangle (5,-3);
\draw[fill=green, draw = black] (-2.2,1) circle (2);
\draw[fill=blue, draw = black] (2.2,1) circle (2);
\draw[fill=red, draw = black] (2,2, 0.5) circle(0.3) node {$e_i$};
\node at (-3,4) {\LARGE\textbf{$M_{i-1}$}};
\node at (3,4) {\LARGE\textbf{$T_{i-1}$}};
\end{scope}
\end{tikzpicture}
\label{fig:case1}
}
\subfloat[Case ii. $e_i \notin T_{i-1}$]{
\begin{tikzpicture}
\begin{scope} [fill opacity = 1.0]
\draw (-5,5) rectangle (5,-3);
\draw[fill=green, draw = black] (-2.2,1) circle (2);
\draw[fill=blue, draw = black] (2.2,1) circle (2);
\draw[fill=red, draw = black] (0, 3) circle(0.3) node {$e_i$};
\draw[fill=white, draw = black] (2, 0.5) circle[x radius=0.8cm, y radius=3mm, rotate=30] node{$M_i^*$};
\node at (-3,4) {\LARGE\textbf{$M_{i-1}$}};
\node at (3,4) {\LARGE\textbf{$T_{i-1}$}};
\end{scope}
\end{tikzpicture}
\label{fig:case2}
}
}
\caption{Pictorial representation of the two cases}
\label{fig:c1_c2}
\end{figure}
\end{comment}
\begin{theorem}
\label{theorem:one-third}
Any algorithm that produces an $\epsilon$-locally dominant \mbox{\sc $b$-Matching}\ is $\frac{\epsilon}{2+\epsilon}$-approximate for a submodular objective function.
\end{theorem}
\begin{proof}
Let $M^*$ denote an optimal matching and $M$ be a matching produced by an $\epsilon$-locally dominant algorithm. Denote $|M| =k$. We order the elements of $M$ such that when the edge $e_i$ is included in $M$, it is an $\epsilon$-locally dominant edge. Let $M_i$ denote the locally dominant matching after adding $e_i$ to the set, where $M_0 = \emptyset$ and $M_k = M$.
Our goal is to show that for each edge in the locally dominant algorithm, we may charge at most two distinct elements of $M^*$. At the $i$th iteration of the algorithm when we add $e_i$ to $M_{i-1}$, we will show that there exists a distinct subset $M_i^* \subset M^*$ with $|M_i^*| \leq 2$ such that $\rho_{e_i}(M_{i-1}) \geq \epsilon\rho_{e^*_j}(M_{i-1})$, for all ${e^*_j \in M^*_i}$. We will achieve this by maintaining a new sequence of sets $\{T_j\}$, where $T_{i-1}$ is the reservoir of potential edges that $e_i$ could be charged to. The initial set of this sequence of sets is $T_0$, which holds the edges in the optimal matching $M^*$. The sequence of $T$-sets shrink in every iteration
by removing the elements charged in the previous iteration, so that
it stores only the candidate elements that could be charged in this and future iterations.
Formally, $M^*=T_0 \supseteq T_1 \supseteq \dots \supseteq T_k = \emptyset$ such that for $1\leq i \leq k$, the following two conditions hold.
\newline i) $M_i \cup T_i$ is also a \mbox{\sc $b$-Matching}\, and
\newline ii) $M_i \cap T_i = \emptyset$.
\newline
The two conditions are satisfied for $M_0$ and $T_0$ because $M_0 \cup T_0 = M^*$ and $M_0 \cap T_0 = \emptyset \cap M^* = \emptyset$.
Now we will describe the charging mechanism at each iteration. We need to construct the reservoir set $T_{i}$ from $T_{i-1}$. Recall that $e_i$ is added at the $i$th step of the $\epsilon$-locally dominant matching to obtain $M_i$. There are two cases to consider:
\newline i) If $e_i \in T_{i-1}$, the charging set $M^*_i = \{e_i\}$,
$M_i = M_{i-1} \cup \{e_i\}$, and $T_i = T_{i-1} \setminus \{e_i\}$.
\newline ii) Otherwise, let $M^*_i$ be a smallest subset of $T_{i-1}$ such that $(M_{i-1} \cup \ldots \cup \{e_i\} \cup T_{i-1}) \setminus M^*_i$ is a \mbox{\sc $b$-Matching}.\ Since a $b$-matching is a 2-extendible system, we know $|M^*_i| \leq 2$.
Then $M_i = M_{i-1} \cup \{e_i\}$; and $T_i = T_{i-1} \setminus M^*_i$.
\newline Note that the two conditions on $M_i$ and $T_i$ from the previous paragraph are satisfied after these sets are computed
from $M_{i-1}$ and $T_{i-1}$. Since $M$
is a maximal matching, we have $T_k = \emptyset$; otherwise we could have added any of the available edges in $T_k$ to $M$.
\begin{comment}
\smf{
We show an example of $M_i$, $T_i$, and $M^*_i$ in Figure~\ref{graph:lemma}. Suppose we have the square root objective function. The optimum matching are the dashed edges, i.e., $T_0 = M^* = \{\{a,b\},\{a,c\},\{b,c\},\{e,f\},\{f,g\},\{e,g\}\}$. We start with $M_0 = \emptyset$. We see that the two conditions are valid for $M_0$, and $T_0$. Initially the marginal gain of all the edges are equal. Let the locally dominant algorithm chooses $e_1 = \{c,e\}$. Now since $e_1 \notin T_0$, We have to find a smallest set whose deduction from $M_0 \cup T_0$, i.e., $M^*$ results a valid \mbox{\sc $b$-Matching}. One such set is $M_1^* = \{\{b,c\},\{e,g\}\}$. With this, $T_1$ now becomes $\{\{a,b\},\{a,c\},\{e,f\},\{f,g\}\}$, and $M_1 = \{c,e\}$. We verify that the two conditions are valid for $T_1$ and $M_1$ too.
}
\end{comment}
Now when $e_i$ is added to $M_{i-1}$, all the elements of $M^*_i$ are available. This set $M^*_i$ must be the adjacent edges of $e_i$.
Thus $\forall e^*_j \in M^*_i$, we have $\epsilon \rho_{e^*_j}(M_{i-1}) \leq \rho_{e_i}(M_{i-1})$. We can sum the inequality for each element of $e^*_j \in M_i^*$, leading to $\sum_{j}\rho_{e^*_j}(M_{i-1}) \leq \frac{2}{\epsilon}\rho_{e_i}(M_{i-1})$.
Rewriting the summation we have,
\begin{align*}
\rho_{e_i}(M_{i-1}) \geq& \frac{\epsilon}{2}\sum_{j}\rho_{e^*_j}(M_{i-1})\\
\geq& \frac{\epsilon}{2} \sum_{j} \rho_{e^*_j}(M_{i-1}\cup\{e^*_1,\dots,e^*_{j-1}\}) \\
=& \frac{\epsilon}{2} \sum_{j} (f(M_{i-1} \cup \{e^*_1,\dots,e^*_j\})\\
&- f(M_{i-1} \cup \{e^*_1,\dots,e^*_{j-1}\}))\\
=& \frac{\epsilon}{2} (f(M_{i-1} \cup \{e^*_1,\dots,e^*_{|M^*_i|}\}) - f(M_{i-1})) \\
=& \frac{\epsilon}{2} (f(M_{i-1} \cup M^*_i) - f(M_{i-1})) \\
\geq& \frac{\epsilon}{2} (f(M \cup M^*_i) - f(M)).
\end{align*}
\smf{ In line 2, each of the summands is a superset of $M_{i-1}$, and the inequality follows from submodularity of $f$ (Proposition~\ref{prop:monotone}).}
Line 3 expresses the marginal gains in terms of the function $f$. The fourth equality is due to telescoping of the sums, the fifth equality replaces the set $M^*_i$ for its elements, and the last inequality follows by monotonicity of $f$ (from Proposition~\ref{prop:monotone}).
We now sum over all the elements in $M$ as follows.
\begin{align*}
\sum_{i} \rho_{e_i}(M_{i-1}) \geq & \frac{\epsilon}{2} \sum_{i} (f(M \cup M^*_i) - f(M)),\\
f(M) \geq& \frac{\epsilon}{2} \sum_{i} (f(M \cup \{M^*_1 \cup \dots M^*_i\}) \\&- f(M \cup \{M^*_1, \dots, M^*_{i-1}\}))\\
=& \frac{\epsilon}{2} (f(M \cup M^*) - f(M))\\
\geq& \frac{\epsilon}{2} (f(M^*) - f(M)). \\
f(M) \geq& \frac{\epsilon}{2+\epsilon} f(M^*).
\end{align*}
The left side of the second line of the above equations is due to Proposition~\ref{prop:sum}, while the right side comes from Proposition~\ref{prop:monotone}. The next equality telescopes the sum,
and the fourth inequality is due to monotonicity of $f$. Finally the last line is a restatement of the inequality above it.
\end{proof}
\begin{corollary}
\label{cor:semi-match}
Any algorithm that produces an $\epsilon$-locally dominant semi-matching is $\frac{\epsilon}{1+\epsilon}$-approximate for a submodular objective function.
\end{corollary}
\begin{proof}
A semi-matching (there are matching constraints on only one vertex part in a bipartite graph) forms a matroid, which is a 1-extendible system \cite{mestre2006greedy}. So by definition of 1-extendible system, $|M^*_i| \leq 1$. We can substitute this value in appropriate places in the proof of Lemma~\ref{theorem:one-third} and get the desired ratio.
\end{proof}
\subsection{Local Lazy Greedy Algorithm}
Now we design a locally dominant edge algorithm to compute a \mbox{\sc $b$-Matching}, outlining our approach in Algorithm~\ref{alg:llg}.
We say that a vertex $v$ is \emph{available} if there is an available edge incident on it, i.e., adding the edge to the matching does not violate the $b(v)$ constraint.
For each vertex $v \in V$, we maintain a priority queue that stores the edges incident on $v$. The key value of the queue is the marginal gain of the adjacent edges.
At each iteration of the algorithm we alternate between two operations: \textit{update} and \textit{matching}. In the \textit{update} step, we update a best incident edge of an unmatched vertex $v$.
Similar to \mbox{\sc Lazy Greedy}, we can make use of the monotonicity of the marginal gains, and the lazy evaluation process is shown in Algorithm~\ref{alg:lz-eval}. After this step, we can consider a best incident edge for each vertex as a candidate to be matched. We also maintain an array (say \textit{pointer}) of size $|V|$ that holds the best vertex found in the \textit{update} step. The next step is the actual \textit{matching}. We scan over all the available vertices $v \in V$ and check whether $pointer(v)$ also points to $v$ (i.e., $pointer(pointer(v)) = v$). If this condition is true, we have identified a locally dominant edge, and we add it to the matching. We continue the two steps until no available edge remains.
\begin{algorithm}
\caption{Lazy Evaluation (Max Heap pq)}
\label{alg:lz-eval}
\begin{algorithmic}[1]
\WHILE{$pq$ is not empty}
\STATE Edge $e$ = pq.pop()
\STATE Update marginal gain of $e$
\IF{ $e$ is available}
\IF{ marg\_gain of $e$ $ \geq $ marg\_gain of pq.top()}
\STATE \textbf{break}
\ELSE
\STATE push $e$ and its updated gain into $pq$
\ENDIF
\ENDIF
\ENDWHILE
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{Local Lazy Greedy Algorithm}
\label{alg:llg}
\begin{algorithmic}[1]
\LineComment{Initialization}
\FOR{$v \in V$}
\STATE pq(v) $\coloneqq$ max-heap of the incident edges keyed by marginal gain
\STATE pointer(v) = pq(v).top
\ENDFOR
\STATEx
\LineComment{Main Loop}
\WHILE{$\exists$ an edge with both its endpoints available}
\LineComment{Updating}
\FOR{$v \in V$ such that $u$ is available}
\STATE Update pq(v) using Lazy Evaluation (pq(v))
\STATE pointer(v) = pq(v).top
\ENDFOR
\STATEx
\LineComment{Matching }
\FOR{ $u \in V$ such that $u$ is available}
\STATE v = pointer(u)
\IF{$v$ is available and pointer(v) == u}
\STATE M = M $\cup$ $\{u,v\}$
\ENDIF
\ENDFOR
\ENDWHILE
\end{algorithmic}
\end{algorithm}
\Alex{We omit the short proofs of the following two results.}
\begin{Lemma}
The \mbox{\sc Local Lazy Greedy}\
algorithm is locally dominant.
\end{Lemma}
\begin{corollary}
\Alex{For the \mbox{\sc $b$-Matching} \ problem with submodular objective, the \mbox{\sc Local Lazy Greedy} \ algorithm is $1/3$-approximate. }
\end{corollary}
\begin{comment}
\begin{Lemma}
Under Assumption~\ref{assump:local}, the average time complexity of Algorithm~\ref{alg:llg} is $O(\beta\, m \log \Delta)$.
\end{Lemma}
\begin{proof}
As for the Lazy Greedy algorithm, the number of total push operations is $O(m \beta \,\log{\Delta})$ (the argument of the logarithm is $\Delta$ instead of $m$ because the maximum size of a priority queue is $\Delta$). We maintain two sets, say \textit{PotentialU} and \textit{PotentialM}, of vertices that hold the candidate vertices for iteration in the \emph{update} and \emph{matching} step, respectively. Initially all the vertices are in \textit{PotentialU}, and \textit{PotentialM} is empty. The two sets are set to empty after their corresponding step. In the \textit{update} phase, we insert the vertices for which the marginal gain changed into \textit{PotentialM}.
In the \emph{matching} step, we iterate only over the vertices in \emph{PotentialM} set. When an edge $(u,v)$ is matched in the \textit{matching} step, we insert $u$, $v$ if they are unsaturated and all their available neighboring vertices into the \textit{PotentialU} set. This is the set on which in the next iteration, \textit{update} would iterate. Since a vertex can be put at most $\beta$ times into the set, the overall size of \textit{PotentialU} set is $O(n \beta)$. The \textit{PotentialM} set is always a subset of \textit{PotentialU}, and hence it is also bounded by $O(n\beta)$. Next we will show that maintaining such sets is not expensive. A vertex can be chosen to be inserted into \textit{PotentialU} at most $\beta$ times, and each time it may have to scan over its neighbors in $O({\rm degree}(v))$ time. Hence the total number of insertions to this set is $O(\beta\, m)$. Note that the average time complexity of insertion in an unordered set is constant. Combining all these we get the average time complexity of $O( \beta \, m \log \Delta)$.
\end{proof}
\end{comment}
\begin{Lemma}
Under Assumption~\ref{assump:local}, the time complexity of Algorithm~\ref{alg:llg} is $O(\beta\, m \log \Delta)$.
\end{Lemma}
\begin{proof}
As for the Lazy Greedy algorithm, the number of total push operations is $O(m \beta \,\log{\Delta})$ (the argument of the logarithm is $\Delta$ instead of $m$ because the maximum size of a priority queue is $\Delta$). We maintain two \smf{arrays}, say \textit{PotentialU} and \textit{PotentialM}, of vertices that hold the candidate vertices for iteration in the \emph{update} and \emph{matching} step, respectively. Initially all the vertices are in \emph{PotentialU} and \emph{PotentialM} is empty. The two arays are set to empty after their corresponding step. In the \emph{update} phase, we insert the vertices for which the marginal gain changed into \emph{PotentialM}.
In the \emph{matching} step, we iterate only over the vertices in \emph{PotentialM} array. When an edge $(u,v)$ is matched in the \emph{matching} step, we insert $u$, $v$ if they are unsaturated and all their available neighboring vertices into the \emph{PotentialU}. This is the \smf{array} on which in the next iteration, \emph{update} would iterate. Since a vertex $u$ can be inserted at most $b(u) + \sum_{v \in N(u)}b(v)$ times into the array, the overall size of \emph{PotentialU} array during the execution of the algorithm is $O(m \beta)$. The \emph{PotentialM} is always a subset of \emph{PotentialU}. So it is also bounded by $O(m \beta)$
Combining all these we get, an $O( \beta \, m \log \Delta)$
time complexity.
\end{proof}
\subsection{Parallel Implementaion of Local Lazy Greedy}
\begin{algorithm}[t]
\caption{Parallel Local Lazy Greedy}
\label{alg:pllg}
\begin{algorithmic}[1]
\LineComment{Initialization}
\FOR{$v \in V$ \textbf{in parallel}}
\STATE pq(v) $\coloneqq$ max-heap of the incident edges keyed by marginal gain
\STATE pointer(v) = pq(v).top
\ENDFOR
\STATEx
\LineComment{Main Loop}
\WHILE{$\exists$ an edge
where both endpoints
are available}
\LineComment{Updating}
\FOR{$v \in V$ such that $v$ is available \textbf{in parallel} }
\STATE Update pq(v) according to Lazy Evaluation (pq(v))
\STATE pointer(v) = pq(v).top
\ENDFOR
\STATEx
\LineComment{Matching }
\FOR{ $u \in V$ such that $u$ is available \textbf{in parallel} }
\STATE v = pointer(u)
\IF{$v$ is available and $u < v$ and pointer(v) == u }
\STATE Mark $(u,v)$ as a matching edge
\ENDIF
\ENDFOR
\ENDWHILE
\end{algorithmic}
\end{algorithm}
Both the standard \mbox{\sc Greedy}\ and \mbox{\sc Lazy Greedy}\ algorithm offer little to no concurrency. The \mbox{\sc Greedy}\ algorithm requires global ordering of the gains after each iteration, and the \mbox{\sc Lazy Greedy}\ has to maintain a global priority queue. On the other hand, the \mbox{\sc Local Lazy Greedy}\ algorithm is concurrent. Here local dominance is sufficient to maintain the desired approximation ratio. We present a shared memory parallel algorithm based on the serial \mbox{\sc Local Lazy Greedy}\ in Algorithm~\ref{alg:pllg}.
\smf{One key difference between the parallel and the serial algorithms is on maintaining the \emph{potentialU} and \emph{potentialM} arrays. One option is for each of the processors to maintain individual \emph{potentialU} and \emph{potentialM} arrays and concatenate them after the corresponding steps. These arrays may contain duplicate vertices, but they can be handled as follows. We maintain a bit array of size of $n$ initialized to $0$ in each position. This bit array would be reset to $0$ at every iteration. We only process vertices that have $0$ in its corresponding position in the array. To make sure that only one processor is working on the vertex, we use an atomic {\tt test-and-set} instruction to set the corresponding bit of the array. Thus the total work in the parallel algorithm is the same as of that the serial one i.e., $O( \beta \, m \log \Delta)$. Since the fragment inside the while loop is embarrassingly parallel, the parallel runtime depends on the number of iterations. This number depends on the weights and the edges in the graph, but in the worst case, could be $O(\beta n)$. We leave it for future work to bound the number of iterations under different weight distributions (say random) and different graph structures. }
\section{Introduction}
Let $f$ be a set function defined on the powerset of a set $V$, $f:2^V\xrightarrow{}R $.
Then $f$ is submodular if for every $A \subseteq B \subseteq V$ and $e \in V\setminus B$, we have $f(A \cup e)-f(A) \geq f(B \cup e) - f(B)$.
Informally submodularity ensures diminishing marginal gain.
Moreover, $f$ is monotone if for every $A \subseteq B \subseteq V$, $f(A) \leq f(B)$. Submodular functions naturally arise in several applications such as coverage and weighed coverage functions, facility location, entropy and mutual information \cite{Krause14}.
Maximizing a monotone submodular function with constraints is NP-hard in general. In fact it is NP-hard even for the simplest constraint, i.e., cardinality, for many classes of submodular functions \cite{Feige98,Krause05}. A greedy algorithm that chooses repeatedly a set with maximum marginal gain is known to achieve $(1-1/e)$ approximation ratio \cite{Fisher1978}. This approximation ratio is known to be tight \cite{Buchbinder14}. A survey on submodular function maximization under different constraints can be found in \cite{Krause14}.
We are interested in optimizing submodular functions on a graph. A number of natural class of constraints arise in that case. We focus in particular on \mbox{\sc $b$-Matching} \ and \mbox{\sc $b$-Edge Cover} \ constraints. Recall that $G(V,E)$ denotes an undirected graph where $V$ and $E$ are the set of vertices and edges, respectively, and let $b \in Z^{|V|}$ denote positive integer capacities for the degree of each vertex.
In the following we will denote $\beta = \text{max}_{v \in V}b(v)$.
\subsection{Recent Progress}
A subset system is a pair $(U,I)$, where $U$ is a finite set of elements and $I$ is a collection of subsets (commonly called independent sets) of $U$ with the property that if $A \in I$ and $A' \subseteq A$ then $A' \in I$. A matroid is a subset system $(U,I)$ which satisfies the property that
$\forall A,B \in I$ and $|A|<|B|$, $\exists e \in B \setminus A$ such that $A+e \in I$. A subset system $(U,I)$ is a $k$-independence system \cite{Calinescu11} for an integer $k\geq 1$ if for every $A \in I$ and $e \in U$, there exists a set $B \subseteq A$ such that $|B| \leq k$ and $A\setminus B + e \in I$. It is also known as a $k$-system~\cite{Feldman11}. The Greedy algorithm for maximizing a monotone submodular function with matroid constraints achieves 1/2-approximation ratio. More generally with k-matroid intersection and $k-$independence system constraints, the approximation ratio is $1/(k+1)$ \cite{Calinescu11}.
Max $k$-cover can be reduced to submodular \mbox{\sc $b$-Matching}\ \cite{Fuji16}. \cite{Feige98} showed that there is no polynomial time algorithm for approximating the max $k$-cover within a factor of $(1-1/e+\epsilon)$ for any $\epsilon > 0$. Thus we obtain an immediate bound on the approximation ratio of submodular \mbox{\sc $b$-Matching}.
Several approximation algorithms have been proposed for maximizing monotone submodular functions with \mbox{\sc $b$-Matching}\ constraints. If the graph is bipartite, then the \mbox{\sc $b$-Matching} \ constraint can be represented as the intersection of two partition matroids, and the Greedy algorithm provides $1/3$-approximation ratio. \mbox{\sc $b$-Matchings} \ in non-bipartite graphs are not thus representable as the intersection of partition matroids \cite{Fekete2003}. Nevertheless as \mbox{\sc $b$-Matching} \ forms a $k-$system, the Greedy algorithm yields a $1/3$-approximation ratio for non-bipartite graphs. \cite{Feldman11} showed that \mbox{\sc $b$-Matching} \ is also a $k$-exchange system, and they provide a $1/(2+\frac{1}{p}+\epsilon)$-approximation algorithm based on local search, with runtime $O(\beta^{p+1} (\Delta-1)^p nm\epsilon^{-1})$.
(Here $p$ is a parameter to be chosen.)
Recently \cite{Fuji16} developed two algorithms for the problem. One of them has the approximation ratio of $1/4$, but it is faster than the classical Greedy algorithm. The other algorithm is a faster variant of the local search algorithm from \cite{Feldman11}.
Minimizing a submodular function is solvable in strongly polynomial time \cite{Iwata01}, but the addition of constraints make the problem harder \cite{Svitkina11}. A particular type of constraint that has attracted interest is the covering constraint \cite{Wolsey82,Koufogiannakis13,Iwata09}. Let $U$ be a finite set of $n$ elements and $ S= \{S_1,\dots ,S_n\}$ be a collection of subsets of $U$. Let $\eta$ be the maximum frequency of an element in the subsets of $S$. A set cover is the problem of selecting as few subsets as possible from $S$ such that their union covers $U$. If there are non-negative costs associated with the elements of $S$, the problem is to find a cover with minimum total cost. The set cover problem with linear cost function is NP-hard, and in fact set cover can not be approximated efficiently beyond $o(\log n)$ \cite{Feige98}.
In the classic covering problems, each element needs to be covered by at least one of the subsets. We can generalize the covering requirement to a positive integer value to obtain the set multicover problem.
We are interested in covering problems where the cost function is submodular. For the general set cover problem, there is an $\eta$-approximation algorithm\cite{Iwata09}. This amounts to $2$-approximation algorithm for vertex cover and $\Delta$-approximation algorithm for edge cover.
There is also a greedy $\Delta$-approximation algorithm for covering problems with submodular cost \cite{Koufogiannakis13}.
There are several applications for submodular \mbox{\sc $b$-Matching} \ and \mbox{\sc $b$-Edge Cover} \ : content spread maximization \cite{Chaoji12}, peptide identification in tandem mass spectrometry \cite{Bai16,Bai19}, word alignment \cite{Lin11}, and diversity maximizing assignment \cite{Ahmadi19,Dickerson18}.
\subsection{Load Balancing Fock Matrix Computation}
\label{sec:Fock}
We show an application of submodular \mbox{\sc $b$-Matching}\ in Self-Consistent Field (SCF) computations in computational chemistry~\cite{scf}.
\subsection{Background}
The SCF calculation is iterative, and we focus on the computationally dominant kernel that is executed in every SCF iteration: the two-electron contribution to the Fock matrix build. The algorithm
executes forty to fifty iterations to converge to a predefined tolerance.
The two-electron contribution involves a $\Theta(n^4)$ calculation over $\Theta(n^2)$ data elements, where $n$ is the number of {basis functions}. The computation is organized as a set of $n^4$ tasks, where only a small percentage ($< 1\%$) of tasks contribute to the Fock matrix build. Before starting the main SCF iterative loop, the work required for the Fock matrix build in each iteration is computed from the number of nonzeros in the matrix, which is proportional to the work across all SCF iterations.
This step is inexpensive since it only captures the execution pattern of the Fock matrix build algorithm without performing other computations. The task assignment is recorded prior to the first iteration and then reused across all SCF iterations.
The Fock matrix build itself is also iterative (written as a $\Theta(n^4)$ loop), where each iteration represents a task that computes some elements of the Fock matrix. For a given iteration, a task is only executed upon satisfying some domain constraints based on the values in two other pre-computed matrices, the Schwarz and density matrices.
The default load balancing used in NWChemEx~\cite{Apre+:NWChemEx} is to assign iteration indices of the outermost two loops in the Fock matrix build across MPI ranks using an atomic counter based work sharing approach. All MPI ranks atomically increment a global shared counter to identify the loop iterations to execute. This approach limits scalability of the Fock build since the work and number of tasks across MPI ranks are not guaranteed to be balanced.
\begin{comment}
\begin{figure}
\centering
\includegraphics[scale=0.4]{fig/load-balance-all.pdf}
\caption{ Assigning tasks to processors to balance the computational work using a submodular $b$-matching.}
\label{fig:lb}
\end{figure}
\end{comment}
The task assignment problem here naturally corresponds to a \mbox{\sc $b$-Matching}\ problem. Let $G(U,V,W)$ be a complete bipartite graph, where $U,V,W$ represent the sets of blocks of the Fock matrix, the set of machines, and the load of the (block,machine) pairs, respectively. The $b$ value for each vertex in $U$ is set to $1$; \Alex{for each vertex in $V$, it is set to $\lceil|U|/|V|\rceil$ in order to balance the number of MPI messages that each processor needs to send.} We will show that a submodular objective with these \mbox{\sc $b$-Matching}\ constraints implicitly encodes the desired load balance. To motivate this, we use the square root function ($\alpha = 0.5$) as our objective function in Eqn.~(\ref{sub_b-match_bip}).
We consider the execution of the Greedy algorithm for Submodular \mbox{\sc $b$-Matching}\ \Alex{on a small example}
consisting of four tasks with work loads of $300$, $200$, $100$ and $50$
on two machines $M1$ and $M2$. The \mbox{\sc $b$-Matching}\ constraint requires each processor to be assigned two tasks.
At the first iteration, we assign the first block (load $300$) to machine $M1$. Note that assigning the second block to machine $M1$ would have the same marginal gain as assigning it to $M2$ if the objective function were linear. But since the square root objective function is submodular, the marginal gain of assigning the second block to the second machine is higher than assigning it to the first machine. So we will assign the second block (load $200$) to machine $M2$.
Then the third block of work $100$ would be assigned to $M2$ rather
than $M1$, due to the higher marginal gain, and finally the last block with load $50$ would be assigned to $M1$ due to the \mbox{\sc $b$-Matching}\ constraint.
We see that modeling the objective by a submodular function implicitly provides the desired load balance, and the experimental results
will confirm this.
\section{Related Work}
\smf{Here we situate our contributions to submodular \mbox{\sc $b$-Matching}\
in the broader context of earlier work in submodular maximization. A reader who is eager to get to the algorithms and results in this paper could skip this section on a first reading. }
\begin{comment}
A \emph{subset system} is a pair $(U,\mathcal{I})$, where $U$ is a finite set of elements and $\mathcal{I}$ is a collection of subsets
of $U$ with the property that if $A \in \mathcal{I}$ and $A' \subseteq A$ then $A' \in \mathcal{I}$. A \emph{matroid} is a subset system $(U,\mathcal{I})$ which satisfies the property that
$\forall A,B \in \mathcal{I}$ and $|A|<|B|$, $\exists e \in B \setminus A$ such that $A \cup e \in \mathcal{I}$. Here the sets in $\mathcal{I}$ are called
\emph{independent sets}.
A subset system $(U,\mathcal{I})$ is a $k$-\emph{independence system} \cite{Calinescu11} (or $k$-\emph{system} \cite{Feldman11}) for an integer $k\geq 1$ if for every $A \in \mathcal{I}$ and $e \in U$, there exists a set $B \subseteq A$ such that $|B| \leq k$ and $(A\setminus B) \cup \{ e\} \in \mathcal{I}$. A \emph{subset system} is $k$-\emph{extendible} if the following holds: let $A \subseteq B$, $A,B \in \mathcal{I}$ and $A \cup \{e\} \in \mathcal{I}$, where $e \notin A$, then there is a set $Y \subseteq B \setminus A$ such that $|Y| \leq k$ and $B \setminus Y \cup \{e\} \in \mathcal{I}$.
Maximizing a monotone submodular function with constraints is NP-hard in general; indeed, it is NP-hard for the simplest constraint of cardinality for many classes of submodular functions \cite{Feige98,Krause05}. A Greedy algorithm that repeatedly chooses a set with a maximum marginal gain is known to achieve
$(1-1/e)$-approximation ratio \cite{Fisher1978}, and this is tight \cite{Buchbinder14}. The Greedy algorithm with matroid constraints achieves $1/2$-approximation ratio. More generally, with k-matroid intersection, $k-$independence system or $k$-extendible system constraints, the approximation ratio of the greedy algorithm becomes $1/(k+1)$ \cite{Calinescu11}.
\end{comment}
The maximum $k$-cover problem can be reduced to submodular \mbox{\sc $b$-Matching}\ \cite{Fuji16}. Feige \cite{Feige98} showed that there is no polynomial time algorithm for approximating the max $k$-cover within a factor of $(1-1/e+\epsilon)$ for any $\epsilon > 0$. Thus we obtain an immediate bound on the approximation ratio of submodular \mbox{\sc $b$-Matching}.
New approximation techniques have been developed to expedite the greedy algorithm, especially for cardinality and matroid constraints.
\begin{comment}
The continuous greedy approach for cardinality and matroid constraints has been introduced in \cite{Calinescu11}. In \cite{badanidiyuru2014fast}, the authors improve the continuous greedy technique to develop faster algorithms for cardinality and intersection of $p$-system and $l$-knapsack constraints. Mirzasoleiman et al. developed a randomized greedy algorithm that is faster than lazy greedy and achieves $(1-1/e)$ approximation in expectation \cite{mirzasoleiman2015lazier}. They also developed a distributed two-round algorithm for the cardinality constraints in \cite{mirzasoleiman2016distributed}. Under certain conditions, this algorithm achieves an approximation ratio as good as the centralized greedy algorithm. But for more general constraints such as matroid or $k$-system, the approximation ratio depends on the number of distributed nodes and the maximum independent set size. \cite{buchbinder2019deterministic} gave the first deterministic $1/2+\epsilon$ algorithm for submodular maximization with matroid constraints. The running time of their algorithm is $O(np^2 + pT)$, where $n,p$ are the size of the ground set and rank of the matroids, respectively, and $T$ is the time required to compute a maximum weight perfect matching in a complete bipartite graph with $2p$ vertices.
\end{comment}
Surveys on submodular function maximization under different constraints may be found in \cite{buchbinder2018survey,Krause14,tohidi2020submodularity}.
Several approximation algorithms have been proposed for maximizing monotone submodular functions with \mbox{\sc $b$-Matching}\ constraints. If the graph is bipartite, then the \mbox{\sc $b$-Matching} \ constraint can be represented as the intersection of two partition matroids, and the Greedy algorithm provides a $1/3$-approximation ratio.
But \mbox{\sc $b$-Matching} \ forms a $2$-extendible system and the Greedy algorithm yields a $1/3$-approximation ratio for non-bipartite graphs. Feldman \emph{et al.} \cite{Feldman11} showed that \mbox{\sc $b$-Matching} \ is also a \Alex{$2$-exchange system}, and they provide a $1/(2+\frac{1}{p}+\epsilon)$-approximation algorithm based on local search, with time complexity $O(\beta^{p+1} (\Delta-1)^p nm\epsilon^{-1})$.
(Here $p$ is a parameter to be chosen.) \Alex{The continuous greedy and randomized LP rounding algorithms} have been used in \cite{chaoji2012recommendations} to compute a submodular \mbox{\sc $b$-Matching} \ algorithm that produces a $(\frac{1}{3+2\epsilon})(1-\frac{1}{e})$ approximate solution in $O(m^5)$ time.
Recently Fuji \cite{Fuji16} developed two algorithms for the problem. One of these, Find Walk, is a modified version of the Path Growing approximation algorithm \cite{drake2003simple} proposed for 1-matching with linear weights.
Mestre \cite{mestre2006greedy} extended the idea to \mbox{\sc $b$-Matching}. In \cite{Fuji16}, Fuji extended this further to the submodular objectives. They showed an approximation ratio of $1/4$ with time complexity
$O(\beta \, m)$.
\smf{ The second algorithm uses randomized local search, has an approximation ratio of $1/(2+\frac{1}{p}) - \epsilon$, and runs in $O(\beta^{p+1} (\Delta-1)^{p-1} m \log \frac{1}{\epsilon}$ time in expectation.} Here a vertex is chosen uniformly at random in each iteration, and the algorithm searches for a certain length alternating path with increasing weights. This algorithm is similar to the $2/3-\epsilon$ approximation algorithm for linear weighted matching in \cite{pettie2004simpler} and the corresponding \mbox{\sc $b$-Matching}\ variant in \cite{mestre2006greedy}. We list several approximation algorithms for submodular \mbox{\sc $b$-Matching}\ in Table~\ref{tab:algorithms-summary}.
\begin{table}[b]
\resizebox{\columnwidth}{!}{
\centering
\begin{tabular}{|l l l c|}
\hline
Alg. & Appx. Ratio & Time & Conc.? \\
\hline
Greedy\cite{nemhauser1978analysis} & $1/3$ & $O(\beta nm)$ & N \\
\hline
Lazy Greedy \cite{minoux1978accelerated} & & $O(\beta m \log m)$ & N \\
& $1/3$ & assuming~\ref{assump:local} & \\
\hline
Local Search \cite{Feldman11} & $1/(2+\frac{1}{p}+\epsilon)$ & $O(\beta^{p+1} (\Delta-1)^p nm\epsilon^{-1})$ & N\\
\hline
Cont. Grdy+ & & & \\
Rand. Round\cite{chaoji2012recommendations} & $(\frac{1}{3+2\epsilon})(1-\frac{1}{e})$ & $O(m^5)$ & N\\[1ex]
\hline
Path Growing \cite{Fuji16} & 1/4 & $O(\beta m)$ & N \\[1ex]
\hline
Rand LS \cite{Fuji16} & $1/3-\epsilon$ & $O(\beta^2 m \log 1/\epsilon)$ & N\\
& & in expectation & \\
\hline
Local Lazy & & $O( \beta m \log \Delta)$ &Y \\
Greedy & $\frac{\epsilon}{2+\epsilon}$ & assuming~\ref{assump:local} & \\[2ex]
\hline
\end{tabular}
}
\caption{Algorithms for the submodular \mbox{\sc $b$-Matching}\ problem. The last column lists if the algorithm is concurrent or not.}
\label{tab:algorithms-summary}
\end{table}
Now we consider several related problems that do not have the \mbox{\sc $b$-Matching} \ constraint.
Assigning tasks to machines is a classic scheduling problem. The most studied objective here is minimizing the makespan, i.e., the maximum total time used by any machine.
The problem of makespan minimization can be generalized to a General Assignment Problem(GAP), where there is a fixed processing time and a cost associated with each task and machine pair. The goal is to assign the tasks into available machines with the assignment cost bounded by a constant $C$ and makespan at most $T$. Shmoys and Tardos \cite{shmoys1993approximation} extended the LP relaxation and rounding approach \cite{lenstra1990approximation} to GAP. The makespan objective can be a surrogate to the load balancing that we are seeking, but the GAP problem does not encode the $b$-matching constraints on the machines. Computationally solving a GAP problem entails computing an LP relaxation that is expensive for large problems.
Another possible approach is to model our load balancing problem as a multiple knapsack problem (MKP). In an MKP, we are given a set of $n$ items and $m$ knapsacks such that each item $i$ has a weight (profit) $w_i$ and a size $s_i$, and each knapsack $j$ has a capacity $c_j$. The goal here is to find a subset of items of maximum weight such that they have a feasible packing in the knapsacks. MKP is a special case of GAP \cite{chekuri2005polynomial}, and
like the GAP, we cannot model the $b(v)$ constraints by MKP.
Our formulation of load balancing has the most similarity with the Submodular Welfare Maximization (SWM) problem \cite{lehmann2006combinatorial}. In the SWM problem, the input consists of a set of $n$ items to be assigned to one of $m$ agents. Each agent $j$ has a submodular function
$v_j$, where $v_j(S)$ denotes the utility obtained by this agent if the set of items $S$ is allocated to her. The goal is to partition the $n$ items into $m$ disjoint subsets $S_1,\ldots,S_m$ to maximize the total welfare, defined as $\sum_{j=1}^m v_j(S_j)$. The greedy algorithm achieves $1/2$- approximation ratio \cite{lehmann2006combinatorial}. Vondrak's $(1-1/e)$-approximation \cite{vondrak2008optimal} is the best known algorithm for this problem. This algorithm uses continuous greedy relaxation of the submodular function and randomized rounding. Although we have modeled our objective as the sum of submodular functions, unlike the SWM, we have the same submodular function for each machine; our approach could be viewed as Submodular Welfare Maximization with $b$-matching constraints. In the original SWM problem, there are no constraints on the partition size, but in our problem we are required to set an upper bound on the individual partition sizes.
| {'timestamp': '2021-07-14T02:07:01', 'yymm': '2107', 'arxiv_id': '2107.05793', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05793'} | arxiv |
\subsection{References}
\nocitesec{*}
\bibliographystylesec{ACM-Reference-Format}
\bibliographysec{secondaryStudiesNotIncluded}
\section{Introduction}
The term ``Grey Literature'' (GL) has many definitions. The most widely accepted is the Luxembourg one~\cite{Garousi:2019:IST}, approved at the Third International Conference on Grey Literature in 1997: \textit{``[GL] is produced on all levels of government, academics, business and industry in print and electronic formats, but which is not controlled by commercial publishers, i.e., where publishing is not the primary activity of the producing body.''} The term ``grey'' (or ``fugitive'') literature is often used to refer to the literature not obtainable through traditional publishing channels, without passing through control mechanisms (e.g., peer review) before a publication~\cite{Petticrew:2006:Book:SR}. On the other hand, there are the Traditional Literature (TL), covered by peer reviewed works (e.g., conference and journal papers).
In the last years, GL gained particular attention in Software Engineering (SE) research. For instance, William and Rainer investigated the use of blogs as
an evidence source for SE research~\cite{Williams:2017:EASE, Williams:2018:ASWEC}. Several primary studies are investigating the use of GL. As an example, William and Rainer in two studies investigated the use of blogs as an evidence source for SE research~\cite{Williams:2017:EASE, Williams:2018:ASWEC}. There are also tertiary studies investigating the use of GL in secondary studies~\cite{Yasin:Thesis:2020,Zhang:2020:ICSE}.
Recently, Zhang et al.~\cite{Zhang:2020:ICSE} showed a growing number of secondary studies using GL over the years, especially the Multivocal Literature Reviews (MLR) and Grey Literature Reviews (GLR). The former is a Systematic Literature Review (SLR) that search for evidence in GL in addition to TL~\cite{Garousi:2019:IST}, while the latter only searches in GL sources. However, despite the interest, more specifically for MLR studies~\cite{Neto:2019:ESEM}, there is only one study~\cite{Garousi:2016:EASE} assessing to what extent GL sources are contributing to the findings of MLR studies.
Garousi et al.~\cite{Garousi:2016:EASE} investigated what is gained when considering GL as a source of evidence in an MLR study and what knowledge are missed when GL is not considered. However, several MLRs were published since Garousi et al.'s study, and no other research has investigated how GL affected the MLR studies.
This lack of understanding could make SE researchers skeptical about using GL or conducting an MLR study, in particular because the addition of GL greatly increases the effort of conducting an MLR, when compared with traditional secondary studies~\cite{Raulamo-Jurvanen:2017:EASE}.
The goal of this research is to assess to what extent the use of GL contributed to MLR studies that followed Garousi's Guidelines~\cite{garousi2017guidelines,Garousi:2019:IST}. By contributing, we mean, understanding to what extent the GL is providing evidence that is, in fact, used by an MLR to answer its research question. To achieve this goal, we explored the following research questions (RQ):
\begin{itemize}
\item \textbf{RQ1:} \textit{How commonplace is to employ Grey Literature in Multivocal Literature Review studies?}
\end{itemize}
\begin{itemize}
\item \textbf{RQ2:} \textit{To what extent Grey Literature contributes with the findings of Multivocal Literature Review studies?}
\end{itemize}
\begin{itemize}
\item \textbf{RQ3:} \textit{What types of Grey Literature sources are most commonly observed in Multivocal Literature Review?}
\end{itemize}
To answer these questions, we employed a tertiary study to find potential MLR studies, and qualitatively explored nine of these MLR studies. Our main findings are the following:
\begin{itemize}
\item Several findings of MLR studies were exclusively retrieved from GL sources. For instance, we perceived that some RQs from two MLR studies~\cite{MLR4,MLR6} were answered using only GL.
\item MLRs are benefiting from GL mostly to provide \emph{explanation} about a topic (e.g., explaining how DevOps could help in operations process and manage risks of companies~\cite{MLR2}) and to \emph{classify} the findings (e.g., when classifying libraries, architectural style, and architectural guidelines about Android apps~\cite{MLR3}). Also, contributions providing recommendations (e.g., a recommendation of the use of dependency injection approach to fix the heavy of the setup of test smells~\cite{MLR6}) are presented in 66.6\% of the MLR studies.
\item Several GL types were identified among the MLR studies. The most common types were the blog posts, web articles, books and book chapters, and technical reports. These GLs were produced mainly by SE practitioners, consultants and companies, and tool vendors.
\end{itemize}
\section{Research Method: A Tertiary Study}\label{sec:case-studies}
As we intend to investigate to what extent GL contributed to multivocal studies, we conducted a tertiary study to identify MLR studies published in the SE literature. This research followed the most well-known guideline to conduct a secondary study in SE produced by Kitchenham et al.~\cite{Kitchenham:2007:Guideline}.
For replication purposes, all the data used in this research is available online at: \texttt{https://bit.ly/2SBoDIh}.
\subsection{Search strategy}\label{sec:method-search-strategy}
In this investigation, we restricted our investigation to MLR studies that strictly followed Garousi's guidelines~\cite{garousi2017guidelines,Garousi:2019:IST}. We took this decision because these are the main and most recent guidelines in SE research to conduct MLR studies. Although the most recent Garousi's guidelines were published (in a peer review format) in 2019~\cite{Garousi:2019:IST}, an earlier version of it (published in 2017 as a preprint~\cite{garousi2017guidelines}); this is why we considered both of them in our research.
We started our research in the beginning of 2020. For this reason, we decided to limit our scope to studies published since 2017 (the first publication of Garousi's Guidelines~\cite{garousi2017guidelines}) until the end of 2019.
We started by using the Google Scholar search engine to find works that cited Garousi's studies published~\cite{garousi2017guidelines,Garousi:2019:IST}.
\subsection{Selection criteria}
When manually investigating the 60 potential studies, we focused on selecting only MLR studies.
For each candidate study, we applied a set of exclusion criteria described in Table~\ref{tab:ec}.
We excluded any candidate study that complies with at least one exclusion criterion. At the end of this process, we were left with nine MLR studies.
\begin{table}[!ht]
\caption{List of exclusion criteria.}
\small
\centering
\begin{tabular}{cp{7.5cm}}
\toprule
\textbf{\#} & Description \\
\midrule
EC1 & The study was published before 2017 or after 2019.\\
EC2 & The study was duplicated.\\
EC3 & The study was not written in English.\\
EC4 & The study was not related to Software Engineering.\\
EC5 & The study was not a full paper (e.g., a position paper).\\
EC6 & The study did not report an MLR study.\\
EC7 & The study did not follow Garousi's guidelines~\cite{garousi2017guidelines,Garousi:2019:IST}. \\%~\cite{garousi2017guidelines,Garousi:2019:IST}.\\
\bottomrule
\end{tabular}
\label{tab:ec}
\end{table}
\subsection{Study selection}
We conducted this research in five phases, as detailed in Figure~\ref{fig:selection-process}. There is a number indicating each phase (\textbf{P1--P5}).
\begin{figure}[b!]
\centering
\includegraphics[scale = 0.40, clip = true, trim= 0px 0px 0px 0px]{img-selection-process-esem2021.png}
\caption{Process of selecting studies in each phase of the tertiary study.}
\label{fig:selection-process}
\end{figure}
At phase \textbf{P1}, we selected a total of 60 potential studies. From these, 28 cited the first version of the guideline for conduct MLR in SE research based on a technical report~\cite{garousi2017guidelines}, and 32 mentioned the final version of the MLR guidelines for SE~\cite{Garousi:2019:IST}.
At phase \textbf{P2}, we sorted the potential studies by title and organized them on a spreadsheet. We applied EC1 and EC2 to remove the studies out of the range of our investigation and the studies with the same bibliographical information (i.e., title, abstract, and author(s)). For EC2, we employed the following steps: (1) We compared paper titles; (2) For studies with the same title, we looked at the abstracts and if they were different. We considered the complete study as recommended by Kitchenham and Charters~\cite{Kitchenham:2007:Guideline}; if they are the same, we exclude one of them. If the publication years are different, we excluded the oldest study. We removed 25 studies, one study published after 2019 (EC1), and 24 instances of duplicated studies (EC2), respectively. At the end of this phase, 35 studies remained.
At phase \textbf{P3}, we read the studies thoroughly and applied EC3--EC7 to all the 35 potentially relevant studies. As the criteria employed to select studies were simple, only one researcher applied them alone. We removed 24 studies base on the following criteria: three studies are not written in English (EC3); nine studies are not related to SE (EC4); four studies are not full papers (EC5); six studies did not report an MLR (EC6); and two studies were eliminated because they did not follow the Garousi's studies~\cite{garousi2017guidelines,Garousi:2019:IST} to conduct their research. This way, at the end of this phase, \textbf{nine MLR studies remained}. The complete references of each study are presented in \textbf{Appendix A}.
At phases \textbf{P4--P5}, we applied the data extraction, analysis, and synthesis following the process depicted in Figure~\ref{fig:gl-delta-process}. These phases are fully described in Section~\ref{sec:delta-process}.
\subsection{Data extraction and analysis}\label{sec:delta-process}
Due to the lack of a process to help SE researchers that intend to investigate how the use of GL contributed to MLR studies, we had to design a process based on our own experience. This process was refined by three researchers and was used to conduct phases P4 and P5. We conducted this process in pairs, and all the authors of the paper revised the emerged categories and classifications.
Our process starts by investigating an MLR study distributed in three activities with their respective steps, as shown in Figure~\ref{fig:gl-delta-process}. In what follows, we describe our process.
\begin{figure}[b]
\centering
\includegraphics[scale = 0.37, clip = true, trim= 0px 0px 0px 0px]{img-delta-process-MLR-studies.png}
\caption{The process used to identify how GL use contributed to MLR studies.}
\label{fig:gl-delta-process}
\end{figure}
\subsubsection*{Activity 1: Identifying primary sources}
The first activity aims to identify the primary sources\footnote{In related studies, the term ``primary sources'' in GL is used as equivalent to the term ``primary studies'' in TL~\cite{Garousi:2019:IST}} included in an MLR study through four steps. The first step (\textit{Step A1}) identifies the number of primary sources included in the MLR study. Then, we count the occurrences of each group: Grey Literature (GL) and Traditional Literature (TL) (\textit{Step A2}). These numbers are important in two moments: (i) to calculate the amount (\%) of GL included (total of GL included / total of included studies), and (ii) to search for GL references in the studies. The following step is to find the reference of each GL included (\textit{Step A3}), and add all the data collected in A3 in a spreadsheet. The list or references for GL is usually found in the appendix, tables, or external files available. The final step (\textit{Step A4}) consisted in selecting and extracting all the data available of each GL, in order to permit traceability between the data extracted and the primary sources (as recommended by Garousi et al.~\cite{Garousi:2019:IST}). In our research, we collected data such as (but is not limited to): (i) the names of authors,(ii) the year of publication, (iii) total number of included studies, (iv) the total number of of GL sources included, and (v) the guideline followed. In addition, considering each study that included GL, we also extracted: (i) the GL type, (ii) the evidence used from GL, (iii) the type of contribution, and (iv) type of producer.
\subsubsection*{Activity 2: Identifying the Grey Literature contribution}
The second activity consists of selecting the GL data saved to identify how its use contributed to the MLR study. Then, inserting in the spreadsheet all the portions of GL used as evidence.
We used the following approach to identify these contributions \textit{(Step B1}): (i) after identifying the GL sources, we searched for any mention/discussion of each GL in the manuscript. We noticed it is common to find this information in tables, graphics, or as citation during the manuscript; (ii) once we identified the contribution, we extracted the citation or the artifact name used to highlight where the contribution occurred; (iii) we employed a qualitative analysis to classify the contribution of the use of each GL \textit{(Step B2}) according to its type. We used the GL types classification introduced by Maro et al.~\cite{MARO:JSS:2018}; and (iv) we investigated the relation of the GL types and the contributions identified.
In the following, we present in greater detail the qualitative analysis process used in the Activity 2 (Figure~\ref{fig:code-categories}), based on the thematic analysis technique~\cite{Braun:ThematicAnalysis:2006}:
\begin{figure}[t]
\centering
\includegraphics[scale = 0.32, clip = true, trim= 90px 30px 110px 0px]{img-esem2021-codes-categories.png}
\caption{Example of classification process used to analyze the contributions by GL use.}
\label{fig:code-categories}
\end{figure}
\begin{itemize}
\item \textbf{Familiarizing ourselves with data.} Each researcher involved in the data analysis procedure becomes aware of which part of the MLR study the GL sources were referenced, as expressed in Figure~\ref{fig:code-categories}-(a).
\item \textbf{Initial coding.} In this step, each researcher individually added pre-formed codes. Our process of allocating data to pre-identified themes of contributions is based on the list of contribution facets proposed by Garousi and K\"u\c{c}\"uk~\cite{GarousiBaris:JSS:2018} (e.g., recommendation, experience report, tool, solution proposal, opinion, empirical study, categorizing (or classification)).
During the initial coding, we found categories not identified by Garousi and K\"u\c{c}\"uk~\cite{GarousiBaris:JSS:2018}. Thus, we extended the original contribution facets to add these categories. We briefly define each one as following:
\textit{Programming}, used to evidence programming-related techniques; \textit{Concept Definition}, used for sources that present a concept or a definition of meaning; \textit{Explanation}, used for evidence that provides any explanation or information about a topic; \textit{Recommendation}, used for evidence that contributed by providing any recommendation to solve or support a problem or challenge. Figure~\ref{fig:code-categories}-(b) presents an example of this analysis, where two portions from the texts were extracted and coded: Suggestion and Recommendation. Labels express the meaning of excerpts from the quote that represented appropriate types of contributions.
\item \textbf{Classifying contributions by GL use.} Here, we already had an initial list of codes. A single researcher looked for similar codes in data. Codes with similar characteristics were grouped into broader categories. Eventually, we also had to refine the categories found, comparing and re-analyzing them in parallel. Figure~\ref{fig:code-categories}-(c) presents an example of this process. This example exhibits how the category ``Recommendation'' emerged.
\item \textbf{Classifications refinement.} In this step (Figure~\ref{fig:code-categories}-(d)), we involved two researchers in evaluating all classifications and a third researcher to solve any disagreements (if needed). In the cases of any doubt, we solved them through conflict resolution meetings.
\end{itemize}
\subsubsection*{Activity 3: Investigating the impact of GL}
This activity consisted of investigating how GL usage contributed to MLR study. It started by selecting the data of GL stored to investigated GL findings \textit{(Step C1)} and to understand how these findings contributed to the MLR study \textit{(Step C2)}. The goal is to assess quantitatively and qualitatively these contributions. For instance, in terms of quantitative analysis, we presented the difference in the proportion of included studies and the number of studies related to a particular finding. In qualitative aspects, we compared GL findings with TL findings, focusing on understanding if any finding was observed solely because of GL.
\section{Results}\label{sec:results}
This section answers our RQs by analyzing nine MLRs studies that followed Garousi's guidelines~\cite{garousi2017guidelines,Garousi:2019:IST}.
First, we present an overview of how the use of GL contributed to each MLR study (Section~\ref{sec:overview-gl-contributions}). Then, we present our classification for the contributions identified and correlating them with the GL types and their producers (Section~\ref{sec:classifying-gl-contributions}). Finally, we present the types of GL and producers identified (Section~\ref{sec:gl-sources-producers}).
\begin{comment}
\begin{table*}[t]
\centering
\caption{Characteristics of investigated studies.}
\label{tab:mlr-studies-characteristics}
\begin{tabularx}{\textwidth}{cbcss}
\toprule
ID & Main topic & GL as primary source & RQs answered using GL & RQs exclusively answered using GL\\
\midrule
\cite{MLR1} & Relevance of software engineering research & 15/46 (32.6\%) & 2/2 & 0/2\\
\cite{MLR2} & Risk management in DevOps & 7/16 (43.7\%) & 3/3 & 0/3\\
\cite{MLR3} & Architecting Android Apps & 32/44 (72.7\%) & 3/3 & 0/3\\
\cite{MLR4} & Holacracy In Software Development Teams & 10/11 (90.9\%) & 3/3 & 2/3\\
\cite{MLR5} & Test smells & 120/166 (72.3\%) & 8/9 & 0/9\\
\cite{MLR6} & Software traceability & 160/339 (47.2\%) & 1/3 & 1/3\\
\cite{MLR7} & Integration platforms & 5/23 (21.7\%) & 1/3 & 0/3\\
\cite{MLR8} & SaaS Pricing Cookbook & 151/227 (66.5\%) & 1/1 & 0/1\\
\cite{MLR9} & Code Changes & 21/43 (48.8\%) & 1/2 & 0/2\\
\bottomrule
\multicolumn{4}{l}{\begin{tabular}[c]{@{}l@{}}* Not possible to determine because the amount of GL included was not informed.\\ \end{tabular}}
\end{tabularx}
\end{table*}
\end{comment}
\begin{table}[b]
\caption{Characteristics of investigated studies. ``Total (\#)'' means the total amount of GL as the primary source, ``Total (\%)'' means the proportion of GL as primary source, ``RQ'' means the number of research questions answered with GL, and ``XRQ'' means the number of research questions \emph{exclusively} answered.}
\label{tab:mlr-studies-characteristics}
\begin{minipage}{.5\textwidth}
\centering
\begin{tabularx}{\textwidth}{crrss}
\toprule
ID & Total (\#) & Total (\%) & RQ & XRQ\\
\midrule
\cite{MLR1} & 15 & 32.6\% & 2/2 & 0/2\\
\cite{MLR2} & 7 & 43.7\% & 3/3 & 0/3\\
\cite{MLR3} & 32 & 72.7\% & 3/3 & 0/3\\
\cite{MLR4} & 10 & 90.9\% & 3/3 & 2/3\\
\cite{MLR5} & 120 & 72.3\% & 8/9 & 0/9\\
\cite{MLR6} & 160 & 47.2\% & 1/3 & 1/3\\
\cite{MLR7} & 5 & 21.7\% & 1/3 & 0/3\\
\cite{MLR8} & 151 & 66.5\% & 1/1 & 0/1\\
\cite{MLR9} & 21 & 48.8\% & 1/2 & 0/2\\
\bottomrule
\end{tabularx}
\end{minipage}
\end{table}
\subsection{RQ1: How commonplace is to employ Grey Literature in Multivocal Literature Review studies?}\label{sec:overview-gl-contributions}
An overview of the nine MLR studies is presented in Table~\ref{tab:mlr-studies-characteristics}, showing several interesting observations. First, the second column (Total (\%)) shows that in the study~\cite{MLR4}, GL accounted for more than 90\% of primary sources overall. In three studies~\cite{MLR3,MLR5,MLR8}, GL accounted for between 51--75\% of the selected studies. Only one MLR study~\cite{MLR8}, GL was found in less than 25\% of included sources. This finding suggest that MLRs are taking serious advantage of GL. Second, in the third column (RQ), we depict how many GL sources were used to answer the research questions posed by the MLRs. We noticed that all studies used GL to answer at least one research question. The MLRs~\cite{MLR1,MLR2,MLR3,MLR4,MLR8}, in particular, used GL as their basis to answer all research questions. When looking closer (last column, XRQ), we also observed two studies~\cite{MLR4,MLR6} that have some RQs that were exclusively answered using GL, for instance.
Next, we assess what evidence was found in GL.
Garousi et al.~\cite{MLR1} conducted an MLR to provide a more ``holistic'' view about SE research relevance. The study included 46 primary sources, 31 from TL (67.4\%) and 15 from GL (32.6\%). Although the amount of TL studies was higher than GL sources, the evidence retrieved from GL were used to support most of the findings. The authors identified that the root causes of low relevance of SE research (e.g., Simplistic view about SE in practice, Wrong research problems identification, Issues with research mindset) were observed in multiple sources (GL and TL), concluding that the community members share similar opinions on the debate.
Plant's study~\cite{MLR2} performed an MLR to investigate which types of risks companies using DevOps are generally exposed to and proposed a framework that helps companies control their process and manage risks. The study identified 24 risk types. From these, nine were exclusively identified in GL sources (e.g., Automated change controls and thresholds, Automate production deployment, Static code analysis), eight were exclusively identified in TL sources, and seven were found in both groups (GL and TL). In particular, if the study did not consider GL sources, the MRL would not have discussions about \textit{Automated security tests} and \textit{Monitoring and logging}, which comes largely from GL.
Verdecchia~\cite{MLR3} investigated (through an MLR and interviews with SE practitioners) how developers architect their Android apps, what architectural patterns these apps rely on, and their potential impact on quality. The study identified 15 libraries and nine architectural patterns considered when developing Android apps. Considering only the libraries, 13 were found exclusively in GL (e.g., JUnit, Mockito, Mosby), and only two of them were found through the interviews. From the architectural patterns identified, 7/9 (77.8\%) were exclusively found in GL (e.g., Clean, Hexagonal, Viper). Beyond that, 212 architectural practices were extracted and synthesized into 42 architectural guidelines. From these guidelines, 38/42 (90.5\%) were retrieved from GL. According to the study, four main themes emerge from the guidelines retrieved exclusively in GL. Regarding the quality requirements considered while architecting Android apps, seven (7/24; 29.1\%) of them were exclusively retrieved from GL (e.g., Scalability, Interoperability, Maintainability). In particualr, the scalability attribute was \emph{exclusively} found in GL sources. On the other hand, 11 groups of quality requirements were exclusively found in TL sources.
Bhandari and Colomo-Palacios~\cite{MLR4} conducted an MLR to investigate holacracy, a practice to radically shift from the conventional ladder to a more decentralized organizational structured. This MLR investigated holacracy in software development teams, its features, benefits, and challenges. This study investigated three research questions: RQ1 covered the definitions of holacracy and was answered using only GL sources. RQ2 investigated the characteristics of holacracy, which were identified: roles, circles of small groups, and meetings. Circles and meetings, in particular, were derived only from GL sources, and the roles were identified in both GL and TL. Finally, RQ3 was answered using only GL sources, explored the benefits (e.g., increased product transparency, better decisions, fast improvement) and challenges (e.g., implementation difficulty, undefined job roles cause employee outflow) using holacracy.
Garousi and K\"u\c{c}\"uk~\cite{MLR5} performed an MLR to summarize what is known about smells in test code. The authors highlighted that ``most test smells and problems in this area are `observed' by practitioners who are actively developing test scripts and are communicating by them via the GL (e.g., blog posts and industry conference talks).'' In this study, GL sources represent 72 out of 81 (88.9\%) primary sources that presented new smells names and types. For solution proposals, 72.4\% of the sources were GL.
Maro et al.~\cite{MLR6} conducted an MLR to explore traceability challenges and solutions in the automotive software development domain. The study identified 22 challenges of software traceability (e.g., Lack of knowledge and understanding of traceability, Difficulty defining information model for traceability, Unclear traceability process) distributed in seven groups of factors (e.g., Human, Uses of Traceability, Knowledge of Traceability). In this investigation, although the challenges identified in GL and TL were similar, the study mentioned that the solutions presented in GL were richer than TL due to the diversity of producers.
Freire et al.~\cite{MLR7} performed an MLR to evaluate integration platforms, specialized software tools with integration solutions, which aim to direct a set of applications to promote compatibility among their data and new features regarding the performance of their run-time systems. This study selected nine open-source integration platforms, of which two were exclusively found in GL sources (Petals and ServiceMix), five were found both GL and TL (e.g., Guaraná, Fuse, Mule), and two exclusively found in TL sources (Camel and Spring Integration).
Saltan and Smolander~\cite{MLR8} investigated a total of 13 SaaS pricing frameworks: seven retrieved from TL (e.g., Pricing process framework, Cloud solution pricing framework) and six from GL (e.g., Customer-centric value-based pricing framework, Pricing process framework, PWC pricing management framework). These frameworks coverage the three SaaS pricing aspects (Pricing strategy, Pricing tactics, Pricing operations). Considering the pricing aspects observed, if the study did not include GL, no evidence of Pricing Operations would exist.
The study of Ram and Sawant~\cite{MLR9} focused on gaining a sound foundation about what aspects of a code change reviewers focus on, conducted two investigations: an MLR study and the other one using interviews. The study identified ten themes that constitute an excellent code change (e.g., Change description, Change scope, Code style). Two themes were identified only in TL sources (Nature of the change, Subsystem hotness). No theme was exclusively composed of GL, although in some of the themes, GL counts as the main source to provide evidence (e.g., Change description, Commit history).
\subsection{RQ2: To what extent Grey Literature contributes with the findings of Multivocal Literature Review studies?}\label{sec:classifying-gl-contributions}
This section presents the results of our investigation of the 384 GL sources found in nine MLR studies, resulting in 326 contributions identified and classified. We also explored these contributions by analyzing their relation with each MLR study.
To better comprehend of the present results and enable traceability, we include direct quotes extracted from the MLR studies representing the GL use in the study. In the following, we describe each type of contribution.
\subsection*{Contributions related by GL use}
\vspace{0.2cm}
\noindent
\textbf{Recommendation (7/9 studies; 77.8\%).}
GL evidence was found by providing recommendations to deal with something (e.g., project, tool) or some problems (e.g., lack of proper visualization and reporting tools for software traceability in the automotive domain). In Garousi and K\"u\c{c}\"uk~\cite{MLR5}, the authors cited a blog post that suggested using dependency injection as an approach to fix one test smell. Maro et al.~\cite{MLR6} mentioned a service description presenting a recommendation to use a centralized data storage where all artifacts are stored and therefore accessible by the staff in different locations. This would solve the challenge of complexity added by distributed software development: \textit{``[\ldots] having tool support such as an integrated tool platform where all development activities are done, or a structured way of defining artifacts also helps to solve this challenge.''}
\vspace{0.2cm}
\noindent
\textbf{Explanation (7/9 studies; 77.8\%).}
This category (with the highest number of contributions) indicates that authors used GL to explain some topics explored in seven MLR studies.
An example for this category, the study of Garousi et al.~\cite{MLR1} mentioned a blog post: \textit{``Software research is biased toward huge projects and, thus, small to medium size projects may not benefit from most SE papers.''} The study of Plant~\cite{MLR2} used a whitepaper to explain how DevOps could manage risks in software companies: \textit{``[\ldots] Due to the increased speed, quality, and agility which DevOps brings about if implemented correctly, implementing DevOps processes can contribute significantly to achieving these objectives.''} In the study of Bhandari and Colomo-Palacios~\cite{MLR5}, GL sources were used to characterize holacracy in software development teams. For instance, the information present in a blog post: \textit{``In holacracy, instead of job titles, there is a strong focus on the roles that people take on within the organization. Every task or project assigned to an employee must be within the accountabilities of his or her role.''}
\vspace{0.2cm}
\noindent
\textbf{Classification (6/9 studies; 66.7\%).}
This category was also commonly observed, indicating that GL helped to classify the findings (e.g., types of concepts, tools, SE practices) of the MLR studies.
Verdecchia et al.~\cite{MLR3} used 32 GL primary sources and 12 TL primary studies to classify the libraries, architectural style, and architectural guidelines found about Android apps.
As an example, the study of Verdecchia et al. used GL evidence to classify 38 architectural practices found into four themes: general Android architecture, MVP, MVVM, and Clean Architecture. In Garousi and K\"u\c{c}\"uk~\cite{MLR5}, a GL based in a bachelor thesis was used to categorize test smells, as follow: \textit{``[\ldots] categorized 53 different test smells on several dimensions, e.g., test automation, determinism, correct use of assertions, and reliability.''}
Another example was the study of Ram et al.~\cite{MLR9} that used GL to classify the findings of what constitutes a good code change. This study used evidence from GL to classify eight themes (e.g., change description, change scope, code quality, code style).
\vspace{0.2cm}
\noindent
\textbf{Solution proposal (5/9 studies; 55.5\%).}
In this category, the use of GL contributed to proving solutions proposals to some problems or challenges faced.
An example for this category, the study of Maro et al.~\cite{MLR6} identified some solutions proposals for software traceability in the automotive domain, in a presentation of one company, as we quoted: \textit{``Two solutions have been suggested. One is to have tools that support the different disciplines with collaboration features such as chats, forums, and notifications. [\ldots] Second is having a defined process on how the teams should collaborate [\ldots].''} The study of Plant~\cite{MLR2} used a book to show how they implemented their DevOps process: \textit{``In order to ensure quality and information security, Muñoz and Díaz implemented phases from the OWASP Software Assurance Maturity Model (SAMM) [\ldots]. The OWASP SAMM covers the phases governance, construction, verification and operations and therefore spans the complete DevOps life cycle [\ldots].''}
\vspace{0.2cm}
\noindent
\textbf{Opinion (5/9 studies; 55.5\%).}
This category was identified using opinions included in some GL sources. We employed the same meaning of Garousi and K\"u\c{c}\"uk~\cite{GarousiBaris:JSS:2018} for ``opinion'' contributions, in which GL sources characterizing to emit ``opinion.'' In this regard, an opinion about Android architecture based on a discussion from a blog post was used in Verdecchia et al.'s~\cite{MLR3}: \textit{``No. Do not retain the presenter I don’t like this solution mainly because I think that presenter is not something we should persist, it is not a data class, to be clear.''} Another example was presented in Garousi et al.~\cite{MLR1} that used the content of a video presentation in a conference panel as evidence. A professor in the panel emitted an opinion about the root causes of low relevance of SE research, focusing on requirements engineering in the SE area: \textit{``In my view, too often, research justified as satisfying the needs of industry begins with a wrong or simplified understanding of industry's problems.''}
\vspace{0.2cm}
\noindent
\textbf{Concept Definition (3/9 studies; 33.3\%).}
GL was used to present some concepts and definitions in MLR studies. For instance, in Bhandari and Colomo-Palacios~\cite{MLR5}, a web article presented the definition of holacracy, as followed: \textit{``The literature defined holacracy in software development teams as a way of decentralized management and organizational governance where authority and decision making are delivered throughout autonomous and self-organizing teams (circles).''} Another use of this contribution was identified in Garousi's study~\cite{MLR1}, in which a slide presentation defined the ``impact'' in SE research as \textit{``How do your actions [research] change the world?.''}
\vspace{0.2cm}
\noindent
\textbf{Experience report (3/9 studies; 33.3\%).}
To characterize the evidence found in experience-based studies, we employed the same approach of Garousi and K\"u\c{c}\"uk~\cite{GarousiBaris:JSS:2018}: \textit{``Experience studies were those who had explicitly used the term ``experience'' in their title or discussions without conducting an empirical study.''} In this regard, the study of Verdecchia et al.~\cite{MLR3} used a guideline that provided a diverse experience reports on how to test each code module (e.g., User interface and interactions, Webservice, Testing Artifacts). The study of K\"u\c{c}\"uk~\cite{MLR5} used an evidence from a blog post about unit testing that provided: \textit{``a practitioner shared her experience of moving away from assertion-centric unit testing and fixing smells such as eager tests.''}
\vspace{0.2cm}
\noindent
\textbf{Others (3/9 studies; 33.3\%).}
Here we group the studies that the use of GL contributed with \textit{``tools''}, \textit{``code programming''}, and \textit{``empirical evidence.''} In this regard, Plant~\cite{MLR2} presented a discussion from a \textit{whitepaper} about the use of containers like Docker in DevOps, as we quoted: \textit{``They are therefore very resource efficient. However, configurations in Docker containers cannot be changed since containers cannot be updated. Updated software or configuration, therefore, requires a new image build.''} The study of Maro et al.~\cite{MLR6} used a \textit{book} that explored test smells, as following: \textit{``[GL] explored a set of ‘pitfalls’ (smells) for JUnit and an Apache-based test framework named Cactus.''} The last example is about empirical study base in a blog post, present in Garousi and K\"u\c{c}\"uk~\cite{MLR5}, in which were explored open-source projects to investigate test redundancy, as we follow: \textit{``[\ldots] [GL] reported a study on more than 50 test suites from 10 popular open-source projects and found that higher amounts of test redundancy are linked to higher amounts of bugs.''}
\begin{comment}
\vspace{0.2cm}
\noindent
\textbf{Tools (2/9 studies; 22.2\%).}
Few studies contributed by providing a discussion about some tools used by software engineers. For instance, Garousi and K\"u\c{c}\"uk~\cite{MLR5} explored the frameworks for unit testing in a \textit{blog post}, as we quoted: \textit{``Smells specific for other frameworks in the xUnit family were also explored, e.g., [GL sources] were focused on PHPUnit.''} And, Plant~\cite{MLR2} presented a discussion from a \textit{whitepaper} about the use of containers like Docker in DevOps, as we quoted: \textit{``They are therefore very resource efficient [GL]. However, configurations in Docker containers cannot be changed since containers cannot be updated. Updated software or configuration, therefore, requires a new image build [GL].''}
\end{comment}
\begin{comment}
\vspace{0.2cm}
\noindent
\textbf{Programming (1/9 studies; 11.1\%).}
Only one study~\cite{MLR6} provided evidence found in a \textit{book/chapter} and \textit{video} contributing to this category. An example was the use of \textit{video} that explained through a code demonstration the motivation for slow tests, as we quoted: \textit{``[GL] explored the common reason for Slow Tests as follows: having other testing anti-patterns, having tests with lots of setups, and having a slow implementation (production) code.''} Another example in the same study was retrieved from a \textit{book}, that explored test smells, as we presented: \textit{``[GL] explored a set of ‘pitfalls’ (smells) for JUnit and an Apache-based test framework named Cactus.''}
\vspace{0.2cm}
\noindent
\textbf{Empirical (1/9 studies; 11.1\%).}
Only one MLR~\cite{MLR6} included GL sources that contributed with empirical evidence. These sources were retrieved from \textit{blog post}. The first one provided the following information: \textit{``[\ldots] [GL] reported a study on more than 50 test suites from 10 popular open-source projects and found that higher amounts of test redundancy are linked to higher amounts of bugs.''} The second one, empirically examined the adequacy of assertions in automated test suites.
\end{comment}
\subsection{RQ3: What types of Grey Literature sources are most commonly observed in Multivocal Literature Review?}\label{sec:gl-sources-producers}
In our investigation, we explored: (i) the use of each GL type in MLR studies and the relation between these types with the contribution identified by GL use; and (ii) the GL types and the types of producers identified.
For a better comprehension of Table~\ref{tab:types-GL-vs-types-GL-contributions}, we informed: one GL type could be related to none, one or more of a type of contribution; and one study could be classified into none (blank), one, or in more than one type of contribution.
\subsubsection*{(i) Grey Literature vs Contributions}
We classified the 384 GL sources identified in MLR studies according to 19 types of GL.
Figure~\ref{fig:occurences-types-gl} shows the distribution of this classification from two perspectives. The first one (blue bar) presents the amount of GL sources for each GL type. The second one (red bar) shows the amount of MLR studies in which each GL type was found. The GL types identified were related to the type of contribution identified, as shown in Table~\ref{tab:types-GL-vs-types-GL-contributions}.
Considering GL sources, \textit{Blog posts} were the most common GL type found among the MLR studies (118 occurrences), used in six MLR studies~\cite{MLR1,MLR3,MLR5,MLR6,MLR7,MLR9}. Regarding the contributions related to its use, the most commonly was to provide recommendations and opinions.
\textit{Slides presentations} was the second type most common found in the studies (45 occurrences), used in four MLR studies~\cite{MLR1,MLR5,MLR6,MLR8}. Its use was most common to provide recommendations and solution proposals.
\textit{Project or software descriptions} were the third most found type (42 occurrences), although this type was used in only one study~\cite{MLR7}. Its use provided the following contributions: solution proposals and recommendations.
\textit{Whitepapers} was another type commonly found (25 occurrences), used in four MLR studies~\cite{MLR3,MLR4,MLR6,MLR8}. The main contributions related to this use were to provide explanations, recommendations, and opinions.
\begin{figure*}[h]
\centering
\includegraphics[scale=0.55, clip = true, trim= 20px 0px 0px 0px]{img-types-of-gl-vs-amount-gl-sources-and-mlr-studies.png}
\caption{Amount of the Grey Literature found distributed by its types and the amount of MLR studies in which each type of GL was used.}
\label{fig:occurences-types-gl}
\end{figure*}
\begin{table*}[]
\caption{Number of grey literature sources (separated by their types) that are related to a type of contribution.}
\label{tab:types-GL-vs-types-GL-contributions}
\begin{tabular}{lcccccccccc}
\toprule
\multirow{2}{*}{Type of GL} &
\multicolumn{10}{c}{Type of contribution} \\
& REC & EXPLA & CLA & SOP & OPN & DEF & EXP & TOOLS & PRO & EMP \\
\midrule
Blog post & 55 & 19 & 12 & 2 & 34 & 2 & 2 & 5 & & 2 \\
Book/Chapter & 7 & 3 & 4 & 2 & 1 & & & 1 & 1 & \\
Case/Serv. desc. & 1 & & & 2 & & & & & & \\
Guideline & 17 & 5 & 5 & & 1 & & 1 & & & \\
Magazine article & & 1 & 2 & & 1 & & & & & \\
Q\&A website & 1 & 2 & & & & & & & & \\
Slide & 9 & 5 & 3 & 6 & 2 & 1 & & & & \\
Proj/Softw desc & 2 & & & 4 & & & & & & \\
Talk abstract & 1 & & & & & & & & & \\
Tech. Report & 5 & 13 & 5 & 1 & 4 & & & & & \\
Theses & & 3 & 2 & & & & 2 & & \\
Video & 4 & 8 & & & 1 & & & 1 & 3 & \\
Web article & 2 & 3 & & 3 & & 1 & & & & \\
Whitepaper & 4 & 6 & 2 & 2 & 4 & 2 & & 1 & & \\
Wiki entry & 1 & 3 & & & & & & & & \\
* Unknown & 1 & 3 & 1 & 1 & & & & & & \\
* Others & 1 & 2 & 1 & 2 & 5 & 1 & & & & \\
\bottomrule
\multicolumn{4}{l}{\begin{tabular}[c]{@{}l@{}}CLA = Classification \\ PRO = Programming \\ DEF = Concept Definition \\ EMP = Empirical Study\\ \end{tabular}} & \multicolumn{4}{l}{\begin{tabular}[c]{@{}l@{}} EXP = Experience\\ EXPLA = Explanation\\OPN = Opinion \\\end{tabular}} & \multicolumn{2}{l}{\begin{tabular}[c]{@{}l@{}} SOP = Solution Proposal \\ REC = Recommendation\\ TOOLS = Tools\\
\end{tabular}}
\end{tabular}
\end{table*}
\subsubsection*{(ii) Grey Literature Producers}
We also investigated the producers of all 384 GL sources to identify who was the producer and to which GL types he/she was related. Figure~\ref{fig:types-gl-vs-type-producers} shows the results of these investigations.
Our first analysis shows that GL sources were produced mainly by SE \textit{Practitioners} (130/384 GL sources; 31.9\%), followed by \textit{Consultants or Companies} and \textit{Tool vendors}, each one representing respectively, 21.3\% (87/384 GL sources) and 21.1\% (86/384 GL sources).
Our second analysis showed the relationship between GL types and producer types. Three types of producers (Practitioners, Consultant or Companies, Tool vendors) caught our attention because they were responsible for almost 75\% of the GL primary sources identified. We noted that \textit{Consultants and Companies} contributed to more GL types. Their major contributions occurred with \textit{slides} and \textit{whitepapers}. \textit{Practitioners} were the second one with more contributions in different GL types. The highlighted of their contributions were mainly with \textit{blog posts}, \textit{web articles}, and \textit{Q\&A websites}. Finally, \textit{tool vendors} were the ones that most produced \textit{descriptions of projects or software} included in the MLR studies.
\begin{figure*}
\centering
\includegraphics[scale = 0.55, clip = true, trim= 20px 0px 0px 0px]{img-types-gl-vs-type-producers.png}
\caption{Distribution of each type of Grey Literature source identified among the MLR studies investigated, according to the types of producers.}
\label{fig:types-gl-vs-type-producers}
\end{figure*}
\section{Discussion}\label{sec:discussion}
This section revisits our main findings, discussing some of them, and relating them to related works. After, we present some challenges we faced to investigate the contributions of the GL use. Finally, we present our discussions about our limitations and threats to validity.
\subsection{Revisiting findings}
Observing the number of primary sources included in MLRs, GL has a significant contribution. Although GL sources had low inclusions rates in some studies, as in Garousi's study~\cite{MLR1}. In our opinion, it reflected the research topic investigated, which was focused on the SE research area.
We identified 19 GL types used between the MLR studies investigated. The most common types were blog posts, web articles, and book chapters, produced mainly for SE Practitioners, Consultants or Companies, and Tool vendors. These findings show that studies using GL took advantage of evidence retrieved from the practice of SE. Furthermore, GL evidence is perceived as a benefit for several studies, for including different perspectives of traditional literature and the practice of SE~\cite{Williams:2019:Journal,Zhang:2020:ICSE,Kamei:SBES:2020}. This allows reducing the bias to the propensity for only studies reporting positive findings to be published, increase reviews’ comprehensiveness and timeliness, and foster a holistic view of available evidence~\cite{Paez:2017:Medicine}.
In our investigation, our findings show that beyond the GL evidence supported some findings of TL sources, its use contributed with exclusive evidence that would not exist if GL were not investigated. It shows the importance of GL to address topics that are missing from TL sources~\cite{Sumeer:2020}.
Considering the study of Verdecchia et al.~\cite{MLR3}, if they did not consider GL, no library, architectural standards, and guidelines presented on Android apps would exist since all these findings were identified only in GL and through interviews with Android SE practitioners. Moreover, in some studies~\cite{MLR4,MLR6}, GL was the only type of source that had answers to some RQs (see Table~\ref{tab:mlr-studies-characteristics}). Thus, it shows the importance of GL evidence in contributing to the synthesis of MLR studies. Although in Garousi's study~\cite{MLR1} the inclusion of GL did not add anything different from what was found in TL. For this last study, we believe this happened because all GL included were produced in \textit{Academia} by professors or researchers.
Our investigation shows that GL has essential contributions to MLR studies by providing helpful content with recommendations, explanations, and several other contributions, although the empirical evidence is scarce. We identified that the evidence provided in MLR studies is mainly produced by SE practitioners, consultants or companies, and tool vendors. Our findings corroborate with Garousi et al.~\cite{Garousi:2016:EASE} as we found contributions related to practical solutions proposals, recommendations, opinions, or guidelines.
Previous studies investigated the types of GL sources used but not their producers. For instance, Zhang et al.~\cite{Zhang:2020:ICSE} investigated secondary studies and identified that the most common GL types used were technical reports, blog posts, books, and theses. Another tertiary study conducted by Yasin et al.~\cite{Yasin:Thesis:2020} investigated a different time-span (studies published until 2012) of our research. Our results were quite different because Yasin's study considered conference papers as a GL type. Neto et al.~\cite{Neto:2019:ESEM} also investigated MLR studies but did not investigate the amount of use for each GL type. Instead, they only mentioned that MLR studies included videos, whitepapers, books, web articles, magazine articles, blog posts, and technical reports.
\subsection{Challenges investigating Grey Literature contributions in MLR studies}
This section describes some challenges we faced to investigate the GL in MLR studies, with a possible way(s) to address each one.
The first challenge faced was to identify the GL sources included in MLR studies. This investigation in some studies was a time-consuming activity since some of them had hundreds of primary sources and some of the others did not classify the primary sources (e.g.,~\cite{MLR5}) or did not present their references (e.g.,~\cite{Saltan:IWSiB:2019,Eck:ESEC/FSE:2019}).
We recommended that SE researchers intending to conduct MLR studies to classify all primary studies/sources (TL or GL) for the first challenge. Moreover, we also recommended that GL be classified (e.g., blog post, book, theses). These recommendations are helpful for a more comprehensive understanding of GL use and to guide future researchers that may want to explore a specific GL source.
The second challenge is related to the lack of information about the GL. For instance, some essential pieces of information (e.g., the title of the source, URL, last accessed, name of the author(s), type of GL, type of producer) were not available for several GL sources in MLRs studies~\cite{MLR8,Saltan:IWSiB:2019,Eck:ESEC/FSE:2019}. This challenge precludes a better understanding of each GL source and answers our research questions. For this reason, we removed these studies~\cite{Saltan:IWSiB:2019,Eck:ESEC/FSE:2019} from our analysis, although they presented some important information about GL in their studies. For instance, Saltan~\cite{Saltan:IWSiB:2019} investigates challenges about flaky tests, mentioning the high number of relevant GL sources identified compared with TL sources, which shows that flaky test understanding is still scarce.
To address the second challenge, we recommended to the researchers include all the information available from GL sources. This information may be essential for the reader to better understand the GL source used and guide future research to a deep investigation of GL sources.
The third challenge relates to identifying and classifying contributions by GL use, which is a consequence of the first two challenges. For instance, it was not possible to conduct a deep investigation of the GL sources in two MLR studies~\cite{Saltan:IWSiB:2019,Eck:ESEC/FSE:2019}. Moreover, we perceived that the studies often did not highlight the differences between the findings from GL and TL.
One possible way to address the third challenge is following the Garousi et al.'s guidelines~\cite{Garousi:2019:IST} which recommended that the data extraction be conducted separated by the different types of source (GL and TL) and a balanced synthesis using sources with varying levels of rigor. In our opinion, another possibility is the synthesis highlight the differences between GL and TL, aiming to the reader understand how each type of primary source contributed to the study and the relevance of each piece of evidence presented.
\subsection{Limitations}
This section discusses the potential threats to the validity of our study and what we have done to minimize or mitigate them.
An internal threat of any qualitative investigation is related to the interpretation. The case of our research relates to how we interpret the contributions identified by GL use. As this activity involves personal understanding, to mitigate this threat, we followed a paired process during this research, and a third researcher revised the derived categories.
An external threat is related to the impossibility of precisely determining all GL use contributions because, in several MLR studies, both GL and TL were not referenced in the articles. We know that it is common to occur in any secondary studies, mainly in that study with several studies included. In some studies (e.g.,~\cite{Eck:ESEC/FSE:2019}) the list of primary sources was not available. We tried to mitigate this threat by sending mail to the studies. Another threat is related to our decision to select only MLR studies that followed Garousi's guidelines to investigate studies that followed a well-known process to conduct a multivocal review in SE. This decision might have introduced a bias in our findings, limiting the discussions' scope about the contribution and types of GL identified.
\section{Related Works}\label{sec:related_works}
GL investigations in SE research are particularly recent~\cite{Garousi:2016:EASE,Williams:2018:EASE}. In the context of studies that investigated MLRs studies, we found three studies~\cite{Kitchenham:2009:ESEM,Garousi:2016:EASE,Neto:2019:ESEM} that are more related to this research.
Kitchenham et al.~\cite{Kitchenham:2009:ESEM} conducted one of the first studies using the multivocal approach in SE, comparing the use of manual and automated searches and assessing the importance and breadth of GL. Their findings showed the importance of GL, especially to investigate research questions that need practical and technical answers. For instance, when comparing two technologies. Although they recognized that, in general, the quality of GL studies is lower than TL.
Garousi et al.~\cite{Garousi:2016:EASE} expanded the investigation of GL as a source of evidence for MLR studies in SE research, conducting two investigations. The first one presented a meta-analysis from three cases in which GL was used to understand what knowledge is missed when an SLR does not consider GL. The second one investigated three MLRs to understand what the community gains when conducting multivocal literature. The study highlighted the importance of using GL to cover technical research questions and be beneficial to practitioners, once the evidence is retrieved from the industry.
Neto and colleagues~\cite{Neto:2019:ESEM} investigated MLRs and GLRs studies through a tertiary study. Their research aimed to understand (i) the motivations to included GL (lack of academic research on the topic, practical evidence, emerging research on the topic), (ii) the types of GL used (videos, tools overview, blog posts, books, industrial journals, technical reports, and websites), and (iii) the search engines used, mainly focused on Google's regular search engine. They searched for the studies published between 2009 and 2019 using six academic search engines. From 56 studies returned, they selected 12.
Other studies were conducted to investigated GL in secondary studies, in general, not specifically focused on MLR studies~\cite{Yasin:Thesis:2020,Zhang:2020:ICSE}. The first one was conducted by Yasin et al.~\cite{Yasin:Thesis:2020} investigated the extent of GL use in secondary studies published until 2012 and the importance of Google Scholar to identify GL sources. In the period analyzed, the perceptions of GL in SE research and its types were different to nowadays. For instance, Yasin et al. considered workshop papers and conference proceedings as GL. These types and the technical reports were the common types identified in the investigated studies. Google Scholar was not considered a vital source to identify these sources. The second one was conducted by Zhang et al.~\cite{Zhang:2020:ICSE} that investigated GL through a tertiary study and survey research, focusing on understanding the GL definitions used in the studies and the types of GL used. The study did not identify a standard definition, and the most common GL types identified were technical reports, blog posts, books, and theses.
In SE research, few works investigated MLR studies to compare the contributions perceived by the use of GL and TL. For this reason, this research intends to expand and improve the knowledge in this regard, adding investigations and new explored topics. Our research differs from the previous ones by: (i) investigating all GL evidence included to understand and classify their contributions in MLR studies; and (ii) providing a process to support SE researchers that intend to investigate the contributions of GL in secondary studies.
\section{Conclusions and Future Work}\label{sec:conclusions}
In this paper, we conducted a tertiary study with MLR studies to better understand the GL and its contributions to these studies. We investigated a total of nine MLR studies that followed Garousi's guidelines.
Our analysis consisted of comparing the findings from GL and TL and analyzing and classifying their contributions in with each study. Our results are important to comprehend the impacts of GL use in MLR studies and increase the state-of-art by pilling additional evidence on this topic.
Our findings show that GL use stood out as an essential source to contribute with recommendations, explanations, solutions proposals, and opinions about a topic. Beyond permitting the state of the practice to be included in MLR studies, once most of the GL sources investigated were produced by SE practitioners, consultants or companies, and tool vendors.
We identified that several of these contributions were exclusively found in GL sources. Thus, if the studies did not consider GL, several findings would not have been introduced, making the results potential biased. Moreover, GL also supported several findings found in the TL.
This study has some implications for SE research. First, by describing the process used and the challenges we faced to investigate the GL usage contributions to MLR studies, we hope to help SE researchers to take advantage of this type of investigation. Moreover, we provided additional evidence to show how GL use contributed to MLR studies.
For future works, our intention includes expanding our view to MLR studies that did not follow Garousi's guidelines~\cite{garousi2017guidelines,Garousi:2019:IST}, to investigate MLR studies authors to understand their perceptions about GL use.
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2021-08-19T02:00:52', 'yymm': '2107', 'arxiv_id': '2107.05792', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05792'} | arxiv |
\section{Introduction}
One of the most relevant problems of the Brazilian educational system is the grade retention rate, demanding critical attention from politicians and the academic community \cite{schwartzman2004challenges}. Since there are many students who end up repeating a school year or even dropping out \cite{nunes2014fatores}, some social measures are needed to prevent this behavior. In this work, we quantify the predictive power of personality traits in predicting grade retention. Since personality traits data are not traditionally used to that end or not even collected, we can help researchers and policy makers deciding how beneficial it would be if they start using that kind of features in their predictive models.
\section{Objectives and motivation}
The main objective of this paper is to assess, from a machine learning perspective, the predictive power of students' personality traits called "facets" \cite{soto2009ten}, measured in 2012, in predicting grade retention between 2012 and 2017 in the city of Sertãozinho (São Paulo, Brazil). In 2012, students were in grades\footnote{4º, 5º and 6º "anos".} 4, 5, and 6. In this work, we consider a student suffered grade retention if he/she advanced less than five grades between 2012 and 2017. That could happen when a student fails, temporarily drop out or due to any other possible reason that could interfere in such matter.
To achieve our objective, we adopted two strategies. At first, we test the performance of machine learning models trained only over those personality traits data, that have been collected in 2012, at evaluating the risk of future grade retention, trying to assess the hypothesis that the personality features are predictive by themselves. Additionally, we test the effects of combining personality traits features with more conventional data, that usually includes academic, demographic, socioeconomic features (such as standardized tests, school type, being public or private, ethnicity, mother education). We do that in order to test if there is a gain in the predictive power of the models with the addition of those new features (the personality traits). As for the evaluation method of the models, we adopted the area under the Receiver Operating Characteristic curve (ROC AUC).
With that said, if we could verify our hypothesis that personality traits are indeed predictive for grade retention, it would be possible to implement more assertive tools, applied to the social context, making it possible to obtain more accurate measures of social vulnerability and having more precise interventions for avoiding grade retention among students, especially in developing countries.
\section{Ethical concerns}
Since this work intersects with the social sciences, it is needed to reinforce some details. First, we must say that using machine learning algorithms to support/make decisions in a social context can be dangerous if the tools are misused. Any policy maker that intends to apply that kind of tool in real situations should be aware of possible biases and discriminatory behaviour of those algorithms. As for the practical side, it is recommended that any institution willing to use this paper's results follows the Five Pillars of Artificial Intelligence (AI) Ethics regarding the use of AI in schools and Education \cite{southgate2019artificial}.
\section{Related work}
Previous research that tried to find correlations between grade retention and students' characteristics in the Brazilian educational context are not new in the literature. \citet{nunes2014fatores}, for example, found correlations between school failure and low expectations of academic prospects, and correlations between “good perceptions about the school" and better academic perspectives. \citet{ortigao2013repetencia} observed that doing homework and having family support while going to school are important factors associated with decreased risk of grade retention. Furthermore, \citet{caluz2018papel} described the relation between personality traits and grade retention using econometric modelling and a dataset similar to ours.
In our work, we add to the scientific literature by evaluating the statistical dependency of personality traits and grade retention from a machine learning perspective.
\section{Data}
The data used in this study was collected in the city Sertãozinho in the state of São Paulo - Brazil. The study was conducted by the “Laboratório de Estudos em Pesquisas e Economia Social" (LEPES/USP)\footnote{See \url{http://lepes.fearp.usp.br/}} and consists of field surveys with students in 2012 and the same students in 2017. In 2012, students were in grades\footnote{4º, 5º and 6º "anos".} 4, 5, and 6.
The information we used from the surveys can be split in two parts. The first part is a (i) personality test called Big Five Inventory, taken by students in 2012, which measured their scores in 10 “facets" presented in \citet{soto2009ten}, also described by \citet{piedmont1998revised}. The facets are: \textit{Activity}, \textit{Aesthetics}, \textit{Altruism}, \textit{Anxiety}, \textit{Assertiveness}, \textit{Compliance}, \textit{Depression}, \textit{Ideas}, \textit{Order}, and \textit{Self-Discipline}. The second part is composed by (ii) socioeconomic questions, that evaluate students' profiles in 2012 or in previous years, and mathematics and language standardized tests, taken by students in 2012. The tests were prepared using items of the National Institute for Educational Studies and Research Anísio Teixeira (INEP). A list with all the variables can be found in the supplementary material.
Our dataset in 2012 had roughly 4,900 students but only around 3,000 of them were interviewed in 2017. Moreover, considering that we only kept students with no missing information, our final analysis was made using 1888 subjects. Almost all students in 4$^{th}$ grade in 2012 were removed from the analysis, since most of them did not take the standardized tests due to bureaucratic reasons.
\section{Methods}
\subsection{Exploratory data analysis}
For the exploratory step, we performed an analysis of pairwise mutual information of grade retention and personality traits with test scores features. This analysis helps us to understand the statistical dependence of grade retention and the features of interest. We use the Scikit-Learn\footnote{See \url{https://scikit-learn.org/stable/modules/generated/sklearn.feature_selection.mutual_info_classif.html} - accessed in 29/06/2021.} implementation of mutual information estimation, which relies on a non-parametric estimation method to measure the dependence of two random variables.
\subsection{Evaluation using predictive modelling and K-fold cross-validation}
For the rest of the sections, we used a logistic regression model and a XGBoost \cite{chen2016xgboost} classifier to measure the personality traits' predictive power.
By performing a nested K-fold cross-validation procedure\footnote{Hyperparameter tuning details can be found in the supplementary material.} (outer $K=10$), we calculate the average AUC score using the $10$ iterations' test sets. We assess the models' performances in three cases: (i) using only the personality traits features (“Personalities only"), (ii) using all features other than personality traits (“Others only"), (iii) using the whole set of features. The first case will let us assess the predictive power of personality traits by their own, while the second and third cases will let us assess the predictive gain of adding personality traits to a set of more conventional features.
In order to draw error bars in our analysis, we employ the concept of standard error. Let $\textup{AUC}^{cv}$ be the vector containing AUC scores for each iteration of the outer K-fold cross-validation in the nested procedure. Thus, $\textup{AUC}^{cv}$ has length $K=10$. We use the following formula to estimate the standard error of our average AUC estimator:
\begin{equation}
\widehat{SE}(\textup{AUC}^{cv}) =\frac{\widehat{SD}(\textup{AUC}^{cv})}{\sqrt{K}}
\end{equation}
Where $\widehat{SE}$ is the estimated standard error, $\widehat{SD}$ is the $\textup{AUC}^{cv}$ sample standard deviation, and $K$ is the number of folds in the outer cross-validation loop ($K = 10$).
\subsection{Gain analysis for including personality traits to the “Others only" features set}
To get more confidence and reduce error bars through variance reduction, we analyse the average AUC gain and the gain error bar, calculated in a similar way done for the ROC AUC scores. That is, instead of estimating average AUC scores and then taking the difference, we first take the difference of the individual $K=10$ AUC scores and then calculate their average. This procedure returns exactly the same difference but with lower standard error\footnote{This is an idea inspired by paired hypothesis tests, e.g., paired t-test.}. This is a valid approach since training and test sets are always the same in all combinations of features' sets and models in each of the $K=10$ iterations.
To identify whether this gain was significant we performed a paired one-tailed Student's t-test. In supplementary material, we tested pre-requisites of t-tests to verify if they are valid in our case.
\section{Results}
\subsection{Mutual information}
We applied mutual information analysis to our data (Figure \ref{fig:MutualInfo}). Given that the used method depends on a random seed, we repeated this experiment 100 times and then recorded the average mutual information and standard deviation.
Depression and Ideas have shown the biggest dependencies with grade retention alongside with Language and Mathematics. Three personality traits (Aesthetics, Compliance and Self-discipline) showed little dependence with grade retention.
\begin{figure}[h!]
\centering
\includegraphics[width=0.48\textwidth]{figs/MutualInfo.png}
\caption{Average pairwise mutual information in Nats ($\pm$ standard deviation) of grade retention and one of the personality traits or test scores.}
\label{fig:MutualInfo}
\end{figure}
\subsection{Evaluation using predictive modelling and K-fold cross-validation}
One can see in Figure \ref{fig:AUC bar plot} the bar plots of average cross-validation AUCs combining three sets of features (Personalities only, Others Only and All features) and two models (logistic regression and XGBoost classifier). It's notable that, in general, the logistic regression model performed better than XGBoost.
In parallel, we see that for both types of models, the average AUC scores in the case of “Personalities only" reveal that, on average, the models performed fairly better than a random classifier, with scores that range from 0.60 to nearly 0.65. However, a clear result is that, in both logistic regression and XGBoost models, by adding personality traits to the “Others only" features set, we have a relatively good gain in the average AUC scores. In the following subsection, we will go into more details, with an analysis of this gain.
\begin{figure}[h!]
\centering
\includegraphics[width=0.435\textwidth]{figs/barplotauc.png}
\caption{Bar plots of average cross-validation AUCs ($\pm$ standard error) with $K=10$. We combined three sets of features (Personalities only, Others Only and All features) and two models (logistic regression and XGBoost classifier). The red line displays the maximum average ROC AUC score achieved.}
\label{fig:AUC bar plot}
\end{figure}
It is worth mentioning that, when looking at the error bars for both the “Others Only" and “All Features" features sets in Figure \ref{fig:AUC bar plot}, the gain is somewhat uncertain because the error bars intersect each other, leaving a margin for misinterpretation. For this reason we perform a analysis over the AUC gains.
\subsection{Gain analysis for including personality traits to the “Others only" features set}
The average AUC gains and their standard errors are represented in Table \ref{ttest}. Since the errors are lower than the average AUC gains, we can increase our confidence that there is an actual gain in performance with the inclusion of the personality traits to the “Others only" features set.
The p-values in Table \ref{ttest} are obtained in a t-test. The hypotheses tested are: $H_0$ (that there is no average AUC gain by including personality traits to the “Others only" features set) and $H_1$ (that there is a positive gain). Since the p-value of the test in the logistic regression case is lower than 0.025, the null hypothesis $H_0$ can be rejected considering 5\% of significance. Considering XGBoost result, $H_0$ can be rejected considering a test of size 10\%. Thus, we have good reasons to think that the AUC gain by including personality traits to the “Others only" features set is positive.
\begin{table}[h]
\centering
\caption{Average AUC gain by including personality traits to the “Others only" features set. The p-values are calculated according to the hypotheses $H_0$ (that there is no average AUC gain by including personality traits to the “Others only" features set) and $H_1$ (that there is a positive gain). We have good evidence that the average AUC gain is positive.}
\medskip
\begin{tabular}{c|c|c|c}
\toprule
Model&Avg. AUC Gain & Std. error & p-value \\
\midrule
Log. Reg. &$0.025$& $0.011$ & $0.023$ \\[.25em]
XGBoost & $0.026$ & $0.015$ & $0.057$ \\
\bottomrule
\end{tabular}%
\label{ttest}%
\end{table}%
Moreover, both logistic regression and XGBoost present average AUC gains around 0.025. That is an good increase relatively speaking, i.e., if we look at the logistic regression “Others Only" and “All Features" average scores, one can see it increased from approximately 0.7 to 0.725. Considering the minimum ROC AUC scores acceptable for machine learning models as being 0.5, we get that the increase was around $\frac{0.725-0.7}{0.7-0.5}=10\%$. The relative gain is even greater considering XGBoost.
\section{Conclusion}
In this work, we measure the predictive power of personality traits when predicting grade retention of Brazilian students. The use of personality traits to that end can assist more accurate public policies focused on decreasing grade retention rates, and it opens a window for further research to explore the gain of using those features as predictors. Our results show that we can use personality traits, besides socioeconomic indices and test scores, to have better machine learning models when predicting grade retention.
Future works might explore the policy of "progressão continuada"\footnote{Similar to automatic promotion. See \url{https://learningportal.iiep.unesco.org/en/glossary/automatic-promotion}}, which tries to lower evasion rates in Brazilian schools. It could be the case that some Sertãozinho's schools adopt that policy, and developing the analysis using this fact can lead to new discoveries. Also, breaking down the "Other only" features set can uncover insights in the future.
Due to privacy reasons, we cannot share the dataset. The supplementary material and code can be found in \url{https://github.com/Lucka-Gianvechio/LatinX-Grade-Retention-Paper}.
\section{Acknowledgements}
We would like to thank the “Laboratório de Estudos em Pesquisas e Economia Social" (LEPES/USP) for sharing the dataset, and "Conselho Nacional de Desenvolvimento Científico e Tecnológico" (CNPq) for financially supporting Felipe during his master's degree.
\section{Electronic Submission}
\label{submission}
Submission to ICML 2021 will be entirely electronic, via a web site
(not email). Information about the submission process and \LaTeX\ templates
are available on the conference web site at:
\begin{center}
\textbf{\texttt{http://icml.cc/}}
\end{center}
The guidelines below will be enforced for initial submissions and
camera-ready copies. Here is a brief summary:
\begin{itemize}
\item Submissions must be in PDF\@.
\item Submitted papers can be up to eight pages long, not including references, plus unlimited space for references. Accepted papers can be up to nine pages long, not including references, to allow authors to address reviewer comments. Any paper exceeding this length will automatically be rejected.
\item \textbf{Do not include author information or acknowledgements} in your
initial submission.
\item Your paper should be in \textbf{10 point Times font}.
\item Make sure your PDF file only uses Type-1 fonts.
\item Place figure captions \emph{under} the figure (and omit titles from inside
the graphic file itself). Place table captions \emph{over} the table.
\item References must include page numbers whenever possible and be as complete
as possible. Place multiple citations in chronological order.
\item Do not alter the style template; in particular, do not compress the paper
format by reducing the vertical spaces.
\item Keep your abstract brief and self-contained, one paragraph and roughly
4--6 sentences. Gross violations will require correction at the
camera-ready phase. The title should have content words capitalized.
\end{itemize}
\subsection{Submitting Papers}
\textbf{Paper Deadline:} The deadline for paper submission that is
advertised on the conference website is strict. If your full,
anonymized, submission does not reach us on time, it will not be
considered for publication.
\textbf{Anonymous Submission:} ICML uses double-blind review: no identifying
author information may appear on the title page or in the paper
itself. Section~\ref{author info} gives further details.
\textbf{Simultaneous Submission:} ICML will not accept any paper which,
at the time of submission, is under review for another conference or
has already been published. This policy also applies to papers that
overlap substantially in technical content with conference papers
under review or previously published. ICML submissions must not be
submitted to other conferences and journals during ICML's review
period.
Informal publications, such as technical
reports or papers in workshop proceedings which do not appear in
print, do not fall under these restrictions.
\medskip
Authors must provide their manuscripts in \textbf{PDF} format.
Furthermore, please make sure that files contain only embedded Type-1 fonts
(e.g.,~using the program \texttt{pdffonts} in linux or using
File/DocumentProperties/Fonts in Acrobat). Other fonts (like Type-3)
might come from graphics files imported into the document.
Authors using \textbf{Word} must convert their document to PDF\@. Most
of the latest versions of Word have the facility to do this
automatically. Submissions will not be accepted in Word format or any
format other than PDF\@. Really. We're not joking. Don't send Word.
Those who use \textbf{\LaTeX} should avoid including Type-3 fonts.
Those using \texttt{latex} and \texttt{dvips} may need the following
two commands:
{\footnotesize
\begin{verbatim}
dvips -Ppdf -tletter -G0 -o paper.ps paper.dvi
ps2pdf paper.ps
\end{verbatim}}
It is a zero following the ``-G'', which tells dvips to use
the config.pdf file. Newer \TeX\ distributions don't always need this
option.
Using \texttt{pdflatex} rather than \texttt{latex}, often gives better
results. This program avoids the Type-3 font problem, and supports more
advanced features in the \texttt{microtype} package.
\textbf{Graphics files} should be a reasonable size, and included from
an appropriate format. Use vector formats (.eps/.pdf) for plots,
lossless bitmap formats (.png) for raster graphics with sharp lines, and
jpeg for photo-like images.
The style file uses the \texttt{hyperref} package to make clickable
links in documents. If this causes problems for you, add
\texttt{nohyperref} as one of the options to the \texttt{icml2021}
usepackage statement.
\subsection{Submitting Final Camera-Ready Copy}
The final versions of papers accepted for publication should follow the
same format and naming convention as initial submissions, except that
author information (names and affiliations) should be given. See
Section~\ref{final author} for formatting instructions.
The footnote, ``Preliminary work. Under review by the International
Conference on Machine Learning (ICML). Do not distribute.'' must be
modified to ``\textit{Proceedings of the
$\mathit{38}^{th}$ International Conference on Machine Learning},
Online, PMLR 139, 2021.
Copyright 2021 by the author(s).''
For those using the \textbf{\LaTeX} style file, this change (and others) is
handled automatically by simply changing
$\mathtt{\backslash usepackage\{icml2021\}}$ to
$$\mathtt{\backslash usepackage[accepted]\{icml2021\}}$$
Authors using \textbf{Word} must edit the
footnote on the first page of the document themselves.
Camera-ready copies should have the title of the paper as running head
on each page except the first one. The running title consists of a
single line centered above a horizontal rule which is $1$~point thick.
The running head should be centered, bold and in $9$~point type. The
rule should be $10$~points above the main text. For those using the
\textbf{\LaTeX} style file, the original title is automatically set as running
head using the \texttt{fancyhdr} package which is included in the ICML
2021 style file package. In case that the original title exceeds the
size restrictions, a shorter form can be supplied by using
\verb|\icmltitlerunning{...}|
just before $\mathtt{\backslash begin\{document\}}$.
Authors using \textbf{Word} must edit the header of the document themselves.
\section{Format of the Paper}
All submissions must follow the specified format.
\subsection{Dimensions}
The text of the paper should be formatted in two columns, with an
overall width of 6.75~inches, height of 9.0~inches, and 0.25~inches
between the columns. The left margin should be 0.75~inches and the top
margin 1.0~inch (2.54~cm). The right and bottom margins will depend on
whether you print on US letter or A4 paper, but all final versions
must be produced for US letter size.
The paper body should be set in 10~point type with a vertical spacing
of 11~points. Please use Times typeface throughout the text.
\subsection{Title}
The paper title should be set in 14~point bold type and centered
between two horizontal rules that are 1~point thick, with 1.0~inch
between the top rule and the top edge of the page. Capitalize the
first letter of content words and put the rest of the title in lower
case.
\subsection{Author Information for Submission}
\label{author info}
ICML uses double-blind review, so author information must not appear. If
you are using \LaTeX\/ and the \texttt{icml2021.sty} file, use
\verb+\icmlauthor{...}+ to specify authors and \verb+\icmlaffiliation{...}+ to specify affiliations. (Read the TeX code used to produce this document for an example usage.) The author information
will not be printed unless \texttt{accepted} is passed as an argument to the
style file.
Submissions that include the author information will not
be reviewed.
\subsubsection{Self-Citations}
If you are citing published papers for which you are an author, refer
to yourself in the third person. In particular, do not use phrases
that reveal your identity (e.g., ``in previous work \cite{langley00}, we
have shown \ldots'').
Do not anonymize citations in the reference section. The only exception are manuscripts that are
not yet published (e.g., under submission). If you choose to refer to
such unpublished manuscripts \cite{anonymous}, anonymized copies have
to be submitted
as Supplementary Material via CMT\@. However, keep in mind that an ICML
paper should be self contained and should contain sufficient detail
for the reviewers to evaluate the work. In particular, reviewers are
not required to look at the Supplementary Material when writing their
review.
\subsubsection{Camera-Ready Author Information}
\label{final author}
If a paper is accepted, a final camera-ready copy must be prepared.
For camera-ready papers, author information should start 0.3~inches below the
bottom rule surrounding the title. The authors' names should appear in 10~point
bold type, in a row, separated by white space, and centered. Author names should
not be broken across lines. Unbolded superscripted numbers, starting 1, should
be used to refer to affiliations.
Affiliations should be numbered in the order of appearance. A single footnote
block of text should be used to list all the affiliations. (Academic
affiliations should list Department, University, City, State/Region, Country.
Similarly for industrial affiliations.)
Each distinct affiliations should be listed once. If an author has multiple
affiliations, multiple superscripts should be placed after the name, separated
by thin spaces. If the authors would like to highlight equal contribution by
multiple first authors, those authors should have an asterisk placed after their
name in superscript, and the term ``\textsuperscript{*}Equal contribution"
should be placed in the footnote block ahead of the list of affiliations. A
list of corresponding authors and their emails (in the format Full Name
\textless{}email@domain.com\textgreater{}) can follow the list of affiliations.
Ideally only one or two names should be listed.
A sample file with author names is included in the ICML2021 style file
package. Turn on the \texttt{[accepted]} option to the stylefile to
see the names rendered. All of the guidelines above are implemented
by the \LaTeX\ style file.
\subsection{Abstract}
The paper abstract should begin in the left column, 0.4~inches below the final
address. The heading `Abstract' should be centered, bold, and in 11~point type.
The abstract body should use 10~point type, with a vertical spacing of
11~points, and should be indented 0.25~inches more than normal on left-hand and
right-hand margins. Insert 0.4~inches of blank space after the body. Keep your
abstract brief and self-contained, limiting it to one paragraph and roughly 4--6
sentences. Gross violations will require correction at the camera-ready phase.
\subsection{Partitioning the Text}
You should organize your paper into sections and paragraphs to help
readers place a structure on the material and understand its
contributions.
\subsubsection{Sections and Subsections}
Section headings should be numbered, flush left, and set in 11~pt bold
type with the content words capitalized. Leave 0.25~inches of space
before the heading and 0.15~inches after the heading.
Similarly, subsection headings should be numbered, flush left, and set
in 10~pt bold type with the content words capitalized. Leave
0.2~inches of space before the heading and 0.13~inches afterward.
Finally, subsubsection headings should be numbered, flush left, and
set in 10~pt small caps with the content words capitalized. Leave
0.18~inches of space before the heading and 0.1~inches after the
heading.
Please use no more than three levels of headings.
\subsubsection{Paragraphs and Footnotes}
Within each section or subsection, you should further partition the
paper into paragraphs. Do not indent the first line of a given
paragraph, but insert a blank line between succeeding ones.
You can use footnotes\footnote{Footnotes
should be complete sentences.} to provide readers with additional
information about a topic without interrupting the flow of the paper.
Indicate footnotes with a number in the text where the point is most
relevant. Place the footnote in 9~point type at the bottom of the
column in which it appears. Precede the first footnote in a column
with a horizontal rule of 0.8~inches.\footnote{Multiple footnotes can
appear in each column, in the same order as they appear in the text,
but spread them across columns and pages if possible.}
\begin{figure}[ht]
\vskip 0.2in
\begin{center}
\centerline{\includegraphics[width=\columnwidth]{icml_numpapers}}
\caption{Historical locations and number of accepted papers for International
Machine Learning Conferences (ICML 1993 -- ICML 2008) and International
Workshops on Machine Learning (ML 1988 -- ML 1992). At the time this figure was
produced, the number of accepted papers for ICML 2008 was unknown and instead
estimated.}
\label{icml-historical}
\end{center}
\vskip -0.2in
\end{figure}
\subsection{Figures}
You may want to include figures in the paper to illustrate
your approach and results. Such artwork should be centered,
legible, and separated from the text. Lines should be dark and at
least 0.5~points thick for purposes of reproduction, and text should
not appear on a gray background.
Label all distinct components of each figure. If the figure takes the
form of a graph, then give a name for each axis and include a legend
that briefly describes each curve. Do not include a title inside the
figure; instead, the caption should serve this function.
Number figures sequentially, placing the figure number and caption
\emph{after} the graphics, with at least 0.1~inches of space before
the caption and 0.1~inches after it, as in
Figure~\ref{icml-historical}. The figure caption should be set in
9~point type and centered unless it runs two or more lines, in which
case it should be flush left. You may float figures to the top or
bottom of a column, and you may set wide figures across both columns
(use the environment \texttt{figure*} in \LaTeX). Always place
two-column figures at the top or bottom of the page.
\subsection{Algorithms}
If you are using \LaTeX, please use the ``algorithm'' and ``algorithmic''
environments to format pseudocode. These require
the corresponding stylefiles, algorithm.sty and
algorithmic.sty, which are supplied with this package.
Algorithm~\ref{alg:example} shows an example.
\begin{algorithm}[tb]
\caption{Bubble Sort}
\label{alg:example}
\begin{algorithmic}
\STATE {\bfseries Input:} data $x_i$, size $m$
\REPEAT
\STATE Initialize $noChange = true$.
\FOR{$i=1$ {\bfseries to} $m-1$}
\IF{$x_i > x_{i+1}$}
\STATE Swap $x_i$ and $x_{i+1}$
\STATE $noChange = false$
\ENDIF
\ENDFOR
\UNTIL{$noChange$ is $true$}
\end{algorithmic}
\end{algorithm}
\subsection{Tables}
You may also want to include tables that summarize material. Like
figures, these should be centered, legible, and numbered consecutively.
However, place the title \emph{above} the table with at least
0.1~inches of space before the title and the same after it, as in
Table~\ref{sample-table}. The table title should be set in 9~point
type and centered unless it runs two or more lines, in which case it
should be flush left.
\begin{table}[t]
\caption{Classification accuracies for naive Bayes and flexible
Bayes on various data sets.}
\label{sample-table}
\vskip 0.15in
\begin{center}
\begin{small}
\begin{sc}
\begin{tabular}{lcccr}
\toprule
Data set & Naive & Flexible & Better? \\
\midrule
Breast & 95.9$\pm$ 0.2& 96.7$\pm$ 0.2& $\surd$ \\
Cleveland & 83.3$\pm$ 0.6& 80.0$\pm$ 0.6& $\times$\\
Glass2 & 61.9$\pm$ 1.4& 83.8$\pm$ 0.7& $\surd$ \\
Credit & 74.8$\pm$ 0.5& 78.3$\pm$ 0.6& \\
Horse & 73.3$\pm$ 0.9& 69.7$\pm$ 1.0& $\times$\\
Meta & 67.1$\pm$ 0.6& 76.5$\pm$ 0.5& $\surd$ \\
Pima & 75.1$\pm$ 0.6& 73.9$\pm$ 0.5& \\
Vehicle & 44.9$\pm$ 0.6& 61.5$\pm$ 0.4& $\surd$ \\
\bottomrule
\end{tabular}
\end{sc}
\end{small}
\end{center}
\vskip -0.1in
\end{table}
Tables contain textual material, whereas figures contain graphical material.
Specify the contents of each row and column in the table's topmost
row. Again, you may float tables to a column's top or bottom, and set
wide tables across both columns. Place two-column tables at the
top or bottom of the page.
\subsection{Citations and References}
Please use APA reference format regardless of your formatter
or word processor. If you rely on the \LaTeX\/ bibliographic
facility, use \texttt{natbib.sty} and \texttt{icml2021.bst}
included in the style-file package to obtain this format.
Citations within the text should include the authors' last names and
year. If the authors' names are included in the sentence, place only
the year in parentheses, for example when referencing Arthur Samuel's
pioneering work \yrcite{Samuel59}. Otherwise place the entire
reference in parentheses with the authors and year separated by a
comma \cite{Samuel59}. List multiple references separated by
semicolons \cite{kearns89,Samuel59,mitchell80}. Use the `et~al.'
construct only for citations with three or more authors or after
listing all authors to a publication in an earlier reference \cite{MachineLearningI}.
Authors should cite their own work in the third person
in the initial version of their paper submitted for blind review.
Please refer to Section~\ref{author info} for detailed instructions on how to
cite your own papers.
Use an unnumbered first-level section heading for the references, and use a
hanging indent style, with the first line of the reference flush against the
left margin and subsequent lines indented by 10 points. The references at the
end of this document give examples for journal articles \cite{Samuel59},
conference publications \cite{langley00}, book chapters \cite{Newell81}, books
\cite{DudaHart2nd}, edited volumes \cite{MachineLearningI}, technical reports
\cite{mitchell80}, and dissertations \cite{kearns89}.
Alphabetize references by the surnames of the first authors, with
single author entries preceding multiple author entries. Order
references for the same authors by year of publication, with the
earliest first. Make sure that each reference includes all relevant
information (e.g., page numbers).
Please put some effort into making references complete, presentable, and
consistent. If using bibtex, please protect capital letters of names and
abbreviations in titles, for example, use \{B\}ayesian or \{L\}ipschitz
in your .bib file.
\section*{Software and Data}
If a paper is accepted, we strongly encourage the publication of software and data with the
camera-ready version of the paper whenever appropriate. This can be
done by including a URL in the camera-ready copy. However, \textbf{do not}
include URLs that reveal your institution or identity in your
submission for review. Instead, provide an anonymous URL or upload
the material as ``Supplementary Material'' into the CMT reviewing
system. Note that reviewers are not required to look at this material
when writing their review.
\section*{Acknowledgements}
\textbf{Do not} include acknowledgements in the initial version of
the paper submitted for blind review.
If a paper is accepted, the final camera-ready version can (and
probably should) include acknowledgements. In this case, please
place such acknowledgements in an unnumbered section at the
end of the paper. Typically, this will include thanks to reviewers
who gave useful comments, to colleagues who contributed to the ideas,
and to funding agencies and corporate sponsors that provided financial
support.
\nocite{langley00}
| {'timestamp': '2021-07-14T02:06:06', 'yymm': '2107', 'arxiv_id': '2107.05767', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05767'} | arxiv |
\section{Additional Results}
\paragraph{Counter Examples} For classwise calibration, construct a very simple example where a prediction function is classwise calibrated but not decision calibrated. In particular, consider ${\mathcal{Y}} = \lbrace 0, 1, 2 \rbrace$ and ${\mathcal{A}} = \lbrace 0, 1, 2 \rbrace$. The loss matrix is given by
\begin{align*}
\ell(y, a) = \left( \begin{array}{ccc} 0 & -1000 & -1 \\ -1 & 0 & -1000 \\ -1000 & -1 & 0 \end{array} \right)
\end{align*}
In words, there is a big loss if (y, a) = (0,1), (1, 2) or (2,0) and only a small loss for other types of errors. Consider the prediction function with calibration diagram in Figure~\ref{fig:classwise_example}. Both scenarios are classwise calibrated, but the corresponding (true) decision loss can be drastically different.
\begin{figure}
\centering
\includegraphics[width=0.7\linewidth]{plot/classwise_calibration}
\caption{Classwise Calibration counter example}
\label{fig:classwise_example}
\end{figure}
A forecaster that is classwise calibrated might not be calibrated for a coarsened class (e.g. construct a new classifier where the class poodle and retriever are merged into the same class dog). In the probability simplex this corresponds to orthogonal projection. For example, suppose there are four classes A,B,C,D. when $p(A \mid X) = 0.1$ we always have under ${\hat{p}}$ $A=0.1,B=0.0$ and when ${\hat{p}}(A \mid X) = 0.1$ we always have under ${\hat{p}}$ $A=0.0, B=0.1$, but under $p^*$ $A=0.1, B=0.1$. It is possible to construct such a prediction function that satisfies classwise calibration if there are at least four classes. However if we merge $A,B$ then ${\hat{p}}(\lbrace A, B \rbrace \mid X) = 0.1$ we have $p^*(\lbrace A, B \rbrace \mid X) = 0.2$. This is no longer classwise calibrated.
A forecaster that is confidence calibrated might not be calibrated for a coarsened class.
\subsection{Ideas}
In a cancer risk prediction, a image could be classified by different risk groups. There is a provider that offers the prediction function. The loss function depends on the treatment/diagnosis options available at a location or time period. For example, maybe the introduction of a new imaging device could reduce the cost of a false positive: what previous requires an invasive procedure now only requires a easier test. The prediction function does not have to be adjusted depending on the loss function. Instead all the hospitals that use the prediction can know that the computed decision loss equals the true decision loss.
The loss could depend on some additional variable $U$ but the requirement is that $U$ should be independent of $X$. Often this requires a leap of faith and the assumptions are only approximately true. For example, the prediction of medical images should be independent of the socio-economic status of a person; the prediction of traffic sign in autonomous driving should be independent of the
Suppose there is some "safe" action $a_0$ (such as a conservative treatment, or querying a human) such that $\forall y \in {\mathcal{Y}}$ we have $\ell(y, a_0) \geq c$. Then we know that if the prediction function is calibrated, then
\begin{align*}
{\mathbb{E}}[\ell(Y, \delta_*(X))] = {\mathbb{E}}[\ell({\hat{Y}}, \delta_*(X))] \geq \inf_y \ell(y, a_0) \geq c
\end{align*}
\section{Additional Experiment Details and Results}
\label{appendix:experiment}
Additional experiments are shown in Figure~\ref{fig:ham_additional} and Figure~\ref{fig:imagenet_additional}. The observations are similar to those in the main paper.
\begin{figure}
\centering
\begin{tabular}{c}
\includegraphics[width=0.9\linewidth]{plot/ham_result_2-7_2.png} \\
\includegraphics[width=0.9\linewidth]{plot/ham_result_2-8_5.png}
\end{tabular}
\caption{Additional Results on the HAM10000 for 2 and 5 actions. The observations are similar to Figure~\ref{fig:ham_main_result} even though overfitting happens sooner with 5 actions}
\label{fig:ham_additional}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=1.0\linewidth]{plot/calibrate_decision_imagenet_resnet18_3.png}
\caption{Additional results on the resnet18. The observations are similar to Figure~\ref{fig:imagenet_inception}: decision recalibration improves the loss gap.}
\label{fig:imagenet_additional}
\end{figure}
\subsection{From Decision Calibration to Distribution Calibration}
\label{appendix:dec2dist}
\label{appendix:proof_dec2dist}
\dectodist*
\begin{proof}[Proof of Proposition~\ref{thm:dec2dist}]
First we observe from Proposition~\ref{prop:decision_equivalence} that if a predictor ${\hat{p}}$ is ${\mathcal{L}}^K$-decision calibrated, then for all $a \in [K]$ such that $\lbrace x, \delta_\ell({\hat{p}}(x)) = a \rbrace$ has non-zero probability,
\begin{align*}
{\mathbb{E}}_X{\mathbb{E}}_{\hat{Y} \sim {\hat{p}}(X)}[\hat{Y} \mid \delta_\ell({\hat{p}}(X)) = a] = {\mathbb{E}}_X{\mathbb{E}}_{Y \sim p^*(X)}[Y \mid \delta_\ell({\hat{p}}(X)) = a] \numberthis\label{eq:equal_conditioned}
\end{align*}
We now show a simple compression scheme that achieves the properties required for Proposition~\ref{thm:dec2dist}.
Given a loss $\ell \in {\mathcal{L}}^K$, we compress the predictions along the partitions defined by $\delta_\ell$.
Suppose ${\hat{p}}$ is ${\mathcal{L}}^K$-decision calibrated.
For a fixed loss $\ell \in {\mathcal{L}}^K$, consider the following predictor ${\hat{p}}_\ell$ that arises by compressing ${\hat{p}}$ according to the optimal decision rule $\delta_\ell$.
\begin{align*}
{\hat{p}}_\ell(x) = {\mathbb{E}}_X[{\hat{p}}(X) \mid \delta_\ell({\hat{p}}(X)) = \delta_\ell({\hat{p}}(x))]
\end{align*}
First, note that by averaging over each set $\lbrace x, \delta_\ell({\hat{p}}(x) = a) \rbrace$, the support size of ${\hat{p}}_\ell$ is bounded by at most $K$.
Next, we note that by construction and Eq.(\ref{eq:equal_conditioned}), ${\hat{p}}_\ell$ is distribution calibrated.
To see this, consider each $q \in \Delta^C$ supported by ${\hat{p}}_\ell$; for each $q$, there is some optimal action $a_q \in [K]$.
That is, the sets $\{x : {\hat{p}}_\ell(x) = q\} = \{x : \delta_\ell({\hat{p}}(x)) = a_q\}$ are the same.
Distribution calibration follows.
\begin{align*}
{\mathbb{E}}_X{\mathbb{E}}_{Y \sim p^*(X)}[Y \mid {\hat{p}}_\ell(X) = q]
&= {\mathbb{E}}_X{\mathbb{E}}_{Y \sim p^*(X)}[Y \mid \delta_\ell({\hat{p}}(X)) = a_q]\\
&= {\mathbb{E}}_X{\mathbb{E}}_{\hat{Y} \sim {\hat{p}}_\ell(X)}[\hat{Y} \mid \delta_\ell({\hat{p}}(X)) = a_q]\\
&= {\mathbb{E}}_X{\mathbb{E}}_{\hat{Y} \sim {\hat{p}}_\ell(X)}[\hat{Y} \mid {\hat{p}}_\ell(X) = q]\\
&= q
\end{align*}
Finally, it remains to show that the optimal decision rule resulting from ${\hat{p}}_\ell$ and ${\hat{p}}$ are the same, pointwise for all $x \in {\mathcal{X}}$.
As an immediate corollary, the expected loss using ${\hat{p}}_\ell$ and ${\hat{p}}$ is the same.
We show that the decision rule will be preserved by the fact that for each $x \in {\mathcal{X}}$, the compressed prediction is a convex combination of predictions that gave rise to the same optimal action.
Specifically, consider any $x$ such that ${\hat{p}}_\ell(x) = q$.
By the argument above, there is some action $a_q \in [K]$ that is optimal for all such $x$.
Optimality implies that for all $a \in [K]$
\begin{align*}
\langle \ell_{a_q} , {\hat{p}}(x) \rangle \le \langle \ell_a, {\hat{p}}(x) \rangle.
\end{align*}
Thus, by linearity of expectation, averaging over $\{x : {\hat{p}}_\ell(x) = q\}$, the optimal action $a_q$ is preserved.
\begin{align*}
\langle \ell_{a_q} , q \rangle &= \langle \ell_{a_q} , {\mathbb{E}}[{\hat{p}}(X) \mid \delta_\ell({\hat{p}}(X)) = a_q] \rangle\\
&= {\mathbb{E}}[\langle \ell_{a_q}, {\hat{p}}(X) \rangle \mid \delta_\ell({\hat{p}}(X)) = a_q]\\
&\le {\mathbb{E}}[\langle \ell_a, {\hat{p}}(X) \rangle \mid \delta_\ell({\hat{p}}(X)) = a_q]\\
&= \langle \ell_a , {\mathbb{E}}[{\hat{p}}(X) \mid \delta_\ell({\hat{p}}(X)) = a_q] \rangle\\
&= \langle \ell_a, q \rangle
\end{align*}
Thus, the optimal action is preserved for all $x \in {\mathcal{X}}$.
\end{proof}
\section{Proofs}
\label{appendix:proof}
\subsection{Equivalence between Decision Calibration and Existing Notions of Calibration}
\thmequivalence*
\begin{proof}[Proof of Theorem~\ref{thm:equivalence}, part 1]
Before the proof we first need a technical Lemma
\begin{lemma}\label{lemma:conditional_exp}
For any pair of random variables $U, V$, ${\mathbb{E}}[U \mid V] = 0$ almost surely if and only if $\forall c \in \mathbb{R}, {\mathbb{E}}[U \mathbb{I}(V > c)] = 0$.
\end{lemma}
\textbf{Part 1} When the loss function is $\ell: y, a \mapsto \mathbb{I}(y \neq a \cap a \neq \bot) + \beta \mathbb{I}(a = \bot)$, the Bayes decision is given by
\begin{align*}
\delta_\ell(x) = \left\lbrace \begin{array}{ll} \arg\max {\hat{p}}(x) & \max {\hat{p}}(x) > 1-\beta \\ \bot & \text{otherwise} \end{array}\right.
\end{align*}
Denote $U= \max {\hat{p}}(X)$ and $V = \arg\max {\hat{p}}(X)$.
For any pair of loss functions $\ell$ and $\ell'$ parameterized by $\beta$ and $\beta'$ we have
\begin{align*}
&{\mathbb{E}}[\ell'(Y, \delta_{\ell}(X))] - {\mathbb{E}}[\ell'({\hat{Y}}, \delta_{\ell}(X))] \\
&= {\mathbb{E}}[(\ell'(Y, \bot) - \ell'({\hat{Y}}, \bot)) \mathbb{I}(\delta_{\ell}(X) = \bot)] + {\mathbb{E}}[(\ell'(Y, \delta_{\ell}(X)) - \ell'({\hat{Y}}, \delta_{\ell}(X))) \mathbb{I}( \delta_{\ell}(X) \neq \bot)] & \text{Tower} \\
&= 0 + {\mathbb{E}}[(p^*_{V}(X) - {\hat{p}}_{V}(X)) \mathbb{I}( \max {\hat{p}}(x) > 1-\beta )] & \text{Def of } \ell \\
&= {\mathbb{E}}[(p^*_{V}(X) - U) \mathbb{I}(U > 1-\beta)]
\end{align*}
Suppose ${\hat{p}}$ is confidence calibrated, then almost surely
\begin{align*}
U = \Pr[Y = \arg\max {\hat{p}}(X) \mid U] = {\mathbb{E}}[p^*_{V}(X) \mid U]
\end{align*}
which implies almost surely
$
{\mathbb{E}}[p^*_{V}(X) - U \mid U] = 0
$.
By Lemma~\ref{lemma:conditional_exp} we can conclude that
\begin{align*}
0 = {\mathbb{E}}[(p^*_{V}(X) - U) \mathbb{I}(U > 1-\beta)] = {\mathbb{E}}[\ell'(Y, \delta_\ell(X))] - {\mathbb{E}}[\ell'({\hat{Y}}, \delta_\ell(X))]
\end{align*}
so ${\hat{p}}$ is $L_r$-weakly calibrated.
Conversely suppose ${\hat{p}}$ is $L_r$ weakly calibrated, then $\forall \beta \in [0, 1]$,
$
{\mathbb{E}}[(p^*_{V}(X) - U) \mathbb{I}(U > 1-\beta)] = 0
$. By Lemma~\ref{lemma:conditional_exp} we can conclude that almost surely
\begin{align*}
0 = {\mathbb{E}}[p^*_{V}(X) - U \mid U] = {\mathbb{E}}[p^*_{V}(X) \mid U] - U
\end{align*}
so ${\hat{p}}$ is confidence calibrated.
\textbf{Part 2} For any loss function $\ell: y, a \mapsto {\mathbb{I}}(a = \bot) + \beta_1 {\mathbb{I}}(y \neq c \wedge a=T) + \beta_2 {\mathbb{I}}(y = c \wedge a=F)$ where $\beta_1, \beta_2 > 1$, observe that the Bayes decision for loss function $\ell$ is
\begin{align*}
\delta_\ell(x) = \left\lbrace \begin{array}{ll} T & {\hat{p}}_c(x) > \max(1 - 1/\beta_1, \beta_1 / (\beta_1 + \beta_2)) \\ F & {\hat{p}}_c(x) < \min(1/\beta_2, \beta_1 / (\beta_1 + \beta_2)) \\ \bot & \text{otherwise} \end{array}\right.
\end{align*}
Choose any pair of numbers $\alpha \geq \gamma$, we can choose $\beta_1, \beta_2$ such that $\alpha := \max(1 - 1/\beta_1, \beta_1 / (\beta_1 + \beta_2)), \gamma := \min(1/\beta_2, \beta_1 / (\beta_1 + \beta_2))$.
For any pair of loss functions $\ell$ and $\ell'$ parameterized by $\beta_1, \beta_2, \beta_1', \beta_2'$ (with associated threshold $\alpha \geq \gamma, \alpha' \geq \gamma'$) we have
\begin{align*}
& {\mathbb{E}}[\ell'(Y, \delta_{\ell}(X)) - {\mathbb{E}}[\ell'({\hat{Y}}, \delta_{\ell}(X))] \\
&= {\mathbb{E}}[(\ell'(Y, \delta_{\ell}(X)) - \ell'({\hat{Y}}, \delta_{\ell}(X))) {\mathbb{I}}(\delta_{\ell}(X) = T)] + {\mathbb{E}}[(\ell'(Y, \delta_{\ell}(X)) - \ell'({\hat{Y}}, \delta_{\ell}(X))) {\mathbb{I}}(\delta_{\ell}(X) = F)] \\
&= {\mathbb{E}}[(\ell'(Y, T) - \ell'({\hat{Y}}, T)) {\mathbb{I}}(\delta_{\ell}(X) = T)] + {\mathbb{E}}[(\ell'(Y, F) - \ell'({\hat{Y}}, F)) {\mathbb{I}}(\delta_{\ell}(X) = F)] \\
&= \beta_1' {\mathbb{E}}[ ( {\hat{p}}_c(X) - p_c^*(X)) {\mathbb{I}}({\hat{p}}_c(X) > \alpha) ] + \beta_2' {\mathbb{E}}[ (p_c^*(X) - {\hat{p}}_c(X)) {\mathbb{I}}({\hat{p}}_c(X) < \gamma) ]
\end{align*}
Similar to the argument for part 1, suppose ${\hat{p}}$ is classwise calibrated then $\forall \alpha, \gamma$, ${\mathbb{E}}[ (p_c^*(X) - {\hat{p}}_c(X)) {\mathbb{I}}({\hat{p}}_c(X) > \alpha) ] = 0$ and ${\mathbb{E}}[ (p_c^*(X) - {\hat{p}}_c(X)) {\mathbb{I}}({\hat{p}}_c(X) < \gamma) ] = 0$; therefore it is ${\mathcal{L}}_{cr}$-decision calibrated.
Conversely suppose ${\hat{p}}$ is ${\mathcal{L}}_{cr}$-decision calibrated, then $\forall \alpha$ we have ${\mathbb{E}}[ ( {\hat{p}}_c(X) - p_c^*(X)) {\mathbb{I}}({\hat{p}}_c(X) > \alpha) ] = 0$, which implies that ${\hat{p}}$ is classwise calibrated according to Lemma~\ref{lemma:conditional_exp}.
\textbf{Part 3} Choose the special loss function ${\mathcal{A}} = \Delta^C$ and $\ell$ as the log loss $\ell: y, a \mapsto -\log a_y$ then the Bayes action can be computed as
\begin{align*}
\delta_\ell(x) = \arg\inf_{a \in \Delta^C} {\mathbb{E}}_{{\hat{Y}} \sim {\hat{p}}(X)}[-\log a_{\hat{Y}}] = {\hat{p}}(x)
\end{align*}
Denote $U = {\hat{p}}(X)$ then let ${\mathcal{L}}_B$ be the set of all bounded loss functions, i.e. ${\mathcal{L}}_B = \lbrace \ell, |\ell(y, a)| \leq B \rbrace$
\begin{align*}
& \sup_{\ell' \in {\mathcal{L}}_B} {\mathbb{E}}[\ell'(Y, \delta_{\ell}(X))] - {\mathbb{E}}[\ell'({\hat{Y}}, \delta_{\ell}(X))] \\
& \sup_{\ell' \in {\mathcal{L}}_B} {\mathbb{E}}[ {\mathbb{E}}[\ell'(Y, U) - \ell'({\hat{Y}}, U) \mid U]] & \text{Tower} \\
&= B {\mathbb{E}}[ \left\lVert {\mathbb{E}}[ p^*(X) - {\hat{p}}(X) \mid U] \right\rVert_1 ] & \text{Cauchy Schwarz} \\
\end{align*}
If ${\hat{p}}$ satisfies distribution calibration, then $\left\lVert {\mathbb{E}}[ p^*(X) - {\hat{p}}(X) \mid U] \right\rVert_1 = 0$ almost surely, which implies that ${\hat{p}}$ is ${\mathcal{L}}_B$ decision calibrated. Conversely, if ${\hat{p}}$ is ${\mathcal{L}}_B$ decision calibrated, then $\left\lVert {\mathbb{E}}[ p^*(X) - {\hat{p}}(X) \mid U] \right\rVert_1 = 0$ almost surely (because if the expectation of a non-negative random variable is zero, the random variable must be zero almost surely), which implies that ${\hat{p}}$ is distribution calibrated. The theorem follows because $B$ is arbitrarily chosen.
\end{proof}
\input{appendix_dec2dist}
\subsection{Proofs for Section 4}
\label{appendix:proof_pac}
\decisionequivalence*
\begin{proof}[Proof of Proposition~\ref{prop:decision_equivalence}]
We first introduce a new set of notations to make the proof easier to follow. Because ${\mathcal{A}} = [K]$ and ${\mathcal{Y}} \simeq [C]$, a loss function can be uniquely identified with $K$ vectors $\ell_1, \cdots, \ell_K$ where $\ell_{ac} = \ell(c, a)$. Given prediction function ${\hat{p}}: {\mathcal{X}} \to \Delta^C$ and the expected loss can be denoted as
\begin{align}
{\mathbb{E}}_{{\hat{Y}} \sim {\hat{p}}(x)} [\ell({\hat{Y}}, a)] = \langle {\hat{p}}(x), \ell_a \rangle \numberthis \label{eq:notation_change}
\end{align}
Choose any Bayes decision function $\delta_{\ell'}$ for some loss $\ell' \in {\mathcal{L}}^K$, as a notation shorthand denote $\delta_{\ell'}({\hat{p}}(x)) = \delta_{\ell'}(x)$.
We can compute the gap between the left hand side and right hand side of Definition~\ref{def:decision_calibration} as
\begin{align*}
&\sup_{\ell} \frac{\left\lvert {\mathbb{E}}_{X} {\mathbb{E}}_{ {\hat{Y}} \sim {\hat{p}}(X)} [\ell({\hat{Y}}, \delta_{\ell'}(X)) ] - {\mathbb{E}}_{X} {\mathbb{E}}_{ Y \sim p^*(X)} [\ell(Y, \delta_{\ell'}(X)) ] \right\rvert}{\sup_a \lVert \ell(\cdot, a) \rVert_2 } \\
&= \sup_{\ell, \lVert \ell(\cdot, a) \rVert_2 \leq 1} \left\lvert {\mathbb{E}}_{X} {\mathbb{E}}_{ {\hat{Y}} \sim {\hat{p}}(X)} [\ell({\hat{Y}}, \delta_{\ell'}(X)) ] - {\mathbb{E}}_{X} {\mathbb{E}}_{ Y \sim p^*(X)} [\ell(Y, \delta_{\ell'}(X)) ] \right\rvert & \text{Normalize} \\
&= \sup_{\ell, \lVert \ell(\cdot, a) \rVert_2 \leq 1} \left\lvert {\mathbb{E}}_X\left[ \langle \ell_{\delta_{\ell'}(X)}, {\hat{p}}(X) \rangle \right] - {\mathbb{E}}_X\left[ \langle \ell_{\delta_{\ell'}(X)}, p^*(X) \rangle \right] \right\rvert & \text{Eq.\ref{eq:notation_change}}\\
&= \sup_{\ell, \lVert \ell(\cdot, a) \rVert_2 \leq 1} \left\lvert \sum_a {\mathbb{E}}_X[ \langle {\hat{p}}(X), \ell_a \rangle \mathbb{I}(\delta_{\ell'}(X) = a) ] - \sum_a {\mathbb{E}}_X[ \langle p^*(X), \ell_a \rangle \mathbb{I}(\delta_{\ell'}(X) = a) ] \right\rvert & \text{Total Probability} \\
&= \sup_{\ell, \lVert \ell(\cdot, a) \rVert_2 \leq 1} \left\lvert \sum_a \langle {\mathbb{E}}_X[ (p^*(X) - {\hat{p}}(X)) \mathbb{I}(\delta_{\ell'}(X) = a) ], \ell_a \rangle \right\rvert & \text{Linearity} \\
&= \sum_a \left\lVert {\mathbb{E}}_X[ (p^*(X) - {\hat{p}}(X)) \mathbb{I}(\delta_{\ell'}(X) = a) ] \right\rVert_2 & \text{Cauchy Schwarz}
\end{align*}
Finally we complete the proof by observing that the set of maps
\begin{align*}
\lbrace q, a \mapsto {\mathbb{I}}(\delta_{\ell}(q) = a), \ell \in {\mathcal{L}}^K, q \in \Delta^C \rbrace
\end{align*}
is the same as the set of maps $B^K$. We do this by establishing a correspondence where $\ell_a = -w_a / \lVert w_a \rVert_2$ then
\begin{align*}
{\mathbb{I}}(\delta_{\ell}(q) = a) = {\mathbb{I}}(\arg\inf_{a'} \langle \ell_{a'}, q \rangle = a) = {\mathbb{I}}(\arg\sup_{a'} \langle w_{a'}, q \rangle = a) = b_w(q, a)
\end{align*}
\end{proof}
\subsection{Formal Statements and Proofs for Theorem~\ref{thm:pac_informal}}
\paragraph{Formal Statement of Theorem~\ref{thm:pac_informal}, part I.} We first define a new notation. Given a set of samples ${\mathcal{D}} = \lbrace (X_1, Y_1), \cdots, (X_N, Y_N) \rbrace$, and for any function $\psi: {\mathcal{X}} \times {\mathcal{Y}} \to {\mathbb{R}}$ denote $\hat{{\mathbb{E}}}_{\mathcal{D}}[\psi(X, Y)]$ as the empirical expectation, i.e.
\begin{align*}
\hat{{\mathbb{E}}}_{\mathcal{D}}[\psi(X, Y)] := \frac{1}{N} \sum_{n} \psi(X_n, Y_n)
\end{align*}
\begin{manualtheorem}{2.1}[Formal]\label{thm:convergence1} Let $B^K$ be as defined by Eq.(\ref{eq:bk_def}), for any true distribution over $X,Y$ and any ${\hat{p}}$, given a set of $N$ samples ${\mathcal{D}} = \lbrace (X_1, Y_1), \cdots, (X_N, Y_N) \rbrace$, with probability $1-\delta$ over random draws of ${\mathcal{D}}$,
\begin{align}
\sup_{b \in B^K} \sum_{a=1}^K \left\lVert {\mathbb{E}} [ ({\hat{p}}(X) - Y) b({\hat{p}}(X), a) ] \right\rVert_2 - \sum_{a=1}^K \left\lVert \hat{{\mathbb{E}}}_{\mathcal{D}} [ ({\hat{p}}(X) - Y) b({\hat{p}}(X), a) ] \right\rVert_2 \leq \tilde{O}\left( \frac{K^{3/2} C}{\sqrt{N}} \right) \label{eq:convergence_thm}
\end{align}
where $\tilde{O}$ denotes equal up to constant and logarithmic terms.
\end{manualtheorem}
Note that in the theorem $\delta$ does not appear on the RHS of Eq.(\ref{eq:convergence_thm}). This is because the bound depends logarithmically on $\delta$.
\begin{proof}[Proof of Theorem~\ref{thm:convergence1}]
Before proving this theorem we first need a few uniform convergence Lemmas which we will prove in Appendix~\ref{appendix:proof_rest}.
\begin{lemma}
\label{lemma:concentration_action}
Let $B$ by any set of functions $\lbrace b: \Delta^C \to [0, 1] \rbrace$ and $U,V$ be any pair of random variables where $U$ takes values in $[-1, 1]^C$ and $V$ takes values in $\Delta^C$. Let ${\mathcal{D}} = \lbrace (U_1, V_1), \cdots, (U_N, V_N)\rbrace$ be an i.i.d. draw of $N$ samples from $U,V$, define the Radamacher complexity of $B$ by
\begin{align*}
{\mathcal{R}}_N(B) := {\mathbb{E}}_{{\mathcal{D}}, \sigma_i \sim \mathrm{Uniform}(\lbrace -1, 1 \rbrace)} \left[ \sup_{b \in B} \frac{1}{N} \sum_{n=1}^N \sigma_i b(V_i) \right]
\end{align*}
then for any $\delta > 0$, with probability $1-\delta$ (under random draws of ${\mathcal{D}}$), $\forall b \in B$
\begin{align*}
\lVert \hat{{\mathbb{E}}}_{\mathcal{D}}[U b(V)] - {\mathbb{E}}[U b(V)] \rVert_2 \leq \sqrt{C} {\mathcal{R}}_N(B) + \sqrt{\frac{2C}{N}\log \frac{2C}{\delta}}
\end{align*}
\end{lemma}
\begin{lemma} \label{lemma:radamacher_bound}
Define the function family
\begin{align*}
B^K_a &= \left\lbrace b: z \mapsto {\mathbb{I}}(a = \arg\sup_{a'} \langle z, w_a \rangle), w_a \in {\mathbb{R}}^C, a=1, \cdots, K, z \in \Delta^C \right\rbrace \\
\bar{B}^K_a &= \left\lbrace b: z \mapsto \frac{e^{\langle z, w_a \rangle}}{\sum_{a'} e^{\langle z, w_{a'} \rangle}}, w_a \in {\mathbb{R}}^C, a=1, \cdots, K, z \in \Delta^C \right\rbrace
\end{align*}
then ${\mathcal{R}}_N(B^K_a) = O\left( \sqrt{\frac{CK\log K \log N}{N}} \right)$ and
${\mathcal{R}}_N(\bar{B}^K_a) = O\left( \left(\frac{K}{N}\right)^{1/4}\log \frac{N}{K} \right)$.
\end{lemma}
Proof of the theorem is straight-forward given the above Lemmas. As a notation shorthand denote $U = {\hat{p}}(X) - Y$. Note that $U$ is a random vector raking values in $[-1, 1]^C$. We can rewrite the left hand side of Eq.(\ref{eq:convergence_thm}) as
\begin{align}
&\sup_{b \in {B^K}} \sum_a \lVert {\mathbb{E}}[U b({\hat{p}}(X), a)] \rVert_2 - \lVert \hat{{\mathbb{E}}}_{{\mathcal{D}}}[U b({\hat{p}}(X), a)] \rVert_2\\
&\leq \sum_a \sup_{b \in B^K_a} \lVert {\mathbb{E}}[U b({\hat{p}}(X), a)] \rVert_2 - \lVert \hat{{\mathbb{E}}}_{{\mathcal{D}}}[U b({\hat{p}}(X), a)] \rVert_2 & \text{Jensen} \\
&\leq \sum_a \sup_{b \in B^K_a} \lVert {\mathbb{E}}[U b({\hat{p}}(X), a)] - \hat{{\mathbb{E}}}_{{\mathcal{D}}}[U b({\hat{p}}(X), a)] \rVert_2 & \text{Triangle} \\
&\leq \sum_a \sqrt{C} {\mathcal{R}}_N(B^K_a) + \sqrt{\frac{2C}{N}\log \frac{2C}{\delta}} \quad \left( \text{w.p. } 1-\delta \right) & \text{Lemma~\ref{lemma:concentration_action}} \\
&\leq \sum_a \sqrt{C} O\left( \sqrt{\frac{CK\log K \log N}{N}} \right) + \sqrt{\frac{2C}{N}\log \frac{2C}{\delta}} & \text{Lemma~\ref{lemma:radamacher_bound}} \\
&\leq K\sqrt{C} O\left( \sqrt{\frac{CK\log K \log N}{N}} \right) + K\sqrt{ \frac{2C}{N} \log \frac{2C}{\delta}} \\
&= \tilde{O}\left( \frac{K^{3/2} C}{\sqrt{N}} \right)
\end{align}
\end{proof}
\paragraph{Formal Statement Theorem~\ref{thm:pac_informal}, Part II}
\begin{manualtheorem}{2.2}\label{thm:convergence}
Given any input ${\hat{p}}$ and tolerance $\epsilon$, Algorithm~\ref{alg:recalibration_sketch} terminates in $O(K/\epsilon^2)$ iterations. For any $\lambda > 0$, given $O(\text{poly}(K, C, \log(1/\delta), \lambda))$ samples, with $1-\delta$ probability Algorithm~\ref{alg:recalibration_sketch} outputs a $({\mathcal{L}}^K, \epsilon+\lambda)$-decision calibrated prediction function ${\hat{p}}'$ that satisfies ${\mathbb{E}}[\lVert {\hat{p}}'(X) - Y \rVert_2^2] \leq {\mathbb{E}}[\lVert {\hat{p}}(X) - Y \rVert_2^2] + \lambda$.
\end{manualtheorem}
\begin{proof}[Proof of Theorem~\ref{thm:convergence}]
We adapt the proof strategy in \citep{hebert2018multicalibration}. The key idea is to show that a potential function must decrease after each iteration of the algorithm. We choose the potential function as ${\hat{{\mathbb{E}}}}[(Y - {\hat{p}}(X))^2]$.
Similar to Appendix~\ref{appendix:relax} at each iteration $t$ we first lighten our notation with a shorthand $b_a(X) = b({\hat{p}}^{(t-1)}(X), a)$ (at different iteration $t$, $b_a$ denotes different functions), and $b(X)$ is the vector of $(b_1(X), \cdots, b_K(X))$. If the algorithm did not terminate that implies that $b$ satisfies
\begin{align}
\sum_a \lVert {\hat{{\mathbb{E}}}}[ ({\hat{p}}(X) - Y) b_a(X) ] \rVert \geq \epsilon \label{eq:error_lb}
\end{align}
Denote $\gamma \in \mathbb{R}^{K \times K}$ where $\gamma_a = {\hat{{\mathbb{E}}}}[(Y - {\hat{p}}(X) ) b(X, a)]/ {\hat{{\mathbb{E}}}}[b(X, a)]$.
The adjustment we make is ${\hat{p}}'(X) = \pi({\hat{p}}(X) + \sum_a \gamma_a b(X, a))$
\begin{align*}
&{\hat{{\mathbb{E}}}}[\lVert Y - {\hat{p}}(X)\rVert^2] - {\hat{{\mathbb{E}}}}[\Vert Y - {\hat{p}}'(X) \rVert^2] \\ &= {\hat{{\mathbb{E}}}}[ \lVert Y - {\hat{p}}(X)\rVert^2 - \Vert Y - \pi({\hat{p}}(X) + \sum_a \gamma_a b(X, a) ) \rVert^2] \\
&\geq {\hat{{\mathbb{E}}}}[ \lVert Y - {\hat{p}}(X)\rVert^2 - \Vert Y - {\hat{p}}(X) - \sum_a \gamma_a b(X, a) \rVert^2] & \text{Projection ineq} \\
&= {\hat{{\mathbb{E}}}}\left[ (2Y - 2{\hat{p}}(X) - \sum_a \gamma_a b(X, a))^T \left( \sum_a \gamma_a b(X, a) \right)\right] & a^2-b^2 = (a+b)(a-b) \\
&= 2\sum_a \gamma_a^T \gamma_a {\hat{{\mathbb{E}}}}[b(X, a)] - \sum_{a, a'} \gamma_a^T \gamma_{a'} {\hat{{\mathbb{E}}}}[b(X, a)b(X, a')] & \text{Definition} \gamma_a \\
&= 2\sum_a \gamma_a^T \gamma_a {\hat{{\mathbb{E}}}}[b(X, a)] - \sum_{a} \gamma_a^T \gamma_{a} {\hat{{\mathbb{E}}}}[b(X, a)b(X, a)] & b(x, a) b(x, a') = 0, \forall a \neq a' \\
&= 2\sum_a \gamma_a^T \gamma_a {\hat{{\mathbb{E}}}}[b(X, a)] - \sum_{a} \gamma_a^T \gamma_{a} {\hat{{\mathbb{E}}}}[b(X, a)] & b(X, a)^2 = b(X, a)\\
&= \sum_a \Vert \gamma_a \rVert^2 {\hat{{\mathbb{E}}}}[b(X, a)] \geq \frac{1}{K} \left( \sum_a \lVert \gamma_a \rVert {\hat{{\mathbb{E}}}}[b(X, a)] \right)^2 & \text{Norm inequality} \\
& = \frac{1}{K}\left( \sum_a \left\lVert {\hat{{\mathbb{E}}}}[(Y - {\hat{p}}(X)b(X, a)] \right\rVert \right)^2 \geq \frac{\epsilon^2}{K} & \text{Definition } \gamma_a
\end{align*}
Because initially for the original predictor ${\hat{p}}$ we must have
\begin{align*}
{\hat{{\mathbb{E}}}}[\lVert p^*(X) - {\hat{p}}(X)\rVert_2^2] \leq {\hat{{\mathbb{E}}}}[ \lVert p^*(X) - {\hat{p}}(X) \rVert_1^2 ] \leq 1
\end{align*}the algorithm must converge in $K/\epsilon^2$ iterations and output a predictor ${\hat{p}}'$ where
\begin{align*}
\sum_a \lVert {\hat{{\mathbb{E}}}}[ ({\hat{p}}'(X) - Y) b_a(X) ] \rVert \leq \epsilon
\end{align*}
In addition we know that
\begin{align*}
{\hat{{\mathbb{E}}}}[\lVert {\hat{p}}'(X) - Y \rVert_2^2] \leq {\hat{{\mathbb{E}}}}[\lVert {\hat{p}}(X) - Y \rVert_2^2]
\end{align*}
Now that we have proven the theorem for empirical averages (i.e. all expectations are ${\hat{{\mathbb{E}}}}$), we can convert this proof to use true expectations (i.e. all expectations are ${\mathbb{E}}$) by observing that all expectations involved in the proof satisfy ${\mathbb{E}}[\cdot] \in {\hat{{\mathbb{E}}}}[\cdot] \pm \kappa$ for any $\kappa > 0$ and sample size that is polynomial in $\kappa$.
\end{proof}
\begin{proof}[Proof of Theorem~\ref{thm:convergence_relaxed}]
Observe that the matrix $D$ defined in Algorithm~\ref{alg:recalibration} is a symmetric, positive semi-definite and non-negative matrix such that $\sum_{a, a'} D_{aa'} = 1$. To show that the algorithm converges we first need two Lemmas on the properties of such matrices. For a positive semi-definite (PSD) symmetric matrix, let $\lambda_1$ denote the largest eigenvalue, and $\lambda_n$ denote the smallest eigenvalue (which are always real numbers). The first Lemma is a simple consequence of the Perron-Frobenius theorem,
\begin{lemma}
\label{lemma:perron}
Let $D$ be any symmetric PSD non-negative matrix such that $\sum_{a, a'} D_{aa'} = 1$, then $\lambda_1(D) \leq 1$, so $\lambda_n(D^{-1}) \geq 1$.
\end{lemma}
\begin{lemma}[\citep{fang1994inequalities} Theorem 1]\label{lemma:non_neg_matrix} Let $D$ be a symmtric PSD matrix, then for any matrix $B$ (that has the appropriate shape to multiply with $D$)
\begin{align*}
\lambda_n(D) {\mathrm{trace}}(B) \leq {\mathrm{trace}}(BD) \leq \lambda_1(D) {\mathrm{trace}}(B)
\end{align*}
\end{lemma}
Now we can proveed to prove our main result. We have to show that the L2 error ${\hat{{\mathbb{E}}}}[(Y - {\hat{p}}^{(t-1)}(X))^2]$ must decrease at iteration $t$ if we still have
\begin{align*}
\epsilon^2/K \leq \sum_{a} \lVert {\hat{{\mathbb{E}}}}[(Y - {\hat{p}}^{(t-1)}(X)) b_a^{(t)}(X)] \rVert^2 := {\mathrm{trace}}(RR^T)
\end{align*}
We can compute the reduction in L2 error after the adjustment
\begin{align*}
&{\hat{{\mathbb{E}}}}[(Y - {\hat{p}}^{(t-1)}(X))^2] - {\hat{{\mathbb{E}}}}[(Y - {\hat{p}}^{(t)}(X))^2] \\
&= {\hat{{\mathbb{E}}}}\left[ (2 (Y - {\hat{p}}^{(t-1)}(X)) - R^TD^{-1}b^{(t)}(X))^T R^T D^{-1} b^{(t)}(X) \right] & \text{Definition} \\
&= 2{\hat{{\mathbb{E}}}}\left[ (Y - {\hat{p}}^{(t-1)}(X))^T R^T D^{-1} b^{(t)}(X) \right] - {\hat{{\mathbb{E}}}}\left[ b^{(t)}(X)^T D^{-T} R R^T D^{-1} b^{(t)}(X) \right] \\
&= 2{\mathrm{trace}} \left( {\hat{{\mathbb{E}}}}\left[ b^{(t)}(X) (Y - {\hat{p}}^{(t-1)}(X))^T R^T D^{-1} \right] \right) \\
& \qquad - {\mathrm{trace}} \left( {\hat{{\mathbb{E}}}}\left[ b^{(t)}(X) b^{(t)}(X)^T D^{-T} R R^T D^{-1} \right] \right) & \text{Cyclic property} \\
&= 2{\mathrm{trace}} \left( R R^T D^{-1} \right) - {\mathrm{trace}}(RR^T D^{-1}) = {\mathrm{trace}}(RR^T D^{-1}) & \text{Definition} \\
&\geq {\mathrm{trace}}(RR^T) \geq \epsilon^2/K & \text{Lemma~\ref{lemma:non_neg_matrix} and \ref{lemma:perron}}
\end{align*}
Therefore, the algorithm cannot run for more than $O(K/\epsilon^2)$ iterations. Suppose the algorithm terminates we must have
\begin{align*}
\sup_{b \in B^K} \sum_{a} \lVert {\hat{{\mathbb{E}}}}[(Y - {\hat{p}}^{(t-1)}(X)) b_a^{(t)}(X)] \rVert
&\leq \sup_{b \in {\bar{B}^K}} \sum_{a} \lVert {\hat{{\mathbb{E}}}}[(Y - {\hat{p}}^{(t-1)}(X)) b_a^{(t)}(X)] \rVert \\
&\leq \sup_{b \in {\bar{B}^K}} \sqrt{K} \sqrt{\sum_{a} \lVert {\hat{{\mathbb{E}}}}[(Y - {\hat{p}}^{(t-1)}(X)) b_a^{(t)}(X)] \rVert^2 } \\
&\leq \sqrt{K} \epsilon/\sqrt{K} = \epsilon
\end{align*}
So by Proposition~\ref{prop:reduction_to_decision} we can conclude that the algorithm must output a $({\mathcal{L}}^K, \epsilon)$-decision calibrated prediction function.
\end{proof}
\subsection{Proof of Remaining Lemmas}
\label{appendix:proof_rest}
\begin{proof}[Proof of Lemma~\ref{lemma:conditional_exp}]
By the orthogonal property of the condition expectation, for any event $A$ in the sigma algebra induced by $V$, we have
\begin{align*}
{\mathbb{E}}[(U - {\mathbb{E}}[U\mid V]) {\mathbb{I}}_A] = 0
\end{align*}
This includes the event $V > c$
\begin{align*}
{\mathbb{E}}[(U - {\mathbb{E}}[U\mid V]) {\mathbb{I}}(V > c)] = 0
\end{align*}
In other words,
\begin{align*}
{\mathbb{E}}[U{\mathbb{I}}(V > c)] = {\mathbb{E}}[{\mathbb{E}}[U \mid V] {\mathbb{I}}(V > c)]
\end{align*}
\end{proof}
\begin{proof}[Proof of Lemma~\ref{lemma:concentration_action}]
First observe that by the norm inequality $\lVert z \rVert_\alpha \leq C^{1/\alpha} \lVert z \rVert_\infty$ we have
\begin{align}
\lVert \hat{{\mathbb{E}}}_{\mathcal{D}}[U b(V)] - {\mathbb{E}}[U b(V)] \rVert_2 \leq \sqrt{C} \lVert \hat{{\mathbb{E}}}[U b(V)] - {\mathbb{E}}[U b(V)] \rVert_\infty \label{eq:convergence_2_to_infty}
\end{align}
Denote the $c$-th dimension of $U$ by $U^c$; we now provide bounds for $\lvert \hat{{\mathbb{E}}}[U^c b(V)] - {\mathbb{E}}[U^c b(V)] \rvert$ by
standard Radamacher complexity arguments. Define a set of ghost samples $\bar{{\mathcal{D}}} = \lbrace (\bar{U}_1, \bar{V}_1), \cdots (\bar{U}_N, \bar{V}_N) \rbrace$ and Radamacher variables $\sigma_n \in \lbrace -1, 1 \rbrace$
\begin{align}
&{\mathbb{E}}_{{\mathcal{D}}} \left[ \sup_b \lvert \hat{{\mathbb{E}}}_{{\mathcal{D}}}[U^c b(V)] - {\mathbb{E}}[U^c b(V)] \rvert \right] \\
&= {\mathbb{E}}_{{\mathcal{D}}} \left[ \sup_b \left\lvert \hat{{\mathbb{E}}}_{{\mathcal{D}}}[U^c b(V)] - {\mathbb{E}}_{\bar{{\mathcal{D}}}}\left[ \hat{{\mathbb{E}}}_{\bar{{\mathcal{D}}}}[ U^cb(V)] \right] \right\rvert \right] & \text{Tower} \\
&= {\mathbb{E}}_{{\mathcal{D}}} \left[ \sup_b \left\lvert {\mathbb{E}}_{\bar{{\mathcal{D}}}}[\hat{{\mathbb{E}}}_{{\mathcal{D}}}[U^c b(V)] - \hat{{\mathbb{E}}}_{\bar{{\mathcal{D}}}}[ U^cb(V)] ] \right\rvert\right] & \text{Linearity} \\
&\leq {\mathbb{E}}_{{\mathcal{D}}} \left[ \sup_b {\mathbb{E}}_{\bar{{\mathcal{D}}}}\left[ \left\lvert \hat{{\mathbb{E}}}_{{\mathcal{D}}}[U^c b(V)] - \hat{{\mathbb{E}}}_{\bar{{\mathcal{D}}}}[ U^cb(V)] \right\rvert \right] \right] & \text{Jensen} \\
&\leq {\mathbb{E}}_{{\mathcal{D}}, \bar{{\mathcal{D}}}} \left[ \sup_b \left\lvert \hat{{\mathbb{E}}}_{{\mathcal{D}}}[U^c b(V)] - \hat{{\mathbb{E}}}_{\bar{{\mathcal{D}}}}[ U^cb(V)] \right\rvert\right] & \text{Jensen} \\
&\leq {\mathbb{E}}_{\sigma, {\mathcal{D}}, \bar{{\mathcal{D}}}} \left[ \sup_b \left\lvert \frac{1}{N} \sum_i \sigma_i U^c_i b(V_i) - \frac{1}{N} \sum_i \sigma_i \bar{U}^c_i b(\bar{V}_i) \right\rvert \right] & \text{Radamacher} \\
&\leq {\mathbb{E}}_{\sigma, {\mathcal{D}}, \bar{{\mathcal{D}}}} \left[ \sup_b \left\lvert \frac{1}{N} \sum_i \sigma_i U^c_i b(V_i) \right\rvert + \sup_b \left\lvert \frac{1}{N} \sum_i \sigma_i \bar{U}^c_i b(\bar{V}_i) \right\rvert \right] & \text{Jensen} \\
&= 2{\mathbb{E}}_{\sigma, {\mathcal{D}}} \left[ \sup_b \left\lvert \frac{1}{N} \sum_i \sigma_i U^c_i b(V_i)\right\rvert \right]
\end{align}
Suppose we know the Radamacher complexity of the function family $b$
\begin{align}
{\mathcal{R}}_N(B) := {\mathbb{E}}\left[ \sup_b \frac{1}{N}\sum_i \sigma_i b(V_i) \right]
\end{align}
Then by the contraction inequality, and observe that $U_{i}^c \in [-1, 1]$ so multiplication by $U_{i}^c$ is a 1-Lipschitz map, we can conclude for any $c \in [C]$
\begin{align}
{\mathcal{R}}_N(B) \geq {\mathbb{E}}\left[ \sup_b \frac{1}{N} \sum_i \sigma_i U_{ic} b(V_i) \right] \label{eq:individual_convergence}
\end{align}
Finally observe that the map ${\mathcal{D}} \to \frac{1}{N} \sum_i \sigma_i U_{ic} b(V_i) $ has $2/N$ bounded difference, so by Mcdiamid inequality for any $\epsilon > 0$
\begin{align}
\Pr\left[\sup_b \left\lvert \frac{1}{N}\sum_i \sigma_i U_i^c b(V_i) \right\rvert \geq {\mathcal{R}}_N(B) + \epsilon\right] \leq 2e^{-N\epsilon^2/2}
\end{align}
By union bound we have
\begin{align}
\Pr\left[ \max_c \sup_b \left\lvert \frac{1}{N}\sum_i \sigma_i U_i^c b(V_i) \right\rvert \geq {\mathcal{R}}_N(B) + \epsilon\right] \leq 2Ce^{-N\epsilon^2/2}
\end{align}
We can combine this with Eq.(\ref{eq:convergence_2_to_infty}) to conclude
\begin{align*}
&\Pr\left[ \sup_b \lVert \hat{{\mathbb{E}}}[U b(V)] - {\mathbb{E}}[U b(V)] \rVert_2 \geq \sqrt{C} {\mathcal{R}}_N(B) + \sqrt{C} \epsilon \right] \\
&\leq \Pr\left[ \max_c \sup_b \hat{{\mathbb{E}}}[U^c b(V)] - {\mathbb{E}}[U^c b(V)] \rVert_2 \geq {\mathcal{R}}_N(B) + \epsilon \right] \leq 2Ce^{-N\epsilon^2/2}
\end{align*}
Rearranging we get $\forall \delta > 0$
\begin{align*}
\Pr\left[ \sup_b \lVert \hat{{\mathbb{E}}}[U b(V)] - {\mathbb{E}}[U b(V)] \rVert_2 \geq \sqrt{C} {\mathcal{R}}_N(B) + \sqrt{\frac{2C}{N}\log \frac{2C}{\delta}} \right] \leq \delta
\end{align*}
\end{proof}
\begin{proof}[Proof of Lemma~\ref{lemma:radamacher_bound}]
For $B^K_a$ we use the VC dimension approach. Because $\forall b \in B^K_a$ the set $\lbrace z \in \Delta^C, b(z) = 1 \rbrace$ is the intersection of $K$ many $C$-dimensional half plances, its VC dimension ${\mathrm{VC}}(B^K_a) \leq (C+1)2K\log_2 (3K)$~\citep{mohri2018foundations} (Q3.23). By Sauer's Lemma we have
\begin{align*}
{\mathcal{R}}_N(B^K_a) \leq \sqrt{\frac{2{\mathrm{VC}}(B^K_a)\log (eN/{\mathrm{VC}}(B^K_a)) }{N}} = O\left( \sqrt{\frac{2CK\log K \log N}{N}} \right)
\end{align*}
\end{proof}
\section{Relaxations to Decision Calibration}
\label{appendix:relax}
We define the algorithm that corresponds to Algorithm~\ref{alg:recalibration_sketch} but for softmax relaxed functions. Before defining our algorithm at each iteration $t$ we first lighten our notation with a shorthand $b_a(X) = b({\hat{p}}^{(t-1)}(X), a)$ (at different iteration $t$, $b_a$ denotes different functions), and $b(X)$ is the vector of $(b_1(X), \cdots, b_K(X))$.
\RestyleAlgo{boxruled}
\LinesNumbered
\begin{algorithm}[H]
Input current prediction function ${\hat{p}}$, a dataset ${\mathcal{D}} = \lbrace (x_1, y_1), \cdots, (x_M, y_M) \rbrace $\, tolerance $\epsilon$ \;
Initialize ${\hat{p}}^{(0)} = {\hat{p}}$, $v^{(0)} = +\infty$\;
\For{$t=1, 2, \cdots$ until $v^{(t-1)} < \epsilon^2/K$}{
$v^{(t)}, b^{(t)} = \sup, \arg\sup_{b \in {\bar{B}^K}} \sum_{a=1}^K \left\lVert {\mathbb{E}} [(Y - {\hat{p}}^{(t-1)}(X)) b_a(X)] \right\rVert^2$ \;
Compute $D \in {\mathbb{R}}^{K \times K}$ where $D_{aa'} = {\mathbb{E}}[b_a^{(t)}(X) b_{a'}^{(t)}(X)]$ \;
Compute $R \in {\mathbb{R}}^{K \times C}$ where $R_a = {\mathbb{E}}[(Y - {\hat{p}}^{(t-1)}(X)) b^{(t)}_a(X)]$ \;
Set ${\hat{p}}^{(t)}: x \mapsto \pi({\hat{p}}^{(t-1)}(x) + R^T D^{-1} b^{(t)}(x))$ where $\pi$ is the normalization projection\;
}
Output ${\hat{p}}^{(T)}$ where $T$ is the number of iterations
\caption{Recalibration Algorithm to achieve decision calibration.}
\label{alg:recalibration}
\end{algorithm}
For the intuition of the algorithm, consider the $t$-th iteration where the current prediction function is ${\hat{p}}^{(t-1)}$. On line 4 we find the worst case $b^{(t)}$ that maximizes the ``error'' $\sum_{a=1}^K \left\lVert {\mathbb{E}}[(Y - {\hat{p}}^{t-1}(X)) b^{(t)}_a(X)] \right\rVert^2 $, and on line 5-7 we make the adjustment ${\hat{p}}^{(t-1)} \to {\hat{p}}^{(t)}$ to minimize this error $\sum_{a=1}^K \left\lVert {\mathbb{E}}[(Y - {\hat{p}}^{t}(X)) b^{(t)}_a(X)] \right\rVert^2$.
In particular, the adjustment we aim to find on line 5-7 (which we denote by $U \in {\mathbb{R}}^{C \times K}$) should satisfy the following: if we let
\begin{align*}
{\hat{p}}^{(t)}(X) = {\hat{p}}^{(t-1)}(X) + U b^{(t)}(X)
\end{align*}
we can minimize
\begin{align*}
L(U) &:= \sum_{a=1}^K \left\lVert {\mathbb{E}}[(Y - {\hat{p}}^{(t)}(X)) b^{(t)}_a(X)] \right\rVert^2
\end{align*}
We make some simple algebra manipulations on $L$ to get
\begin{align*}
L(U) &= \sum_{a=1}^K \left\lVert {\mathbb{E}}[(Y - {\hat{p}}^{(t-1)}(X)) b^{(t)}_a(X) - U b^{(t)}(X) b^{(t)}_a(X) ] \right\rVert^2 \\
&= \sum_{a=1}^K \left\lVert R_a - (D U^T)_a \right\rVert^2
= \left\lVert R - DU^T \right\rVert^2
\end{align*}
Suppose $D$ is invertible, then the optimum of the objective is
\begin{align*}
U^* := \arg\inf L(U) = R^T D^{-1}, \quad L(U^*) = 0
\end{align*}
When $D$ is not invertible we can use the pseudo-inverse, though we observe in the experiments that $D$ is always invertible.
For the relaxed algorithm we also have a theorem that is equivalent to Theorem~\ref{thm:convergence}. The statement of the theorem is identical; the proof is also essentially the same except for the use of some new technical tools.
\begin{manualtheorem}{2.2'} \label{thm:convergence_relaxed}
Algorithm~\ref{alg:recalibration} terminates in $O(K/\epsilon^2)$ iterations. For any $\lambda > 0$, given $O(\text{poly}(K, C, \log(1/\delta), \lambda))$ samples, with $1-\delta$ probability Algorithm~\ref{alg:recalibration_sketch} outputs a $({\mathcal{L}}^K, \epsilon + \lambda)$-decision calibrated prediction function ${\hat{p}}'$ that satisfies ${\mathbb{E}}[\lVert {\hat{p}}'(X) - Y \rVert_2^2] \leq {\mathbb{E}}[\lVert {\hat{p}}(X) - Y \rVert_2^2] + \lambda$.
\end{manualtheorem}
\section{Achieving Decision Calibration with PAC Guarantees}
\subsection{Approximate ${\mathcal{L}}^K$ Decision Calibration is Verifiable and Achievable}
Decision calibration in Definition~\ref{def:decision_calibration} usually cannot be achieved perfectly. The definition has to be relaxed to allow for statistical and numerical errors.
To meaningfully define approximate calibration we must assume that the loss functions are bounded, i.e. no outcome $y \in {\mathcal{Y}}$ and action $a \in {\mathcal{A}}$ can incur an infinite loss.
In particular, we bound $\ell$ by its 2-norm
$
\max_a \lVert \ell(\cdot, a) \rVert_2 := \max_a \sqrt{\sum_{y \in {\mathcal{Y}}} \ell(y, a)^2}
$.~\footnote{The choice of 2-norm is for convenience. All $p$-norms are equivalent up to a multiplicative factor polynomial in $C$, so our main theorem (Theorem~\ref{thm:pac_informal}) still hold for any $p$-norms up to the polynomial factor.}
Now we can proceed to define approximate decision calibration. In particular, we compare the difference between the two sides in Eq.(\ref{eq:equal_loss}) of Definition~\ref{def:decision_calibration} with the maximum magnitude of the loss function.
\begin{definition}[Approximate decision calibration]
\label{def:decision_calibration_relaxed}
A prediction function ${\hat{p}}$ is $({\mathcal{L}}, \epsilon$)-decision calibrated (with respect to $p^*$) if $\forall \ell \in {\mathcal{L}}$ and $\delta \in \drule_{\mathcal{L}}$
\begin{align}
\left\lvert {\mathbb{E}} [\ell({\hat{Y}}, \delta({\hat{p}}(X))) ] - {\mathbb{E}} [\ell(Y, \delta({\hat{p}}(X))) ] \right\rvert \leq \epsilon \sup_{a \in {\mathcal{A}}} \lVert \ell(\cdot, a) \rVert_2
\end{align}
\end{definition}
Definition~\ref{def:decision_calibration_relaxed} is a relaxation of Definition~\ref{def:decision_calibration}: if a prediction function is $({\mathcal{L}}, 0)$-decision calibrated, then it is ${\mathcal{L}}$-decision calibrated (Definition~\ref{def:decision_calibration}).
The main observation in our paper is that for the set of loss functions with $K$ actions, $({\mathcal{L}}^K,\epsilon)$-decision calibration can be verified and achieved with polynomially many samples.
\begin{theorem}[Main Theorem, informal]
\label{thm:pac_informal}
There is an algorithm, such that for any predictor ${\hat{p}}$ and given polynomially (in $K, C, 1/\epsilon$) many samples, can with high probability
\begin{enumerate}
\item correctly decide if ${\hat{p}}$ satisfies $({\mathcal{L}}^K,\epsilon)$-decision calibration
\item output a new predictor ${\hat{p}}'$ that satisfies $({\mathcal{L}}^K,\epsilon)$-decision calibration without degrading the original predictions (in terms of $L_2$ error).
\end{enumerate}
\end{theorem}
As with distribution calibration, trivial predictors ${\hat{p}}(x) \equiv {\mathbb{E}}[Y], \forall x$
satisfy $({\mathcal{L}}^K,0)$-decision calibration.
To maintain a meaningful prediction function we also require ``sharpness'' which we measure by $L_2$ error.
We guarantee that the $L_2$ error of ${\hat{p}}'$ can only \emph{improve} under post-processing; that is, ${\mathbb{E}}[\lVert {\hat{p}}'(X) - Y \rVert_2^2] \leq {\mathbb{E}}[\lVert {\hat{p}}(X) - Y \rVert_2^2]$.
In fact, the algorithm works by iteratively updating the predictions to make progress in $L_2$.
For rest of this section, we propose concrete algorithms that satisfy Theorem~\ref{thm:pac_informal}.
\subsection{Verification of Decision Calibration}
This section focuses on the first part of Theorem~\ref{thm:pac_informal} where we certify $({\mathcal{L}}^K, \epsilon)$-decision calibration. A naive approach would use samples to directly estimate
\begin{align}
\sup_{\delta \in \drule_{{\mathcal{L}}^K}} \sup_{\ell \in {\mathcal{L}}^K} \left\lvert {\mathbb{E}} [\ell({\hat{Y}}, \delta({\hat{p}}(X))) ] - {\mathbb{E}} [\ell(Y, \delta({\hat{p}}(X))) ] \right\rvert / \left( \sup_{a \in {\mathcal{A}}} \lVert \ell(\cdot, a) \rVert_2 \right)
\end{align}
and compare it with $\epsilon$. However, the complexity of this optimization problem poses challenges to analysis. We will make several observations to transform this complex optimization problem to a simple problem that resembles linear classification.
\paragraph{Observation 1.} The first observation is that we do not have to take the supremum over ${\mathcal{L}}^K$ because for any choice of $\delta \in \drule$ by simple calculations (details in the Appendix) we have
\begin{align}
\sup_{\ell \in {\mathcal{L}}^K} \frac{\left\lvert {\mathbb{E}} [\ell({\hat{Y}}, \delta({\hat{p}}(X))) ] - {\mathbb{E}} [\ell(Y, \delta({\hat{p}}(X))) ] \right\rvert }{\sup_{a \in {\mathcal{A}}} \lVert \ell(\cdot, a) \rVert_2} = \sum_{a=1}^K \left\lVert {\mathbb{E}} [ ({\hat{Y}} - Y) \mathbb{I}(\delta({\hat{p}}(X)) = a) ] \right\rVert_2 \label{eq:norm_calibration}
\end{align}
Intuitively on the right hand side, $\delta$ partitions the probabilities $\Delta^C$ based on the optimal decision $\Delta_1 := \lbrace q \in \Delta^C, \mathbb{I}(\delta(q) = 1) \rbrace, \cdots, \Delta_K := \lbrace q \in \Delta^C, \mathbb{I}(\delta(q) = K) \rbrace $. For each partition $\Delta_k$ we measure the difference between predicted label and true label \textit{on average}, i.e. we compute ${\mathbb{E}}[ ({\hat{Y}} - Y) \mathbb{I}({\hat{p}}(X) \in \Delta_k)]$
\paragraph{Observation 2.}
We observe that the partitions of $\Delta^C$ are defined by linear classification boundaries. Formally, we introduce a new notation for the linear multi-class classification functions
\begin{align}
{B^K} = \left\lbrace b_w \mid \forall w \in {\mathbb{R}}^{K \times C} \right\rbrace\label{eq:bk_def}&&
\textrm{where~~}b_w(q,a) = {\mathbb{I}}(a = \arg\sup_{a' \in [K]} \langle q, w_{a'}\rangle)
\end{align}
Note that this new classification task is a tool to aid in understanding decision calibration, and bears no relationship with the original prediction task (predicting $Y$ from $X$). Intuitively $w$ defines the weights of a linear classifier; given input features $q \in \Delta^C$ and a candidate class $a$, $b_w$ outputs an indicator: $b_w(q, a)=1$ if the optimal decision of $q$ is equal to $a$ and $0$ otherwise.
The following equality draws the connection between Eq.(\ref{eq:norm_calibration}) and linear classification. The proof is simply a translation from the original notations to the new notations.
\begin{align}
\sup_{\delta \in \drule_{{\mathcal{L}}^K}} \sum_{a=1}^K \left\lVert {\mathbb{E}} [ ({\hat{Y}} - Y) \mathbb{I}(\delta({\hat{p}}(X))) = a) ] \right\rVert_2 = \sup_{b \in {B^K}}\sum_{a=1}^K \left\lVert {\mathbb{E}} [ ({\hat{Y}} - Y) b({\hat{p}}(X), a) ] \right\rVert_2
\end{align}
The final outcome of our derivations is the following proposition (Proof in Appendix~\ref{appendix:proof_pac})
\begin{restatable}{prop}{decisionequivalence}
\label{prop:decision_equivalence}
A predictor ${\hat{p}}$ satisfies $({\mathcal{L}}^K, \epsilon)$-decision calibration if and only if
\begin{align}
\sup_{b \in {B^K}}\sum_{a=1}^K \left\lVert {\mathbb{E}} [ ({\hat{Y}} - Y) b({\hat{p}}(X), a) ] \right\rVert_2 \leq \epsilon \label{eq:decision_calibration_equivalent}
\end{align}
\end{restatable}
In words, ${\hat{p}}$ satisfies decision calibration if and only if there is no linear classification function that can partition $\Delta^C$ into $K$ parts, such that the average difference ${\hat{Y}} - Y$ (or equivalently ${\hat{p}}(X) - p^*(X)$) in each partition is large.
Theorem~\ref{thm:pac_informal}.1 follows naturally because $B^K$ has low Radamacher complexity, so the left hand side of Eq.(\ref{eq:decision_calibration_equivalent}) can be accurately estimated with polynomially many samples. For a formal statement and proof see Appendix~\ref{appendix:proof_pac}.
The remaining problem is computation. With unlimited compute, we can upper bound Eq.(\ref{eq:decision_calibration_equivalent}) by brute force search over $B^K$; in practice, we use a surrogate objective optimizable with gradient descent. This is the topic of Section~\ref{sec:computation}.
\subsection{Recalibration Algorithm}
This section discusses the second part of Theorem~\ref{thm:pac_informal} where we design a post-processing recalibration algorithm.
The algorithm is based on the following intuition, inspired by \citep{hebert2018multicalibration}: given a predictor ${\hat{p}}$ we find the worst $b \in B^K$ that violates Eq.(\ref{eq:decision_calibration_equivalent}) (line 3 of Algorithm~\ref{alg:recalibration_sketch}); then, we make an update to ${\hat{p}}$ to minimize the violation of Eq.(\ref{eq:decision_calibration_equivalent}) for the worst $b$ (line 4,5 of Algorithm~\ref{alg:recalibration_sketch}). This process is be repeated until we get a $(B^K, \epsilon)$-decision calibrated prediction (line 2). The sketch of the algorithm is shown in Algorithm~\ref{alg:recalibration_sketch} and the detailed algorithm is in the Appendix.
\RestyleAlgo{boxruled}
\LinesNumbered
\begin{algorithm}[H]
Input current prediction function ${\hat{p}}$, tolerance $\epsilon$. Initialize ${\hat{p}}^{(0)} = {\hat{p}}$\;
\For{$t=1, 2, \cdots, T$ until output ${\hat{p}}^{(T)}$ when it satisfies Eq.(\ref{eq:decision_calibration_equivalent})}{
Find $b \in {B^K}$ that maximizes $\sum_{a=1}^K \left\lVert {\mathbb{E}}[ (Y - {\hat{p}}^{(t-1)}(X)) b({\hat{p}}^{(t-1)}(X), a) \right\rVert$ \;
Compute the adjustments $d_a = {\mathbb{E}}[(Y - {\hat{p}}^{(t-1)} (X)) b ({\hat{p}}^{(t-1)}(X), a)] / {\mathbb{E}}[ b ({\hat{p}}^{(t-1)}(X), a)]$ \;
Set $\hat{p}^{(t)} : x \mapsto \hat{p}^{(t-1)}(x) + \sum_{a=1}^K b ({\hat{p}}^{(t-1)}(x), a)\cdot d_a$ (projecting onto $[0,1]$ if necessary) \;
}
\caption{Recalibration algorithm to achieve ${\mathcal{L}}^K$ decision calibration.}
\label{alg:recalibration_sketch}
\end{algorithm}
Given a dataset with $N$ samples, the expectations in Algorithm~\ref{alg:recalibration_sketch} are replaced with empirical averages. The following theorem demonstrates that Algorithm~\ref{alg:recalibration_sketch} satisfies the conditions stated in Theorem~\ref{thm:pac_informal}.
\begin{manualtheorem}{2.2}\label{thm:convergence}
Given any input ${\hat{p}}$ and tolerance $\epsilon$, Algorithm~\ref{alg:recalibration_sketch} terminates in $O(K/\epsilon^2)$ iterations. For any $\lambda > 0$, given $O(\text{poly}(K, C, \log(1/\delta), \lambda))$ samples, with $1-\delta$ probability Algorithm~\ref{alg:recalibration_sketch} outputs a $({\mathcal{L}}^K, \epsilon+\lambda)$-decision calibrated prediction function ${\hat{p}}'$ that satisfies ${\mathbb{E}}[\lVert {\hat{p}}'(X) - Y \rVert_2^2] \leq {\mathbb{E}}[\lVert {\hat{p}}(X) - Y \rVert_2^2] + \lambda$.
\end{manualtheorem}
The theorem demonstrates that if we can solve the inner search problem over $B^K$, then we can obtain decision calibrated predictions efficiently in samples and computation.
\subsection{Relaxation of Decision Calibration for Computational Efficiency}
\label{sec:computation}
We complete the discussion by addressing the open computational question.
Directly optimizing over ${B^K}$ is difficult, so we instead define the softmax relaxation.
\begin{align*}
{\bar{B}^K} = \left\lbrace \bar{b}_w \mid \forall w \in {\mathbb{R}}^{K \times C} \right\rbrace&&
\textrm{where~~}\bar{b}_w(q,a) = \frac{e^{\langle q, w_a\rangle}}{\sum_{a'} e^{\langle q, w_{a'} \rangle}}
\end{align*}
The key motivation behind this relaxation is that $\bar{b}_w \in {\bar{B}^K}$ is now differentiable in $w$, so we can optimize over ${\bar{B}^K}$ using gradient descent.
Correspondingly some technical details in Algorithm~\ref{alg:recalibration_sketch} change to accommodate soft partitions; we address these modifications in Appendix~\ref{appendix:relax} and show that after these modifications Theorem~\ref{thm:convergence} still holds.
Intuitively, the main reason that we can still achieve decision calibration with softmax relaxation is because ${B^K}$ is a subset of the closure of ${\bar{B}^K}$.
Therefore, compared to Eq.(\ref{eq:decision_calibration_equivalent}), we enforce a slightly stronger condition with the softmax relaxation. This can be formalized in the following proposition.
\begin{restatable}{prop}{propreduction}
\label{prop:reduction_to_decision}
A prediction function ${\hat{p}}$ is $({\mathcal{L}}^K, \epsilon)$-decision calibrated if it satisfies
\begin{align}
\sup_{\bar{b} \in {\bar{B}^K}}\sum_{a=1}^K \left\lVert {\mathbb{E}} [ ({\hat{Y}} - Y) \bar{b}({\hat{p}}(X), a) ] \right\rVert_2 \leq \epsilon \label{eq:decision_calibration_equivalent2}:
\end{align}
\end{restatable}
We remark that unlike Proposition~\ref{prop:decision_equivalence} (which is an ``if and only if'' statement), Proposition~\ref{prop:reduction_to_decision} is a ``if'' statement. This is because the closure of $\bar{B}^K$ is superset of $B^K$, so Eq.(\ref{eq:decision_calibration_equivalent2}) implies Eq.(\ref{eq:decision_calibration_equivalent}) but not vice versa.
\section{Conclusion and Discussion}
Notions of calibration are important to decision makers.
Specifically, we argue that many of the benefits of calibration can be summarized in two key properties---no regret decision making and accurate loss estimation.
Our results demonstrate that it is possible to achieve these desiderata for realistic decision makers choosing between a bounded number of actions, through the framework of decision calibration.
Our results should not be interpreted as guarantees about the quality of individual predictions.
For example, the medical provider cannot guarantee to each patient that their expected loss is low. Instead the guarantee should be interpreted as from the machine learning provider to the medical provider (who treats a group of patients).
Misuse of our results can lead to unjustified claims about the trustworthiness of a prediction.
Still, a clear benefit of the framework is that---due to accurate loss estimation---the overall quality of the predictor can be evaluated using unlabeled data.
One natural way to strengthen the guarantees of decision calibration would be extend the results to give decision ``multi-calibration,'' as in \cite{hebert2018multicalibration,dwork2021outcome}.
Multi-calibration guarantees that predictions are calibrated, not just overall, but also when restricting our attention to structured (identifiable) subpopulations.
In this paper, we consider loss functions that only depend on $x$ through ${\hat{p}}(x)$; extending decision calibration to a multi-group notion would correspond to including loss functions that can depend directly on the input features in $x$.
However, when the input features are complex and high-dimensional (e.g. medical images), strong results (such as the feasibility of achieving ${\mathcal{L}}^K$-decision calibration) become much more difficult.
As in \cite{hebert2018multicalibration}, some parametric assumptions on how the loss can depend on the input feature $x$ would be necessary.
\section{Acknowledgements}
This research was supported in part by AFOSR (FA9550-19-1-0024), NSF (\#1651565, \#1522054, \#1733686), ONR, and FLI. SZ is supported in part by a JP Morgan fellowship and a Qualcomm innovation fellowship. MPK is supported by the Miller Institute for Basic Research in Science and the Simons Collaboration on the Theory of Algorithmic Fairness. TM acknowledges support of Google Faculty Award and NSF IIS 2045685.
\section{Calibration: A Decision Making Perspective}
In our setup, the decision maker outsources the prediction task and uses a prediction function ${\hat{p}}$ provided by a third-party forecaster (e.g., an ML Prediction API).
Thus, we imagine a forecaster who trains a generic prediction function
without knowledge of the exact loss $\ell$ downstream decision makers will use (or worse, will be used by multiple decision-makers with different loss functions).
For example, the prediction function may be trained to minimize a standard objective such as L2 error or log likelihood, then sold to decision makers as an off-the-shelf solution.
In such a setting, the decision makers may be concerned that the off-the-shelf solution may not perform well according to their loss function.
If the forecaster could predict optimally
(i.e. ${\hat{p}}(X) = p^*(X)$ almost surely),
then there would be no issue of trust;
of course, perfect predictions are usually impossible, so the forecaster needs feasible ways of conveying trust to the decision makers.
To mitigate concerns about the performance of the prediction function, the forecaster might aim to offer
performance guarantees applicable to decision makers
whose loss functions come from class of losses ${\mathcal{L}} \subset {\mathcal{L}_{\mathrm{all}}}$.
\subsection{Decision Calibration}
First and foremost, a decision maker wants assurance that making decisions based on the prediction function ${\hat{p}}$ give low expected loss.
In particular, a decision maker with loss $\ell$ wants assurance that the Bayes decision rule $\delta_\ell$ is the best decision making strategy, given $\hat{p}$.
In other words, she wants $\delta_\ell$ to incur a lower loss compared to alternative decision rules.
Second, the decision maker wants to know how much loss is going to be incurred (before the actions are deployed and outcomes are revealed); the decision maker does not want to incur
any additional loss in surprise that she has not prepared for.
To capture these desiderata we formalize a definition based on the following intuition: suppose a decision maker with some loss function $\ell$ considers a decision rule $\delta \in {\drule_{\mathrm{all}}}$ (that may or may not be the Bayes decision rule), the decision maker should be able to correctly compute the expected loss of using $\delta$ to make decisions, as a function of \emph{the predictions} $\hat{p}$.
\begin{definition}[Decision Calibration]
\label{def:decision_calibration}
For any set of loss functions ${\mathcal{L}} \subset {\mathcal{L}_{\mathrm{all}}}$ and set of decision rules $\drule \subset {\drule_{\mathrm{all}}} := \lbrace \Delta^C \to {\mathcal{A}} \rbrace$, we say that a prediction ${\hat{p}}$ is $({\mathcal{L}};\drule)$-decision calibrated (with respect to $p^*$) if $\forall \ell \in {\mathcal{L}}$ and $\delta \in \drule$ with the same action space ${\mathcal{A}}$~\footnote{We require $\ell$ and $\delta$ to have the same action space ${\mathcal{A}}$ for type check reasons. Eq.(\ref{eq:equal_loss}) only has meaning if the loss $\ell$ and decision rule $\drule$ are associated with the same action space ${\mathcal{A}}$. }
\begin{align}
{\mathbb{E}}_X {\mathbb{E}}_{{\hat{Y}} \sim {\hat{p}}(X)} [\ell({\hat{Y}}, \delta({\hat{p}}(X))) ] = {\mathbb{E}}_X {\mathbb{E}}_{Y \sim p^*(X)} [\ell(Y, \delta({\hat{p}}(X))) ] \label{eq:equal_loss}
\end{align}
In particular, we say ${\hat{p}}$ is ${\mathcal{L}}$-decision calibrated if it is $({\mathcal{L}};\drule_{\mathcal{L}})$-decision calibrated.
\end{definition}
The left hand side of Eq.(\ref{eq:equal_loss}) is the ``simulated'' loss where the outcome ${\hat{Y}}$ is hypothetically drawn from the predicted distribution. The decision maker can compute this just by knowing the input features $X$ and without knowing the outcome $Y$. The right hand side of Eq.(\ref{eq:equal_loss}) is the true loss that the decision maker incurs in reality if she uses the decision rule $\delta$.
Intuitively, the definition captures the idea that the losses in ${\mathcal{L}}$ and decision rules in $\drule$ do not distinguish between outcomes sampled according to the predicted probability and the true probability; specifically, the definition can be viewed as a concrete instantiation of the framework of \emph{Outcome Indistinguishability}~\citep{dwork2021outcome}.
As a cautionary remark, Eq.(\ref{eq:equal_loss}) should not be mis-interpreted as guarantees about individual decisions; Eq.(\ref{eq:equal_loss}) only looks at the average loss when $X,Y$ is a random draw from the population. Individual guarantees are usually impossible without tools beyond machine learning~\citep{zhao2021right}. In addition, Definition~\ref{def:decision_calibration} does not consider decision rules that can directly depend on $X$, as $\delta \in {\drule_{\mathrm{all}}}$ only depends on $X$ via the predicted probability ${\hat{p}}(X)$. Studying decision rules that can directly depend on $X$ require tools such as multicalibration~\citep{hebert2018multicalibration} which are beyond the scope of this paper (See related work).
In Definition~\ref{def:decision_calibration} we also define the special notion of ${\mathcal{L}}$-decision calibrated because given a set of loss functions ${\mathcal{L}}$, we are often only interested in the associated Bayes decision rules $\drule_{\mathcal{L}}$, i.e. the set of decision rules that are optimal under \textit{some} loss function.
For the rest of the paper we focus on ${\mathcal{L}}$-decision calibration
for simplicity. ${\mathcal{L}}$-decision calibration can capture the desiderata we discussed above formalized in the following proposition.
\begin{prop}
\label{prop:nice_consequences}
If a prediction function ${\hat{p}}$ is ${\mathcal{L}}$-decision calibrated, then it satisfies
\begin{align*}
\forall \delta' \in \drule_{\mathcal{L}}, &{\mathbb{E}}_X{\mathbb{E}}_{Y \sim p^*(X)}[\ell(Y, \delta_\ell({\hat{p}}(X))) ] \leq {\mathbb{E}}_X{\mathbb{E}}_{Y \sim p^*(X)}[\ell(Y, \delta'({\hat{p}}(X))) ] & \text{(No regret)} \\
& {\mathbb{E}}_X {\mathbb{E}}_{{\hat{Y}} \sim {\hat{p}}(X)} [\ell({\hat{Y}}, \delta_{\ell}({\hat{p}}(X))) ] = {\mathbb{E}}_X {\mathbb{E}}_{Y \sim p^*(X)} [\ell(Y, \delta_{\ell}({\hat{p}}(X))) ] & \text{(Accurate loss estimation)}
\end{align*}
\end{prop}
\textbf{No regret} states that the Bayes decision rule $\delta_\ell$ is not worse than any alternative decision rule $\delta' \in \drule_{{\mathcal{L}}}$.
In other words, the decision maker is incentivized to take optimal actions according to their true loss function.
That is, using the predictions given by $\hat{p}$, the decision maker cannot improve their actions by using a decision rule $\delta'$ that arises from a different loss function $\ell' \in {\mathcal{L}}$.
\textbf{Accurate loss estimation} states that for the Bayes decision rule $\delta_\ell$, the simulated loss on the left hand side (which the decision maker can compute before the outcomes are revealed) equals the true loss on the right hand side.
This ensures that the decision maker knows the expected loss that will be incurred over the distribution of individuals
and can prepare for it.
This is important because in most prediction tasks, the labels $Y$ are revealed with a significant delay or never revealed. For example, the hospital might be unable to follow up on the true outcome of all of its patients.
In practice, the forecaster chooses some set ${\mathcal{L}}$ to achieve ${\mathcal{L}}$-decision calibration, and advertise it to decision makers. A decision makers can then check whether their loss function $\ell$ belongs to the advertised set ${\mathcal{L}}$. If it does, the decision maker should be confident that the Bayes decision rule $\delta_\ell$ has low loss compared to alternatives in $\drule_{\mathcal{L}}$, and they can know in advance the loss that will be incurred.
\subsection{Decision Calibration Generalizes Existing Notions of Calibration}
We show that by varying the choice of loss class ${\mathcal{L}}$, decision calibration can actually express prior notions of calibration.
For example, consider confidence calibration, where among the samples whose the top probability is $\beta$, the top accuracy is indeed $\beta$. Formally, confidence calibration requires that
\begin{align*}
\Pr[Y = \arg\max {\hat{p}}(X) \mid \max {\hat{p}}(X) = \beta] = \beta.
\end{align*}
We show that a prediction function ${\hat{p}}$ is confidence calibrated if and only if it is ${\mathcal{L}}_r$-decision calibration, where ${\mathcal{L}}_r$ is defined by
\begin{align*}
{\mathcal{L}}_r := \left\lbrace
\ell(y, a) = \mathbb{I}(y \neq a \land a \neq \bot) + \beta \cdot \mathbb{I}(a = \bot) :
a \in {\mathcal{Y}} \cup \lbrace \bot \rbrace, \forall \beta \in [0, 1] \right\rbrace
\end{align*}
Intuitively, loss functions in ${\mathcal{L}}_r$ corresponds to the refrained prediction task: a decision maker chooses between reporting a class label, or reporting ``I don't know,'' denoted $\bot$.
She incurs a loss of $0$ for correctly predicting the label $y$, a loss of $1$ for reporting an incorrect class label, and a loss of $\beta < 1$ for reporting ``I don't know''.
If a decision maker's loss function belong to this simple class of losses ${\mathcal{L}}_r$, she can use a confidence calibrated prediction function ${\hat{p}}$, because the two desiderata (no regret and accurate loss estimation) in Proposition~\ref{prop:nice_consequences} are true for her.
However, such ``refrained prediction`` decision tasks only account for a tiny subset of all possible tasks that are interesting to decision makers.
Similarly, classwise calibration is characterized through decision calibration using a class of loss functions that penalizes class-specific false positives and negatives.
In this way, decision calibration clarifies the implications of existing notions of calibration on decision making: relaxed notions of calibration correspond to decision calibration over restricted classes of losses.
In general, decision calibration provides a unified view of most existing notions of calibration as the following theorem shows.
\begin{table}
\centerfloat
\vspace{-10mm}
\begin{adjustwidth}{-.3in}{-.3in}
\begin{tabular}{p{0.42\linewidth}|p{0.49\linewidth}}
Existing Calibration Definitions & Associated Loss Functions \\
\hline
$\begin{array}{l} \text{Confidence Calibration \citep{guo2017calibration}} \\ \Pr[Y = \arg\max {\hat{p}}(X) \mid \max {\hat{p}}(X) = \beta] = \beta \\ \forall \beta \in [0, 1] \end{array}$ &
$
{\mathcal{L}}_r := \left\lbrace \begin{array}{ll}
\ell(y, a) = \mathbb{I}(y \neq a \land a \neq \bot) + \beta \cdot \mathbb{I}(a = \bot) : \\
a \in {\mathcal{Y}} \cup \lbrace \bot \rbrace, \forall \beta \in [0, 1] \end{array} \right\rbrace
$ \\
\hline
$\begin{array}{l} \text{Classwise Calibration \citep{kull2019beyond}} \\
{\mathbb{E}}[Y_c \mid \hat{p}_c(X) = \beta] = \beta, \forall c \in [C], \forall \beta \in [0, 1]
\end{array} $ &
${\mathcal{L}}_{cr} := \left\lbrace \begin{array}{l}
\ell_c(y, a) = \mathbb{I}(a = \bot) + \beta_1 \cdot \mathbb{I}(y = c \land a = T) \\
\qquad\qquad\qquad + \beta_2 \cdot \mathbb{I}(y \neq c \land a = F) :\\
a \in \lbrace T, F, \bot \rbrace,
\forall \beta_1, \beta_2 \in \mathbb{R}, c \in [C] \end{array} \right\rbrace$
\\
\hline
$\begin{array}{l} \text{Distribution Calibration \citep{kull2015novel} } \\ {\mathbb{E}}[Y \mid {\hat{p}}(X) = q] = q, \forall q \in \Delta^C \end{array}$ &
${\mathcal{L}}_{\text{all}} = \lbrace\ell:{\mathcal{Y}} \times {\mathcal{A}} \mapsto \mathbb{R} \rbrace$
\end{tabular}
\end{adjustwidth}
\vspace{3mm}
\caption
A prediction function ${\hat{p}}$ satisfies the calibration definitions on the left if and only if it satisfies ${\mathcal{L}}$-decision calibration for the loss function families on the right (Theorem~\ref{thm:equivalence}).}
\vspace{-3mm}
\label{table:calibration}
\end{table}
\begin{restatable}{theorem}{thmequivalence}[Calibration Equivalence]
\label{thm:equivalence}
For any true distribution $p^*$,
and for the loss function sets ${\mathcal{L}}_r, {\mathcal{L}}_{cr}$ defined in Table~\ref{table:calibration}, a prediction function ${\hat{p}}$ is
\begin{itemize}
\item confidence calibrated iff it is ${\mathcal{L}}_r$-decision calibrated.
\item classwise calibrated iff it is ${\mathcal{L}}_{cr}$-decision calibrated.
\item distribution calibrated iff it is ${\mathcal{L}}_{\text{all}}$-decision calibrated.
\end{itemize}
\end{restatable}
For proof of this theorem see Appendix~\ref{appendix:proof}. In Table~\ref{table:calibration}, confidence and classwise calibration are weak notions of calibration; correspondingly the loss function families ${\mathcal{L}}_r$ and ${\mathcal{L}}_{\text{cr}}$ are also very restricted.
On the other hand, distribution calibration (i.e. ${\mathbb{E}}[Y \mid {\hat{p}}(X) = q] = q, \forall q \in \Delta^C$) is equivalent to ${\mathcal{L}_{\mathrm{all}}}$-decision calibration.
This means that a distribution calibrated predictor guarantees
the no regret and accurate loss estimation properties as in Proposition~\ref{prop:nice_consequences} to a decision maker holding any loss functions.
Unfortunately, distribution calibration is very challenging to verify or achieve. To understand the challenges, consider certifying whether a given predictor ${\hat{p}}$ is distribution calibrated.
Because
we need to reason about the conditional distribution ${\mathbb{E}}[Y \mid {\hat{p}}(X) = q]$ for every $q$ that ${\hat{p}}$ can predict (i.e. the support of ${\hat{p}}$), the necessary sample complexity
grows linearly in the support of ${\hat{p}}$. Of course, for a trivial predictors that map all inputs $x$ to the same prediction $q_0$ (i.e. ${\hat{p}}(x) = q_0, \forall x \in {\mathcal{X}}$) distribution calibration is easy to certify~\citep{widmann2019calibration}, but such predictors have no practical use.
Our characterization of distribution calibration further
sheds light on why it is so difficult to achieve.
${\mathcal{L}_{\mathrm{all}}}$ consists of \textit{all} loss function, including all loss functions $\ell: {\mathcal{Y}} \times {\mathcal{A}} \to {\mathbb{R}}$ whose action space ${\mathcal{A}}$ contains exponentially many elements (e.g. $|{\mathcal{A}}| = 2^C$).
The corresponding decision rules $\delta\in \drule_{{\mathcal{L}_{\mathrm{all}}}}: \Delta^C \to {\mathcal{A}}$ may also map $\Delta^C$ to exponentially many possible values.
Enforcing Definition~\ref{def:decision_calibration} for such complex loss functions and decision rules is naturally difficult.
\subsection{Decision Calibration over Bounded Action Space}
In many contexts, directly optimizing for distribution calibration may be overkill.
In particular, in most realistic settings, decision makers tend to have a bounded number of possible actions, so the relevant losses come from ${\mathcal{L}}^K$ for reasonable $K \in {\mathbb{N}}$.
Thus, we consider obtaining decision calibration for all loss functions defined over a bounded number of actions $K$.
In the remainder of the paper, we focus on this restriction of decision calibration to the class of losses with bounded action space; we reiterate the definition of decision calibration for the special case of ${\mathcal{L}}^K$.
\begin{definition}[${\mathcal{L}}^K$-Decision Calibration]
\label{def:decision_calibration_lk}
Let ${\mathcal{L}}^K$ be the set of all loss functions with $K$ actions $
{\mathcal{L}}^K = \lbrace \ell: {\mathcal{Y}} \times {\mathcal{A}} \to {\mathbb{R}}, |{\mathcal{A}}| = K \rbrace
$, we say that a prediction ${\hat{p}}$ is ${\mathcal{L}}^K$-decision calibrated (with respect to $p^*$) if $\forall \ell \in {\mathcal{L}}^K$ and $\delta \in \drule_{{\mathcal{L}}^K}$
\begin{align}
{\mathbb{E}}_X {\mathbb{E}}_{{\hat{Y}} \sim {\hat{p}}(X)} [\ell({\hat{Y}}, \delta({\hat{p}}(X))) ] = {\mathbb{E}}_X {\mathbb{E}}_{Y \sim p^*(X)} [\ell(Y, \delta({\hat{p}}(X))) ] \label{eq:equal_loss}
\end{align}
\end{definition}
The key result (that we show in Section 4) is that ${\mathcal{L}}^K$-decision calibration can be efficiently verified and achieved for \textit{all} predictors.
Specifically, we show that the sample and time complexity necessary to learn ${\mathcal{L}}^K$-decision calibrated predictors depends on the number of actions $K$, not on the support of $\hat{p}$.
This is in contrast to the standard approach for establishing distribution calibration, which scales with the support of ${\hat{p}}$.
Before studying the algorithmic aspects of decision calibration, we argue that ${\mathcal{L}}^K$-decision calibration implies similar performance guarantees as distribution calibration to decision makers with bounded actions.
\paragraph{From decision calibration to distribution calibration}
We argue that in the practical context where decision makers have a bounded number of actions, ${\mathcal{L}}^K$-decision calibration is actually as strong as distribution calibration.
Specifically, we show that given a ${\mathcal{L}}^K$-decision calibrated predictor ${\hat{p}}$ and a chosen loss $\ell \in {\mathcal{L}}^K$, a decision maker can construct a post-processed predictor ${\hat{p}}_\ell$ that is (1) distribution calibrated; and (2) the Bayes action remains unchanged under ${\hat{p}}_\ell$ (i.e. $\delta_\ell({\hat{p}}(x)) = \delta_\ell({\hat{p}}_\ell(x))$).
This means the expected loss $\ell$ of decision making under ${\hat{p}}$ is maintained under the post-processed predictor ${\hat{p}}_\ell$.
In other words, for the purposes of decision making, the decision calibrated predictor $\hat{p}$ is identical to the derived predictor that satisfies distribution calibration $\hat{p}_\ell$.
This argument is subtle: on the surface, the idea that decision calibration (which is feasible) goes against the intuition that distribution calibration is difficult to achieve.
Note, however, that the difficulty in achieving distribution calibration comes from the large support of ${\hat{p}}$.
The key insight behind our construction is that, given a \textit{fixed} loss function $\ell$ over $K$ actions, it is possible to
construct a ${\hat{p}}_\ell$ with small support
without losing any information necessary
for making decisions according to $\ell$. In other words, for making good decisions according to \emph{all} loss functions $\ell$, ${\hat{p}}$ might need to have large support; but for a \emph{fixed} $\ell$ with $K$ actions, ${\hat{p}}_\ell$ does not need to have large support.
In this way, we can learn a single ${\mathcal{L}}^K$-decision calibrated predictor (with possibly large support), but view it as giving rise to many different loss-specific distribution calibrated predictors ${\hat{p}}_\ell$ for each $\ell \in {\mathcal{L}}^K$.
Formally, we show the following proposition.
\begin{restatable}{prop}{dectodist}
\label{thm:dec2dist}
Suppose ${\hat{p}}$ is ${\mathcal{L}}^K$-decision calibrated.
Then, for any loss function $\ell \in {\mathcal{L}}^K$, we can construct a predictor ${\hat{p}}_\ell$ of support size $\le K$, such that:
\begin{itemize}
\item ${\hat{p}}_\ell$ is distribution calibrated
\item the optimal decision rule is preserved $\delta_\ell({\hat{p}}_\ell(x)) = \delta_\ell({\hat{p}}(x))$ for all $x \in {\mathcal{X}}$;\\
thus, ${\mathbb{E}}[\ell(Y,\delta_\ell({\hat{p}}_\ell(X)))] = {\mathbb{E}}[\ell(Y,\delta_\ell({\hat{p}}(X)))]$.
\end{itemize}
\end{restatable}
Proposition~\ref{thm:dec2dist} is proved in Appendix~\ref{appendix:dec2dist}.
\subsection{Desiderata of Uncertainty for Decision Making}
\paragraph{Accurate loss estimation.} First and foremost, a decision maker want assurance that making decisions based on a prediction function ${\hat{p}}$ give low expected loss.
Suppose the decision maker uses the Bayes decision rule $\delta_\ell$ (as in Definition~\ref{def:bayes_decision}), then without knowing the outcome $Y$, she can compute her ``simulated'' loss:
$
{\mathbb{E}}_X {\mathbb{E}}_{{\hat{Y}} \sim {\hat{p}}(X)} [\ell({\hat{Y}}, \delta_{\ell}({\hat{p}}(X))) ]
$. This is the loss a decision maker expects to incur assuming the predictions are correct, i.e. the outcome $Y$ indeed is drawn from the predicted distribution ${\hat{p}}(X)$. To assure decision makers that she will not incur any additional loss in surprise, the ``simulated'' loss should equal the true loss.
Formally, a prediction function ${\hat{p}}$ satisfies accurate loss estimation (with respect to ${\mathcal{L}} \subset {\mathcal{L}_{\mathrm{all}}}$ and $p^*$) if $\forall \ell \in {\mathcal{L}}$
\begin{align}
{\mathbb{E}}_X {\mathbb{E}}_{{\hat{Y}} \sim {\hat{p}}(X)} [\ell({\hat{Y}}, \delta_{\ell}({\hat{p}}(X))) ] = {\mathbb{E}}_X {\mathbb{E}}_{Y \sim p^*(X)} [\ell(Y, \delta_{\ell}({\hat{p}}(X))) ] \label{eq:accurate_loss}
\end{align}
For example, given Eq.(\ref{eq:accurate_loss}), a hospital can test the prediction function ${\hat{p}}$ on the features of its current patients; if the simulated loss is small, then the hospital will know that using ${\hat{p}}$ and the Bayes decision rule $\delta_\ell$ leads to low expected loss. If the simulated loss is large the hospital can look for alternative solutions.
\paragraph{Strategyproofness.}
Another property we consider is that that the prediction should discourage intentional mis-specifying the loss function. For example, without guarantees on the predicted probabilities, a hospital may need to be strategic in their recommendation of treatments. For example, hospitals may worry that the predicted probability of a severely bad outcomes (if left untreated) is lower than reality. The hospital might artificially modify its loss function so that the (modified) optimal decision rule recommends invasive treatments more often. This strategy would hedge against costly false negatives, but comes with the risks associated with over-diagnosis and over-treatment~\citep{esserman2013overdiagnosis}.
The decision maker only has to concerned about specifying her true preferences as accurately as possible, and does not have be concerned about the interplay between the loss function and the prediction function.
Formally, a prediction ${\hat{p}}$ is strategy proof (with respect to ${\mathcal{L}} \subset {\mathcal{L}_{\mathrm{all}}}$ and $p^*$) if $\forall \ell, \ell' \in {\mathcal{L}}$
\begin{align}
{\mathbb{E}}[\ell(X, Y, \delta_\ell({\hat{p}}(X)))] \leq {\mathbb{E}}[\ell(X, Y, \delta_{\ell'}({\hat{p}}(X)))] \label{eq:truth_rewarding}
\end{align}
In other words, a decision maker cannot do better by choosing an inaccurate loss function that does not reflect her true preferences.
\section{Empirical Evaluation}
\blfootnote{Decision calibration is implemented in the torchuq package at https://github.com/ShengjiaZhao/torchuq. Code to reproduce these experiments can be found in following directory of the torchuq package ``torchuq/applications/decision\_calibration''}
\subsection{Skin Legion Classification}
\begin{figure}
\centering
\vspace{-10mm}
\includegraphics[width=1.0\linewidth]{plot/ham_example_2_3.png}
\vspace{-3mm}
\caption{An illustrative example of accurate loss estimation on the HAM10000 dataset.
The predictor predicts the probability of 7 skin illness categories (akiec, bcc, ...., mel); the hospital decides between two actions (treatment vs. no treatment). \textbf{Left} An example loss function (details not important). Blue indicates low loss and red indicates high loss. For the malignant conditions such as 'akiec' and 'mel', no treatment has high loss (red); for the benign conditions such as 'nv', (unnecessary) treatment has moderate loss.
\textbf{Middle} Histogram of predicted loss vs. the true loss. The predicted loss is the loss the hospital expected to incur assuming the predicted probabilities are correct under the Bayes decision rule
The true loss is the loss the hospital actually incurs (after ground-truth outcomes are revealed).
We plot the histogram from random train/test splits of the dataset, and observe that the true loss is generally much greater than the predicted loss. Because the hospital might incur loss it didn't expect or prepare for, the hospital cannot trust the prediction function.
\textbf{Right} After applying our recalibration algorithm, the true loss almost matches the predicted loss.
}
\label{fig:ham}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.75\linewidth]{plot/ham_result_2-0-3_3.png}
\vspace{-3mm}
\caption{Calibration improves decision loss and its estimation on the HAM10000 skin legion classification dataset. \textbf{Left} The gap between the predicted decision loss and the true decision loss in Eq.(\ref{eq:loss_gap_metric}) on a set of randomly sampled loss functions. We plot both the average gap (orange) and the worst gap (blue) out of all the loss functions. The dotted lines are the validation set performance, and solid lines are the test set performance.
With more recalibration steps in Algorithm~\ref{alg:recalibration_sketch}, both the average gap and the worst gap improves. The improvements are greater than Dirichlet recalibration (dashed line) \textbf{Right} The decision loss (averaged across all random loss functions). With more recalibration steps the decision loss also improves slightly.}
\label{fig:ham_main_result}
\end{figure}
This experiment materializes our motivating example in the introduction. We aim to show on a real medical prediction dataset, our recalibration algorithm improves both the decision loss and reduces the decision loss estimation error. For the estimation error, as in Definition~\ref{def:decision_calibration_relaxed} for any loss function $\ell$ and corresponding Bayes decision rule $\delta_\ell$ we measure
\begin{align}
\text{loss gap} := \left\lvert {\mathbb{E}} [\ell({\hat{Y}}, \delta_\ell({\hat{p}}(X))) ] - {\mathbb{E}} [\ell(Y, \delta_\ell({\hat{p}}(X))) ] \right\rvert / \sup_{a \in {\mathcal{A}}} \lVert \ell(\cdot, a) \rVert_2 \label{eq:loss_gap_metric}
\end{align}
In addition to the loss function in Figure~\ref{fig:ham} (which is motivated by medical domain knowledge), we also consider a set of 500 random loss functions where for each $y\in{\mathcal{Y}}, a\in{\mathcal{A}}$, $\ell(y, a) \sim \text{Normal}(0, 1)$, and report both the average loss gap and the maximum loss gap across the loss functions.
\paragraph{Setup} We use the HAM10000 dataset~\citep{tschandl2018ham10000}. We partition the dataset into train/validation/test sets, where approximately 15\% of the data are used for validation, while 10\% are used for the test set. We use the train set to learn the baseline classifier ${\hat{p}}$, validation set to recalibrate, and the test set to measure final performance.
For modeling we use the densenet-121 architecture~\citep{huang2017densely}, which achieves around 90\% accuracy.
\paragraph{Methods} For our method we use Algorithm~\ref{alg:recalibration} in Appendix~\ref{appendix:relax} (which is a small extension of Algorithm~\ref{alg:recalibration_sketch} explained in Section~\ref{sec:computation}). We compare with temperature scaling~\citep{guo2017calibration} and Dirichlet calibration~\citep{kull2019beyond}.
We observe that all recalibration methods (including ours) work better if we first apply temperature scaling, hence we first apply it in all experiments.
For example, in Figure~\ref{fig:ham_main_result} temperature scaling corresponds to $0$ decision recalibration steps.
\paragraph{Results} The results are shown in Figure~\ref{fig:ham_main_result}. For these experiments we set the number of actions $K=3$. For other choices we obtain qualitatively similar results in Appendix~\ref{appendix:experiment}.
The main observation is that decision recalibration improves the loss gap in Eq.(\ref{eq:loss_gap_metric}) and slightly improves the decision loss. Our recalibration algorithm converges rather quickly (in about 5 steps). We also observe that our recalibration algorithm slightly improves top-1 accuracy (the average improvement is $0.40 \pm 0.08$\%) and L2 loss (the average decrease is $0.010 \pm 0.001$) on the test set.
\begin{figure}
\centering
\includegraphics[width=1.0\linewidth]{plot/calibrate_decision_imagenet_inception_v3_3.png}
\caption{Calibration improves decision loss estimation on Imagenet-1000. The meaning of the plot is identical to Figure~\ref{fig:ham_main_result}. From left to right we vary the number of classification categories $C$ from 10 to 1000. Our algorithm reduces the gap between predicted loss and true loss in Eq.(\ref{eq:loss_gap_metric}) even up to 1000 classes, although more classes require more iterations and are more prone to over-fitting. Dirichlet calibration is less scalable than our method. For example, with 1000 classes the loss gap of Dirichlet calibration is off the chart. }
\label{fig:imagenet_inception}
\vspace{-3mm}
\end{figure}
\subsection{Imagenet Classification}
We stress test our algorithm on Imagenet. The aim is to show that even with deeply optimized classifiers (such as inception-v3 and resnet) that are tailor made for the Imagenet benchmark and a large number of classes (1000 classes), our recalibration algorithm can improve the loss gap in Eq.(\ref{eq:loss_gap_metric}).
\paragraph{Setup} The setup and baselines are identical to the HAM10000 experiment with two differences: we use pretrained models provided by pytorch, and among the 50000 standard validation samples, we use 40000 samples for recalibration and 10000 samples for testing. Similar to the previous experiment, we randomly generate a set of 500 loss functions from normal distributions.
\paragraph{Results} The results are shown in Figure~\ref{fig:imagenet_inception} with additional plots in Appendix~\ref{appendix:experiment}. Decision calibration can generalize to a larger number of classes, and still provides some (albeit smaller) benefits with 1000 classes. Recalibration does not hurt accuracy and L2 error, as we observe that both improve by a modest amount (on average by $0.30$\% and $0.00173$ respectively).
We contrast decision calibration with Dirichlet calibration~\citep{kull2019beyond}. Dirichlet calibration
also reduces the loss gap when the number of classes is small (e.g. 10 classes), but is less scaleble than decision recalibration. With more classes its performance degrades much more than decision calibration.
\section{Introduction}
\label{introduction}
\input{intro_new.tex}
\section{Background}
\input{related_work.tex}
\input{def.tex}
\input{bounded_action}
\input{experiment}
\input{related}
\input{conclusion}
\bibliographystyle{iclr2021_conference}
\section{Related Work}
\paragraph{Calibration}
Early calibration research focus on binary classification~\citep{brier1950verification,dawid1984present}.
For multiclass classification,
the strongest definition is distribution (strong) calibration~\citep{kull2015novel,song2019distribution} but is hindered by sample complexity. Weaker notions such as confidence (weak) calibration~\citep{platt1999probabilistic,guo2017calibration}, class-wise calibration~\citep{kull2019beyond} or average calibration~average calibration~\citep{kuleshov2018accurate} are more commonly used in practice. To unify these notions, \citep{widmann2019calibration} proposes ${\mathcal{F}}$-calibration but lacks detailed guidance on which notions to use.
\paragraph{Individual calibration} Our paper discusses the \textit{average} decision loss over the population $X$. A stronger requirement is to guarantee the loss for each individual decision.
Usually individual guarantees are near-impossible~\citep{barber2019limits} and are only achievable with hedging~\citep{zhao2021right} or randomization~\citep{zhao2020individual}.
\paragraph{Multi-calibration and Outcome Indistinguishability.}
Calibration have been the focus of many works on fairness, starting with \citep{kleinberg2016inherent,pleiss2017fairness}.
Multi-calibration has emerged as a noteworthy notion of fairness~\citep{hebert2018multicalibration, kim2019multiaccuracy,dwork2019learning,shabat2020sample,jung2020moment,dwork2021outcome} because it goes beyond ``protected'' groups, and guarantees calibration for any group that is identifiable within some computational bound.
Recently, \citep{dwork2021outcome} generalizes multicalibration to outcome
indistinguishability (OI).
Decision calibration is a special form of OI.
\subsection{Setup and Notation}
We consider the prediction problem with random variables $X$ and $Y$, where
$X \in {\mathcal{X}}$ denotes the input features, and $Y \in {\mathcal{Y}}$ denotes the label. We focus on classification where ${\mathcal{Y}} = \lbrace (1, 0, \cdots, 0), (0, 1, \cdots, 0), \cdots, (0, 0, \cdots, 1) \rbrace$ where each $y \in {\mathcal{Y}}$ is a one-hot vector with $C \in {\mathbb{N}}$ classes.~\footnote{We can also equivalently define ${\mathcal{Y}} = \lbrace 1, 2, \cdots, C \rbrace$, here we denote $y$ by a one-hot vector for notation convenience when taking expectations.}
A probability prediction function is a map $\hat{p}: {\mathcal{X}} \to \Delta^C$ where $\Delta^C$ is the $C$-dimensional simplex. We define the support of ${\hat{p}}$ as the set of distributions it could predict, i.e. $\lbrace {\hat{p}}(x) \vert x \in {\mathcal{X}} \rbrace$.
We use $p^*: {\mathcal{X}} \to \Delta^C$ to denote the true conditional probability vector, i.e. $p^*(x) = {\mathbb{E}}[Y \mid X= x] \in \Delta^C$,
and for all $c \in [C]$, each coordinate gives the probability of the class $p^*(x)_c = \Pr[Y_c \mid X = x]$.
\subsection{Decision Making Tasks and Loss Functions}
We formalize a decision making task as a loss minimization problem. The decision maker has some set of available actions ${\mathcal{A}}$ and a loss function $\ell: {\mathcal{Y}} \times {\mathcal{A}} \to {\mathbb{R}}$. In this paper we assume the loss function does not directly depend on the input features $X$.
For notational simplicity we often refer to a (action set, loss function) pair $({\mathcal{A}}, \ell)$ only by the loss function $\ell$: the set of actions ${\mathcal{A}}$ is implicitly defined by the domain of $\ell$. We denote the set of all possible loss functions as ${\mathcal{L}_{\mathrm{all}}} = \lbrace\ell: {\mathcal{Y}} \times {\mathcal{A}} \to \mathbb{R} \rbrace$.
We treat all action sets ${\mathcal{A}}$ with the same cardinality as the same set --- they are equivalent up to renaming the actions. A convenient way to think about this is that we only consider actions sets ${\mathcal{A}} \in \lbrace [1], [2], \cdots, [K], \cdots, {\mathbb{N}}, {\mathbb{R}} \rbrace$ where $[K] = \lbrace 1, \cdots, K \rbrace$.
\subsection{Bayes Decision Making}
Given some predicted probability ${\hat{p}}(X)$ on $Y$, a decision maker selects an action in ${\mathcal{A}}$. We assume that the decision maker selects the action based on the predicted probability. That is, we define a decision function as any map from the predicted probability to an action $\delta: \Delta^C \to {\mathcal{A}}$. and denote by ${\drule_{\mathrm{all}}}$ as the set of all decision functions.
Typically a decision maker selects the action that minimizes the expected loss (under the predicted probability). This strategy is formalized by the following definition of Bayes decision making.
\begin{definition}[Bayes Decision]
\label{def:bayes_decision}
Choose any $\ell \in {\mathcal{L}_{\mathrm{all}}}$ with corresponding action space ${\mathcal{A}}$ and prediction ${\hat{p}}$, define the Bayes decision function as
$
\delta_\ell({\hat{p}}(x)) = \arg\inf_{a \in {\mathcal{A}}} {\mathbb{E}}_{{\hat{Y}} \sim {\hat{p}}(x)} [\ell({\hat{Y}}, a)]
$.
For any subset ${\mathcal{L}} \subset {\mathcal{L}_{\mathrm{all}}}$ denote the set of all Bayes decision functions as $\drule_{\mathcal{L}} := \lbrace \delta_\ell, \ell \in {\mathcal{L}} \rbrace$.
\end{definition}
| {'timestamp': '2021-07-14T02:03:41', 'yymm': '2107', 'arxiv_id': '2107.05719', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05719'} | arxiv |
\section{Introduction}
State-of-the-art artificial neural networks (ANNs) achieve impressive results in a variety of machine intelligence tasks \citep{sejnowski2020unreasonable}. However, they largely rely on mechanisms that diverge from the original inspiration from biological neural networks \citep{bengio2015towards, illing2019biologically}. As a result, only a small part of this prolific field also contributes to computational neuroscience. In fact, this biological implausibility is also an important issue for machine intelligence. For their impressive performance, ANNs trade off other desired properties, which are present in biological systems. For example, ANN training often demands very large and labelled datasets. When labels are unavailable, self-supervised learning schemes exist, where supervisory error signals generated by the network itself are exploited and backpropagated from the output towards the input to update the network's parameters \citep{goodfellow2014generative, devlin2018bert, chen2020simple}. However, this global propagation of signals in deep networks introduces another limitation. Namely, it prevents the implementation of efficient distributed computing hardware that would be based on only local signals from neighbouring physical nodes in the network, and is in contrast to the local synaptic plasticity rules that are believed to govern biological learning.
Several pieces of work have been addressing parts of the biological implausibility and drawbacks of backpropagation in ANNs \citep{bengio2015towards, lillicrap2016random, guerguiev2017towards, pfeiffer2018deep, illing2019biologically, pogodin2020kernelized, millidge2020predictive, pogodin2021towards}.
Recently, an approximation to backpropagation that is mostly Hebbian, i.e. relies on mostly pre- and post-synaptic activity of each synapse, has been achieved by reducing the global error requirements to 1-bit information \citep{pogodin2020kernelized}. Two schemes that further localize the signal that is required for a weight update are Equilibrium Propagation \citep{scellier2017equilibrium} and Predictive Coding \citep{millidge2020predictive}. Both methods approximate backpropagation through Hebbian-like learning, by delegating the global aspect of the computation, from a global error signal, to a global convergence of the network state to an equilibrium. This equilibrium is reached through several iterative steps of feed-forward and feed-back communication throughout the network, before the ultimate weight update by one training example. The biological plausibility and hardware-efficiency of this added iterative and heavily feedback-dependent process are open questions that begin to be addressed \citep{ernoult2020equilibrium}.
Moreover, learning through backpropagation, and presumably also its approximations, has another indication of biological implausibility, which also significantly limits ANN applicability. Namely, it produces networks that are confused by small adversarial perturbations of the input, which are imperceptible by humans.
It has recently been proposed that a defence strategy of "deflection" of adversarial attacks may be the ultimate solution to that problem \citep{qin2020deflecting}. Through this strategy, to cause confusion in the network's inferred class, the adversary is forced to generate such a changed input that really belongs to the distribution of a different input class. Intuitively, but also strictly by definition, this deflection is achieved if a human assigns to the perturbed input the same label that the network does.
Deflection of adversarial attacks in ANNs has been demonstrated by an elaborate scheme that is based on detecting the attacks \citep{qin2020deflecting}. However, the human ability to deflect adversarial perturbations likely does not rely on detecting them, but rather on effectively ignoring them, making the deflecting type of robustness an emergent property of biological computation rather than a defence mechanism.
The biological principles that underlie this property of robustness are unclear, but it might emerge from the distinct algorithms that govern learning in the brain.
Therefore, what is missing is a biologically plausible model that can learn from fewer data-points, without labels, through local plasticity, and without feedback from distant layers. This model could then be tested for emergent adversarial robustness.
A good candidate category of biological networks and learning algorithms is that of competitive learning. Neurons that compete for their activation through lateral inhibition are a common connectivity pattern in the superficial layers of the cerebral cortex \citep{douglas2004neuronal, binzegger2004quantitative}. This pattern is described as winner-take-all (WTA), because competition suppresses activity of weakly activated neurons, and emphasizes strong ones. Combined with Hebbian-like plasticity rules, WTA connectivity gives rise to competitive-learning algorithms. These networks and learning schemes have been long studied \citep{von1973self} and a large literature based on simulations and analyses describes their functional properties. A WTA neuronal layer, depending on its specifics, can restore missing input signals \citep{rutishauser2011collective, diehl2016learning}, perform decision making i.e. winner selection \citep{hahnloser1999feedback, maass2000computational, rutishauser2011collective} generate oscillations such as those that underlie brain rhythms \citep{cannon2014neurosystems}. Perhaps more importantly, its neurons can learn to become selective to different input patterns, such as orientation of visual bars in models of the primary visual cortex \citep{von1973self}, MNIST handwritten digits \citep{nessler2013PLoS, diehl2015unsupervised, krotov2019unsupervised}, CIFAR10 objects \citep{krotov2019unsupervised}, spatiotemporal spiking patterns \citep{nessler2013PLoS}, and can adapt dynamically to model changing objects \citep{moraitis2020shortterm}.
The WTA model is indeed biologically plausible, Hebbian plasticity is local, and learning is input-driven, relying on only feed-forward communication of neurons -- properties that seem to address several of the limitations of ANNs. However, the model's applicability is limited to simple tasks, because, the theoretical literature related to Hebbian WTA remains surprisingly limiting, despite its long history, and the strong and productive community interest \citep{sanger1989optimal, foldiak1989adaptive, foldiak1990forming, linsker1992local, olshausen1996emergence, bell1995information, olshausen1997sparse, lee1999independent, nessler2013PLoS, pehlevan2014hebbian, hu2014hebbian, PehlevanNIPS2015, pehlevan2017clustering, isomura2018error}.
It remains unclear which specific plasticity rule and structure could optimize a non-spiking WTA for Bayesian inference, how to minimize a common loss function such as cross-entropy despite unsupervised learning, and how a cortical or artificial WTA could represent varying families of probability distributions. In summary, on the theoretical side, an algorithm that is simultaneously normative, based on WTA networks and Hebbian unsupervised plasticity, performs Bayesian inference, and, importantly, is composed of conventional, i.e. non-spiking, ANN elements and is rigorously linked to modern ANN tools such as cross-entropy loss, would be an important advance but has been missing. On the practical side, evidence that Hebbian WTA networks could be useful for presently pertinent issues of modern ANNs such as adversarial robustness, generation of synthetic images, or faster learning, has remained limited. Here we aim to fill these gaps.
Recently, when WTA networks were studied in a theoretical framework compatible with conventional machine learning (ML), but in the context of short-term as opposed to long-term Hebbian plasticity, it resulted in surprising practical advantages over supervised ANNs \citep{moraitis2020shortterm}.
A similar theoretical approach could also reveal unknown advantages of long-term Hebbian plasticity in WTA networks.
In addition, it could provide insights into how a WTA microcircuit could participate in larger-scale computation by deeper cortical or artificial networks.
Here we construct "SoftHebb", a biologically plausible WTA model that is based on standard rate-based neurons as in ANNs, can accommodate various activation functions, and learns without labels, using local plasticity and only feed-forward communication, i.e. the properties we seek in an ANN.
Importantly, it is equipped with a simple normalization of the layer's activations, and an optional temperature-scaling mechanism \citep{hinton2015distilling}, producing a soft WTA instead of selecting a single "hard" winner neuron. This allows us to prove formally that a SoftHebb layer is a generative mixture model that objectively minimizes its Kullback-Leibler (KL) divergence from the input distribution through Bayesian inference, thus providing a new formal ML-theoretic perspective of these networks.
We complement our main results, which are theoretical, with experiments that are small-scale but produce intriguing results. As a generative model, SoftHebb has a broader scope than classification, but we test it in simulations on the tasks of recognizing MNIST handwritten digits and Fashion-MNIST fashion products.
First, we confirm that SoftHebb is more accurate than a hard-WTA model. Second, we validate that it minimizes a loss function (cross-entropy) even though it has no access to it or to labels during learning. In addition, likely owing to its Bayesian and generative properties, the unsupervised WTA model outperforms a supervised two-layer perceptron in several aspects: learning speed and accuracy in the first presentation of the training dataset, robustness to noisy data, and increased robustness to one of the strongest white-box adversarial attacks, i.e. projected gradient descent (PGD) \citep{madry2017towards}, and without any explicit defence. Interestingly, the SoftHebb model also exhibits inherent properties of deflection \citep{qin2020deflecting} of the adversarial attacks, and generates object interpolations.
\section{Theory}
\begin{defn}[\bfseries The input assumptions]
\label{def:data}
Each observation $_j\boldsymbol{x} \in \mathbb{R}^n$ is generated by a hidden "cause" $_jC$ from a finite set of $K$ possible such causes:
$_jC \in \{C_k,\, \forall k \leq K\in \mathbb{N}\}.$
Therefore, the data is generated by a mixture of the probability distributions attributed to each of the $K$ classes $C_k$:
\begin{equation
p(\boldsymbol{x})=\sum_{k=1}^{K}p(\boldsymbol{x}|C_k)P(C_k).
\label{eq:pstar}
\end{equation}
In addition, the dimensions of $\boldsymbol{x}$, $x_i$ are conditionally independent from each other, i.e. \\$p(\boldsymbol{x})=\prod_{i=1}^{n}p(x_i). \label{eq:independence}$
The number $K$ of the true causes or classes of the data is assumed to be known.
\stepcounter{subsection}
\end{defn}
The term "cause" is used here in the sense of causal inference. It is important to emphasize that the true cause of each input is hidden, i.e. not known. In the case of a labelled dataset, labels may correspond to causes, and the labels are deleted before presenting the training data to the model.
We choose a mixture model that corresponds to the data assumptions but is also interpretable in neural terms (Paragraph \ref{sec:neuro_exp}):
\begin{defn}[\bfseries The generative probabilistic mixture model]
\label{def:model}
We consider a mixture model distribution $q$:
$q(\boldsymbol{x})=\sum_{k=1}^{K}q(\boldsymbol{x}|C_k)\,Q(C_k),$
approximating the data distribution $p$.
We choose specifically a mixture of exponentials and we parametrize $Q(C_k;w_{0k})$ also as an exponential, specifically:
\begin{align}
q(x_i|C_k;w_{ik})&=e^{w_{ik}\cdot \frac{x_i}{||\boldsymbol{x}||}},\, \forall k \label{eq:g_param}\\
Q(C_k;w_{0k})&=e^{w_{0k}},\,\forall k.\label{eq:g0_param}
\end{align}
In addition, the parameter vectors are subject to the normalization constraints:
$||\boldsymbol{w}_k||=1,\, \forall k$,
and
$
\sum_{k=1}^{K}e^{w_{0k}}=1. \label{eq:norm_0}$
\stepcounter{subsection}
\end{defn}
The model we have chosen is a reasonable choice because it factorizes similarly to the data of Definition \ref{def:data}:
\begin{equation}q_k\coloneqq q(\boldsymbol{x}|C_k; \boldsymbol{w}_k)=\prod_{i=1}^{n}q(x_i|C_k;w_{ik})=e^{\sum_{i=1}^{n}w_{ik}\frac{x_i}{||\boldsymbol{x}||}}=e^{u_k}, \label{eq:multinomial}
\end{equation}
where $u_k=\frac{ \boldsymbol{w}_k\cdot \boldsymbol{x}}{|| \boldsymbol{w}_k||\cdot||\boldsymbol{x}||}$, i.e. the cosine similarity of the two vectors.
A similar probabilistic model was used in related previous theoretical work \citep{nessler2009stdp, nessler2013PLoS, moraitis2020shortterm}, but for different data assumptions, and with certain further constraints to the model. Namely, \citep{nessler2009stdp, nessler2013PLoS} considered data that was binary, and created by a population code, while the model was stochastic. These works provide the foundation of our derivation, but here we consider the more generic scenario where data are continuous-valued and input directly into the model, which is deterministic and, as we will show, more compatible with standard ANNs. In \citep{moraitis2020shortterm}, data had particular short-term temporal dependencies, whereas here we consider the distinct case of independent and identically distributed (i.i.d.) input samples.
The Bayes-optimal parameters of a model mixture of exponentials can be found analytically as functions of the input distribution's parameters, and the model is equivalent to a soft winner-take-all neural network \citep{moraitis2020shortterm}. After describing this, we will prove here that Hebbian plasticity of synapses combined with local plasticity of the neuronal biases sets the parameters to their optimal values.
\begin{thm}[\bfseries The optimal parameters of the model] \label{thm:optimal}
The parameters that minimize the KL divergence of such a mixture model from the data are, for every $k$,
\begin{gather}
\prescript{}{opt}{}w_{0k}=\ln P(C_k)
\label{eq:G0}\\
\text{and } \prescript{}{opt}{}\boldsymbol{w}^*_k=\frac{ \prescript{}{opt}{}\boldsymbol{w}_k}{|| \prescript{}{opt}{}\boldsymbol{w}_k||}=\frac{\mu_{p_k}\left(\boldsymbol{x}\right)}{||\mu_{p_k}\left(\boldsymbol{x}\right)||},
\end{gather}
where $\prescript{}{opt}{}\boldsymbol{w}_k=c\cdot \mu_{p_k}\left(\boldsymbol{x}\right), c\in\mathbb{R}^+,\,
\mu_{p_k}\left(\boldsymbol{x}\right)$ is the mean of the distribution $p_k$, and $p_k\coloneqq p(\boldsymbol{x}|C_k)$.
\stepcounter{subsection}
\end{thm}
In other words, the optimal parameter vector of each component $k$ in this mixture is proportional to the mean of the corresponding component of the input distribution, i.e. it is a centroid of the component. In addition, the optimal parameter of the model's prior $Q(C_k)$ is the logarithm of the corresponding component's prior probability.
The Theorem's proof was provided in the supplementary material of \citep{moraitis2020shortterm}, but for completeness we also provide it in our Appendix. These centroids and priors of the input's component distributions, as well as the method of their estimation, however, are different for different input assumptions, and we will derive a learning rule that provably sets the parameters to their Maximum Likelihood Estimate for the inputs addressed here. The learning rule is a Hebbian type of synaptic plasticity combined with a plasticity for neuronal biases. Before providing the rule and the related proof, we will describe how our mixture model is equivalent to a WTA neural network.
\subsection{Equivalence of the probabilistic model to a WTA neural network}
\stepcounter{thm}
\label{sec:neuro_exp} The cosine similarity between the input vector and each centroid's parameters underpins the model (Eq. \ref{eq:multinomial}). This similarity is precisely computed by a linear neuron that receives normalized inputs
$\boldsymbol{x}^*\coloneqq\frac{\boldsymbol{x}}{||\boldsymbol{x}||}$, and that normalizes its vector of synaptic weights:
$\boldsymbol{w}^*_k\coloneqq\frac{\boldsymbol{w}}{||\boldsymbol{w}||}$. Specifically, the neuron's summed weighted input
$u_k= \boldsymbol{w}^*_k\cdot\boldsymbol{x}^*$ then determines the cosine similarity of an input sample to the weight vector, thus computing the likelihood function of each component of the input mixture (Eq. \ref{eq:g_param}). The bias term of each neuron can store the parameter $w_{0k}$ of the prior $Q(C_k; w_{0k})$.
Based on these, it can also be shown that a set of $K$ such neurons can actually compute the Bayesian posterior, if the neurons are connected in a configuration that implements softmax. Softmax has a biologically-plausible implementation through lateral inhibition (divisive normalization) between neurons \citep{nessler2009stdp, nessler2013PLoS, moraitis2020shortterm}. Specifically, based on the model of Definition \ref{def:model}, the posterior probability is
\begin{equation}
Q(C_k|\boldsymbol{x})=\frac{e^{u_k+w_{0k}}}{\sum_{l=1}^{K}e^{u_l+w_{0l}}}. \label{eq:Q_model}
\end{equation}
But in the neural description, $u_k+w_{0k}$ the activation of the $k$-th linear neuron. That is, Eq. \ref{eq:Q_model} shows that the result of Bayesian inference of the hidden cause from the input $Q(C_k|\boldsymbol{x})$ is found by a softmax operation on the linear neural activations. In this equivalence, we will be using $y_k\coloneqq Q(C_k|\boldsymbol{x};\boldsymbol{w})$ to symbolize the softmax output of the $k$-th neuron, i.e. the output after the WTA operation, interchangeably with $Q(C_k|\boldsymbol{x})$.
It can be seen in Eq. \ref{eq:Q_model} that the probabilistic model has one more, alternative, but equivalent neural interpretation. Specifically, $Q(C_k|\boldsymbol{x})$ can be described as the output of a neuron with exponential activation function (numerator in Eq. \ref{eq:Q_model}) that is normalized by its layer's total output (denominator). This is equally accurate, and more directly analogous to the biological description \citep{nessler2009stdp, nessler2013PLoS, moraitis2020shortterm}. This shows that the exponential activation of each individual neuron $k$ directly equals the $k$-th exponential component distribution of the generative mixture model (Eq. \ref{eq:multinomial}).
Therefore the softmax-configured linear neurons, or the equivalent normalized exponential neurons, fully implement the generative model of Definition \ref{def:model}, and also infer the Bayesian posterior probability given an input and the model parameters. However, the problem of calculating the model's parameters from data samples is a difficult one, if the input distribution's parameters are unknown. In the next sections we will show that this neural network can find these optimal parameters through Bayesian inference, in an unsupervised and on-line manner, based on only local Hebbian plasticity.
\subsection{A Hebbian rule that optimizes the weights}
Several Hebbian-like rules exist and have been combined with WTA networks. For example, in the case of stochastic binary neurons and binary population-coded inputs, it has been shown that weight updates with an exponential weight-dependence find the optimal weights \citep{nessler2009stdp, nessler2013PLoS}. Oja's rule is another candidate \citep{oja1982simplified}. An individual linear neuron equipped with this learning rule finds the first principal component of the input data \citep{oja1982simplified}. A variation of Oja's rule combined with hard-WTA networks and additional mechanisms has achieved good experimental results performance on classification tasks \citep{krotov2019unsupervised}, but lacks the theoretical underpinning that we aim for. Here we propose a Hebbian-like rule for which we will show it optimizes the soft WTA's generative model. The rule is similar to Oja's rule, but considers, for each neuron $k$, both its linear weighted summation of the inputs $u_k$, and its nonlinear output of the WTA $y_k$:
\begin{equation}
\label{eq:synplast}
\Delta w_{ik}^{(SoftHebb)}\coloneqq\eta \cdot y_k \cdot \left(x_i-u_kw_{ik}\right),
\end{equation}
where $w_{ik}$ is the synaptic weight from the $i$-th input to the $k$-th neuron, and $\eta$ is the learning rate hyperparameter.
By solving the equation $E[\Delta w_{ik}]=0$ where $E[]$ is the expected value over the input distribution, we can show that, with this rule, there exists a stable equilibrium value of the weights, and this equilibrium value is an optimal value according to Theorem \ref{thm:optimal}:
\begin{thm}
\label{thm:equilib}
The equilibrium weights of the SoftHebb synaptic plasticity rule are
\begin{equation}w_{ik}^{SoftHebb}=c \cdot\mu_{p_k}(x_i)=\prescript{}{opt}w_{ik}, \text{ where } c=\frac{1}{||\mu_{p_k}(\boldsymbol{x})||}.
\end{equation}
\end{thm}
The proof is provided in the Appendix.
Therefore, our update rule (Eq. \ref{eq:synplast}) optimizes the weights of the neural network.
\subsection{Local learning of neuronal biases as Bayesian priors}
For the complete optimization of the model, the neuronal biases $w_{0k}$ must also be optimized to satisfy Eq. \ref{eq:G0}, i.e. to optimize the Bayesian prior belief for the probability distribution over the $K$ input causes.
We define the following rate-based rule inspired from the spike-based bias rule of \citep{nessler2013PLoS}:
\begin{gather}
\Delta w_{0k}^{SoftHebb}=\eta e^{-w_{0k}}\left(y_k - e^{w_{0k}} \right).
\end{gather}
With the same technique we used for Theorem \ref{thm:equilib}, we also provide proof in the Appendix that the equilibrium of the bias with this rule matches the optimal value $\prescript{}{opt}{}w_{0k}=\ln P(C_k)$ of Theorem \ref{thm:optimal}:
\begin{thm}
\label{thm:nesslerbias}
The equilibrium biases of the SoftHebb bias learning rule are
\begin{gather}
w_{0k}^{SoftHebb}=\ln P(C_k)=\prescript{}{opt}{}w_{0k}.\end{gather}
\end{thm}
\subsection{Alternate activation functions}
\label{sec:activation_fn}
The model of Definition \ref{def:model} uses for each component $p(\boldsymbol{x}|C_k)$ an exponential probability distribution with a base of Euler's e, equivalent to a model using similarly exponential neurons (Subsection \ref{sec:neuro_exp}). Depending on the task, different probability distribution shapes, i.e. different neuronal activation functions, may be better models. This is compatible with our theory (see Appendix B). Firstly, the base of the exponential activation function can be chosen differently, resulting in a softmax function with a different base, such that Eq. \ref{eq:Q_model} becomes more generally
$
Q(C_k|\boldsymbol{x})=\frac{b^{u_k+w_{0k}}}{\sum_{l=1}^{K}b^{u_l+w_{0l}}}. \label{eq:Qb_model}
$
This is equivalent to Temperature Scaling \citep{hinton2015distilling}, a mechanism that also maintains the probabilistic interpretation of the output. It can also be implemented by a normalized layer of exponential neurons, and are compatible with our theoretical derivations and the optimization by the plasticity rule of Eq. \ref{eq:synplast}. Moreover, we show in the Appendix that soft WTA models can be constructed by rectified linear units (ReLU) or in general by neurons with any non-negative monotonically increasing activation function, and their weights are also optimized by the same plasticity rule.
\subsection{Cross-entropy and true causes, as opposed to labels}
\label{sec:causes}
It is important to note that, in labelled datasets, the labels that have been assigned by a human supervisor may not correspond exactly to the true causes that generate the data, which SoftHebb infers. For example, consider MNIST. The 10 labels indicating the 10 decimal digits do not correspond exactly to the true cause of each example image. In reality, the cause $C$ of each MNIST example in the sense implied by causal inference is not the digit cause itself, but a combination of a single digit cause $D$, which is the MNIST label, with one of many handwriting styles $S$. That is, the probabilistic model is such that in the Eq. $P(\boldsymbol{x})=\sum_kP(\boldsymbol{x}|C_k)P(C_k)$ of Definition \ref{def:data}, the cause $C$ of each sample is dual, i.e. there exists a digit $D_d\,(d\in \left[0, 9\right])$ and a style $S_s$ such that \begin{gather}
\label{eq:causes0}P(C_k)\coloneqq P(C=C_k)=P(D_d) P(S_s)\neq P(D_d).\\
\label{eq:causes}
\text{and }P(D_d)=\sum_kP(C_k) P(D_d|C_k).
\end{gather}
This is important for our unsupervised model.
To illustrate this point, a network with $K$ competing neurons trained on MNIST may learn not to specialize to $K$ digits $D$, but rather to $K$ handwriting styles $S$ of one digit $D_d$, or in general $K$ combinations of digits with styles – combinations, which are the true causes $C$ that generate the data. This leads in this case to a mismatch between the labels $D$, and the true causes $C$ of the data. Therefore, given the labels and not the causes, it is not obvious which number $K$ should be chosen for the number of neurons. Practically speaking, $K$ can be chosen using common heuristics from cluster analysis. It is also not obvious how to measure the loss of the WTA network during the learning process, since the ground truth for causes $C$ is missing. We will now provide the theoretical tools for achieving this loss-evaluation based on the labels.
Even though SoftHebb is a generative model, it can be used for discrimination of the input classes $C_k$, using Bayes' theorem. More formally, the proof of Theorem \ref{thm:optimal} involved showing that SoftHebb minimizes the KL divergence of the model $q(\boldsymbol{x})$ from the data $p(\boldsymbol{x})$. Based on this it can be shown that the algorithm also minimizes its cross-entropy $H^{causes}_Q\coloneqq H(P(C), Q(C|\boldsymbol{x}))$ of the causes $Q(C_k|\boldsymbol{x})$ that it infers, from the true causes of the data $P(C_k)$:
$\boldsymbol{w}^{SoftHebb}= arg \min_{\boldsymbol{w}} H^{causes}_Q.$
An additional consequence is that by minimizing $H^{causes}$, SoftHebb also minimizes its label-based cross-entropy $H^{labels}_Q\coloneqq H(P(D_d), Q(D_d))$ between the true labels $P(D_d)$ and the implicitly inferred labels $Q(D_d)$:
\begin{gather}
Q(D_d)\coloneqq\sum_{k}Q(C_k) P(D_d|C_k) \label{eq:causesQ}\\
\boldsymbol{w}^{SoftHebb}=arg \min_{\boldsymbol{w}} H^{causes}_Q= arg \min_{\boldsymbol{w}} H^{labels}_Q. \label{eq:argminHQ}
\end{gather}
This is because, in Eqs. \ref{eq:causes} and \ref{eq:causesQ}, the dependence of the labels on the true causes $P(D_d|C_k)$ is fixed by the data generation process.
To obtain $Q(D_d|\boldsymbol{x})$ and measure the cross-entropy, the causal structure $P(D_d|C)$ is missing, but it can be represented by a supervised classifier $Q_2(D_d|Q(C|\boldsymbol{x}))$ of SoftHebb's outputs, trained using the labels $D_d$.
Therefore, by (a) unsupervised training of SoftHebb, then (b) training a supervised classifier on top, and finally (c1) repeating the training of SoftHebb with the same initial weights and ordering of the training inputs, while (c2) measuring the trained classifier's loss, we can observe the cross-entropy loss $H^{labels}$ of SoftHebb while it is being minimized, and infer that $H^{causes}$ is also minimized (Eq. \ref{eq:argminHQ}). We call this the post-hoc cross-entropy method, and we have used it in our experiments (Section \ref{sec:exp_cross} and Fig. \ref{fig:performance} C and D) to evaluate the learning process in a theoretically sound manner.
\section{Experiments}
\begin{figure}
\includegraphics[width = 140mm]{Figures/performance.pdf}
\caption{Performance of SoftHebb on MNIST compared to hard-WTA and backpropagation.}
\label{fig:performance}
\end{figure}
\subsection{MNIST accuracy vs hard WTA}
\label{sec:vshardWTA}
We implemented the theoretical SoftHebb model in simulations and tested it in the task of learning to classify MNIST handwritten digits. The network received the MNIST frames normalized by their Euclidean norm, and the plasticity rule we derived updated its weights and biases in an unsupervised manner. We used $K=2000$ neurons. First we trained the network for 100 epochs, i.e. randomly ordered presentations of the 60000 training digits.
In our validation testing we found that softmax with a base of 1000 (see Section \ref{sec:activation_fn}) performed best. The learning rate $\eta$ of Eq. \ref{eq:synplast} decreased linearly from 0.03 to 0 throughout training. Each training experiment we will describe was repeated five times with varying random initializations and input order. We will report the mean and standard deviation of accuracies.
Inference of the input labels by the WTA network of 2000 neurons was performed in two different ways. The first approach is single-layer, where after training the network we assigned a label to each of the 2000 neurons, in a standard approach that is used in unsupervised clustering. Namely, for each neuron, we found the label of the training set that makes it win the WTA competition most often. In this single-layer approach, this is the only time when labels were used, and at no point were weights updated using labels.
The second approach was two-layer and based on supervised training of a perceptron classifier on top of the WTA layer. The classifier layer was trained with the Adam optimizer and cross-entropy loss for 60 epochs, while the previously-trained WTA parameters were frozen.
SoftHebb achieved an accuracy of $(96.18\pm0.06)\%$ and $(96.94\pm0.02)\%$ in its 1- and 2-layer form respectively.
To confirm the strength of the soft WTA approach combined with training the priors through biases, which makes the network Bayesian, we also trained the weights of a network with a hard-WTA setup, i.e. where the strongest-activated neuron's output $y_k$ is 1, and the other neurons are suppressed to 0, for each input. We found that an initial learning rate of 0.05 was best for the hard-WTA network. The SoftHebb model outperformed the hard WTA (Fig. \ref{fig:performance}A).
However, SoftHebb's accuracy is significantly lower than a multi-layer perceptron (MLP) with one hidden layer of also 2000 neurons that is trained end-to-end exhaustively. The MLP achieves a $(98.33\pm0.06)\%$ accuracy (not shown in the figure). This is expected, due to end-to-end training, supervision, and the MLP being a discriminative model as opposed to a generative model merely applied to a classification task, as SoftHebb is. If the Bayesian and generative aspects that follow from our theory were not required, several additional mechanisms exist to enhance the discriminative power of WTA networks \citep{krotov2019unsupervised}, and even a random projection layer instead of a trained WTA performs well \citep{illing2019biologically}. The generative approach however has its own advantages even for a discriminative task, and we will show some of these here.
\subsection{Cross-entropy minimization and single-epoch advantage over backpropagation}
\label{sec:exp_cross}
First, we show as a validation of the theory that the SoftHebb model minimizes cross-entropy $H^{causes}_Q$ of its activations from its input's causes, even though no explicit loss is provided. According to our post-hoc cross-entropy method (Section \ref{sec:causes}), as a proxy we observed the minimization of $H^{labels}_Q$ during the first epoch of on-line Hebbian learning. The loss on the training inputs as they appear (running loss), as well as on the whole testing dataset can be seen in Fig. \ref{fig:performance}C and D respectively (blue curves). The method allows us to observe the discriminative aspect of the generative model, as it is optimized. After this one epoch, the accuracy of the 1-layer form of the SoftHebb model is $(95.44\pm0.14)\%$. The 2-layer form is again obtained by training a supervised classifier output layer for 60 epochs, and its accuracy is $(96.21\pm0.15)\%$ (Fig. \ref{fig:performance}B, blue bars).
We then also train for a single epoch a 2-layer MLP with a hidden-layer of 2000 neurons, with backpropagation of stochastic gradient descent (SGD) and cross-entropy loss. We found, through grid search, the optimal minibatch size and learning rate of the MLP (4 and 0.2 respectively). The MLP achieves an accuracy of $(95.39\pm0.45)\%$ (Fig. \ref{fig:performance}B, orange bar), if we exclude one run of the experiment which only achieved an accuracy of 86.92\%. Surprisingly, it not surpass SoftHebb, not even in its 1-layer form. In addition, the cross-entropy of the SoftHebb model is visibly minimized faster than through SGD (orange curves of Fig. \ref{fig:performance}C \& D).
It is possible that SoftHebb's advantage in terms of loss and accuracy is a side-effect of pre-training the second layer when obtaining SoftHebb's post-hoc cross-entropy, or of that layer's 60-epoch training. To test this possibility, we similarly obtained a trained version of the MLP's output layer alone, and then trained its first layer with backpropagation and the second layer frozen. Meanwhile, we recorded its loss, thus obtaining its own version of post-hoc cross-entropy (\ref{fig:performance}C \& D, yellow curve). SoftHebb still showed an advantage in terms of loss minimization speed, and its 2-layer form's accuracy is still not surpassed (\ref{fig:performance}B, blue \& yellow bars), despite the fully unsupervised and local learning in the core of the network.
Moreover, the figure shows that the minimization of the loss on the general test set by SoftHebb is smoother than the running loss, while SGD's test-set loss is influenced by the specifics of the individual training examples. This may indicate stronger generalization by the SoftHebb model, emerging from its Bayesian and generative nature. If this is true, SoftHebb may be more robust to input perturbations.
\begin{figure}
\centering
\includegraphics[width = 140mm]{Figures/attack_curves_f.pdf}
\caption{Noise and adversarial attack robustness of SoftHebb and of backpropagation-trained MLP on MNIST and Fashion-MNIST. The insets show one example from the testing set and its perturbed versions, for increasing perturbations. (A) SoftHebb is highly robust to noise. (B) MLP's MNIST accuracy drops to ~60\% by hardly perceptible perturbations ($\epsilon=16/255$), while SoftHebb requires visually noticeable perturbations ($\epsilon=64/255$) for similar drop in performance. At that degree of perturbation, the MLP has already dropped to zero. SoftHebb deflects the attack: it forces the attacker to produce examples of truly different classes - the original digit "4" is perturbed to look like a "0" (see also Fig. \ref{fig:gan}).}
\label{fig:robustness}
\end{figure}
\subsection{Robustness to noise and adversarial attacks - Generative adversarial properties}
\label{sec:robustness}
Indeed, we tested the trained SoftHebb and MLP models for robustness, and found that SoftHebb is significantly more robust than the backprop-trained MLP, both to added Gaussian noise and to PGD adversarial attacks (see Fig. \ref{fig:robustness}). PGD \citep{madry2017towards} produces perturbations in a direction that maximizes the loss of each targeted network, and in size controlled by a parameter $\epsilon$. Strikingly, SoftHebb has a visible tendency to deflect the attacks, i.e. its confusing examples actually belong to a perceptually different class (Fig. \ref{fig:robustness}B and \ref{fig:gan}). This effectively nullifies the attack and was previously shown in elaborate state-of-the-art adversarial-defence models \citep{qin2020deflecting}.
The pair of the adversarial attacker with the generative SoftHebb model essentially composes a generative adversarial network (GAN), even though the term is usually reserved for pairs \textit{trained }in tandem \citep{goodfellow2014generative, creswell2018generative}. As a result, the model could inherit certain properties of GANs. It can be seen that it is able to generate interpolations between input classes (Fig. \ref{fig:gan}). The parameter $\epsilon$ of the adversarial attack can control the balance between the interpolated objects. Similar functionality has existed in the realm of GANs \citep{radford2015unsupervised}, autoencoders \citep{berthelot2018understanding}, and other deep neural networks \citep{bojanowski2017optimizing}, but was not known for simple biologically-plausible models.
\subsection{Generalizability of the algorithm to other datasets: Fashion-MNIST}
Finally, we trained SoftHebb on a more difficult dataset, namely Fashion-MNIST \citep{xiao2017/online} which contains grey-scale images of clothing products. A supervised MLP of the same size achieved a test accuracy of $(88.7\pm0.34)\%$ on this task. We used the exact same SoftHebb model and hyperparameters that we used on MNIST, without any adjustment for the changed dataset. Still, the model achieved an accuracy of $(75.14\pm 0.17)\%$. In addition, with very small adversarial perturbations, the MLP drops to an accuracy lower than the SoftHebb model despite our generic training, while SoftHebb's robustness is reconfirmed (dashed lines in Fig. \ref{fig:robustness}) as are its generative
interpolations (Fig. \ref{fig:gan}B).
\begin{figure}
\centering
\includegraphics[width = 135mm]{Figures/adv_examples_softhebb.pdf}
\caption{Examples generated by the adversarial pair PGD attacker/SoftHebb model. SoftHebb's inherent tendency to deflect the attack towards truly different classes is visible. This tendency can be repurposed to generate interpolations between different classes of the data distribution, a generative property previously unknown for such simple networks.}
\label{fig:gan}
\end{figure}
\section{Discussion}
We have described SoftHebb, a biologically plausible model that is unsupervised, local, and requires no error or other feedback from upper layers. The model consists of elements fully compatible with conventional ANNs. We have shown the importance of soft competition in rate-based WTA networks, and derived formally the plasticity that optimizes the network through Bayesian computations and learns a generative model of the input distribution. We also developed a method for quantifying its unsupervised discriminative loss in a theoretically sound manner. Our experiments are small, but they confirm our optimization theory, and show that SoftHebb has significant strengths that emerge from its unsupervised, generative, and Bayesian nature. It is intriguing that, through biological plausibility, emerge properties commonly associated with biological intelligence, such as speed of learning, robustness to noise and adversarial attacks, and deflection of the attacks. In particular, its ability to learn better than even supervised networks when training time is limited is interesting for resource-limited neuromorphic applications. Its robustness to noise and adversarial attacks is impressive, considering that it is intrinsic and was not instilled by specialized defences. SoftHebb tends to not merely be robust to attacks, but actually deflect them. We also showed that these networks can generate image interpolations in the latent space. However, the model is quite limited compared to state of-the-art ML, if classification accuracy, exhaustive training, and unperturbed inputs are the benchmark. To address this, its potential integration into multilayer networks should be explored using our new tools. This could also provide insights into the role of WTA microcircuits in larger networks in cortex. A first approach to such multilayer networks could be by stacking individually-trained layers. The remaining piece to successfully integrate SoftHebb in deep networks is to make the learned representation in each layer distributed, in spite of a WTA approach. SoftHebb is indeed more distributed than a hard WTA, and further-distributed features may be achieved by localized receptive fields \citep{pogodin2021towards} similar to area V1 of cortex \citep{hubel1962receptive}.
\clearpage
| {'timestamp': '2021-10-07T02:25:21', 'yymm': '2107', 'arxiv_id': '2107.05747', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05747'} | arxiv |
\section{Introduction}
Deformable atlas building is to create a “mean” or averaged image and register all subjects to a common space. The resulting atlas and group transformations are powerful tools for statistical shape analysis of images~\cite{hong2017fast,ma2008bayesian}, template-based segmentation~\cite{pohl2006bayesian,rohlfing2004evaluation,iglesias2012incorporating}, or object tracking~\cite{lorenzo2002atlas,liao2019temporal}, just to name a few. A good quality of altas heavily relies on the registration process, which is typically formulated as a regularized optimization to solve~\cite{ashburner2011diffeomorphic,beg2005computing,vialard2012,zhang2019fast}. An issue in the current process of registration-based atlas construction is how to regularize model parameters. Having an appropriate regularization is critical to the "sharpness" of the atlas, as well as ensuring a set of desirable properties of transformations, i.e., a smooth and invertible smooth mapping between images, also known as diffeomorphisms, to preserve the topology of original images.
Current atlas building models either exhaustively search for an optimal regularization in the parameter space, or treat it as unknown variables to estimate from Bayesian models. While ad hoc parameter-tuning may yield satisfactory results, it requires expert domain knowledge to guide the tuning process~\cite{joshi2004unbiased,vialard2011diffeomorphic,ma2008bayesian,wang2019data}. Inspired by probabilistic models, several works have proposed Bayesian models of atlas building with automatically estimated regularizations ~\cite{allassonniere2007towards,allassonniere2008stochastic,zhang2013bayesian}. These approaches define a posterior distribution that consists of an image matching term between a deformed atlas and each individual as a likelihood, and a regularization as a prior to support the smoothness of transformation fields. The regularization parameter is then jointly estimated with atlas after carefully integrating out the image deformations using Monte Carlo sampling. However, sampling in a high-dimensional transformation space (i.e., on a dense 3D image grid $128^3$) is computationally expensive and often leads to a long execution time with high memory consumption. More importantly, the aforementioned methods are limited to regularizations with single-penalty for population studies. This prohibits the model's ability to adaptively search for the best regularization parameter associated with an individual subject, which is critical to images with various degrees of geometric transformations. The typical “one-fits-all” fails in cases where large geometric variations occur, i.e., brain shape changes of Alzheimer's disease group. Allowing the subject-specific (data-driven) regularization can substantially affect the sharpness and quality of the atlas~\cite{yeo2008effects}.
In this paper, we propose a hierarchical Bayesian model of atlas building with subject-specific regularizations in the context of Large Deformation Diffeomorphic Metric Mapping (LDDMM) algorithm~\cite{beg2005computing}. In contrast to previous approaches treating the regularization of individual subjects as a single-penalty function with adhoc parameters, we develop a data-adaptive algorithm to automatically adjust the model parameters accordingly. To achieve this, we introduce a novel hierarchical prior that features (i) prior distributions with multiple regularization parameters on the group transformations in a low-dimensional bandlimited space; and (ii) a hyperprior to model the regularization parameters as latent variables. We then develop a Monte Carlo Expectation Maximization (MCEM) algorithm, where the expectation step integrates over the regularization parameters using Hamiltonian Monte Carlo (HMC) sampling. The joint estimation of model parameters including atlas, registration, and hyperparameters in the maximization step successfully eliminates a massive burden of multi-parameters tuning. We demonstrate the effectiveness of our algorithm on both 2D synthetic images and 3D real brain MRIs.
To the best of our knowledge, we are the first to extend the atlas building to a data-adaptive and parameter-tuning-free framework via hierarchical Bayesian learning. Experimental results show that our model provides an efficient atlas construction of population images, particularly with large variations of geometric transformations. This paves a way for an improved quality of clinical studies where atlas building is required, for example, statistical shape analysis of brain changes for neurodegenerative disease diagnosis~\cite{hong2017fast}, or atlas-based segmentation for in-utero placental disease monitoring~\cite{liao2019temporal}.
\section{Background: Atlas Building with Fast LDDMM}
We first briefly review an unbiased atlas building algorithm~\cite{joshi2004unbiased} based on Fourier-approximated Lie Algebra for Shooting~(FLASH), a fast variant of LDDMM with geodesic shooting~\cite{zhang2019fast}. Given a set of images $I_1,\cdots,I_N$ with $N$ being the number of images, the problem of atlas building is to find a template image $I$ and transformations $\phi_1,\cdots, \phi_N$ that minimize the energy function
\begin{equation}
\label{eq:lddmm}
E(I, \phi_n) = \sum_{n=1}^{N} \text{Dist} (I \circ \phi_n, I_n) + \text{Reg}(\alpha, \phi_n).
\end{equation}
The $\text{Dist}(\cdot, \cdot)$ is a distance function that measures the dissimilarity between images, i.e., sum-of-squared differences~\cite{beg2005computing}, normalized cross correlation~\cite{avants2008symmetric}, and mutual information~\cite{wells1996multi}. The $\Reg(\cdot)$ is a weighted regularization with parameter $\alpha$ that guarantees the diffeomorphic properties of transformation fields.
\paragraph*{\bf Regularization In Tangent Space of Diffeomorphisms.}
Given an open and bounded $d$-dimensional domain $\Omega \subset \mathbb{R}^d$, we use $\Diff(\Omega)$ to denote a space of diffeomorphisms and its tangent space $V=T \Diff(\Omega)$. The regularization of LDDMM is defined as an integral of the Sobolev norm of the time-dependent velocity field $v(t) \in V (t \in [0, 1])$ in the tangent space, i.e.,
\begin{equation}
\label{eq:lddmm}
\text{Reg}(\alpha, \phi_n) = \int \langle \L(\alpha) v_n(t), \L(\alpha) v_n(t) \rangle \, dt, \, \text{with} \, \, \frac{d\phi_n(t)}{dt} = - D\phi_n(t)\cdot v_n(t).
\end{equation}
Here $\L$ is a symmetric, positive-definite differential operator, with parameter $\alpha$ controling the smoothness of transformation fields. In this paper, we use the Laplacian operator $\L=(- \alpha \Delta + \text{Id})^3$, where $\text{Id}$ is an identity matrix. The operator $D$ is a Jacobian matrix and $\cdot$ denotes an element-wise matrix multiplication.
According to the geodesic shooting algorithm~\cite{vialard2012}, the minimum of LDDMM is uniquely determined by solving a Euler-Poincar\'{e} differential equation (EPDiff)~\cite{arnold1966,miller2006geodesic} with initial conditions. This inspires a recent model FLASH to reparameterize the regularization of Eq.~\eqref{eq:lddmm} in a low-dimensional bandlimited space of initial velocity fields, which dramatically reduces the computational complexity of transformation models with little to no loss of accuracy~\cite{zhang2019fast}.
\paragraph*{\bf Fourier Computation of Diffeomorphisms.} Let $\widetilde{\Diff}(\Omega)$ and $\tilde{V}$ denote the space of Fourier representations of diffeomorphisms
and velocity fields respectively. Given time-dependent velocity field $\tilde{v}(t) \in \tilde{V}$, the diffeomorphism $\tilde{\phi}(t) \in \widetilde{\Diff}(\Omega)$ in the finite-dimensional Fourier domain can be computed as
\begin{align}\label{eq:leftinvariantfft}
\tilde{\phi}(t) = \tilde{\text{Id}} + \tilde{u}(t), \quad \frac{d \tilde{u}(t)}{dt} &= -\tilde{v}(t) - \tilde{\mathcal{D}} \tilde{u}(t) \ast \tilde{v}(t),
\end{align}
where $\tilde{\text{Id}}$ is the frequency of an identity element, $\tilde{\mathcal{D}}\tilde{u}(t)$ is a tensor product $\tilde{\mathcal{D}} \otimes \tilde{u}(t)$, representing the Fourier frequencies of a Jacobian matrix $\tilde{\mathcal{D}}$ with central difference approximation, and $\ast$ is a circular convolution~\footnote{To prevent the domain from growing infinity, we truncate the output of the convolution in each dimension to a suitable finite set.}.
The Fourier representation of the geodesic shooting equation (EPDiff) is
\begin{align}\label{eq:epdiffleft}
\frac{\partial \tilde{v}(t)}{\partial t} =-\tilde{\K}\left[(\tilde{\mathcal{D}} \tilde{v}(t))^T \star \tilde{\mathcal{\L}}\tilde{v}(t) + \tilde{\nabla} \cdot (\tilde{\mathcal{\L}}\tilde{v}(t) \otimes \tilde{v}(t)) \right],
\end{align}
where $\star$ is the truncated matrix-vector field auto-correlation. The operator $\tilde{\nabla} \cdot$ is the discrete divergence of a vector field. Here $\tilde{\K}$ is an inverse operator of $\tilde{\L}$, which is the Fourier transform of a Laplacian operator in this paper.
The regularization in Eq.~\eqref{eq:lddmm} can be equivalently formulated as
\begin{align*}
\text{Reg}(\alpha, \phi_n) = \langle \tilde{{\L}}(\alpha) \tilde{v}_n(0), \tilde{{\L}}(\alpha) \tilde{v}_n(0) \rangle, \quad \text{s.t.} \, \text{Eq.}~\eqref{eq:leftinvariantfft} \& \text{Eq.}~\eqref{eq:epdiffleft}.
\end{align*}
We will drop off the time index in remaining sections for notational simplicity, e.g., defining $\tilde{v}_n \triangleq \tilde{v}_n(0)$.
\section{Our Model: Bayesian Atlas Building with Hierarchical Priors}
This section presents a hierarchical Bayesian model for atlas building that allows subject-specific regularization with no manual effort of parameter-tuning. We introduce a hierarchical prior distribution on the initial velocity fields with adaptive smoothing parameters followed by a likelihood distribution on images.
\paragraph*{\bf Likelihood.} Assuming an independent and identically distributed (i.i.d.) Gaussian noise on image intensities, we formulate the likelihood of each observed image $I_n$ as
\begin{align}
\label{eq:likelihood}
p(I_n \, | \, I, \tilde{v}_n, \sigma^2) = \frac{1}{(\sqrt{2 \pi} \sigma ^2 )^{M}} \exp{ \left(-\frac{1}{2\sigma ^2} \lVert I \circ \phi_n - I_n \rVert_2^2 \right)}.
\end{align}
Here $\sigma^2$ denotes a noise variance, $M$ is the number of image voxels, and $\phi_n$ is an inverse Fourier transform of $\tilde{\phi}_n$ at time point $t=1$. It is worth mentioning that other noise models such as spatially varying noises~\cite{simpson2012probabilistic} can also be applied.
\paragraph*{\bf Prior.} To ensure the smoothness of transformation fields, we define a prior on each initial velocity field $\tilde{v}_n$ as a complex multivariate Gaussian distribution
\begin{align}
\label{eq:prior}
p({\tilde{v}}_n \, | \, \alpha_n ) = \frac{1}{(2 \pi)^{\frac{M}{2}} | {\tilde{\L}_n}^{-1}(\alpha_n) |} \exp\left ({-\frac{1}{2} \langle {\tilde{\L}_n(\alpha_n)} {\tilde{v}}_n, {\tilde{\L}(\alpha_n)} {\tilde{v}}_n \rangle} \right),
\end{align}
where $|\cdot|$ is matrix determinant. The Fourier coefficients of a discrete Laplacian operator is $\tilde{{\L}}_n(\xi_1 , \ldots, \xi_d) = \left(-2 \alpha_n \sum_{j = 1}^d \left(\cos (2\pi \xi_j) - 1 \right) + 1\right)^3$, with $(\xi_1 , \ldots, \xi_d)$ being a d-dimensional frequency vector.
\paragraph*{\bf Hyperprior.} We treat the subject-specific regularization parameter $\alpha_n$ of the prior distribution~\eqref{eq:prior} as a random variable generated from Gamma distribution, which is a commonly used prior to model positive real numbers~\cite{simpson2015probabilistic}. Other prior such as inverse Wishart distribution~\cite{gori2017bayesian} can also be applied. The hyperprior of our model is formulated as
\begin{align}
\label{eq:hyperprior}
p(\alpha_n \, | \, k, \beta) = \frac{\alpha_n^{k-1} \exp ^{(-\alpha_n / \beta)}}{\Gamma (k) \beta^{k}},
\end{align}
with $k$ and $\beta$ being positive numbers for shape and scale parameters respectively. The Gamma function $\Gamma(k)=(k-1)!$ for all positive integers of $k$.
We finally arrive at the log posterior of the diffeomorphic transformation and regularization parameters as
\begin{align}
E(\tilde{v}_n, \alpha_n, I, \sigma, k, \beta) & \triangleq \ln \prod_{n=1}^N p(I_n \, | \, I, \tilde{v}_n, \sigma^2) \cdot p({\tilde{v}}_n \, | \, \alpha_n ) \cdot p(\alpha_n \, | \, k, \beta) \nonumber \\
&= \sum_{n=1}^{N} \frac{1}{2}\ln\lvert \L_n \rvert - M \ln \sigma-\frac{ \| I \circ \phi_n -I_n \|_2^2}{2\sigma^2} - \frac{1}{2}(\tilde{\L} \tilde{v}_n, \tilde{\L} \tilde{v}_n) \nonumber \\
& \quad (k-1) \ln \alpha_n -\frac{\alpha_n}{\beta} - k \ln \beta - \ln \Gamma(k) +\text{const.}
\label{eq:posterior}
\end{align}
\subsection{Model Inference}
We develop an MCEM algorithm to infer the model parameter $\Theta$, which includes the image atlas $I$, the noise variance of image intensities $\sigma^2$, the initial velocities of diffeomorphic transformations $\tilde{v}_n$, and the hyperparameters $k$ and $\beta$. We treat the regularization parameter $\alpha_n$ as latent random variables and integrate them out from the log posterior in Eq.~\eqref{eq:posterior}.
Computations of two main steps (expectation and maximization) are illustrated below.
\paragraph*{\bf Expectation: HMC.} Since the E-step does not yield a closed-form solution, we employ a powerful Hamiltonian Monte Carlo (HMC) sampling method~\cite{duane1987hybrid} to approximate the expectation function $Q$ with respect to the latent variables $\alpha_n$. For each $\alpha_n$, we draw a number of $S$ samples from the log posterior~\eqref{eq:posterior} by using HMC from the current estimated parameters $\hat{\Theta}$. The Monte Carlo approximation of the expectation $Q$ is
\begin{align}
Q(\Theta | \hat{\Theta}) \approx \frac{1}{S} \sum_{n=1}^{N} \sum_{j=1}^{S} \ln p(\alpha_{nj} \, | \, I_n; \hat{\Theta}).
\label{eq:expectation}
\end{align}
To produce samples of $\alpha_n$, we first define the potential energy of the Hamiltonian system $H(\alpha_n,\gamma) = U(\alpha_n)+W(\gamma)$ as $U(\alpha_n) = -\ln p(\alpha_n | I_n; \Theta)$. The kinetic energy $W(\gamma)$ is a typical normal distribution on an auxiliary variable $\gamma$. This gives us Hamilton's equations to integrate
\begin{align}\label{eq:hmc}
\frac{\alpha_n}{dt} = \frac{\partial H}{\partial \gamma} = \gamma, \quad
\frac{d \gamma}{dt} &=-\frac{\partial H}{\partial \alpha_n}=- \nabla_{\alpha_n}U.
\end{align}
Since $\alpha_n$ is a Euclidean variable, we use a standard ``leap-frog'' numerical integration scheme, which approximately conserves the Hamiltonian and results in high acceptance rates. The gradient of $U$ with respect to $\alpha_{n}$ is
\begin{align}
\nabla_{\alpha_{n}}U = \frac{3}{2S}\sum_{j=1}^S[ \sum_{i=1}^d \frac{\tilde{\A}_{i}}{\alpha_{nj} \tilde{A}_i + 1} - \langle 2(\alpha_{nj} \tilde{\A} +1)^{5}\tilde{\A} \tilde{v}_{nj}, \tilde{v}_{nj} \rangle],
\label{eq:alphagrad}
\end{align}
where $\tilde{\A}= -2 \sum_{i = 1}^d \left(\cos (2\pi \xi_i) - 1 \right)$. Here $\tilde{\A}$ denotes a discrete Fourier Laplacian operator with a $d$-dimensional frequency vector.
Starting from the current point $\alpha_n$ and initial random auxiliary variable $\gamma$, the Hamiltonian system is integrated forward in time by Eq.~\eqref{eq:hmc} to produce a candidate point $(\hat{\alpha}_n, \hat{\gamma})$. The candidate point $\hat{\alpha}_n$ is accepted as a new point in the sample with probability $p(accept) = \min(1, -U(\hat{\alpha}_n)-W(\hat{\gamma}) + U(\alpha_n)+W(\gamma))$.
\paragraph*{\bf Maximization: Gradient Ascent.} We derive the maximization step to update the parameters $\Theta=\{I, \tilde{v}_n, \sigma^2, k, \beta \}$ by maximizing the HMC approximation of the expectation $Q$ in Eq.~\eqref{eq:expectation}.
For updating the atlas image $I$, we set the derivative of the $Q$ function with respect to $I$ to zero. The solution for $I$ gives a closed-form update
\begin{align}
I = \frac{\sum_{j=1}^S \sum_{n=1}^N (I_n \circ \phi^{-1}_{nj}) \cdot \lvert D \phi^{-1}_{nj} \rvert }{\sum_{j=1}^S \sum_{n=1}^N \lvert D \phi^{-1}_{nj} \rvert}.
\label{eq:atlasupdate}
\end{align}
Similarly, we obtain the closed-form solution for the noise variance $\sigma^2$ after setting the gradient of $Q$ w.r.t. $\sigma^2$ to zero
\begin{align}
\sigma^2 = \frac{1}{MNS} \sum_{n=1}^N\sum_{j=1}^S \lVert I \circ \phi_{nj}-I_n \rVert_2^2.
\label{eq:sigmaupdate}
\end{align}
The closed-form solutions for hyperparameters $k$ and $\beta$ are
\begin{align}
k = \psi^{-1}( \frac{1}{NS}\sum_{i=1}^{N} \sum_{j = 1}^{S} \ln \alpha_{nj}-\ln \beta ), \quad \beta = \frac{1}{NS k}\sum_{n=1}^N \sum_{j = 1}^S \alpha_{nj}.
\label{eq:betakupdate}
\end{align}
Here $\psi$ is a digamma function, which is the logarithmic derivative of the gamma function $\Gamma (\cdot)$. The inverse of digamma function $\psi^{-1}$ is computed by using a fixed-point iteration algorithm~\cite{minka2000estimating}.
As there is no closed-form update for initial velocities, we employ a gradient ascent algorithm to estimate $\tilde{v}_{nj}$. The gradient $\nabla_{\tilde{v}_{nj}} Q$ is computed by a forward-backward sweep approach. Details are introduced in the FLASH algorithm~\cite{zhang2019fast}.
\section{Experimental Evaluation}
We compare the proposed model with LDDMM atlas building algorithm that employs single-penalty regularization with manually tuned parameters on 3D brain images~\cite{zhang2019fast}. In HMC sampling, we draw $300$ samples for each subject, with initialized value of $\alpha = 10$, $k = 9.0$, $\sigma=0.05$, and $\beta = 0.1$. An averaged image of all image intensities is used for atlas initialization.
\noindent{\bf Data.} We include $100$ 3D brain MRI scans with segmentation maps from a public released resource Open Access Series of Imaging Studies (OASIS) for Alzheimer's disease~\cite{fotenos2005normative}. The dataset covers both healthy and diseased subjects, aged from $55$ to $90$. The MRI scans are resampled to $128^3$ with the voxel size of $1.25 mm^3$. All MRIs are carefully prepossessed by skull-stripping, intensity normalization, bias field correction, and co-registration with affine transformation.
\noindent{\bf Experiments.} We estimate the atlas of all deformed images by using our method and compare its performance with LDDMM atlas building~\cite{zhang2019fast}. Final results of atlases estimated from both our model and the baseline algorithm are reported. We also compare the time and memory consumption of proposed model with the baseline that performs HMC sampling in a full spatial domain~\cite{zhang2013bayesian}. To measure the sharpness of estimated atlas $I$, we adopt a metric of normalized standard deviation computed from randomly selected 3000 image patches~\cite{legouhy2019online}. Given $N(i)$,
a patch around a voxel $i$ of an atlas $I$, the local measure of the sharpness at voxel $i$ is defined as $\text{sharpness}(I(i)) = \text{sd}_{N(i)}(I)/ \text{avg}_{N(i)}(I)$, where sd and avg denote the standard deviation and the mean of $N_i$.
To further evaluate the quality of estimated transformations, we perform atlas-based segmentation after obtaining transformations from our model. For a fair comparison, we fix the atlas for both methods and examine the registration accuracy by computing the dice similarity coefficient (DSC)~\cite{dice1945measures} between the propagated segmentation and the manual segmentation on six anatomical brain structures, including cerebellum white matter, thalamus, brain stem, lateral ventricle, putamen, caudate. The significance tests on both dice and sharpness between our method and the baseline are performed.
\noindent{\bf Results.} Fig.~\ref{fig:3datlas} visualizes a comparison of 3D atlas on real brain MRI scans. The top panel shows that our model substantially improves the quality of atlas with sharper and better details than the baseline with different values of manually set regularization parameters, e.g., $\alpha=0.1, 3.0, 6.0, 9.0$. Despite the observation of a smaller value of $\alpha=0.1$ produces sharper atlas, it breaks the smoothness constraints on the transformation fields hence introducing artifacts on anatomical structures (outlined in purple boxes). The mean and standard deviation of our estimated hyperprior parameters $k$ and $\beta$ in Eq.~\eqref{eq:hyperprior} over $30$ pairwise image registrations are $47.40/7.22$, and $0.036/0.005$. The bottom panel quantitatively reports the sharpness metric of all methods. It indicates that our algorithm outperforms the baseline by offering a higher sharpness score while preserving the topological structure of brain anatomy.
\begin{figure}[!ht]
\begin{center}
\includegraphics[width=0.96\textwidth] {./3DAtlas_2.pdf}
\caption{Top: atlases estimated by baseline with different $\alpha$ and our model (artifacts introduced by small regularization are outlined in purple boxes). Bottom: sharpness measurement of atlas for all methods with different patch size $w$. The mean of the sharpness metric of \textbf {our method} vs. the best performance of baseline without artifacts ($\alpha =3$) is \textbf{0.290}/0.264, \textbf{0.362}/0.323, \textbf{0.405}/0.360. }
\label{fig:3datlas}
\end{center}
\end{figure}
Fig.~\ref{fig:dice} reports results of fixed-atlas-based segmentation by performing the baseline with various regularization parameters and our algorithm. It shows the dice comparison on six anatomical brain structures of all image pairs. Our algorithm produces better dice coefficients without the need of parameter tuning.
\begin{figure}[!h]
\begin{center}
\includegraphics[width=.96\textwidth] {./3DDice.pdf}
\caption{A comparison of dice evaluation for fixed-atlas-based segmentation on six brain structures (cerebellum white matter (WM), thalamus (Th), brain stem (BS), lateral ventricle (LV), putamen(Pu), caudate (Ca)).}
\label{fig:dice}
\end{center}
\end{figure}
The runtime of our atlas building on $100$ 3D brain MR images are $4.4$ hours with $0.89$GB memory consumption. The p-values of significance differences test on both dice ($p=0.002$) and sharpness ($p=0.0034$) reject the null hypothesis that there's no differences between our model estimation and baseline algorithms.
\section{Conclusion}
This paper presents a novel hierarchical Bayesian model for unbiased diffeomorphic atlas building with subject-specific regularization. We design a new parameter choice rule that allows adaptive regularization to control the smoothness of image transformations. We introduce a hierarchical prior that provides prior information of regularization parameters at multiple levels. The developed MCEM inference algorithm eliminates the need of manual parameter tuning, which can be tedious and infeasible in multi-parameter settings. Experimental results show that our proposed algorithm yields a better registration model as well as an improved quality of atlas. While our algorithm is presented in the setting of LDDMM, the theoretical development is generic to other deformation models, e.g., stationary velocity fields~\cite{arsigny2006log}. In addition, this model can be easily extended to multi-atlas building where a much higher degree of variations exist in the population studies. Our future work will focus on conducting subsequent statistical shape analysis in the resulting atlas space.
| {'timestamp': '2021-07-14T02:03:04', 'yymm': '2107', 'arxiv_id': '2107.05698', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05698'} | arxiv |
\section*{}
\normalsize
\textbf{Manuscript type:} Article
\vspace{0.4 in}
\begin{center} \Large{Assessment of Immune Correlates of Protection via Controlled Vaccine Efficacy and Controlled Risk}
\large
\vspace{0.3 in}
Running head: Controlled Vaccine Efficacy Immune CoP
\vspace{0.3 in}
Peter B. Gilbert\textsuperscript{a,b*}, Youyi Fong\textsuperscript{a,b}, Marco Carone\textsuperscript{b,a}
\end{center}
\normalsize
\vspace{0.3 in}
\textsuperscript{a} Vaccine and Infectious Disease Division, Fred Hutchinson Cancer Research Center, Seattle, WA
\textsuperscript{b} Department of Biostatistics, University of Washington, Seattle, WA
\vspace{0.5 in}
*Correspondence: Peter B. Gilbert, Fred Hutchinson Cancer Research Center, 1100 Fairview Ave N, Seattle, WA, 98109. E-mail: pgilbert@scharp.org; Tel: (206) 667-7299.
\normalsize
\textbf{Conflicts of interest:} None declared.
\textbf{Sources of funding:} This work was supported by grants UM1AI068635 and R37AI054165 from the National Institute of Allergy and Infectious Diseases of the National Institutes of Health to Peter B. Gilbert.
\textbf{Data availability:} The CYD14 and CYD15 data are available upon request to the sponsor of the studies, Sanofi Pasteur. The computing code used to implement the methods as illustrated in the CYD14 and CYD15 applications is available at the Github repository youyifong/CoPcontrolledVE.
\textbf{Acknowledgments:} We thank the participants, investigators, and sponsor of the CYD14 and CYD15 trials, and Lindsay Carpp for editing contributions.
\newpage
\section*{Abstract}
\normalsize
Immune correlates of protection (CoPs) are immunologic biomarkers accepted as a surrogate for an infectious disease clinical endpoint and thus can be used for traditional or provisional vaccine approval.
To study CoPs in randomized, placebo-controlled trials, correlates of risk (CoRs) are first assessed in vaccine recipients. This analysis does not assess causation, as a CoR may fail to be a CoP.
We propose a causal CoP analysis that estimates the controlled vaccine efficacy
curve across biomarker levels $s$, $CVE(s)$, equal to one minus the ratio of the controlled-risk curve $r_C(s)$ at $s$ and placebo risk, where $r_C(s)$ is causal risk if all participants are assigned vaccine and the biomarker is set to $s$.
The criterion for a useful CoP is wide variability of $CVE(s)$ in $s$.
Moreover, estimation of $r_C(s)$ is of interest in itself, especially in studies without a placebo arm.
For estimation of $r_C(s)$, measured confounders can be adjusted for by
any regression method that accommodates missing biomarkers, to which we add
sensitivity analysis to quantify robustness of CoP evidence to unmeasured confounding.
Application to two harmonized phase 3 trials supports that 50\% neutralizing antibody titer has value as a controlled vaccine efficacy CoP for virologically confirmed dengue (VCD): in CYD14 the point estimate (95\% confidence interval) for $CVE(s)$ accounting for measured confounders and building in conservative margin for unmeasured confounding increases from
\input{input/fig3_low_cyd14} at titer 1:36 to \input{input/fig3_high_cyd14} at titer 1:1200; these estimates are
\input{input/fig3_low_cyd15} and \input{input/fig3_high_cyd15} for CYD15.
\comment{
\textbf{Conclusions:}
We recommend augmenting CoR analysis of vaccine recipients with controlled-risk CoP analysis that quantifies robustness of CoP evidence via sensitivity analysis. Additionally, in placebo-controlled trials controlled vaccine efficacy curve analysis provides interpretable CoP evaluation.
}
Key words: controlled effects causal inference, COVID-19, dengue vaccine efficacy, E-value, immune correlate of protection, sensitivity analysis.
\section{Introduction}
Safe and effective vaccines to prevent SARS-CoV-2 acquisition and COVID-19 disease are needed to curtail the COVID-19 pandemic. Approval of a vaccine requires demonstration that the vaccine confers a favorable benefit-to-risk profile in reducing clinically significant endpoints, usually established through phase 3 randomized, placebo-controlled, vaccine efficacy trials.
\cite{polack2020safetyshort,Badenetal2020short,sadoff2021safety}
Where SARS-CoV-2 vaccines are approved and widely locally available, placebo arms in future efficacy trials will likely be infeasible.\cite{Follmannetal2020} Thus, there is a need for alternative approaches to approving SARS-CoV-2 vaccines, such as surrogate endpoint trials that use as primary endpoint an antibody response biomarker measured post-vaccination. Effectiveness of this approach would require that the biomarker is measured using a validated assay and has been ``scientifically well established to reliably predict clinical benefit" (traditional approval) or be
``reasonably likely to predict clinical benefit"\cite{FlemingPowers2012,FDASIA} (accelerated approval).
Immunologic surrogate endpoints based on binding or functional antibody assays have been accepted by regulatory agencies for many licensed vaccines. \cite{Plotkin2008,Plotkin2010,PlotkinGilbert2018} Acceptance has been based on evidence from a variety of sources, including statistical analysis of phase 3 vaccine efficacy trials, natural history studies,
vaccine challenge studies in animals\cite{mason1973yellow,van2011correlation,beasley2016first}
and in humans,\cite{hobson1972role,chen2016single} and passive monoclonal antibody transfer studies.
Phase 3 trials constitute one of the most important sources of evidence, because they rigorously characterize the level of vaccine efficacy, and samples from breakthrough infection or disease cases can be analyzed and contrasted with samples from non-cases to infer immune correlates of risk (CoRs) and immune correlates of protection (CoPs).\cite{Qinetal2007} By CoP, we mean an immunologic biomarker statistically related to protection in some fashion that has been accepted for use in either accelerated or traditional approval.\cite{PlotkinGilbert2018}
Establishing a CoP typically requires multiple phase 3 placebo-controlled trials,
with the placebo arm needed to enable assessment of criteria for a valid CoP within various statistical frameworks, including surrogate endpoint evaluation,\cite{Prentice1989,Freedman1992,Molenberghsetal2008} principal stratification vaccine efficacy moderation evaluation,\cite{GilbertGabrieletal2014,Moodieetal2018} mediation evaluation \cite{Cowlingetal2019}, stochastic interventional vaccine efficacy evaluation,\cite{Hejazietal2020} and meta-analysis.\cite{GabrielDanielsHalloran2016}
This manuscript has two objectives. First, to propose a new causal inference approach to CoP evaluation based on randomized, placebo-controlled trials: controlled vaccine efficacy analysis.
This approach is essentially based on estimation of the controlled causal effect of the immunologic biomarker in vaccine recipients on outcome risk, and is thus closely
linked to the second objective, to propose a causal inference approach to CoP evaluation based on analysis of the vaccine arm only. The second objective is especially relevant for studies without a placebo arm.
As a case in point, several ongoing SARS-CoV-2 placebo-controlled vaccine efficacy trials have crossed over placebo recipients to the vaccine arm,\cite{polack2020safetyshort,Badenetal2020short,sadoff2021safety} precluding the study of CoPs against longer-term endpoints via methods requiring a placebo arm.
These studies follow large numbers of vaccine recipients for SARS-CoV-2 acquisition and disease outcomes, providing the requisite data for vaccine-arm only CoP analysis.
\section{Definition of a controlled vaccine efficacy CoP and a controlled risk CoP}
Based on analysis of a vaccinated group in a phase 3 trial or in a post-approval trial, regression methods (e.g. logistic or Cox regression accounting for case-cohort or case-control biomarker sampling\cite{Chan2002,LiParnesChan2013,Moodieetal2018}) may be used to identify CoRs, i.e., immunologic biomarkers measured from vaccine recipients associated with subsequent occurrence of a clinical endpoint of interest.\cite{mehrotra2020clinical,Qinetal2007}
However, a CoR may fail to be a CoP, because the association parameter (e.g., hazard ratio) may not reflect a causal relationship.\cite{vanderWeele2013}
Consequently, while identification of a CoR is an important step toward validating a CoP, it is itself insufficient.\cite{Prentice1989,FlemingDeMets1996} We address this challenge in two steps. First, we define two causal effect parameters whose interpretations provide criteria for a CoP. Second, acknowledging that estimation of these two parameters requires the absence of unmeasured confounders, we develop a conservative estimation strategy that formally accounts for potential violations of this assumption.
Let $A=1$ indicate assignment to vaccine, and if the study included a placebo, let $A=0$ indicate assignment to placebo.
Let $S$ be an immunologic biomarker measured at a given post-vaccination visit, e.g. the Day 57 visit in the Moderna COVE phase 3 trial.\cite{Badenetal2020short} Let $Y$ be the indicator of occurrence of the clinical endpoint of interest after Day 57 during some fixed period of follow-up. Let $M$ be the indicator that $S$ is measured; typically, $M=1$ for all outcome cases (with $Y=1$) with available samples at Day 57 as well as for a random sample of all enrolled participants (case-cohort design \cite{Prentice1986}) or of all non-cases (case-control design \cite{BreslowHolubkov1997}). Let $X$ be a vector of baseline covariates, including potential predictors of $Y$. Let $O = (X,Y,M,MS)$ be the observed data unit for a participant, where $M S$ emphasizes that $S$ is only measured if $M=1$.
We define the two causal CoPs in terms of the causal parameter $r_C(s)=P\{Y(1,s)=1\}$, the probability of outcome occurrence for the counterfactual scenario in which all trial participants are assigned to vaccination and the immunologic biomarker is set to level $S=s$. We refer to the graph of $r_C(s)$ versus $s$ as the `controlled risk' curve since $r_C(s)$ forms the basis of a controlled effects parameter in the causal mediation literature.\cite{RobinsGreenland1992,Pearl2001} We define $S$ to be a {\it controlled risk CoP} if $r_C(s)$ is monotone non-increasing in $s$ with $r_C(s) > r_C(s')$ for at least some $s < s'$. Point and confidence interval estimates of the graph of $r_C(s)$ versus $s$ describe the strength and nature of the CoP.
Building on a controlled risk CoP, for a placebo-controlled trial, we define the controlled vaccine efficacy curve \[\mathit{CVE}(s) = 1 - \frac{r_C(s)}{P\{Y(0)=1\}} = 1 - \frac{P\{Y(1,s)=1\}}{P\{Y(0)=1\}},\ \]
where $P\{Y(0)=1\}$ is the probability of outcome if the whole cohort were assigned to receive placebo. We propose to define a {\it controlled VE CoP} as an immunologic biomarker with $\mathit{CVE}(s)$ non-decreasing in $s$ with $\mathit{CVE}(s) < \mathit{CVE}(s')$ for at least some $s < s'$.
Because $\mathit{CVE}(s)$ depends on $s$ entirely through $r_C(s)$, a controlled risk CoP and a controlled VE CoP are actually equivalent, and the distinction for applications is whether an unvaccinated/placebo arm is available. Where available, a controlled VE CoP has the preferred interpretation for most applications such as predicting VE in new settings (bridging).
Both types of causal CoPs may either be an `absolute CoP' or a `relative CoP' in the Plotkin nomenclature.\cite{Plotkin2008,Plotkin2010,PlotkinGilbert2018}
\section{Estimation and testing of controlled risk and control vaccine efficacy}
Since they are causal parameters, controlled risk CoPs and controlled VE CoPs are better fits to the
provisional-approval goalpost that an immunologic biomarker is reasonably likely to predict vaccine efficacy \cite{FlemingPowers2012} than a CoR association parameter. We consider estimation of $r_C(s)$, where the estimator $\widehat r_C(s)$ is also used in the estimator of $\mathit{CVE}(s)$.
Consider the marginalized risk
\begin{eqnarray}
r_M(s) = E\left[r(s,X)\right], \label{eq: OVR}
\end{eqnarray}
\noindent where
$r(s,x)=P(Y=1\,|\,S=s,A=1,X=x)$ and the outer expectation is over the marginal distribution of $X$ in the study population. The value $r_M(s)$ can be estimated from the observed data without untestable assumptions, and thus $r_M(s)$ is a CoR association parameter.
This parameter averages the biomarker-conditional risk over
the distribution of $X$ (i.e., direct standardization or g-computation).
If $r_C(s)>r_C(s')$ for $s < s'$, then by definition the risk decreases if the antibody biomarker is increased from $s$ to $s'$. In contrast, this implication does not necessarily follow if
$r_M(s) > r_M(s')$ for $s < s'$, because an unmeasured confounder not included in $X$ could create a reversal wherein $r_M(s) > r_M(s')$ even though $r_C(s) < r_C(s')$.
\comment{
…$F*$ upwards (i.e. increasing antibody response) is guaranteed to increase $VE^*$. In contrast, if formula (\ref{eq: PredVE}) replaced $P(Y*(1,s)=1)$ with the statistical parameter $P(Y*=1|S*=s,A*=1), then the implication would not hold. (SEEMS TO FAIL) Moreover, if the original and new trials were imagined in the same context of the original trial, such that $P(Y*(0)=1) = P(Y(0)=1)$, then $P(Y*(1,s)=1)$ decreasing in $s$ implies that $F^*$ stochastically larger than $F$ implies that $VE* > VE$ (i.e., improving the antibody biomarker response leads to improved vaccine efficacy).
To understand this, we need to distinguish vaccine efficacy in the original phase 3 trial, which was placebo-controlled (e.g., Pfizer/BioNTech), from vaccine efficacy of a vaccine in the new phase 3 trial, which does not have a placebo arm. We use notation $*$ to denote the new trial. In the original trial, overall vaccine efficacy (VE) can be written as
$$VE = \frac{\int P(Y(1,s)=1)dF(s)}{ P(Y(0)=1)},$$
\noindent where $F$ is the distribution of the antibody biomarker $S$ in vaccine recipients and $P(Y(0)=1)$ is the probability of outcome if the whole cohort were assigned to receive placebo. In the new trial, overall VE can be written as
\begin{eqnarray}
VE* = \frac{\int P(Y*(1,s)=1)dF*(s)}{ P(Y*(0)=1)}, \label{eq: PredVE}
\end{eqnarray}
\noindent where $F*$ is the distribution of the antibody biomarker $S*$ in the vaccine arm $A*=1$ and $P(Y*(0)=1)$ is the probability of outcome if the whole cohort were assigned to receive placebo. For the original trial, $P(Y(0)=1)$ can be validly estimated simply based on $P(Y=1|A=0)$, whereas for the new trial, $P(Y*(0)=1)$ is challenging to estimate as a counterfactual without an actual placebo arm. However, the salient point is that if $P(Y*(1,s)=1) decreases in $s$, then stochastically shifting $F*$ upwards (i.e. increasing antibody response) is guaranteed to increase $VE^*$. In contrast, if formula (\ref{eq: PredVE}) replaced $P(Y*(1,s)=1)$ with the statistical parameter $P(Y*=1|S*=s,A*=1)$, then the implication would not hold. (SEEMS TO FAIL) Moreover, if the original and new trials were imagined in the same context of the original trial, such that $P(Y*(0)=1) = P(Y(0)=1)$, then $P(Y*(1,s)=1)$ decreasing in $s$ implies that $F^*$ stochastically larger than $F$ implies that $VE* > VE$ (i.e., improving the antibody biomarker response leads to improved vaccine efficacy).
... in that $P(Y(1,s)=1) decreasing as $s$ increases would be guaranteed to translate into vaccine efficacy increasing in the new setting
vaccine efficacy may be predicted effectively based on the controlled risk curve. In particular, for a placebo-controlled phase 3 trial (e.g., the Pfizer/BioNTech trial), let $P(Y(0)=1)$ be the probability of outcome if the whole cohort were assigned to receive placebo. Then, vaccine efficacy can be predicted by averaging the controlled risk curve over the distribution $F$ of the antibody biomarker $S$ in the vaccine arm $A=1$:
\begin{eqnarray}
\textrm{Pred VE} = 1 - \frac{\int P(Y(1,s) dF(s)}{P(Y(0)=1)}. \label{eq: PredVE}
\end{eqnarray}
\noindent Now, interest in predicting VE is for the context of the new phase 3 trial that only studies a vaccine arm(s), for which it is a challenging problem to estimate $P^{new}(Y(0)=1)$
Sachs et al. (2020) considered a similar approach, except using a statistical parameter $P(Y=1|S=s,A=1)$ instead of a causal parameter $P(Y(1,s)=1)$, and noted that for validity the biomarker $S$ was assumed to be a valid CoP. While this CoP assumption was not formally defined, one possibility would be to define it as $P(Y(1,s)=1) = P(Y=1|S=s,A=1)$. Our xx
}
\subsection{Identifiability assumptions}
At biomarker level $s$, the controlled and marginalized risks
coincide, i.e.,
\begin{eqnarray}
r_C(s)=r_M(s)\, \label{eq: franco}
\end{eqnarray}
\noindent provided $Y(1,s)$ and $S$ are independent given $X$ (no unmeasured confounding), and $P(S=s\,|\,A=1,X)>0$ almost surely (positivity). In other words, identification of the controlled risk curve at biomarker level $s$ requires that a rich enough set of covariates be available so that deconfounding of the relationship between endpoint $Y$ and biomarker $S$ is possible in the population of vaccine recipients, and that $s$ be an observable biomarker level within each subpopulation of vaccine recipients defined by values of $X$.
\subsection{Estimation of the controlled risk curve via regression}
Various approaches can be used to estimate
$r_M(s)$, many of which are based on positing a model for $r(s,x)$,
estimating the unknown parameters of this model, and obtaining predicted values $\widehat{r}(s,X_i)$
for each vaccine recipient $i$ with $S_i$ measured. For example, an inverse-probability-weighted complete-case (IPW-CC) version of this approach estimates $r_M(s)$ by
\comment{
\begin{eqnarray}
\widehat{r}_M(s) = \frac{\sum_{i=i}^n \alpha_i(s)\widehat{r}(s,X_i) }{\sum_{i=i}^n \alpha_i(s)}\mbox{\ \ with\ \ }\alpha_i(s)=\frac{\widehat f(s|X_i)}{\widehat \pi(X_i,Y_i)}\ , \label{eq: obsriskest}
\end{eqnarray}
\noindent where $n$ is the number of vaccine recipients with $M=1$, $\widehat f(s|x)$ is an estimate of the conditional density or probability mass function $f(s|x)$ of $S$ given $A=1$ and $X=x$, and $\widehat \pi(x,y)$ is an estimate of the probability $\pi(x,y) = P(M=1\,|\,Y=y,A=1,X=x)$ of having data on $S$.
For unbiased estimation, the method for estimating the parameters of the model for $r(s,x)$ must account for the estimated sampling probabilities $\widehat \pi(X_i,Y_i)$ (e.g., \cite{BreslowHolubkov1997,Prentice1986,Barlowetal1999}). Moreover, the estimator
$\widehat f$ needs to be consistent for $f$, which also requires using weights $1\slash \widehat \pi(X_i,Y_i)$ in the employed conditional density estimation technique. Moreover, the estimator $\widehat \pi$ needs to be consistent for $\pi$, which often readily holds because the investigator controls which participants are sampled for measurement of $S$.
}
\begin{eqnarray}
\widehat{r}_M(s) = \frac{\sum_{i=i}^n \widehat{r}(s,X_i)\slash \widehat \pi(X_i,Y_i) }{\sum_{i=i}^n 1\slash \widehat \pi(X_i,Y_i)}\ , \label{eq: obsriskest}
\end{eqnarray}
\noindent where $n$ is the number of vaccine recipients with $M=1$ and $\widehat \pi(x,y)$ is an estimate of the probability $\pi(x,y) = P(M=1\,|\,Y=y,A=1,X=x)$ of having data on $S$.
For unbiased estimation, the method for estimating the parameters of the model for $r(s,x)$ must account for the estimated sampling probabilities $\widehat \pi(X_i,Y_i)$ (e.g., \cite{BreslowHolubkov1997,Prentice1986,Barlowetal1999}). In addition, the estimator $\widehat \pi$ needs to be consistent for $\pi$, which often readily holds because the investigator controls which participants are sampled for measurement of $S$.
In a setting where only a final binary outcome $Y$ is registered,
a common approach employs a generalized linear model
or scaled logit model \cite{Dunningetal2015} to estimate $r(s,x)$.
In a survival analysis framework that accounts for loss to follow-up, the outcome may be $Y=I(T \le t)$ for some fixed $t$, with $T$ the time from immunologic biomarker measurement until the clinical endpoint, and
$r(s,x)$ is modeled, e.g., using a proportional hazards model. Alternatively,
flexible nonparametric or machine learning-based regression approaches could be used. \cite{westling2020causal,WestlingCarone2020,PriceGilbertvanderLaan2018}
We aim to provide a reasonable sensitivity analysis framework that can be employed for almost any regression approach used for CoR analysis, including recently proposed approaches.\cite{son2020fast,Sachsetal2020}
\subsection{Conservative bounded estimation of the controlled risk ratio and curve via sensitivity analysis}
\label{sens}
As CoR analysis is based on observational data --- the biomarker value is not randomly assigned ---
a central concern is that unmeasured or uncontrolled confounding of the association between $S$ and $Y$ could render $r_M(s) \neq r_C(s)$, biasing
estimates of the controlled risk curve $r_C(s)$ and of controlled risk ratios of interest
$$RR_C(s_1,s_2) = r_C(s_2)/r_C(s_1)\ .$$
Sensitivity analysis is useful to evaluate how strong unmeasured confounding would have to be to explain away an inferred causal association, i.e., inference on $r_M(s)$ indicates an association yet
$r_C(s)$ is flat.
As recommended by VanderWeele and Ding (2017), we report the E-value as a summary measure of the evidence of causality.
The E-value is the minimum strength of association, on the risk ratio scale, that an unmeasured confounder would need to have with both the exposure ($S$) and the outcome ($Y$) to fully explain away a specific observed exposure–outcome association, conditional on the measured covariates.\cite{vanderWeeleDing2017,vanderWeeleMathur2020}
Here, ``explained away" means that under the E-value-level of unmeasured confounding the causal effect would be nullified (controlled risk ratio $RR_C(s_1,s_2) = 1$).
Because
$RR_C(s_1,s_2)=(1-CVE(s_2))\slash (1-CVE(s_1)),$ evidence for $RR_C(s_1,s_2) < 1$ is equivalently evidence for $CVE(s_1) < CVE(s_2)$. Thus in a placebo-controlled trial $RR_C(s_1,s_2)$ can be interpreted as the multiplicative degree of superior vaccine efficacy caused by marker level $s_2$ compared to caused by marker level $s_1$.
Consider two exposure/marker-level subgroups of interest $S=s_1$ and $S=s_2$ with $s_1 < s_2$, with $\widehat{RR}_M(s_1,s_2) = \widehat{r}_M(s_2)\slash \widehat{r}_M(s_1) < 1$. The E-value for the point estimate $\widehat{RR}_M(s_1,s_2)$ is
\begin{eqnarray}
e_{pt.est}(s_1,s_2) = \frac{1+\sqrt{1-\widehat{RR}_M(s_1,s_2)}}{\widehat{RR}_M(s_1,s_2)}\ .\label{eq: Evalue}
\end{eqnarray}
\noindent The E-value $e_{UL}(s_1,s_2)$ for the upper 95\% confidence limit $\widehat{UL}(s_1,s_2)$ for $RR_M(s_1,s_2)$ is
$$min\left\{ 1,\frac{1+\sqrt{1-\widehat{UL}(s_1,s_2)}}{\widehat{UL}(s_1,s_2)} \right\}\ . $$
\noindent
These two E-values quantify confidence in an immunologic biomarker as a controlled risk CoP and as a controlled VE CoP if there is a placebo arm, with E-values near one suggesting weak support and evidence increasing with greater E-values.
\comment{
To illustrate the interpretation of an E-value, suppose $S$ is binary and
$\widehat{RR}_M(0,1) = \widehat{r}_M(1) \slash \widehat{r}_M(0) = 0.40$ with 95\% confidence interval (CI) $(0.14, 0.78)$. An E-value $e(0,1)=4.4$ means that the marginalized risk ratio $RR_M(0,1)$ at point estimate 0.40 could be explained away by an unmeasured confounder
associated with both the exposure and the outcome by
a marginalized risk ratio of 4.4-fold each, after accounting for the
measured confounders $X$, but that weaker confounding could
not do so. Here ``explained away" means a nullified causal effect, i.e., point estimate of $RR_C(0,1)=1.0$.
The E-value $e_{UL}(s_1,s_2)$ for the upper limit $\widehat{UL}(s_1,s_2)$ of the 95\% CI for $\widehat{RR}_M(s_1,s_2)$ is also reported, computed as 1 if $\widehat{UL}(s_1,s_2)\ge 1$ and, otherwise, as
$$\frac{1+\sqrt{1-\widehat{UL}(s_1,s_2)}}{\widehat{UL}(s_1,s_2)}\ , $$
\noindent which in the example equals $e_{UL}(0,1)=1.88$.
}
It is also useful to provide conservative estimates of controlled risk ratios and of the controlled risk curve, accounting for unmeasured confounding.
We approach these tasks based on the sensitivity/bias analysis approach of Ding and VanderWeele (2016).\cite{DingvanderWeele2016}
Define two context-specific
sensitivity parameters for any given $s_1 < s_2$:
$RR_{UD}(s_1,s_2)$
is the maximum risk ratio for the outcome $Y$ comparing any two categories of the unmeasured confounder $U$, within either exposure group $S=s_1$ or $S=s_2$, conditional on the
vector $X$ of observed covariates; and $RR_{EU}(s_1,s_2)$ is the maximum risk
ratio for any specific level of the unmeasured confounder $U$ comparing individuals
with $S=s_1$ to those with $S=s_2$,
with adjustment already made for the measured covariate vector $X$
(where $RR_{UD}(s_1,s_2) \ge 1$ and $RR_{EU}(s_1,s_2) \ge 1$).
Thus, $RR_{UD}(s_1,s_2)$ quantifies the importance of the unmeasured confounder $U$ for the outcome, and $RR_{EU}(s_1,s_2)$ quantifies how imbalanced the exposure/marker subgroups $S=s_1$ and $S=s_2$ are in the
unmeasured confounder $U$.
We suppose that $RR_M(s_1,s_2) < 1$ for the values $s_1 < s_2$ used in a data analysis --- this is the case of interest for immune correlates assessment.
Define the bias factor
$$B(s_1,s_2) = \frac{RR_{UD}(s_1,s_2) RR_{EU}(s_1,s_2)}{RR_{UD}(s_1,s_2) + RR_{EU}(s_1,s_2) - 1}\ $$
for $s_1 \le s_2$, and define $RR^U_M(s_1,s_2)$ the same way as
$RR_M(s_1,s_2)$, except marginalizing over the joint distribution of $X$ and $U$. Then, $RR^U_M(s_1,s_2)\leq RR_M(s_1,s_2)\times B(s_1,s_2)$, where $RR^U_M(s_1,s_2) = E\{r(s_2,X^*)\}/
E\{r(s_1,X^*)\}$ with $X^* = (X,U)$ and $r$ conditional risk defined near equation (\ref{eq: OVR}).\cite{DingvanderWeele2016}
Translating this result into our context, under the positivity assumption $RR^U_M(s_1,s_2) = RR_C(s_1,s_2)$, so that
\begin{eqnarray}
RR_C(s_1,s_2) \le RR_M(s_1,s_2)\times B(s_1,s_2)\ . \label{eq: Dingvan2016result}
\end{eqnarray}
\noindent It follows that a conservative (upper bound) estimate of $RR_C(s_1,s_2)$ is $\widehat{RR}_M(s_1,s_2)\times B(s_1,s_2)$, and a conservative 95\% CI is obtained by multiplying each confidence limit for
$RR_M(s_1,s_2)$ by $B(s_1,s_2)$. These estimates
account for the presumed-maximum plausible amount of deviation from the no unmeasured confounders assumption specified by user-supplied values of $RR_{UD}(s_1,s_2)$ and $RR_{EU}(s_1,s_2)$.
An advantage of this approach is that the bound (\ref{eq: Dingvan2016result}) holds without making any assumption about the confounder vector $X$ or the unmeasured confounder $U$.\nocite{DingvanderWeele2016}
To provide conservative inference for $r_C(s)$, we next select a central value $s^{cent}$ of $S$ such that $\widehat{r}_M(s^{cent})$ matches the observed overall risk,
$\widehat P(Y=1|A=1)$.
This value is a `central' marker value at which the observed marginalized risk equals the observed overall risk. Next, we `anchor' the analysis by assuming
$r_C(s^{cent}) = r_M(s^{cent}),$ where picking the central value $s^{cent}$ makes this plausible to be at least approximately true.
Under this assumption, the bound (\ref{eq: Dingvan2016result}) implies the bounds
\begin{eqnarray}
r_C(s) &\le &r_M(s) B(s^{cent},s) \hspace{.1in} \hbox{\ if} \hspace{.1in} s\ge s^{cent} \label{eq: biasform1} \\
r_C(s) &\ge &r_M(s) \frac{1}{B(s,s^{cent})} \hspace{.1in} \hbox{\ if} \hspace{.1in} s < s^{cent}. \label{eq: biasform2}
\end{eqnarray}
\noindent Therefore, after specifying $B(s^{cent},s)$ and $B(s^{cent},s)$ for all $s$, we conservatively estimate $r_c(s)$ by plugging $\widehat r_M(s)$ into the formulas (\ref{eq: biasform1}) and (\ref{eq: biasform2}).
Because $B(s_1,s_2)$ is always greater than one for $s_1 < s_2$,
formula (\ref{eq: biasform1}) pulls the observed risk $\widehat{r}_M(s)$ upwards for subgroups with high biomarker values, and
formula (\ref{eq: biasform2}) pulls the observed risk $\widehat{r}_M(s)$ downwards for subgroups
with low biomarker values. This makes the estimate of the controlled risk curve flatter, closer to the null curve, as desired for a sensitivity/robustness analysis.
To specify $B(s_1,s_2)$, we note that it should have greater magnitude for a greater distance of $s_1$ from $s_2$, as determined by specifying
$RR_{UD}(s_1,s_2)$ and $RR_{EU}(s_1,s_2)$ increasing with
$s_2 - s_1$ (for $s_1 \le s_2$).
We consider one specific approach, which sets
$RR_{UD}(s_1,s_2) = RR_{EU}(s_1,s_2)$ to the common value $RR_U(s_1,s_2)$ that is specified log-linearly: $\log RR_U(s_1,s_2)$ \newline $= \gamma (s_2 - s_1)$ for $s_1 \le s_2$.
Then, for a user-selected pair of values $s_1=s^{fix}_1$ and $s_2=s^{fix}_2$ with $s^{fix}_1 < s^{fix}_2$,
we set a sensitivity parameter
$RR_U(s^{fix}_1,s^{fix}_2)$ to some value above one.
It follows that
$$\log RR_U(s_1,s_2) = \left(\frac{s_2 - s_1}{s^{fix}_2 - s^{fix}_1}\right) \log RR_U(s^{fix}_1,s^{fix}_2), \hspace{.2in} s_1 \le s_2.$$
\noindent Figure \ref{RRuplot} illustrates the $RR_U(s_1,s_2)$ and $B(s_1,s_2)$ surfaces.
\subsection{Use of marginalized risk and generality of the approach}
Our approach focuses on marginalized covariate-adjusted association parameters. This choice provides a simple conversion of the association parameters to causal parameters through the equation $r_M(s)=r_C(s)$.
Moreover,
a very common approach to covariate-adjusted CoR analysis consists of fitting a two-phase sampling regression
(e.g., logistic, Cox)
model to the immunologic biomarker and observed confounders, and subsequently reporting estimates of the association parameter (e.g., odds ratio, hazard ratio) corresponding to the immunologic biomarker covariate.
Because odds ratios and hazard ratios are not collapsible,
the conditional odds ratio and conditional hazard ratio do not in general equal the marginalized odds ratio and marginalized hazard ratio, respectively. \cite{RobinsGreenland1992,loux2017comparison} The dependency of the conditional odds/hazard ratio on the set of confounders conditioned upon may make these parameters less useful for generalizability of inferences than the marginalized parameters.
Yet, the same approach applies for alternative marginalized parameters, e.g. the marginalized odds ratio $$\frac{r_M(s_2)/\{1-r_M(s_2)\}}{r_M(s_1)/\{1-r_M(s_1)\}}\ .$$ The same specification of
$RR_{UD}(s_1,s_2)$ and $RR_{EU}(s_1,s_2)$ can be used, as the outcome in vaccine efficacy trials is generally rare. \cite{DingvanderWeele2016,vanderWeeleDing2017}
\subsection{Estimation of controlled vaccine efficacy with sensitivity analysis}
As evidence for a controlled VE CoP should be robust to potential bias from unmeasured confounding, we propose reporting conservative estimates and confidence intervals for $\mathit{CVE}(s)$, where `conservative' means including margin for potential unmeasured confounding that makes the estimated curve $\mathit{CVE}(s)$ flatter. To do this, we write
$\mathit{CVE}(s)= 1 - r_C(s) \slash E[P(Y=1|A=0,X)]$, and estimate $r_C(s)$ based on the equations
(\ref{eq: biasform1}) and (\ref{eq: biasform2}).
The denominator (placebo arm marginalized risk) equals $P\{Y(0)=1\}$ based on the randomization; there is thus no concern about unmeasured confounding. While this denominator may be estimated validly ignoring $X$, we favor using an estimation approach compatible with whatever approach was used to estimate $r_M(s)$.
For most regression approaches to estimation of $r_M(s)$ the bootstrap can be used to obtain valid 95\% confidence intervals for $\mathit{CVE}(s)$, implemented in the same manner as for inference about $r_M(s)$ and $r_C(s)$ except that the placebo arm must also be bootstrapped.
If the study cohort is naive to the relevant pathogen (e.g., SARS-CoV-2 VE trial primary cohorts), then the marker $S$ has no variability in the placebo arm [all values are `negative,' below the assay lower limit of detection (LLOD)]. Advantageously, in this setting $\mathit{CVE}(s)$ has a special connection to the natural effects mediation literature,\nocite{Cowlingetal2019} where
$\mathit{CVE}(s < LLOD)$ is the natural direct effect, and 100\% of vaccine efficacy is
mediated through $S$ if and only if $\mathit{CVE}(s < LLOD) = 0$. Thus inference on $\mathit{CVE}(s < LLOD)$ evaluates full mediation.
\section{Analysis of two dengue vaccine efficacy trials}\label{sec:CYD14CYD15}
In the CYD14 (NCT01373281)\cite{Capedingetal2014} and CYD15 (NCT01374516)\cite{Villaretal2015} trials, participants were randomized 2:1 to the CYD-TDV dengue vaccine vs. placebo, with immunizations at Months 0, 6, and 12. The primary analyses assessed vaccine efficacy (VE) against symptomatic, virologically confirmed dengue (VCD) occurring at least 28 days after the third immunization through to the Month 25 visit. Based on a proportional hazards model, estimated VE was 56.5\% (95\% CI 43.8--66.4) in CYD14 and 64.7\% (95\% CI 58.7--69.8) in CYD15. Sanofi Pasteur conducted the CYD14 and CYD15 trials and provided access to the data.
Month 13 (M13) neutralizing antibody (nAb) titers to each serotype were measured through case-cohort Bernoulli random sampling of all randomized participants at enrollment and from all participants who experienced the VCD endpoint after M13 and by Month 25 (cases). A participant's average M13 log10-transformed geometric mean titer across serotypes (``M13 average titer") has been studied as a CoR of VCD;\cite{Vigne2017,Moodieetal2018} we study this biomarker as a controlled risk CoP and as a controlled VE CoP.
For estimation of $r(s,x)$, we apply a method used in Moodie et al.,\cite{Moodieetal2018}
Cox partial likelihood regression \cite{Prentice1986} that accounted for the case-cohort sampling design.
The baseline covariates $X$ accounted for are protocol-specified age categories, sex, and country. Participants without VCD through the M13 visit and with
M13 average titer measured are included in analyses.
We first investigate how the marginalized risk of VCD compares between vaccine recipients with highest versus lowest tertile values of M13 average titer, coded $s=1$ and $s=0$.
The tasks of CoR analysis are to estimate $r_M(s=1)$, $r_M(s=0)$, and
$RR_M(0,1) = r_M(s=1) \slash r_M(s=0)$. Given the sampling design, $\widehat \pi(X_i,Y_i)$ is 1.0 for all cases $Y_i=1$ and is 0.195 (0.096) for
non-cases $Y_i=0$ sampled into the CYD14 (CYD15) subcohort. We estimate each $r_M(s)$ based on equation (\ref{eq: obsriskest}).
We use the bootstrap to obtain 95\% pointwise confidence intervals for each marginalized risk and marginalized risk ratio, which directly provide confidence intervals for each controlled risk and controlled risk ratio assuming no unmeasured confounding. Under the E-value formulas they also provide results assuming a certain amount of unmeasured confounding.
The results in Table 1 show
E-values for $RR_C(0,1)$ much larger than 1.0 with 95\% CIs lying below 1.0 for both trials, supporting a controlled risk CoP robust to unmeasured confounding.
For instance, the CYD15 results with 95\% CI for $RR_C(0,1)$ 0.04--0.20 building in margin for unmeasured confounding can be interpreted as marker level in the third vs. first tertile causing at least 5 times (5 = 1/0.20) greater vaccine efficacy, accounting for uncertainty both due to sampling variability and to unmeasured confounding.
\begin{center}
\begingroup
\renewcommand{\arraystretch}{2}
\begin{table}[H] \centering
\doublespacing
\caption{Analysis of M13 average titer (upper vs. lower tertile) as a CoR and a controlled risk CoP: CYD14 and CYD15 dengue vaccine efficacy trials}
\label{table1}
\singlespacing
\begin{tabular}{lcccccc} \hline \hline
& \multicolumn{2}{c}{marginalized risk} & \multicolumn{2}{c}{controlled risk} & & \\
& \multicolumn{2}{c}{ratio $RR_M(0,1)$} & \multicolumn{2}{c}{ratio $RR_C(0,1)^1$} & \multicolumn{2}{c}{e(0,1)$^2$} \\
Trial & Point Est. & 95\% CI & Point Est. & 95\% CI & Point Est. & 95\% CI UL \\ \hline
CYD14 & \input{input/CoPVeryHighVE_cyd14} \\
CYD15 & \input{input/CoPVeryHighVE_cyd15} \\ \hline \hline
\end{tabular}
\newline
\doublespacing
\noindent $^1$Conservative (upper bound) estimate assuming unmeasured confounding at level $RR_{UD}(0,1)=RR_{EU}(0,1) = 4$ and thus $B(0,1)=16/7$. \newline
\noindent $^2$E-values are computed for upper tertile $s=1$ vs. lower tertile $s=0$ biomarker subgroups after controlling for age, sex, and country; UL = upper limit.
\end{table}
\endgroup
\end{center}
\comment{
$RR(0,1)$ are $\widehat{RR}(1,0) = xx (95\% CI xx-xx)$ for CYD14 and
$\widehat{RR}(0,1) = xx (95\% CI xx-xx)$ for CYD15. For CYD14, the E-value $e_{RR}(0,1)$ is xx, with E-value $e_{UL}(0,1)$ for the upper limit equal to xx. For CYD15, the E-value $e_{RR}(0,1)$ is xx, with the E-value $e_{UL}(0,1)$ for the upper limit equal to xx. Next, we set $RR_{UD}(0,1)=RR_{EU}(0,1)=2$, such that $B(0,1)=$. The resulting conservative estimates of the controlled risk ratio are $\widehat{RR_C}(0,1) = xx (95\% CI xx-xx)$ for CYD14 and
$\widehat{RR_C}(0,1) = xx (95\% CI xx-xx)$ for CYD15 (PENDING: Just multiply by $B(0,1)$).
}
Next we repeat the analysis treating $S$ as a quantitative variable, where $r(s,x)$ is again estimated by two-phase Cox partial likelihood regression and now $RR_M(s_1,s_2)$ is the marginalized risk ratio between $s_1$ and $s_2$. Let $s_1$ and $s_2$ be the 15$^{th}$ and 85$^{th}$ percentile of M13 average titer.
The results for $RR_M(s_1,s_2)$ are $\widehat{RR}_M(s_1,s_2) = \input{input/cyd14_mrr}$ $(95\%$ CI \input{input/cyd14_mrrci}) for CYD14 and $\widehat{RR}_M(s_1,s_2) = \input{input/cyd15_mrr}$ $(95\%$ CI \input{input/cyd15_mrrci}) for CYD15. For CYD14, the E-value $e_{pt.est}(s_1,s_2)$ is \input{input/cyd14_e}, with E-value $e_{UL}(s_1,s_2)$ for the upper limit equal to \input{input/cyd14_eul}. For CYD15, the E-value $e_{pt.est}(s_1,s_2)$ is \input{input/cyd15_e}, with E-value $e_{UL}(s_1,s_2)$ for the upper limit equal to \input{input/cyd15_eul}. Next, we set $RR_{UD}(s_1,s_2)=RR_{EU}(s_1,s_2)=4$, such that $B(s_1,s_2)=16/7$. The resulting upper bound estimates of the controlled risk ratio are $\widehat{RR_C}(s_1,s_2) = \input{input/cyd14_crr}$ $(95\%$ CI \input{input/cyd14_crrci}) for CYD14 and $\widehat{RR_C}(s_1,s_2) = \input{input/cyd15_crr}$ $(95\%$ CI \input{input/cyd15_crrci}) for CYD15. Figure 2 shows
the sensitivity analysis described in Section
\ref{sens}.
After building in the margin for unmeasured confounding, for CYD4 estimated VCD risk decreases from 0.032 at
low M13 average titer value 1:36 to 0.01 at high titer value 1:1200; for CYD15 these results are 0.033 and 0.008, respectively.
Figure \ref{CoPveryhighVE_Fig3} shows results for
the
$\mathit{CVE}(s)$ curve,
where $E[P(Y=1|A=0,X)]$ was estimated with a standard Cox model
with point estimate the average of the fitted values $\widehat E[P(Y_i=1|A_i=0,X_i)]$ across all placebo recipients at-risk for VCD at the M13 visit.
The results show that after accounting for potential unmeasured confounding the point estimate of $\mathit{CVE}(s)$ in CYD14 monotonically increases from \input{input/fig3_low_cyd14} at low M13 average titer value of 36 to \input{input/fig3_high_cyd14} at high value 1200. The degree of increase is greater for CYD15: from \input{input/fig3_low_cyd15} to \input{input/fig3_high_cyd15}. This supports a robust controlled VE CoP.
The steeper increase and potentially superior CoP for CYD15 may be due to the older ages (9--16 vs. 2--14) and corresponding larger fraction of previously-infected vaccine recipients.
The $CVE(s)$ curve is above zero at lowest average titer, suggesting the CoP imperfectly mediates VE. This could be due to a variety of reasons including that the marker does not fully capture immune response quality.
For validity the analyses require positivity; Price et al.\cite{PriceGilbertvanderLaan2018} showed that M13 average titer in vaccine recipients varied over its whole range at each covariate level of $X$ in CYD14 and in CYD15, supporting this assumption.
In conclusion, the evidence for M13 nAb titer as a controlled risk CoP and as a controlled VE CoP is robust to no unmeasured confounding. As some vaccine recipients with high titer experienced VCD, the CoP is a relative CoP, not an absolute CoP.
\comment{
\section{Application to surrogate endpoint success criteria of vaccines}
If an immunologic marker $S$ is accepted as a surrogate endpoint, for traditional or provisional approval of a vaccine based on $S$, a threshold value, $s^*$, is typically first set such that
$S \ge s^*$ implies a certain high level of vaccine efficacy (e.g., 80\%). Then, based on a vaccine trial with $S$ as the primary endpoint, pre-specified success criteria are defined by lower bounds for point and 95\% lower confidence limit estimates for the frequency of vaccine recipients with $S \ge s^*$ (e.g., 0.9 and 0.67, respectively). The approach developed here provides one formal approach for conservatively defining $s^*$ based on
a placebo-controlled efficacy trial that helped lead to an established CoP.
Based on the curve $\mathit{CVE}(s)$,
$s^*$ can be defined as the smallest value of $S=s$ such that
the point estimate and lower 95\% confidence limit for $\mathit{CVE}(s)$ exceed pre-specified bars (e.g., 80\% and 60\%, respectively).
This approach is conservative in two ways. First, the estimate of $\mathit{CVE}(s^*)$ is a lower bound because the analysis assumes maximum feasible unmeasured confounding (specified by $RR_{UD}(s_1,s_2)$ and $RR_{EU}(s_1,s_2)$) that lowers the estimate. Second,
assuming that $r_C(s)$ is monotone non-increasing in $s$, the estimate of $\mathit{CVE}(s^*)$ is a lower bound compared to use of an alternative version of $\mathit{CVE}(s^*)$ that
replaces $r_C(s)$ with
$r^+_C(s)=P\{Y(1,s+)=1\}$,
where $Y(1,s+)$ denotes risk under assignment to vaccine and to the biomarker
$S \ge s$. This latter approach can be viewed as a causal version of the Chang-Kohberger (2003)\nocite{Jodaretal2003} method of estimating a threshold CoP. Their method (1) assumed that a high enough value $s^*$ implies that individuals with $S>s^*$ have essentially zero disease risk (protection) regardless of whether they were vaccinated; (2) assumed $P(Y=1|S\le s^*,A=1) \slash P(Y=1|S\le s^*,A=0) = 1$ (zero vaccine efficacy if $S \le s^*$); and (3) based on these assumptions calculated $s^*$ as the value equating
$1 - \widehat P(S\le s^*|A=1) \slash \widehat P(S\le s^*|A=0)$ to the estimate of overall vaccine efficacy. Our approach is different by removing the assumptions (1) and (2) [the latter of which could fail for reasons including misspecification of a simple binary protection/non-protection model and post-randomization selection bias (Frangakis and Rubin, 2002)\nocite{FrangakisRubin2002}] and adding confounding adjustment and uncertainty quantification accounting for sampling variability and potential unmeasured confounding.
}
\section{Discussion}
In virtually all immune correlates analyses of vaccine efficacy trials or prospective cohort studies, immunologic biomarkers are studied as correlates of risk in vaccine recipients. Given the goal to establish a biomarker as a correlate of protection/surrogate endpoint, it is generally of interest to evaluate the extent to which the correlates of risk results --- which are based on associational parameters --- can be interpreted in terms of causal effects, making them constitute a more reliable basis for decision-making for various
vaccine application questions. We proposed a general approach to augment correlates of risk analysis with a conservative analysis of the controlled risk curve $r_C(s)$, and also of the controlled vaccine efficacy curve $\mathit{CVE}(s)$ if there was a randomized placebo arm. The approach is general because it allows any frequentist method for estimation of the underlying conditional risk curve.
It is conservative by providing estimates and confidence intervals that assume a specified amount of unmeasured confounding that make it more difficult to conclude a controlled risk CoP (equivalently a controlled vaccine efficacy CoP if there is a placebo arm). For the controlled risk ratio and its relative controlled vaccine efficacy counterpart, the conservative estimation and inference is achieved by reporting E-values for the point estimate and upper 95\% confidence limit, whereas for the controlled risk and controlled vaccine efficacy curves it is quantified through an interpretable parametrization of the bias function that makes the controlled risk estimate flatter/closer to the null.
Aligned with VanderWeele and Ding (2017) \cite{vanderWeeleDing2017}, we do not think a particular E-value magnitude indicating a truly robust result should be pre-specified, as the interpretation of the E-value depends on the problem context, including the study endpoint, the vaccine, the set of potential confounders that are adjusted for, and the plausible magnitude of unmeasured confounders.
For example, if there is extensive knowledge about the endpoint prognostic factors and a rich set of baseline potential confounders are collected, then the bar for the magnitude of the E-value to be convincing will be smaller.
The assessment of controlled risk / vaccine efficacy CoPs should include the study of the strength of observed confounding as context for interpreting potential unmeasured confounding.
For SARS-CoV-2 vaccine studies, this would include studying the association of age, co-morbidities, and race/ethnicity with infection or disease outcomes.
It is useful for the sensitivity analysis to include a table reporting associations of potential confounders with outcomes and with immunologic biomarkers.
Our sensitivity analysis through E-values and the bias function only addresses unmeasured confounding; violation of the positivity assumption, selection bias, and missing data could also make the controlled risk CoP analysis results misleading. For prospective cohort studies with investigator control of which blood samples are selected for biomarker measurement, selection bias and missing data should not be a problem, unless a large percentage of participants have missing blood samples at the key biomarker sampling time point.
In our approach, the positivity assumption is required to convert the estimation of an associational parameter into estimation of a causal parameter, and so, we recommend the approach only be applied if diagnostics support that the antibody biomarker in vaccine recipients tends to vary over its full range within each level of the potential confounders that are adjusted for. Alternatively, specialized methods designed to be more robust to positivity violations (e.g., collaborative targeted minimum loss-based estimation \cite{van2010collaborative}) could be incorporated into our proposed framework.
Additionally, a basic premise of the proposed approach is that it is conceivable to assign every vaccine recipient to have an immunologic biomarker set to a given value $s$.
Diagnostics may be helpful to examine this premise. For example, if the oldest and/or immunocompromised participants tend to have low immune responses, it may be difficult to conceive of assigning their biomarker to the highest levels of $S$.
One way to address this problem would be to base CoP evaluation on the stochastic interventional risk curve defined in Hejazi et al. \cite{Hejazietal2020} instead of the controlled risk approach outlined here. This approach sets each vaccinated recipient's biomarker based on a random draw from a specified distribution --- for example, from the observed distribution with a specified shift upwards for some or all participants --- which in some settings may be more plausible.
While we focused on controlled vaccine efficacy based on the controlled risk curve $P\{Y(1,s)=1\}$ versus $s$, it may also be interesting to study
$r^+_C(s)=P\{Y(1,s+)=1\}$ versus $s$, where $Y(1,s+)$ denotes risk under assignment to vaccine and
to the biomarker $S \ge s$. In the dengue application, we studied this curve for two tertile cut-points. If the biomarker is continuous, similar regression methods can be used for estimation and inference on $r^+_C(s)$ over the entire span of $s$ values. One advantage of studying $r^+_C(s)$ is that regulators have historically defined immunologic surrogate endpoints for approval decisions in terms of thresholds \cite{Plotkin2008,Plotkin2010}.
However, since assignment to a level $S\geq s$ does not uniquely define a hypothetical intervention, the interpretation of the resulting controlled risk $r^+_C(s)$ will typically hinge on the degree to which each level of $S$ above $s$ is represented in the study sample --- this can result in less interpretable scientific findings.
In our application, we focused on two-phase Cox regression, a commonly used method, as the basis of the analysis of the marginalized risk curve $r_M(s)$. Yet, given the critical need to control for confounding and minimize systematic bias, it may be appealing to alternatively incorporate into the analysis nonparametric doubly-robust methods for estimating $r_M(s)$ under minimal assumptions, along the lines of
Westling et al. (2020) \cite{westling2020causal}.
Among surrogate endpoint evaluation approaches that have been considered, the principal stratification approach may most closely resemble the controlled vaccine efficacy approach, because it estimates a `vaccine efficacy curve' across principal strata defined by the level $s$ of the immunologic biomarker if assigned vaccine, and the outcome of the analysis looks similar. However, the two approaches address different scientific objectives, with principal stratification assessing vaccine efficacy across `natural' subgroups without assignment/intervention on the marker, whereas controlled effects assign the marker level. Thus an advantage of principal stratification is obviating the need to conceive assignment of a biomarker that was not randomly assigned; yet this implies the limitation of not fully addressing causal mediation of vaccine efficacy (e.g., VanderWeele, 2008).\nocite{vanderWeele2008} Consequently, while it is more challenging to conceptualize and define controlled vaccine efficacy, if this challenge is overcome then inferences are more relevant for core applications such as bridging -- predicting vaccine efficacy of new vaccines based on the immunologic biomarker.
Lastly,
the science of the biological assays used to define immunologic biomarkers should be highlighted as
fundamental to the establishment and utility of a CoP. Pre-specified validation criteria are typically required for an immunologic biomarker to be accepted as a surrogate endpoint.\cite{FDAGuidance2018} Post-acceptance, effective use of a surrogate endpoint requires that the biomarker be measured by the same lab that established the CoP, or that a new lab conducting the immunoassay has validated concordance of its assay compared to the original assay conducted by the original lab. Thus, standardization and validation of the immunoassay used to measure the CoP is a basic requirement for use of a CoP for approving/bridging vaccines.
| {'timestamp': '2021-07-14T02:04:41', 'yymm': '2107', 'arxiv_id': '2107.05734', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05734'} | arxiv |
\section{Introduction}
FER is an active research area in human-computer interactive systems as expressions convey important cue about emotional affect state of individuals. Traditional FER systems were built using facial images collected in-a-lab like environment. These methods fail to perform well under natural and un-controlled conditions. To tackle these challenges, large scale datasets like AffectNet \cite{12} captured in-the-wild have been developed. However, collecting a large-scale dataset with accurate annotations is usually impractical. Large scale FER datasets suffer from noisy annotations due to i) ambiguity in expressions, ii) poor quality of images, iii) automatic annotations obtained by querying web using keywords, iv) prototypic expressions vary across cultures, situations, and across individuals under same situation and v) subjectivity of annotators. Training with incorrect labels results in overfitting on wrong label images due to unique memorization ability of deep networks \cite{3_arpit2017closer, 5_45820} and model may learn wrong features which results in the degradation of performance. So, it is important to eliminate the influence of noisy samples during training.
Kollias et al. \cite{ABAW2} as a part of Affective Behavior Analysis in-the-wild (ABAW) 2021 competition have provided benchmark dataset Aff-Wild2 \cite{kollias2018aff, kollias2019expression, kollias2018multi, kollias2020analysing, kollias2021distribution, kollias2021affect, kollias2019face} consisting of in-the-wild 542 videos with 2,786,201 frames collected from YouTube. This dataset is an extension of Aff-Wild \cite{zafeiriou2017aff, kollias2017recognition, kollias2019deep} dataset. Aff-Wild2 dataset is annotated for 3-different tasks: i) valence and arousal estimation (2-D continuous dimensional model \cite{russell1980circumplex}, ii) seven basic emotions \cite{ekman1992argument} of happiness, neutral, anger, sad, surprise, disgust and fear (categorical classification) and iii) facial action unit recognition based on Facial Action Unit Coding System \cite{ekman2002facial} (multi-label classification). Since Aff-Wild2 is of very large scale, so it is unlikely that it does not have noisy annotations. Based on our recently proposed Consensual Collaborative Training (CCT) FER framework in the presence of noisy annotations \cite{gera_cct}, we experiment and validate our model on Aff-Wild2 dataset for expression classification track in ABAW 2021.
\section{Method}
In this section, we briefly present our CCT framework proposed in \cite{gera_cct} for FER under noisy annotations.
\begin{figure*}
\centerline{\includegraphics[width=1\columnwidth]{images/ECCT_framework.png}}
\caption{CCT involves training three networks $\theta_1, \theta_2 \text{ and } \theta_3$ jointly using a convex combination of supervision loss and consistency loss. Consensus is built by aligning the posterior distributions (shown as dotted red curves between $p_{1},p_{2}$ and $p_{3}$) using consistency loss. Dynamic weighting factor ($\lambda$) that balances both the losses is described in section \ref{DB}.}
\label{CCTframework}
\end{figure*}
\label{CCT}
\subsection{Overview}The CCT method follows the principle of consensus based collaborative training called Co-Training \cite{28_blum1998combining}. It uses three networks to learn robust facial expression features in the presence of noisy annotations. Inspired by \cite{10_wei2020combating,11_sarfraz2021noisy,29_dutt2020coupled}, we use three networks with identical architecture, but different initialization, trained jointly using a convex combination of supervision loss and consistency loss. Different initialization promote different learning paths for the networks, though they have same architecture. This subsequently reduces the overall error by averaging out individual errors due to the diversity of predictions and errors. In the initial phase of training, networks are trained using supervision loss. This ensures that clean data is effectively utilized during training since DNNs fit clean labels initially \cite{3_arpit2017closer, 5_45820}. Further, to avoid eventual memorization of noisy labels by individual DNNs \cite{3_arpit2017closer, 5_45820}, gradually, as the training progresses, more focus is laid on consensus building using consistency loss between predictions of different networks. Building consensus between networks of different capabilities ensures that no network by itself can decide to overfit on noisy labels. Further, it also promotes hard instance learning during training because the networks are not restricted to update based on only low loss samples, and further that, as the training progresses, they must agree. The trade-off between supervision and consistency loss is dynamically balanced using a Gaussian-like ramp-up function \cite{11_sarfraz2021noisy}. Further, the proposed CCT does not require noise distribution information, and it is also architecture independent. Figure \ref{CCTframework} delineates the proposed CCT framework and Algorithm \ref{CCTtraing_algorithm} enumerates the pseudo-code for CCT training. CCT implicitly avoids memorization because it has three networks collaborating with each other through the consistency loss.
\subsection{Problem formulation}
Let $D=\{(x_{i}, y_{i})\}_{i=1}^{N}$ be the dataset of N samples where $x_{i}$ is the $i^{th}$ input facial image with expression label $y_{i}\in\{1,2,...,C\}$, C denoting the number of expressions. We formulate CCT as a consensual collaborative learning between three networks parametrized by $\{\theta_{j}\}_{j=1}^{3}$. The learning is achieved by minimizing the loss $L$ given by:
\begin{equation} \label{loss}
L = (1-\lambda) * L_{sup} + \lambda * L_{cons}
\end{equation}
where $L_{sup}$, $L_{cons}$ and $\lambda$ are described below.
\subsubsection{Supervision loss} Cross-entropy ($CE$) loss is used as supervision loss to minimize the error between predictions and labels. Let $p_j$ denote the prediction probability distribution of network $j$. Then,
\begin{equation} \label{sup_loss}
L_{sup} = \sum_{j=1}^{3} L_{CE}^{(j)}(p_{j},y)
\end{equation}
where y is the groundtruth vector.
\subsubsection{Consistency loss} We use Kullback-Leibler divergence ($D_{KL}$) to bring consensus among predictions of different networks by aligning their probability distributions.
\begin{equation} \label{cons_loss}
L_{cons} = \sum_{j=1}^{3} \mathop{\sum_{k=1}^{3}}_{k\neq j} D_{KL}^{(j)}(p_{k}||p_{j})
\end{equation}
\subsubsection{Dynamic balancing}
\label{DB}
The dynamic trade-off factor between $L_{sup}$ and $L_{cons}$ is computed as in \cite{11_sarfraz2021noisy}. Specifically,
\begin{figure*}
\centerline{\includegraphics[width=0.6\columnwidth]{images/dynamic_balancing.png}}
\caption{Dynamic balancing curves for different values of $\beta$ }
\label{dynamic_balancing_factor}
\end{figure*}
\begin{equation} \label{rampup}
\lambda = \lambda_{max} * \exp^{-\beta(1 - \frac{e}{e_{r}})^{2}}
\end{equation}
where $\beta$ determines the shape of the Gaussian like ramp-up function, $\lambda_{max}$ refers to maximum value of $\lambda$, $e$ is the current epoch and $e_{r}$ is epoch (ramp-up length) at which $\lambda$ attains its maximum value ($\lambda_{max}$). When $\lambda$ is small, supervision loss dominates. As training progresses, $e$ approaches $e_{r}$ which pushes $\lambda$ towards $\lambda_{max}$, allowing consistency loss to take over. Figure \ref{dynamic_balancing_factor} displays the dynamic balancing curves for different $\beta$'s.
\subsubsection{Inference} During testing, given an unlabeled facial image, we use average of predictions from three networks to infer expression label. However, all networks give comparable performance, so any one of three networks can be used to reduce inference time.
\begin{algorithm}
\KwInput{ Model f with parameters $\theta = \{\theta_{1}, \theta_{2}, \theta_{3}\}$, dataset(D), learning rate($\eta$), total epochs $e_{max}$, maximum lambda value $\lambda_{max}$}
Initialize $\{\theta_{1}, \theta_{2}, \theta_{3}\}$ randomly.
\For{$e = 1,2,..,e_{max}$}
{
\hspace*{1em}Sample mini-batch $D_{n}$ from D\;
\hspace*{1em}Compute $ p_{i} = f(x,\theta_{i}) \forall x \in D_{n}, (1\leq i\leq3) $\;
\hspace*{1em}Compute dynamic balancing factor $\lambda$ using Eq.\eqref{rampup}\;
\hspace*{1em}Compute joint loss $L$ using Eqs. \eqref{loss}, \eqref{sup_loss} and \eqref{cons_loss}\;
\hspace*{1em}Update $\theta = \theta - \eta \nabla L$
}
return $\{\theta_{1}, \theta_{2}, \theta_{3}\}$
\caption{CCT training algorithm}
\label{CCTtraing_algorithm}
\end{algorithm}
\section{Datasets and Implementation Details}
\subsection{Datasets}
Aff-Wild2 dataset consisting of 539 videos with 2, 595, 572 frames with 431 subjects, 265 of which are male and 166 female, is annotated for 7 basic facial expressions. Eight of videos have displayed two subjects both of which have been labelled as left and right. Aff-Wild2 is split into three subsets: training, validation and test subsets consisting of 253, 71 and 223 videos respectively. Cropped and aligned frames for all them are made available as a part of the challenge. Since the dataset is highly imbalanced in terms of number of images per expression category, so we use other in the wild datasets like AffectNet\cite{12}, RAFDB \cite{li2019reliable_45,li2017reliable_46} for pre-training. \textbf{AffectNet} \cite{12} is the largest facial expression dataset with around 0.4 million images manually labeled for the presence of eight (neutral, happy, angry, sad, fear, surprise, disgust, contempt). Images except contempt category are considered for training the model. \textbf{RAF-DB} contains 29672 facial images tagged with basic or compound expressions by 40 independent taggers. Only 12271 images with basic emotion from training set are used.
\subsection{Implementation details}
The proposed work is implemented in PyTorch\footnote{https://pytorch.org} using a three GeForce RTX 2080 Ti GPUs with 11GB memory each. The individual networks in CCT are ResNet-18 pre-trained on large scale face dataset MS-Celeb-1M \cite{msceleb}. All images in AffectNet, RAFDB are aligned using MTCNN\footnote{https://github.com/ZhaoJ9014/face.evoLVe.PyTorch} \cite{zhang2016_56} and then resized to 224x224. For Aff-Wild2, cropped images provided by organizers are used after resizing them to 224x224. Batch size is set to 256. Optimizer used is Adam. Learning rate (lr) is initialized as 0.001 for base networks and 0.01 for the classification layer. Further, lr is decayed exponentially by a factor of 0.95 every epoch. Data augmentation includes random horizontal flipping, random erasing and color jitter. $\lambda_{max}$ is set to 0.9 and $\beta$ to $4.0 $ based on the ablation study in Sec \ref{ablation_dynamic_balancing_factor}.
\subsection{Evaluation metric}
Evaluation metric used in the challenge evaluation is weighed average of accuracy (33\%) and $F_{1}$ score (67\%).
Accuracy is defined as fractions of predictions that are correctly identified. It can be written as:
\begin{equation}\label{eq:6}
Accuracy(Acc) = \frac{Number \hspace{.3em} of\hspace{.3em} Correct\hspace{.3em}Predictions}{Total \hspace{.3em}number \hspace{.3em}of\hspace{.3em} Predictions}
\end{equation}
$F_{1}$ score is defined as weighted average of precision (i.e. Number of positive class images correctly identified out of positive predicted) and recall (i.e. Number of positive class images correctly identified out of true positive class). It can be written as:
\begin{equation}\label{eq:7}
F_{1} \hspace{.3em} score = \frac{ 2 \times precision \times recall }{ precision + recall}
\end{equation}
And the overall score considered is:
\begin{equation}\label{eq:8}
Overall \hspace{.3em} score = 0.67 \times F_{1} + 0.33 \times Acc
\end{equation}
\section{Results and Discussions}\label{Resultsanddiscussion}
\subsection{Performance Comparison with state-of-the-art methods}
We report our results on the official validation set of expression track from the ABAW 2021 Challenge \cite{ABAW2} in Table \ref{tab:Tab1} . Our best performance achieves overall score of 0.48 on validation set which is a significant improvement over baseline. For the competition, we have submitted multiple models based i) trained on only train set of Aff-Wild2, ii) trained on both train and validation set of Aff-Wild2 and iii) pretrained on AffectNet and finetuned on Aff-Wild2.
\begin{table}[hbt!]
\centering
\caption{Performance comparison on Aff-Wild2 validation set}
\begin{tabular}{c|c|c|c}
\hline
Method & F1 score & Accuracy & Overall \\
\hline
\hline
Baseline \cite{ABAW2} & 0.30 & 0.50 & 0.366 \\
CCT \cite{gera_cct} & \textbf{0.4040} & \textbf{0.6378} & \textbf{0.4814} \\
\hline
\end{tabular}
\label{tab:Tab1}
\end{table}
\begin{table}
\centering
\caption{Performance comparison on Aff-Wild2 Test set}
\begin{tabular}{c|c|c|c}
\hline
Method & F1 score & Accuracy & Overall \\
\hline
\hline
Baseline \cite{ABAW2} & 0.26 & 0.46 & 0.326 \\
Kawakarpo \cite{kawakarpo} & 0.29 & 0.6491 & 0.4082 \\
NTUA-CVSP \cite{NTUACVSP} & 0.3367 & 0.6418 & 0.4374 \\
Morphoboid \cite{Morphoboid} & 0.3511 & 0.668 & 0.4556 \\
FLAB2021 \cite{FLAB2021} & 0.4079 & 0.6729 & 0.4953 \\
STAR \cite{STAR} & 0.4759 & 0.7321 & 0.5604 \\
Maybe Next Time \cite{Maybe} & 0.6046 & 0.7289 & 0.6456 \\
CPIC-DIR2021 \cite{CPIC}& 0.6834 & 0.7709 & 0.7123 \\
Netease Fuxi Virtual Human \cite{Netease} & \textbf{0.763} & \textbf{0.8059} & \textbf{0.7777} \\
\hline
Ours\cite{gera_cct} & 0.361 & 0.675 & 0.4646 \\
\hline
\end{tabular}
\label{tab:Tab2}
\end{table}
Table \ref{tab:Tab2} presents the performance comparison on test set w.r.t other participating teams\footnote{https://ibug.doc.ic.ac.uk/resources/iccv-2021-2nd-abaw/}. Our top performing model was trained on whole train set of Aff-Wild2 using proposed model which is pretrained on AffectNet. Clearly, out model gives superior performance compared to many of teams. Since, we have trained model for single task and not used any of audio and video features, so performance is not as good as teams using multi-task learning with video features.
\begin{table}[hbt!]
\centering
\caption{Performance comparison w.r.t different number of models in CCT on validation set}
\begin{tabular}{c|c|c|c|c}
\hline
No of models & Pretrained & F1 score & Accuracy & Overall \\
\hline
\hline
1 & AffectNet & 0.3311 & 0.5705 & 0.41 \\
2 & AffectNet & 0.3744 & 0.621 & 0.456 \\
3 & AffectNet & \textbf{0.4040} & \textbf{0.6378} & \textbf{0.4814} \\%\textbf{0.3865} & \textbf{0.63} & \textbf{0.467} \\
4 & AffectNet & 0.366 & 0.613 & 0.447 \\
\hline
\end{tabular}
\label{tab:tab_no_of_models}
\end{table}
\begin{table}[hbt!]
\centering
\caption{Performance comparison w.r.t different dataset for pretraining in CCT on validation set.}
\begin{tabular}{c|c|c|c}
\hline
Pretrained dataset& F1 score & Accuracy & Overall \\
\hline
\hline
MS-Celeb-1M & 0.378 & 0.609 & 0.454 \\
RAFDB & 0.383 & 0.615 & 0.460 \\
AffectNet & \textbf{0.4040} & \textbf{0.6378} & \textbf{0.4814} \\%\textbf{0.3865} & \textbf{0.63} & \textbf{0.467} \\
\hline
\end{tabular}
\label{tab:tab_pretrained_dataset}
\end{table}
\begin{table}[hbt!]
\centering
\caption{Performance comparison with and without oversampling in CCT on validation set using MS-Celeb-1M pertrained model.}
\begin{tabular}{c|c|c|c}
\hline
Oversampling & F1 score & Accuracy & Overall \\
\hline
\hline
Without & 0.378 & 0.609 & 0.454 \\
With & 0.357 & 0.58 & 0.43 \\
\hline
\end{tabular}
\label{tab:tab_oversampling}
\end{table}
\begin{table}[hbt!]
\centering
\caption{Impact of consistency loss}
\begin{tabular}{c|c|c|c}
\hline
Loss & F1 score & Accuracy & Overall \\
\hline
\hline
CE Loss & 0.3634 & 0.610 & 0.445 \\
CE Loss + Consistency Loss & 0.378 & 0.609 & 0.454 \\
\hline
\end{tabular}
\label{tab:consistency_loss_vs_celoss}
\end{table}
\begin{table}[hbt!]
\centering
\caption{Impact of dynamic balancing factor ($\lambda$) for different values of $\beta$ in Eq. \ref{rampup} and Fig. \ref{dynamic_balancing_factor} using AffectNet pertrained model. }
\begin{tabular}{c|c|c|c}
\hline
$\beta$ & F1 score & Accuracy & Overall \\
\hline
\hline
0.1 & 0.352 & 0.593 & 0.432 \\
0.65 & 0.378 & 0.609 & 0.454 \\
1.0 & 0.390 & 0.6378 & 0.472 \\
1.5 & 0.378 & 0.6269 & 0.460 \\
2.0 & 0.3969 & 0.6160 & 0.469 \\
3.0 & 0.4051 & 0.6226 & 0.4769 \\
4.0 & \textbf{0.4040} & \textbf{0.6378} & \textbf{0.4814} \\
5.0 & 0.3931 & 0.6387 & 0.4742 \\
\hline
\end{tabular}
\label{tab:dynamic_balancing_factor}
\end{table}
\subsection{Ablation studies}
\subsubsection{Influence of number of networks:}
Table \ref{tab:tab_no_of_models} shows the influence of number of networks that are collaboratively trained in CCT. It can be observed that model with 3 networks performs the best in the presence of noise. This is because of the region where the 3 networks come into consensus is relatively smaller, thereby avoiding more noisy labels during training. However, with 4 networks, the number of parameters also significantly increases and building consensus is quite difficult.
\subsubsection{Impact of dynamic balancing factor} \label{ablation_dynamic_balancing_factor}
Since, as per Eq. \ref{rampup}, if the best $\beta$ is determined, automatically the best $\lambda$ gets fixed. So, we determine the best $\beta$ by computing performance for different values of beta in Table \ref{tab:dynamic_balancing_factor}. $\beta = 4$ gave best performance in Aff-Wild2 validation set.
\subsubsection{Effect of pretrained dataset}
We compared the influence of different datasets for pretrained model in Table \ref{tab:tab_pretrained_dataset}. Clearly, AffectNet dataset due to its large scale gives better performance compared to RAFDB.
\subsubsection{Influence of oversampling}
Table \ref{tab:tab_oversampling} shows that oversampling is not effective for training. So, all test submission are based on training without oversampling.
\subsubsection{Impact of consistency loss}
Table \ref{tab:consistency_loss_vs_celoss} evaluates the effect of consistency loss w.r.t training using only supervision loss. Clearly, dynamic transition using combined loss is more effective than training using only supervision loss.
\iffalse
\subsubsection{Comparison with baseline}
ResNet50 pretrained on VGGFace2 dataset with all samples from training set gave overall score of 0.42 as shown in Table 3 but it has large number of parameters as well as training takes much longer time . Also, accuracy is much less as compared to training on our model.
\subsubsection{Effect of number of training samples}
Since dataset is of huge size and highly imbalanced, we performed a comparative study by training our model on maximum of 15k, 20k, 50k, 1 lakh and all images from Aff-Wild2 as well as by using training images from Affectnet and ExpW datasets. Oversampling is used while training only on Aff-Wild2 dataset. The results are shown in Table 4. Clearly, as number of training data increases, performance improves but gain is not as significant as it should be. By training the model on AffectNet along with ExpW, by using only 50k samples from Aff-Wild2 performance matched to that of by using all images.
\subsubsection{Effect of pretrained dataset}
We did another study by pretraining our model on combination of i) AffectNet + RAFDB, ii) AffecNet+ExpW and iii) AffectNet+ExpW+RafDB and then fine tuned the model on Aff-Wild2 dataset. The results are shown in Table 5. Clearly, pretrained face model is necessary as performance drops significantly without it. Best performance is obtained by using VGGface2 pretrained model.
\subsection{Visualizations}
Our attention model is able to capture salient regions in the presence of occlusions and pose variations as shown in Figures \ref{fig:figure_visualization} and \ref{fig:figure_visualizationtest}. These visualizations are obtained using Grad-CAM\cite{selvaraju2017grad} from Conv\_4x layer feature maps. Dark color indicates high attention whereas lighter color indicates less attention. Figure \ref{fig:figure_visualization} shows visualizations on selected images from train and validation sets of Aff-Wild2 datasets in the presence of occlusion and pose variations. Some of visualizations on images from test set of Aff-Wild2 as shown in Figure \ref{fig:figure_visualizationtest} clearly demonstrate that our model is able to capture non-occluding regions as well as able to handle extreme pose and lighting variations of wild.
\begin{figure*}[ht!]
\centering
\includegraphics[width=.9\textwidth]{./images/Visualizations}
\caption{Attention maps for various images from training and validation set of Aff-Wild2 dataset using Grad-CAM activation visualization. (Predicted emotions are shown below each image.)}
\label{fig:figure_visualization}
\end{figure*}
\begin{figure*}[ht!]
\centering
\includegraphics[width=.7\textwidth]{./images/Visualizations_test2}
\caption{Attention maps for various images from test set of Aff-Wild2 dataset using Grad-CAM activation visualization (Predicted emotions are shown below each image.)}
\label{fig:figure_visualizationtest}
\end{figure*}
\fi
\section{Conclusions}
In this paper, we present robust framework called CCT for effectively training a FER system with noisy annotations on Aff-Wild2 dataset. CCT combated the noisy labels by co-training three networks. Supervision loss at early stage of training and gradual transition to consistency loss at later part of training ensured that the noisy labels did not influence the training. Both the losses are balanced dynamically. Our results on challenging dataset as a part of ABAW 2021 competition demonstrate the superiority of our method as compared to many others methods presented without using any audio and landmarks information. In the future work, we would like to test our model for valence-arousal estimation and facial action unit recognition tasks.
\section{Acknowledgments}
We dedicate this work to Our Guru Bhagawan Sri Sathya Sai Baba, Divine Founder Chancellor of Sri Sathya Sai Institute of Higher Learning, PrasanthiNilyam, A.P., India. We are also grateful to D. Kollias for all patience and support.
\bibliographystyle{unsrt}
| {'timestamp': '2021-07-27T02:06:39', 'yymm': '2107', 'arxiv_id': '2107.05736', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05736'} | arxiv |
\section{Introduction}
Reinforcement learning (RL) has recently achieved impressive successes in fields such as robotic manipulation~\cite{openai2019solving} and video game playing~\cite{mnih2015human}. However, compared with supervised learning that has a wide range of practical applications, RL applications have primarily been limited to game playing or lab robotics. A crucial reason for such limitation is the lack of guarantee that the performance of RL policies will improve monotonically; they often oscillate during policy updates. As such, deploying such updated policies without examining their reliability might bring severe consequences in real-world scenarios, e.g., crashing a self-driving car.
Dynamic programming (DP)~\cite{Bertsekas2005} offers a well-studied framework under which strict policy improvement is possible: with a known state transition model, reward function, and exact computation, monotonic improvement is ensured and convergence is guaranteed within a finite number of iterations~\cite{Ye2011}. However, in practice an accurate model of the environment is rarely available. In situations where either model knowledge is absent or the DP value functions cannot be explicitly computed, approximate DP and corresponding RL methods are to be considered. However, approximation introduces unavoidable update and Monte-Carlo sampling errors, and possibly restricts the policy space in which the policy is updated, leading to the \emph{policy oscillation} phenomenon~\cite{Bertsekas2011,wagner2011}, whereby the updated policy performs worse than pre-update policies during intermediate stages of learning. Inferior updated policies resulting from policy oscillation could pose a physical threat to real-world RL applications. Further, as value-based methods are widely employed in the state-of-the-art RL algorithms~\cite{haarnoja-SAC2018}, addressing the problem of policy oscillation becomes important in its own right.
Previous studies~\cite{Kakade02,pirotta13} attempt to address this issue by optimizing lower bounds of policy improvement: the classic conservative policy iteration (CPI) \cite{Kakade02} algorithm states that, if the new policy is linearly interpolated by the greedy policy and the baseline policy, non-negative lower bound on the policy improvement can be defined.
Since this lower bound is a negative quadratic function in the interpolation coefficient, one can solve for the maximizing coefficient to obtain maximum improvement at every update.
CPI opened the door of monotonic improvement algorithms and the concept of linear interpolation can be regarded as performing regularization in the \emph{stochastic policy space} to reduce greediness.
Such regularization is theoretically sound as it has been proved to converge to global optimum \cite{Scherrer2014-localPolicySearch,Neu17-unified}.
For the last two decades, CPI has inspired many studies on \emph{ensuring monotonic policy improvement}.
However, those studies (including CPI itself) are mostly theory-oriented and hardly applicable to practical scenarios, in that maximizing the lowerbound requires solving several state-action-space-wise maximization problems, e.g. estimating the maximum distance between two arbitrary policies.
One significant factor causing the complexity might be its excessive generality~\cite{Kakade02,pirotta13};
these bounds do not focus on any particular class of value-based RL algorithms, and hence without further assumptions the problem cannot be simplified.
Another recent trend of developing algorithms robust to the oscillation is by \emph{introducing regularizers into the reward function}.
For example, by maximizing reward as well as Shannon entropy of policy \cite{ziebart2010-phd}, the optimal policy becomes a multi-modal Boltzmann softmax distribution which avoids putting unit probability mass on the greedy but potentially sub-optimal actions corrupted by noise or error, significantly enhancing the robustness since optimal actions always have nonzero probabilities of being chosen.
On the other hand, the introduction of Kullback-Leibler (KL) divergence \cite{todorov2006linearly} has recently been identified to yield policies that average over all past value functions and errors, which enjoys state-of-the-art error dependency theoretically \cite{vieillard2020leverage}.
Though entropy-regularized algorithms have superior finite-time bounds and enjoy strong empirical performance, they do not guarantee to reduce policy oscillation since degradation during learning can still persist \cite{Nachum2017-TrustPCL}.
It is hence natural to raise the question of whether the practically intractable lowerbounds from the monotonic improvement literature can benefit from entropy regularization if we restrict ourselves to the entropy-regularized policy class.
By noticing that the policy interpolation and entropy regularization actually perform regularization in different aspects, i.e. in the stochastic policy space and reward function, we answer this question by affirmative.
We show focusing on the class of entropy-regularizede policies significantly simplifies the problem as a very recent result indicates a sequence of entropy-regularized policies has bounded KL divergence \cite{kozunoCVI}.
This result sheds light on approximating the intractable lowerbounds from the monotonic improvement algorithms since many quantities are related to the maximum distance between two arbitrary policies.
In this paper, we aim to tackle the policy oscillation problem by ensuring monotonic improvement via optimizing a more tractable lowerbound.
This novel entropy regularization aware lower bound of policy improvement depends only the expected policy advantage function.
We call the resultant algorithm \emph{cautious policy programming (CPP)}.
CPP leverages this lower bo\-und as a criterion for adjusting the degree of a policy update for alleviating policy oscillation.
By introducing heuristic designs suitable for nonlinear approximators, CPP can be extended to working with deep networks.
The extensions are compared with the state-of-the-art algorithm \cite{Vieillard-2020DCPI} on monotonic policy improvement.
We demonstrate that our approach can trade off performance and stability in both didactic classic control problems and challenging Atari games.
The contribution of this paper can be succinctly summarized as follows:
\begin{itemize}
\item we develop an easy-to-use lowerbound for ensuring monotonic policy improvement in RL.
\item we propose a novel scalable algorithm CPP which optimizes the lowerbound.
\item CPP is validated to reduce policy oscillation on high-dimensional problems which are intractable for prior methods.
\end{itemize}
Here, the first and second points are presented in Sec. \ref{sec:proposedMethod}, after a brief review on related work in Sec. \ref{sec:relatedWork} and preliminary in Sec. \ref{sec:preliminary}.
The third point is inspected in Sec. \ref{sec:experimental} which presents the results.
CPP has touched upon many related problems, and we provide in-depth discussion in Sec. \ref{sec:discussion}.
The paper is concluded in Sec. \ref{sec:conclusion}.
To not interrupt the flow of the paper, we defer all proofs until the Appendix.
\section{Related Work}\label{sec:relatedWork}
The policy oscillation phenomenon, also termed \emph{overshooting} by~\cite{wagner2011} and referred to as degraded performance of updated policies, frequently arises in approximate policy iteration algorithms~\cite{Bertsekas2011} and can occur even under asymptotically converged value functions~\cite{wagner2011}. It has been shown that aggressive updates with sampling and update errors, together with restricted policy spaces, are the main reasons for policy oscillation~\cite{pirotta13}.
In modern applications of RL, policy oscillation becomes an important issue when learning with deep networks when various sources of errors have to been taken in to account. It has been investigated by \cite{Fujimoto18-addressingApproximationError,fu2019-diagnosis} that those errors are the main cause for typical oscillating performance with deep RL implementations.
To attenuate policy oscillation, the seminal algorithm conservative policy iteration (CPI) \cite{Kakade02} propose to perform regularization in the stochastic policy space, whereby the greedily updated policy is interpolated with the current policy to achieve less aggressive updates.
{\color{black}
CPI has inspired numerous conservative algorithms that enjoy strong theoretical guarantees \cite{pirotta13,Pirotta13-adaptiveStepSizePG,abbasi-improvement16,Metelli18-configurable} to improve upon CPI by proposing new lower bounds for policy improvement. However, since their focus is on general Markov decision processes (MDPs), deriving practical algorithms based on the lower bounds is nontrivial and the proposed lower bounds are mostly of theoretical value.
Indeed, as admitted by the authors of \cite{papini20-balanceSpeedStabilityPG} that a large gap between theory and practice exists, as manifested by the their experimental results that even for a simple Cartpole environment, state-of-the-art algorithm failed to deliver attenuated oscillation and convergence speed comparable with heuristic optimization scheme such as Adam \cite{Adam}.
This might explain why \emph{adaptive coefficients} must be introduced in~\cite{Vieillard-2020DCPI} to extend CPI to be compatible with deep neural networks. To remove this limitation, our focus on entropy-regularized MDPs allows for a straightforward algorithm based on a novel, significantly simplified lower bound.
}
Another line of research toward alleviating policy oscillation is to incorporate regularization as a penalty into the reward function, leading to the recently booming literature on entropy-regularized MDPs \cite{azar2012dynamic,Fox2016,kozunoCVI,haarnoja-SAC2017a,vieillard2020leverage,Mei2019-principledEntropySearch}.
Instead of interpolating greedy policies, the reward is augmented with entropy of the policy, such as Shannon entropy for more diverse behavior and smooth optimization landscape \cite{ahmed19-entropy-policyOptimization},
or Kullback-Leibler (KL) divergence for enforcing policy similarity between policy updates and hence achieving superior sample efficiency \cite{Uchibe2018,uchibe2021-forwardBackward}.
The Shannon entropy renders the optimal policy of the regularized MDP stochastic and multi-modal and hence robust against errors and noises in contrast to the deterministic policy that puts all probability mass on a single action \cite{haarnoja-SAC2018}.
On the other hand, augmenting with KL divergence shapes the optimal policy an average of all past value functions, which is significantly more robust than a single point estimate.
Compared to the CPI-based algorithms, entropy-regularized algorithms do not have guarantee on per-update improvement. But they have demonstrated state-of-the-art empirical successes on a wide range of challenging tasks \cite{cui2017kernel,TSURUMINE2019,ZHU2020CEP,ZHU2022CCE}.
To the best of the authors' knowledge, unifying those two regularization schemes has not been considered in published literature before.
{\color{black}
It is worth noting that, inspired by \cite{Kakade02}, the concept of monotonic improvement has been exploited also in policy search scenarios~\cite{trpo-schulman15,akrour-monotonic-2016,Lior19-adaptiveTRPO,mei20b-globalConvergence,papini20-balanceSpeedStabilityPG}.
However, there is a large gap between theory and practice in those policy gradient methods.
On one hand, though \cite{trpo-schulman15,schulman2017proximal} demonstrated good empirical performance, their relaxed trust region is often too optimistic and easily corrupted by noises and errors that arise frequently in the deep RL setting: as pointed out by \cite{engstrom2020implementation}, the trust region technique itself alone fails to explain the efficiency of the algorithms and lots of code-level tricks are necessary.
On the other hand, exactly following the guidance of monotonic improving gradient does not lead to tempered oscillation and better performance even for simple problems \cite{Papini2017-adaptiveBatchSizePG,papini20-balanceSpeedStabilityPG}.
Another shortcoming of policy gradient methods is they focus on local optimal policy with strong dependency on initial parameters.
On the other hand, we focus on value-based RL that searches for global optimal policies.
}
\section{Preliminary}\label{sec:preliminary}
\subsection{Reinforcement Learning}
RL problems can be formulated by MDPs expressed by the quintuple $(\mathcal{S},\mathcal{A},\mathcal{T},\mathcal{R},\gamma)$, where $\mathcal{S}$ denotes the state space, $\mathcal{A}$ denotes the finite action space, and $\mathcal{T}$ denotes transition dynamics such that $\mathcal{T}_{ss'}^{a}:=\mathcal{T}(s'|s,a)$ represents the transition from state $s$ to $s'$ with action $a$ taken. $\mathcal{R} = r^{\,\,a}_{ss'}$ is the immediate reward associated with that transition. In this paper, we consider $r^{\,\,a}_{ss'}$ as bounded in the interval $[-1, 1]$. $\gamma \in (0,1)$ is the discount factor. For simplicity, we consider the infinite horizon discounted setting with a fixed starting state $s_{0}$. A policy $\pi$ is a probability distribution over actions given some state. We also define the stationary state distribution induced by $\pi$ as $d^{\pi}(s) = (1-\gamma)\sum_{t=0}^{\infty}\gamma^{t}\mathcal{T}({s_{t} = s|s_{0}, \pi})$.
RL algorithms search for an optimal policy $\pi^{*}$ that maximizes the state value function for all states $s$:
\begin{align*}
\pi^{*} := \argmax_{\pi} V^{\pi}(s) = \argmax_{\pi} \mathbb{E}\left[\sum_{t=0}^{\infty}\gamma^{t} r_{t} \big| s_{0} = s \right],
\end{align*}
where the expectation is with respect to the transition dynamics $\mathcal{T}$ and policy $\pi$. The state-action value function $Q^{\pi}$ is more frequently used in the control context:
\begin{align*}
Q^{\pi^{*}}(s, a) = \max_{\pi} \mathbb{E}\left[\sum_{t=0}^{\infty}\gamma^{t} r_{t} \big| s_{0} = s, a_{0} = a \right].
\end{align*}
\iffalse
RL methods search for an optimal stationary policy $\pi^{*}$ such that the expected long-term discounted reward is maximized, over all states:
\begin{align}
\begin{split}
V_{\pi^{*}}(s) = \max_{\pi}\mathbb{E}_{\mathcal{T}}\big[ \sum_{t=0}^{\infty}\gamma^{t} (r_{ss'}^{a})_{t} \big| s_{0} = s \big].
\end{split}
\end{align}
It is known that $V_{\pi^{*}}$ solves the following system of equations known as the Bellman optimality:
\begin{align}
\begin{split}
V_{{\pi}^{*}}(s)=\max_{\pi}{\sum_{\substack{a \in \mathcal{A} \\ s' \in \mathcal{S}}}\pi(a|s)\bigg[\mathcal{T}_{ss'}^{a}\big(r_{ss'}^{a}+\gamma V_{{\pi}^{*}}(s')\big)\bigg]}.
\label{sys_Vbellman}
\end{split}
\end{align}
The state-action value function $Q_{\pi^{*}}(s,a)$ is more frequently used in control context:
\begin{align}
\begin{split}
Q_{\pi^{*}}(s,a)&=\max_{\pi}{\sum_{s'\in\mathcal{S}}{\mathcal{T}_{ss'}^{a}\big(r_{ss'}^{a}+\gamma\sum_{a'\in\mathcal{A}}{\pi(a'|s')Q_{\pi^{*}}(s',a')}\big)}}.
\label{sys_Qbellman}
\end{split}
\end{align}
\fi
\subsection{Lower Bounds on Policy Improvement}
To frame the monotonic improvement problem, we introduce the following lemma that formally defines the criterion of policy improvement of some policy $\pi'$ over $\pi$:
\begin{lemma}{\cite{Kakade02}}\label{thm:kakade}
{For any stationary policies $\pi'$ and $\pi$, the following equation holds}:
\begin{align}
\begin{split}
&\Delta J^{\pi'}_{\pi, d^{\pi'}} := J^{{\pi'}}_{d} - J^{{\pi}}_{d} = {\sum_{s}{d^{\pi'}(s)\sum_{a}{\pi'(a|s){A_{\pi}(s,a)}}}}, \\
&\text{where } J^{{\pi'}}_{d} := \mathbb{E}_{s_{0},a_{0},\dots}{\bigg[ (1 - \gamma) \sum_{t=0}^{\infty}\gamma^{t}r_{t}\bigg]} = \sum_{s}{d^{{\pi'}}(s)}\sum_{a}{{\pi'}(a|s)r^{a}_{ss'}},
\end{split}
\label{kakade_idty}
\end{align}
\end{lemma}
$J$ is the discounted cumulative reward, and $A_{\pi}(s,a) := \quad$ $ Q_{\pi}(s,a) - V_{\pi}(s)$ is the advantage function. Though Lemma \ref{thm:kakade} relates policy improvement to the expected advantage function, pursuing policy improvement by directly exploiting Lemma \ref{thm:kakade} is intractable as it requires comparing $\pi'$ and $\pi$ point-wise for infinitely many new policies. Many existing works~\cite{Kakade02,pirotta13,trpo-schulman15} instead focus on finding a $\pi'$ such that the right-hand side of Eq. (\ref{kakade_idty}) is lower bounded. To alleviate policy oscillation brought by the greedily updated policy $\tilde{\pi}$,~\cite{Kakade02} proposes adopting \emph{partial update}:
\begin{align}
\begin{split}
\pi' = \zeta\tilde{\pi} + (1-\zeta)\pi.
\label{mixture_policy}
\end{split}
\end{align}
Eq. (\ref{mixture_policy}) corresponds to performing regularization in the stochastic policy space by interpolating the greedy policy and the current policy to achieve conservative updates.
{\color{black}
The concept of linearly interpolating policies has inspired many algorithms that enjoy strong theoretical guarantees \cite{pirotta13,Metelli18-configurable,akrour-monotonic-2016}.
However, those algorithms are mostly of theoretical value and have only been applied to small problems due to intractable optimization or estimation when the state-action space is high-dimensional/continuous.
Indeed, as admitted by the authors of \cite{papini20-balanceSpeedStabilityPG}, there is a large gap between theory and practice when using algorithms based on policy regularization Eq. (\ref{mixture_policy}): even on a simple CartPole problem, a state-of-the-art algorithm fail to compete with heuristic optimization technique.
Like our proposal in this paper, a very recent work \cite{Vieillard-2020DCPI} attempts to bridge this gap by proposing heuristic coefficient design for learning with deep networks.
We discuss the relationship between it and the CPP in Section \ref{sec:approximate_zeta}.
In the next section, we detail the derivation of the proposed lower bound by exploiting entropy regularization.
This novel lower bound allows us to significantly simplify the intractable optimization and estimation in prior work and provide a scalable implementation.
}
\section{Proposed Method}\label{sec:proposedMethod}
This section features the proposed novel lower bound on which we base a novel algorithm for ensuring monotonic policy improvement.
\subsection{Entropy-regularized RL}
In the following discussion, we provide a general formulation for entropy-regularized algorithms~\cite{azar2012dynamic,haarnoja-SAC2018,kozunoCVI}.
At iteration \emph{K}, the entropy of current policy $\pi_{K}$ and the Kullback-Leibler (KL) divergence between $\pi_{K}$ and some baseline policy $\bar{\pi}$ are added to the value function:
\begin{align}
\begin{split}
V_{\bar{\pi}}^{\pi_{K}}(s) &:= \sum_{\substack{a \in \mathcal{A} \\ s' \in \mathcal{S}}}\pi(a|s)\bigg[\mathcal{T}_{ss'}^{a}\big(r_{ss'}^{a}+\gamma V^{\pi_{K}}_{\bar{\pi}}(s')\big) - \mathcal{I}_{\bar{\pi}}^{\pi_{K}}\bigg], \\
\mathcal{I}_{\bar{\pi}}^{\pi_{K}} &= -\tau\log{\pi_{K}(a|s)} - \sigma\log{\frac{\pi_{K}(a|s)}{\bar{\pi}(a|s)}},
\label{sys_DPPbellman}
\end{split}
\end{align}
where $\tau$ controls the weight of the entropy bonus and $\sigma$ weights the effect of KL regularization. The baseline policy $\bar{\pi}$ is often taken as the policy from previous iteration $\pi_{K-1}$.
{\color{black}
Based on \cite{Nachum2017-bridgeGap,Nachum2017-TrustPCL}, we know the state value function $V^{\pi_{K}}_{\bar{\pi}}$ defined in Eq. (\ref{sys_DPPbellman}) and state-action value function $Q^{\pi_{K}}_{\bar{\pi}}$ also satisfy the Bellman recursion:
\begin{align*}
Q^{\pi_{K}}_{\bar{\pi}}(s,a) := r_{ss'}^{a} + \gamma\sum_{s'}\mathcal{T}_{ss'}^{a}V^{\pi_{K}}_{\bar{\pi}}(s').
\end{align*}
For notational convenience, in the remainder of this paper, we use the following definition:
\begin{align}
\alpha := \frac{\tau}{\tau+\sigma}, \quad \beta:=\frac{1}{\tau+\sigma}.
\label{eq:coef_def}
\end{align}
An intuitive explanation to Eq. (\ref{sys_DPPbellman}) is that the entropy term endows the optimal policy with multi-modal policy behavior \cite{haarnoja-SAC2017a} by placing nonzero probability mass on every action candidate, hence is robust against error and noise in function approximation that can easily corrupt the conventional deterministic optimal policy \cite{Puterman1994}.
On the other hand, KL divergence provides smooth policy updates by limiting the size of the update step \cite{azar2012dynamic,kozunoCVI,trpo-schulman15}.
Indeed, it has been recently shown that augmenting the reward with KL divergence renders the optimal policy an exponential smoothing of all past value functions \cite{vieillard2020leverage}.
Limiting the update step plays a crucial role in the recent successful algorithms since it prevents the aggressive updates that could easily be corrupted by errors \cite{Fujimoto18-addressingApproximationError,fu2019-diagnosis}.
It is worth noting that when the optimal policy is attained, the KL regularization term becomes zero.
Hence in Eq. (\ref{sys_DPPbellman}), the optimal policy maximizes the cumulative reward while keeping the entropy high.
}
\subsection{Entropy-regularization-aware Lower Bound}\label{nlb}
{\color{black}
Recall in Eq. (\ref{mixture_policy}) performing regularization in the stochastic policy space for the greedily updated policy $\tilde{\pi}$ requires preparing an reference policy $\pi$.
This policy could be from expert knowledge or previous policies.
The resultant $\pi'$, has guaranteed monotonic improvement which we formulate as the following lemma:
\begin{lemma}[\cite{pirotta13}]\label{thm:SPI}
{Provided that policy $\pi'$ is generated by partial update Eq. (\ref{mixture_policy}), $\zeta$ is chosen properly, and $A_{\pi, d^{{\pi}}}^{\tilde{\pi}} \geq 0$, then the following policy improvement is guaranteed:}
\begin{align}
\begin{split}
&\Delta J^{\pi'}_{\pi, d^{\pi'}} \geq \frac{\big((1-\gamma)A_{\pi,d^{\pi}}^{\tilde{\pi}}\big)^{2}}{2\gamma\delta\Delta A^{\tilde{\pi}}_{\pi}}, \\
\text{with } & \zeta = \min{(1, \zeta^{*})},\\
\text{where } &\zeta^{*}=\frac{(1-\gamma)^{2}A^{\tilde{\pi}}_{{\pi, d^{\pi}}}}{\gamma\delta\Delta A^{\tilde{\pi}}_{\pi}},\\
&\delta=\max_{s}{\left|\sum_{a\in\mathcal{A}}\big(\tilde{\pi}(a|s)-\pi(a|s)\big)\right|},\\
&\Delta A^{\tilde{\pi}}_{\pi}=\max_{s, s'}{|A^{\tilde{\pi}}_{\pi}(s)-A^{\tilde{\pi}}_{\pi}(s')}|,
\end{split}
\label{J_first_exact}
\end{align}
where $A_{\pi,d^{\pi}}^{\tilde{\pi}} := \sum_{s}d^{\pi}(s)\sum_{a} \adaBracket{\tilde{\pi}(a|s) - \pi(a|s)}Q_{\pi}(s,a)$.
\end{lemma}
\begin{proof}
See Section \ref{apdx:lemma2} for the proof.
\end{proof}
The interpolated policy $\pi'$ optimizes the bound and the policy improvement is a negative quadratic function in $\zeta$.
However, this optimization problem is highly non-trivial as $\delta$ and $\Delta A^{\tilde{\pi}}_{\pi}$ require searching the entire state-action space.
This challenge explains why CPI-inspired methods have only been applied to small problems with low-dimensional state-action spaces \cite{pirotta13,Metelli18-configurable,papini20-balanceSpeedStabilityPG}.
When the expert knowledge is not available, we can simply choose previous policies.
Specifically, at any iteration $K$, we want to ensure monotonic policy improvement given policy $\pi_{K}$.
We propose constructing a new monotonically improving policy as:
\begin{align}
\begin{split}
\tilde{\pi}_{K+1} = \zeta\pi_{K+1} + (1-\zeta)\pi_{K}.
\end{split}
\label{mixture_cvi}
\end{align}
It is now clear by comparing Eq. (\ref{mixture_policy}) with Eq. (\ref{mixture_cvi}) that our proposal takes $\pi', \tilde{\pi}, \pi$ as $\tilde{\pi}_{K+1}, \pi_{K+1}, \pi_{K}$, respectively. It is worth noting that ${\pi}_{K+1}$ is the \emph{updated policy that has not been deployed.}
However, the intractable quantities $\delta$ and $\Delta A^{\tilde{\pi}}_{\pi}$ in Lemma \ref{thm:SPI} are still an obstacle to deriving a scalable algorithm.
Specifically, by writing the component $A^{\tilde{\pi}}_{\pi}(s)$ of $\Delta A^{\tilde{\pi}}_{\pi}$ as
\begin{align*}
A^{\tilde{\pi}}_{\pi}(s) = \sum_{a} \big( \tilde{\pi}(a|s) - \pi(a|s) \big)Q_{\pi}(s,a),
\end{align*}
we see that both $\delta$ and $\Delta A^{\tilde{\pi}}_{\pi}$ require accurately estimating the total variation between two policies.
This could be difficult without enforcing constraints such as gradual change of policies.
Fortunately, by noticing that the consecutive entropy-regularized policies $\pi_{K+1}, \pi_{K}$ have \emph{bounded} total variation, we can leverage the boundedness to bypass the intracatable estimation.
\begin{lemma}[\cite{kozunoCVI}]\label{thm:KL}
{For any policies $\pi_{K}$ and $\pi_{K+1}$ generated by taking the maximizer of Eq. (\ref{sys_DPPbellman}), the following bound holds for their maximum total variation}:
\begin{align}
\begin{split}
&\max_{s}{D_{TV}\left(\pi_{K+1}(\cdot|s) \,||\, \pi_{K}(\cdot|s) \right) } \leq \\
&\qquad \qquad \qquad \qquad \min \left\{ \sqrt{1 - e^{- 4 B_{K} - 2 C_{K}}}, \sqrt{8 B_{K} + 4C_{K}} \right\} , \\
& \qquad \text{where } B_{K}=\frac{1-\gamma^{K}}{1-\gamma}\epsilon\beta , \,\,\,\, C_{K} = \beta r_{max} \sum_{k=0}^{K-1}{\alpha^{k}\gamma^{K-k-1}},
\end{split}
\label{CVI_kl}
\end{align}
\emph{$K$ denotes the current iteration index and $0\leq k\leq K-1$ is the loop index.
$\epsilon$ is the uniform upper bound of error.}
\end{lemma}
\begin{proof}
See Section \ref{apdx:lemma3} for the proof.
\end{proof}
Lemma \ref{thm:KL} states that, entropy-regularized policies have boun\-ded total variation (and hence bounded KL divergence by Pinsker's and Kozuno's inequality \cite{kozunoCVI}).
This bound allows us to bypass the intractable estimation in Lemma \ref{thm:SPI} and approximate $\tilde{\pi}_{K+1}$ that optimizes the lowerbound.
We formally state this result in the Theorem \ref{thm:main} below.
For convenience, we assume there is no error, i.e. $B_{K} = 0$.
Setting $B_{K} = 0$ is only for the ease of notation of our latter derivation. Our results still hold by simply replacing all appearance of $C_{K}$ to $B_{K} + C_{K}$. On the other hand, in implementation it requires a sensible choice of upper bound of error which is typically difficult especially for high dimensional problems and with nonlinear function approximators.
Fortunately, by the virtue of KL regularization in Eq. (\ref{sys_DPPbellman}), it has been shown in \cite{azar2012dynamic,Vieillard2020Momentum} that if the sequence of errors is a martingale difference under the natural filtration, then the summation of errors asymptotically cancels out. Hence it might be safe to simply set $B_{K} = 0$ if we assume the martingale difference condition.
\begin{theorem}\label{thm:main}
{Provided that partial update Eq. (\ref{mixture_cvi}) is adopted, $A^{{\pi_{K+1}}}_{\pi_{K},d^{\pi_{K}}} \geq 0$, and $\zeta$ is chosen properly as specified below, then any maximizer policy of Eq. (\ref{sys_DPPbellman}) guarantees the following improvement that depends only on $\alpha, \beta, \gamma$ and $A^{{\pi_{K+1}}}_{\pi_{K},d^{\pi_{K}}}$ after any policy update:}
\begin{align}
\begin{split}
\Delta J^{\tilde{\pi}_{K+1}}_{\pi_{K},d^{\tilde{\pi}_{K+1}}} &\geq \frac{\big(1-\gamma)^{3}(A_{\pi_{K},d^{\pi_{K}}}^{{\pi_{K+1}}})^{2}}{4 \gamma} \max \left\{\frac{1}{1-e^{-2 C_{K}}} \,\, , \,\, \frac{1}{4 C_{K} } \right\},\\
\text{with } \zeta &= \min{(1, \zeta^{*})}, \quad C_{K} = \beta\sum_{k=0}^{K-1}{\alpha^{k}\gamma^{K-k-1}}, \\
\text{where } \zeta^{*} &= \frac{(1-\gamma)^{3}A^{{\pi_{K+1}}}_{{\pi_{K},d^{\pi_{K}}}}}{2 \gamma } \max\left\{ \frac{1}{1-e^{-2 C_{K}}}, \frac{1}{4 C_{K}} \right\},
\label{J_first_improved}
\end{split}
\end{align}
$\alpha, \beta$ are defined in Eq. (\ref{eq:coef_def}) and
\begin{align}
& A^{\pi_{K+1}}_{\pi_{K}, d^{{\pi}_{K}}} := \sum_{s}d^{{{\pi}_{K}}} (s) \, A^{{\pi_{K+1}}}_{\pi_{K}} (s), \label{eq:statAdv}\\
& A^{{\pi_{K+1}}}_{\pi_{K}} (s) := \sum_{a} \big( {\pi_{K+1}}(a|s) - \pi_{K}(a|s) \big)Q_{\pi_{K}}(s,a) \label{eq:expAdv}
\end{align}
are the expected policy advantage, and the policy advantage function, respectively.
\end{theorem}
\begin{proof}
See Section \ref{apdx:thm4} for the proof.
\end{proof}
}
While theoretically we need to compare $1 - e^{-2 C_{K}}$ and $4 C_{K}$ when computing $\zeta^{*}$, in implementation the exponential function $e^{-2 C_{K}}$ might be sometimes close to 1 and hence causing numerical instability.
Hence in the rest of the paper we shall stick to using the constant $C_{K}$ rather than the exponential function.
In the lower bound Eq. (\ref{J_first_improved}), only $A^{{\pi_{K+1}}}_{{\pi_{K}},d^{{\pi}_{K}}}$ needs to be estimated. It is worth noting that $\forall s, A^{{\pi_{K+1}}}_{{\pi_{K}}} (s) \geq 0$ is a straightforward criterion that is naturally satisfied by the greedy policy improvement of policy iteration when computation is exact.
To handle the negative case caused by error or approximate computations, we can simply stack more samples to reduce the variance, as will be detailed in Sec. \ref{sec:CPP_FA}.
\subsection{The CPP Policy Iteratiion}
We now detail the structure of our proposed algorithm based on Theorem \ref{thm:main}.
Specifically, value update, policy update, and stationary distribution estimation are introduced, followed by discussion on a subtlety in practice and two possible solutions.
{\color{black}
Following \cite{scherrer15-AMPI}, CPP can be written in the following succinct policy iteration style:
\begin{align}
\begin{split}
\text{CPP} = \begin{cases}
\pi_{K+1} \leftarrow \mathcal{G}{Q^{\pi_{K}}_{\bar{\pi}}} & \\
Q_{\pi_{K+1}} \leftarrow (T_{\pi_{K+1}})^{m} Q_{\pi_{K}} & \\
\zeta = \min \left\{(4 C_{K})^{-1}{C_{\gamma} A^{{\pi_{K+1}}}_{{\pi_{K},d^{\pi_{K}}}}} \,\, , \,\, 1\right\} \\
\tilde{\pi}_{K+1} \leftarrow \zeta \pi_{K+1} + (1 - \zeta) \pi_{K},
\end{cases}
\end{split}
\label{eq:cpp_pi}
\end{align}
where $C_{\gamma} := \frac{(1-\gamma)^3}{2\gamma}$ is the horizon constant. Note that for numerical stability we stick to using $(4C_K)^{-1}$ as the entropy-bounding constant rather than using $\frac{1}{1 - e^{-2C_K}}$.
Like CPI, CPP can obtain \emph{global optimal policy} rather than just achieving monotonic improvement (which might still converge to a local optimum) by the argument of \cite{Scherrer2014-localPolicySearch}.
The first step corresponds to the greedy step of policy iteration, the second step policy estimation step, third step computing interpolation coefficient $\zeta$ and the last step interpolating the policy.
\subsubsection{Policy Improvement and Policy Evaluation}\label{sec:policyIter}
The first two steps are standard update and estimation steps of policy iteration algorithms \cite{Sutton-RL2018}.
The subscript of $Q^{\pi_{K}}_{\bar{\pi}}$ indicates it is entropy-regularized as introduced in Eq. (\ref{sys_DPPbellman}).
The policy improvement step consists of evaluating $\mathcal{G}{Q^{\pi_{K}}_{\bar{\pi}}}$, which is the greedy operator acting on $Q^{\pi_{K}}_{\bar{\pi}}$.
By the Fenchel conjugacy of Shannon entropy and KL divergence, $\mathcal{G}{Q^{\pi_{K}}_{\bar{\pi}}}$ has a closed-form solution \cite{kozunoCVI,Beck2017-firstOrder}:
\begin{align*}
\mathcal{G}{Q^{\pi_{K}}_{\bar{\pi}}} (a|s) = \frac{\bar{\pi}(a|s)^{\alpha}\exp\adaBracket{\beta Q^{\pi_{K}}_{\bar{\pi}} (s,a) }}{\sum_{b} \bar{\pi}(b|s)^{\alpha}\exp\adaBracket{\beta Q^{\pi_{K}}_{\bar{\pi} } (s,b) }},
\end{align*}
where $\alpha, \beta$ were defined in Eq. (\ref{eq:coef_def}).
The policy evaluation step estimates the value of current policy $\pi_{K+1}$ by repeatedly applying the Bellman operator $T_{\pi_{K+1}}$:
\begin{align}
\begin{split}
&\qquad \qquad (T_{\pi_{K+1}})^{m} Q_{\pi_{K}} := \underbrace{T_{\pi_{K+1}}\dots T_{\pi_{K+1}}}_{m \text{ times}} Q_{\pi_{K}}, \\
& T_{\pi_{K+1}} Q_{\pi_{K}} := r_{ss'}^{a} + \gamma\sum_{s'}\mathcal{T}_{ss'}^{a} \sum_{a}\pi_{K+1}(a|s') Q^{\pi_{K}}_{\bar{\pi}}(s',a).
\end{split}
\label{eq:policy_evaluation}
\end{align}
Note that $m = 1, \infty$ correspond to the value iteration and policy iteration, respectively \cite{Bertsekas:1996:NP:560669}.
Other interger-valued $m \in [2, \infty)$ correspond to the approximate modified policy iteration \cite{scherrer15-AMPI}.
Now in order to estimate $A_{\pi_{K},d^{\pi_{K}}}^{{\pi_{K+1}}}$ in Theorem \ref{thm:main}, both $A_{\pi_{K}}^{{\pi_{K+1}}}$ and $d^{{\pi}_{K}}$ need to be estimated from samples.
Estimating $A_{\pi_{K}}^{{\pi_{K+1}}}(s)$ is straightforward by its definition in Eq. (\ref{eq:expAdv}).
We can first compute $Q_{\pi_{K}}(s,a) - V_{\pi_{K}}(s), \,\forall s,a$ for the current policy, and then update the policy to obtain $\pi_{K+1}(a|s)$.
On the other hand, sampling with respect to $d^{{\pi}_{K}}$ results in an on-policy algorithm, which is expensive.
We provide both on- and off-policy implementations of CPP in the following sections, but in principle off-policy learning algorithms can be applied to estimate $d^{{\pi}_{K}}$ by exploiting techniques such as importance sampling (IS) ratio \cite{precup2000eligibility}.
\subsubsection{Leveraging Policy Interpolation}\label{sec:leverage_interpolation}
Computing $\zeta$ in Eq. (\ref{J_first_improved}) involves the horizon constant $C_{\gamma} := \frac{(1-\gamma)^3}{2\gamma}$ and policy difference bound constant $C_{K}$.
The horizon constant is effective in DP scenarios where the total number of timesteps is typically small, but might not be suitable for learning with deep networks that feature large number of timesteps: a vanishingly small $C_{\gamma}$ will significantly hinder learning, hence it should be removed in deep RL implementations. We detail this consideration in Section \ref{sec:CPP_FA}.
The updated policy $\pi_{K+1}$ in Eq. (\ref{eq:cpp_pi}) cannot be directly deployed since it has not been verified to improve upon $\pi_{K}$.
We interpolate between $\pi_{K+1}$ and $\pi_{K}$ with coefficient $\zeta$ such that the resultant policy $\tilde{\pi}_{K+1}$ by finding the maximizer of a negative quadratic function in $\zeta$.
The maximizer $\zeta^*$ optimizes the lowerbound $\Delta J^{\tilde{\pi}_{K+1}}_{\pi_{K},d^{\tilde{\pi}_{K+1}}}$.
Here, $\zeta$ is optimally tuned and dynamically changing in every update. It reflects the \emph{cautiousness} against policy oscillation, i.e., how much we trust the updated policy $\pi_{K+1}$. Generally, at the early stage of learning, $\zeta$ should be small in order to explore conservatively.
However, a major concern is that Lemma \ref{thm:KL} holds only for Boltzmann policies, while the interpolated policies are generally no longer Boltzmann.
In practice, we have two options for handling this problem:
\begin{enumerate}
\item we use the interpolated policy only for collecting samples (i.e. behavior policy) but not for computing next policy;
\item we perform an additional projection step to project the interpolated policy back to the Boltzmann class as the next policy.
\end{enumerate}
{\color{black}
The first solution might be suitable for relatively simple problems where the safe exploration is required:
the behavior policy is conservative in exploring when $\zeta \!\approx\! 0$.
But learning can still proceed even with such small $\zeta$.
Hence this scheme suits problems where interaction with the environment is crucial but progress is desired.}
On the other hand, the second scheme is more natural since the off-policyness caused by the mismatch between the behavior and learning policy might be compounded by high dimensionality. The increased mismatch might be perturbing to performance.
In the following section, we introduce CPP using linear function approximation for the first scheme and deep CPP for the second scheme.
For the second scheme, manipulating the interpolated policy is inconvenient since we will have to remember all previous weights and more importantly, the theoretical properties of Boltzmann policies do not hold any longer.
To solve this issue, heuristically an information projection step is performed for every interpolated policy to obtain a Boltzmann policy.
In practice, this policy is found by solving $\min_{\pi} D_{KL}(\pi || \zeta\bar{\pi}_{K+1} + (1-\zeta)\pi_{K})$.
Though the information projection step can only approximately guarantee that the CVI bound continues to apply since the replay buffer capacity is finite, it has been commonly used in practice \cite{haarnoja-SAC2018,Vieillard-2020DCPI}.
In our implementation of deep CPP, the projection problem is solved efficiently using autodifferentiation (Line 7 of Algorithm \ref{alg:deepCPP}).
\iffalse
\subsubsection{Estimating Stationary Distributions}
In practice, $d^{\tilde{\pi}_{K+1}}(s)$ in $A_{\pi_{K},d^{\pi_{K}}}^{{\pi_{K+1}}}$ of Eq. (\ref{J_first_improved}) is unwieldy as we have not deployed $\tilde{\pi}_{K+1}$ and only have $\pi_{K+1}, \pi_{K}$ at our disposal.
Motivated by~\cite{Kakade02,trpo-schulman15}, we approximate Eq. (\ref{kakade_idty}) using
\begin{align}
\begin{split}
\Delta {J^{\tilde{\pi}_{K+1}}_{\pi_{K}, d}} \approx \Delta \widehat{J^{\tilde{\pi}_{K+1}}_{\pi_{K}, d}} := {\sum_{s}{d^{\pi_{K}}(s) {\sum_{a} \tilde{\pi}_{K+1}(a|s) A_{\pi_{K}}(s)}}}, \\
\end{split}
\label{kakade_idty_approx}
\end{align}
where now the stationary distribution $d^{\pi_{K}}$ is induced by $\pi_{K}$ instead of $\tilde{\pi}_{K+1}$ in $d^{\tilde{\pi}_{K+1}}$.
If $\pi$ is a differentiable function parametrized by $\theta$, then according to~\cite{Kakade02,trpo-schulman15}, $\Delta \widehat{J^{\tilde{\pi}_{K+1}}_{\pi_{K}, d}}$ and $\Delta {J^{\tilde{\pi}_{K+1}}_{\pi_{K}, d}}$ have the same first-order terms.
Entropy-regularization further justifies this approximation by allowing us to bound the maximum \emph{improvement loss} $\big| \Delta {J^{\tilde{\pi}_{K+1}}_{\pi_{K}, d}} - \Delta \widehat{J^{\tilde{\pi}_{K+1}}_{\pi_{K}, d}} \big|$, even without assuming $\pi$ is differentiable. We first prove the following novel result:
\begin{lemma}\label{thm:boundedStat}
{For any policies $\tilde{\pi}_{K+1}$ generated by Eq. (\ref{mixture_cvi}) and $\pi_{K+1}, \pi_{K}$ by Eq. (\ref{sys_DPPbellman}), the following holds:}
\begin{align*}
&|| d^{\tilde{\pi}_{K+1}} - d^{\pi_{K}} ||_{1} \leq \frac{2\zeta\gamma}{(1-\gamma)^2}\sqrt{C_{K}}.
\end{align*}
\end{lemma}
\begin{proof}
See the proof of Lemma \ref{thm:SPI} in the Appendix.
\end{proof}
Equipped with Lemma \ref{thm:SPI}, we provide the following bound on the improvement loss induced by employing approximation Eq. (\ref{kakade_idty_approx}):
\begin{theorem}\label{thm:concentration}
\emph{The approximation of Eq. (\ref{kakade_idty_approx}) can cause improvement loss $\mathcal{L}^{a, d^{a}}_{b, d^{b}}$ of at most}:
\begin{align*}
\big| \mathcal{L}^{a, d^{a}}_{b, d^{b}} \big| := \bigg|\Delta {J^{\tilde{\pi}_{K+1}}_{\pi_{K}, d}} \,-\, \Delta \widehat{J^{\tilde{\pi}_{K+1}}_{\pi_{K}, d}} \bigg| \leq (1-\gamma) \, \mynorm{A_{b}^{a}}{1}^2,
\end{align*}
where $\tilde{\pi}_{K+1}$ is denoted as $a$ and $\pi_{K}$ as $b$.
{\color{black}
Moreover, we have the following concentration inequality stating that for any threshold $\delta$, we have
\begin{align}
\begin{split}
P\adaBracket{ \bigg| \,\Delta {J^{\tilde{\pi}_{K+1}}_{\pi_{K}, d}} \,-\, \widehat{{J}} \,\, \bigg| \ge \delta} \leq 2 \exp \adaBracket{ \, {\frac{-n\delta^{2}}{2|\mathcal{A}|^{2}}} },
\end{split}
\label{eq:Hoeffding}
\end{align}
where $\widehat{J} := \frac{1}{n} \sum_{j=1}^{n} \adaBracket{\Delta \widehat{J^{\tilde{\pi}_{K+1}}_{\pi_{K}, d}} }_{j}$ is the empirical average over $n$ independent estimates.
In other words, for any $\delta, \kappa > 0$, if the number of iid trajectories
\begin{align*}
n \geq \frac{2|\mathcal{A}|^{2}\log\frac{2}{\kappa}}{\delta^{2}},
\end{align*}
then with probability at least $1 - \kappa$ we have:
\begin{align*}
\bigg| \,\Delta {J^{\tilde{\pi}_{K+1}}_{\pi_{K}, d}} \,-\, \widehat{{J}} \,\, \bigg| < \delta.
\end{align*}
}
\end{theorem}
\begin{proof}
See the proof of Theorem \ref{thm:main} in the Appendix.
\end{proof}
\textbf{Remark. } In practice, $\gamma$ is typically set to a large value, e.g., $\gamma = 0.95$, then improvement loss $\mathcal{L}^{a, d^{a}}_{b, d^{b}} = 0.05 \, ||A_{b}^{a}||^{2}_{1}$. When we bound the reward $r_{max} = 1$, it is often true that $||A_{b}^{a}||_{1} \leq 1$. Hence, for entropy-regularized algorithms, changing the stationary distribution following Eq. (\ref{kakade_idty_approx}) can provide only small improvement loss.
\fi
\subsection{Approximate Interpolation Coefficient}\label{sec:approximate_zeta}
The lowerbound of policy improvement depends on $A^{\pi_{K+1}}_{\pi_{K}, d^{\pi_{K}}}$.
Though it is general difficult to compute exactly, very recently \cite{Vieillard-2020DCPI} propose to estimate it using batch samples.
We hence define several quantities following \cite{Vieillard-2020DCPI}: let $B_t$ denote a batch randomly sampled from the replay buffer $B$ and define $\hat{A}_{K}(s) := \max_{a}Q(s, a) - V(s)$ as an estimate of $A^{\tilde{\pi}}_{\pi}(s)$, $\hat{\mathbb{A}}_{K} := \mathbb{E}_{s\sim B}[\hat{A}_{K}(s)]$ as an estimate of $A^{\tilde{\pi}}_{\pi, d^{\pi}}$, and $\hat{A}_{K, \text{min}}:= \min_{s\sim B}\hat{A}_{K}(s)$ as the minimum of the batch.
When we use linear function approximation with on-policy buffer $B_{K}$, we simply change the minibatch $B$ in the above notations to the on-policy buffer $B_{K}$.
Given the notations defined above, we can compare the existing interpolation coefficients as the following:
\textbf{CPI}:
the classic CPI algorithm proposes to use the coefficient:
\begin{align}
\zeta_{\textsc{CPI}} = \frac{(1-\gamma) \hat{\mathbb{A}}_{K}}{4 r_{max}},
\label{eq:cpi_zeta}
\end{align}
where $r_{max}$ is the largest possible reward.
When the knowledge of the largest reward is not available, approximation based on batches or buffer will have to be employed.
\textbf{Exact SPI}:
SPI proposes to extend CPI by using the following coefficient:
\begin{align}
\zeta_{\textsc{E-SPI}} = \frac{(1-\gamma)^{2} \hat{\mathbb{A}}_{K}}{\gamma\delta\Delta A^{\pi_{K+1}}_{\pi_{K}}},
\label{eq:espi_zeta}
\end{align}
where $\delta, \Delta A^{\pi_{K+1}}_{\pi_{K}}$ were specified in Lemma \ref{thm:SPI}.
When $\delta, \Delta A^{\pi_{K+1}}_{\pi_{K}}$ cannot be exactly computed, sample-based approximation will have to employed.
\textbf{Approximate SPI}:
as suggested by \cite[Remark 1]{pirotta13}, approximate $\zeta$ can be derived if we na\"{i}vely leverage $\delta\Delta A^{\pi_{K+1}}_{\pi_{K}} <\frac{4}{1-\gamma}$:
\begin{align}
\zeta_{\textsc{A-SPI}} = \frac{(1-\gamma)^{3} \hat{\mathbb{A}}_{K}}{4\gamma}.
\label{eq:aspi_zeta}
\end{align}
\textbf{Linear CPP}:
if policies are entropy-regularized as indicated in Eq. (\ref{sys_DPPbellman}), we can upper bound $\delta\Delta A^{\pi_{K+1}}_{\pi_{K}}$ by using Lemma \ref{thm:KL}:
\begin{align}
\zeta_{\textsc{CPP}} = \frac{(1-\gamma)^{3} \hat{\mathbb{A}}_{K}}{8\gamma C_{K}}.
\label{eq:linear_cpp}
\end{align}
By the definition of $C_{K}$ in Eq. (\ref{CVI_kl}), $\zeta_{\textsc{CPP}}$ can take on a wider range of values than $\zeta_{\textsc{A-SPI}}$.
\textbf{Deep CPI}:
for better working with deep networks, the following adaptive coefficient was proposed in deep CPI (DCPI) \cite{Vieillard-2020DCPI}:
\begin{align}
\begin{split}
\zeta_{\textsc{DCPI}} = \hat{\zeta_{0}} \frac{m_K}{M_{K}}, \quad \begin{cases}
m_{K} = \rho_1 m_{K-1} + (1 - \rho_1) \hat{\mathbb{A}}_{K} & \\
M_{K} = \min(\rho_2 M_{K-1}, \hat{A}_{K, \text{min}}),
\end{cases}
\end{split}
\label{eq:adaptive_zeta}
\end{align}
where $\rho_1, \rho_2 \in (0, 1)$ are learning rates, and $\hat{\zeta}_{0} = \frac{1}{4}$ same with CPI \cite{Kakade02}.
\textbf{Deep CPP}:
we follow the DCPI coefficient design for making $\zeta_{\textsc{CPP}}$ suitable for deep RL.
Specifically, we modify DCPP by defining $\hat{\zeta}_{0} = \frac{1}{C_{K}}$:
\begin{align}
\begin{split}
\zeta_{\textsc{DCPP}} = \texttt{clip}\left\{\frac{1}{C_K} \frac{m_K}{M_{K}}, \,\, 0, \,\, 1 \right\},
\end{split}
\label{eq:cpp_zeta}
\end{align}
where $m_K, M_K$ are same as Eq. (\ref{eq:adaptive_zeta}).\\
Based on Eqs. (\ref{eq:linear_cpp}), (\ref{eq:cpp_zeta}), we detail the linear and deep implementations of CPP in the next section.
\subsection{Approximate CPP}\label{sec:CPP_FA}
\begin{algorithm}[t]
\SetKwInOut{Input}{Input}
\caption{ Linear Cautious Policy Programming}\label{alg:CPP}
\Input{$\alpha, \beta, \gamma$ CPP parameters, $I$ the total number of iterations, $T$ the number of steps for each iteration}
initialize $\theta, \tilde{\pi}_{0}$ at random\;
empty on-policy buffer ${B}_{K} = \{\}$\;
\For{$K = 1, \dots, I$}
{
\For{$t=1,\dots, T$}{
Interact using policy $\tilde{\pi}_{K-1}$\;
Collect $(s^{K}_{t},a^{K}_{t},r^{K}_{t},s^{K}_{t+1})$ into buffer ${B}_{K}$ \;
}
{
compute basis matrix $\Phi_{K}$ using ${B}_{K}$\;
update $\theta$ by normal equations Eq. (\ref{eq:normal_equations})\;
compute $\hat{\zeta}_{0} = \frac{1}{C_{K}}$ and $\hat{\zeta} = \hat{\zeta}_{0} \frac{m_{K}}{M_{K}}$ using Eq. (\ref{eq:adaptive_zeta})\;
empty on-policy buffer ${B}_{K}$\;
}
}
\end{algorithm}
We introduce the linear implementation of CPP following \cite{lagoudakis2003least,azar2012dynamic} and deep CPP inspired by \cite{Vieillard-2020DCPI} in Algs. \ref{alg:CPP} and \ref{alg:deepCPP}, respectively.
It is worth noting that in linear CPP we assume the interpolated policy $\tilde{\pi}$ is used only for collecting samples (line 5 of Alg. \ref{alg:CPP}) hence no projection is necessary as it does not interfere with computing next policy.
\textbf{Linear CPP}.
We adopt linear function approximation (LFA) to approximate the Q-function by $Q(s,a) = \phi(s,a)^{T}\theta$, where $\phi(x) = [\varphi_{1}(x), \ldots, \varphi_{M}(x)]^{T}, x=[s,a]^{T}$, $\varphi(x)$ is the basis function and $\theta$ corresponds to the weight vector. One typical choice of basis function is the radial basis function:
\begin{align*}
\varphi_{i}(x) = \exp\big(-\frac{||x-c_{i}||^{2}}{\sigma^{2}}\big),
\end{align*}
where $c_{i}$ is the center and $\sigma$ is the width.
We construct basis matrix $\Phi = [\phi_{1}(x_{1}), \ldots, \phi_{M}(x_{N})] \in \mathbb{R}^{T\times M}$, where $T$ is the number of timesteps.
Specifically, at $K$-th iteration, we maintain an on-policy buffer ${B}_{K}$.
For every timestep $t\in[1,T]$, we collect $(s^{K}_{t},a^{K}_{t},r^{K}_{t},s^{K}_{t+1})$ into the buffer and compute the basis matrix at the end of every iteration.
To obtain the best-fit $\theta_{K+1}$ for the $K + 1$-th iteration, we solve the least-squares problem $||T_{\pi_{K+1}}Q_{\pi_{K}} - \Phi\theta_{K} ||^{2}$:
\begin{align}
\theta_{K+1} = \big(\Phi^{T}\Phi + \varepsilon I\big)^{-1}\Phi^{T}T_{\pi_{K+1}}Q_{\pi_{K}},
\label{eq:normal_equations}
\end{align}
where $\varepsilon$ is a small constant preventing singular matrix inversion and ${T_{\pi_{K+1}}Q_{\pi_{K}}}$ is the empirical Bellman operator defined by
\begin{align*}
{ T_{\pi_{K+1}}Q_{\pi_{K}} } (s^{K}_t, a^{K}_t) := r(s^{K}_t, a^{K}_t) + \gamma \sum_{a} \pi_{K+1}(a|s^{K}_{t+1}) Q_{K}(s^{K}_{t+1},a).
\end{align*}
Since the buffer is on-policy, we empty it at the end of every iteration (line 10).
\begin{algorithm}[t]
\SetKwInOut{Input}{Input}
\caption{Deep Cautious Policy Programming}\label{alg:deepCPP}
\Input{$\alpha, \beta, \gamma$ CPP parameters, $T$ the total number of steps, $F$ the interaction period, $C$ the update period}
initialize $\theta$ at random\;
set $\theta^{-} = \theta$, $K = 0$ and buffer ${B}$ to be empty\;
\For{$K = 1, \dots, T$}
{ interact with the environment using policy $\pi_{\epsilon}$\;
collect a transition tuple $(s,a,r,s')$ into buffer $\mathcal{B}$ \;
\If{$K \text{ mod } F == 0$}{
sample a minibatch $B_{t}$ from ${B}$ and compute the loss $\mathcal{L}_{value}$ and $\mathcal{L}_{policy}$ using Eqs. (\ref{eq:value_loss}), (\ref{eq:policy_loss})\;
do one step of gradient descent on the loss $\mathcal{L}_{train} = \mathcal{L}_{value} + \mathcal{L}_{policy}$\;
compute $\hat{A}_{K}, \hat{\mathbb{A}}_{K}$ and moving average $m_{K}, M_{K}$ using Eq. (\ref{eq:adaptive_zeta})\;
}
\If{$K \text{ mod } C == 0$}
{
$\theta^{-} \leftarrow \theta$ \;
compute $\hat{\zeta}_{0} = \frac{1}{C_{K}}$ and ${\zeta_{\textsc{CPP}}} = \hat{\zeta}_{0} \frac{m_{K}}{M_{K}}$ using Eq. (\ref{eq:adaptive_zeta})\;
}
}
\end{algorithm}
\textbf{Deep CPP. }
Though CPP is an on-policy algorithm, by following \cite{Vieillard-2020DCPI} off-policy data can also be leveraged with the hope that random sampling from the replay buffer covers areas likely to be visited by the policy in the long term.
Off-policy learning greatly expands CPP's coverage, since on-policy algorithms require expensively large number of samples to converge, while off-policy algorithms are more competitive in terms of sample complexity in deep RL scenarios.
We implement CPP based on the DQN architecture, where the Q-function is parameterized as $Q_{\theta}$, where $\theta$ denotes the weights of an online network, as can be seen from Line 2.
Line 3 begins the learning loop.
For every step we interact with the environment using policy $\pi_{\epsilon}$, where $\epsilon$ denotes the epsilon-greedy policy threshold.
As a result, a tuple of experience is collected to the buffer.
Line 6 of Alg. \ref{alg:deepCPP} begins the update loop.
We sample a minibatch from the buffer and compute the loss $\mathcal{L}_{value}, \mathcal{L}_{policy}$ defined in Eqs. (\ref{eq:value_loss}), (\ref{eq:policy_loss}), respectively.
Since our implementation is based on DQN, we do not include additional policy network as done in \cite{Vieillard-2020DCPI}.
Instead, we denote the policy as $\pi_{\theta}$ to indicate that the policy is a function of $Q_{\theta}$ as shown in Eq. (\ref{eq:boltzmann_greedy}).
The base policy is hence denoted by $\pi^{-}_{\theta}$ to indicate it is computed by the target network of $\theta^{-}$.
We define the regression target as:
\begin{align*}
\hat{Q}(s_{t},a_{t},r_{t},s_{t+1}) = & ( r_{t} + \gamma \sum_{a\in\mathcal{A}} \pi_{\theta}(a | s_{t+1})\big( Q^{-}(s_{t+1}, a) + \\
& \tau \log \pi_{\theta}(a|s_{t+1}) + \sigma \log\frac{\pi_{\theta}(a|s_{t+1})}{\pi^{-}_{\theta}(a|s_{t+1})} \big).
\end{align*}
Hence, the loss for $\theta$ is defined by:
\begin{align}
\label{eq:value_loss}
\mathcal{L}_{value}(\theta) = \mathbb{E}_{(s_{t}, a_{t}, \dots) \sim B} \left[ \left( Q_{\theta}(s_{t}, a_{t}) - \hat{Q}(s_{t},a_{t},r_{t},s_{t+1}) \right)^{2} \right].
\end{align}
It should be noted that the interpolated policy cannot be directly used as it is generally no longer Boltzmann.
To tackle this problem, we further incorporate the following minimization problem to project the interpolated policy back to the Boltzmann policy class:
\begin{align}
\begin{split}\label{eq:policy_loss}
&\mathcal{L}_{policy} (\theta) = \\
&\mathbb{E}_{(s_{t}, a_{t}, \dots) \sim B} \left[ D_{KL} \left( \pi_{\theta}(a_{t}|s_{t}) \,\, \big|\big| \,\, \zeta \mathcal{G}Q_{\theta} + (1 - \zeta) \pi_{\theta}^{-}(a_{t}|s_{t}) \right)\right],
\end{split}
\end{align}
where $\mathcal{G}Q_{\theta}$ takes the maximizer of the action value function.
The reason why we can express the policy $\pi$ and $\mathcal{G}Q_{\theta}$ with the subscript $\theta$ is because the policy is a function of action value function, which has a closed-form solution (see \cite{kozunoCVI} for details):
\begin{align}
\label{eq:boltzmann_greedy}
\mathcal{G}Q_{\theta}(a|s) = \frac{ \pi_{\theta}^{-}(a|s)^{\alpha} \exp \left( \beta Q_{\theta}(s, a) \right )}{\sum_{a'\in\mathcal{A}} \pi_{\theta}^{-}(a'|s)^{\alpha} \exp \left( \beta Q_{\theta}(s, a') \right)},
\end{align}
which by simple induction can be written completely in terms of $Q_{\theta}$ as $\mathcal{G}Q_{\theta}(a|s) \propto \exp \adaBracket{\sum_{j=0}Q_{\theta_{j}}(s,a)}$ \cite{vieillard2020leverage}.
Line 8 performs one step of gradient descent on the the compound loss and line 9 computes the approximate expected advantage function for computing $\zeta$.
There is one subtlety in that the definition of $K$ is unclear in the deep RL context: there is no clear notion of \emph{iteration}.
If we na\"{i}vely define $K$ as the the number of steps or the number of updates, then by definition $C_K$ in Eq. (\ref{eq:cpp_zeta}) could quickly converge to 0 or explode, rendering CPP losing the ability of controlling update.
Hence in our implementation, we increment $K$ by one every time we update the target network (every $C$ steps), which results in a suitable magnitude of $K$.
\section{Experimental Results}\label{sec:experimental}
The proposed CPP algorithm can be applied to a variety of entropy-regularized algorithms. In this section, we utilize conservative value iteration (CVI) as the base algorithm in~\cite{kozunoCVI} for our experiments.
In our implementation,
for the $K+1$-th update, the baseline policy $\bar{\pi}$ in Eq. (\ref{sys_DPPbellman}) is $\pi_{K}$.
For didactic purposes, we first examine all algorithms (specified below) in a safety gridworld and the classic control problem pendulum swing-up.
The tabular gridworld allows for exact computation to inspect the effect of algorithms.
On the other hand, pendulum swing-up leverages linear function approximation detailed in Alg. \ref{alg:CPP}.
We then apply the algorithms on a set of Atari games to demonstrate the effectiveness of our proposed method.
It is worth noting that even state-of-the-art monotonic improving methods failed in complicated Atari games \cite{papini20-balanceSpeedStabilityPG}.
The gridworld, pendulum swing-up and Atari games manifest the growth of complexity and allow for comparison on how the algorithms trade off stability and scalability.
For the gridworld and pendulum experiments, we compare Linear CPP using coefficient Eq. (\ref{eq:linear_cpp}) against \emph{safe policy iteration} (SPI)~\cite{pirotta13} which is the closest to our work.
We employ Exact-SPI (E-SPI) coefficient in Eq. (\ref{eq:espi_zeta}) on the gridworld since
in small state spaces where the quantities $\delta, \Delta A^{\pi_{K+1}}_{\pi_{K}}$ can be accurately estimated.
As a result, SPI performance should upper bound that of CPP since CPP was derived by further loosening on SPI.
For problems with larger state-action spaces, SPI performance may become poor as a result of insufficient samples for estimating those quantities, hence Approximate-SPI (A-SPI) Eq. (\ref{eq:aspi_zeta}) should be used.
However, leveraging A-SPI coefficient often results in vanishingly small $\zeta$ values.
For Atari games, we compare Deep CPP leveraging Eq. (\ref{eq:cpp_zeta}) against on- and off-policy state-of-the-art algorithms, see Section \ref{experiment:atari} for a detailed list. Specifically, we implement deep CPP using off-policy data to show it is capable of leveraging off-policy samples, hence greatly expanding its coverage since on-policy algorithms typically have expensive sample requirement.
\subsection{Gridworld with Danger}\label{apdx:gridworld}
\subsubsection{Experimental Setup}
\iffalse
\begin{figure}[t]
\begin{subfigure}[]{0.475\linewidth}
\includegraphics[width=\textwidth]{gridworld_cumuR.pdf}
\caption{Cumulative reward}
\label{comp_cr}
\end{subfigure}
\begin{subfigure}[]{0.475\linewidth}
\includegraphics[width=\textwidth]{refactored_gridworld_oscillation.pdf}
\caption{Values of policy oscillation}
\label{gridworld_oscillation}
\end{subfigure}
\caption{Comparison between SPI, CPP, and CVI on the safety grid world. The black line shows the mean SPI cumulative reward, the blue line CPP, and the red line CVI in (\ref{comp_cr}), with the shaded area indicating $\pm 1$ standard deviation. (\ref{gridworld_oscillation}) compares the respective policy oscillation value defined in Eq. (\ref{oscillation_measure}).}
\label{gridworld-rci}
\end{figure}
\fi
The agent in the $5 \times 5$ grid world starts from a fixed position at the upper left corner and can move to any of its neighboring states with success probability $p$ or to a random different direction with probability $1-p$.
Its objective is to travel to a fixed destination located at the lower right corner and receives a $+1$ reward upon arrival.
Stepping into two danger grids located at the center of the gridworld incurs a cost of $-1$. Every step costs $-0.1$.
We maintain tables for value functions to inspect the case when there is no approximation error.
Parameters are tuned to yield empirically best performance. For testing the \emph{sample efficiency}, every iteration terminates after 20 steps or upon reaching the goal, and only 30 iterations are allowed for training. For statistical significance, the results are averaged over 100 independent trials.
\subsubsection{Results}
Figure (\ref{comp_cr}) shows the performance of SPI, CPP, and CVI, respectively.
Recall that SPI used the \emph{exact} coefficient Eq. (\ref{eq:espi_zeta}).
The black, blue, and red lines indicate their respective cumulative reward ($y$-axis) along the number of iterations ($x$-axis). The shaded area shows $\pm 1$ standard deviation. CVI learned policies that visited danger regions more often and result in delayed convergence compared to CPP.
Figure (\ref{gridworld_oscillation}) compares the average policy oscillation defined in Eq. (\ref{oscillation_measure}).
\begin{figure}[t]
\begin{minipage}{.5\linewidth}
\centering
\subfloat[]{\label{comp_cr}\includegraphics[width=\linewidth]{gridworld_cumuR.pdf}}
\end{minipage}%
\begin{minipage}{.5\linewidth}
\centering
\subfloat[]{\label{gridworld_oscillation}\includegraphics[width=\linewidth]{refactored_gridworld_oscillation.pdf}}
\end{minipage}
\caption{Comparison between SPI, CPP, and CVI on the safety grid world. The black line shows the mean SPI cumulative reward, the blue line CPP, and the red line CVI in Figure (\ref{comp_cr}), with the shaded area indicating $\pm 1$ standard deviation.
Figure (\ref{gridworld_oscillation}) compares the respective policy oscillation value defined in Eq. (\ref{oscillation_measure}).
}
\label{gridworld_rci}
\end{figure}
The slightly worse oscillation value of CPP than SPI with $\zeta_{\textsc{E-SPI}}$ is expected as CPP exploited a lower bound that is looser than that of SPI.
However, as will be shown in the following examples when both linear and nonlinear function approximation are adopted, SPI failed to learn meaningful behaviors due to the inability to accurately estimate the complicated lower bound.
\subsection{Pendulum Swing Up}\label{experiment:pendulum}
Since the state space is continuous in the pendulum swing up, E-SPI can no longer expect to accurately estimate $\delta\Delta A^{\pi_{K+1}}_{\pi_{K}}$, so we employ A-SPI in Eq. (\ref{eq:aspi_zeta}) and compare both E-SPI and A-SPI against Linear CPP Eq. (\ref{eq:linear_cpp}).
\subsubsection{Experimental Setup}\label{sec:pendulum}
A pendulum of length $1.5$ meters has a ball of mass $1$kg at its end starting from the fixed initial state $[0, -\pi]$. The pendulum attempts to reach the goal $[0, \pi]$ and stay there for as long as possible. The state space is two-dimensional $s=[\theta, \dot{\theta} ]$, where $\theta$ denotes the vertical angle and $\dot{\theta}$ the angular velocity. Action is one-dimensional torque $[-2, 0, 2]$ applied to the pendulum. The reward is the negative addition of two quadratic functions quadratic in angle and angular velocity, respectively:
\begin{align*}
R = - \frac{1}{z}(a\theta^{2} - b\dot{\theta}^{2}),
\end{align*}
where $\frac{1}{z}$ normalizes the rewards and a large $b$ penalizes high angular velocity. We set $z = 10, a=1, b=0.01$.
To demonstrate that the proposed algorithm can ensure monotonic improvement even with a small number of samples, we allow 80 iterations of learning; each iteration comprises 500 steps. For statistical evidence, all figures show results averaged over 100 independent experiments.
\iffalse
\begin{figure}[tbp]
\begin{subfigure}[]{0.475\linewidth}
\centering
\includegraphics[width=\linewidth]{refactored_pendulum_AE_Oscillation.pdf}
\caption{Values of policy oscillation}
\label{pendulum_oscillation}
\end{subfigure}%
\begin{subfigure}[]{0.475\linewidth}
\centering
\includegraphics[width=\linewidth]{refactored_zeta_comparison.pdf}
\caption{Values of $\zeta$}
\label{pendulum_zeta}
\end{subfigure}\\[1ex]
\hfill
\begin{subfigure}[]{0.475\linewidth}
\centering
\includegraphics[width=\linewidth]{pendulum_reward_comare_expY.pdf}
\caption{xssx}
\label{pendulum_reward}
\end{subfigure}
\caption{Comparison of SPI, CPP, and CVI on the pendulum swing up task.
(a) Illustrates the policy oscillation value defined in Eq. (\ref{oscillation_measure}).
(b) Shows the $\zeta$ values.}
\label{pendulum_results}
\end{figure}
\fi
\begin{figure}
\begin{minipage}{.5\linewidth}
\centering
\subfloat[]{\label{pendulum_oscillation}\includegraphics[width=\linewidth]{refactored_pendulum_AE_Oscillation.pdf}}
\end{minipage}%
\begin{minipage}{.55\linewidth}
\centering
\subfloat[]{\label{pendulum_reward}\includegraphics[width=\linewidth]{pendulum_reward_comare_expY.pdf}}
\end{minipage}\par\medskip
\centering
\begin{minipage}{.55\linewidth}
\centering
\subfloat[]{\label{pendulum_zeta}\includegraphics[width=\linewidth]{refactored_zeta_comparison.pdf}}
\end{minipage}%
\caption{Comparison of SPI, CPP, and CVI on the pendulum swing up task.
Figure (\ref{pendulum_oscillation}) illustrates the policy oscillation value defined in Eq. (\ref{oscillation_measure}).
Figure (\ref{pendulum_reward}) shows the cumulative reward with $\pm 1$ standard deviation.
Figure (\ref{pendulum_zeta}) shows the $\zeta$ values.
}
\label{pendulum_results}
\end{figure}
\begin{figure}[h]
\begin{subfigure}[t]{.99\linewidth}
\centering
\includegraphics[width=\linewidth]{surfProbability_cpp.pdf}
\caption{CPP interpolated policy of swinging right $\tilde{\pi}(a_{right}|s_{t})$.}
\label{fig:cpp_prob}
\end{subfigure}\\
\vfill
\begin{subfigure}[t]{.99\linewidth}
\centering
\includegraphics[width=\linewidth]{surfProbability_espi_jet.pdf}
\caption{E-SPI interpolated policy of swinging right $\tilde{\pi}(a_{right}|s_{t})$.}
\label{fig:espi_prob}
\end{subfigure}
\caption{CPP and E-SPI interpolated policies of pendulum swinging right $\tilde{\pi}(a_{right}|s_{t})$ ($z$-axis) for timesteps $t=1,\dots,500$ ($x$-axis) from the first to last iteration ($y$-axis).
E-SPI interpolated policy performed might much more aggressive than the CPP policy caused by the large $\zeta$ values shown in Figure (\ref{pendulum_zeta}).
}
\label{pendulum_probability_change}
\end{figure}
\begin{figure*}[t]
\includegraphics[width=0.95\textwidth]{CPP_nns_comparison_6algs.png}
\caption{Comparison on Atari games averaged over 3 random seeds.
CPP, MoDQN, MDQN and CVI are implemented as variants of DQN and hence are off-policy.
PPO and A2C are on-policy.
Correspondence between algorithms and colors is shown in the lower right corner.
Overall, CPP achieved the best balance between final scores, learning speed and oscillation values.
}
\label{atari}
\end{figure*}
\subsubsection{Results}
We compare CPP with CVI and both E-SPI and A-SPI in Figure \ref{pendulum_results}.
In this simple setup, all algorithms showed similar trend.
But CPP managed to converge to the optimal solution in all seeds, as can be seen from the variance plot.
On the other hand, both SPI versions exhibited lower mean scores and large variance, which indicate that for many seeds they failed to learn the optimal policy.
In Figure (\ref{pendulum_oscillation}), both E-SPI and CVI exhibited wild oscillations, resulting in large average oscillaton values, in which the oscillation criterion is defined as:
\begin{align}
\begin{split}
&\forall K, \text{ s.t. } R_{K+1} - R_{K} < 0, \\
& ||\mathcal{O}J||_{\infty} = \max_{K} |R_{K+1} - R_{K}|, \\
&||\mathcal{O}J||_{2} = \sqrt{\big(\sum_{K} (R_{K+1} - R_{K})^{2}\big)},
\end{split}
\label{oscillation_measure}
\end{align}
where $R_{K+1}$ refers to the cumulative reward at the $K+1$-th iteration. It is worth noting that the difference $R_{K+1} - R_{K}$ is obtained by $\tilde{\pi}_{K+1}, \tilde{\pi}_{K}$, which is the lower bound of that by $\tilde{\pi}_{K+1}, {\pi}_{K}$. Intuitively, $|| \mathcal{O}J ||_{\infty}$ and $|| \mathcal{O}J ||_{2}$ measure \emph{maximum} and \emph{average} oscillation in cumulative reward. The stars between CPP and CVI represent statistical significance at level $p=0.05$.
The reason for SPI's drastic behavior can be observed in Figure (\ref{pendulum_zeta}) (truncated to 30 iterations for better view); in E-SPI, insufficient samples led to very large $\zeta$. The aggressive choice of $\zeta$ led to a large oscillation value. On the other hand, A-SPI went to the other extreme of producing vanishingly small $\zeta$ due to the loose choice of $\zeta$ for ensuring improvement of $\Delta J^{\pi'}_{\pi, d^{\pi'}} \geq \frac{(1-\gamma)^{3} (A^{\tilde{\pi}}_{\pi})^{2}}{8\gamma}$, as can be seen from the almost horizontal lines in the same figure; A-SPI had average value $\Delta J^{\tilde{\pi}_{K+1}}_{\pi_{K},d^{\tilde{\pi}_{K+1}}} = 2.39\times 10^{-9}$ and $\zeta = 1.69\times 10^{-6}$.
CPP converged with much lower oscillation thanks to the smooth growth of the $\zeta$ values; CPP was cautious in the beginning ($\zeta \approx 0$) and gradually became confident in the updates when it was close to the optimal policy ($\zeta \approx 1$).
However, it might happen that $\zeta$ values are large but probability changes are actually small and vice versa.
To certify CPP did not produce such pathological mixture policy and indeed cautiously learned, we plot in Figure \ref{pendulum_probability_change} the interpolated policies of CPP and E-SPI yielding action probability of the pendulum swinging right $\tilde{\pi}(a_{right}|s_{t})$.
The probability change is plotted in $z$-axis, timesteps $t = 1,\dots, 500$ of all iterations are drawn on $x,y$ axes.
For both cases, $\tilde{\pi}(a_{right}|s) \approx 0.33$ which is uniform at the beginning of learning.
However, E-SPI policy $\tilde{\pi}(a_{right}|s)$ gradually peaked from around 10th iteration, which led to very aggressive behavior policy.
Such aggressive behavior was consistent with the overly large $\zeta$ values shown in Figure (\ref{pendulum_zeta}).
On the other hand, CPP policy $\tilde{\pi}(a_{right}|s)$ was more tempered and showed a gradual change conforming to its $\zeta$ change.
The probability plots together with $\zeta$ values in Figure (\ref{pendulum_zeta}) indicate that the CPP interpolation was indeed effective in producing non-trivial diverse mixture policies.
{\color{black}
\subsection{Atari Games}\label{experiment:atari}
\subsubsection{Experimental Setup}\label{sec:atari_setup}
We applied the algorithms to a set of challenging Atari games: \texttt{MsPacmann}, \texttt{SpaceInvaders}, \texttt{Beamrider}, \texttt{Assault} and \texttt{Sea\-quest} \cite{bellemare13-arcade-jair} using the adaptive $\zeta$ introduced in Eq. (\ref{eq:cpp_zeta}).
We compare deep CPP with both on- and off-policy algorithms to demonstrate that CPP is capable of achieving superior balance between learning speed and oscillation values.
For on-policy algorithms, we include the celebrated proximal policy gradient (PPO) \cite{schulman2017proximal}, a representative trust-region method.
We also compare with Advantage Actor-Critic (A2C) \cite{mnih2016asynchronous} which is a standard on-policy actor-critic algorithm: our intention is to confirm the expensive sample requirement of on-policy algorithms typically render them underperformant when the number of timesteps is not sufficiently large.
For the off-policy algorithms, we decide to include several state-of-the-art DQN variants: Munchausen DQN (MDQN) \cite{vieillard2020munchausen} features the implicit KL regularization brought by the Munchausen log-policy term: it was shown that MDQN was the only non-distributional RL method outperforming distributional ones.
We also include another state-of-the-art variant: Momentum DQN (MoDQN) \cite{Vieillard2020Momentum} that avoids estimating the intractable base policy in KL-regularized RL by constructing momentum. MoDQN has been shown to obtain superior performance on a wide range of Atari games.
Finally, as an ablation study, we are interested in the case $\zeta = 1$, which translates to conservative value iteration (CVI) \cite{kozunoCVI} based on the framework Eq. (\ref{sys_DPPbellman}).
CVI has not seen deep RL implementation to the best of our knowledge. Hence a performant deep CVI implementation is of independent interest.
All algorithms are implemented using library Stable Baselines 3 \cite{stable-baselines3}, and tuned using the library Optuna \cite{optuna}. Further, all on- and off-policy algorithms share the same network architectures for their group (i.e. MDQN and CPP share the same architecture and PPO and A2C share another same architecture) for fair comparison. The experiments are evaluated over 3 random seeds. Details are provided in \ref{apdx:atari}.
We expect that on simple tasks PPO and A2C might be stable due to the on-policy nature, but too slow to learn meaningful behaviors.
However, PPO is known to take drastic updates and heavily needs code-level optimization to correct the drasticity \cite{engstrom2020implementation}.
On the other hand, for complicated tasks, too drastic policy updates might be corrupted by noises and errors, leading to divergent learning.
By contrast, CPP should balance between learning speed and oscillation value, leading to gradual but smooth improvement.
\begin{table*}[t!]
\centering
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
Criterion & Algorithm &\texttt{Assault} & \texttt{Seaquest} & \texttt{SpaceInvaders} & \texttt{MsPacman} & \texttt{BeamRider}\\
\hline
\multirow{6}{5em}{\,\, $||\mathcal{O}J||_{2}$}& CPP& 151 & 622 & 89 & 249 & 460 \\
&MDQN& 129 & 2149 & 77 & 202 & 220 \\
&MoDQN&162& 813 & 91 & 288 & 718 \\
&CVI& 77 & 449 & 83 & 292 & 220 \\
&PPO& 74 & 68 & 72 & 280 & 74 \\
&A2C& 218 & 98 & 48 & 395 & 87\\
\hline
\multirow{6}{5em}{\,\, $||\mathcal{O}J||_{\infty}$} &CPP& 59 & 561 & 42 & 26 & 292\\
&MDQN& 51 & 2141 & 16 & 52 & 149 \\
&MoDQN&111& 716 & 36 & 124 & 665 \\
&CVI& 6 & 361 & 51 & 98 & 105 \\
&PPO& 16 & 9 & 7 & 36 & 33 \\
&A2C& 52 & 15 & 8 & 249 & 34\\
\hline
\end{tabular}
\caption{The oscillation values of algorithms listed in Sec. \ref{sec:atari_setup} measured in $||\mathcal{O}J||_{2}$ and $||\mathcal{O}J||_{\infty}$ defined by Eq. (\ref{oscillation_measure}).
CPP achieved the best balance between final score, learning speed and oscillation values.
Note that CPP was implemented to leverage off-policy data.
Algorithms of small oscillation values, such as PPO, failed to compete with CPP in terms of final scores and convergence speed.
}
\label{tab:oscillation_comparison}
\end{table*}
\subsubsection{Results}
\textbf{Final Scores. }
As is visible from Figure \ref{atari}, Deep CPP achieved either the first or second place in terms of final scores on all environments, with the only competitive algorithm being MDQN which is the state-of-the-art DQN variant, and occasionally CVI which is the case of $\zeta \!=\! 1$.
However, MDQN suffered from numerical stability on the environment \texttt{Seaquest} as can be seen from the flat line at the end of learning.
CVI performed well on the simple environment \texttt{MsPacman}, which can be interpreted as that learning on simple environments is not likely to oscillate, and hence the policy regularization imposed by $\zeta$ is not really necessary, setting $\zeta \!=\! 1$ is the best approach for obtaining high return.
However, in general it is better to have adjustable update: on the environment \texttt{BeamRider} the benefit of adjusting the degree of updates was significant: CPP learning curve quickly rised at the beginning of learning, showing a significant large gap with all other algorithms.
Further, while CVI occasionally performed well, it suffered also from numerical stability: on the environment \texttt{Assault}, CVI and MoDQN achieved around 1000 final scores but ran into numerical issues as visible from the end of learning.
This problem has been pointed out in \cite{Vieillard2020Momentum}.
On the other hand, on all environments on-policy algorithms A2C and PPO failed to learn meaningful behaviors.
On some environment such as \text{Assault} A2C showed divergent learning behavior at around $4 \times 10^{6}$ and PPO did not learn meaningful behavior until the end.
This observation suggests that the sample complexity of on-policy algorithms is high and generally not favorable compared to off-policy algorithms.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{NNs_CPI_SPI_ablation.png}
\caption{Learning curves of DCPI on \texttt{Seaquest} with four coefficient designs.
All designs achieved the final score of 50, while CPP achieved around 3000 in Figure \ref{atari}.
}
\label{fig:ablation}
\end{figure}
\textbf{Oscillation. }
The averaged oscillation values of all algorithms are listed in Table \ref{tab:oscillation_comparison}.
While MDQN showed competitive performance against CPP, it exhibited wild oscillation on the difficult environment \texttt{Seaquest} \cite{azar18-noisynet} and finally ran into numerical issue as indicated by the flatline near the end.
The oscillation value reached to around 2100. Since MDQN is the state-of-the-art regularized value iteration algorithm featuring implicit regularization, this result illustrates that on difficult environments, only reward regularization might not be sufficient to maintain stable learning.
On the other hand, CPP achieved a balance between stable learning and small oscillation, with oscillation value around $600$, attaining final score slightly lower than MDQN and higher than MoDQN and CVI.
The oscillation values and final scores should be combined together for evaluating how algorithms perform.
CVI, MoDQN sometimes showed similar performance to CPP, but in general the final scores are lower than CPP, with higher oscillation values.
On the other hand, MDQN showed competitive final scores, but sometimes it exhibited wild oscillation and ran into numerical issues, implying that on some environments where low oscillation is desired, CPP might be more desirable than MDQN.
On-policy algorithms even showed low oscillation values, but their final scores are considered unacceptable.
\subsection{Ablation Study}\label{sec:ablation}
We are interested in comparing the performance of DCPI with CPP to see the role played by $\zeta_{\textsc{DCPP}}$.
It is also enlightening by inspecting the result of fixing $\zeta$ as a constant value.
In this subsection, we perform ablation study by comparing the the following four designs:
\begin{itemize}
\item DCPI with fixed $\zeta \!=\! 0.01$: this is to inspect the result of constantly low interpolation coefficient.
\item DCPI with fixed $\zeta \!=\! 0.5$: this is to examine the performance of equally weighting all policies.
\item CPI: this uses the coefficient from Eq. (\ref{eq:cpi_zeta}).
\item SPI: this uses the DCPI architecture, but we compute $\zeta_{\textsc{A-SPI}}$ by using Eq. (\ref{eq:aspi_zeta}).
\end{itemize}
We examine those four designs on the challenging environment \texttt{Seaquest}.
Other experimental settings are held same with Sec. \ref{experiment:atari}.
As can be seen from Figure \ref{fig:ablation}, all designs showed a similar trend of converging to some sub-optimal policy.
The final scores were around 50, which was significantly lower than CPP in Figure \ref{atari}.
This result is not surprising since for $\zeta=0.01$, almost no update was performed.
For $\zeta=0.5$, the algorithm weights contribution of all policies equally without caring about their quality.
On this environment, $\zeta_{\text{A-SPI}}$ is vanishingly small similar with that shown in Figure (\ref{pendulum_zeta}).
Lastly, for CPI the number of learning steps is not sufficient for learning meaningful behavior.
\iffalse
As is evident from Table \ref{tab:oscillation_comparison}, the oscillation and variance of PPO on those two environments were possibly due to compounding errors that appear in learning with deep networks \cite{fu2019-diagnosis,Fujimoto2018-errorAC}, the relaxed trust region of PPO was optimistic facing those errors.
As expected, DCPP and DSPI did not differ much as the agents quickly learned meaningful behaviors with a small number of samples.
The off-policiness for both algorithms mentioned in Sec. \ref{sec:CPP_FA} was under control, but from \texttt{MsPacmann} it can be seen that, under the entropy-regularization guidance, DCPP achieved slightly faster learning, while in both two environment PPO was slower.
\texttt{Beamrider}, on the other hand, stands in the middle of two extremes.
The learning curves showed that all three algorithms learned meaningful behaviors after collecting enough experiences.
However, DSPI and PPO learned much slower.
Their slowness comes from different reasons: PPO learned slowly since it needed to average over sufficiently many samples to extract meaningful gradient direction.
On the other hand, the slowness of deep SPI was due to the gradually growing off-policiness of the samples used.
The results on the \texttt{Assault} environment demonstrated an example that taking drastic update steps might result in better performance.
Indeed, the conservativeness of Deep SPI lead to a completely flat line in return, while Deep CPP remained stable at the score of around 2000.
PPO achieved higher return at the cost of drastic oscillation: as can be seen from Table \ref{tab:oscillation_comparison}, the maximum oscillation value of PPO reached 12825, more than ten times larger than that of Deep CPP.
For safety-critical applications, PPO's drastic tradeoff in favor of learning speed is unacceptable.
It is most interesting to inspect the \texttt{Seaquest} environment, where both PPO and DSPI failed to learn any meaningful behaviors; very conservative estimation of $\zeta$ values hindered the learning, leading to the almost flat line.
This was because, in difficult environments, the agent usually had to wait until substantial experiences had been collected before it could learn meaningful behaviors. Unbounded off-policiness for both the value and stationary distribution estimates suggested in Sec. \ref{sec:CPP_FA} resulted in large error and completely derailed learning.
On the other extreme, PPO's relaxed trust region often optimistically estimate the gradient direction as indicated by \cite{engstrom2020implementation}.
This optimistic estimate is often corrupted by noises and errors and hence by the trust region trick alone does not result in a informative gradient direction.
DCPP learned meaningful behaviors but had wild variance. This might suggest Seaquest is an especially difficult environment and requires elaborate policies that are simultaneously safe and progressive. Indeed, as pointed out by~\cite{azar18-noisynet}, \texttt{Seaquest} is known to be challenging for \emph{typical value-based methods} such as DQN variants.
This is supported by comparing our result to \cite{azar18-noisynet,Vieillard-2020DCPI}; the reported standard DQN yielded a score of around 2000 and the empirically tuned DCPI attained a score of around 5000. Hence, it is inspiring that DCPP managed to achieve a mean score of around $7000$, though with large variance. The margin of DCPP over DCPI \cite{Vieillard-2020DCPI}, PPO and DSPI suggests that DCPP can not only stabilize high performance in complicated tasks, but also perform well in challenging tasks where cautiousness and progressive learning are both required.
}
\fi
\section{Discussion}\label{sec:discussion}
Leveraging the entropy-regularized formulation for monotonic improvement has been recently analyzed in the \emph{policy gradient} literature for tabular MDP \cite{mei20b-globalConvergence,Agarwal20-theoryPolicyGradient,cen2020fastGlobalConvergence}.
In the tabular MDP setting with exact computation, monotonic improvement and fast convergence can be proved.
However, realistic applications are beyond the scope for their analysis and no scalable implementation has been provided.
On the other hand, value-based methods have readily applicable error propagation analysis \cite{Munos2005,scherrer15-AMPI,Lazaric2016-classificationPolicyIterationAnalysis} for the function approximation setting, but they seldom focus on monotonic improvement guarantees such as $ J^{K+1}-J^{K} \geq 0 $.
In this paper, we started from the value-based perspective to derive monotonic improvement formulation and provide scalable implementation suitable for learning with deep networks.
We verified that CPP can approximately ensure monotonic improvement in low-dimensional problems and achieved superior tradeoff between learning speed and stabilized learning in high-dimensional Atari games.
This tradeoff is best seen from the value of $\zeta$:
in the beginning of learning the agent prefers to be cautious, resulting in small $\zeta$ values as can be seen from Figure (\ref{pendulum_zeta}).
In relatively simple scenarios where exact computation or linear function approximation suffices, $\zeta < 1$ might slow down convergence rate in favor of more stable learning.
On the other hand, in challenging problems this cautiousness might in turn accelerate learning in the later stages, as can be seen from the CVI curves in Figure \ref{atari} that correspond to drastically setting $\zeta=1$: except in the environment \texttt{MsPacman}, in all other environments CVI performed worse than CPP.
This might be due to that learning with deep networks involve heavy approximation error and noises.
Smoothly changing of the interpolation coefficient becomes necessary under these errors and noises, which is a core factor of CPP.
We found that CPP was especially useful in challenging tasks where both learning progress and cautiousness are required.
We believe CPP bridges the gap between theory and practice that long exists in the monotonic improvement RL literature: previous algorithms have only been tested on simple environments yet failed to deliver guaranteed stability.
CPP made a step towards practical monotonic improving RL by leveraging entropy-regularized RL.
However, there is still room for improvement.
Since the entropy-regularized policies are Boltzmann, generally the policy interpolation step does not yield another Boltzmann by adding two Boltzmann policies.
{\color{black}
Hence an information projection step should be performed to project the resultant policy back to the Boltzmann class to retrieve Boltzmann properties.
}
While this projection step can be made perfect in the ideal case, in practice there is an unavoidable projection error.
This error if well controlled, could be damaging and significantly degrade the performance. How to remove this error is an interesting future direction.
Another sublety of CPP is on the use of Lemma \ref{thm:KL}.
Lemma \ref{thm:KL} states that the maximum KL divergence of a sequence of CVI policies is bounded.
However, since we performed interpolation on top of CVI policies, it is hence not clear whether this guarantee continues to hold for the interpolated policy, which renders our use of Lemma \ref{thm:KL} heurisitic.
As demonstrated by the experimental results, we found such heuristic worked well for the problems studied.
We leave the theoretical justification of Lemma \ref{thm:KL} on interpolated policies to future work.
We believe the application of CPP, i.e., the combination of policy interpolation and entropy-regularization to other state-of-the-art methods is feasible at least within the value iteration scenario.
Indeed, CPP performs two regularization: one in the stochastic policy space and the other in the reward function.
There are many algorithms share the reward function regularization idea with CPP, which implies the possibility of adding another layer of regularization on top of it.
On the other hand, distributional RL methods may also benefit from the interpolation since they output distribution of rewards which renders interpolation straightforward. We leave them to future investigation.
Another interesting future direction is to extend CPP to the actor-critic setting that can handle continuous action spaces.
Though both CPI-based and entropy-regularized concepts have been respectively applied in actor-critic algorithms, there has not seen published results showing featuring this combination.
We expect that the combination could greatly alleviate the policy oscillation phenomenon in complicated continuous action control domain such as Mujoco environments.
\section{Conclusion}\label{sec:conclusion}
In this paper we proposed a novel RL algorithm: cautious policy programming that leveraged a novel entropy regularization aware lower bound for monotonic policy improvement.
The key ingredients of the CPP is the seminal policy interpolation and entropy-regularized policies.
Based on this combination, we proposed a genre of novel RL algorithms that can effectively trade off learning speed and stability, especially inhibiting the policy oscillation problem that arises frequently in RL applications.
We demonstrated the effectiveness of CPP against existing state-of-the-art algorithms on simple to challenging environments, in which CPP achieved performance consistent with the theory.
\section{Acknowledgement}
This research is funded by JSPS KAKENHI Grant Number 21H03522 and 21J15633.
| {'timestamp': '2022-01-19T02:18:05', 'yymm': '2107', 'arxiv_id': '2107.05798', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05798'} | arxiv |
\section{Introduction}
\label{intro}
Despite the promise of artificially intelligent agents ~\cite{lecun2015deep,schmidhuber2015deep}, they are known to suffer from catastrophic forgetting when learning over non-stationary data distributions ~\cite{McCloskey1989CatastrophicII,Goodfellow2013AnEI}.
Continual learning ~\cite{ring1998child,lopez2017gradient,nguyen2017variational}, also known as life-long learning, was introduced to deal with catastrophic forgetting. In this framework, agent continually learns to solve a sequence of non-stationary tasks by accommodating new information, while remaining able to complete previously experienced tasks with minimal performance degradation.
The fundamental challenge in continual learning is catastrophic forgetting, which is caused by the interference among tasks from heterogeneous data distributions~\cite{Lange2019ContinualLA}.
Task interference is almost unavoidable when model parameters, like the feature extractor and the classifier, are shared by all tasks. At the same time, it is practically infeasible to keep a separate set of model parameters for each individual task when learning with an arbitrarily long sequence of tasks \cite{hadsell2020embracing}. Moreover, knowledge tends to be shared and transferred across tasks more in the lower layers than higher layers of deep neural networks \cite{ramasesh2020anatomy}. This has motivated the development of non-parametric classifiers that automatically avoid task interference without sharing any parameters across tasks. Kernel methods \cite{smola1998learning} provide a well-suited tool for this due to their non-parametric nature, and have proven to be a powerful technique in machine learning ~\cite{cristianini2000introduction,smola2004tutorial,rahimi2007random,sinha2016learning}.
Kernels have been shown to be effective for incremental and multi-task learning with support vector machines \cite{diehl2003svm, pentina2015multi}.
Recently, they have also been demonstrated to be strong learners in tandem with deep neural networks \cite{wilson2016deep,wilson2016stochastic,tossou2019adaptive}, especially when learning from limited data \cite{zhen2020learning,patacchiola2020bayesian}.
Inspired by the success of kernels in machine learning, we introduce task-specific classifiers based on kernels by decoupling the feature extractor from the classifier for continual learning.
\begin{figure*}[t!]
\centering
\includegraphics[width=1\textwidth]{figs/vrf.pdf}
\caption{\textbf{Overview of kernel continual learning} with variational random features. For each task $t$, we use the coreset $\mathcal{C}_t$ to infer the random Fourier basis, which generates kernel matrix $\mathcal{K}_t$. The classifier for this task is constructed based on kernel ridge regression using $\mathcal{K}_t$. $h_{\theta}$ denotes the feature extraction network, parameterized by $\theta$, which is shared and updated when training on the task sequence. $f_{\phi}$ is the inference network, parameterized with $\phi$ for random Fourier bases, which is also shared across tasks and updated throughout learning. Memory $\mathcal{M}$ stores the coreset from each task and is used for inference only. $h_{\theta}$ and $f_{\phi}$ are jointly learned end-to-end.
}
\label{fig:demo}
\end{figure*}
In this paper, we propose \textit{kernel continual learning} to deal with catastrophic forgetting in continual learning. Specifically, we propose to learn non-parametric classifiers based on kernel ridge regression. To do so, we deploy an episodic memory unit to store a subset of samples from the training data for each task, which we refer to as `the coreset', and learn the classifier based on the kernel ridge regression. Kernels provide several benefits. First, the direct interference of classifiers is naturally avoided as kernels are established in a non-parametric way for each task and no classifier parameters are shared across tasks. Moreover, in contrast to existing memory replay methods, e.g.,~\cite{kirkpatrick2017overcoming,AGEM}, our kernel continual learning does not need to replay data from previous tasks when training the current task, which avoids task interference while enabling more efficient optimization.
In order to achieve adaptive kernels for each task, we further introduce random Fourier features to learn kernels in a data-driven manner. Specifically, we formulate kernel continual learning with random Fourier features as a variational inference problem, where the random Fourier basis is treated as a latent variable. The variational inference formulation naturally induces a regularization term that encourages the model to learn adaptive kernels for each task from the coreset only. As a direct result, we are able to achieve more compact memory, which reduces the storage overhead.
We perform experiments on four benchmark datasets: Rotated MNIST, Permuted MNIST, Split CIFAR100 and miniImageNet. The results demonstrate the effectiveness and promise of kernel continual learning, which delivers state-of-the-art performance on all benchmarks.
\section{Related Works} \label{related}
A fundamental problem in continual learning is catastrophic forgetting. Existing methods differ in the way they deal with this. We will briefly review them in terms of regularization, dynamic architectures and experience replay. For a more extensive overview we refer readers to the reviews by \citet{Parisi2018ContinualLL} and \citet{Lange2019ContinualLA}.
Regularization methods~\cite{kirkpatrick2017overcoming, MAS, lee2017overcoming, zenke2017continual, kolouri2019attention} determine the importance of each model's parameter for each task, which prevents the parameters from being updated for new tasks. \citet{kirkpatrick2017overcoming}, for example, specify the performance of each weight with a Fisher information matrix. Alternatively, \citet{MAS}, determine parameter importance by the gradient magnitude. Naturally, these methods can also be explored from the perspective of Bayesian optimization ~\cite{nguyen2017variational, titsias2019functional, schwarz2018progress, ebrahimi2019uncertainty, ritter2018online}. For instance, \citet{nguyen2017variational} introduce a regularization technique to protect their model against forgetting. Bayesian or not, all these methods address catastrophic forgetting by adding a regularization term to the main loss function. As shown by \citet{Lange2019ContinualLA}, the penalty terms proposed in such algorithms are unable to prevent drifting in the loss landscape of previous tasks. While alleviating forgetting, the penalty term also unavoidably prevents the plasticity to absorb new information from future tasks learned over a long timescale \cite{hadsell2020embracing}.
Dynamic architectures~\cite{rusu2016progressive, yoon2018lifelong, Jerfel2018ReconcilingMA, li2019learn} allocate a subset of the model parameters for each task. This is achieved by a gating mechanism~\cite{wortsman2020supermasks, Gating}, or by incrementally adding new parameters to the model \cite{rusu2016progressive}. Incremental learning and pruning is another possibility~\cite{PackNet}. Given an over-parameterized model with the ability to learn quite a few tasks, \citet{PackNet} achieve model expansion by pruning the parameters not contributing to the performance of the current task, while keeping them available for future tasks. These methods are preferred when there is no memory usage constraint and the final model performance is prioritized. They offer an effective way to avoid task interference and catastrophic forgetting, but suffer from potentially unbounded model expansion and prevent positive knowledge transfer across tasks.
Experience replay methods~\cite{Lange2019ContinualLA} assume it is possible to access data from previous tasks by having a fixed-size memory or a generative model able to produce samples from old tasks~\cite{lopez2017gradient, riemer2018learning, rios2018closed, shin2017continual, zhang2019prototype}. \citet{Rebuffi2016iCaRLIC} introduce a model augmented with fixed-size memory, which accumulates samples in the proximity of each class center. \citet{Chaudhry2019OnTE} propose another memory-based model by exploiting a reservoir sampling strategy in the raw input data selection phase. Rather than storing the original samples, \citet{AGEM} accumulate the parameter gradients during task learning. \citet{shin2017continual} incorporate a generative model into a continual learning model to alleviate catastrophic forgetting by producing samples from previous tasks and retraining the model using data from both previous tasks and the current one.
These papers assume that an extra neural network, such as a generative model, or a memory unit is available. Otherwise, these methods cannot be exploited.
Replay-based methods benefit from a memory unit to retrain their model over previous tasks. In contrast, our proposed method only uses memory to store data as a task identifier proxy at \textit{inference time} without the need of replay for training, which mitigates the optimization cost.
\section{Kernel Continual Learning}
\subsection{Problem Statement}
In the traditional supervised learning setting, a model or agent $f$ is learned to map input data from the input space to its target in the corresponding output space: $\mathcal{X} \mapsto \mathcal{Y}$, where samples $X \in \mathcal{X}$ are assumed to be drawn from the same data distribution. In the case of the image classification problem, $X$ are the images and $Y$ are associated class labels. Instead of solving a single task, continual learning aims to solve a sequence of different tasks, $T_1, T_2, \cdot \cdot \cdot T_n$, from non-stationary data distributions, where $n$ stands for the number of tasks, and each of which is an individual classification problem. A continual learner is required to continually solve each $t$ of those tasks once being trained on its labeled data, while remaining able to solve previous tasks with no or limited access to their data.
Generally, a continual learning model based on a neural network is comprised of a feature extractor $h_\theta$ and a classifier $f_c$. The feature extractor is a convolutional architecture found before the last fully connected layer, which is shared across tasks. The classifier is the last fully connected layer. We propose to learn a task-specific, non-parametric classifier based on kernel ridge regression.
We consider learning the model on the current task $t$. Given its training data $\mathcal{D}_t$, we choose uniformly a subset of data between existing classes in current task $t$, which is called the \textit{coreset dataset} \cite{nguyen2017variational} and denoted as: $\mathcal{C}_t{=}{(\mathbf{x}_i, \mathbf{y}_i)}_{i{=}1}^{N_c}$. We construct the classifier $f_c$ based on kernel ridge regression on the coreset. Assume we have the classifier with weight $\mathbf{w}$, and the loss function of kernel ridge regression takes the following form:
\begin{equation}
\mathcal{L}_{\rm{krr}}(\mathbf{w}) = \frac{1}{2}\sum_i(\mathbf{y}_i - \mathbf{w}^\top \psi(\mathbf{x}_i)) + \frac{1}{2}\lambda ||\mathbf{w}||^2,
\end{equation}
where $\lambda$ is the weight decay parameter.
Based on the Representer theorem \cite{scholkopf2001generalized}, we have:
\begin{equation}
\mathbf{w} = f^{\alpha^t}_c(\cdot) = \sum^{N_c}_{i=1} \alpha_i k(\cdot,\psi(\mathbf{x}_i)),
\end{equation}
where $k(\cdot,\cdot)$ is the kernel function. Then $\alpha$ can be calculated in a closed form:
\begin{equation}
\alpha^t = Y(\lambda I + \mathcal{K})^{-1},
\end{equation}
where $\alpha^t {=} [\alpha_1, \cdots, \alpha_i, \cdots, \alpha_{N_C}]$ and $\lambda$ is considered to be a learnable hyperparameter. The $\mathcal{K} \in R^{N_c \times N_c}$ matrix for each task is computed as $k(\mathbf{x}_i, \mathbf{x}_j) {=} \psi(\mathbf{x}_i)\psi(\mathbf{x}_j)^\top$. Here, $\psi(\mathbf{x}_i)$ is the feature map of $\mathbf{x}_i \in \mathcal{C}_t$, which can be obtained from the feature extractor $h_\theta$.
To jointly learn the feature extractor $h_\theta$, we minimize the overal loss function over samples from the remaining set:
\begin{equation}
\sum_{(\mathbf{x}', \mathbf{y}') \in D_t\backslash \mathcal{C}_t}
{\mathcal{L}(f^{\alpha^t}_{c}({\psi(\mathbf{x}')), \mathbf{y}'})}.
\end{equation}
Here, we choose $\mathcal{L}(\cdot)$ to be the cross-entropy loss function and the predicted output $\tilde{\mathbf{y}}'$ is computed by
\begin{equation}
\tilde{\mathbf{y}}' = f^{\alpha^t}_c(\psi(\mathbf{x}')) = \texttt{Softmax}(Y(\lambda I + \mathcal{K})^{-1} \tilde{K}),
\label{eq:prediction}
\end{equation}
where $\tilde{K} {=} \psi(X)\psi(\mathbf{x}')^{\top}$, $\psi(X)$ denotes the feature maps of samples in the coreset, and $\texttt{Softmax}(\cdot)$ is the softmax function applied to the output of the kernel ridge regression.
In principle, we can use any (semi-)positive definite kernel, e.g., a radial basis function (RBF) kernel or a dot product linear kernel to construct the classifier. However, none of those kernels are task specific, potentially suffering from suboptimal performance, especially with limited data. Moreover, we would require a relatively large coreset to obtain informative and discriminative kernels for satisfactory performance. To address this, we further introduce random Fourier features to learn data-driven kernels, which have previously demonstrated success in regular learning tasks \cite{bach2004multiple,sinha2016learning,carratino2018learning,zhen2020learning}. Data-driven kernels using random Fourier features provides an appealing technique to learn strong classifiers with a relatively small memory footprint for continual learning based on episodic memory.
\subsection{Variational Random Features}
One of the key ingredients when finding a mapping function in non-parametric approaches, such as kernel ridge regression, is the kernel function. \citet{rahimi2007random} introduced an algorithm to approximate translation-invariant kernels using explicit feature maps, which is theoretically underpinned by Bochner's theorem~\cite{rudin1962fourier}.
\begin{theorem}[Bochner's Theorem]
\label{theorem1}
\textit{A continuous, real valued, symmetric and shift-invariant function $\mathrm{k}\left(\mathbf{x}, \mathbf{x}^{\prime}\right)=\mathrm{k}(\mathbf{x}-\mathbf{x}^{\prime})$ on $\mathbb{R}^\mathrm{d}$ is a positive definite kernel if and only if it is the Fourier transform $p(w)$ of a positive finite measure such that:}
\begin{equation}
\begin{aligned}
\mathrm{k}\left(\mathbf{x}, \mathbf{x}^{\prime}\right)=& \int_{\mathbb{R}^{d}} e^{i \omega^{\top}\left(\mathbf{x}-\mathbf{x}^{\prime}\right)} d p(\boldsymbol{\omega})=\mathbb{E}_{\omega}\left[\zeta_{\omega}(\mathbf{x}) \zeta_{\omega}\left(\mathbf{x}^{\prime}\right)^{*}\right] \\
& \text { where } \zeta_{w}(\mathbf{x})=e^{i \omega^{\top} \mathbf{x}}.
\end{aligned}
\end{equation}
\end{theorem}
With a sufficient number of samples $\omega$ drawn from $p(\omega)$, we can achieve an unbiased estimation of $\mathrm{k}\left(\mathbf{x}, \mathbf{x}^{\prime}\right)$ by $\zeta_{w}(\mathbf{x})\zeta_{w}(\mathbf{x})^*$ \cite{rahimi2007random}.
Based on Theorem~\ref{theorem1}, we draw $D$ sets of samples: $\{{\omega_i}\}_{i=1}^{D}$ and $\{{b_i}\}_{i=1}^{D}$ from a normal distribution and uniform distribution (with a range of [$0$, $2\pi$]), respectively, and construct the random Fourier features (RFFs) for each data point $\mathbf{x}$ using the formula:
\begin{equation}
\psi(\mathbf{x})=\frac{1}{\sqrt{D}}\left[\cos \left(\boldsymbol{\omega}_{1}^{\top} \mathbf{x}+b_{1}\right), \cdots, \cos \left(\boldsymbol{\omega}_{D}^{\top} \mathbf{x}+b_{D}\right)\right].
\label{eq:rff}
\end{equation}
Having the random Fourier features, we calculate the kernel matrix by $\mathrm{k}\left(\mathbf{x}, \mathbf{x}^{\prime}\right) {=} \psi(\mathbf{x})\psi(\mathbf{x}^\prime)^\top$.
Traditionally the shift-invariant kernel is constructed based on random Fourier features, where the Fourier basis is drawn from a Gaussian distribution transformed from a pre-defined kernel. This results in kernels that are agnostic to the task. In continual learning, however, tasks are provided sequentially from non-stationary data distributions, which makes it suboptimal to share the same kernel function across tasks. To address this problem, we propose to learn task-specific kernels in a data-driven manner. This is even more appealing in continual learning as we would like to learn informative kernels using a coreset of a minimum size. We formulate it as a variational inference problem, where we treat the random basis $\omega$ as a latent variable.
\paragraph{Evidence Lower Bound} From the probabilistic perspective, we would like to maximize the following conditional predictive log-likelihood for the current task $t$:
\begin{equation}
\max _{p} \sum_{(\mathbf{x}, \mathbf{y}) \in \mathcal{D}_t\backslash \mathcal{C}_t} \ln p(\mathbf{y} | \mathbf{x}, \mathcal{D}_t\backslash \mathcal{C}_t),
\label{cll}
\end{equation}
which amounts to making maximally accurate predictions on $\mathbf{x}$ based on $\mathcal{D}_t\backslash \mathcal{C}_t$.
By introducing the random Fourier basis $\omega$ into Eq.~(\ref{cll}), which is treated as a latent variable, we have:
\begin{equation}
\max _{p} \sum_{(\mathbf{x}, \mathbf{y}) \in \mathcal{D}_t\backslash \mathcal{C}_t} \ln \int p(\mathbf{y} |\mathbf{x}, \omega, \mathcal{D}_t\backslash \mathcal{C}_t) p_{\gamma}(\omega |\mathcal{D}_t\backslash \mathcal{C}_t)d\omega.
\label{formula:loglikelihood}
\end{equation}
The intuition is that we can use data to infer the distribution over the latent variable $\omega$ whose prior is conditioned on the data. We combine the data and $\omega$ to generate kernels to classify $\mathbf{x}$ based on kernel ridge regression. We can also simply place an uninformative prior of a standard Gaussian distribution over the latent variable $\omega$, which will be investigated in our experiments.
It is intractable to directly solve for the true posterior $p(\omega|\mathbf{x},\mathbf{y},\mathcal{D}_t\backslash \mathcal{C}_t)$ over $\omega$. We therefore introduce a variational posterior $q_{\phi}(\omega|\mathcal{C}_t)$ conditioned solely on the coreset $\mathcal{C}_t$ because the coreset will be stored as episodic memory for the inference of each corresponding task.
By incorporating the variational posterior into Eq.~(\ref{formula:loglikelihood}) and applying Jensen's inequality, we establish the evidence lower bound (ELBO) as follows:
\begin{equation}
\begin{aligned}
\ln p(\mathbf{y} | \mathbf{x}, \mathcal{D}_t\backslash \mathcal{C}_t) & \geq \mathbb{E}_{q_{\phi}(\boldsymbol{\omega} | \mathcal{C}_t)} \big[\ln p(\mathbf{y} |\mathbf{x}, \boldsymbol{\omega},\mathcal{D}_t\backslash \mathcal{C}_t) \big]\\
&-D_{\mathrm{KL}}\big[q_{\phi}(\boldsymbol{\omega} | \mathcal{C}_t) \| p_{\gamma}(\boldsymbol{\omega}|\mathcal{D}_t\backslash \mathcal{C}_t)\big]\\
&=\mathcal{L}_{\mathrm{ELBO}}.
\label{elbo}
\end{aligned}
\end{equation}
Therefore, maximizing the ELBO amounts to maximizing the conditional log-likelihood in Eq.~(\ref{cll}). The detailed derivation is provided in the supplementary materials.
\paragraph{Empirical Objective Function}
In the continual learning setting, we would like the model to be able to make predictions based solely on the coreset $\mathcal{C}_t$ stored in the memory. That is, the conditional log-likelihood should be conditioned on the coreset only. Based on the ELBO in Eq.~(\ref{elbo}) we establish the following empirical objective function which, is minimized by our overall training procedure:
\begin{equation}
\begin{aligned}
\tilde{\mathcal{L}}_{\mathrm{ELBO}} & = \frac{1}{T} \sum _{t=1} ^ {T}\Big[\sum_{(\mathbf{x}, \mathbf{y}) \in \mathcal{D}_t\backslash \mathcal{C}_t} \frac{1}{L}\sum^L_{\ell=1} \big[\ln p(\mathbf{y} | \mathbf{x}, \boldsymbol{\omega}^{(\ell)},\mathcal{C}_t)\big] \\
&-D_{\mathrm{KL}}\big[q_{\phi}(\boldsymbol{\omega} | \mathcal{C}_t) \| p_{\gamma}(\boldsymbol{\omega} | \mathcal{D}_t\backslash \mathcal{C}_t)\big]\Big],
\end{aligned}
\label{objective}
\end{equation}
where, in the first term, we employ the Monte Carlo method to draw samples from the variational posterior $q(\omega|\mathcal{C}_t)$ to estimate the log-likelihood, and $L$ is the number of Monte Carlo samples. In the second term, the conditional prior serves as a regularizer that ensures the inferred random Fourier basis will always be relevant to the current task. Minimizing the Kullback Leibler (KL) divergence forces the distribution of random Fourier bases, as inferred from the coreset, to be close to the one from the training set. Moreover, the KL term enables us to generate informative kernels adapted to each task using relatively small memory.
In practice, the conditional distributions $q_{\phi}(\boldsymbol{\omega} | \mathcal{C}_t) $ and $p_{\gamma}(\boldsymbol{\omega} | \mathcal{D}_t\backslash \mathcal{C}_t)$ are assumed to be Gaussian. We implement them by using the amortization technique \cite{kingma2013auto}. That is, we use multilayer perceptrons to generate the distribution parameters, $\mu$ and $\sigma$, by taking the conditions as input. In our experiments, we deploy two separate amortization networks, referred to as the inference network $f_{\phi}$ for the variational posterior and the prior network $f_\gamma$ for the prior.
In addition, to demonstrate the effectiveness of data-driven kernels, we also implement a variant of variational random features by replacing the conditional prior in Eq. (\ref{objective}) with an uninformative one, i.e., an isotropic Gaussian distribution $\mathcal{N}(0,\rm{I})$. In this case, kernels are also learned in a data-driven way from the coreset without being regulated by the training data from the task.
\begin{figure*}[t!]
\centering
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width=.99\linewidth]{figs/perm_mnist_acc.pdf}
\caption{Permuted MNIST}
\label{fig:5-run-5-task-acc-pm}
\end{subfigure}%
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width=.99\linewidth]{figs/rot_mnist_acc.pdf}
\caption{Rotated MNIST}
\label{fig:5-run-5-task-acc-rm}
\end{subfigure}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width=.99\linewidth]{figs/cifar100_acc.pdf}
\caption{Split CIFAR100}
\label{fig:5-run-5-task-acc-cifar}
\end{subfigure}
\caption{\textbf{Effectiveness of kernels.} Accuracy of kernel continual learning by variational random features for the first five tasks on three benchmarks. Note the limited decline in accuracy as the number of tasks increase.}
\label{fig:5-run-5-task-acc}
\vspace{-4mm}
\end{figure*}
\section{Experiments}
We conduct our experiments on four benchmark datasets for continual learning. We perform thorough ablation studies to demonstrate the effectiveness of kernels for continual learning as well as the benefit of variational random features in learning data-driven kernels.
\subsection{Datasets}
\textbf{Permuted MNIST} Following~\cite{kirkpatrick2017overcoming}, we generate 20 different MNIST datasets. Each dataset is created by a special pixel permutation of the input images, without changing their corresponding labels. Each dataset has its own permutation by owning a random seed.
\textbf{Rotated MNIST} Similar to Permuted MNIST, Rotated MNIST has 20 tasks \cite{mirzadeh2020understanding}. Each task's dataset is a specific random rotation of the original MNIST dataset,
e.g., the dataset for task $1$, task $2$, and task $3$ are the original MNIST dataset, a 10-degree rotation, and a 20-degree rotation, respectively.
In other words, each task's dataset is a 10-degree rotation of the previous task's dataset.
\textbf{Split CIFAR100} \citet{zenke2017continual} created this benchmark by dividing the CIFAR100 dataset into 20 sections. Each section represents $5$ out of $100$ labels (without replacement) from CIFAR100. Hence, it contains $20$ tasks and each task is a $5$-way classification problem.
\textbf{Split miniImageNet} Similar to Split CIFAR100, the miniImageNet benchmark~\cite{vinyals2016matching} contains 100 classes, and is a subset of the original ImageNet dataset~\cite{russakovsky2015imagenet}. It has 20 disjoint tasks, each of which task contains 5 classes.
\subsection{Evaluation Metrics}
We follow the common conventions in continual learning ~\cite{Chaudhry2018RiemannianWF, mirzadeh2020understanding}, and report the \textit{average accuracy} and \textit{average forgetting} metrics.
\textbf{Average Accuracy} This score shows the model accuracy after training over $t$ consecutive tasks are finished. It is formulated as follows:
\begin{equation}
\mathrm{A}_t = \frac{1}{t} \sum_{i=1}^{t} \mathrm{a}_{t,i},
\label{eq:avg_per}
\end{equation}
where $\mathrm{a}_{t,i}$ refers to the model performance on task $i$ after being trained on task $t$.
\textbf{Average Forgetting}
This metric measures the decline in accuracy for each task, according to the highest accuracy and the final accuracy reached after model training is finished. It is formulated as follows:
\begin{equation}
\mathrm{F} = \frac{1}{T-1} \sum _{i=1} ^{T-1} \rm{max}_{1,...,T-1}(\mathrm{a}_{t,i} - \mathrm{a}_{T,i}).
\label{eq:avg_forg}
\end{equation}
Taken together, the two metrics allow us to asses how well a continual learner achieves its classification target while overcoming forgetting.
\subsection{Implementation Details}
Our kernel continual learning contains three networks: a shared backbone $h_\theta$, a posterior network $f_\phi$, and a prior network $f_\gamma$. An overview of our implementation is provided in the supplementary materials. For the Permuted MNIST and Rotated MNIST benchmarks, $h_\theta$ contains only two hidden layers, each of which has $256$ neurons, followed by a ReLU activation function. For Split CIFAR100, we use a ResNet18 architecture similar to~\citet{mirzadeh2020understanding}, and for miniImageNet, we have a ResNet18 similar to ~\citet{chaudhry2020continual}. With regard to the $f_\gamma$ and $f_\phi$ networks, we adopt three hidden layers followed by an ELU activation function~\cite{gordon2018meta}. The number of neurons in each layer depends on the benchmark. On Permuted MNIST and Rotated MNIST, there are $256$ neurons per layer, and we use $160$ and $512$ for Split CIFAR100 and miniImageNet, respectively.
For fair comparisons, the model is trained for only \textit{one} epoch per task, that is, each sample in the dataset is observed only once. The batch size is set to 10. Other optimization techniques, such as weight-decay, learning rate decay, and dropout are set to the same values as in \cite{mirzadeh2020understanding}. The model is implemented in Pytorch \cite{Pytorch}.
All our code will be released.\footnote{
\href{https://github.com/mmderakhshani/KCL}{https://github.com/mmderakhshani/KCL}
}
\subsection{Results}
We first provide a set of ablation studies for our proposed method. Then, the performance of our method is compared against other continual learning methods (see the supplementary materials for more details about each ablation).
\paragraph{Effectiveness of kernels}
To demonstrate the effectiveness of kernels for continual learning, we establish classifiers based on kernel ridge regression using commonly used linear, polynomial, radial basis function (RBF) kernels, and our proposed variational random Fourier features. We report results on Split CIFAR100, where we sample five different random seeds. For each random seed, the model is trained over different kernels. Finally, the result for each kernel is estimated by averaging over the corresponding random seeds. For fair comparison, all kernels are computed using the same coreset of size $20$.
The results are shown in Table \ref{tab:kernel-ablation}. All kernels perform well: the radial basis function (RBF) obtains a modest average accuracy in comparison to other basic kernels such as the linear and polynomial kernels. The linear and polynomial kernels perform similarly. The kernels obtained from variational random features (VRFs) achieve the best performance in comparison to other kernels, and they work better than its uninformative counterpart. This emphasizes that the prior incorporated in VRFs is more informative because its prior is data-driven.
Regarding VRFs, Figure~\ref{fig:5-run-5-task-acc} demonstrates the change of each task's accuracy on Permuted MNIST, Rotated MNIST and Split CIFAR100.
It is also worth mentioning that the classifiers based on those kernels are non-parametric, enabling them to systematically avoid task interference in classifiers. Thanks to the non-parametric nature of the classifiers based on kernels, our method is flexible and able to naturally deal with a more challenging setting under a different numbers of classes (which we refer to as `varied ways'). To demonstrate this, we conduct experiments with a varying number of classes in each task using VRFs. The results on Split CIFAR100 and Split miniIMageNet
are shown in Table~\ref{tab:variable_lenght}. Kernel continual learning results in slightly lower accuracy on Split CIFAR100, but leads to an improvement over the traditional fixed ways evaluation on Split miniImageNet.
\begin{table}[t]
\centering
\caption{\textbf{Effectiveness of kernels} on Split CIFAR100.
All kernels perform well, but the simple linear kernel performs better than the RBF kernel. The adaptive kernels based on the random Fourier features achieve the best performance, indicating the advantage of data-driven kernels.
}
\vspace{2mm}
\resizebox{1\columnwidth}{!}{%
\begin{tabular}{@{}lcc@{}}
\toprule
& \multicolumn{2}{c}{\textbf{Split CIFAR100}} \\ \cmidrule(lr){2-3}
\textbf{Kernel} & Accuracy & Forgetting \\ \midrule
RBF & 56.86 {\scriptsize $\pm$ 1.67} & 0.03 {\scriptsize $\pm$ 0.008} \\
Linear & 60.88 {\scriptsize $\pm$ 0.64} & 0.05 {\scriptsize $\pm$ 0.007} \\
Polynomial & 60.96 {\scriptsize $\pm$ 1.19} & 0.03 {\scriptsize $\pm$ 0.004} \\
VRF (uninformative prior) & 62.46 {\scriptsize $\pm$ 0.93} & 0.05 {\scriptsize $\pm$ 0.004} \\
VRF & 62.70 {\scriptsize $\pm$ 0.89} & 0.06 {\scriptsize $\pm$ 0.008} \\
\bottomrule
\end{tabular}%
}
\label{tab:kernel-ablation}
\end{table}
\begin{table}[t!]
\centering
\caption{\textbf{Effectiveness of VRF kernel} for variable-way scenario on Split CIFAR100 and Split miniImageNet. In this scenario, instead of covering a fixed number of five classes per task from Split CIFAR100 and Split miniImageNet, a task is able to cover a more flexible number of classes in the range $[3, 15]$. By doing so, the experimental setting is more realistic. Even in this case, our proposed method is effective, as indicated by the performance improvement of miniImageNet.}
\vspace{2mm}
\resizebox{1\columnwidth}{!}{%
\begin{tabular}{lllll}
\toprule
& \multicolumn{2}{c}{\textbf{Split CIFAR100}} & \multicolumn{2}{c}{\textbf{Split miniImageNet}} \\ \cmidrule(lr){2-3} \cmidrule(lr){4-5}
& Accuracy & Forgetting & Accuracy & Forgetting \\ \midrule
Fixed Ways & 64.02 & 0.05 & 51.89 & 0.06 \\
Varied Ways & 61.00\scriptsize{$\pm$ 1.80} & 0.05\scriptsize{$\pm$ 0.01} & 53.90\scriptsize{$\pm$ 2.95} & 0.05\scriptsize{$\pm$ 0.01} \\
\bottomrule
\end{tabular}%
}
\label{tab:variable_lenght}
\end{table}
\begin{figure*}[t!]
\centering
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width=.99\linewidth]{figs/different_size_rff_cifar.pdf}
\caption{Split CIFAR100}
\label{fig:positive_transfer_cifar}
\end{subfigure}%
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width=.99\linewidth]{figs/different_size_rff_mini_imagenet.pdf}
\caption{Split miniImageNet}
\label{fig:positive_transfer_imagenet}
\end{subfigure}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width=.99\linewidth]{figs/kernel_cifar.pdf}
\caption{RBF vs. VRF on Split CIFAR100}
\label{fig:positive_transfer_rbf_vs_vrf}
\end{subfigure}
\caption{\textbf{Influence of number of tasks}. The average accuracies of kernel continual learning by variational random features for $20$ tasks under three different coreset sizes are illustrated on Split CIFAR100 (a) and Split miniImageNet (b). Moreover, in figure (c), we show the average accuracy of two VRF and RBF kernels. As show in all figures, our proposed kernel continual learning is improved when observing more tasks.}
\label{fig:pft}
\end{figure*}
\begin{figure*}[t!]
\minipage[t]{0.32\textwidth}
\includegraphics[width=\linewidth]{figs/rff_l_rbf.pdf}
\caption{\textbf{Memory benefit of Variational Random Features}. To achieve similar performance, variational random features need a smaller coreset size compared to RBF kernels, showing the benefit of variational random features for kernel continual learning.}
\label{fig:rbf-vs-rff}
\endminipage\hfill
\minipage[t]{0.32\textwidth}
\includegraphics[width=\linewidth]{figs/core_acc_complete.pdf}
\caption{\textbf{How much inference memory?} Enlarging the coreset size of the VRF kernel leads to improvement in performance on all datasets. The more challenging the dataset, the more memory size helps.}
\label{fig:core_vs_acc}
\endminipage\hfill
\minipage[t]{0.32\textwidth}%
\includegraphics[width=\linewidth]{figs/bases_acc_complete.pdf}
\caption{\textbf{How many Random Bases?} In general, a larger number of random Fourier bases consistently improves the performance on all benchmarks. With the relatively small number of $256$ bases, our variational random features can deliver good performance.
}
\label{fig:basis_vs_acc}
\endminipage
\end{figure*}
\begin{table}[h]
\centering
\caption{\textbf{How much inference memory?} Increasing the coreset size has only a minimal impact on time complexity at inference.}
\vspace{2mm}
\label{tab:time_coreset}
\resizebox{.8\columnwidth}{!}{%
\begin{tabular}{@{}lcccc@{}}
\toprule
& \multicolumn{4}{c}{\textbf{Split CIFAR100}}\\
\cmidrule(lr){2-5}
& 5 & 10 & 20 & 40 \\
\midrule
Time (s) & 0.0017 & 0.0017 & 0.0017 & 0.0018 \\
\bottomrule
\end{tabular}%
}
\end{table}
\begin{table}[h]
\centering
\caption{\textbf{How may Random Bases?} Increasing the number of Random Bases leads to an increased time complexity at inference.}
\vspace{2mm}
\label{tab:time_random_bases}
\resizebox{.8\columnwidth}{!}{%
\begin{tabular}{@{}lcccc@{}}
\toprule
& \multicolumn{4}{c}{\textbf{Split CIFAR100}}\\
\cmidrule(lr){2-5}
& 256 & 512 & 1024 & 2048 \\
\midrule
Time (s) & 0.0014 & 0.0015 & 0.0015 & 0.0017 \\
\bottomrule
\end{tabular}%
}
\vspace{-2mm}
\end{table}
\paragraph{Influence of Number of Tasks} Next we ablate the robustness of our proposal when the number of tasks increase. We report results with three different coreset sizes on Split CIFAR100 and Split miniImageNet
in Figure~\ref{fig:pft} (a) and (b). As can be seen, our method achieves increasingly better performance as the number of tasks increases, indicating that knowledge is transferred forward from previous tasks to future tasks.
The observed positive transfer is likely due to the shared parameters in the feature extractors and amortization networks, as they allow knowledge to be transferred across tasks.
We again show a comparison between variational random features and a predefined RBF kernel in Figure~\ref{fig:pft} (c). The performance for variational random features increases faster than the RBF kernel when observing more tasks. This might be due to the amortization network shared among tasks, which enables knowledge to be transferred across tasks as well, indicating the benefit of learning data-driven kernels by our variational random features.
\begin{figure*}[h]
\centering
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width=.99\linewidth]{figs/perm_mnist_acc_compare_all.pdf}
\caption{Permuted MNIST}
\label{fig:5-run-20-tasks-avg-acc-pm}
\end{subfigure}%
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width=.99\linewidth]{figs/rot_mnist_acc_compare_all.pdf}
\caption{Rotated MNIST}
\label{fig:5-run-20-tasks-avg-acc-rm}
\end{subfigure}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width=.99\linewidth]{figs/cifar100_acc_compare_all.pdf}
\caption{Split CIFAR100}
\label{fig:5-run-20-tasks-avg-acc-cifar}
\end{subfigure}
\caption{
\textbf{Comparison between the state of the art} and our
kernel continual learning by variational random features over 20 consecutive tasks, in terms of average accuracy. Our model consistently performs better than other methods with less accuracy drop on Rotated and Permuted MNIST and, further, the performance even starts to increase when observing more tasks on the challenging Split CIFAR100 dataset.}
\label{fig:ablation}
\vspace{-2mm}
\end{figure*}
\begin{table*}[h]
\centering
\caption{\textbf{Comparison to the state-of-the-art.} Results for other methods on Permuted MNIST, Rotated MNIST and Split CIFAR100 are adopted from~\citet{mirzadeh2020understanding}. For Split miniImageNet results are from \citet{chaudhry2020continual}.We include columns denoting \textit{if} and \textit{when} memory is used. In all cases, kernel continual learning is best.}
\vspace{2mm}
\resizebox{1\linewidth}{!}{%
\begin{tabular}{lccccccccccc}
\toprule
\multirow{2}{*}{\textbf{Method}} &
\multicolumn{2}{c}{\textbf{Memory}}
& \multicolumn{2}{c}{\textbf{Permuted MNIST}} & \multicolumn{2}{c}{\textbf{Rotated MNIST}} & \multicolumn{2}{c}{\textbf{Split CIFAR100}} & \multicolumn{2}{c}{\textbf{Split miniImageNet}} \\ \cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7} \cmidrule(lr){8-9} \cmidrule(lr){10-11}
& If & When & Accuracy & Forgetting & Accuracy & Forgetting & Accuracy & Forgetting & Accuracy & Forgetting\\ \midrule
Lower Bound: Naive-SGD \cite{mirzadeh2020understanding} & \xmark & - & 44.4\scriptsize{$\pm$2.46} & 0.53\scriptsize{$\pm$0.03} & 46.3\scriptsize{$\pm$1.37} & 0.52\scriptsize{$\pm$0.01} & 40.4\scriptsize{ $\pm$2.83} & 0.31\scriptsize{$\pm$0.02} & 36.1\scriptsize{$\pm$ 1.31} & 0.24\scriptsize{$\pm$ 0.03} \\
EWC \cite{kirkpatrick2017overcoming} & \xmark & - & 70.7\scriptsize{$\pm$1.74} & 0.23\scriptsize{$\pm$0.01} & 48.5\scriptsize{$\pm$1.24} & 0.48\scriptsize{$\pm$0.01} & 42.7\scriptsize{$\pm$1.89} & 0.28\scriptsize{$\pm$0.03} & 34.8\scriptsize{$\pm$ 2.34} & 0.24\scriptsize{ $\pm$ 0.04} \\
AGEM \cite{AGEM} & \cmark & Train & 65.7\scriptsize{$\pm$0.51} & 0.29\scriptsize{$\pm$0.01} & 55.3\scriptsize{$\pm$1.47} & 0.42\scriptsize{$\pm$0.01} & 50.7\scriptsize{$\pm$2.32} & 0.19\scriptsize{$\pm$0.04} & 42.3\scriptsize{$\pm$ 1.42} & 0.17\scriptsize{$\pm$ 0.01}\\
ER-Reservoir \cite{Chaudhry2019OnTE} & \cmark & Train & 72.4\scriptsize{$\pm$0.42} & 0.16\scriptsize{$\pm$0.01} & 69.2\scriptsize{$\pm$1.10} & 0.21\scriptsize{$\pm$0.01} & 46.9\scriptsize{$\pm$0.76} & 0.21\scriptsize{$\pm$0.03} & 49.8\scriptsize{$\pm$ 2.92} & 0.12\scriptsize{$\pm$ 0.01}\\
Stable SGD \cite{mirzadeh2020understanding} & \xmark & - & 80.1\scriptsize{$\pm$0.51} & 0.09\scriptsize{$\pm$0.01} & 70.8\scriptsize{$\pm$0.78} & 0.10\scriptsize{$\pm$0.02} & 59.9\scriptsize{$\pm$1.81} & 0.08\scriptsize{$\pm$0.01} & - & - \\
\textit{\textbf{Kernel Continual Learning}} & \cmark & \textbf{Test} & \textbf{85.5\scriptsize{$\pm$0.78}} & \textbf{0.02\scriptsize{$\pm$0.00}} & \textbf{81.8\scriptsize{$\pm$0.60}} & \textbf{0.01\scriptsize{$\pm$0.00}} & \textbf{62.7\scriptsize{$\pm$0.89}} & \textbf{0.06\scriptsize{$\pm$0.01}} & \textbf{53.3\scriptsize{$\pm$ 0.57}} & \textbf{0.04\scriptsize{$\pm$ 0.00}}\\
\midrule
Upper Bound: multi-task learning \cite{mirzadeh2020understanding} & \xmark & - & 86.5\scriptsize{$\pm$0.21} & 0.0 & 87.3\scriptsize{$\pm$0.47} & 0.0 & 64.8\scriptsize{$\pm$0.72} & 0.0 & 65.1 & 0.0\\
\bottomrule
\end{tabular}%
}
\label{tab:compare-20tasks}
\vspace{-2mm}
\end{table*}
\paragraph{Memory benefit of Variational Random Features}
To further demonstrate the memory benefit of data-driven kernel learning, we compare variational random features with a predefined RBF kernel in Figure~\ref{fig:rbf-vs-rff}. We consider five different coreset sizes. Variational random features exceed the RBF kernel consistently. For instance, With a smaller coreset size of 20, variational random features can achieve similar performance to the RBF kernel with a larger coreset size of 40. This demonstrates that learning task-specific kernels in a data driven way enables us to use less memory than with a pre-defined kernel.
\paragraph{How much inference memory?}
Since kernel continual learning does not need to replay and only uses memory for inference, the coreset size plays a crucial role. We therefore ablate its influence on Rotated MNIST, Permuted MNIST, and Split CIFAR100
by varying the coreset size as 1, 2, 5, 10, 20, 30, 40, and 50. Here, the number of random bases is set to 1024 for Rotated MNIST and Permuted MNIST, and 2048 for Split CIFAR100.
The results in Figure~\ref{fig:core_vs_acc} show that increasing the coreset size from 1 to 5 results in a steep accuracy increase for all datasets. This continues depending on the difficulty of the dataset. For Split CIFAR100, the results start to saturate after a coreset size of 20.
This is expected as increasing the number of samples in a coreset allows us to better infer the random Fourier bases with more data from the task, therefore resulting in more representative and descriptive kernels. In the remaining experiments we use a coreset size of $20$ for Rotated MNIST, Permuted MNIST and Split CIFAR100, and a coreset size of $30$ for miniImageNet (see supplementary materials). We also ablate the effect of the coreset size on time complexity in Table \ref{tab:time_coreset}. Indeed, it shows that increasing the coreset size only comes with a limited cost increase at inference time.
\paragraph{How many Random Bases?}
When approximating VRF kernels the number of random Fourier bases is a important hyperparameter. In principle, a larger number of random Fourier bases should yield a better approximation of kernels, leading to better classification accuracy. Here, we investigate its effect on the continual learning accuracy. Results with different numbers of bases are shown in Figure~\ref{fig:basis_vs_acc} on Rotated MNIST, Permutated MINST and Split CIFAR100. As expected, the performance increases with a larger number of random Fourier bases, but with a relatively small number of $256$ bases, our method already performs well on all datasets. Table \ref{tab:time_random_bases} further shows the impact of the number of random bases on time complexity. It highlights that increasing the number of random bases comes with an increasing computation time for the model at inference time.
\paragraph{Comparison to the state-of-the-art}
We compare kernel continual learning with alternative methods on the four benchmarks. The accuracy and forgetting scores in Table~\ref{tab:compare-20tasks} for Rotated MNIST, Permuted MNIST and Split CIFAR100 are all adopted from~\cite{mirzadeh2020understanding}, and results for miniImageNet are from \cite{chaudhry2020continual}. The ``\textit{if}'' column indicates whether a model utilizes memory and if so, the ``\textit{when}'' column denotes whether the memory data are used during training time or test time. Our method achieves better performance in terms of average accuracy and average forgetting. Moreover, compared to memory-based methods such as A-GEM \cite{AGEM} and ER-Reservoir \cite{Chaudhry2019OnTE}, which replay over previous tasks (\textit{when} $=$ Train), kernel continual learning does not require replay, enabling our method to be efficient during training time. Further, for the most challenging miniImageNet dataset, kernel continual learning also performs better than other methods, both in terms of accuracy and forgetting. In Figure~\ref{fig:ablation}, we compare our kernel continual learning by variational random features with other methods in terms of average accuracy over 20 consecutive tasks. Our method performs consistently better. It is worth noting that on the relatively challenging Split CIFAR100 dataset, the accuracy of our method drops a bit at the beginning but starts to increase when observing more tasks. This indicates a positive forward transfer from previous tasks to future tasks. All hyperparameters for reproducing the results in Figure~\ref{fig:ablation} and Table~\ref{tab:compare-20tasks} are provided in the supplementary materials.
\section{Conclusion}
In this paper, we introduce kernel continual learning, a simple but effective variation of continual learning with kernel-based classifiers. To mitigate catastrophic forgetting, instead of using shared classifiers across tasks, we propose to learn task-specific classifiers based on kernel ridge regression. Specifically, we deploy an episodic memory unit to store a subset of training samples for each task, which is referred to as the coreset. We formulate kernel learning as a variational inference problem by treating random Fourier bases as the latent variable to be inferred from the coreset. By doing so, we are able to generate an adaptive kernel for each task while requiring a relatively small memory size. We conduct extensive experiments on four benchmark datasets for continual learning. Our thorough ablation studies demonstrate the effectiveness of kernels for continual learning and the benefits of variational random features in learning data-driven kernels for continual learning. Our kernel continual learning already achieves state-of-the-art performance on all benchmarks, while opening up many other possible connections between kernel methods and continual learning.
\section*{Acknowledgements}
This work is financially supported by the Inception Institute of Artificial Intelligence, the University of Amsterdam and the allowance Top consortia for Knowledge and Innovation (TKIs) from the Netherlands Ministry of Economic Affairs and Climate Policy.
| {'timestamp': '2021-07-16T02:05:21', 'yymm': '2107', 'arxiv_id': '2107.05757', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05757'} | arxiv |
\section{Introduction}
A \emph{Minimum Path Cover (MPC)} of a (directed) graph $G = (V, E)$ is a minimum-sized set of paths such that every vertex appears in some path in the set. While computing an MPC is NP-hard in general, it is a classic result, dating back to Dilworth~\cite{dilworth2009decomposition} and Fulkerson~\cite{fulkerson1956note}, that this can be done in polynomial time on directed acyclic graphs (\emph{DAGs}). Computing an MPC of a DAG has applications in various fields. In bioinformatics, it allows efficient solutions to the problems of multi-assembly~\cite{eriksson2008viral,trapnell2010transcript,rizzi2014complexity,chang2015bridger,liu2017strawberry}, perfect phylogeny haplotyping~\cite{bonizzoni2007linear,gramm2007haplotyping}, and alignment to pan-genomes~\cite{makinen2019sparse,ma2021co}. Other examples include scheduling~\cite{colbourn1985minimizing,desrosiers1995time,bunte2009overview,van2016precedence,zhan2016graph,marchal2018parallel}, computational logic~\cite{bova2015model,gajarsky2015fo}, distributed computing~\cite{tomlinson1997monitoring,ikiz2006efficient}, databases~\cite{Jagadish90}, evolutionary computation~\cite{jaskowski2011formal}, program testing~\cite{ntafos1979path}, cryptography~\cite{mackinnon1985optimal}, and programming languages~\cite{kowaluk2008path}. Since in many of these applications the size $k$ (number of paths, also known as \emph{width}) of an MPC is bounded, research has
also focused in solutions whose complexity is parameterized by $k$. This approach is also related to the line of research ``FPT inside P''~\cite{giannopoulou2017polynomial} of finding natural parameterizations for problems already in P (see also e.g.~\cite{fomin2018fully,koana2021data,abboud2016approximation}).
MPC algorithms can be divided into those based on a reduction to maximum matching~\cite{fulkerson1956note}, and those based on a reduction to minimum flow~\cite{ntafos1979path}. The former compute an MPC of a \emph{transitive} DAG by finding a maximum matching in a bipartite graph with $2|V|$ vertices and $|E|$ edges. Thus, one can compute an MPC of a transitive DAG in time $O(\sqrt{|V|} |E|)$ with the Hopcroft-Karp algorithm \cite{hopcroft1973n}. Further developments of this idea include the $O(k|V|^2)$-time algorithm of Felsner et~al.~\cite{felsner2003recognition}, and the $O(|V|^2 + k\sqrt{k}|V|)$ and $O(\sqrt{|V|}|E| + k\sqrt{k}|V|)$-time algorithms of Chen and Chen~\cite{chen2008efficient,chen2014graph}.
The reduction to minimum flow consists in building a flow network $\mathcal{G}$ from $G$, where a global source $s$ and global sink $t$ are added, and each vertex $v$ of $G$ is split into an edge $(v^{in}, v^{out})$ of $\mathcal{G}$ with a demand (lower bound) of one unit of flow (see \Cref{sec:preliminaries} for details). A minimum-valued (integral) flow of $\mathcal{G}$ corresponds to an MPC of $G$, which can be obtained by decomposing the flow into paths. This reduction (or similar) has been used several times in the literature to compute an MPC (or similar object)~\cite{ntafos1979path,mohring1985algorithmic,gavril1987algorithms,Jagadish90,ciurea2004sequential,rademaker2012optimal,pijls2013another,marchal2018parallel}, and it is used in the recent $O(k(|V| + |E|)\log{|V|})$-time solution of M\"akinen et~al.~\cite{makinen2019sparse}. Furthermore, by noting that a path cover of size $|V|$ is always valid (one path per vertex) the problem can be reduced to maximum flow with capacities at most $|V|$ (see for example \cite[Theorem 4.9.1]{bang2008digraphs}) and it can be solved by using maximum flow algorithms outputting integral solutions. As an example, using the Goldberg-Rao algorithm~\cite{goldberg1998beyond} the problem can be solved in time $\widetilde{O}(|E|\min(|E|^{1/2}, |V|^{2/3})+k|E|)$ (the $k|E|$ term is needed for decomposing the flow into an MPC). More recent maximum flow algorithms~\cite{lee2014path,madry2016computing,liu2020faster,kathuria2020unit,van2021minimum,gao2021fully} provide an abundant options of trade-offs, though none of them leads to a parameterized linear-time solution for the MPC problem. Next, we describe our techniques and results.
\paragraph{Sparsification, shrinking and splicing.}
Across our solutions we interleave three techniques.
\emph{Transitive sparsification} consists in the removal of some transitive edges\footnote{Transitive edges are edges whose removal does not disconnect its endpoints.} while preserving the reachability among vertices, and thus the width of the DAG\footnote{Every edge in an MPC removed by a transitive sparsification can be \emph{re-routed} through an alternative path.}. We sparsify the edges to $O(k|V|)$ only, in overall $O(|E|)$ time, obtaining thus a linear dependency on $|E|$ in our running times. Our idea is inspired by the work of Jagadish~\cite{Jagadish90}, which proposed a compressed index for answering reachability queries in constant time: for each vertex $v$ and path $P$ of an MPC, it stores the last vertex in $P$ that reaches $v$ (thus using overall $k|V|$ space). However, three issues arise when trying to apply this idea \emph{inside} an MPC algorithm: (i) it is dependent on an initial MPC (whereas we are trying to compute one), (ii) it can be computed in only $O(k|E|)$ time~\cite{makinen2019sparse}, and (iii) edges in the index are not necessarily in the DAG. We address (i) by using a suboptimal (but yet bounded) path cover whose gradual computation is interleaved with transitive sparsifications, and we address (ii) and (iii) by keeping only $O(k)$ incoming edges per vertex in a \emph{single linear pass} over the edges.
By \emph{shrinking} we refer to the process of transforming an arbitrary path cover into an MPC. For example, using the flow network $\mathcal{G}$ built from the given path cover, we can search for \emph{decrementing} paths, until obtaining a minimum flow corresponding to an MPC. Given an $O(\log{|V|})$ approximation of an MPC, both algorithms of~\cite{felsner2003recognition,makinen2019sparse} shrink this path cover in a separate step. In both of our algorithms, we do not use shrinking as a separate black-box, but instead interleave shrinking steps in the gradual computation of the MPC. Moreover, in the second algorithm we further guide the search for decrementing paths to amortize the search time to parameterized linear time.
Finally, by \emph{splicing} we refer to the general process of reconnecting paths in a path cover so that (after splicing) at least one of them contains a certain path $D$ as a subpath, while working in time proportional to $|D|$. In particular, we show how to perform splicing to apply the changes required by a decrementing path on a flow decomposition for obtaining an MPC (see \Cref{sec:splicing-algorithm}), and also to reconnect paths for reducing the number of edges used by an MPC (see \Cref{sec:edge-thinning}).
\paragraph{A simple divide-and-conquer approach.}
As a first simple example of sparsification and shrinking interleaved inside an MPC algorithm, in \Cref{sec:DandC} we show how these two techniques enable the first divide-and-conquer MPC algorithm.
\begin{restatable}{theorem}{sparsealgorithm}
\label{thm:main-d-c}
Given a DAG $G = (V,E)$ of width $k$, we compute an MPC in time ${O(k^2|V|\log{|V|}+|E|)}$.
\end{restatable}
\Cref{thm:main-d-c} works by splitting a topological ordering of the vertices in half, and recursing in each half. When combining the MPCs from the two halves, we need to (i)~account for the new edges between the two parts (here we exploit sparsification), and (ii)~efficiently combine the two partial path covers into one for the entire graph (and here we use shrinking). Since this divides the problem in disjoint subgraphs, we also obtain the first linear-time parameterized parallel algorithm.
\begin{restatable}{theorem}{parallelsparsealgorithm}
\label{thm:parallel-d-c}
Given a DAG $G = (V,E)$ of width $k$, we compute an MPC in $O(k^2|V|+|E|)$ parallel steps using $O(\log{|V|})$ single processors in the PRAM model~\cite{wyllie1979complexity}.
\end{restatable}
\paragraph{The first linear-time parameterized algorithm.}
Our second algorithm works on top of the minimum flow reduction, but instead of running a minimum flow algorithm and then extracting the corresponding paths (as previous approaches do~\cite{ntafos1979path,mohring1985algorithmic,Jagadish90,ciurea2004sequential,rademaker2012optimal,pijls2013another,marchal2018parallel,makinen2019sparse}), it processes the vertices in topological order, and incrementally maintains an MPC (i.e.~a flow decomposition) $\mathcal{P}$ of the corresponding induced subgraph. When a new vertex $v$ is processed, $\mathcal{P}$ is used to sparsify the edges incoming to $v$ to at most $k$ (see \Cref{sec:progressive-flows}). After that, the path cover $\mathcal{P} \cup \{(v)\}$ is shrunk by searching for a single decrementing path in the corresponding residual graph. The search is guided by assigning an integer level to each vertex. We amortize the time of performing all the searches to $O(k^3)$ time per vertex, thus obtaining the final $O(k^3|V|+|E|)$ running time.
\begin{restatable}{theorem}{mpcflow}
\label{thm:mpc-flow}
Given a DAG $G = (V,E)$ of width $k$, we compute an MPC in time ${O(k^3|V|+|E|)}$.
\end{restatable}
The amortization is achieved by guiding the search through the assignment of integer levels to the vertices, which allows to perform the traversal in a \emph{layered} manner, from the vertices of largest level to vertices of smallest level (see \Cref{sec:layered-traversal}). If a decrementing path $D$ is found, $\mathcal{P} \cup \{(v)\}$ is updated by splicing it along $D$ (see \Cref{sec:splicing-algorithm}).
An \emph{antichain} is a set of pairwise non-reachable vertices, and it is a well-known result, due to Dilworth~\cite{dilworth2009decomposition}, that the maximum size of an antichain equals the size of an MPC. Our level assignment defines a series of size-decreasing one-way cuts (\Cref{lemma:optimality-by-invariant-a}). Moreover, by noting that these cuts in the network correspond to antichains (see e.g. \cite{pijls2013another}), the levels implicitly maintain a structure of antichains that \emph{sweep} the graph during the algorithm. The high-level idea of maintaining a collection of antichains has been used previously by Felsner et~al.~\cite{felsner2003recognition} and C\'aceres et~al.~\cite{caceres2021a} for the related problem of computing a maximum antichain. However, apart from being restricted to this related problem, these two approaches have intrinsic limitations. More precisely, Felsner et~al.~\cite{felsner2003recognition} maintain a \emph{tower of right-most antichains} for \emph{transitive} DAGs and $k \leq 4$, mentioning that ``the case $k=5$ already seems to require an unpleasantly involved case analysis''~\cite[p.~359]{felsner2003recognition}. C\'aceres et~al.~\cite{caceres2021a} overcome this by maintaining $O(2^k)$ many \emph{frontier antichains}, and obtaining a linear-time parameterized $O(k^24^k|V| + k2^k|E|)$-time maximum antichain algorithm.
Based on the relation between maximum one-way cuts in the minimum flow reduction and maximum antichains in the original DAG (see for example~\cite{mohring1985algorithmic,pijls2013another,marchal2018parallel}), we obtain algorithms computing a maximum antichain from any of our existing algorithms, preserving their running times (see \Cref{thm:main-antichain}). In particular, by using our second algorithm we obtain an exponential improvement on the function of $k$ of the algorithm of C\'aceres et~al.~\cite{caceres2021a}.
\paragraph{Edge sparsification in parameterized linear time.} Our last result in \Cref{sec:edge-thinning} is a structural result concerning the problem of \emph{edge sparsification} preserving the width of the DAG. Edge sparsification is a general concept that consists in finding spanning subgraphs (usually with significantly less edges) while (approximately) preserving certain property of the graph. For example, \emph{spanners} are distance preserving (up to multiplicative factors) sparsifiers, and it is a well-known result that $(1+\epsilon)$ cut sparsifiers can be computed efficiently~\cite{benczur1996approximating}. We show that if the property we want to maintain is the (exact) width of a DAG, then its edges can be sparsified to less than~$2|V|$. Moreover, we show that such sparsification is asymptotically tight (\Cref{remark:2-tight}), and it can be computed in $O(k^2|V|)$ time if an MPC is given as additional input. Therefore, by using our second algorithm we obtain the following result.
\begin{corollary}
\label{cor:main-sparsification}
Given a DAG $G = (V,E)$ of width $k$, we compute a spanning subgraph $G' = (V, E')$ of $G$ with $|E'| < 2|V|$ and width $k$ in time ${O(k^3|V|+|E|)}$.
\end{corollary}
The main ingredient to obtain this result is an algorithm for transforming any path cover into one of the same size using less than~$2|V|$ distinct edges, a surprising structural result.
\begin{restatable}{theorem}{edgethinning}
\label{thm:edge-thinning}
Let $G = (V,E)$ be a DAG, and let $\mathcal{P}, |\mathcal{P}|=t$ be a path cover of $G$. Then, we compute, in $O(t^2|V|)$ time, a path cover $\mathcal{P}',|\mathcal{P}'|=t$, whose number of \emph{distinct} edges is less than $2|V|$.
\end{restatable}
We obtain \Cref{cor:main-sparsification} by using \Cref{thm:edge-thinning} with an MPC and defining $E'$ as the edges in $\mathcal{P}'$. Our approach adapts the techniques used by Schrijver~\cite{schrijver1998bipartite} for finding a perfect matching in a regular bipartite graph. In our algorithm, we repeatedly search for undirected cycles~$C$ of edges joining vertices of high degree (in the graph induced by the path cover), and splice paths along $C$ (according to the \emph{multiplicty} of the edges of $C$) to remove edges from the path cover.
\paragraph{Paper structure.} \Cref{sec:preliminaries} presents basic concepts, the main preliminary results needed to understand the technical content of this paper, and results related to the three common techniques used in latter sections\footnote{We include the full version of this section in \Cref{sec:extended-preliminaries} for completeness.}. \Cref{sec:DandC,sec:progressive-flows} present our $O(k^2|V|\log{|V|}+|E|)$ and $O(k^3|V|+|E|)$ time algorithms for MPC, respectively\footnote{In \Cref{sec:antichain-structure} we show that our second algorithm implicitly maintains a structure of antichains.}. \Cref{sec:edge-thinning} presents the algorithm of \Cref{thm:edge-thinning}. Omitted proofs can be found in the Appendices.
\section{Preliminaries} \label{sec:preliminaries}
\paragraph{Basics.} We denote by $N^+(v)$ ($N^-(v)$) the set of out-neighbors (in-neighbors) of $v$, and by $I^+(v)$ ($I^-(v)$) the edges outgoing (incoming) from (to) $v$. A graph $S = (V_S, E_S)$ is said to be a \emph{subgraph} of $G$ if $V_S \subseteq V$ and $E_S \subseteq E$. If $V_S = V$ it is called \emph{spanning} subgraph. If $V' \subseteq V$, then $G[V']$ is the subgraph of $G$ \emph{induced} by $V'$, defined as $G[V'] = (V', E_{V'})$, where $E_{V'} = \{(u, v) \in E ~:~ u,v \in V'\}$. A \emph{directed acyclic graph} (DAG) is a directed graph without proper cycles. A \emph{topological ordering} of a DAG is a total order of $V$, $v_1,\ldots, v_{|V|}$, such that for all $(v_{i}, v_{j}) \in E$, $i < j$. A topological ordering can be computed in $O(|V|+|E|)$ time~\cite{kahn1962topological,tarjan1976edge}. If there exists a path from $u$ to $v$, then it is said that $u$ \emph{reaches} $v$. The \emph{multiplicity} of an edge $e\in E$ with respect to a set of paths $\mathcal{P}$, $\mu_{\mathcal{P}}(e)$ (only $\mu(e)$ if $\mathcal{P}$ is clear from the context), is defined as the number of paths in $\mathcal{P}$ that contain $e$, $\mu_{\mathcal{P}}(e) = |\{P\in\mathcal{P}\mid e \in P\}|$. The \emph{width} of a graph $G$, $\mathsf{width}(G)$, is the size of an MPC of $G$. We will work with subgraphs induced by a consecutive subsequence of vertices in a topological ordering. The following lemma shows that we can bound the width of these subgraphs by $k = \mathsf{width}(G)$.
\begin{restatable}[\cite{caceres2021a}]{lemma}{topologicalDoNotIncreaseWidth}
\label{topologicalDoNotIncreaseWidth}
Let $G = (V, E)$ be a DAG, and $v_1, \ldots , v_{|V|}$ a topological ordering of its vertices. Then, for all $i, j \in [1\ldots |V|], i \le j$, $\mathsf{width}(G_{i,j}) \le \mathsf{width}(G)$, with $G_{i,j} := G[\{v_{i}, \ldots , v_{j}\}]$.
\end{restatable}
\paragraph{Minimum Flow.
Given a (directed) graph $G = (V, E)$, a source $s \in V$, a sink $t \in V$, and a function of \emph{lower bounds} or \emph{demands} on its edges $d: E \rightarrow \mathbb{N}_{0}$, an $st$-\emph{flow} (or just \emph{flow} when $s$ and $t$ are clear from the context) is a function on the edges $f: E \rightarrow \mathbb{N}_{0}$, satisfying $f(e) \ge d(e)$ for all $e \in E$ ($f$ \emph{satisfies the demands}) and $\sum_{e \in I^-(v)} f(e) = \sum_{e \in I^+(v)} f(e)$ for all $v \in V \setminus \{s,t\}$ (\emph{flow conservation}). If a flow exists, the tuple $(G, s, t, d)$ is said to be a \emph{flow network}. The \emph{size} of $f$ is the net amount of flow exiting $s$, formally $|f| = \sum_{e \in I^+(s)} f(e) - \sum_{e \in I^-(s)} f(e)$. An $st$-\emph{cut} (or just \emph{cut} when $s$ and $t$ are clear from the context) is a partition $(S, T)$ of $V$ such that $s \in S$ and $t \in T$. An edge $(u, v)$ \emph{crosses} the cut $(S, T)$ if $u\in S$ and $v \in T$, or vice versa. If there are no edges \emph{crossing} the cut from $T$ to $S$, that is, if $\{(u,v) \in E \mid u \in T, v \in S\} = \emptyset$, then $(S, T)$ is a \emph{one-way cut} (ow-cut). The \emph{demand} of an ow-cut is the sum of the demands of the edges crossing the cut, formally $d((S,T)) = \sum_{e = (u, v), u \in S, v \in T} d(e)$. An ow-cut whose demand is maximum among the demands of all ow-cuts is a \emph{maximum ow-cut}.
Given a \emph{flow network} $(G, s, t, d)$, the problem of \emph{minimum flow} consists of finding a flow $f^*$ of minimum size $|f^*|$ among the flows of the network, such flow is a \emph{minimum flow}. If a minimum flow exists, then $(G, s, t, d)$ is a \emph{feasible} flow network. It is a known result~\cite{ahujia1993network,ciurea2004sequential,bang2008digraphs} that the demand of a maximum ow-cut equals the size of a minimum flow.
Given a flow $f$ in a feasible flow network $(G, s, t, d)$, the \emph{residual network} of $G$ with respect to $f$ is defined as $\residual{G}{f} = (V, E_f)$ with $E_f = \{(u, v) \mid (v, u) \in E\} \cup \{e \mid f(e) > d(e)\}$, that is, the \emph{reverse edges} of $G$, plus the edges of $G$ on which the flow can be decreased without violating the demands (\emph{direct edges}). Note that a path from $s$ to $t$ in $\residual{G}{f}$ can be used create another flow $f'$ of smaller size by increasing flow on reverse edges and decreasing flow on direct edges of the path, such path it is called \emph{decrementing path}. A flow $f$ is a minimum flow if and only if there is no decrementing path in $\residual{G}{f}$ (see \Cref{sec:min-flow-extended}). A \emph{flow decomposition} of $f$ is a set of $|f|$ paths $\mathcal{P}$ in $G$ such that $f(e) = \mu_{\mathcal{P}}(e)$ for all $e \in E$, in this case it is said that $f$ is the flow \emph{induced} by $\mathcal{P}$. If $\mathcal{P}$ is a flow decomposition of $f$, then the residual network of $G$ with respect to $\mathcal{P}$ is $\residual{G}{f}$.
\paragraph{MPC in DAGs through Minimum Flow.
The problem of finding an MPC in a DAG $G = (V, E)$ can be solved by a reduction to the problem of minimum flow on an appropriate feasible flow network $(\mathcal{G} = (\mathcal{V}, \mathcal{E}), s, t, d)$~\cite{ntafos1979path}, defined as: $\mathcal{V} = \{s, t\} \cup \{v^{in} \mid v \in V\} \cup \{v^{out} \mid v \in V\}$ ($\{s,t\}\cap V = \emptyset$); $\mathcal{E} = \{(s, v^{in}) \mid v \in V\} \cup \{(v^{out}, t) \mid v \in V\} \cup \{(v^{in}, v^{out}) \mid v \in V\} \cup \{(u^{out}, v^{in}) \mid (u,v) \in E\}$; and $d(e) = 1$ if $e = (v^{in}, v^{out})$ for some $v \in V$ and $0$ otherwise. The tuple $(\mathcal{G}, s, t, d)$ is the \emph{flow reduction} of $G$. Note that $|\mathcal{V}| = O(|V|)$, $|\mathcal{E}|=O(|E|)$, and $\mathcal{G}$ is a DAG. Every flow $f$ of $(\mathcal{G}, s, t, d)$ can be decomposed into $|f|$ paths corresponding to a path cover of $G$ (by removing $s$ and $t$ and merging the edges $(v^{in}, v^{out})$ into $v$, see \Cref{sec:minflow-reduction-extended}). A minimum flow of $(\mathcal{G}, s, t, d)$ has size $\mathsf{width}(G)$, thus providing an MPC of $G$ after decomposing it (see \Cref{sec:minflow-reduction-extended}). Moreover, the set of edges of the form $(v^{in}, v^{out})$ crossing a maximum ow-cut corresponds to a maximum antichain of $G$ (by merging the edges $(v^{in}, v^{out})$ into $v$, see~\cite{mohring1985algorithmic,rademaker2012optimal,pijls2013another,marchal2018parallel}). By further noting that if $f$ is a minimum flow of $(\mathcal{G}, s, t, d)$, and defining $S = \{v \in \mathcal{V} \mid s\text{ reaches } v\text{ in }\residual{\mathcal{G}}{f}\}$, then $(S, T=\mathcal{V}\setminus S)$ corresponds to a maximum ow-cut, we obtain the following result.
\begin{restatable}{lemma}{fastantichain}
\label{thm:main-antichain}
Given a DAG $G = (V,E)$ of width $k$ and an MPC $\mathcal{P}$, we compute a maximum antichain of $G$ in time $O(k|V|+|E|)$.
\end{restatable}
As such, this allows us to obtain algorithms computing a maximum antichain from any of our MPC algorithms, preserving their running times.
\paragraph{Sparsification, shrinking, splicing.} We say that a spanning subgraph $S = (V, E_S)$ of a DAG $G = (V, E)$ is a \emph{transitive sparsification} of $G$, if for every $u, v \in V$, $u$ reaches $v$ in $S$ if and only if $u$ reaches $v$ in $G$. Since $G$ and $S$ have the same reachability relations on their vertices, they share their antichains, thus $\mathsf{width}(G) = \mathsf{width}(S)$. As such, an MPC of $S$ is also an MPC of $G$, thus the edges $E\setminus E_S$ can be safely removed for the purpose of computing an MPC of $G$. If we have a path cover $\mathcal{P}$ of size $t$ of $G$, then we can \emph{sparsify} (remove some transitive edges) the incoming edges of a particular vertex $v$ to at most $t$ in time $O(t+|N^-(v)|)$. If $v$ has more than $t$ in-neighbors then two of them belong to the same path, and we can remove the edge from the in-neighbor appearing first in the path. We create an array of $t$ elements initialized as $survivor \gets (v_{-\infty})^t$, where $v_{-\infty} \not \in V$ is before every $v\in V$ in topological order. Then, we process the edges $(u,v)$ incoming to $v$, we set $i \gets path(u)$ ($path(u)$ gives the ID of some path of $\mathcal{P}$ containing $u$) and if $survivor[i]$ is before $u$ in topological order we replace it $survivor[i] \gets u$. Finally, the edges in the sparsification are $\{(survivor[i], v) \mid i\in\{1,\ldots,t\} \land survivor[i] \not = v_{-\infty}\}$.
\begin{restatable}{obs}{obssparsification}
\label{obs:sparsificationVertex}
Let $G = (V, E)$ be a DAG, $\mathcal{P}$ a path cover, $|\mathcal{P}|=t$, $v$ a vertex of $G$, and $path:V\rightarrow \{1,\ldots,t\}$ a function that answers in constant time $path(v)$, the ID of some path of $\mathcal{P}$ containing $v$. We can sparsify the incoming edges of $v$ to at most $t$ in time $O(t+|N^-(v)|)$.
\end{restatable}
By first computing a $path$ function, and then applying \Cref{obs:sparsificationVertex} to every vertex we obtain.
\begin{restatable}{lemma}{sparsificationalgorithm}
\label{sparsification_algorithm}
Let $G = (V, E)$ be a DAG, and $\mathcal{P}$, $|\mathcal{P}|=t$, be a path cover of $G$. Then, we can sparsify $G$ to $S = (V, E_S)$, such that $\mathcal{P}$ is a path cover of $S$ and $|E_S| \le t|V|$, in $O(t|V| + |E|)$ time.
\end{restatable}
The following lemma shows that we can locally sparsify a subgraph and apply these changes to the original graph to obtain a transitive sparsification.
\begin{restatable}{lemma}{sparsificationOfSubgraph}
\label{sparsificationOfSubgraph}
Let $G = (V, E)$ be a graph, $S = (V_S, E_S)$ a subgraph of $G$, and $S' = (V_S, E_{S'})$ a transitive sparsification of $S$. Then $G' = (V, E\setminus (E_S \setminus E_{S'}))$ is a transitive sparsification of $G$.
\end{restatable}
As explained before, shrinking is the process of transforming an arbitrary path cover $\mathcal{P}$ into an MPC, and it can be solved by finding $|\mathcal{P}|-\mathsf{width}(G)$ decrementing paths in $\residual{\mathcal{G}}{\mathcal{P}}$, and then decomposing the resulting flow into an MPC. M\"akinen et al.~\cite{makinen2019sparse} apply this idea to shrink a path cover of size $O(k\log{|V|})$. We generalize this approach in the following lemma.
\begin{restatable}{lemma}{shrinkingalgorithm}
\label{result:shrinking}
Given a DAG $G = (V, E)$ of width $k$, and a path cover $\mathcal{P}$, $|\mathcal{P}|=t$, of $G$, we can obtain an MPC of $G$ in time $O(t(|V| + |E|))$.
\end{restatable}
As said before, splicing consists in reconnecting paths in a path cover $\mathcal{P}$ so that (after reconnecting) at least one of the paths contains as a subpath a certain path $D$, in time $O(|D|)$. Splicing additionally requires that for every edge $e$ of $D$ there is at least one path in $\mathcal{P}$ containing $e$.
\begin{restatable}{lemma}{splicingalgorithm}
\label{result:splicing}
Let $G = (V, E)$ be a DAG, $D$ a proper path, and $\mathcal{P}$ path cover such that for every edge $e \in D$ there exists $P\in\mathcal{P}, e \in P$. We obtain a path cover $\mathcal{P}'$ of $G$ such that $|\mathcal{P}'| = |\mathcal{P}|$ and there exists $P\in\mathcal{P}'$ containing $D$ as a subpath, in time $O(|D|)$. Moreover, $\mu_{\mathcal{P}}(e) = \mu_{\mathcal{P}'}(e)$ for all $e \in E$.
\end{restatable}
Because of the last property of $\mathcal{P}'$, the flow induced by $\mathcal{P}$ is the same as the flow induced by $\mathcal{P}'$. As such, if $\mathcal{P}$ is a flow decomposition of a flow $f$, then $\mathcal{P}'$ is also a flow decomposition of $f$.
\section{Divide and Conquer Algorithm}\label{sec:DandC}
\begin{figure}[t]
\centering
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[width=0.95\textwidth]{images/example2}
\caption[]%
{{\small Input graph}}
\label{subfig:input-graph}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[width=0.95\textwidth]{images/example3}
\caption[]%
{{\small Result of recursion}}
\label{subfig:recursion}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[width=0.95\textwidth]{images/example4}
\caption[]%
{{\small Result of sparsification}}
\label{subfig:sparsification}
\end{subfigure}
\begin{subfigure}[b]{0.24\textwidth}
\centering
\includegraphics[width=0.95\textwidth]{images/example5}
\caption[]%
{{\small Result of shrinking}}
\label{subfig:shrinking}
\end{subfigure}
\caption[]
{\small Main steps of the divide-and-conquer algorithm applied to a DAG $G$. \Cref{subfig:input-graph} shows the input graph, a maximum antichain, and the division into $G_{\ell}$ and $G_r$. \Cref{subfig:recursion} shows the resulting graph $G'$ after applying the algorithm recursively into $G_{\ell}$ and $G_r$, the corresponding sparsifications $G_{\ell}'$ and $G_r'$, and path covers $\mathcal{P}_{\ell}$ and $\mathcal{P}_r$. \Cref{subfig:sparsification} shows the result $G''$ of the sparsification algorithm run on $G'$ with the paths $\mathcal{P}_\ell \cup \mathcal{P}_r$. \Cref{subfig:shrinking} shows the result $\mathcal{P}$ after shrinking.}
\label{fig:divide-and-conquer}
\end{figure}
\sparsealgorithm*
\begin{proof}
Before starting the recursion compute a topological ordering of the vertices $v_1, \ldots , v_{|V|}$ in time $O(|V|+|E|)$. Solve recursively in the subgraph $G_{\ell} = (V_{\ell}, E_{\ell})$ induced by $v_1, \ldots , v_{|V|/2}$, obtaining an MPC $\mathcal{P}_{\ell}$ of a sparsification $G'_{\ell} = (V_{\ell}, E'_{\ell})$ of $G_{\ell}$ with $|E'_{\ell}| \le 2|\mathcal{P}_{\ell}||V_{\ell}|$, and in the subgraph $G_r = (V_r, E_r)$ induced by $v_{|V|/2+1}, \ldots , v_{|V|}$, obtaining an MPC $\mathcal{P}_{r}$ of a sparsification $G'_r = (V_r, E'_r)$ of $G_r$ with $|E'_r| \le 2|\mathcal{P}_{r}||V_r|$. By \Cref{topologicalDoNotIncreaseWidth}, $|\mathcal{P}_\ell|\le k$ and $|\mathcal{P}_r|\le k$. Applying \Cref{sparsificationOfSubgraph} with $G'_{\ell}$ and $G'_{r}$ we obtain that $G' = (V, E' = E'_{\ell} \cup E'_{r} \cup E_{\ell r})$ is a sparsification of $G$ with $|E'| \le 2|\mathcal{P}_{\ell}||V_{\ell}| + 2|\mathcal{P}_r||V_r| + |E_{\ell r}| \le |E_{\ell r}| + 2k|V|$, where $E_{\ell r}$ are the edges in $G$ from $V_{\ell}$ to $V_r$. We consider the path cover $\mathcal{P}_{\ell} \cup \mathcal{P}_r$ of $G'$ and use \Cref{sparsification_algorithm} to obtain a sparsification $G'' = (V, E'')$ of $G'$ in time $O(|E'| + (|\mathcal{P}_{\ell}|+|\mathcal{P}_r|)|V|) = O(|E_{\ell r}| + k|V|)$ such that $|E''| \le (|\mathcal{P}_{\ell}|+|\mathcal{P}_r|)|V| \le 2k|V|$. Finally, we \emph{shrink} $\mathcal{P}_{\ell} \cup \mathcal{P}_r$ in $G''$ to $\mathcal{P}$ of size $k$ in $O((|\mathcal{P}_{\ell}|+|\mathcal{P}_r|)k|V|) = O(k^2|V|)$ time (\Cref{result:shrinking}).
The complexity analysis considers the recursion tree of the algorithm. Note that the complexity of a recursion step is $O(k^2|V| + |E_{\ell r}|)$, that is, every vertex of the corresponding subgraph costs $O(k^2)$ and every edge going from the left subgraph to the right subgraph costs $O(1)$. Since the division of the graph generates disjoint subgraphs, every vertex appears in $O(\log{|V|})$ nodes in the recursion tree, and every edge going from left to right appears in exactly one node in the recursion tree. Therefore, the total cost is $O(|E|+k^2|V|\log{|V|})$. \Cref{fig:divide-and-conquer} illustrates the algorithm.
\end{proof}
Since our algorithm is based on divide and conquer, we can parallelize the work done on every sub-part of the input, and obtain a linear-time parallel algorithm for the MPC problem.
\parallelsparsealgorithm*
\section{Progressive Flows Algorithm}\label{sec:progressive-flows}
In this section we prove \Cref{thm:mpc-flow}. To achieve this result we rely on the reduction from MPC in a DAG to minimum flow (see \Cref{sec:preliminaries}). We process the vertices of $G$ one by one in a topological ordering $v_1, \ldots, v_{|V|}$. At each step, we maintain a set of \emph{st-flow paths} $\mathcal{P}_i$ that corresponds to a flow decomposition of a minimum flow of $\mathcal{G}_i = (\mathcal{V}_i, \mathcal{E}_i)$ (the flow reduction of $G_i = G[\{v_1, \ldots, v_i\}]$), that is, an MPC of $G_i$. When the next vertex $v_{i+1}$ is considered, we first use $\mathcal{P}_{i}$ to sparsify its incoming edges to at most $|\mathcal{P}_{i}| = O(k)$ in time $O(k+|N^-(v_{i+1})|)$ (see \Cref{obs:sparsificationVertex} and \Cref{topologicalDoNotIncreaseWidth}). Then, we set $\mathcal{T}_{i+1} \gets \mathcal{P}_i \cup \{(v_{i+1}^{in}, v_{i+1}^{out})\}$, where $(v_{i+1}^{in}, v_{i+1}^{out})$ corresponds to the edge representing $v_{i+1}$ in the flow reduction (we represent $st$-flow paths either as a sequence of vertices or edges excluding the extremes for convenience). $\mathcal{T}_{i+1}$ represents a path cover of $G_{i+1}$, and we use it to try to find a decrementing path in $\residual{\mathcal{G}_{i+1}}{\mathcal{T}_{i+1}}$. If such decrementing path $D$ is found, some flow paths along $D$ are \emph{spliced} to generate $\mathcal{P}_{i+1}$, such that $|\mathcal{P}_{i+1}| = |\mathcal{P}_{i}|$ (see \Cref{sec:splicing-algorithm}). Otherwise, if no decrementing path is found, we set $\mathcal{P}_{i+1} \gets \mathcal{T}_{i+1}$.
We guide the traversal for a decrementing path by assigning an integer level $\ell(v)$ to each vertex $v$ in $\mathcal{G}_{i}$. The search is performed in a \emph{layered} manner: it starts from the highest reachable layer (the vertices of highest level according to $\ell$), and it only continues to the next highest reachable layer once all reachable vertices from the current layer have been visited (see \Cref{sec:layered-traversal}). To allow the \emph{layered traversal} and to achieve amortized $O(k^3)$ time per vertex, we maintain three invariants in the algorithm (see \Cref{sec:levels-and-invariants}) and update the level assignment accordingly (see \Cref{sec:level-updates}).
\subsection{Levels, layers and invariants}\label{sec:levels-and-invariants}
We define the level assignment given to the vertices of $\mathcal{G}_{i}$, $\ell: \mathcal{V}_i \to \{0, 1, \ldots, \mathsf{width}(G_i)\} \cup \{-\infty, +\infty\}$, and the invariants maintained on $\ell$. A \emph{layer} is a maximal set of vertices with the same level, thus layer $l$ is $\{v \in V(\mathcal{G}_{i}) \mid \ell(v) = l\}$. All layers form a partition of $\mathcal{V}_i$. We extend the definition of level assignment to paths, the level of a path is the maximum level of a vertex in the path, that is, if $P$ is a path of $\mathcal{G}_i$, then $\ell(P) = \max_{v \in P} \ell(v)$. We define $\mathcal{P}_i^{\ge l} \subseteq \mathcal{P}_i$, as the flow paths whose level is at least $l$, $\mathcal{P}_i^{\ge l} = \{P \in \mathcal{P}_i \mid \ell(P)\ge l\}$. Note that $|\mathcal{P}_i^{\ge l}| \ge |\mathcal{P}_i^{\ge l'}|$ if $l' > l$.
At the beginning we fix $\ell(s) = -\infty$ and $\ell(t) = +\infty$. We also maintain that $0\le\ell(v)\le\mathsf{width}(G_i)$ for all $v \in \mathcal{V}_i \setminus \{s,t\}$. Additionally, we maintain the following invariants:
\begin{description}
\item[Invariant A]: If $(u, v)$ is an edge in $\residual{\mathcal{G}_i}{\mathcal{P}_i}$ and $\{u, v\} \cap \{s, t\} = \emptyset$, then $\ell(u) \ge \ell(v)$.
\item[Invariant B]: If $(u^{in}, u^{out})$ is the last edge of some $P \in \mathcal{P}_i$, then $\ell(u^{in}) < \ell(u^{out})$.
\item[Invariant C]: If $l, l'$ are positive integers with $l' > l$, then $|\mathcal{P}_i^{\ge l}| > |\mathcal{P}_i^{\ge l'}|$.
\end{description}
Note that, since we do not include $s$ and $t$ in the representation of flow paths, $0\le\ell(P)\le\mathsf{width}(G_i)$ for all $P \in \mathcal{P}_{i}$, moreover, by \textbf{Invariant B}{}, $\ell(P) \ge 1$, thus $\mathcal{P}_i^{\ge 1} = \mathcal{P}_i$. Also note that \textbf{Invariant C}{} implies that every layer $l \in \{1,\ldots,L\}, L =\max_{v\in\mathcal{V}_i\setminus\{t\}}\ell(v)$ is not empty.
\subsection{Progressive flows algorithm}\label{sec:progressive-flows-algorithm}
Our algorithm starts by using $\mathcal{P}_i$ to obtain at most $|\mathcal{P}_i|$ edges incoming to $v_{i+1}$ in time $O(|\mathcal{P}_i|+|N^-(v_{i+1})|) = O(k+|N^-(v_{i+1})|)$ (see \Cref{obs:sparsificationVertex}). This procedure requires to answer $path(v)$ (the ID of some path of $\mathcal{P}_{i}$ containing $v$) queries in constant time. To satisfy this requirement, we maintain path IDs on every vertex/edge of every flow path $P \in \mathcal{P}_i$. In each iteration of our algorithm, these path IDs can be broken by the splicing algorithm (\Cref{sec:splicing-algorithm}) but are repaired before the beginning of the next iteration (\Cref{sec:level-updates}). The following lemma states that the sparsification of incoming edges in $G_{i+1}$ produces an sparsification of outgoing edges in the residual.
\begin{lemma}\label{lemma:sparsifiedresidual}
For every $x \in \mathcal{V}_{i+1}\setminus \{s, t\}$, $|N^+({x})| = O(|\mathcal{P}_{i}|)$, in $\residual{\mathcal{G}_{i+1}}{\mathcal{T}_{i+1}}$.
\end{lemma}
\begin{proof}
If $x$ is of the form $v^{in}$, then its only direct edge could be $(v^{in}, v^{out})$ (only if $(v^{in}, v^{out})$ appears in more than one path in $\mathcal{P}_{i+1}$), its reverse edges are of the form $(v^{in}, u^{out})$, such that $(u, v)$ is an edge in $G_{i+1}$, thus there are at most $|\mathcal{P}_i|$ of such edges because of sparsification (recall that $|\mathcal{P}_j| \le |\mathcal{P}_i|$ for $j < i$, by \Cref{topologicalDoNotIncreaseWidth}). On the other hand, if $x$ is of the form $u^{out}$, then the only reverse edge is $(u^{out}, u^{in})$. To bound the number of direct edges consider the $st$-ow-cut $(S, T)$, with $S =\{v \in \mathcal{V}_{i+1} : \mbox{$v$ reaches $u^{out}$ in $\mathcal{G}_{i+1}$}\}$. The flow induced by $\mathcal{T}_{i+1}$ crossing the cut cannot be more that $|\mathcal{T}_{i+1}| = |\mathcal{P}_i|+1$, and thus the number of direct edges $(u^{out}, v^{in})$ is at most $|\mathcal{P}_i|+1$.
\end{proof}
\subsubsection{Layered traversal}\label{sec:layered-traversal}
Our layered traversal performs a BFS in each reachable layer from highest to lowest. If $t$ is reached, the search stops and the algorithm proceeds to splice the flow paths along the decrementing path found. Since $\mathcal{P}_{i}$ represents a minimum flow of $\mathcal{G}_i$, every decrementing path $D$ in $\residual{\mathcal{G}_{i+1}}{\mathcal{T}_{i+1}}$ starts with the edge $(s, v_{i+1}^{in})$ and ends with an edge of the form $(u^{out}, t)$ such that some flow path of $\mathcal{P}_i$ ends at $u^{out}$. Moreover, since $(v_{i+1}^{in}, v_{i+1}^{out})$ does not exist in $\residual{\mathcal{G}_{i+1}}{\mathcal{T}_{i+1}}$, the second edge of $D$ must be a reverse edge of the form $(v_{i+1}^{in}, u^{out})$, such that $u$ is an in-neighbor of $v_{i+1}$ in $G_{i+1}$.
We work with $|\mathcal{P}_{i}|+1$ queues $Q_{0}, Q_1, \ldots, Q_{|\mathcal{P}_{i}|}$ (one per layer), where $Q_j$ contains the \emph{enqueued} elements from layer $j$, therefore it is initialized as $Q_j \gets \{u^{out} \mid (u^{out}, v_{i+1}^{in}) \in \mathcal{E}_{i+1} \land \ell(u^{out}) = j\}$. By \Cref{lemma:sparsifiedresidual}, this initialization takes $O(|\mathcal{P}_{i}|) = O(k)$ time, and it is charged to $v$. We start working with $Q_{|\mathcal{P}_i|}$. When working with $Q_j$, we obtain the first element $u$ from the queue (if no such element exists we move to layer $j-1$ and work with $Q_{j-1}$), then we \emph{visit} $u$ and for each non-visited out-neighbor $v$ we add $v$ to $Q_{\ell(v)}$. Adding the out-neighbors of $v$ to the corresponding queues is charged to $v$, which amounts to $O(|\mathcal{P}_i|) = O(k)$ by \Cref{lemma:sparsifiedresidual}. Since edges in the residual do not increase the level (\textbf{Invariant A}), out-neighbors can only be added to queues at an equal or lower layer. As such, this traversal advances in a \emph{layered} manner, and it finds a decrementing path if one exists.
Note that the running time of the layered traversal can be bounded by $O(|\mathcal{P}_i|)=O(k)$ per visited vertex. If no decrementing path is found we update the level of the vertices as explained in \Cref{sec:level-updates}. Otherwise, we first splice flow paths along the decrementing path $D$ (\Cref{sec:splicing-algorithm}).
\subsubsection{Splicing algorithm}\label{sec:splicing-algorithm}
Given a decrementing path $D$ in $\residual{\mathcal{G}_{i+1}}{\mathcal{T}_{i+1}}$, we splice flow paths along $D$ to obtain $\mathcal{P}_{i+1}$. Reverse edges in $D$ indicate that we should push $1$ unit of flow in the opposite direction, thus an edge representing this flow unit should be created. On the other hand, direct edges in $D$ indicate that we should subtract $1$ unit of flow from that edge, in other words, that this edge should be removed from some flow path containing it. As explained in \Cref{sec:layered-traversal}, $D$ starts by a direct edge $(s, v_{i+1}^{in})$, followed by a reverse edge $(v_{i+1}^{in}, u^{out})$ such that $(u, v_{i+1})$ is an edge in $G_{i+1}$. It then continues by a (possibly empty) sequence of reverse and direct edges, and it finishes by a direct edge $(u^{out}, t)$, such that some flow path of $\mathcal{P}_{i}$ ends at $u^{out}$.
A \emph{direct (reverse) segment} is a maximal subpath of \emph{direct (reverse)} edges of $D$. The \emph{splicing} algorithm processes direct and reverse segments interleaved as they appear in $D$. It starts by processing the first reverse segment (the one starting with $(v_{i+1}^{in}, u^{out})$). The procedure that process reverse segments receives as input the suffix of a flow path (the first call receives $((v_{i+1}^{in}, v_{i+1}^{out}))$). It creates the corresponding flow subpath (the reverse of the segment), appends it to the path that received as input, and provides the resulting path as input of the procedure handling the next direct segment. The procedure that handles direct segments $S$, also receives as input the suffix of a flow path. It \emph{splices} the paths of the flow decomposition along $S$ using the procedure of \Cref{result:splicing}, obtaining a new flow decomposition such that one of the paths $P$ contains $S$ as a subpath. It then removes $S$ from $P$ and reconnects the prefix of $P$ before $S$ with the path given as input, and provides the suffix of $P$ after $S$ as input of the procedure handling the next reverse segment.
Note that both procedures run in time proportional to the corresponding segment (see \Cref{result:splicing} for direct segments). As such, the splicing algorithm takes $O(D)$ time. Moreover, since all vertices in the decrementing path are also vertices visited by the traversal, the running time is bounded above by the running time of the layered traversal, that is, $O(k)$ per visited vertex.
\begin{figure}[t]
\centering
\begin{subfigure}[b]{0.4\textwidth}
\centering
\includegraphics[width=0.8\textwidth]{images/splicing-a.pdf}
\caption[]%
{{\small Before splicing}}
\label{subfig:before}
\end{subfigure}
\hspace{1cm}
\begin{subfigure}[b]{0.4\textwidth}
\centering
\includegraphics[width=0.8\textwidth]{images/splicing-b.pdf}
\caption[]%
{{\small After splicing}}
\label{subfig:after}
\end{subfigure}
\caption[]
{\small Effect of the splicing along a decrementing path $D$ of $\residual{\mathcal{G}_{i+1}}{\mathcal{T}_{i+1}}$. We only show vertices $s, t, v^{in}_{i+1}, v^{out}_{i+1}$, just four flow paths in blue, green, brown and purple (with some overlap), and two red vertices where splicing of flow paths occurs (splicing points). \Cref{subfig:before} shows the four flow paths before splicing. Path $D$ is highlighted in dashed red (direct segments) and solid red (reverse segment). \Cref{subfig:after} shows that splicing along $D$ transforms the four flow paths into three. The reverse segment creates a subpath (black) of one of these. The direct segments remove subpaths of previous flow paths. The splicing points now join subpaths of the previous brown and blue, and purple and brown, paths respectively.}
\label{fig:splicing}
\end{figure}
\Cref{fig:splicing} illustrates the effect of the splicing algorithm on flow paths.
\subsubsection{Level and path updates}\label{sec:level-updates}
After obtaining $\mathcal{P}_{i+1}$, we update the level of some vertices of $\mathcal{V}_{i+1}$ to maintain the invariants (\Cref{sec:levels-and-invariants}) of the level assignment $\ell$. Moreover, to sparsify (\Cref{sec:progressive-flows-algorithm}) in the next iteration, we also repair the path IDs on the vertices/edges of $\mathcal{P}_{i+1}$ that could be in an inconsistent state after running the splicing algorithm.
If the smallest layer visited during the traversal is layer $l$, then we set $\ell(v_{i+1}^{in}) = l$, $\ell(v_{i+1}^{out}) = l+1$ (to maintain \textbf{Invariant B}{}, see \Cref{sec:invariants}), and change the level of every vertex $u$ visited during the traversal to $\ell(u) = l$ (to maintain \textbf{Invariant A}{}, see \Cref{sec:invariants}).
If a decrementing path was found (and the splicing algorithm was executed) we first repair the path IDs by traversing every flow path of $\mathcal{P}_{i+1}$ backwards from the last vertex, until we arrive to a vertex of level less than $l$, from which we obtain the corresponding path ID that we then update by going back (forwards) in the flow path. After that, the following observations hold.
\begin{obs}\label{obs:end-vertices}
Let $E_{i} = \{u^{out} \in \mathcal{V}_i \mid \exists P \in \mathcal{P}_{i}, \text{$u^{out}$ is the last vertex of $P$}\}$, and $A_{i+1}$ the singleton set containing the last vertex in the decrementing path found by the layered traversal in $\residual{\mathcal{G}_{i+1}}{\mathcal{T}_{i+1}}$, or the empty set if no decrementing path was found. Then, $E_{i+1} = E_i \cup \{v_{i+1}^{out}\} \setminus A_{i+1}$.
\end{obs}
\begin{proof}
If no decrementing path was found the observation easily follows. On the other hand, if a decrementing path $D$ is found, the observation follows from the fact that the only edge in $D$ of the form $(u^{out}, t)$ with $u^{out} \in E_i$, comes from $A_{i+1}$.
\end{proof}
\begin{obs}\label{obs:level-path-changes}
If $l$ is the smallest level visited by the layered traversal in $\residual{\mathcal{G}_{i+1}}{\mathcal{T}_{i+1}}$, then $|\mathcal{P}_i^{\ge l'}|$ = $|\mathcal{P}_{i+1}^{\ge l'}|$ for every $l' \in \{1, \ldots, \mathsf{width}(G_i)+1\} \setminus \{l+1\}$, and $|\mathcal{P}_{i+1}^{\ge l+1}|=|\mathcal{P}_i^{\ge l+1}| +1$.
\end{obs}
Therefore, this is the only way \textbf{Invariant C}{} can be broken by the algorithm. As such, after the level and path ID updates, we check if $|\mathcal{P}_{i+1}^{\ge l}| = |\mathcal{P}_{i+1}^{\ge l+1}|$, and in that case we decrease the level of every vertex $u$, $\ell(u) \ge l$, by $1$. If this happens, we say that we \emph{merge} layer $l$.
The running time of all these updates is bounded by $O(|\mathcal{P}_{i}|) = O(k)$ per vertex of level $l$ or more, which dominates the running time of an step of the algorithm (except the initial sparsification).
\begin{figure}[t]
\centering
\begin{subfigure}[b]{0.32\textwidth}
\centering
\includegraphics[width=0.95\textwidth]{images/progressive2}
\caption[]%
{{\small Layered traversal}}
\label{subfig:traversal}
\end{subfigure}
\begin{subfigure}[b]{0.32\textwidth}
\centering
\includegraphics[width=0.95\textwidth]{images/progressive3}
\caption[]%
{{\small Level updates}}
\label{subfig:updates}
\end{subfigure}
\begin{subfigure}[b]{0.32\textwidth}
\centering
\includegraphics[width=0.95\textwidth]{images/progressive4}
\caption[]%
{{\small Merge of layer $l$}}
\label{subfig:merge}
\end{subfigure}
\caption[]
{\small Execution of our second algorithm in an abstract example graph. Edges and flow paths are absent for simplicity. Layers are divided by dotted vertical strokes, $L = \max_{v\in\mathcal{V}_i\setminus\{t\}}\ell(v)$. \Cref{subfig:traversal} shows a decrementing path in $\residual{\mathcal{G}_{i+1}}{\mathcal{T}_{i+1}}$ (red) found by the layered traversal as well as all vertices visited (red and orange), $l$ is the smallest layer visited. \Cref{subfig:updates} shows the updates to the level assignment, all vertices visited by the traversal get level $l$, and $v_{i+1}^{out}$ gets level $l+1$. \Cref{subfig:merge} shows the result of merging layer $l$, all vertices of level $l$ or more decrease their level by one.}
\label{fig:progressive}
\end{figure}
\Cref{fig:progressive} illustrates the evolution of the level assignment in a step of the algorithm.
\subsection{Running time}\label{sec:running-time}
Note that the running time of step $i+1$ is bounded by $O(|N^{-}(v_{i+1})|)$ (from sparsification) plus $O(|\mathcal{P}_{i}|) = O(k)$ per vertex whose level is $l$ or more, where $l$ is the smallest level visited by the layered traversal in $\residual{\mathcal{G}_{i+1}}{\mathcal{T}_{i+1}}$. The first part adds up to $O(|E|)$ for the entire algorithm, whereas for the second part we show that every vertex is charged $O(k)$ only $O(k^2)$ times in the entire algorithm, thus adding up to $O(k^3|V|)$ in total.
Every time a vertex $u$ is charged $O(k)$, then the minimum level visited in that step must be $l\le \ell(u)$. Consider the sequence $(|\mathcal{P}_i^{\ge 1}|,|\mathcal{P}_i^{\ge 2}|,\ldots,|\mathcal{P}_i^{\ge \ell(u) + 1}|)$ and its evolution until its final state $(|\mathcal{P}_{|V|}^{\ge 1}|,|\mathcal{P}_{|V|}^{\ge 2}|,\ldots,|\mathcal{P}_{|V|}^{\ge \ell'(u) + 1}|)$ (where $\ell'$ is the level assignment when the algorithm finishes). By \Cref{obs:level-path-changes}, any update that charges $u$ changes exactly one value in this sequence ($|\mathcal{P}_{i}^{\ge l+1}|$ is incremented by one), and possibly truncates the sequence on the right due to $u$'s level being lowered (levels can only decrease over time). By \textbf{Invariant C}, this sequence is always strictly decreasing, and since $|\mathcal{P}_i^{\ge 1}| \le k$, it can be updated at most $O(k^2)$ times until it reaches its final state; hence $u$ is charged $O(k)$ only $O(k^2)$ times.
\subsection{Invariants}\label{sec:invariants}
In this section we show that the invariants of the algorithm (\Cref{sec:levels-and-invariants}) are maintained for the next step, namely that the invariants hold for $\mathcal{G}_{i+1}, \mathcal{P}_{i+1}$ and the modified level assignment $\ell$.
\begin{description}
\item[Invariant A]: Let us consider the residual network after level updates have been made to all visited vertices in $\mathcal{V}_{i+1}$ and $v_{i+1}^{out}$, but prior to possibly merging layer $l$ (if called for). Consider an edge $(u,v)$ in $\residual{\mathcal{G}_{i+1}}{\mathcal{P}_{i+1}}$ with $\{u, v\} \cap \{s, t\} = \emptyset$. If both $u$ and $v$ are visited, their levels are each set to $l$, so $\ell(u) \ge \ell(v)$ in $\mathcal{G}_{i+1}$. If neither $u$ nor $v$ are visited, both vertices exist in $\mathcal{V}_i$ and the flow between these vertices is not modified by the decrementing path $D$, so $(u,v)$ in $\residual{\mathcal{G}_i}{\mathcal{P}_i}$. Thus $\ell(u) \ge \ell(v)$ in $\mathcal{G}_{i+1}$ by the invariant of the previous iteration, since their levels are unchanged. If $u$ is visited and $v$ is not, then again $(u,v)$ cannot belong to $D$, so either $u = v_{i+1}^{in}$, or $(u,v)$ in $\residual{\mathcal{G}_i}{\mathcal{P}_i}$. In any case $(u, v)$ in $\residual{\mathcal{G}_i}{\mathcal{T}_{i+1}}$, thus it must be that $\ell(v) \le l$ in $\mathcal{G}_i$, otherwise $v$ would be visited during the layered traversal, so again $\ell(v) \le \ell(u)$ in $\mathcal{G}_{i+1}$, once $\ell(u)$ has been updated. If $v$ is visited and $u$ is not, again $(u,v)$ cannot belong to $D$, so either $(u,v) = (v_{i+1}^{out},v_{i+1}^{in})$ and the invariant is maintained by the level assignment, or $(u,v)$ in $\residual{\mathcal{G}_i}{\mathcal{P}_i}$, in which case $l \le \ell(v) \le \ell(u)$ prior to setting $\ell(v) = l$. Thus, the invariant is maintained in all cases. Finally, it is easy to see that a merge of layer $l$ does not break the invariant.
\item[Invariant B]: By \Cref{obs:end-vertices} the last edges of the paths of $\mathcal{P}_{i+1}$ are $(v_{i+1}^{in}, v_{i+1}^{out})$, or of the form $(u, v)$ with $v \in E_i\setminus A_{i+1}$. As such, after splicing but before a possible merge of layer $l$, the invariant is maintained because the algorithm sets $\ell(v_{i+1}^{in}) = \ell(v_{i+1}^{out})-1 = l$, and it can only decrease the level of $u$ for the rest of the edges (since the vertices in $E_i\setminus A_{i+1}$ are not visited by the layered traversal). If a merge of layer $l$ happens then both extremes of each edge decrease their level by $1$, thus not breaking the invariant.
\item[Invariant C]: By \Cref{obs:level-path-changes}, the only possibility to break the invariant is that $|\mathcal{P}_{i+1}^{\ge l}| = |\mathcal{P}_{i+1}^{\ge l+1}|$, but if this happens it is fixed by merging layer $l$.
\end{description}
\section{Support Sparsification Algorithm}
\label{sec:edge-thinning}
We present an algorithm that transforms any path cover $\mathcal{P}, |\mathcal{P}| = t$ of a DAG $G = (V, E)$ into one of the same size and using less than $2|V|$ distinct edges, in $O(t^2|V|)$ time (\Cref{thm:edge-thinning}). The main approach consists of splicing paths so that edges are removed from the \emph{support} $E_{\mathcal{P}} = \{e \in P \mid P \in \mathcal{P}\}$. It maintains a path cover $\mathcal{P}', |\mathcal{P}'| = t$ of $G' = (V, E_{\mathcal{P}'})$ (thus also a path cover of $G$). At the beginning we initialize $\mathcal{P}'\gets \mathcal{P}$, and we splice paths so that at the end $|E_{\mathcal{P}'}| < 2|V|$.
To decide how to splice paths, we color the vertices of $v \in V$ based on their degree, that is, if $deg_{G'}(v) \le 2$ we color $v$ $blue${}, and $red${} otherwise. We also color the edges $(u, v) \in E_{\mathcal{P}'}$ according to the color of their endpoints, that is, if both $u$ and $v$ are $blue${}, we color $(u, v)$ $blue${}, likewise if both $u$ and $v$ are $red${}, we color $(u, v)$ $red${}, otherwise we color $(u, v)$ $purple${}. We traverse the underlying undirected graph of $G'$ in search of a $red${} cycle (cycle of $red${} edges) $C$ and splice paths along $C$ so that at least one $red${} edge is removed from $G'$. We repeat this until no $red${} cycles remain, thus at the end we have that $red${} vertices and edges form a forest, $blue${} vertices and edges form a collection of vertex-disjoint paths and cycles, and $purple${} edges connect $red${} vertices with the extreme vertices of $blue${} paths. As such, if the number of $blue${} and $red${} vertices is $n_b$ and $n_r$, respectively, and the number of $blue${} paths is $p$, there are $n_b - p$ $blue${} edges, less than $n_r$ $red${} edges, and at most $2p$ $purple${} edges. Therefore, $|E_{\mathcal{P}'}| < n_b -p + n_r + 2p \le 2|V|$, as desired. The following remark shows that the factor $2$ from the bound is asymptotically tight.
\begin{figure}[t]
\centering
\includegraphics[scale=0.4]{images/tight}
\caption{\small A DAG $G$ showing that the factor $2$ from the bound of \Cref{thm:edge-thinning} is asymptotically tight. The figure shows the example graph, as well as the result of applying \Cref{thm:edge-thinning} on an MPC of it. The algorithm colors vertices $v_{i,j}$ $blue${}, vertices $u_i$ $red${}, and edges $purple${}, thus it does not find any $red${} cycle.}
\label{fig:2-tight}
\end{figure}
\begin{remark}\label{remark:2-tight}
Consider the DAG $G = (V,E)$ from \Cref{fig:2-tight}, with $|V| = n+ n(n+1) = n(n+2)$, $|E| = 2n^2$ and $\mathsf{width}(G) = n$. Note that any path cover $\mathcal{P}$ of size $n$ must use every edge of the graph, then $|E_{\mathcal{P}}|/|V| = |E_{\mathcal{P}'}|/|V| = 2 - 4/(n+2)$.
\end{remark}
Recall that the \emph{multiplicity} of an edge $e$, $\mu(e)$, is the number of paths in $\mathcal{P}'$ using $e$, that is, $\mu(e) = |\{P \in \mathcal{P}' \mid e \in P\}|$. When processing a $red${} cycle $C = v_1, \ldots, v_l, v_{l+1} = v_1$, we partition the corresponding edges of $G'$ in either \emph{forward} $F = \{(v_{i}, v_{i+1}) \in E_{\mathcal{P}'}\}$ or \emph{backward} $B = \{(v_{i+1}, v_{i}) \in E_{\mathcal{P}'}\}$ edges. We splice either along forward or backward edges depending on the comparison between $\sum_{e \in F} \mu(e)$ and $\sum_{e \in B} \mu(e)$. If $\sum_{e \in F} \mu(e) \ge \sum_{e \in B} \mu(e)$, we only splice along backward edges, otherwise only along forward edges. Here we only describe the former case, the later is analogous.
The splicing procedure considers the backward \emph{segments} of the cycle, namely, maximal subpaths of consecutive backward edges in $C$. For each backward segment $b$, it generates a path $P_b \in P'$ that traverses $b$ entirely, by splicing paths along $b$. For this we apply the splicing procedure of \Cref{result:splicing} on every backward segment, which runs in total time $O(|B|) = O(|C|)$. After that, for every $P_b$ we remove $b$ and reconnect the parts of $P_b$ entering and exiting $b$ to their corresponding adjacent forward segments. Note that vertices of $b$ are still covered by some path after splicing since they are $red${}, and the splicing procedure preserves the multiplicity of edges. Also note that the net effect is that the number of paths remains unchanged but the multiplicity of forward edges has increased by one and the multiplicity of backward edges has decreased by one, thus the condition $\sum_{e \in F} \mu(e) \ge \sum_{e \in B} \mu(e)$ will be valid again after the procedure. As such, we repeat the splicing procedure until some backward edge has multiplicity $0$, removing $C$ in this way.
To analyze the running time of all splicing procedures during the algorithm, we consider the function $\Phi(G') = \sum_{e \in E_{\mathcal{P}'}} \mu(e)^2$. We study the change of $\Phi(G')$ of applying the splicing procedure, $\Delta \Phi$. Since the only changes on multiplicity occur on forward and backward edges we have that
\begin{align*}
\Delta \Phi &= \sum_{e\in F} \left((\mu(e)+1)^2-\mu(e)^2\right) + \sum_{e\in B} \left((\mu(e)-1)^2-\mu(e)^2\right)\\
&= |F| + |B| + 2 \left(\sum_{e \in F} \mu(e) - \sum_{e \in B} \mu(e)\right) \ge |C|.
\end{align*}
As such, each splicing procedure takes $O(|C|)$ time, and increases $\Phi(G')$ by at least $|C|$. Since at the end $\Phi(G') \le t^2|E_{\mathcal{P}'}| \le t^22|V|$, the running time of all splicing procedures amounts to $O(t^2|V|)$.
Finally, we describe how to traverse the underlying undirected graph of $G'$ while detecting $red${} cycles in linear time, which is $O(t|V|)$. We perform a \emph{modified} DFS traversal of the graph. We additionally mark the edges as \emph{processed{}} either when the edge is removed (gets multiplicity $0$), or when the traversal \emph{pops} this edge from the DFS stack\footnote{When an edge is marked as processed{} we move it at the end of the adjacency list of the corresponding vertex. Therefore, the first edge in the adjacency list of a vertex is always not marked as processed{}, unless all of them are.}. Since our graph is undirected, all edges are between a vertex and some ancestor in the DFS tree (no crossing edges), thus cycles can be detected by checking if the vertex being visited already is in the DFS stack (and it is not the top of the stack)\footnote{We can maintain an array \emph{in-stack} indicating whether a vertex is in the DFS stack.}. When a $red${} cycle is detected, then we pop from the DFS stack all vertices of the cycle, but without marking as processed{} the corresponding edges. The cost of these pops plus the additional cost of traversing the edges of the cycle again in a future traversal is linear in the length of the cycle, thus these are charged to the corresponding splicing procedures of this cycle, and the cost of the traversal remains proportional to the size of the graph.
\bibliographystyle{unsrt}
| {'timestamp': '2021-07-14T02:03:40', 'yymm': '2107', 'arxiv_id': '2107.05717', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05717'} | arxiv |
\section{Visual Program Specifications}
\label{sec:visual}
This section discusses how to add visual specification constructs to {\small\textsf{Snap!}}\xspace. Our goal was to do this in such a way that (1)~the intended semantics of the specification construct is clear from the way it is visualised, and (2)~that it smoothly integrates with the existing programming constructs in {\small\textsf{Snap!}}\xspace
Often, Design-by-Contract specifications are added as special comments in the code. For example, in JML a function contract is written in a special comment, tagged with an \texttt{@}-symbol, immediately preceding the function declaration. The tag ensures that the comment can be recognised as part of the specification. There also exist languages where for example pre- and postconditions are part of the language (e.g., Eiffel~\cite{Meyer91}, Spec\#~\cite{BarnettLW04}). We felt that for our goal, specifications should be integrated in a natural way in the language, rather than using comments.
Therefore, we introduce variations of the existing block structures, in which we added suitable slots for the specifications. This section discusses how we added pre- and postconditions, and in-code specifications such as asserts and loop invariants to {\small\textsf{Snap!}}\xspace. In addition, to have a sufficiently expressive property specification language, we also propose an extension of the expression constructs.
\subsection{Visual Pre- and Postconditions}
To specify pre- and postconditions for a \text{BYOB}\xspace script, we provide
a variation of the initial hat block with a slot for a precondition at the start of the block, and a slot for a postcondition at the end of the block (Fig.~\ref{fig:contracts3}).
This shape is inspired by the c-shaped style of other {\small\textsf{Snap!}}\xspace blocks, such as blocks for loops. The main advantage is that it visualises at which points in the execution, the pre- and the postconditions are expected to hold. In addition, it also graphically identifies which code is actually verified. Moreover, the shapes are already familiar to the {\small\textsf{Snap!}}\xspace programmer. If the slots are not filled, default pre- and postcondition \texttt{true} can be used.
Notice that the pre- and postcondition slots consist of multiple boolean-argument slots, and we define the property to be the conjunction of the evaluation of each of these slots.
This is similar to how {\small\textsf{Snap!}}\xspace extends a list or adds arguments to the header of a \text{BYOB}\xspace.
\vspace{-10pt}
\begin{figure}[htb]
\centering
\includegraphics[width=.95\linewidth]{Media/div3.png}
\vspace{-5pt}
\caption{Hat block extended with contracts}
\label{fig:contracts3}
\end{figure}
\vspace{-5pt}
\subsection{Visual Assertions and Loop Invariants}
For static verification, pre- and postconditions are often not sufficient, and we need additional in-code specifications to guide the prover, such as assertions, which specify properties that should hold at a particular point in the program, and loop invariants. Moreover, assertions can also be convenient for run-time assertion checking to make it explicit that a property holds at a particular point in the program.
\paragraph{Visual Assertions}
To specify assertions, both the property specified and the location within the code are relevant. To allow the specification of assertions at arbitrary places in a script, we define a special assertion block $\vcenter{\hbox{\includegraphics[height=\baselineskip]{Media/assert.png}}}$ similar to all other control blocks.
\paragraph{Visual Loop Invariants}
Loop invariants are necessary for static verification~\cite{Tuerk10}. A loop invariant should hold at the beginning and end of every loop iteration.
To account for this, we provide a (multi-argument boolean) slot to specify the loop invariant in the traditional {\small\textsf{Snap!}}\xspace c-shaped loop block.
This slot is located just after the header where the loop conditions are defined. In addition, the c-shaped loop block repeats the word invariant at the bottom of the block (see Figure~\ref{fig:loopinvariant}) to visually indicate that the invariant is checked after each iteration.
\begin{figure}[htb]
\centering
\includegraphics[width=.55\linewidth]{Media/invariant.png}
\vspace{5pt}
\caption{Visual loop invariants.}
\vspace{-10pt}
\label{fig:loopinvariant}
\end{figure}
\subsection{Visual Expressions}
In addition, we have introduced some specification-only keywords, as commonly found in Design-by-Contract languages.
\begin{itemize}
\item An \emph{old} expression is used in postconditions to indicate that a variable/expression should be evaluated in the pre-state of the function. To support this, we introduced an operator block $\vcenter{\hbox{\includegraphics[height=\baselineskip]{Media/old.png}}}$ with a slot for a variable name.
\item A \emph{result} expression refers to the return value of a function inside its postcondition. We support this by introducing a constant $\vcenter{\hbox{\includegraphics[height=\baselineskip]{Media/result.png}}}$ operator, that allows to specify a property about the result value of a reporter \text{BYOB}\xspace.
\end{itemize}
We also introduce syntax to ease the definition of complex Boolean expressions, by means of the operator blocks
$\vcenter{\hbox{\includegraphics[height=\baselineskip]{Media/implies.png}}}$,
$\vcenter{\hbox{\includegraphics[height=\baselineskip]{Media/geq.png}}}$,
$\vcenter{\hbox{\includegraphics[height=\baselineskip]{Media/leq.png}}}$ and
$\vcenter{\hbox{\includegraphics[height=\baselineskip]{Media/neq.png}}}$, as well as syntax to write more advanced Boolean expressions, introducing support for quantified expressions (See Fig.\ref{fig:quantifiers}).
\begin{figure}[htb]
\includegraphics[height=1.45em]{Media/forall_example.png}
\caption{A global quantification expression block}
\label{fig:quantifiers}
\end{figure}
\section{Background}\label{sec:background}
\subsection{{\small\textsf{Snap!}}\xspace}
{\small\textsf{Snap!}}\xspace\ is a visual programming language. It has been designed to introduce children (but also adults) to programming in an intuitive way. At the same time, it is also a platform for serious study of computer science\cite{harvey2017snap}. {\small\textsf{Snap!}}\xspace actually re-implements and extends {\small\textsf{Scratch}}\xspace~\cite{DBLP:journals/cacm/ResnickMMREBMRSSK09}. Programming in {\small\textsf{Snap!}}\xspace is done by dragging and dropping blocks into the coding area. Blocks represent common program constructs such as variable declarations, control flow statements (branching and loops), function calls and assignments. Snapping blocks together, the user builds a script and visualises its behaviour by means of turtle graphics visualisations, called \textit{sprites}. Sprites can change shape, move, show bubbled text, play music, etc. For all these effects, dedicated blocks are available.
\begin{figure}[h]
\includegraphics[width=\linewidth]{Media/snap.png}
\caption{The {\small\textsf{Snap!}}\xspace working area.}
\label{fig:workingarea}
\end{figure}
The {\small\textsf{Snap!}}\xspace\ interface divides the working area into three parts: the pallet area, the scripting area, and the stage area, indicated by labels 1, 2 and 3, respectively, in Fig.~\ref{fig:workingarea}.
On the left, the various programming blocks are organised into pallets that describe their natural use. For instance, the \emph{Variables} pallet contains blocks for declaring and manipulating variables. In {\small\textsf{Snap!}}\xspace, variables are dynamically typed.
Blocks are dragged and dropped from the pallets into the scripting area, located at the centre of the working area where the {\small\textsf{Snap!}}\xspace program is constructed.
Blocks can be arranged by snapping them together, or by inserting them as arguments of other blocks. Blocks can only be used as arguments if their shapes match with the shape of the argument slots in the target block. These shapes actually provide a hint on the expected evaluation type of a block,
for instance, rounded slots for numbers $\vcenter{\hbox{\includegraphics[height=\baselineskip]{Media/plus.png}}}$ and diamond slots for booleans $\vcenter{\hbox{\includegraphics[height=\baselineskip]{Media/and.png}}}$.
The behaviour of the script is shown with turtle graphics drawings in the stage area located in the rightmost part of the screen.
In addition, at the bottom of the pallet area, there is a ``Make a block'' button. This allows the user to define his or her \emph{Build Your Own Block} (\text{BYOB}\xspace) blocks. When pressed, a new floating ``Block Editor'' window pops out with a new coding area, in which the behaviour of the personalised block can be defined (similar to how a script is made in the scripting area). Label $4$ in Fig.~\ref{fig:workingarea} shows a \text{BYOB}\xspace block being edited. Once defined, the \text{BYOB}\xspace block becomes available to be used just as any other predefined block.
\subsection{Program Verification}
The basis of the \textit{Design-by-Contract}\xspace approach~\cite{meyer1987eiffel} is that the behaviour of all program components is defined as a contract. For example, a function contract specifies the conditions under which a function may be called (the function's \emph{precondition}), and it specifies the guarantees that the function provides to its caller (the function's \emph{postcondition}). There exist several specification languages that have their roots in this \textit{Design-by-Contract}\xspace approach. For example the Eiffel programming language has built-in support for pre- and postconditions~\cite{meyer1988eiffel}, and for Java, the behavioural interface language JML~\cite{leavens2005design} is widely used. As is common for such languages, we use the keyword \emph{requires} to indicate a precondition, and the keyword \emph{ensures} to indicate a postcondition.
If a program behaviour is specified using contracts, various techniques can be used to validate whether an implementation respects the contract.
Dynamic verification validates an implementation w.r.t. a specification at runtime. This means that, whenever during program execution a specification is reached, it will be checked for this particular execution that the property specified indeed holds. In particular, this means that whenever a function will be called, its precondition will be checked, and whenever the function returns, its postcondition will be checked.
An advantage of this approach is that it is easy and fast to use it: one just runs a program and checks if the execution does not violate the specifications. A disadvantage is that it only provides guarantees about a concrete execution.
In contrast, static verification aims at verifying that all possible behaviours of a function respect its contract. This is done by applying Hoare logic proof rules~\cite{Hoare69} or using Dijkstra's predicate transformer semantics~\cite{Dijkstra76}. Applying these rules results in a set of first-order proof obligations; if these proof obligations can be proven it means that the code satisfies its specification. Advantage of this approach is that it guarantees correctness of all possible behaviours. Disadvantage is that it is often labour-intensive, and often many additional annotations, such as for example loop invariants, are needed to guide the prover.
\section{Graphical approach to verification result reporting}
\label{sec:report}
Another important point to consider is how to report on the outcome of the verification: (1)~presenting the verdict of a passed verification, and (2)~in case of failure, giving a concrete and understandable explanation for the failure. The latter is especially important in our case, as we are using the technique with inexperienced users.
In order to signal a contract violation, or any assertion invalidated during dynamic verification, we use {\small\textsf{Snap!}}\xspace's pop-up notification windows. These windows have the advantage that a failing block can be printed inside them even when the failing script is not currently visible to the user. This allows to be very precise about the error, even when the \text{BYOB}\xspace body is not currently visible.
In order to signal errors while compiling to {\small\textsf{Boogie}}\xspace, such as making use of dynamic typing or nested lists in your {\small\textsf{Snap!}}\xspace \text{BYOB}\xspace code, we use {\small\textsf{Snap!}}\xspace's speech bubbles that can emerge at specific points in the script while describing the cause of failure. This has the advantage that the failing block can easily be singled out by the location of the bubble, while the cause of failure is described by the text inside the bubble. We find this option less invasive than a pop-up window but still as precise, and we can be sure that the blocks involved will be visible since static verification is triggered from the \text{BYOB}\xspace editor window (See Fig.\ref{fig:bubbles}).
Notice that currently we do not report the results of static verification within {\small\textsf{Snap!}}\xspace, since our extension only returns a compiled {\small\textsf{Boogie}}\xspace code which has to be verified with {\small\textsf{Boogie}}\xspace separately.
\begin{figure}
\centering
\includegraphics[width=.95\linewidth]{Media/bubble.png}
\vspace{-5pt}
\caption{Static verification compilation notification.}
\label{fig:bubbles}
\end{figure}
\section{Tool support}
\label{sec:toolsupport}
We have developed our ideas into a prototypal extension to {\small\textsf{Snap!}}\xspace\ which can be found at \url{https://git.snt.utwente.nl/montire/verifiedsnap/}. This repository
also contains a set of running examples to showcase the new support for verification. These are available in the \emph{lessons} folder under the root directory along with an exercise sheet named \emph{exercises.pdf}. The extension uses the same technology as the original {\small\textsf{Snap!}}\xspace\ and can be run by just opening the \emph{snap.html} file in most common web-browsers that support java-script.
Our extension supports both dynamic and static verification of \text{BYOB}\xspace blocks. Dynamic verification is automatically triggered when executing \text{BYOB}\xspace blocks in the usual way. For static verification, a dedicated button located at the top right corner of the \text{BYOB}\xspace editor window allows to trigger the compilation of the \text{BYOB}\xspace code into an intended equivalent {\small\textsf{Boogie}}\xspace code. The compiled code can be then downloaded and verified with {\small\textsf{Boogie}}\xspace. {\small\textsf{Boogie}}\xspace can be run locally or on the cloud at \url{https://rise4fun.com/Boogie/}.
\emph{Dynamic verification} has been fully integrated into the normal execution flow of a {\small\textsf{Snap!}}\xspace\ program, and thus there is no real restrictions on the characteristics of the \text{BYOB}\xspace that can be dynamically verified.
For \emph{Static verification}, we have restricted data types to be Integers, Booleans and List of Integers. Moreover, we do not support dynamic typing of variables.
Finally, we only focus on compiling an interesting subset of {\small\textsf{Snap!}}\xspace blocks for the sake of teaching \textit{Design-by-Contract}\xspace.
\section{Introduction}
Research in deductive program verification has made substantial progress over the last years: tools and technique have been developed to reason about non-trivial programs written in widely-used programming languages, the level of automation has substantially increased, and bugs in widely-used libraries have been found \cite{DeGouwRBBH15,oortwijn2020automated,SOJH2020}. However, the use of deductive verification techniques remains the field of expert users, and substantial programming knowledge is necessary to appreciate the benefits of these techniques.
We believe that it is important to make deductive program verification techniques accessible also to novice programmers. Therefore, we have to teach the \textit{Design-by-Contract}\xspace~\cite{DBLP:journals/computer/Meyer92} (DbC) approach, which requires the programmer to explicitly specify the assumptions and responsibilities of code in a modular way, in parallel with actually teaching programming, i.e. DbC should be taught as an integral part of the process leading from design to implementation. In this paper, we make the \textit{Design-by-Contract}\xspace idea accessible to high school students, in combination with appropriate tool support, which is currently
unavailable.
Concretely, this paper presents a \textit{Design-by-Contract}\xspace approach for {\small\textsf{Snap!}}\xspace~\cite{harvey2013snap}. {\small\textsf{Snap!}}\xspace is a visual programming language targeting high school students. The design of {\small\textsf{Snap!}}\xspace is inspired by {\small\textsf{Scratch}}\xspace, another widely-used visual programming language. Compared to {\small\textsf{Scratch}}\xspace, {\small\textsf{Snap!}}\xspace has some more advanced programming features. In particular, {\small\textsf{Snap!}}\xspace provides the possibility to create parametrised reusable blocks, basically modelling user-defined functions. Also the look and feel of {\small\textsf{Snap!}}\xspace targets high school students, whereas {\small\textsf{Scratch}}\xspace aims at an even younger age group. {\small\textsf{Snap!}}\xspace has been successfully integrated in high school curricula, by its integration in the \emph{Beauty and Joy of Computing} course~\cite{DBLP:journals/inroads/GarciaHB15}. This course combines programming skills with a training in abstract computational thinking.
The first step to support \textit{Design-by-Contract}\xspace for {\small\textsf{Snap!}}\xspace is to define a suitable specification language. The visual specification language that we propose in this paper is built as a seamless extension of {\small\textsf{Snap!}}\xspace, i.e. we propose a number of new specification blocks and natural modifications of existing ones. These variations capture the main ingredients for the \textit{Design-by-Contract}\xspace approach, such as pre- and postconditions. Moreover, we also provide blocks to add assertions and loop invariants in a program and we extend the standard expression pallets of {\small\textsf{Snap!}}\xspace with some common expressions to ease specifications. The choice of specification constructs is inspired by existing specification languages for \textit{Design-by-Contract}\xspace, such as JML~\cite{Leavens99}, choosing the most frequently used constructs with a clear and intuitive meaning. Moreover, all verification blocks are carefully designed to reflect the intended semantics of the specifications in a visual way.
A main concern for a programmer, after writing the specification of the intended behaviour of their programs, should be to validate that these programs behave according to their specification. Therefore, we provide two kinds of tool support: (i)~runtime assertion checking~\cite{Cheon03}, which checks whether specifications are not violated during a particular program execution, and (ii)~static checking (or deductive verification)~\cite{leino1995towards}, which verifies that all possible program executions respect its specifications. The runtime assertion checker is built as an extension of the standard {\small\textsf{Snap!}}\xspace execution mechanism. The deductive verification support is built by providing a translation from a {\small\textsf{Snap!}}\xspace program into {\small\textsf{Boogie}}\xspace~\cite{DBLP:conf/fmco/BarnettCDJL05}.
Another important aspect to take into account for a good learning experience are the error messages that indicate that a specification is violated. We have integrated these messages in {\small\textsf{Snap!}}\xspace's standard error reporting system, again sticking to the look and feel of standard {\small\textsf{Snap!}}\xspace. Moreover, we have put in effort to make the error messages as clear as possible, so that also a relatively novice programmer can understand why the implementation deviates from the specification.
\section{Conclusions}
\label{sec:conclusion}
This paper presented a prototypal program verification extension to {\small\textsf{Snap!}}\xspace. The extension is intended to support the teaching of \textit{Design-by-Contract}\xspace in the later years of high schools. We paid considerable attention to the didactic aspects of our tool: the looks and feel of the extension should remain familiar to {\small\textsf{Snap!}}\xspace users, the syntax and structure of the new blocks should give a clear intuition about their semantics, and the error reporting should be precise and expressive.
Our extension allows to analyse \text{BYOB}\xspace blocks both by runtime assertion checking and static verification. Runtime assertion checking is fully integrated into {\small\textsf{Snap!}}\xspace and there is no limitation on the kind of blocks that can be analysed. Static verification compiles the {\small\textsf{Snap!}}\xspace code into a {\small\textsf{Boogie}}\xspace equivalent code and the verification needs to be run outside of {\small\textsf{Snap!}}\xspace. Moreover, we make some restrictions on the kind of \text{BYOB}\xspace blocks we can compile, in order to keep the complexity of the prototype low. As future work we would like to lift these restrictions as much as possible by integrating the remaining {\small\textsf{Snap!}}\xspace blocks into the compilation and by allowing other data types to be used. Also, we would like to integrate the verification into {\small\textsf{Snap!}}\xspace, translating {\small\textsf{Boogie}}\xspace messages back to the {\small\textsf{Snap!}}\xspace world, to help student to interpret them.
We would like to carry out an empirical study on our proposed approach. This will require the development of a concrete study plan and its evaluation in a Dutch classroom.
Computer science curricula that uses blocks programming is widely and freely available \cite{BJCGuide,GoogleCSFirst,CCC,PencilCodeManual,factorovich2015actividades}. Nevertheless, it is hardly spotted that they include topics around design and verification of code. The words `test' or `testing' are also rare around the curricula and, where mentioned, they are not sufficiently motivated. The drawbacks of teaching coding with blocks without paying attention to design nor correctness has already been analysed \cite{DBLP:conf/iticse/Meerbaum-SalantAB11,aivaloglou2016kids}. We have not found any work on teaching these concepts in schools, nor implementations on block programming that support teaching them. | {'timestamp': '2021-07-14T02:01:41', 'yymm': '2107', 'arxiv_id': '2107.05679', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05679'} | arxiv |
\section{Introduction}
A typical workflow of an autonomous vehicle involves three main steps: perception, planning, and control.
The estimation of the current state of the vehicle and its surroundings is performed by perception.
The sequence of states to be visited for safely navigating the environment is determined by planning.
And finally, the plan is realized through a control algorithm.
Crucially, these three steps assume that the vehicle has access to an accurate map of the environment that is either obtained from simultaneous localization and mapping or provided by the user.
In contrast to the above mentioned workflow, in this paper, we pursue \emph{reactive planning and control}.
Here, we assume that the map of the environment and the relative position of the vehicle are not known.
Instead, the vehicle generates the plan and control input purely based on the current data that it receives from the sensors.
Hence, the plan and the control inputs are generated \emph{on-the-fly}.
We believe that investigating reactive planning and control based approaches are useful in instances where the environment is highly dynamic or mapping of the environment has not yet been performed or is computationally very expensive.
Additionally, the same planning and control mechanisms can be deployed in a wide range of scenarios as it doesn't require any map.
One of the main drawbacks of reactive planning and control is that it is very challenging to prove that the safety and progress specifications are satisfied.
Since the map of the environment is not known, the waypoints generated during the motion planning are always relative to the vehicle.
Hence, as the vehicle navigates through the environment, the waypoint in the next instance also evolves.
\emph{This dynamic nature of the state of the vehicle and the waypoints makes the safety analysis very challenging.}
Furthermore, as the vehicle navigates through the environment, the new sensor readings could cause changes in the planned path making safety analysis a very challenging task.
In this paper, we perform safety and performance analysis of a reactive planning and control algorithm deployed on an autonomous vehicle that is navigating a race lap.
Our planner involves computing a Voronoi diagram of the walls visible to the perception and our control algorithm implements the pure-pursuit algorithm.
Our safety and performance analysis has two parts.
In the first part, we demonstrate that the waypoint computed by the reactive planner is consistent with the planner that has access to the full map.
In the second part, we model the co-evolution of the state of the vehicle and the waypoint as a hybrid automata and compute an artifact called \emph{reachable set}.
The reachable set contains all the configurations visited by the autonomous vehicle while realizing the plan using the pure-pursuit control algorithm.
We show that the reachable set is safe (no overlap with the boundaries of the race track) and achieves a fixed point after the vehicle completes a full lap.
This proves that the vehicle satisfies the safety specification while guaranteeing that it will eventually complete the lap.
We also employ abstraction techniques from hybrid systems literature~\cite{tiwari2002series,prabhakar2015hybrid} to improve the efficiency of the reachable set computation algorithm.
The primary contribution of this paper is to establish the safety and performance specification of reactive planning and control algorithm used for navigation of autonomous vehicles.
Unlike many approaches that strictly investigate safety of planning or safety of closed loop control behavior, we consider both these aspects at the same time for proving safety.
In addition, we also show the effectiveness of our reactive planning and control algorithm in two ways.
First, we develop a simulation environment of a race lap using Unreal engine and deploy the vehicle in various types of race tracks.
Second, we implement the algorithm on an open source hardware platform of F1Tenth, a scale down version of autonomous vehicle built on Traxxas RC car.
\section{Related work}
\label{sec:relwork}
Planning and control of autonomous vehicles as well as their safety verification has received a lot of attention in the recent past. A comprehensive survey of many of these techniques are provided in~\cite{paden2016survey,machines5010006}. In this section, we briefly discuss the various planning and control techniques and some of the verification techniques presented in the literature and contrast it with the techniques presented in this paper.
Planners for autonomous vehicles are often hierarchical in nature~\cite{miller2008team,urmson2008autonomous}. The task planner selects the high level task to be performed by the vehicle and the motion planner implements the task decided by the task planner. In this paper, since we are concerned with an autonomous racing vehicle, the task of the vehicle is to complete the lap. We hence focus our attention to the motion planning aspect of the vehicle.
Motion planning of autonomous vehicles is primarily divided into two methods. First are the geometric based planning methods where the sequence of waypoints for the vehicle are decided on the geometry of the configuration space~\cite{thrun2006stanley,montemerlo2008junior}. Planning based on Voronoi diagrams is one of the popular geometric techniques for planning~\cite{takahashi1989motion,shkolnik2009reachability}.
Second are the sampling based motion planning techniques.
In particular, RRTs~\cite{lavalle1998rapidly,karaman2011sampling} and PRMs~\cite{kavraki1996probabilistic} are two of the most influential techniques. In the literature, several variants of RRTs and PRMs specific to the domain of autonomous vehicles have been proposed~\cite{xu2012real,aoude2010threat,levinson2011towards,perez2012lqr,kant1986toward}. All of these techniques assume that a partial map of the environment is provided and the location of the vehicle in the map is known. In the case of reactive planning and control, we do not assume that a partial map of the system is known.
Reactive planning was proposed as an alternative to offline planning when all the information for completing a task are not available to the robot~\cite{georgeff1987reactive}, or when the environment is highly dynamic~\cite{belkhouche2009reactive} such as robot soccer~\cite{bruce2002real} or human collaborative environment~\cite{dumonteil2015reactive}.
Such reactive plans have been successfully deployed in robots that are resource constrained such as small-scale helicopters~\cite{redding2007real}, micro air vehicles~\cite{sharma2012reactive}, and autonomous sailboats~\cite{petres2011reactive}.
Additionally, reactive planners have also been used to modify an existing plan due to the presence of dynamic obstacles~\cite{moreau2019reactive,moreau2019reactive-be}.
Finally, when autonomous vehicles have to satisfy service requests along liveness specification given according to a temporal logic formula, a reactive sampling based motion planning algorithm has been used~\cite{vasile2014reactive,vasile2020reactive}.
Control of autonomous vehicles are also divided into two categories, geometric and model based. In geometric control techniques, the underlying geometric properties of the bicycle model are used in order to make the vehicle reach its destination. Two popular geometric control techniques are pure-pursuit~\cite{park2014development,Snider.2009} and Stanley~\cite{hoffmann2007autonomous}. These techniques are intuitive and easy to implement.
Model based control techniques assume a given model of the vehicle and generate control inputs depending on the model~\cite{de1998feedback,murray1993nonholonomic}. Model predictive control based methods that are path tracking, unconstrained, and with dynamic car model have been proposed in the literature~\cite{falcone2007predictive,falcone2008linear,raffo2009predictive}. In fact, MPC based control methods have been used in other autonomous racing vehicles~\cite{talvala2011pushing}.
In safety analysis of mobile robots, synthesis of safe plan based on temporal logic specification has received a lot of attention~\cite{kress2009temporal,fainekos2009temporal,Kloetzertemp}. For proving the safety of the control algorithms, various reachable set computation methods have been proposed and evaluated for behavior of an autonomous vehicle at different scenarios~\cite{AlthoffDolan,LygerosSastry,ACCVerified,ACCTwoApproaches}.
Given a map of the environment, accurate sensors, noise free localization, and accurate model of the vehicle dynamics, it is possible to provide a sequence of waypoints for moving along the track and prove that the vehicle finishes the lap without colliding with any obstacles using standard reachability based techniques.
However, in this paper, we consider reactive planning and control, where the waypoint dynamically changes along with the vehicle position and orientation.
The works that are closest to the current work are~\cite{Das.2011} and ~\cite{Dolgov.2010}. In both these works, the plan of the vehicle is based on computing the Voronoi diagram. In~\cite{Das.2011}, the authors do not precisely model the interaction between the waypoint decided by the planner and the control algorithm and hence do not provide any safety guarantees even when the track is known apriori. In~\cite{Dolgov.2010}, in contrast to our work, the authors assume that a partial map of the environment is known. Furthermore, they do not provide any safety guarantees assuming an uncertainty in the initial conditions of the vehicle.
\section{Preliminaries}
\subimport{}{4-4-problemdefn.tex}
\subimport{}{4-2-purepursuit.tex}
\subsection{Perception}
The perception module linearizes the laser scan.
The laser scan is a 2-dimensional point cloud,
in the form of an array of distances measured at increasing angles.
We linearize this point cloud with a one-pass algorithm that ensures that
the interpolation error is bounded by a given value.
This gives us a sequence of line segments that represents the perceived obstacles around the car.
These line segments are the input to the Planner.
\begin{figure}
\centering
\includegraphics[width=88mm]{Figures/Planning.png}%
\label{fig:plan}%
\caption{The area visible by the laser scan is colored as red,
the linearized laser scan is in green,
the roadmap is in blue,
and the plan is in white.
The Pure Pursuit goal is a red dot on the lookahead circle.
The midpoint of the discontinuity of the (linearized) laser scan is a gray point.}
\end{figure}
\subsection{Bicycle model of the car}
\begin{figure}
\centering
\includegraphics[width=85mm]{Figures/BicycleModel.pdf}%
\caption{Bicycle model \cite{Snider.2009}}
\label{fig:bicycle}%
\end{figure}
In this model (Figure~\ref{fig:bicycle}),
the assumption is that no wheel has lateral slippage.
Therefore,
if the steering angle is $\delta > 0$ and the wheelbase is $L$,
then the rear wheel moves on a circle of radius $R$ where
\begin{equation}
R = \frac{L}{tan(\delta)}.
\end{equation}
\subsection{Hybrid System}
\begin{definition}
\label{def:hybridSystem}
A \emph{hybrid system} $H$ is defined to be a tuple $\tup{Loc, X, Flow, Inv, Trans, Guard}$ where:
\begin{description}
\item[$Loc$] is a finite set of locations (also called modes).
\item[$X$] $\subseteq \mathbb{R}^n$ is the state space of the behaviors.
\item[$Flow$] $: Loc \rightarrow F(X)$ assigns a differential equation $\dot{x} = f(x)$ for each location of the hybrid system.
\item[$Inv$] $: Loc \rightarrow 2^{\reals^n}$ assigns an invariant set for each location of the hybrid system.
\item[$Trans$] $\subseteq Loc \times Loc$ is the set of discrete transitions.
\item[$Guard$] $: Trans \rightarrow 2^{\reals^n}$ defines the set of states where a discrete transition is enabled.
\end{description}
The invariants and guards are given as the conjunction of linear or non-linear constraints. The \textit{initial set of states} $\Theta$ is a subset of $Loc \times 2^{\reals^n}$. An \textit{initial state} $q_0$ is a pair $(Loc_0, x_0)$, such that $x_0 \in X$, and
$(Loc_0, x_0) \in \Theta$.
\end{definition}
\vspace{0.2cm}
\begin{definition}
\label{def:hybridExecution}
Given a hybrid system $H$ and an initial set of states $\Theta$, an execution of $H$ is a sequence of trajectories and transitions $\xi_0 a_1 \xi_1 a_2 \ldots $ such that
(i) the first state of $\xi_0$ denoted as $q_0$ is in the initial set, i.e., $q_0 = (Loc_0, x_0)\in \Theta$,
(ii) each trajectory $\xi_i$ is the solution of the differential equation of the corresponding location $Loc_i$,
(iii) all the states in the trajectory $\xi_i$ respect the invariant of the location $Loc_i$,
and (iv) the state of the trajectory before each transition $a_i$ satisfies $Guard(a_i)$.
\end{definition}
The set of states encountered by all executions that conform to the above semantics is called the \emph{reachable set} and is denoted as $Reach_{H}^{\Theta}$. Bounded-time variant of these executions and the reachable set is defined over the time bound $T$. We abuse the term \emph{trajectory} to denote the hybrid system execution as well as the solution of the differential equation of a location.
\vspace{0.2cm}
\begin{definition}
\label{def:hybridSafe}
A hybrid system $H$ with initial set $\Theta$, time bound $T$, and unsafe set $U \subseteq \mathbb{R}^n$ is said to be safe with respect to its executions if all trajectories starting from $\Theta$ for bounded time $T$ are safe i.e., $Reach_{H}^{\Theta} \cap U = \emptyset$.
\end{definition}
\subsection{Bicycle model of a car}
\begin{figure}
\centering
\includegraphics[width=45mm]{Figures/BicycleModel-coords.pdf}%
\caption{Bicycle model \cite{Snider.2009}}
\label{fig:bicycle}%
\end{figure}
Our formal analysis is based on the
bicycle model of a car, where we imagine that there is one rear wheel at the center of the rear axle and one front wheel at the center of the front axle.
We assume no wheel slippage, and only the front wheel can steer.
This model defines a dynamical system.
The \emph{state} of the system at time $t$
is described by the triple $(x(t), y(t), \theta(t))$
where $(x, y)$ are the coordinates of the rear wheel
in some inertial frame, say the racing track, and
$\theta$ is the angle of the heading direction of the bicycle measured from the $x$-axis counter-clockwise.
If $v$ is the speed (magnitude of velocity) of the rear wheel,
$L$ is the \emph{wheelbase} (distance between the rear and front wheels),
and $\delta$ is the steering angle,
then
\[
\left\{
\begin{array}{l}
\dot{x} = v \cdot cos(\theta) \\
\dot{y} = v \cdot sin(\theta) \\
\dot{\theta} = \frac{\displaystyle v}{L} tan(\delta)
\end{array}
\right.
\]
Illustration of the bicycle model of the vehicle is provided in Figure~\ref{fig:bicycle}.
\subsection{Problem definition}
Consider that an autonomous vehicle is tasked to complete a circuit track without hitting the borders of the track.
Completing the track is a \emph{progress} requirement, and avoiding the track boundaries is a \emph{safety} requirement.
Furthermore, the planning and control algorithms are required to be \emph{reactive}: at each time step, steering and speed controls are calculated from the current sensor data only.
Assuming that there is no lateral wheel slippage,
we can isolate the problem of finding the steering control from finding the velocity control.
This is because if a wheel does not slip laterally, it will move along its direction and so the shape (i.e. footprint) of the trajectory only depends on the steering angle.
In other words, the shape of the trajectory is not influenced by the speed, as long as the speed is nonzero.
In this paper, we present a simple reactive planner and controller and formally analyze its safety and progress properties.
\section{Planning and Control}
In this section we describe our planning and control algorithms which are a variation of Voronoi-based planning \cite{Das.2011} and geometric control \cite{Snider.2009}.
The safety and progress properties of our algorithms will be formally analyzed and experimentally validated in subsequent sections.
\label{sec:percp-plan-control}
\input{sections/5-2-planner}
\input{sections/5-3-controller}
\input{sections/5-4-evaluation}
\subsection{The Planner}
\label{sec:voronoiplanner}
Our planner is \emph{reactive} in the sense that it does not remember its past inputs or outputs.
The input is simply a 2D point-cloud from lidar, and the output is a 2D \emph{waypoint} passed to the controller.
We assume that the environment is polygonal.
The planner calculates a Voronoi diagram corresponding to the point-cloud, then it chooses a point on the Voronoi diagram as the waypoint.
The first step is to calculate a Voronoi diagram.
Since the environment is polygonal, the planner converts the 2D point cloud to a set of line segments based on co-linearity and connectivity thresholds.
\emph{Co-linearity threshold} determines the minimum angle between consecutive line segments of a polyline.
\emph{Connectivity threshold} determines the minimum distance between two co-linear line segments.
Representing a set of points by a line segment simplifies the computation and representation of the Voronoi diagram.
Since the input to the Voronoi computation is a set of line segments, the Voronoi edges are either linear or parabolic arcs.
After computing the Voronoi diagram, we approximate each parabolic edge by a polyline using a \emph{deviation threshold}.
The \emph{deviation threshold} determines the maximum distance of the points on a parabolic arc from the approximating polyline.
This linear approximation simplifies the planner and its formal analysis.
A Voronoi diagram calculated by the planner is called a \emph{local} Voronoi diagram since it is computed for the point-cloud visible from lidar.
This is in contrast to the \emph{global} Voronoi diagram where the diagram is computed with respect to the whole polygonal environment (which is not available to the car).
The next step is to choose a waypoint based on the local Voronoi diagram.
We choose a point \emph{on} the Voronoi diagram to try to stay as far as possible from the track walls (i.e. to be as safe as possible).
If the waypoint is too close or too far from the vehicle, the controller may make the car steer too sharply or slowly.
We choose among the points at a fixed distance from the center of the rear axle.
This distance is called the \emph{lookahead distance} and the corresponding circle is called the \emph{lookahead circle}.
The lookahead circle may intersect the Voronoi diagram in more than one point, so we need to choose among them.
Since the goal is to make the car progress towards finishing the track, the intersection point further along the heading direction of the car is selected as the waypoint.
\subsection{The Controller}
\label{sec:ppcontroller}
The pure-pursuit controller~\cite{Amidi.1991}
as formulated in~\cite{Snider.2009} is used to determine the steering angle.
This simple controller was ``the most stable and accurate tracker"
of the three methods tested in~\cite{Amidi.1991}.
Furthermore, pure-pursuit performed
``fairly well and is quite robust to large errors and discontinuous paths" in comparison to a few more complicated (geometric, kinematic or dynamic) controllers~\cite{Snider.2009}.
\begin{figure}
\centering
\includegraphics[width=60mm]{Figures/Purepursuit.png}%
\caption{Purepursuit controller \cite{Snider.2009}.}
\label{fig:purepursuit}%
\end{figure}
The input to the pure-pursuit controller is a waypoint described in the car's \emph{rear-axle coordinates}.
The origin of the rear axle coordinates is the center of the rear axle, the x-axis is the heading of the car, and the heading of the y-axis is 90 degrees counterclockwise from the x-axis.
The output is the steering angle $\delta$ for the bicycle model of a car.
Let $(g_x, g_y)$ be the coordinates of the waypoint in the rear-axle frame.
Note that the lookahead distance $\ell$ is $\sqrt{g_x^2+g_y^2}$.
If $L$ is the \emph{wheelbase} of the car (i.e. distance between rear and front axles), then the pure-pursuit steering angle $\delta$ is\footnote{See \cite{Snider.2009} for the derivation of the formula.}
\begin{align}
\delta & = tan^{-1}(\frac{2Lsin(\alpha)}{\ell}) \nonumber \\
& = tan^{-1}(\frac{2L g_y}{\ell^2})
\label{eqn:purepursuit}
\end{align}
Note that this formula is valid even when the waypoint is on the right of the car,
where $\alpha$, $g_y$ and $\delta$ are all negative.
This formula is valid only when $g_x > 0$
i.e. when the waypoint is on the front of the rear axle.
In this case,
we have $\frac{-\pi}{2} < \delta < \frac{\pi}{2} $.
In practice,
$-\delta_{max} \leq \delta \leq \delta_{max} $
where $\delta_{max} < \frac{\pi}{2}$ is the maximum possible angle that the car can steer.
For example,
the maximum steering angle for the Traxxas car in the open source hardware platform of F1Tenth vehicle is about $34$ degrees.
\section{Evaluation of Planning and Control in Simulation and Noisy Environments}
\subimport{}{5-6-simulation.tex}
\subimport{}{5-7-physical_validation.tex}
\subsection{Computer simulations}
We have built a virtual environment including various racing circuits in Unreal Engine for testing the reactive planning and control algorithm.
Some of these tracks are provided in Figure~\ref{fig:simulation_tracks}.
The tracks in the left column are similar to the tracks on which F1Tenth competitions \cite{f1tenth} were conducted.
Other tracks include a triangular track, and a straight track with static obstacles.
We have also tested the simulation on some polygonal tracks for which we will provide formal analysis in the subsequent sections.
Videos of these simulations are available on the web.\footnote{\url{https://tinyurl.com/ry5xhza}}
In total, of the nine different laps that we have tested, our algorithm was able to successfully able to complete a lap while not colliding with any of the race track boundaries or obstacles.
\begin{figure}[!t]
\centering
\includegraphics[width=0.8\columnwidth]{Figures/sim-tracks.png}
\caption{Racing tracks for the simulations.}
\label{fig:simulation_tracks}
\end{figure}
The vehicle used in the simulations is the vehicle from Unreal Engine 4.21's `Vehicle Advanced' template project.
The default tire friction constants are increased to avoid wheel slippage.
We have implemented a model of Hokuyo UST-10LX LiDAR in Unreal Engine.
The measurements are taken using Unreal Engine's line tracing.
We do not model measurement errors and uncertainty.
\subsection{Physical validation}
We also have tested the planner and controller on the open source hardware platform of F1Tenth vehicle.
This is to show the practicality of our simple reactive planning and control in the presence of noise, unstructured environment, and limited computational resource.
For example, Hokuyo UST-10LX LiDAR provides a new point-cloud every 25 milliseconds, but our planning and control is an order of magnitude faster on the Nvidia Jetson TX2's CPU so we can process every point-cloud.
We tested the car in two tracks.
The simpler one is shown in Fig.~\ref{fig:physical_track} where the track boundaries is mostly structured using corrugated cardboard rolls.
The harder track (provided in the videos) is an office with chairs and tables around the office walls and in the middle of the office.
Our algorithm manages to successfully complete a lap while avoiding obstacles on both these tracks.
\begin{figure}[!t]
\centering
\includegraphics[width=85mm]{Figures/physical_track.png}
\caption{Physical validations.}
\label{fig:physical_track}
\end{figure}
\section{Rigorous Analysis of Planning and Control Algorithms for Safety and Progress Properties}
\label{sec:rigorous}
In this section we perform rigorous analysis of the Voronoi planning along with pure-pursuit controller.
We prove that the vehicle would not hit any of the walls and will successfully complete a lap when its starting position belongs to a defined set of initial states.
Our analysis has two parts: the first part is about the properties of the planner and the second part is about the closed loop behavior of the vehicle.
In the first part, we prove that the \emph{local Voronoi diagram} computed by the vehicle from its current environment will be consistent with the \emph{global Voronoi diagram} under certain conditions.
This consistency ensures that the reactive path planning performed by the robot is equivalent to the path planning performed while having access to the map.
The second part of analysis requires computing an artifact called \emph{reachable set} of the closed loop vehicle dynamics.
Given a set of initial positions for the vehicle, the reachable set includes all the set of states visited by the trajectories starting from the set.
We demonstrate that the reachable set does not overlap with any of the walls and achieves a fixed point after finishing the lap, thus proving the safety and progress properties.
\subimport{}{6-1-voronoi.tex}
\import{}{6-2-system_model.tex}
\import{}{6-3-reachable-set.tex}
\subsection{Consistency of local Voronoi diagrams}
\label{sec:localVoronoi}
In this section, we prove that the Voronoi diagram computed by the vehicle with a given lidar scan is consistent with the global Voronoi diagram computed from the map.
Intuitively, this proof formalizes the notion that a lidar with a sufficiently long range can detect all the edges for computing the Voronoi diagram for a small neighborhood.
The proof will formalize the requirements on the track and the range of the lidar.
At each point in time, only a subset of the walls are \emph{visible} to the lidar, i.e. all the walls in its range that are not occluded.
A \emph{local Voronoi diagram} is the Voronoi diagram of the visible walls.
The \emph{global Voronoi diagram} is the Voronoi diagram of all walls.
The planner chooses the waypoint from the intersection of the local Voronoi diagram and the lookahead circle.
Recall that the \emph{lookahead circle} is a circle of fixed radius centered at the rear axle of the car.
We also assume that the lidar is placed at the middle of the front axle of the car.
We give sufficient conditions such that within the lookahead circle the local and global Voronoi diagrams coincide.
Consider the visible subset of the walls, the local Voronoi diagram, and the lookahead circle at some arbitrary time.
Pick a point $p$ on the global Voronoi diagram inside the lookahead circle.
We give sufficient conditions such that the closest wall points to $p$ in the global Voronoi diagram are visible to the lidar.
Thus, $p$ is also on the local Voronoi diagram.
The sufficient conditions rule out the two possible cases for invisibility of the closest wall points: being out of range, or occluded by a visible point.
Let $R$ be the range of lidar,
$L$ the distance from lidar to the rear axle,
$\ell$ the lookahead radius,
$m$ the minimum width of the track,
$M$ the maximum width of the track,
and $D$ the minimum distance between lidar and the walls at any point in time.
Then we have the following guarantee:
\begin{theorem}
The local and global Voronoi diagrams coincide within the lookahead circle if
\begin{align}
R > M, \\
R > L + \ell + \frac{M}{2}, \label{eq:lidar-range-b} \\
\textnormal{and, } D^2 \geq (L+\ell)^2-\frac{m^2}{4}.\label{eq:lidar-wall-distance}
\end{align}
\label{thm:voronoi}
\end{theorem}
Before proving Theorem~\ref{thm:voronoi}, we will prove a lemma about the relationship between lookahead circle, walls of the circuit, and distance between a point on the Voronoi diagram and the walls.
\begin{lemma}
\begin{enumerate}
\item Any point on (local or global) Voronoi diagrams is at most $\frac{M}{2}$ away from its closest walls.
\item Lookahead disk is contained in the circle $C_{L+\ell}$ of radius $L+\ell$ centered at lidar.
\item For any point $p$ on the global Voronoi diagram inside $C_{L+\ell}$, $p$'s closest walls are in lidar's range.
\end{enumerate}
\end{lemma}
\begin{proof}
\begin{enumerate}
\item
Lidar can see its closest walls since $R>M$. Furthermore, a point on the Voronoi diagram is equidistant to its closest walls.
\item
The distance from lidar to rear axle is $L$, and lookahead circle is the circle of radius $\ell$ centered at the rear axle.
\item
The closest wall points to $p$ are in the circle of radius $L+\ell+\frac{M}{2}$ centered at lidar. By Equation \ref{eq:lidar-range-b}, $p$'s closest wall points are in lidar's range.
\end{enumerate}
\end{proof}
\begin{proof}[Proof of Theorem \ref{thm:voronoi}]
We need to show that for any point $p$ on the global Voronoi diagram, if $p$ is inside the lookahead circle then $p$'s closest walls are visible from lidar, so that $p$ is also on the local Voronoi diagram.
By the lemma, the circle $C_{L+\ell}$ of radius $L+\ell$ centered at lidar contains the lookahead circle, so it is sufficient to assume that $p$ is in $C_{L+\ell}$.
Consider an arbitrary visible wall point $w$ occluding a wall point $u$.
That is, both $w$ and $u$ are on the same ray from lidar but $u$ is further away than $w$.
We show that $p$ is closer to $w$ than $u$.
Let $d$ be the distance of lidar to $w$ and $c$ be the distance of $w$ to $u$ (so the distance of lidar to $u$ is $d+c$).
First note that there is no Voronoi point inside the circle $C_{u, \frac{m}{2}}$ of radius $\frac{m}{2}$ centered at $u$, since $m$ is the minimum width of the track.
Also, the points that are closer to $u$ than $w$ constitute a half-plane $H$ with distance $d+\frac{c}{2}$ from lidar and its boundary being the bisector of $u$ and $w$.
Hence Voronoi points that are closer to $u$ than $w$ are in $H\setminus C_{u, \frac{m}{2}}$ i.e. in $H$ and outside of $C_{u, \frac{m}{2}}$.
See Fig. \ref{fig:voronoi-proof}.
If
$(d+\frac{c}{2})^2 + \frac{m^2}{4} - \frac{c^2}{4} > (L+\ell)^2$
or equivalently
$ d^2+dc > (L+\ell)^2-\frac{m^2}{4} $
then $C_{L+\ell}$ does not intersect $H\setminus C_{u, \frac{m}{2}}$.
The stronger condition
\begin{equation}
d^2 \geq (L+\ell)^2-\frac{m^2}{4}
\end{equation}
ensures that a global Voronoi point inside $C_{L+\ell}$ is closer to $w$ than any wall point in $w$'s shadow.
This inequality is guaranteed by Inequality \ref{eq:lidar-wall-distance}, since $D$ is the minimum distance of lidar to walls so $d^2 \geq D^2$.
\end{proof}
Observe that Theorem~\ref{thm:voronoi} gives us some bounds on the size of the lookahead circle.
The lookahead circle cannot be too large, else, the closest walls to a points in the lookahead circle might be occluded from the lidar.
\begin{figure}
\centering
\includegraphics[width=2.5in]{Figures/voronoi-proof-shadow-distant.pdf}
\caption{Consistency of local and global Voronoi diagrams. The blue curve is the global Voronoi diagram. The green dot is lidar, and the pink dot is the waypoint. The gray area is $H\setminus C_{u, \frac{m}{2}}$. }
\label{fig:voronoi-proof}
\end{figure}
\subsection{Coupled model of control and plan}
\label{sec:model}
As described in Section~\ref{sec:ppcontroller}, the pure-pursuit controller determines the steering angle $\delta$ according to the waypoint $(g_x, g_y)$ by the planner (given in Equation~\ref{eqn:purepursuit}).
This waypoint lies on the local Voronoi diagram and always at a distance $\ell$ from the rear-axel.
When the conditions given in Theorem~\ref{thm:voronoi} are satisfied, the waypoint also lies on the global Voronoi diagram.
Given that the Voronoi diagram is a conjunction of several line segments, without loss of generality, we assume that the waypoint lies on one such line segment.
Observe that as the vehicle moves towards the waypoint, the position and orientation of the vehicle changes.
This indeed changes the intersection of the lookahead circle with the Voronoi diagram and as a result, changes the waypoint.
Thus, the evolution of the state of the vehicle (position and orientation) and the waypoint are tightly coupled.
In this section, we model the joint behavior of the waypoint along with the vehicle dynamics.
Observe that for pure-pursuit controller, the waypoint $(g_x, g_y)$ is described in the vehicle's coordinate system (i.e., the origin being the center of the rear-axel and the orientation of the vehicle as the x-axis).
We transform this waypoint along the coordinate axis where the Voronoi line segment is the x-axis, the rear wheel has coordinates $(x,y)$ and the orientation of the vehicle $\theta$ is w.r.t the line segment on the Voronoi diagram.
After the coordinate transformation, the orientation $\delta$ in this coordinate system will be
$$ tan(\delta) = \frac{2L}{\ell^2} (-\sqrt{\ell^2-y^2} \cdot sin(\theta)-y \cdot cos(\theta)). $$
Therefore,
\begin{align}
\dot{\theta} & = \frac{\displaystyle v}{\displaystyle L} \frac{\displaystyle 2L}{\displaystyle \ell^2} (-\sqrt{\ell^2-y^2} \cdot sin(\theta)-y \cdot cos(\theta)) \nonumber \\
& = \frac{\displaystyle 2v}{\displaystyle \ell^2} (-\sqrt{\ell^2-y^2} \cdot sin(\theta)-y \cdot cos(\theta))
\end{align}
The closed loop behavior of the vehicle dynamics is therefore given as:
\[
\begin{array}{l}
\dot{x} = v \cdot cos(\theta) \\
\dot{y} = v \cdot sin(\theta) \\
\dot{\theta} = \frac{\displaystyle 2v}{\displaystyle \ell^2} (-\sqrt{\ell^2-y^2} \cdot sin(\theta)-y \cdot cos(\theta))
\end{array}
\]
Notice that this closed loop behavior is accurate as long as the waypoint lies on the same line segment.
When the vehicle makes progress, the lookahead circle would intersect with a different line segment on the voronoi diagram.
As a result, the coordinate system for modeling the evolution of vehicle state and the waypoint changes.
We model this change as a hybrid automata.
\begin{definition}
A hybrid automata is defined as a tuple $\langle Mod, X, E, Flows \rangle$ where
\begin{itemize}
\item \textbf{$Modes$} is the set of discrete modes,
\item \textbf{$X$} is the state space,
\item \textbf{$E$} is the set of discrete transitions among modes, and
\item \textbf{$Flows$} describes the evolution of the system in each mode.
\end{itemize}
\end{definition}
Often, $Flows$ are described as a collection of nonlinear differential equations, one for each mode.
Each discrete transition $e = (mode, mode') \in E$ among the modes $mode, mode' \in Modes$ of the hybrid automata has an associated $guard(e)$ condition. The hybrid automata can take the transition only when the state of the trajectory satisfies the guard condition.
Additionally, after taking the discrete transition $e$, the state of the system changes from its current state $x$ to a new state $x'$ defined according to a reset function $x' = reset(e,x)$.
In the case of the vehicle following the waypoint on Voronoi diagram, when a new line segment is encountered by the lookahead circle, the change of basis variables (alignment of the x-axis along the new segment) is the reset function.
Notice that the set of states that take this transition lies on a circle of radius $\ell$ from an end point of the new line segment.
This set is a non-convex set.
Performing analysis on such hybrid automata with non-convex guard conditions is very challenging.
We therefore construct an abstract hybrid automata that allows more behaviors than the original hybrid automata, but is easier to analyze.
More specifically, we allow the hybrid automata to non-deterministically take a transition whenever the vehicle enters the convex overapproximation of the original guard condition.
Given that we strictly increase the set of possible states that can take the discrete transitions, it is easy to observe that the abstract hybrid automata includes all the behaviors of the original hybrid automata.
Illustration of the abstraction of the guard condition for hybrid automata modeling the behavior of the vehicle is given in Figure~\ref{fig:guard_inv_approx}.
Given a circuit, we construct the hybrid automata model of the vehicle moving in the lap using our Voronoi planning and pure pursuit control algorithm.
In the next section, we present the details of the techniques employed to prove the safety and progress properties of the vehicle.
\begin{figure}
\centering
\includegraphics[width=0.8\linewidth]{Figures/rss2021-guard-approximate.png}
\caption{Over-approximation of guard. $l$ is the look ahead distance of the car. The original exact guard is circular and we linearize it as a convex polytope that is defined using linear constraints.}
\label{fig:guard_inv_approx}
\end{figure}
\subsection{Reachable Set Computation}
\begin{definition}
Given a hybrid system $H$ modeled as an hybrid automaton and an initial set of states $\Theta$, an execution of $H$ is a sequence of trajectories and transitions $\xi_0 e_1 \xi_1 e_2 \ldots $ such that
(i) the first state of $\xi_0$ denoted as $q_0$ is in the initial set, i.e., $q_0 = (mode_0, x_0)\in \Theta$,
(ii) each trajectory $\xi_i$ is the solution of the differential equation $Flows_{i}$ of the corresponding mode $mode_i$,
(iii) the state of the trajectory before each discrete transition $e_i = (mode_i, mode_{i+1})$ satisfies $guard(e_i)$,
(iv) and the state of the trajectory after taking the transition $e_i$ changes to $q_{i+1} = (mode_{i+1}, x_{i+1})$ where $x_{i+1} = reset (e_i, x_i)$.
\end{definition}
The set of states encountered by all executions that conform to the above semantics is called the \emph{reachable set} and is denoted as $Reach_{[H, \Theta]}$. Bounded-time variant of these executions and the reachable set defined over the time bound $T$ is denoted as $Reach_{[H, \Theta]}^T$. We drop $H$ and/or $\Theta$ from $Reach_{[H, \Theta]}^T$ whenever it is clear from the context, and abuse the term \emph{trajectory} to denote the hybrid system execution as well as the solution of the differential equation of a mode.
We say the reachable set computation has a \emph{fixed point at time $t$} when there exists $t \leq T$ such that $Reach^t = Reach^{t+1}$.
Since it is computationally hard to compute the exact reachable set for most system classes including hybrid systems ~\cite{ALUR19953,10.1007/3-540-46430-1_6}, a verification engine is typically used to compute an overapproximation of the reachable set denoted as $\tilde{Reach^T}$. Given the sequence of reachable set computed at discrete time instances, the $i^{th}$ element in the is denoted as $Reach^T[i]$.
\vspace{0.2cm}
\begin{definition}
\label{def:hybridSafe}
A hybrid system $H$ with initial set $\Theta$, time bound $T$, and unsafe set $U$ is said to be safe with respect to its executions if all trajectories starting from $\Theta$ for bounded time $T$ are safe i.e., $\tilde{Reach^T} \cap U = \emptyset$.
\end{definition}
As the reachable set overapproximation $\tilde{Reach^T}$ includes more behaviors than the exact reachable set, its safety w.r.t. $U$ proves the safety of the exact reachable set w.r.t. $U$. However, the safety result is inconclusive when $\tilde{Reach^T} \cap U \neq \emptyset$. We next discuss the fixed point based computation of the reachable set for a given initial set $\Theta$.
\begin{itemize}[leftmargin=*]
\item \textbf{Computing a Fixed Point :} Recall that the vehicle motion for a given circuit is modeled as the hybrid automata where each mode is associated with an edge from the global Voronoi diagram.
We denote the lap as one full pass of the given circuit which is the sequence of edges from the global Voronoi diagram such that an end point of the last segment coincides with an initial point of the first segment. Informally, the number of laps represents the number of passes of the given circuit performed by the vehicle.
As the vehicle completes one lap while following Voronoi edges by switching modes of the hybrid automaton, it may not arrive back at the exact system state it initially started from. As a consequence, the set of states reachable in a mode during next lap is not necessarily same as the set of states reachable in this mode during previous lap(s). Whereas, a fixed point at some time $t$ is an evidence that the set of reachable states beyond time $t$ is time-invariant.
Computing a fixed point for the reachable set serves three important purposes - (i) arriving at the same mode(s) after completing a lap underscores \emph{progress}, (ii) safety of the fixed point at $t$ ensures \emph{safety} of the reachable set at all times beyond $t$, (iii) it makes the analysis \emph{efficient} because one can save a significant amount of computational resources by not requiring to compute the reachable set after $t$ for a much larger initial set as explained next.
\item \textbf{Computing additional reachable sets :} The error bound of reachable set overapproximation is proportional to the size of the initial set $\Theta$, i.e., larger the initial set, higher is the overapproximation error.
Whereas, computing the reachable set for each state in the infinite state system as ours is practically impossible.
The standard approach for handling this trade-off is to refine the large initial set into smaller subsets and perform reachable set computation on each subset.
A fixed point can assist in accelerating the reachable set computation for a large set $\Theta$. For any two given sets $\theta, \theta' \in \Theta$, it may not be necessary to compute the fixed point of $Reach_{\theta'}$ once the fixed point $Reach_{\theta}^t$ at time $t$ is obtained.
While computing $Reach_{\theta'}$, we iteratively check whether $Reach_{\theta'}^i[i] \subseteq Reach_{\theta}^t[i], i \leq t$, and halt the computation as soon as the containment check returns true.
Generalizing this approach to more than two sets would mean computing the fixed point of one set and perform the containment check for the rest w.r.t. the fixed point.
\item \textbf{Refinement techniques :} One way to computing the reachable set for a large set $\Theta$ is to \emph{manually} obtain the fixed point candidate $\theta \in \Theta$, and find the partitions $\theta' \in \Theta, \theta \cup \theta' = \Theta$ such that each partition has its reachable set at some $i \leq t$ contained in the fixed point.
An efficient strategy is to \emph{automatically} obtain both the fixed point candidate and other partitions. If the overapproximation error is too high for the given set $\Theta$, it is automatically refined into multiple sets.
One of these subsets is picked for the fixed point candidacy. If the overapproximation error for the candidate set is still high, it is further divided into parts until a candidate with its fixed point at some $t$ is found. The rest of $\Theta$ is automatically partitioned depending on whether their reachable sets are contained in the fixed point at $i \leq t$ or not.
\end{itemize}
\section{Evaluation}
In this section, we evaluate our fixed-point based reachable set computation on five different tracks with different characteristics.
For each track given as the sequence of global Voronoi diagram edges, a new hybrid automaton model for the evolution of vehicle along this track is generated. Typically, a hybrid automata has as many discrete modes as the number of Voronoi edges.
The dynamics in each mode of the automaton is the closed loop behavior of the vehicle dynamics and the way point as described in Section~\ref{sec:model}.
Then, we employ a non-linear hybrid systems verification tool to computed the fixed point of the reachable set for each track.
The computation of a fixed point in each track underscores both safety and progress of the vehicle.
In addition, we tested the planning and control algorithm both in simulation and open source F1Tenth platform.\footnote{\url{https://tinyurl.com/ry5xhza}}
\subimport{}{8-1-verification.tex}
\subsection{Safety Verification}
\begin{figure*}
\centering
\subfigure[for small initial set]{\label{fig:track1_voronoi-cora}\includegraphics[width=3.2in]{Figures/tracks/track1-voronoi-cora.jpg}}
\subfigure[for a large initial set]{\label{fig:track1_cora-abstraction}\includegraphics[width=3.2in]{Figures/tracks/reachMap-obstacle_zoomed.png}}
\caption{\textbf{Reachable set computation for Track-1}. In Fig.~\ref{fig:track1_voronoi-cora}, the fixed point is obtained in mode 3 in the second lap. The filled black rectangle depicts the initial set. In Fig.~\ref{fig:track1_cora-abstraction}, the smaller rectangle corresponds to the fixed point partition and larger one is the originally given initial set.}
\label{fig:eval_track1}
\end{figure*}
We experiment with multiple safety verification platforms such as CORA~\cite{Althoff2018b}, Flow*~\cite{10.1007/978-3-642-39799-8_18}, and C2E2~\cite{Duggirala.2015} for non-linear hybrid systems. Different platforms use different symbolic representations for the reachable set. For instance, Flow* uses Taylor models, C2E2 uses Jacobian matrix and discrepancy functions, and CORA primarily makes use of zonotopes for representing the reachable sets. As their utility is application specific, we observed that overapproximation error in both C2E2 and Flow* is very high for our case studies. One possible reason could be that Taylor model approximation in Flow* and discrepancy function computed in C2E2 are too conservative. We illustrate the reachable set accuracy across Flow* and CORA on a small system in Section~\ref{subsec:appendix-reach-set-accuracy} in the Appendix.
In the safety verification of our dynamical model, the obstacles or walls constitute the unsafe set i.e., the objective is to verify that the reachable set does not overlap with the walls.
The initial set considered during reachable set computation in track-1 is $x \in [-0.3, 0.3]$, $y \in [-0.3, 0.3]$ and $\theta \in [-0.2, 0.2]$.
The Voronoi diagram and the corresponding reachable set for track-1 are shown in Fig.~\ref{fig:track1_voronoi-cora}. Based on the track width, the turns in this track encompass 4 different transitions - wide to narrow, wide to wide, narrow to narrow, and narrow to wide.
Also observe that the fixed point of the reachable set computation is obtained in \emph{mode 3} in lap 2. The values of state variables in \emph{mode 3} across lap-1 and lap-2 are depicted in Fig.~\ref{fig:track1-fixed-point-loc3} that establishes our fixed point claim. The reachable set computation results for other tracks are illustrated in Fig.~\ref{fig:eval_track2-track3-track4-track5} in the Appendix. CORA takes roughly a minute to compute the reachable set for each track.
An observation from the safety verification results is that if the set of initial conditions is large (larger uncertainty of vehicle's initial orientation and position with respect to the map), CORA fails to compute the reachable set over-approximation.
As suggested earlier, this can potentially be mitigated by fixed-point based partitioning of the large initial set and verifying the safety for each partition.
We have implemented the automatic partitioning algorithm and evaluated the approach on track-1 for the initial set $x \in [-0.8, 0.6]$, $y \in [-0.8, 0.6]$ and $\theta \in [-0.2, 0.2]$. CORA fails to compute the reachable set for this initial set.
Our technique keeps partitioning the set until it finds a partition $x \in [-0.2, 0.2]$, $y \in [-0.2, 0.2]$ and $\theta \in [-0.2, 0.2]$ having a fixed point. (We do not partition $\theta$ in this case).
Once the fixed point is found, the rest of the initial set is partitioned into intervals of the given width and reachable set is computed for each partition. In addition, at each step, reachable set containment w.r.t. the fixed point is conducted to avoid redundant computation. Fig.~\ref{fig:track1_cora-abstraction} demonstrates the safe reachable set successfully computed by our approach for the given set.
We also performed reachable set computation using CORA over tracks where the vehicle had to take a steep turn (turns of more than 90 degrees). For such instances, CORA failed to compute an overapproximation of the reachable set that is sufficient to establish the safety even for small initial sets. This shows that there is room for improvement in the current reachable set computation methods.
\section{Conclusion and Future Work}
We have illustrated the reachability based verification results of a reactive planning and control autonomous vehicle that uses Voronoi diagrams for planning and pure-pursuit controller for navigation.
To the best of authors' knowledge, this is the first work that considers all three aspects of planning, control, and the dynamically changing waypoint for prove the safety specification.
We also demonstrated reactive planning and control technique in various tracks in simulation, and on two physical tracks using a scaled down version of autonomous vehicle.
We believe that the coupled effect of planning and control requires further investigation.
In future, we intend to extend this to prove and demonstrate the safety of autonomous vehicles in presence of dynamic obstacles.
\section{Appendix}
\subsection{Reachable set accuracy}
\label{subsec:appendix-reach-set-accuracy}
Suppose the track is defined in a stationary $(x, y)$ frame, $\theta$ is the vehicle's orientation and
$\ell$ is the look ahead distance.
As a part of experimentation, we perform the reachable set computation in Flow* and CORA by modeling a single turn on the track as the hybrid automata.
The initial set is given as intervals over state variables i.e., $x \in [0.0, 0.5]$, $y \in [0.9, 1.1]$ and $\theta \in [-0.5, -0.5]$.
The reachable sets computed in both tools are shown in figures~\ref{fig:reachSet1_flow} and ~\ref{fig:reachSet1_cora}.
The divergent behavior of the reachable set in Flow* is seemingly due to error compounded over time because of coarse approximation.
The figures also illustrate that the vehicle while turning swings to some extent before merging back on to the track.
\begin{figure}
\centering
\subfigure[Flow*]{\label{fig:reachSet1_flow}\includegraphics[width=3.5in]{Figures/reachSet_1_flow.png}}
\subfigure[CORA]{\label{fig:reachSet1_cora}\includegraphics[width=\linewidth]{Figures/reachSet_1_cora.png}}
\caption{Reachable sets computed in Flow* and CORA with time step 0.02 sec and time bound 15 sec for a set of initial states. The vehicle follows a vertical path downwards before making a left turn.}
\label{fig:reachSets}
\end{figure}
\begin{figure*}
\centering
\subfigure[Track 1-X]{\label{fig:track1-loc3-x}\includegraphics[width=3.8in]{Figures/tracks/traci1-loc3-x.jpg}}
\subfigure[Track 1-Y]{\label{fig:track1-loc3-y}\includegraphics[width=3.8in]{Figures/tracks/track1-loc3-y.jpg}}
\subfigure[Track 1-$\theta$]{\label{fig:track1-loc3-theta}\includegraphics[width=3.8in]{Figures/tracks/track1-loc3-theta.jpg}}
\caption{\textbf{Fixed point illustration using state variables in Track-1}}
\label{fig:track1-fixed-point-loc3}
\end{figure*}
\begin{figure*}
\centering
\subfigure[Track 2]{\label{fig:track2-voronoi-cora}\includegraphics[width=3.5in]{Figures/tracks/track2-voronoi-cora.jpg}}
\subfigure[Track 3]{\label{fig:track3-voronoi-cora}\includegraphics[width=3.5in]{Figures/tracks/track3-voronoi-cora.jpg}}
\subfigure[Track 4]{\label{fig:track4-voronoi-cora}\includegraphics[width=3.5in]{Figures/tracks/track4-voronoi-cora.jpg}}
\subfigure[Track 5]{\label{fig:track5-voronoi-cora}\includegraphics[width=3.5in]{Figures/tracks/track5-voronoi-cora.jpg}}
\caption{Safety verification of the plan in multiple other tracks. The track-wise initial sets are $\Theta_{2} = [[-0.25, 0.25][-0.25, 0.25][-0.15,0.15]]$, $\Theta_{3} = [[-0.2, 0.2][-0.2, 0.2][-0.2,0.2]]$, $\Theta_{4} = [[-0.12, 0.12][-0.12, 0.12][-0.12,0.12]]$, and $\Theta_{5} = [[-0.12, 0.12][-0.12, 0.12][-0.12,0.12]]$}
\label{fig:eval_track2-track3-track4-track5}
\end{figure*}
| {'timestamp': '2021-07-14T02:08:32', 'yymm': '2107', 'arxiv_id': '2107.05815', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05815'} | arxiv |
\section{Protocol characteristics used for fingerprinting}
\label{app:characteristics}
\begin{itemize}
\item Input/output count: the number of inputs and/or outputs may indicate a wallet software's behavior of creating transactions. While the number of inputs depends on the UTXOs available to the user, some commonly occurring patterns such as peeling chains (\cite{Meiklejohn2013,Moeser2013}) have consistent input and output counts.
\item Version: BIP 68 \cite{BIP68} introduced relative timelocks for transactions, which requires transaction to set the transaction version to \texttt{2}.
\item Locktime: Transactions can set a timelock such that they are valid only after the tip of the chain has passed a specific block height or timestamp. Some clients (e.g., Bitcoin Core) produce timelocked transactions by default to prevent fee-sniping \cite{Todd2014FeeSniping}.
\item Replace-by-fee (RBF): Transactions opting into the replace-by-fee policy can be replaced by a similar transaction paying a higher fee \cite{BIP125}.
\item SegWit: Segregated witness \cite{BIP141} is a protocol update that enabled storing the inputs' signatures outside of the transaction, thereby increasing available space in blocks. As the upgrade is backwards-comptabile, not all wallets produce SegWit transactions. A wallet might also be able to produce SegWit transaction, but may be required to use non-SegWit serialization if none of the inputs use SegWit. We call this behavior SegWit-conform.
\item Ordered inputs/outputs: BIP 69 \cite{BIP69} defines non-binding rules (i.e. not enforced by the consensus mechanism) for lexicographically sorting inputs and outputs in a transaction. (A limitation of our implementation is that it does not compare the raw \texttt{scriptPubKey} in case the output values are equal, as they are not available in BlockSci).
\item Zero-conf: Bitcoin user's are encouraged to wait for up to six confirmations (about an hour) before accepting a payment, as there is a risk that funds might be double-spent. A transaction spending inputs without any confirmations indicates willingness to accept the double-spending risk, which could be specific to certain intermediaries.
\item Transaction fee: Bitcoin users pay transaction fees for their transactions to be included into the blockchain by miners. Some clients may pay the same exact fee (either absolute, or relative to the transaction's size) for every transaction.
\item Multisignature: Multisignature scripts allow to specify a list of public keys and a threshold $m$ such that the redeemer must provide valid signatures for $m$ out of $n$ of these keys. They aren't typically used by normal end-user wallets.
\item Address types: Bitcoin Core defines a number of standardized output scripts types including Pay-to-Pubkey-Hash (P2PKH), Pay-to-Script-Hash (P2SH) as well as their respective SegWit variants (P2WPKH and P2WSH). Often, a wallet consistently uses a specific address type.
(Compared to the normal address type heuristic, the fingerprint checks for overlap with the address types of all inputs of the spending transaction).
\end{itemize}
\section{Additional plots and tables}\label{app:figures-pow10-compressed}
\begin{center}
\includegraphics[width=\columnwidth]{figures/votes-heuristics-compressed.pdf}
\captionof{figure}{Number of votes from heuristics (with compressed power-of-ten heuristic)}
\label{fig:total-votes-compressed}
\end{center}
\begin{center}
\includegraphics[width=\columnwidth]{figures/heuristics-count-compressed.pdf}
\captionof{figure}{Average number of correct and incorrect votes per transaction and type of heuristic, over time (with compressed power-of-ten heuristic)}
\label{fig:heuristics-count-compressed}
\end{center}
\begin{center}
\includegraphics[width=\columnwidth]{figures/random-forest-predictions.pdf}
\captionof{figure}{Probabilities returned by the random forest classifier for standard transactions with unknown change}
\label{fig:random-forest-predictions}
\end{center}
\begin{center}
\captionof{table}{Change in outgoing transaction volumes of darknet markets to exchanges using the base clustering (before) and our enhanced clustering (after).}
\label{tab:darknet-market-volumes}
\begin{tabular}{
l
S[table-format=6.0]
S[table-format=6.0]
S[table-format=2.2]
}
\toprule
& \multicolumn{2}{c}{Volume (BTC)}\\
\cmidrule(lr){2-3}
Tag name & {Before} & {After} & {Change (\%)} \\
\midrule
abraxasmarket & 21925 & 24334 & 10.99 \\
agoramarket & 158355 & 172523 & 8.95 \\
alphabaymarket & 35495 & 51682 & 45.61 \\
babylonmarket & 222 & 287 & 29.21 \\
blackbankmarket & 8292 & 9942 & 19.89 \\
blueskymarket & 2520 & 3391 & 34.58 \\
cannabisroadmarket & 6 & 8 & 39.64 \\
doctordmarket & 224 & 426 & 90.52 \\
evolutionmarket & 49891 & 85919 & 72.21 \\
middleearthmarket & 11793 & 12389 & 5.06 \\
nucleusmarket & 45265 & 50289 & 11.1 \\
pandoraopenmarket & 8708 & 9539 & 9.54 \\
sheepmarket & 12104 & 13391 & 10.64 \\
silkroad2market & 47292 & 49847 & 5.4 \\
silkroadmarket & 419409 & 477551 & 13.86 \\
\addlinespace
\textit{Total} & 821500 & 961519 & 17.05 \\
\bottomrule
\end{tabular}
\end{center}
\newpage
\begin{center}
\captionof{table}{Characteristics of clusterings created with the Meiklejohn heuristic in comparison to our constrained clustering}
\label{tab:meiklejohn}
\begin{tabular}{l r r}
\toprule
& \multicolumn{2}{c}{Meiklejohn heuristics} \\
\cmidrule(){2-3}
Characteristic & Local & Global \\
\midrule
Coverage & \SI{47.8}{\percent} & \SI{54.7}{\percent} \\
\addlinespace
Largest cluster \\
\tabitem \# addresses & \num{216.1}\,M & \num{230.4}\,M \\
\tabitem \# transactions & \num{106.3}\,M & \num{113.3}\,M \\
\addlinespace
Address pairs clustered \\
\tabitem Neither & \SI{90.80}{\percent} & \SI{90.00}{\percent} \\
\tabitem Ours only & \SI{0.06}{\percent} & \SI{0.05}{\percent} \\
\tabitem Meiklejohn only & \SI{8.98}{\percent} & \SI{9.78}{\percent} \\
\tabitem Both & \SI{0.17}{\percent} & \SI{0.18}{\percent} \\
\addlinespace
Predictions \\
\tabitem Total & \num{123.8}\,M & \num{141.5}\,M\\
\tabitem Overlapping & \num{54.6}\,M & \num{62.3}\,M \\
\addlinespace
Conflicting predictions \\
\tabitem Count & \num{0.9}\,M & \num{1.2}\,M \\
\tabitem Difference in BTC & \num{1.6}\,M & \num{3.0}\,M\\
\tabitem Difference in USD & \num{8.8}\,B & \num{16.3}\,B \\
\bottomrule
\end{tabular}
\end{center}
\section{Further insights and technical details}
\subsection{Filtering the ground truth data set}\label{app:gt-filtering}
\roundon{2}
Selecting transactions with two outputs, no \opreturn{} outputs, where no input address has been directly reused in the outputs and where at least one output is in the same base cluster as the inputs yields a total of \num{46.791086} million transactions.
We first exclude \num{1.079338} million transactions with unspent outputs, as our subsequent analyses rely upon the spending transactions being known.
\roundoff
\paragraph{Transactions with two change candidates.}
Out of the \num{45.7} million transactions with at least one change candidate, for \num{0.92} million transactions \textit{both} outputs are in the same base cluster.
This can happen when a user transfers funds to an address in their own wallet, an online service restructures their funds, or cluster collapse leads to merging of both outputs' addresses.
In a first step, we exclude all transactions with two change candidates.
However, it is possible that there are yet unidentified transactions where both outputs do belong to the same entity.
This should occur only in rare cases, but there may be specific intermediaries that create such transactions more frequently (e.g., \SI{28.67}{\percent} of these transactions originate from only two base clusters).
We therefore exclude \textit{all} transactions from base clusters where more than \SI{10}{\percent} of transactions exhibit such behavior.
This removes an additional \num{472607} transactions in \num{8635} base clusters from our ground truth.
\paragraph{Potential false positives.}
A risk of using the base clustering to extract ground truth is that the multi-input heuristic could already have produced false positives.
For example, if a user Alice makes a payment to merchant Bob and their wallet addresses are incorrectly clustered together, her spend output would appear to be the change.
To this end, we first remove \num{365010} transactions belonging to the Mt.\ Gox supercluster that resulted from users being able to import their private keys into the service \cite{Harrigan2016}.
Next, we spot-check our base clustering against the website \mbox{WalletExplorer}.\footnote{\url{https://walletexplorer.com}}
For the 100 largest base clusters in our ground truth we select 25 addresses at random and collect the tag (which is either explicitly named or pseudo-random) that WalletExplorer assigns to the address.
In five instances, the addresses yield multiple tags.
Four of these return only additional pseudo-random tags, which upon manual inspection we believe to be the result of a heuristic to not link addresses in transactions with large numbers of inputs.
Only one base cluster contains addresses with two different named tags: \enquote{LocalBitcoins.com-old} and \enquote{AnxPro.com}.
This could be a result of cluster collapse, or an instance of mislabeling on the side of WalletExplorer.
We remove the \num{87931} transactions from this base cluster from our ground truth.
Overall, this check gives us some confidence that our base clustering does not already include wide-spread cluster collapse.
\roundon{2}
\paragraph{Change address reuse.}\label{sec:filter-freshness}
Our initial selection removed transactions where the change address appeared in an input of the transaction.
Yet, we find many instances where the change address did not appear in the inputs but had been seen before.
For example, a base cluster labeled by WalletExplorer as the gambling service \enquote{SatoshiDice}, contains \num{5.767771} million transactions that use only 50 different change addresses.
Similarly, there are \num{1.272048} million transactions from a base cluster tagged as \enquote{LuckyB.it} that all use a single change address.\footnote{\texttt{1NxaBCFQwejSZbQfWcYNwgqML5wWoE3rK4}}
In many of these cases, the change address could have already been revealed (before the transaction took place) through the multi-input heuristic.
If the change is known at the time the transaction is created, applying change heuristics is unnecessary.
In contrast, whenever a transaction uses a fresh address for change, it cannot possibly be revealed as the change at the time the transaction was created.
With this intuition, we remove transactions with change addresses that were not freshly generated if, at the time they were included in the blockchain, the change had already been revealed by the multi-input heuristic.
This removes a total of \num{13.813332} million transactions (\SI{92.7982234}{\percent} of transactions with reused change addresses).
\Cref{tab:fresh-non-fresh} provides an overview of whether the change and spend addresses are fresh in our ground truth data.
\roundoff
\begin{table}[]
\centering
\caption{Number of transactions (in million) in our ground truth data set with fresh or reused spend and change outputs.}
\label{tab:fresh-non-fresh}
\roundon{2}
\begin{tabular}{l S S S}
\toprule
& \multicolumn{2}{c}{\textit{Spend}} \\
\cmidrule(lr){2-3}
\textit{Change} & {Reused} & {Fresh} & {Total} \\
\midrule
Reused & 0.519791 & 0.552218 & 1.072009 \\
Fresh & 16.679914 & 12.297981 & 28.977895 \\
\addlinespace
Total & 17.199705 & 12.850199 & 30.049904 \\
\bottomrule
\end{tabular}
\end{table}
\subsection{Random forest classifier}
\label{app:rf-tuning}
\paragraph{Encoding.}
Due to the large size of the data set, we forgo one-hot encoding and instead use the following ordinal encoding for the heuristics:
\begin{itemize}
\item[\textbf{1}] the heuristic votes for the output
\item[\textbf{0}] the heuristic votes neither for nor against the output
\item[\textbf{-1}] the heuristic votes against the output
\end{itemize}
\paragraph{Model parameter.}
Our hyperparameter search returns the following parameters:
\begin{itemize}
\item Full model
\begin{itemize}
\item \texttt{max\_features: 5}
\item \texttt{min\_samples\_split: 50}
\end{itemize}
\item No fingerprinting model
\begin{itemize}
\item \texttt{max\_features: 5}
\item \texttt{min\_samples\_split: 100}
\end{itemize}
\end{itemize}
\section*{Acknowledgements}
We thank Rainer Böhme and Kevin Lee for their feedback on an earlier draft of this paper. This work is supported by NSF Award CNS-1651938 and a grant from the Ripple University Blockchain Research Initiative.
\printbibliography
\section{Introduction}
\paragraph{Motivation.}
Blockchain analysis techniques are essential for understanding how cryptocurrencies like Bitcoin are used in practice.
A major challenge in analysing blockchains is grouping transactions belonging to the same user.
Because users can create an unlimited amount of addresses, each of which can receive and send coins, their activity may be split among a multitude of such addresses.\footnote{Cryptocurrencies use digital signature schemes to authorize transactions. Public keys are used as account identifiers (called \textit{addresses}), and the signatures created with the corresponding private key authorize transactions. Users can create and use an unlimited amount of key pairs.}
Techniques to group activity of individual users are commonly referred to as \textit{address clustering heuristics,} as they focus on identifying the addresses under an individual user's control using heuristic assumptions about how their transactions are created.
As the term \textit{heuristic} suggests, address clustering today is more intuitive than rigorous; our overarching goal in this paper is to elevate it to a science.
There are at least four applications for which accurate address clustering is important.
First, a law enforcement agency may be interested in evaluating the transactions of a specific entity (e.g., a specific exchange, trader or gambling service).
They may supplement their own investigation of the entity's behavior with a set of reliable heuristics to identify relevant transactions.
Second, and conversely, the ability to accurately determine a user's transactions directly impacts their privacy.
This tension between law enforcement needs and everyday users' privacy is inherent to cryptocurrencies due to their transparency and pseudonymity. Advocates from one side push for greater privacy and from the other side for stronger regulation.
To better understand this tug-of-war, it is important to quantify how reliable change address heuristics are in practice.
Third, accurate grouping of transaction activity is important for aggregate analyses such as studying economic activity over time.
This usually requires a full clustering of all addresses on the blockchain. %
Finally, the problem of address clustering itself may be interesting for researchers outside of cryptocurrencies. For example, it may pose as an application domain for machine learning models and could be used as a benchmarking application.\footnote{We plan to make our dataset public to facilitate this.}
\paragraph{Goals.}
\begin{figure}
\centering
\begin{tikzpicture}[
inout/.style={
rectangle,
semithick,
draw,
rounded corners=5pt,
minimum width=2cm,
minimum height=1cm,
font=\sffamily,
align=center
},
lbl/.style={
font=\footnotesize\sffamily
}
]
\draw[] (-.25, -.25) rectangle ++(5,2.75);
\draw[dashed] (2.25,-.25) -- ++ (0,2.75);
\node[inout, fill=snblue!10] at (1, 1.75) {0.50 BTC \\[-2pt]\footnotesize Input 1};
\node[inout, fill=snblue!10] at (1, .5) {0.50 BTC \\[-2pt]\footnotesize Input 2};
\node[inout, fill=snorange!10] at (3.5, 1.75) (output) { 0.75 BTC \\[-2pt]\footnotesize Spend Output};
\node[inout, fill=snblue!10] at (3.5, .5) { 0.25 BTC \\[-2pt] \footnotesize Change Output};
\node[lbl] at (2.25, -.5) {Transaction};
\end{tikzpicture}
\caption[Schema of a typical Bitcoin transaction with two inputs and two outputs.]{Schema of a typical Bitcoin transaction with two inputs and two outputs: the spend output is the intended payment, the change output returns the surplus coins to the sender. Each input and output is associated with an address.}
\label{fig:change-concept}
\end{figure}
The current state of address clustering techniques available to researchers is sub-optimal in multiple ways.
The most common heuristic, \textit{multi-input}, groups addresses that are jointly used in inputs of a transaction (cf. \Cref{fig:change-concept}) \cite{reid2013,ron2013quantitative}.
This heuristic is easy to apply, relatively effective in practice, \cite{Harrigan2016} and widely used.
However, it misses addresses that are never co-spent with other addresses (cf. \Cref{fig:multi-input-problem}).
Many of these addresses can be identified using \textit{change address} heuristics: as coins in Bitcoin cannot be spent partially, transactions need to return the surplus value back to the user who created the transaction.
Identifying the change output thus allows grouping the associated address with the inputs' addresses.
While the effectiveness of change address detection has been demonstrated empirically and through simulation (e.g., \cite{Meiklejohn2013, androulaki2013}), it remains difficult to assess how well it works in practice.
As a result, clustering techniques are applied inconsistently across studies: many forgo change address clustering (e.g., \cite{jourdan2018characterizing,schatzmann2020bitcoin,BlockSci,maesa2018data}), whereas some simply apply a single change heuristic (e.g., \cite{conti2018economic, parino2018analysis}) .
\begin{figure}
\centering
\begin{tikzpicture}[
inout/.style={
rectangle,
semithick,
draw,
rounded corners=5pt,
minimum width=.7cm,
minimum height=.7cm,
font=\sffamily
},
lbl/.style={
font=\scriptsize\sffamily
}
]
\draw[] (0,0) rectangle ++(2,2);
\draw[dotted] (1,0) -- ++ (0,2);
\node[inout, fill=snblue!10] at (.5, 1.45) {A};
\node[inout, fill=snblue!10] at (.5, .55) {B};
\node[inout] at (1.5, 1.45) (output) {C};
\node[inout] at (1.5, .55) {D};
\node[lbl] at (.5, -.25) {Inputs};
\node[lbl] at (1.5, -.25) {Outputs};
\draw[] (3,0) rectangle ++(2,2);
\draw[dotted] (4,0) -- ++(0,2);
\node[inout] at (3.5, 1.45) (input) {C};
\node[inout] at (4.5, 1.45) (output2) {E};
\node[inout] at (4.5, .55) {F};
\node[lbl] at (3.5, -.25) {Inputs};
\node[lbl] at (4.5, -.25) {Outputs};
\draw[>=stealth,->, thick] (input) -- (output);
\draw[] (6,0) rectangle ++(2,2);
\draw[dotted] (7,0) -- ++(0,2);
\node[inout] at (6.5, 1.45) (input2) {E};
\node[inout] at (7.5, 1.45) {G};
\node[inout] at (7.5, .55) {H};
\node[lbl] at (6.5, -.25) {Inputs};
\node[lbl] at (7.5, -.25) {Outputs};
\draw[>=stealth,->, thick] (input2) -- (output2);
\end{tikzpicture}
\caption[]{Clustering with only the multi-input heuristic misses addresses \textsf{C} and \textsf{E} that are not co-spent with other addresses.}
\label{fig:multi-input-problem}
\end{figure}
A major issue is the lack of ground truth data available to researchers.
In the context of change output detection, ground truth consists of a set of transactions for which the change output is known.
Such a dataset allows to assess the accuracy of individual heuristics aiming to identify the change output of a transaction.
But because the Bitcoin blockchain is used for a variety of different use cases and by a diverse group of users, which may both change significantly over time, ground truth needs to reflect this diversity in order to allow for a reliable assessment.
Such data is hard to collect, and, even if available, is unlikely to be made public, e.g., due to privacy concerns. %
We are only aware of one approach exploiting weaknesses in a specific type of lightweight client \cite{nick2015data}, which allowed to extract the addresses of \num{37585} wallets to assess four different clustering heuristics.
Blockchain intelligence companies might have access to manually curated and refined data sets and clusterings, but their techniques and data aren't generally available to researchers (or only shared in limited form, e.g., \cite{harlev2018breaking,weber2019anti}).
As a result, analyses of clustering heuristics often fall short of quantifying their accuracy and instead resort to analyzing the resulting clusterings (e.g., \cite{chang2018improving,zhang2020heuristic}).
Considering this state of affairs, our first goal in this paper is to address the lack of data and assessment methods.
We build a ground truth set of transactions with known change from the Bitcoin blockchain that can be used to validate the efficacy of change address heuristics.
Equipped with this data set, our second goal is to develop new techniques that allow an analyst to combine different heuristics to predict change outputs with a high true positive and low false positive rate.
Third, we aim to assess the quality of the enhanced clusterings that can be created using such techniques and develop ways to detect and prevent cluster collapse, which occurs when the clusters of two or more distinct entities are incorrectly merged together.
Finally, we are interested in evaluating the potential impact of the enhanced clusterings on the results of typical blockchain analyses.
\paragraph{Contributions, methods and findings.}
\begin{enumerate}
\item \textbf{A new ground truth method and dataset:} We put forward a procedure to select and filter transactions for which the change output has been revealed on the blockchain.
Our approach exploits that future transactions of users can reveal change outputs in past transactions.
We take specific care evaluating the data set with regards to potential issues, such as violations of our core assumption or existing cluster collapse.
We extract a set of \num{30.05} million transactions with known change (carefully filtered down from \num{47} million candidate transactions) that can be used as ground truth for validation and prediction.
Our method does not rely on interaction with intermediaries, though we use address tag data to assess the quality of our data set and methods.
The data set can be continuously updated, improved and shared with other researchers. (\Cref{sec:ground-truth})
\item \textbf{Evaluating existing heuristics:} We assess the true and false positive rates of various change address heuristics on our ground truth data set. We find that most change address heuristics have few false positives at low to medium true positive rates. Further, we find that Bitcoin's protocol characteristics have become increasingly relevant due to their ability to provide a \enquote{fingerprint} for transactions. We also report the heuristics' overall coverage (i.e., how often they return a result) for transactions with unknown change. (\Cref{sec:evaluation})
\item \textbf{Improved prediction:} We use a random forest classifier to identify change outputs and compare it against a baseline: the majority vote of individual heuristics. While machine learning has been used to classify the type of entity behind a transaction (e.g., \cite{harlev2018breaking,jourdan2018characterizing,toyoda2018multi,lin2019evaluation,bartoletti2018data,hu2019characterizing,weber2019anti}), to the best of our knowledge our work is the first to apply it to the problem of change identification.
We find that a random forest model outperforms our baseline threshold voting mechanism, especially for low false positive rates (to prevent cluster collapse). For example, targeting a false positive rate below \SI{0.1}{\percent} the random forest model correctly detects almost twice as many change outputs. (\Cref{sec:ml-model})
\item \textbf{Preventing cluster collapse:} We analyze the clustering that results from the predicted change outputs with regards to cluster collapse using multiple measures. We find that a naive clustering of predicted change outputs leads to cluster collapse, despite choosing a low threshold to prevent false positives. We then apply constraints to the union-find algorithm underlying our clustering, aiming to prevent cluster collapse that stems from frequent, repeated interaction between entities. This technique prevents large-scale cluster collapse while still enhancing a majority of the involved clusters. (\Cref{sec:clustering})
\item \textbf{Assessing impact:} We assess the impact our enhanced clustering has on two exemplary applications: cash-out flows from darknet markets to exchanges and the velocity of bitcoins. We find that our enhanced clustering changes the outcomes of these longitudinal analyses by \SIrange{11}{17}{\percent}. (\Cref{sec:applications})
\end{enumerate}
Our process is summarized in \Cref{fig:process}. We discuss our findings in \Cref{sec:discussion} and conclude in \Cref{sec:conclusion}
\paragraph{Limitations.}
Our results in this paper are limited by the availability of \enquote{real} (i.e. manually collected and validated) ground truth.
As such, our analysis should be treated as a first step towards better understanding the feasibility of change address detection and clustering.
However, we do not expect our high-level insights to change significantly in the light of minor corrections to our ground truth data set.
We invite the research and blockchain community to evaluate our data set using their own ground truth data or analysis techniques.\footnote{We plan to make a list of transactions and output indexes available.}
An interesting avenue for future research would be to build a privacy-preserving tool that allows to crowd-source the validation of both the ground truth data and prediction models, to which individual users could connect their wallet software.
Our extraction mechanism relies on change outputs revealed by the multi-input heuristic.
This heuristic is effective in practice \cite{Harrigan2016} and widely used, but vulnerable to false positives from techniques like CoinJoin and PayJoin transactions that are intentionally designed to break the heuristic (e.g., \cite{meiklejohn2015overlays,Moeser2017,CoinJoin,BIP78}).
While we take measures to detect CoinJoin transactions and pre-existing cluster collapse, some errors can remain.
Furthermore, entities that more effectively prevent address reuse are less likely to be included in our data set.
We adopt the term \textit{clustering} used in the blockchain community, however, our underlying implementation sequentially processes transactions and uses a union find algorithm that does not retain individual distance scores.
In practice it may be desirable to give analysts a choice between different clustering outcomes (e.g., concerning the order in which clusters are merged or the tradeoff between false positive and true positive rates).
Finally, in this paper we work with the Bitcoin blockchain, currently the most popular cryptocurrency by market volume.
Our methods are applicable to similar cryptocurrencies, potentially with a different set of heuristics, but may be less effective if transactions are more homogeneous.
\begin{figure}
\centering
\begin{tikzpicture}[
box/.style = {
draw,
align = center,
inner sep = 5pt,
minimum width = 3.2cm,
text width = 3.2cm,
minimum height = 1.1cm,
node distance = .5cm and 1cm,
},
>=stealth,
lbl/.style = {
node distance = 0cm,
minimum width = 1cm,
font=\large
},
substep/.style = {
inner sep=3pt,
anchor=west,
node distance = .5em and .5cm,
align=left,
minimum width=3.5cm,
text width=3.5cm,
}
]
\node[box, dashed] (step1) {Multi-input\Aq\\base clustering\Aq};
\node[box, below = of step1] (step2) {Extract ground truth\Aq};
\node[box, below = of step2] (step3) {Evaluate heuristics\Aq};
\node[box, below = of step3] (step4) {\Aq{}Train model to predict change\Aq};
\node[box, below = of step4] (step5) {\Aq{}Enhance clustering with change outputs\Aq};
\node[lbl, left = of step2] (lbl1) {\ref{sec:ground-truth}};
\node[lbl, left = of step3] (lbl1) {\ref{sec:evaluation}};
\node[lbl, left = of step4] (lbl1) {\ref{sec:ml-model}};
\node[lbl, left = of step5] (lbl1) {\ref{sec:clustering}};
\draw[->, thick] (step1) -- (step2);
\draw[->, thick] (step2) -- (step3);
\draw[->, thick] (step3) -- (step4);
\draw[->, thick] (step4) -- (step5);
\node[substep, right = of step2] (substep2) {Remove transactions with two candidates};
\node[substep, above = of substep2] (substep1) {Select transactions\\with known change};
\node[substep, below = of substep2] (substep3) {Remove potential\\false positives};
\node[substep, below = of substep3] (substep4) {Remove transactions with reused change};
\draw [decorate, decoration={brace,amplitude=10pt, mirror, aspect=.38}, thick] (substep1.north west) -- (substep4.south west);
\end{tikzpicture}
\caption{Our process in this paper}
\label{fig:process}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}[
inout/.style={
rectangle,
semithick,
draw,
rounded corners=5pt,
minimum width=.7cm,
minimum height=.7cm,
font=\sffamily
},
lbl/.style={
font=\scriptsize\sffamily
}
]
\draw[] (0,0) rectangle ++(2,2);
\draw[dotted] (1,0) -- ++ (0,2);
\node[inout, fill=snblue!10] at (.5, 1.45) {A};
\node[inout, fill=snblue!10] at (.5, .55) {B};
\node[inout, fill=snblue!20] at (1.5, 1.45) (output) {C};
\node[inout] at (1.5, .55) {D};
\node[lbl] at (.5, -.25) {Inputs};
\node[lbl] at (1.5, -.25) {Outputs};
\draw[rounded corners=2pt,] (3,0) rectangle ++(2,2);
\draw[dotted] (4,0) -- ++(0,2);
\node[inout, fill=snblue!20] at (3.5, 1.45) (input) {C};
\node[inout, fill=snblue!10] at (3.5, .55) {A};
\node[inout] at (4.5, 1.45) {E};
\node[inout] at (4.5, .55) {F};
\node[lbl] at (3.5, -.25) {Inputs};
\node[lbl] at (4.5, -.25) {Outputs};
\draw[>=stealth,->, thick] (input) -- (output);
\end{tikzpicture}
\caption[Multi-input clustering reveals the change address]{Address $C$ is merged into the same cluster as addresses A and B by the multi-input heuristic, thereby revealed as the change address in the first transaction.}
\label{fig:change-revealed}
\end{figure}
\section{Building a Ground Truth Data Set} \label{sec:ground-truth}
\paragraph{Core assumption.}
In this paper we focus on the feasibility of detecting the change output in Bitcoin transactions with exactly two spendable outputs, by far the most common type of transaction as of June 2020 (\SI{72.6}{\percent} of all transactions, see \Cref{fig:transaction-overview}).
Our core assumption is that one of these outputs is a payment, and the other output receives the change.
We call this type of transaction a \textit{standard} transaction, as they are created by typical end-user wallet software.\footnote{There exist a separate notion of a standard transaction, namely those that pass the \texttt{isStandard} test of the Bitcoin reference implementation that checks whether a transaction uses one of a handful of default script types.}
For transactions with only one output there is no good indicator to directly and reliably determine whether the output belongs to the same user.
The transaction may correspond to a user sweeping the balance of their wallet, but the destination address may not be under the same user's control (e.g., they might transfer all the bitcoins from a wallet on their personal computer to an online wallet, where private keys are managed by and in control of an exchange).
Transactions with more than two outputs are less likely to originate from an ordinary wallet.
They may belong to an exchange that batches payouts to multiple users, or correspond to a restructuring of their internal hot and cold wallets.
As a result, our assumption that exactly one of the outputs receives change may not hold.
Large numbers of outputs could also indicate mixing services or CoinJoin transactions, where the funds of multiple users are mixed.
Determining change in CoinJoin transactions requires solving a subset-sum problem (e.g., \cite{Moeser2017,goldfeder2018cookie,meiklejohn2015overlays}) and is outside the scope of this paper.
\paragraph{Method.}
Our approach leverages the phenomenon that change outputs are sometimes revealed by the multi-input heuristic at a later point in time due to address reuse.
\Cref{fig:change-revealed} shows an example of how such disclosure may unintentionally happen on the blockchain: a user spends coins at addresses $A$ and $B$, their wallet directs the change to a new address $C$.
Later, they spend the change at address $C$ along with other coins at address $A$.
At this point, the multi-input heuristic reveals that $A, B$ and $C$ belong to the same user, thereby revealing $C$ as the change address in the first transaction.
\paragraph{Comparison to interactive collection.}
We briefly discuss the advantages and disadvantages of our approach to collecting ground truth interactively.
We could download a Bitcoin wallet and send bitcoins to a number of different addresses, thereby creating a corpus of transactions for which both the spend and the change output are known.
However, in order to be able to learn and generalize from our ground truth data it should capture the expected heterogeneity of implementations and use cases over Bitcoin's entire history.
An interactive collection would likely yield ground truth inferior in three dimensions: variety, scale, and the collection time frame.
Heterogeneous ground truth requires transactions from a \textit{variety of different use cases and entities}.
Compared to prior deanonymization studies that identified address clusters of specific entities by interacting with them (revealing some of the intermediary's addresses, e.g., \cite{Meiklejohn2013}), we are interested in the change of transactions made by those intermediaries.
Purchasing an item from an online merchant can reveal one of their addresses, but we do not learn about change in any of the merchant's transactions, only about our own transaction that pays them.
The only conceivable way to learn about change in an intermediary's transactions is to induce them to make a transaction to an address under our control.
This may be possible with exchanges, where we could first deposit and then withdraw funds, but is not applicable to many other intermediaries.\footnote{It could also raise ethical and legal questions, e.g., when interacting with gambling services or intermediaries in other countries.}
Our method, instead, is not limited to a small set of intermediaries of our choosing.
Second, interactive collection would be hard to \textit{scale} beyond a few hundred transactions, as we would need to individually engage with a variety of intermediaries and wallet implementations.
This cannot easily be automated.
While \textcite{nick2015data} was able to collect data on a larger scale from exploiting a vulnerability in a specific type of lightweight client, his method is not transferable or generalizable to other types of wallets.
Our approach, instead, yields a data set of millions of transactions.
A third issue of collecting data interactively is the \textit{time frame}.
Interactive collection, as described above, cannot be done retroactively and is therefore limited to a short, current time window.
This limits its utility as the resulting data set wouldn't capture shifting patterns over different epochs of Bitcoin's history.
Our non-interactive approach, on the other hand, is applicable to transactions from Bitcoin's entire history.
Our method has a few important limitations.
First, because we extract ground truth data non-interactively from the blockchain, we are not able to fully verify its correctness.
Second, our core assumption that exactly one of the outputs is a change output may not hold in every scenario.
When users transfer funds to an address under their control, determining the change and spend based on the multi-input heuristic is ambiguous.
Similarly, there could be instances where none of the outputs is a change output because a user made a payment to two different entities using a perfectly matching set of inputs that does not require change to be returned.
Third, as our method relies on address reuse, the resulting transaction corpus could be biased towards entities or wallet implementations that are more prone to reuse and merge addresses.
It might contain fewer instances of transactions created with wallets that more effectively discourage address reuse.
\subsection{Data collection and overview}
We use and build upon BlockSci v0.7 \cite{BlockSci}, an open-source blockchain analysis framework that provides fast access to blockchain data upon which we can implement custom heuristics and extraction procedures.
We parse the Bitcoin blockchain until the end of June 2020 (block height \num{637090}) and create a \textit{base clustering} using the multi-input heuristic (where we heuristically exclude CoinJoin transactions).
\roundon{0}
As of June 2020, the blockchain contains \num{66.086402} million transactions with one output, \num{422.272490} million with two outputs, and \num{55.607287} million with three or more outputs (\Cref{fig:transaction-overview}).
\roundoff
We divide the transactions into mutually exclusive categories.
Transactions containing unspendable \opreturn{} outputs often signal the use of an overlay application that stores metadata in the blockchain \cite{Bartoletti2017}.
Such transactions may have specific rules for how they are constructed, potentially making change detection unreliable.
Both transactions reusing an input address as well as transactions where cluster membership (i.e. the multi-input heuristic) reveals a change output have their change output identified.
Direct address reuse however makes change identification trivial and applying further change heuristics is never necessary.
We thus only use transactions where the change has been revealed by multi-input clustering as the basis to construct our ground truth data set.
For the remaining transactions, i.e. those with yet unknown change, we will later try to predict their change output.
\begin{figure}
\centering
\begin{tikzpicture}[x=3cm, y=.1cm]
\node[align=center,font=\footnotesize\sffamily\bfseries] at (.5, 62.55) {1 Output (66\,M)};
\draw[fill=gray!20, draw=none] (0, 54.2) rectangle ++(1, 6.6);
\draw[draw=none, fill=snblue] (0, 60.8) rectangle ++(1, -0.0462);
\draw[draw=none, fill=sngreen] (0, 60.7538) rectangle ++(1, -0.198);
\draw[draw=none, fill=snorange] (0, 54.2) rectangle ++(1, 0.0396);
\draw (0, 54.2) rectangle ++(1, 6.6);
\node[align=center,font=\footnotesize\sffamily\bfseries] at (.5, 48.95) {2 Outputs (422\,M)};
\draw[fill=gray!20, draw=none] (0, 5) rectangle ++(1, 42.2);
\draw[draw=none, fill=snblue] (0, 47.2) rectangle node {\footnotesize\sffamily\color{white} Address reuse: 90\,M} ++(1, -9.0308);
\draw[draw=none, fill=sngreen] (0, 38.1692) rectangle node {\footnotesize\sffamily\color{white} Cluster member: 47\,M} ++(1, -4.6842);
\draw[draw=none, fill=snorange] (0, 7.6586) rectangle ++(1, -2.6586);
\node at (0.5, 20.5718) {\footnotesize\sffamily Unknown change: 258\,M};
\draw[thick] ($ (0.5, 5) + (0, 2pt)$) -- ++(0, -4pt) node[below, inner sep=2pt] {\footnotesize\sffamily Overlay applications: 27\,M};
\draw[semithick] (0, 5) rectangle ++(1, 42.2);
\node[align=center,font=\footnotesize\sffamily\bfseries] at (.5, -3.25) {3+ Outputs (56\,M)};
\draw[fill=gray!20, draw=none] (0, -10.6) rectangle ++(1, 5.6);
\draw[draw=none, fill=snblue] (0, -5) rectangle ++(1, -0.6608);
\draw[draw=none, fill=sngreen] (0, -5.6608) rectangle ++(1, -0.756);
\draw[draw=none, fill=snorange] (0, -10.6) rectangle ++(1, 1.792);
\draw (0, -10.6) rectangle ++(1, 5.6);
\begin{scope}[
shift={(1.21, 55)},
x=1.5cm,
y=.1cm,
every node/.style = {font=\sffamily\footnotesize, align=center}]
\draw (0, 0) rectangle (1, -1.08);
\draw (0, -3.08) rectangle (1, -4.474909); %
\draw (0, -6.474909) rectangle (1, -6.927850); %
\draw (0, -8.927850) rectangle (1, -22.741182); %
\draw[thick] (0, -24.741182) rectangle (1, -54.7); %
\draw [draw=sngreen, thick, decorate, decoration={brace,amplitude=10pt, mirror, aspect=.355}] (-5pt, 0) -- ++(0, -54.7);
\draw ($ (1, -.54) -(3pt, 0) $) -- ++ (6pt, 0) node[right] {Unspent outputs (1.08\,M)\Aq};
\draw ($ (1, -3.7774545) -(3pt, 0) $) -- ++ (6pt, 0) node[right] {Two change candidates (1.4\,M)\Aq};
\draw ($ (1, -6.7013795) -(3pt, 0) $) -- ++ (6pt, 0) node[right] {Potential false positives (0.45\,M)\Aq};
\node at (.5, -15.834516) {13.8\,M\\\scriptsize (29.5\,\%)};
\draw ($ (1, -15.834516) -(3pt, 0) $) -- ++ (6pt, 0) node[right] {Change address reuse\Aq};
\node at (.5, -39.720591) {30.05\,M\\\scriptsize (64.2\,\%)};
\draw[thick] ($ (1, -39.720591) -(3pt, 0) $) -- ++ (6pt, 0) node[right] {\textbf{Final ground truth\Aq}};
\end{scope}
\end{tikzpicture}
\caption{Distribution of different types of transactions in the Bitcoin blockchain until June 2020. Transactions with two outputs and change revealed through cluster membership form the basis of our ground truth data, which we further refine down to a ground truth data set of \num{30.05} million transactions.}
\label{fig:transaction-overview}
\end{figure}
\subsection{Refining the candidate set of ground truth transactions}
Our candidate set of ground truth transactions consists of transactions with two outputs (ignoring overlay transactions) where no input address is reused for change and where at least one output is in the same base cluster as the inputs. This yields a total of \num{46.79} million transactions.
We further filter the transactions as follows (see \Cref{fig:transaction-overview} for a visual breakdown and \Cref{app:gt-filtering} for an extended description):
\roundon{2}
\begin{enumerate}
\item We remove \num{1.079338} million transactions with unspent outputs, as our subsequent analyses rely upon the spending transactions being known.
\item For \num{0.922964} million transactions both outputs are in the same base cluster as the inputs, violating our core assumption. We remove these transactions. We also find that some base clusters are more likely to produce such transactions. We thus exclude transactions from base clusters where more than \SI{10}{\percent} of transactions exhibit such behavior. This removes an additional \num{0.472607} million transactions in \num{8635} base clusters.
\item We check our base clustering for existing cluster collapse, which could produce false positives. First, we remove \num{0.365010} million transactions belonging to the Mt.Gox supercluster. Second, we remove a possible instance of cluster collapse detected using address tags from WalletExplorer, further removing \num{0.087931} million transactions.
\item We find many instances where the change address did not appear in the inputs, but had been seen before and was known to be the change at the time the transaction was created. In these instances, applying change address heuristics is unnecessary. We remove \num{13.813332} million transactions where the change output was already known at the time the transaction was created.
\end{enumerate}
\roundoff
\subsection{Assessing the final set of ground truth transactions}
Next, we assess the composition of our ground truth data set and compare it to transactions in the blockchain overall.
This is useful to ensure that it contains heterogeneity with regards to scale, time frame and variety (see discussion above), as well as to spot potential biases in the ground truth that could result from our selection process.
\paragraph{Scale and time frame.}
\roundon{1}
Our ground truth of {\roundon{2}\num{30.049904}} million transactions makes up about \SI{7.699618621557179}{\percent} of standard transactions and about \SI{5.600442670168286}{\percent} of all transactions.
\Cref{fig:gt-share} shows that those percentages are relatively stable over time.
\roundoff
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{figures/gt-share-of-tx.pdf}
\caption{Share of ground truth transactions of all and standard transactions over time.}
\label{fig:gt-share}
\end{figure}
\paragraph{Variety of included clusters.}
\roundon{1}
Our ground truth includes transactions from \num{2.700055} million base clusters.
We consider two measures to assess their variety: the number of addresses those base clusters contain overall, as well as the number of transactions that originate from each (i.e., how ground truth transactions are distributed across base clusters).
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{figures/cluster-size-distribution.pdf}
\caption{Number of base clusters of certain address counts contained in the ground truth data (with at least one transaction), as compared to the full blockchain.}
\label{fig:cluster-sizes}
\end{figure}
\roundon{2}
\Cref{fig:cluster-sizes} shows the distribution of address counts of base clusters that are represented with at least one transaction in our ground truth. %
Our ground truth contains transactions from base clusters of all sizes, giving us some confidence that it can be representative of the blockchain overall.
The share of base clusters from which transactions are included is higher towards clusters with larger number of addresses.
This is likely a side-effect of our selection process, as base clusters with more addresses may be more likely to combine addresses and thereby reveal change.
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{figures/cluster-tx-distribution.pdf}
\caption{Number of transactions in ground truth and full blockchain, grouped by base cluster.}
\label{fig:tx-counts}
\end{figure}
Next, we inspect the distribution of transactions across base cluster that are included in the ground truth data (\Cref{fig:tx-counts}).
The highest number of transactions is \num{3.451018} million, from a cluster that has \num{8.685868} million transactions in total.
It is not labeled by WalletExplorer.com.
The second highest number of transactions is {\roundoff\num{366109}}, again from an unlabeled cluster.
\roundoff
\paragraph{Transaction composition and use of protocol features.}
\Cref{tab:gt-characteristics} compares characteristics of transactions in our ground truth data to those of standard transactions with yet unknown change, including the number of inputs as well as a number of important protocol features (an overview and description of the protocol characteristics used in this paper is available in \Cref{app:characteristics}).
Transactions in the ground truth data set notably tend to have more inputs than those in the set of transactions with unknown change.
This is an artifact of our ground truth selection as it relies on transactions with more than one input to reveal change outputs.
The share of transactions using SegWit serialization or allowing for fee bumping (RBF) is also higher in the set of remaining transactions.
\begin{table}[]
\centering
\caption{Comparison of transaction characteristics between ground truth transactions and transactions with 2 outputs for which change is unknown.}
\label{tab:gt-characteristics}
\roundon{2}
\begin{tabular}{l S S}
\toprule
Characteristic & {Ground truth (\%)} & {Remaining (\%)} \\
\midrule
1 Input & 38.959382366080106 & 78.28375794518618 \\
2 Inputs & 21.906446023920743 & 13.917534303949708 \\
3+ Inputs & 39.13417160999915 & 7.794027764565731 \\
\addlinespace
Version = 1 & 81.56114575274516 & 83.35745379303128 \\
Locktime > 0 & 26.10117489892813 & 24.22006797067363 \\
RBF & 2.773606198542265 & 4.257346346251852 \\
SegWit & 14.894763058144878 & 23.355507574377675 \\
\addlinespace
$n$ (in million) & 30.049904 & 258.675971 \\
\bottomrule
\end{tabular}
\end{table}
\begin{table*}[]
\centering
\caption{Change heuristics proposed in the literature and used in this paper.}
\label{tab:change-heuristics}
\begin{tabularx}{\textwidth}{X p{6cm} c l}
\toprule
Heuristic & Notes and limitations & Used & Refs. \\
\midrule
\textbf{Optimal change}: There should be no unnecessary inputs: if one output is smaller than any of the (2+) inputs, it is likely the change. & Only applies to transactions with 2+ inputs. We use two variants, one ignoring and one accounting for the fee. & $\checkmark$ & \cite{nick2015data,BitcoinWikiPrivacy} \\
\addlinespace
\textbf{Address type}: The change output is likely to have the same address type as the inputs. & Wallets could use different address types to obfuscate the change output.& $\checkmark$ & \cite{BlockSci,BitcoinWikiPrivacy}\\
\addlinespace
\textbf{Power of ten}: As purchase amounts may be rounded, and the change amount also depends on input values and the fee, it is more likely to have fewer trailing zeros. & We use six different variants, which are partially redundant. & $\checkmark$ & \cite{BlockSci,BitcoinWikiPrivacy}\\
\addlinespace
\textbf{Shadow address}: Many clients automatically generate fresh change addresses, whereas spend addresses may be more easily reused. & Modern wallets discourage reuse of receiving addresses. We do not use the heuristic because our ground truth is filtered based on address freshness. & \text{\sffamily x} & \cite{Meiklejohn2013,androulaki2013} \\
\addlinespace
\textbf{Consistent fingerprint}: The transaction spending a change output should share the same characteristics. We use 17 variants based on the following characteristics:
\begin{itemize}[nosep]
\item input/output counts and order
\item version
\item locktime
\item serialization format (SegWit)
\item replace-by-fee (RBF)
\item transaction fee
\item input coin age (zero-conf)
\item address and script types
\end{itemize}
& False positives are possible when a wallet implementation or the protocol change. We only consider characteristics after they are available in the protocol. \Cref{app:characteristics} describes the characteristics we use in more detail. & $\checkmark$ & \cite{BitcoinWikiPrivacy,BlockchairPrivacyMeter} \\
\bottomrule
\end{tabularx}
\end{table*}
\begin{figure*}
\centering
\begin{tikzpicture}[
inoutlbl/.style={align=center},
inout/.style={rounded corners=5pt},
smlinout/.style={
draw,
rounded corners=5pt,
minimum width=.7cm,
minimum height=.7cm
},
smllbl/.style={
font=\scriptsize\sffamily
}
]
\footnotesize
\sffamily
\def2{2}
\def1{1}
\def.25{.25}
\draw (0, 0) rectangle (2*2+4*.25, -3*.25-4*1);
\draw[inout] (.25, -.25) rectangle node[inoutlbl] {0.50 BTC\\1abc\Aq} ++(2, -1);
\draw[inout] (.25, -1 - 2*.25) rectangle node[inoutlbl] {0.50 BTC\\1def\Aq} ++(2, -1);
\draw[thick] (.125, -.125) -- ++(-2.625, 0) node[anchor=south west] {\textbf{Inputs}\Aq};
\node[anchor=north west, text width = 2.5cm] at (-2.5, -.25) {based on:\\\begin{itemize}[nosep,leftmargin=*,label=-,labelsep*=.5ex]\item required amount (spend + fee)\item available coins\item coin selection\end{itemize}};
\def\inoutwidth + 3*\spacer{2 + 3*.25}
\draw[inout] (\inoutwidth + 3*\spacer, -.25) rectangle node[inoutlbl] {0.75 BTC\\3ghk} ++(2, -1);
\draw[inout] (\inoutwidth + 3*\spacer, -1 - 2*.25) rectangle node[inoutlbl] {0.20 BTC\\1mnp} ++(2, -1);
\draw[thick] (4.875, -.125) -- ++(2.625, 0) node[anchor=south east] {\textbf{Outputs}\Aq};
\node[anchor=north west, text width = 2.25cm] at (5.25, -.25) {\textit{spend} amount and address type \mbox{chosen} by payee\\[1em]\textit{change} amount and address type chosen by wallet};
\draw[dashed] (2 + 2* .25, 0) -- ++(0, -3*.25 - 2*1);
\def\feeoffset{-3*.25 - 2*1};
\draw[] (0, \feeoffset) -- ++(5, 0);
\draw[inout, draw=none] (.25, \feeoffset) rectangle node[inoutlbl] {Fee: 0.05 BTC} ++(4.5, -1);
\draw[thick] (.125, \feeoffset - .5*1) -- ++(-2.625, 0) node[anchor=south west] {\textbf{Transaction fee}\Aq};
\node[anchor=north west, text width = 2.5cm] at (-2.5, \feeoffset - .5*1) {\begin{itemize}[nosep,leftmargin=*,label=-,labelsep*=.5ex]\item fixed or variable\end{itemize}};
\def\protocoloffset{\feeoffset - 1};
\draw[] (0, \protocoloffset) -- ++(5, 0);
\draw[inout, draw=none] (.25, \protocoloffset) rectangle node[inoutlbl] {Version, Locktime, SegWit, RBF, \dots} ++(4.5, -1);
\draw[thick] (4.875, \protocoloffset-.25) -- ++(2.625, 0) node[anchor=south east] {\textbf{Characteristics}\Aq};
\node[anchor=north west, text width = 2.25cm] (protocolfields) at (5.25, \protocoloffset-1*.25) {\begin{itemize}[nosep,leftmargin=*,label=-,labelsep*=.5ex]\item determined by wallet and use case\end{itemize}};
\node[anchor=north east, circle, semithick, fill=black, inner sep=.75pt, outer sep=4pt] at (5-.25, -.25) {\color{white}\scriptsize\textbf{1}};
\node[anchor=east, circle, semithick, fill=black, inner sep=.75pt, outer sep=4pt] at (5, \feeoffset-.5*1) {\color{white}\scriptsize\textbf{2}};
\node[anchor=west, circle, semithick, fill=black, inner sep=.75pt, outer sep=2pt] at (0, -1-1.5*.25) {\color{white}\scriptsize\textbf{3}};
\node[anchor=north east, circle, semithick, fill=black, inner sep=.75pt, outer sep=4pt] at (5-.25, -1-2*.25) {\color{white}\scriptsize\textbf{4}};
\def9{9}
\def-3.5{-3.5}
\draw (9,-3.5-.8) rectangle ++(2,2.8);
\draw[dotted] (9+1,-3.5) -- ++ (0,2);
\draw (9,-3.5) -- ++(2,0);
\node[smlinout] at (9+.5, -3.5+1.45) {};
\node[smlinout] at (9+.5, -3.5+.55) {};
\node[smlinout] at (9+1.5, -3.5+1.45) (output1) {};
\node[smlinout, fill=gray!20] at (9+1.5, -3.5+.55) (output2) {};
\node[smllbl,align=center] at (9+1, -3.5-.4) {Version = 1\\SegWit = True};
\draw (9+3,-3.5+3.2) rectangle ++(2,-1.9);
\draw[dotted] (9+4,-3.5+2.1) -- ++(0,1.1);
\draw (9+3,-3.5+2.1) -- ++ (2,0);
\node[smlinout] at (9+3.5, -3.5+2.65) (input1) {};
\node[smlinout] at (9+4.5, -3.5+2.65) {};
\node[smllbl,align=center] at (9+4, -3.5+1.7) {\color{snred!80!black}Version = 2\\\color{snred!80!black}SegWit = False};
\draw[>=stealth,->, semithick] (input1) -- ++(-1cm, 0) -- ++(0, -1.2cm) -- (output1);
\draw (9+3,-3.5-.8) rectangle ++(2,1.9);
\draw[dotted] (9+4,-3.5) -- ++(0,1.1);
\draw (9+3,-3.5) -- ++ (2,0);
\node[smlinout, fill=gray!20] at (9+3.5, -3.5+0.55) (input2) {};
\node[smlinout] at (9+4.5, -3.5+0.55) {};
\draw[>=stealth,->, semithick] (input2) -- (output2);
\node[smllbl,align=center] at (9+4, -3.5-.4) {\color{sngreen!80!black}Version = 1\\\color{sngreen!80!black}SegWit = True};
\draw[->, thick, >=stealth, dashed] (protocolfields.east) to [out=0, in=-160] node[below = 1ex, align=center,font=\itshape] (lbl-consistent) {often consistent\\across transactions} (9-.1,-3.5-.8-.1);
\node[above = .2cm of lbl-consistent, circle, semithick, fill=black, inner sep=.75pt, outer sep=4pt] {\color{white}\scriptsize\textbf{5}};
\end{tikzpicture}
\caption{Schema of how transactions are created, and how consistency of a transaction's fingerprint allows to identify change.}
\label{fig:tx-schema}
\end{figure*}
\section{Evaluating Individual Change Heuristics}\label{sec:evaluation}
\subsection{Background on change address detection}
The Bitcoin protocol does not explicitly distinguish between change and spend outputs. %
However, wallets create change outputs automatically to return surplus value when users make payments (cf. \Cref{fig:tx-schema}).
We briefly describe how this allows to identify change and present the heuristics that have been proposed in the literature (see \Cref{tab:change-heuristics} for details, limitations and references).
\paragraph{Spend output.}
For standard transactions, the user will typically be given a specific payment amount and an address to which the bitcoins should be sent (1).
Payment amounts in Bitcoin are denominated in satoshi, with one bitcoin equal to \SI{e8}{satoshi}.
At current and historic exchange rates, a single satoshi is worth only a fraction of a cent. Merchants may thus round payment values to make it easier for users to enter the correct amounts in their wallet, and transfers initiated by users may use round values as well. %
Change can hence be distinguished from spends by potentially having fewer trailing zeros (\textit{power of ten} heuristic).
\paragraph{Input selection.}
After the spend amount and a transaction fee have been determined, the wallet chooses a set of coins that covers the sum of both amounts (3).
While this selection procedure is not standardized and can differ between wallet implementations (cf. \cite{abramova2020coinselection,Erhardt2016Coinselection}), some behavior is common to many wallets, such as not including unnecessary inputs (\textit{optimal change} heuristic).
\paragraph{Change output.}
The change output is automatically created by the wallet to return the surplus funds. Often, a fresh address is generated (i.e., one that has never received coins before).
In the past it was common that payment addresses were reused, allowing to determine change based on this behavior (\textit{shadow} heuristic / one-time change).
We note that our ground truth data set is filtered based on address reuse (see \Cref{sec:filter-freshness}).
Because this filtering effectively determines the performance of the heuristic, we decide not to use it in our subsequent analyses.
While the address type of the receiving address is determined by the payee, wallets usually use consistent address types.
A single output with a different address type than the inputs might indicate a spend output, thus revealing the change (\textit{address type} heuristic).
\paragraph{Consistency of transaction fingerprints.}
The heuristics above are based on expected behavior that should apply to many common wallet implementations.
Furthermore, transactions can make use of protocol features that may allow to discriminate between different types of wallets.
Such a fingerprint would allow to apply custom heuristics to subsets of transactions.
Transaction fingerprints can also be used for change identification. Assuming that users don't change wallets very often, characteristics should be consistent across multiple transactions.
When a wallet spends the change of a previous transaction, those two transactions' fingerprints should be similar (\textit{consistent fingerprint} heuristic, see (5) in \Cref{fig:tx-schema}).
We are not aware of any prior work that has evaluated this across the range of available protocol characteristics.
We also note that this heuristics requires the outputs to be spent, whereas the previous heuristics are \textit{universal} as they can be applied to all transactions, including those with unspent outputs.
We selected our ground truth data such that it only contains transactions where both outputs are spent, so the consistent fingerprint heuristic can be applied to all of them.
\Cref{fig:time-dist-all-spent} shows the distribution of time until both outputs are spent for transactions in the ground truth data set as well as remaining standard transactions with yet unknown change.
Overall, the outputs of more than half of all transactions are spent in under a week, making the consistent fingerprint heuristic highly applicable to a majority of transactions, including recent ones.
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{figures/time-dist-until-spent-log-scale-complete-fullchain.pdf}
\caption{Time until both outputs are spent for transactions in our ground truth data, in the remaining standard transactions and the blockchain overall. Time until spent is set to infinity if not both outputs of a transaction are spent.}
\label{fig:time-dist-all-spent}
\end{figure}
\subsection{Evaluating individual heuristics}
\begin{table}[]
\centering
\caption{True and false positive rates of heuristics applied to transactions in the ground truth data set.}
\label{tab:heuristics}
\roundon{3}
\begin{tabular}{l
S[table-format=1.3]
S[table-format=1.3]
S[table-format=1.3]
}
\toprule
& \multicolumn{2}{c}{Ground Truth} & {Remaining} \\
\cmidrule(lr){2-3}\cmidrule(lr){4-4}
{Heuristic} & {TPR} & {FPR} & {Coverage$^{*}$} \\
\midrule
{\textit{Universal heuristics}} \\
{Optimal change} & 0.298564 & 0.026741 & 0.133892 \\
{\tabitem incl. fee} & 0.231908 & 0.020275 & 0.09402 \\
{Address type} & 0.210258 & 0.027752 & 0.339128 \\
Power of ten & \\
\tabitem $n = 2$ & 0.488912 & 0.011578 & 0.40525 \\
\tabitem $n = 3$ & 0.443826 & 0.006344 & 0.335279 \\
\tabitem $n = 4$ & 0.399768 & 0.00533 & 0.277476 \\
\tabitem $n = 5$ & 0.325896 & 0.006039 & 0.191026 \\
\tabitem $n = 6$ & 0.229245 & 0.005357 & 0.115285 \\
\tabitem $n = 7$ & 0.114534 & 0.000567 & 0.053381 \\
\addlinespace
\multicolumn{2}{l}{\textit{Consistent fingerprint}}\\
Output count & 0.271959 & 0.124974 & 0.429089 \\
Input/output count & 0.264151 & 0.108481 & 0.571849 \\
Version & 0.223513 & 0.003444 & 0.297377 \\
Locktime & 0.302155 & 0.003055 & 0.356169 \\
RBF & 0.059006 & 0.002104 & 0.087981 \\
SegWit & 0.154755 & 0.018995 & 0.224235 \\
SegWit-conform & 0.022865 & 0.000794 & 0.02916 \\
Ordered ins/outs & 0.241257 & 0.052658 & 0.430409 \\
Zero-conf & 0.101069 & 0.055264 & 0.212937 \\
Absolute fee & 0.133944 & 0.029209 & 0.334688 \\
Relative fee & 0.044614 & 0.009221 & 0.215139 \\
Multisignature & 0.137123 & 0.000484 & 0.150975 \\
Address type & \\
\tabitem P2PKH & 0.214408 & 0.013817 & 0.287347 \\
\tabitem P2SH & 0.235967 & 0.012244 & 0.305038 \\
\tabitem P2WPKH & 0.146152 & 0.016719 & 0.218902 \\
\tabitem P2WSH & 0.049883 & 0.00694 & 0.067782 \\
All address types & 0.252002 & 0.021412 & 0.347952 \\
\bottomrule
\multicolumn{4}{p{.95\columnwidth}}{\footnotesize$^{*}$Coverage denotes share of standard transactions with yet unidentified change where the heuristic returned exactly one output.}
\end{tabular}
\end{table}
We start by evaluating the universal and fingerprinting heuristics individually.
We explicitly encode our constraint that only one of the outputs can be the change.
Thus, applied to a transaction, the heuristic may either return an individual output if it is the only output determined to be change, or no output otherwise.
Let $h$ be a heuristic applied to transaction $t$ which returns a set of potential change outputs, then our constrained heuristic $h'$ returns:
\[ h'(t) = \begin{cases}
h(t) & |h(t)| = 1 \\
\varnothing & \text{otherwise}
\end{cases}
\]
This constraint is crucial to prevent cluster collapse: if a heuristic cannot determine a unique change output, we'd rather cluster none of the outputs than both, as clustering both would violate our core assumption and may lead to the merging of two clusters not belonging to the same user.
In \Cref{tab:heuristics} we report the individual heuristics' true and false positive rate (TPR/FPR) for identifying change outputs in our ground truth.
We also report the share of all standard transactions with unknown change for which the heuristic returns a unique output (denoted as \enquote{coverage}).
Most heuristics have a low FPR, with three fingerprinting heuristics being the exception: output count, input/output count and zero-confirmation spending.
The power of ten heuristic has a notably high TPR compared to many other heuristics (its variants are in many cases redundant).
Comparing the TPR of the heuristics to their coverage, we see moderate positive correlation ($r=0.55, p=0.004$), meaning that heuristics that identify more change outputs in our ground truth also tend to be more applicable to the remaining standard transactions.
One outlier is the optimal change heuristic, which only returns a result in \SI{13.4}{\percent} of the remaining transactions (compared to a TPR of \SI{29.9}{\percent} in the ground truth).
This is due to the difference in the number of inputs for these two sets (see \Cref{tab:gt-characteristics}).
At the same time, many of the fingerprinting heuristics appear to be more applicable to the remaining transactions, signaling higher heterogeneity among those.
\num{23.79} million transactions have votes from a universal heuristic, and \num{27.56} million have votes from a fingerprint heuristic.
\num{757937} transactions don't have any predictions.
\roundon{2}
Among the \num{29.291967} million transactions with at least one vote, \num{28.392189} million (\SI{96.9282}{\percent}) have at least one \emph{correct} vote.
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{figures/votes-heuristics.pdf}
\caption{Number of votes from heuristics}
\label{fig:total-votes}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{figures/heuristics-count.pdf}
\caption{Average number of correct and uncorrect votes per transaction and type of heuristic, over time}
\label{fig:heuristics-count}
\end{figure}
\Cref{fig:total-votes} shows the number of (correct and incorrect) votes received by each transaction.
\Cref{fig:heuristics-count} further breaks down the average number of correct and incorrect predictions per transaction over time, grouped by the type of heuristic.
We notice three important trends: the universal heuristics drop over time, likely due to some of the power-of-ten variants becoming less useful (as they contain redundant information, we provide additional plots where the heuristics are aggregated in \Cref{app:figures-pow10-compressed}).
The consistent fingerprint heuristics instead see a steady uptick in the number of correct votes.
This highlights how the increasing variety of protocol features also raises their utility for detecting change outputs.
Finally, there's an uptick in both correct and incorrect fingerprint votes in late 2017 and early 2018, when wallet implementations started to switch to SegWit transaction serialization and address formats (e.g., \cite{BitcoinCore16,CoinbaseSegWitFAQ}).
\roundoff
For the following analyses, we exclude the \num{757937} transactions that don't have any predictions in order to reduce the chance of false positives.
When we later apply the heuristics to the full blockchain, we will also skip transaction without votes from at least one heuristic.
\section{Combining Heuristics}\label{sec:ml-model}
A clear disadvantage of choosing a single individual heuristic for change output detection is that they apply only to a subset of transactions (cf. \Cref{tab:heuristics}).
Furthermore, some heuristics may be more applicable during certain epochs of Bitcoin's history than others.
In contrast to prior work (e.g., an evaluation of three change heuristics \cite{nick2015data}), we also have a larger variety of heuristics available that enable new ways of combining them.
Here, we consider two approaches.
\subsection{Threshold vote}
\Cref{fig:heuristics-count,fig:total-votes} suggest that, in general, a majority of cast heuristic votes should produce the correct outcome.
However, the number of votes cast varies among transactions, and individual votes could be incorrect.
We thus compute a threshold vote: if there are at least $t$ more votes for output $a$ than for output $b$, then output $a$ is considered the change.
Changing the threshold $t$ thereby allows the analyst to require higher degrees of confidence.
We use all of the heuristics listed in \Cref{tab:heuristics} to compute the threshold vote on the full ground truth data set (as there is no training involved, we do not split the data set).
The resulting ROC curve is shown in \Cref{fig:threshold-vote-rf-roc} (for comparison, we also plot the FPR and TPR of the individual heuristics).
We can achieve an ROC AUC of \num{0.9415}, and, for example, a \SI[round-mode=places,round-precision=1]{35.1940}{\percent} true positive rate (TPR) below a false positive rate (FPR) of \SI{.1}{\percent} with a threshold of $t=7$.
Using a threshold vote may not be ideal as the individual heuristics have varying true positive and false positive rates, and some might be more or less reliable during different periods of Bitcoin's history.
Rather, a specific subset of heuristics may provide better classification accuracy.
Instead of manually trying different combinations of heuristics, we opt to use a supervised learning classifier.
\begin{figure}
\centering
\includegraphics[width=.9\columnwidth]{figures/roc-with-individual-heuristics.pdf}
\caption{ROC curves for predicting change in the ground truth data set using the threshold vote and the random forest classifier, compared to individual heuristics. The curve of the threshold vote is based on the entire data set, whereas the curve of the random forest is based on the test set. The random forest model includes additional transaction and output characteristics.}
\label{fig:threshold-vote-rf-roc}
\end{figure}
\subsection{Random forest classifier}
We use a random forest classifier to predict the change output of a transaction.
A random forest is an ensemble classifier that trains and aggregates the results of individual decision trees.
The first step is to transform our transaction-based predictions into an output-based binary classification problem.
Every output is either a change (\num{1}) or spend (\num{0}) output.
As before, an individual heuristic may produce one of three outcomes: vote for the output, against the output, or not be able to discern between the outputs.
Next, we add additional characteristics about each output and corresponding transaction that may help the classifier differentiate between distinct types of transactions, or wallets.
Output characteristics include the ratio of an output's value to the total output value of a transaction (the change output is the smaller output in \SI{76.76}{\percent} of our ground truth transactions) and its index.
Transaction characteristics include its total value in satoshi, the transaction fee paid per byte, its version number, whether it uses SegWit serialization and sets a non-zero locktime, as well as the number of inputs and the time of inclusion (as epochs of 1008 blocks, about one week).
We use the \texttt{RandomForestClassifier} implementation in scikit-learn 0.24.1.
We add regularization by searching a small parameter grid using a successive halving strategy, optimizing two parameters: the number of features considered at each split, and the minimum number of samples required before each further split.
As we consider an analyst that works with a static snapshot of the blockchain, we randomly split our data set into \SI{80}{\percent} training and \SI{20}{\percent} test set.
We use the training set for the hyperparameter search using 4-fold cross-validation, optimizing the area under the curve (AUC) as our scoring metric.\footnote{Additional details are available in \Cref{app:rf-tuning}.}
To account for the fact that transactions in the same base cluster may be highly similar, we explicitly ensure that all outputs of a base cluster remain in the same set and fold.
Applying the model to the test set, we receive an AUC of \roundnum{4}{.997756} (\Cref{fig:threshold-vote-rf-roc}).\footnote{The AUC on the training set is \roundnum{4}{0.99965}}
We see that random forest model is able to detect a higher share of outputs, especially at low false positive rates, compared to the threshold vote.
In \Cref{fig:comparison-fpr} we show the ROC curves of both the threshold vote and the random forest on the same test set, log-transforming the x-axis to highlight the important difference in low false positive rates.
The random forest achieves much higher true positive rates at low false positive rates, meaning that it correctly identifies the change output in a larger number of transactions.
For example, if we target a false positive rate below \SI{0.1}{\percent}, the threshold vote achieves a TPR of around \SI{39}{\percent} at a FPR of \SI{0.06}{\percent}.
For the same FPR, the random forest achieves a TPR of \SI{73}{\percent}, almost twice as high.
We train a second random forest model only based on transactions that contain predictions of the universal heuristics in order to later predict change in transactions that contain unspent outputs.
Using a similar evaluation strategy as for the full model, the AUC of this model is \roundnum{4}{.997769}.
We note one caveat: our grouping based on the base cluster ID may not be fully effective at preventing homogeneous transactions from the same entity to appear in both sets because the base clustering is likely incomplete (e.g., an entity's transactions can be split among multiple clusters, of which some end up in the training and some in the test set).
Other researcher or companies with access to private, more heterogeneous ground truth may be able to evaluate this possibility.
\begin{figure}
\centering
\includegraphics[width=.9\columnwidth]{figures/rf-vote-comparison.pdf}
\caption{Comparison of the random forest classifier and the threshold vote on the test set. There is a notable difference between the two classifiers for low false positive rates.}
\label{fig:comparison-fpr}
\end{figure}
\subsection{Model validation}
We use two data sets to assess the performance of the random forest model outside of our ground truth.
First, we use the list of \num{16764} transactions identified by \textcite{Huang2018} as ransom payments related to the Locky and Cerber ransomware.
Those payments were identified through clustering, transaction graph analysis and known characteristics of the ransom amounts.
The data set contains not only transaction hashes, but also the index (and amount) of the predicted payment output.
Out of the \num{16764} transactions in the data set, we exclude \num{3057} because they don't match our definition of a standard transaction. For \num{24} transactions, none of the heuristics return any distinct votes.
\num{1636} transactions directly reuse change, and in \num{850} transactions multi-input clustering already correctly revealed the change output.
For the remaining \num{11197} transactions we predict the change output using the random forest model and achieve an AUC of \roundnum{3}{0.9964370105163713}.
Our second data set is constructed using a GraphSense tagpack \cite{GraphSenseTagPacks} that contains \num{382} tags for addresses of \num{273} distinct entities (such as exchanges or gambling services).
We identify each associated cluster and then extract transactions between the clusters, assuming that the output belonging to a different cluster is the spend output.
In total, we extract \num{2167588} transactions between the clusters.
As the data is highly skewed towards a few clusters, we limit the total number of transactions for each combination of interacting clusters to \num{1000} (sampled randomly), giving us \num{853011} transactions.
Out of these, \num{13353} don't have any predictions, \num{113847} reuse an address for change and \num{457818} change outputs have already been identified through cluster membership.
For the remaining \num{267993} transactions we predict the change output and achieve an AUC of \roundnum{3}{0.9732}.
\section{Clustering Change Outputs}\label{sec:clustering}
We now use the random forest model to enhance the base clustering.
To this end, we predict the change output in \num{258} million standard transactions with yet unknown change.
We exclude \num{8.9} million transactions where no individual heuristic identified a change output.
We use our second model that does not include the consistent fingerprint heuristics for \num{12.7} million transactions with unspent outputs.
Informed by the histogram of probabilities (cf. \Cref{fig:random-forest-predictions} in the appendix), and in order to keep the likelihood of false positives low, we use a conservative probability threshold of \num{0.99}.\footnote{This corresponds to a false positive rate of \SI{0.079}{\percent} for our full model. We use a threshold of \num{0.9955} for the model excluding fingerprint heuristics to match the FPR.}
\roundon{2}
This gives us \num{119.862981} million change outputs (for \SI{46.337115}{\percent} of transactions).
In comparison, using the threshold vote to predict change with $t=7$ returns a change output for \SI{36.19}{\percent} of transactions.\footnote{The threshold $t=7$ corresponds to a FPR of \SI{0.061}{\percent} on the test set, the closest to match the FPR of the random forest.}
We then enhance the base clustering by merging the base cluster of the inputs with the base cluster of the change address in the order that the transactions appear on the blockchain.
\roundoff
\subsection{Naive merging leads to cluster collapse}
We inspect the enhanced clustering with regards to cluster collapse.
First, we look at the size of the enhanced clusters.
A typical measure for the size of the cluster is the number of addresses contained in it. However, this may not always be reliable: if entities reuse addresses, their clusters will appear small despite being responsible for a large volume of on-chain transactions.
We therefore also inspect the number of transactions originating from the cluster, which is independent of address reuse.
Without address reuse, these two measures should correlate as a fresh address is created for every outgoing transaction.
Clustering the identified change outputs reduces \roundnum{1}{142.410800} million affected base clusters into \roundnum{1}{31.589837} million enhanced clusters.
However, it leads to severe cluster collapse: there is one large supercluster, of which the prior Mt.\ Gox supercluster is a part of, that consists of \roundnum{1}{172.276068} million addresses (a \SI{1214}{\percent} increase) and \roundnum{1}{98.568690} million transactions (a \SI{2313}{\percent} increase).
Inspecting the \num{273} labeled clusters from the Graphsense tag pack, we find that \num{148} of them have been merged into this supercluster.
\subsection{Constraints prevent cluster collapse}
\begin{figure}
\centering
\begin{tikzpicture}[
entity/.style = {
draw,
minimum height = .9cm,
minimum width = 2cm,
rounded corners=5pt
},
lbl/.style = {
font = \scriptsize,
inner sep = 1pt
},
>=stealth]
\node[entity] (a) {Entity A\Aq};
\node[entity, right = 2.5cm of a] (b) {Entity B\Aq};
\draw[semithick, ->, bend left = 10] ([yshift=0.125 cm]a.east) to node [auto, lbl] {change, $t_2$} ([yshift=0.125 cm]b.west);
\draw[semithick, ->, bend left = 40] ([yshift=0.25 cm]a.east) to node [auto, lbl] {spend, $t_1$} ([yshift=0.25 cm]b.west);
\node[entity, below = .5cm of a] (a2) {Entity A\Aq};
\node[entity, right = 2.5cm of a2] (b2) {Entity B\Aq};
\draw[semithick, ->, bend left = 10] ([yshift=0.125 cm]a2.east) to node [auto, lbl] {change, $t_2$} ([yshift=0.125 cm]b2.west);
\draw[semithick, <-, bend right = 10] ([yshift=-0.125 cm]a2.east) to node [below, lbl] {spend, $t_3$} ([yshift=-0.125 cm]b2.west);
\end{tikzpicture}
\caption{Our constrained clustering prevents the merging of clusters A and B due to conflicting types of payments between them.} \label{fig:constrained-clustering}
\end{figure}
The majority of merges we observe involve address clusters that so far had only been seen in a single transaction.
In these cases, the impact of a single misclassification is low unless a sequence of such merges collapses multiple clusters.
However, in a small number of merges two large clusters are combined, leading to cluster collapse.
For example, if there are two large exchanges that interact frequently with each other, a single misidentified change address would collapse their clusters.
\paragraph{Approach.}
We use this intuition to constrain which clusters we merge.
While change outputs predicted by our model should be clustered, we can use outputs predicted to be spends to prevent cluster merges: the input cluster should not be clustered into the cluster of the spend.
Let $p_{i}$ be the probability returned by the random forest model for output $i$, then we define two thresholds $p_{change}$ and $p_{spend}$ such that if $p_{i} > p_{change}$ the clusters should be merged, and if $p_{i} < p_{spend}$ then the clusters should not be merged.
In many cases, these constraints prevent the spend and change output of a single transaction to end up in the same cluster (cf. \Cref{fig:constrained-clustering}).
It is therefore a stronger assumption than our core assumption, which only considered the change.
This approach is comparable to that by \textcite{ermilov2017automatic} to use address tags in combination with a probabilistic model to reduce the number of conflicting tags in the final clustering.
However, most public sources of address tags only contain information on a limited amount of intermediaries and clusters.
Our approach, instead, potentially covers all clusters appearing in the \num{258} million standard transactions, including those that may be hard to interact with (and thereby tag) manually.
Due to the size of the blockchain, and the large number of predictions we have, here we only consider the binary case of preventing any potential conflict, accepting that we may prevent some valid merges in the process.
\roundon{2}
We implement this approach as a constrained union-find algorithm that prevents merging two clusters that are related by a predicted spend output.
That is, for every spend from cluster $c_i$ to cluster $c_j$ predicted by the random forest with $p \leq p_{spend}$, we add a constraint to cluster $c_i$ that it must not be merged with cluster $c_j$.
When merging two clusters, we compare each cluster's set of constraints to the set of members of the other cluster and skip the merge if the sets intersect.
\paragraph{Results.}
Using the same $p_{change}$ as before and setting $p_{spend} = 0.01$, the constrained clustering skips \num{419641} merges that would have violated constraints and retains \num{247111} more individual clusters than the unconstrained clustering.
\roundnum{1}{8.869488} million of the predicted merges are redundant because the clusters had already been merged.
We find that the constrained merging prevents the previously observed severe cluster collapse.
For example, the constrained clustering does not produce the large Mt.\ Gox supercluster: the enhanced cluster contains \roundnum{1}{4.299191} million transactions (a \SI{5}{\percent} increase) and \roundnum{1}{14.357678} million addresses (a \SI{10}{\percent} increase).
Assessing the \num{273} labeled clusters, there are only ten instances left where two labeled clusters are merged together.
Three of those instances are pairs of gambling services (e.g., \texttt{dadice.com} and \texttt{999dice.com}), the others also involve exchanges and darknet markets.
We suspect that unusual types of payouts from these services might have triggered their collapse.
\roundoff
\Cref{tab:tx-count-smaller-cluster} shows percentiles of the number of transactions associated with each smaller cluster that was merged into a larger cluster.
In at least \SI{90}{\percent} of merges, the transaction count of the smaller cluster was equal to or below \num{1} (\num{0} if unspent and not used otherwise).
This highlights how change address clustering is useful to merge small clusters occurring in only a single transaction that are missed by multi-input clustering.
We can also see that until the \num{99.99} percentile, transaction counts are very similar between the unconstrained and the constrained clustering, but that the constrains prevent large merges from taking place, preventing cluster collapse.
\begin{table}[]
\centering
\caption{Transaction count of smaller cluster being merged}
\label{tab:tx-count-smaller-cluster}
\begin{tabular}{S[table-format=2.3]
S[table-format=4.0]
S[table-format=4.0]}
\toprule
& \multicolumn{2}{c}{{Transaction count}} \\
\cmidrule(lr){2-3}
{Percentile} & {Naive} & {Constrained} \\
\midrule
90 & 1 & 1 \\
99 & 6 & 6 \\
99.9 & 27 & 26 \\
99.99 & 143 & 114 \\
99.999 & 2943 & 646 \\
\bottomrule
\end{tabular}
\end{table}
\Cref{fig:cluster-collapse} shows histograms of the increase in address count and transaction count for each affected cluster.
Increase here is the difference between the resulting size of the enhanced cluster and the largest individual base cluster before change address clustering.
The histograms are plotted on a log-log axis, highlighting the extreme skewness of the distribution.
Most clusters increase only by a few addresses or transactions.\footnote{Due to the log-scale, the histogram showing the increase in transaction size excludes \roundnum{1}{2.41} million clusters that, using the naive approach, didn't increase in their transaction count, and \roundnum{1}{2.61} million using the constrained approach, respectively.\label{fn:log-scale}}
The supercluster can also easily be spotted.
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{figures/cluster-address-increase.pdf}
\includegraphics[width=\columnwidth]{figures/cluster-tx-increase.pdf}
\caption{Absolute increase in address and transaction count per affected cluster, using either the naive or the constrained approach. Note the caveat in \cref{fn:log-scale}.}
\label{fig:cluster-collapse}
\end{figure}
Finally, we inspect the clustering with regards to the maximum time difference between two transactions.
We would expect that transactions in the merged clusters should, in general, not be too far apart.
If two clusters are merged such that the maximum time gap between transactions increases substantially (say, from a few months to a few years), then this potentially indicates an incorrect clustering.
For the majority (\roundnum{0}{28.054845} million) of the new clusters, each prior base cluster had fewer than 2 transactions.
The median max time gap for those clusters amounts to just below \num{2} hours.
For instances where at least one original cluster already consisted of \num{2} or more transactions, the median increase in the maximum time gap is only around half an hour.
Overall, the distribution is highly centered (cf. \Cref{fig:time-gap-change}).
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{figures/time-gap-change.pdf}
\caption{Change in maximum time gap for clusters where at least one merged base cluster had two or more transactions. The X-axis is cut off to highlight the most important area (accounting for \SI{86}{\percent} of clusters).} %
\label{fig:time-gap-change}
\end{figure}
\section{Impact on Blockchain Analyses}\label{sec:applications}
Change address clustering is generally used as a pre-processing step before analyzing activity of entities on the blockchain.
Using different heuristics (or none at all) thus affects the outcome of these analyses.
In this section we present two exemplary applications to highlight the impact change address clustering has on blockchain analyses. Furthermore, we compare our clustering to one created with a popular change address heuristic based on address reuse.
\subsection{Cashout flows from darknet markets to exchanges}
For our first example we evaluate the impact of our enhanced clustering on analysing payment flows from darknet markets to exchanges, using address tags from the GraphSense tag pack to identify relevant clusters.
The tag pack contains address tags for \num{117} exchanges and \num{15} darknet markets.
We extract the value of all outputs in transactions initiated by a darknet market that are sending bitcoins to an exchange, comparing the transaction volume calculated using our base clustering to that of our enhanced clustering.
The median increase in output value across all \num{15} exchanges amounts to \SI{13.86}{\percent}.
Overall, the total amount of bitcoins flowing from the darknet markets to exchanges increases from BTC \num{821500} to BTC \num{961519} (a \SI{17}{\percent} increase).
An overview of each individual market's increase in transaction volumes is presented in \Cref{tab:darknet-market-volumes} in the appendix.
\subsection{Improved estimate of velocity}
We replicate the analysis of velocity conducted by \textcite{BlockSci}, an example for a longitudinal analysis of economic activity occurring on the Bitcoin blockchain.
For this analysis, clustering is used to remove self-payments of users (such as change outputs), which would artificially inflate estimates of economic activity.
The better and more complete our clustering, the more self-payments are removed and hence the lower the estimate will be.
Our refined clustering reduces their estimate of bitcoins moved per day between January 2017 to June 2020 by about \SI{11.7}{\percent}.
This number is quite similar to the impact on cash-out flows.
In general, much activity is generated by large intermediaries, which are more prone to be clustered by the multi-input heuristic.
Our enhanced clustering predominantly merged small clusters, which should give a more realistic estimate for their activity.
As we chose relatively conservative thresholds to enhance the clustering, loosening them could lead to larger effect sizes.
\subsection{Comparison to the Meiklejohn heuristic}
We compare our constrained clustering to one created using the address reuse-based heuristic presented by \textcite{Meiklejohn2013}, which has subsequently been used in other studies (e.g., \cite{conti2018economic, parino2018analysis}).
While the authors highlight the need for manual intervention to prevent cluster collapse, this is likely infeasible for analysts without in-depth domain knowledge or the right set of tools.
There are two possible ways to implement the heuristic, either such that an output is considered to be change if its address has not appeared in any previous transactions (we call this variant local), or such that over the entire blockchain it appears in only one output (global).
The latter thus depends on the particular state of the blockchain.
Applying the local heuristic to the standard transactions with unknown change produces a large supercluster, including \num{106.3} million transactions and \num{216.1} million addresses. \num{166} of the tagged clusters appear in this supercluster.
Similarly, the global variant produces a supercluster containing \num{113.3} million transactions and \num{230.4} million addresses, with \num{175} tagged clusters ending up in the supercluster.
To characterize the difference between the clusterings, we look at the probability that two random addresses are clustered in a particular clustering.
The probability of two addresses being clustered together increases by a factor of \num{40} when using the Meiklejohn heuristic compared to our constrained clustering, further highlighting the cluster collapse (cf. \Cref{tab:meiklejohn} in the appendix).
Finally, we take closer look at the individual predictions.
First, comparing the predictions of the local Meiklejohn heuristic to those of our constrained clustering, they overlap on \num{53.6} million transactions and differ for \num{0.9} million of those. The global heuristic differs on \num{1.2} million transactions out of an overlapping \num{62.3} million.
For those conflicting predictions, the difference in output value to our clustering amounts to BTC \num{1.6} million, or USD \num{8.8} billion of economic activity for the local heuristic.
For the global heuristic, the difference amounts to BTC \num{3} million, or USD \num{16.3} billion.
\section{Discussion}\label{sec:discussion}
Our results confirm existing expectations (e.g., \cite{BitcoinWikiPrivacy}) that in many instances change address detection is feasible with high precision.
This may motivate users to adopt privacy-enhancing countermeasures.
Techniques to avoid address reuse (such as one-time addresses \cite{Monero}) would reduce the effectiveness of the multi-input heuristic and thus also of our ground truth extraction technique.
Widespread use of cooperative obfuscation techniques like CoinJoin \cite{CoinJoin} and PayJoin \cite{BIP78} would make multi-input clustering unreliable (by causing cluster collapse), and ambiguity-based obfuscation such as the randomization of address types (e.g., \cite{BitcoinCore16}) could thwart the fingerprinting heuristics.
If users adopted these techniques more widely (cf. \cite{Moeser2017}), it would also make law enforcement investigations into cryptocurrencies more challenging, increasing the need for complimentary approaches that do not rely on address clustering \cite{moeser2019blacklisting}.
At the same time, the transparency blockchains provide shouldn't categorically be considered a disadvantage, and we think that our work is useful beyond law enforcement purposes.
Researchers studying social or economic questions, using cryptocurrencies as a \enquote{social science lab} \cite{boehme2015jep}, benefit from increased transparency.
Blockchains contain a valuable trove of financial data that traditionally hasn't been available to researchers \cite{blazquez2018bigdata}.
In this context, our techniques can help to remove ambiguity about ownership of funds, improving data quality and leading to more realistic estimates.
\section{Conclusion}\label{sec:conclusion}
Address clustering is an important cornerstone of many blockchain analyses.
In this paper, we've taken a first step towards building better models that allow analysts to identify change outputs in transactions, enabled by a new ground truth data set extracted from the Bitcoin blockchain.
We've further demonstrated how constraints based on our model's predictions can prevent cluster collapse.
Finally, we've shown that the resulting, enhanced clustering changes the outcomes of economic analyses, in our examples by about \SIrange{11}{17}{\percent}.
Given this impact, we hope that our work will encourage further research into change address clustering.
| {'timestamp': '2021-07-14T02:05:31', 'yymm': '2107', 'arxiv_id': '2107.05749', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05749'} | arxiv |
\section{Introduction}
\label{sec:intro}
Running DNN based applications locally on mobile devices is becoming a necessity for many modern applications. The importance of deploying AI on the edge, in devices such as smartphones, drones and autonomous vehicles, can be mainly attributed to three factors. Using cloud resources to run AI algorithms can lead to delays in inference due to \textit{communication latency}. Furthermore, such communication with the cloud is \textit{energy inefficient} as it requires additional power and is prone to \textit{privacy breaches}, which for instance in the autonomous vehicle industry could have dire consequences.
Recent work suggests that compressing overparametrized DNNs after training leads to a reduction in the overall time and cost of development of DNN based applications \cite{li2020train}. In the context of the ImageNet Large-Scale Visual Recognition Challenge (ILSVRC) \cite{deng2009imagenet} it took multiple years of extensive research and development to reduce the size of initial networks like VGG16 \cite{simonyan2014very} and find computationally efficient alternatives such as MobileNets \cite{howard2017mobilenets}. In comparison, the DNN compression approach can provide an equivalent reduction in a cost-effective way by automating the research for smaller and efficient DNNs.
In this paper, we propose the DDLR approach to compress a given DNN by imposing a low-rank structure on its fully connected layers. While there exist approaches to reduce the number of parameters in a given DNN by imposing structures such as low-rank or sparsity, these approaches are not data-driven and as a consequence they require computationally expensive retraining after parameter reduction \cite{cheng2017survey}.
Recently, the data-driven sparsity based approach Net-Trim showed that leveraging data during parameter reduction leads to better compression ratios without retraining \cite{aghasi2017net}. While sparsification gives good compression performance for storage and transmission, it is very challenging to get equivalent gains in inference unless special hardware is designed to explicitly exploit the sparsity and custom software implementation is utilized. In contrast, the low-rank based structural approximation that factorizes each parameter matrix as the product of two low dimensional matrices has no such requirements~\cite{wang2019deep}.
Motivated by Net-Trim and the amenability of low-rank structures for faster inference, in this paper we propose a data-driven method that imposes a low-rank structure on the dense layers of a DNN. We formulate this method as a problem of minimizing the rank of the weight matrix of a dense layer under given performance guarantees. This is a non-convex optimization problem which we relax to a tractable convex optimization formulation lying in the family of well known semi-definite programs (SDPs) which can be solved efficiently using off-the-shelf solvers. The proposed DDLR algorithm solves this problem for each dense layer of a pretrained DNN independently, thereby allowing for extensive parallelization of the process.
Our results show that our method manages to reduce the number of parameters significantly more than Net-Trim while maintaining accuracy levels comparable to the original \textit{uncompressed} network.
The main advantages of our method can be outlined as follows: \textit{(1)} the imposed low-rank structure allows for large parameter reduction and fast inference via efficient matrix-vector multiplications, \textit{(2)} each layer can be compressed independently allowing for parallel processing, \textit{(3)} the error due to compression in each layer is controlled explicitly and \textit{(4)} our method does not require retraining to achieve high accuracy.
\section{Related Work}
Given the large size of modern DNN architectures many methods for storage and computational complexity reduction have been proposed in the literature. One commonly used technique for parameter reduction is that of network pruning \cite{liu2018rethinking, blalock2020state}. Network pruning assigns scores to the parameters of a pretrained neural network and removes parameters based on these scores \cite{han2015learning}. A key component of pruning is the need to retrain the model in order to increase accuracy to levels close to the original network. Pruning can be performed on a single parameter basis \cite{aghasi2017net, laurent2020revisiting} or by taking into account groups of parameters that ultimately lead to structured layers amenable for efficient computations \cite{li2016pruning, lin2019towards}. Another branch of parameter reduction techniques is that of low-rank representation of DNN layers. In \cite{tai2015convolutional} the authors present a method to impose a low-rank representation on the convolutional layers of CNNs. Closer to our framework, \cite{sainath2013low} proposes an approach to impose low-rank structure on the last dense layer of a DNN while training.
Most of the compression techniques above require further retraining which can be computationally expensive for very large models. DNN compression without retraining is an important practical problem and recently \cite{aghasi2017net} proposed Net-Trim which leverages data to perform sparsity based parameter reduction and achieve better DNN compression without retraining. However, it is very challenging to extend the compression gains to faster inference speeds as sparsity structure requires custom hardware and software support for that purpose. The off-the-shelf graphical processors (GPUs)
use single instruction, multiple threads execution models, i.e. the same sequence of operations is computed in parallel on different data to accelerate matrix-vector multiplication. The speed of matrix-vector product is then directly linked to the slowest thread, which might be affected by the number of non-zeros in the computation allocation to each thread and the overhead associated with reading the non-zero entries from the chosen compressed sparse storage format. Consequently, it is quite challenging via sparsity structure, since the non-zero entries could be arbitrarily distributed, to get faster matrix-vector products. The low-rank structure on the other hand does not suffer from such issues and provides faster inference using off-the-shelf hardware. Therefore, in this paper we extend Net-Trim \cite{aghasi2017net} to compress DNNs by imposing low-rank structures on the layers.
\section{Method}
In this section we outline our DDLR method that imposes low-rank representations on the weight matrices of the fully connected layers in a pretrained DNN.
\subsection{DDLR layers}
Consider a DNN with $L$ dense layers. Let the $\ell_{\textrm{th}}$ layer of this DNN be a fully connected dense layer with weight matrix $\mathbf{W}_\ell\in\mathbb{R}^{n_{\ell-1}\times n_{\ell}}$ with $n_{\ell-1}$ denoting the dimension of its input and $n_{\ell}$ being the dimension of its output. The corresponding bias of that layer is denoted with $\mathbf{b}_{\ell}\in\mathbb{R}^{n_{\ell}}$. Let also $\mathbf{Y}_{\ell-1}\in\mathbb{R}^{N\times n_{\ell-1}}$ and $\mathbf{Y}_{\ell}\in\mathbb{R}^{N\times n_{\ell}}$ denote the input and output matrices of the $\ell_{\textrm{th}}$ layer respectively, with the number of rows $N$ corresponding to the number of approximation training data in the network input matrix $\mathbf{X} \in \mathbb{R}^{N \times n_0}$. We focus on DNNs that utilize the $\textrm{ReLU}(x) = max(x,0)$ activation function as they form the backbone of DNN architectures. Our method can be generalized to any other activation function that can lead to a convex constraint in~(\ref{initial-optimization}). Given the input $\mathbf{Y}_{\ell-1}$ the output of layer $\ell$ is obtained as follows
\begin{equation}
\mathbf{Y_{\ell}}= \textrm{ReLU} ( \mathbf{Y}_{\ell-1}\mathbf{W}_{\ell}+\mathbf{1}_{N} \textbf{b}_{\ell}^T),
\end{equation}
where $\mathbf{1}_{N}$ is a $N$-dimensional vector of ones. In order to impose a low-rank structure on the weight matrix $\mathbf{W}_{\ell}$ we need to minimize the $rank(\cdot)$ function of that matrix. Given the non-convexity of the $rank(\cdot)$ function we propose solving the following optimization problem
\begin{equation}
\begin{aligned}
& \underset{\mathbf{U}\in\mathbf{R}^{n_{\ell-1}\times n_{\ell}}}{\text{minimize}}
& & ||\mathbf{U}||_* \\%+ \beta||U-AUB||_* \\
& \text{subject to}
& & ||\textrm{ReLU} ( \mathbf{Y}_{\ell-1}\mathbf{U}+\mathbf{1}_{N} \textbf{b}_{\ell}^T) -\mathbf{Y}_{\ell}||_F\leq \epsilon_{\ell}.
\end{aligned}
\label{initial-optimization}
\end{equation}
The objective function uses the well known nuclear norm relaxation of the $rank(\cdot)$ function in order to obtain a convex objective \cite{fazel2001rank} while the constraint requires the output of the compressed layer to be close to the output of original layer. The layer output error due to compression is controlled by a user specified threshold $\epsilon_{\ell}$. Intuitively, we expect as $\epsilon_{\ell}$ increases the rank of the layer to decrease more since the constraint is becoming more relaxed. However, the constraint in (\ref{initial-optimization}) is non-convex due to the $\textrm{ReLU}$ activation function inside the norm. To alleviate this issue we relax the constraint following~\cite{aghasi2017net}, to obtain the convex constraint
\begin{equation}
\begin{cases}
||(\mathbf{Y}_{\ell-1}\mathbf{U}+\mathbf{1}_{N} \textbf{b}_{\ell}^T-\mathbf{Y}_{\ell})\circ \mathbf{M}_{\ell}||_F^2\leq \epsilon_{\ell}^2\\
(\mathbf{Y}_{\ell-1}\mathbf{U}+\mathbf{1}_{N} \textbf{b}_{\ell}^T)\circ \mathbf{M}_{\ell}'\leq 0
\end{cases},
\label{convex-set}
\end{equation}
where $\mathbf{M}_{\ell}$ is a mask matrix of the same dimension as $\mathbf{Y}_\ell$ selecting the positive entries of $\mathbf{Y}_\ell$ elementwise, i.e. the $(i,j)_{\textrm{th}}$ entry $\textbf{M}_{\ell}^{ij} = 1$ if $ \mathbf{Y}_\ell^{ij} > 0$ and $\mathbf{M}_{\ell}^{ij} = 0$ otherwise. Similarly, $\mathbf{M}_{\ell}'$ is a mask matrix selecting the non-positive entries of $\mathbf{Y}_\ell$ and $\circ$ denotes the matrix Hadamard product. Intuitively, we penalize the deviation of the entries of the compressed layer that correspond to the positive entries of the original layer as the latter are the only ones that are not affected by the ReLU activation function. Furthermore, we allow the entries that correspond to the non-positive entries of the original layer to take any non-positive value. This step allows us to decrease the rank of the weight matrix even more without accumulating extra error. So problem (\ref{initial-optimization}) relaxed using (\ref{convex-set}) can now be written as
\begin{equation}
\begin{aligned}
& \underset{\mathbf{U}\in\mathbf{R}^{n_{\ell-1}\times n_{\ell}}}{\text{minimize}}
& & ||\mathbf{U}||_* \\%+ \beta||U-AUB||_* \\
& \text{subject to}
& & ||(\mathbf{Y}_{\ell-1}\mathbf{U}+\mathbf{1}_{N} \textbf{b}_{\ell}^T-\mathbf{Y}_{\ell})\circ \mathbf{M}_{\ell}||_F^2\leq \epsilon_{\ell}^2\\
& & &(\mathbf{Y}_{\ell-1}\mathbf{U}+\mathbf{1}_{N} \textbf{b}_{\ell}^T)\circ \mathbf{M}_{\ell}'\leq 0,
\end{aligned}
\label{relaxed-optimization}
\end{equation}
from which we obtain the solution $\hat{\mathbf{U}}_{\ell}$. This formulation allows for imposing structure on the layers while explicitly controlling for the error of the compressed layer output. This problem is a SDP with quadratic constraints and can be solved with most off-the-shelf solvers like SCS~\cite{ocpb:16} and CVXOPT~\cite{andersen2013cvxopt}.
\subsection{Parallel implementation}
The optimization problem~(\ref{relaxed-optimization}) imposes a low-rank structure on a single layer of a network. To compress networks with multiple layers we can compress each layer individually and independently from each other. This process is outlined in Algorithm~\ref{algo-1}, where compression of each layer is an independent of the rest of the layers optimization problem. Given that each layer is compressed independently, the algorithm allows for parallel implementation. The algorithm requires the initial data matrix as input $\mathbf{X}^{N\times n_{0}}$, the original trained weight matrices and biases of the layers and the user specified tolerances $\epsilon_{\ell}$. The output is a sequence of low-rank matrices for each dense layer.
\begin{algorithm}[h]
\SetAlgoLined
\SetKwInput{Input}{Input~}
\SetKwInput{Output}{Output~}
\Input{$\mathbf{X}, \mathbf{W}_{\ell}, \textbf{b}_{\ell}, \;\epsilon_{\ell}, \;\ell = 1,\ldots,L$}
$\mathbf{Y}_{0}=\mathbf{X}$\\
\For{$\ell$= 1,\ldots,L}{
$\mathbf{Y}_{\ell}= \textrm{ReLU}(\mathbf{Y}_{\ell-1}\mathbf{W}_{\ell}+\mathbf{1}_{N} \textbf{b}_{\ell}^T)$
}
\For{$\ell$= 1,\ldots, L}{
$\mathbf{M}_{\ell}^{i,j}=1$ if $\mathbf{Y}_{\ell}^{i,j}>0$, otherwise $0$ \\
$\mathbf{M}_{\ell}'^{i,j}=1$ if $\mathbf{Y}_{\ell}^{i,j}\leq0$, otherwise $0$\\
Solve (\ref{relaxed-optimization})
}
\Output{$\hat{\mathbf{U}}_{\ell},\; \ell=1,\ldots, L$}
\caption{DDLR Algorithm}
\label{algo-1}
\end{algorithm}
\vspace{0.5cm}
It should be noted that Algorithm~\ref{algo-1} requires the solution of a SDP (line $8$) for each layer. The solution of SDPs can present a computational bottleneck when weight matrices have large dimensions (e.g. the first dense layer of VGG-16) or the number of data samples $N$ used to solve~(\ref{relaxed-optimization}) is large. In such cases, to alleviate these issues one can \textit{1)} solve~(\ref{relaxed-optimization}) to suboptimality using fewer iterations and \textit{2)} use only a subset of the whole training set to solve~(\ref{relaxed-optimization}). Given the size of the layers in the networks studied in the experiments section we will be solving the SDPs to optimality by using only a sample from the original dataset used for training the network.
\section{Experiments}
We demonstrate the effectiveness of our method on three different datasets. An artificial nested spiral, the MNIST~\cite{lecun2010mnist} and the CIFAR-10~\cite{krizhevsky2009learning} datasets. Through experimentation we concluded that compression works well when the number of data samples used to solve~(\ref{relaxed-optimization}) is no less than $5\%$ of the data used to train the network. For this reason, and to deal with the scaling issues of solving SDPs multiple times, we will be training the networks with a subsample of the available data and we will be solving~(\ref{relaxed-optimization}) using a subset of size $N$ of that sample as presented in the following subsections. For each experiment carried out we use two different values of $N$ in order to study the performance of DDLR with respect to that sample complexity. The main method we will be comparing DDLR with is Net-Trim. Net-Trim on which our method is partially based, imposes a sparse structure on the layers post-training by minimizing the induced $\ell_1$ matrix norm~\cite{aghasi2017net}. Both DDLR and Net-Trim can be used to compress DNNs, removing redundancies from the networks and leading to faster inference. We will be comparing the compression level and the resulting accuracies obtained from these two methods. The benefits of DDLR regarding the possible inference speedup was discussed in the related work section.
For each of the following datasets we utilize Algorithm~\ref{algo-1} for different values of $\epsilon_{\ell}$ to compress a number of the hidden layers. For each experiment we report the relative accuracy on the test set of the compressed network with respect to the original accuracy of the uncompressed network. We measure the compression by reporting the fraction of parameters needed to be stored for the compressed network with respect to the original. For the sparse matrix experiments we assume that the parameters are stored in COO format. The COO format storage requirement is three times the number of positive entries of a matrix. It should be noted that it is possible to get the same value for the rank for more than one values of $\epsilon_{\ell}$. In such cases, we choose the solution that leads to higher accuracy on the test data.
\subsection{Spiral dataset}
The first dataset is a spiral of two-dimensional points representing two classes. The data points were generated by sampling points on the spiral and adding i.i.d. noise uniformly distributed in the interval $[0,3.5]$ for each dimension.
\begin{figure}[h]
\centering
\includegraphics[trim=0 0 0 32,clip, scale=0.55]{plot_original_boundary.pdf}
\caption{Spiral dataset data and decision boundary.}
\label{fig:Spiral_New_Data}
\end{figure}
In this experiment, we consider a DNN classifier with two hidden layers to label the points lying on the spiral. The dataset consists of a total of $1024$ points out of which $80\%$ points were used for training the DNN and the remaining $20\%$ were used for testing. The DNN classifier uses the ReLU activation function except for the last layer where the standard \emph{softmax} function is used. The dimensions of the network layers are $\mathbf{W}_1 \in \mathbb{R}^{2\times 80}, \mathbf{W}_2 \in \mathbb{R}^{80\times 80}$ and $\mathbf{W}_3 \in \mathbb{R}^{80\times 2}$. The DNN was trained by minimizing the cross entropy loss using the stochastic batch gradient descent algorithm with a batch size of $32$ for $1000$ epochs with learning rate $0.001$. The data points along with the decision boundary obtained from the trained DNN are shown in Figure~\ref{fig:Spiral_New_Data}.
We compress only the second layer $\mathbf{W}_2$, as the first and last ones are already low-rank given their dimensions, by utilizing Algorithm~\ref{algo-1}. We implemented the DDLR algorithm under two different scenaria, one using $N=256$ and another using $N=512$ data points for the compression, chosen randomly from the original training dataset. In order to obtain various rank approximations we use the following values for the compression error, $\epsilon_{\ell} \in [0.02, 0.05, 0.08, 0.1, 0.12, 0.15, 0.2, 0.25, 0.3, 0.5, 0.6]\cdot C$, where $C=\lVert Y_{\ell-1}\rVert_F$ is used for scaling purposes. We use the elbow rule to threshold the singular values of the solution of~(\ref{relaxed-optimization}) to obtain the final low-rank weight matrix. As expected, larger values of $\epsilon_{\ell}$ yield layers with lower rank. For both choices of $N$ DDLR seems to outperform Net-Trim achieving test accuracy close to the original using only $60\%$ of the initial parameters. The original accuracy is recovered with about $80\%$ of the original parameters.
\begin{figure}[h]
\centering
\hbox{\hspace{-1.4em} \includegraphics[scale=0.58]{spiral_results.pdf}}
\caption{Relative test accuracy for DDLR and Net-Trim with varying DNN size ratios on Spiral dataset.}
\label{fig:Spiral_LR_NLR_Comp}
\end{figure}
\subsection{MNIST dataset}
For the second set of experiments we use the LeNet-5 CNN architecture~\cite{lecun1998gradient} to classify the handwritten digits of the MNIST dataset. LeNet-5 has three dense layers of dimensions $\mathbf{W}_1\in\mathbb{R}^{256\times120},\mathbf{W}_2\in\mathbb{R}^{120\times84}$ and $\mathbf{W}_3\in\mathbb{R}^{84\times10}$ that follow the convolutional layers. We train LeNet-5 using $1024$ data samples from the original dataset, a $80\%$-$20\%$ train-test split, a batch size of $64$, $30$ epochs and a learning rate of $0.001$. Using Algorithm~\ref{algo-1} we impose a low-rank structure on the first two dense layers of LeNet-5 $\mathbf{W_1}$ and $\mathbf{W}_2$ using the following values of $\epsilon_{\ell}=[0.01,0.02,0.04,0.06,0.08,0.1,0.12,0.14,0.16,0.2,0.3]\cdot C$ for each layer, with $C=\lVert\mathbf{Y}_{\ell-1}\rVert_F$ being a scaling constant. We use $N=128$ and $N=256$ number of samples out of the $1024$ data points to compress the network. Figure~\ref{fig:MNIST_LR_NLR_Comp} presents the relative accuracy for different size ratios. DDLR achieves high compression while maintaining sufficient accuracy. With a $70\%$ reduction in the number of parameters DDLR can achieve a test accuracy less than $4\%$ lower than that of the original network for both values of $N$ while for $N=256$ with a $40\%$ reduction in parameters the accuracy is almost identical to the original. Interestingly, we observe that even for $N=128$ samples, which corresponds to slightly more than $10\%$ of the original data, we are able to obtain high compression associated with high accuracy.
\begin{figure}
\centering
\hbox{\hspace{-1.4em}\includegraphics[scale=0.58]{MNIST_results.pdf}}
\caption{Relative test accuracy for DDLR and Net-Trim with varying DNN size ratios on MNIST dataset.}
\label{fig:MNIST_LR_NLR_Comp}
\end{figure}
\subsection{CIFAR-10 dataset}
For the final set of experiments we classify the CIFAR-10 image dataset using again the LeNet-5 network. For CIFAR-10 the dense layers of Lenet-5 have dimensions $\mathbf{W}_1\in\mathbb{R}^{400\times120},\mathbf{W}_2\in\mathbb{R}^{120\times84}$ and $\mathbf{W}_3\in\mathbb{R}^{84\times10}$. We use $2048$ data points from CIFAR-10 to train our network and $N=128$ and $N=256$ subsamples for compression. For this experiment we compress the first two dense layers $\mathbf{W}_1$ and $\mathbf{W}_2$ using the following values for $\epsilon_{\ell}=[0.01,0.02,0.04,0.06,0.08,0.1,0.12,0.14,0.16,0.2,0.3]\cdot C$, where $C=\lVert\mathbf{Y}_{\ell-1}\rVert_F$. As expected, for larger $N$ both methods perform better with DDLR still outperforming Net-Trim. Quite astonishingly, we observe that with only $50\%$ of the original parameters DDLR achieves an accuracy less than $2\%$ worse in comparison to the accuracy of the original network for $N=256$. For the same relative accuracy on the other hand Net-Trim reduces only by $20\%$ the total number of parameters needed to be stored. Figure~\ref{fig:CIFAR_LR_NLR_Comp} contains the curves of the relative accuracies with respect to the parameter ratio.
\begin{figure}
\centering
\hbox{\hspace{-1.4em}\includegraphics[scale=0.58]{CIFAR_results.pdf}}
\caption{Relative test accuracy for DDLR and Net-Trim with varying DNN size ratios on CIFAR-10 dataset.}
\label{fig:CIFAR_LR_NLR_Comp}
\end{figure}
\section{conclusion and future work}
The DDLR Algorithm is an end-to-end approach that compresses a pretrained DNN by imposing low-rank structures on the fully connected layers while controlling for the overall accuracy decrease in the compressed DNN. We demonstrate in a number of datasets and DNN architectures that high parameter reduction can be achieved at a small loss in accuracy while requiring no retraining. Such reduction can be very significant for storing already trained models on edge devices. Furthermore, low-rank structured layers allow for fast matrix-vector multiplications without the need for specialized hardware which reduce inference time, something that is of vital importance for AI applications, especially on the edge.
The results of the experiments presented in this paper are rather encouraging but also limited due to the computational bottleneck of solving large scale SDPs. This drawback poses an interesting problem that requires theoretical and algorithmic development in future research. An interesting approach in that direction is a reformulation of the optimization problem~(\ref{relaxed-optimization}) in order to be solved using the Alternating Direction Method of Multipliers (ADMM) \cite{boyd2011distributed}. Such an approach can provide better scalability that will allow for compression of networks with larger hidden layers that have been trained on large datasets. Another interesting direction is to understand the impact of quantization on DNNs already compressed using DDLR, as such quantization can lead to significant additional reduction in the size of the networks.
\bibliographystyle{IEEEbib}
\section{Introduction}
\label{sec:intro}
Running DNN based applications locally on mobile devices is becoming a necessity for many modern applications. The importance of deploying AI on the edge, in devices such as smartphones, drones and autonomous vehicles, can be mainly attributed to three factors. Using cloud resources to run AI algorithms can lead to delays in inference due to \textit{communication latency}. Furthermore, such communication with the cloud is \textit{energy inefficient} as it requires additional power and is prone to \textit{privacy breaches}, which for instance in the autonomous vehicle industry could have dire consequences.
Recent work suggests that compressing overparametrized DNNs after training leads to a reduction in the overall time and cost of development of DNN based applications \cite{li2020train}. In the context of the ImageNet Large-Scale Visual Recognition Challenge (ILSVRC) \cite{deng2009imagenet} it took multiple years of extensive research and development to reduce the size of initial networks like VGG16 \cite{simonyan2014very} and find computationally efficient alternatives such as MobileNets \cite{howard2017mobilenets}. In comparison, the DNN compression approach can provide an equivalent reduction in a cost-effective way by automating the research for smaller and efficient DNNs.
In this paper, we propose the DDLR approach to compress a given DNN by imposing a low-rank structure on its fully connected layers. While there exist approaches to reduce the number of parameters in a given DNN by imposing structures such as low-rank or sparsity, these approaches are not data-driven and as a consequence they require computationally expensive retraining after parameter reduction \cite{cheng2017survey}.
Recently, the data-driven sparsity based approach Net-Trim showed that leveraging data during parameter reduction leads to better compression ratios without retraining \cite{aghasi2017net}. While sparsification gives good compression performance for storage and transmission, it is very challenging to get equivalent gains in inference unless special hardware is designed to explicitly exploit the sparsity and custom software implementation is utilized. In contrast, the low-rank based structural approximation that factorizes each parameter matrix as the product of two low dimensional matrices has no such requirements~\cite{wang2019deep}.
Motivated by Net-Trim and the amenability of low-rank structures for faster inference, in this paper we propose a data-driven method that imposes a low-rank structure on the dense layers of a DNN. We formulate this method as a problem of minimizing the rank of the weight matrix of a dense layer under given performance guarantees. This is a non-convex optimization problem which we relax to a tractable convex optimization formulation lying in the family of well known semi-definite programs (SDPs) which can be solved efficiently using off-the-shelf solvers. The proposed DDLR algorithm solves this problem for each dense layer of a pretrained DNN independently, thereby allowing for extensive parallelization of the process.
Our results show that our method manages to reduce the number of parameters significantly more than Net-Trim while maintaining accuracy levels comparable to the original \textit{uncompressed} network.
The main advantages of our method can be outlined as follows: \textit{(1)} the imposed low-rank structure allows for large parameter reduction and fast inference via efficient matrix-vector multiplications, \textit{(2)} each layer can be compressed independently allowing for parallel processing, \textit{(3)} the error due to compression in each layer is controlled explicitly and \textit{(4)} our method does not require retraining to achieve high accuracy.
\section{Related Work}
Given the large size of modern DNN architectures many methods for storage and computational complexity reduction have been proposed in the literature. One commonly used technique for parameter reduction is that of network pruning \cite{liu2018rethinking, blalock2020state}. Network pruning assigns scores to the parameters of a pretrained neural network and removes parameters based on these scores \cite{han2015learning}. A key component of pruning is the need to retrain the model in order to increase accuracy to levels close to the original network. Pruning can be performed on a single parameter basis \cite{aghasi2017net, laurent2020revisiting} or by taking into account groups of parameters that ultimately lead to structured layers amenable for efficient computations \cite{li2016pruning, lin2019towards}. Another branch of parameter reduction techniques is that of low-rank representation of DNN layers. In \cite{tai2015convolutional} the authors present a method to impose a low-rank representation on the convolutional layers of CNNs. Closer to our framework, \cite{sainath2013low} proposes an approach to impose low-rank structure on the last dense layer of a DNN while training.
Most of the compression techniques above require further retraining which can be computationally expensive for very large models. DNN compression without retraining is an important practical problem and recently \cite{aghasi2017net} proposed Net-Trim which leverages data to perform sparsity based parameter reduction and achieve better DNN compression without retraining. However, it is very challenging to extend the compression gains to faster inference speeds as sparsity structure requires custom hardware and software support for that purpose. The off-the-shelf graphical processors (GPUs)
use single instruction, multiple threads execution models, i.e. the same sequence of operations is computed in parallel on different data to accelerate matrix-vector multiplication. The speed of matrix-vector product is then directly linked to the slowest thread, which might be affected by the number of non-zeros in the computation allocation to each thread and the overhead associated with reading the non-zero entries from the chosen compressed sparse storage format. Consequently, it is quite challenging via sparsity structure, since the non-zero entries could be arbitrarily distributed, to get faster matrix-vector products. The low-rank structure on the other hand does not suffer from such issues and provides faster inference using off-the-shelf hardware. Therefore, in this paper we extend Net-Trim \cite{aghasi2017net} to compress DNNs by imposing low-rank structures on the layers.
\section{Method}
In this section we outline our DDLR method that imposes low-rank representations on the weight matrices of the fully connected layers in a pretrained DNN.
\subsection{DDLR layers}
Consider a DNN with $L$ dense layers. Let the $\ell_{\textrm{th}}$ layer of this DNN be a fully connected dense layer with weight matrix $\mathbf{W}_\ell\in\mathbb{R}^{n_{\ell-1}\times n_{\ell}}$ with $n_{\ell-1}$ denoting the dimension of its input and $n_{\ell}$ being the dimension of its output. The corresponding bias of that layer is denoted with $\mathbf{b}_{\ell}\in\mathbb{R}^{n_{\ell}}$. Let also $\mathbf{Y}_{\ell-1}\in\mathbb{R}^{N\times n_{\ell-1}}$ and $\mathbf{Y}_{\ell}\in\mathbb{R}^{N\times n_{\ell}}$ denote the input and output matrices of the $\ell_{\textrm{th}}$ layer respectively, with the number of rows $N$ corresponding to the number of approximation training data in the network input matrix $\mathbf{X} \in \mathbb{R}^{N \times n_0}$. We focus on DNNs that utilize the $\textrm{ReLU}(x) = max(x,0)$ activation function as they form the backbone of DNN architectures. Our method can be generalized to any other activation function that can lead to a convex constraint in~(\ref{initial-optimization}). Given the input $\mathbf{Y}_{\ell-1}$ the output of layer $\ell$ is obtained as follows
\begin{equation}
\mathbf{Y_{\ell}}= \textrm{ReLU} ( \mathbf{Y}_{\ell-1}\mathbf{W}_{\ell}+\mathbf{1}_{N} \textbf{b}_{\ell}^T),
\end{equation}
where $\mathbf{1}_{N}$ is a $N$-dimensional vector of ones. In order to impose a low-rank structure on the weight matrix $\mathbf{W}_{\ell}$ we need to minimize the $rank(\cdot)$ function of that matrix. Given the non-convexity of the $rank(\cdot)$ function we propose solving the following optimization problem
\begin{equation}
\begin{aligned}
& \underset{\mathbf{U}\in\mathbf{R}^{n_{\ell-1}\times n_{\ell}}}{\text{minimize}}
& & ||\mathbf{U}||_* \\%+ \beta||U-AUB||_* \\
& \text{subject to}
& & ||\textrm{ReLU} ( \mathbf{Y}_{\ell-1}\mathbf{U}+\mathbf{1}_{N} \textbf{b}_{\ell}^T) -\mathbf{Y}_{\ell}||_F\leq \epsilon_{\ell}.
\end{aligned}
\label{initial-optimization}
\end{equation}
The objective function uses the well known nuclear norm relaxation of the $rank(\cdot)$ function in order to obtain a convex objective \cite{fazel2001rank} while the constraint requires the output of the compressed layer to be close to the output of original layer. The layer output error due to compression is controlled by a user specified threshold $\epsilon_{\ell}$. Intuitively, we expect as $\epsilon_{\ell}$ increases the rank of the layer to decrease more since the constraint is becoming more relaxed. However, the constraint in (\ref{initial-optimization}) is non-convex due to the $\textrm{ReLU}$ activation function inside the norm. To alleviate this issue we relax the constraint following~\cite{aghasi2017net}, to obtain the convex constraint
\begin{equation}
\begin{cases}
||(\mathbf{Y}_{\ell-1}\mathbf{U}+\mathbf{1}_{N} \textbf{b}_{\ell}^T-\mathbf{Y}_{\ell})\circ \mathbf{M}_{\ell}||_F^2\leq \epsilon_{\ell}^2\\
(\mathbf{Y}_{\ell-1}\mathbf{U}+\mathbf{1}_{N} \textbf{b}_{\ell}^T)\circ \mathbf{M}_{\ell}'\leq 0
\end{cases},
\label{convex-set}
\end{equation}
where $\mathbf{M}_{\ell}$ is a mask matrix of the same dimension as $\mathbf{Y}_\ell$ selecting the positive entries of $\mathbf{Y}_\ell$ elementwise, i.e. the $(i,j)_{\textrm{th}}$ entry $\textbf{M}_{\ell}^{ij} = 1$ if $ \mathbf{Y}_\ell^{ij} > 0$ and $\mathbf{M}_{\ell}^{ij} = 0$ otherwise. Similarly, $\mathbf{M}_{\ell}'$ is a mask matrix selecting the non-positive entries of $\mathbf{Y}_\ell$ and $\circ$ denotes the matrix Hadamard product. Intuitively, we penalize the deviation of the entries of the compressed layer that correspond to the positive entries of the original layer as the latter are the only ones that are not affected by the ReLU activation function. Furthermore, we allow the entries that correspond to the non-positive entries of the original layer to take any non-positive value. This step allows us to decrease the rank of the weight matrix even more without accumulating extra error. So problem (\ref{initial-optimization}) relaxed using (\ref{convex-set}) can now be written as
\begin{equation}
\begin{aligned}
& \underset{\mathbf{U}\in\mathbf{R}^{n_{\ell-1}\times n_{\ell}}}{\text{minimize}}
& & ||\mathbf{U}||_* \\%+ \beta||U-AUB||_* \\
& \text{subject to}
& & ||(\mathbf{Y}_{\ell-1}\mathbf{U}+\mathbf{1}_{N} \textbf{b}_{\ell}^T-\mathbf{Y}_{\ell})\circ \mathbf{M}_{\ell}||_F^2\leq \epsilon_{\ell}^2\\
& & &(\mathbf{Y}_{\ell-1}\mathbf{U}+\mathbf{1}_{N} \textbf{b}_{\ell}^T)\circ \mathbf{M}_{\ell}'\leq 0,
\end{aligned}
\label{relaxed-optimization}
\end{equation}
from which we obtain the solution $\hat{\mathbf{U}}_{\ell}$. This formulation allows for imposing structure on the layers while explicitly controlling for the error of the compressed layer output. This problem is a SDP with quadratic constraints and can be solved with most off-the-shelf solvers like SCS~\cite{ocpb:16} and CVXOPT~\cite{andersen2013cvxopt}.
\subsection{Parallel implementation}
The optimization problem~(\ref{relaxed-optimization}) imposes a low-rank structure on a single layer of a network. To compress networks with multiple layers we can compress each layer individually and independently from each other. This process is outlined in Algorithm~\ref{algo-1}, where compression of each layer is an independent of the rest of the layers optimization problem. Given that each layer is compressed independently, the algorithm allows for parallel implementation. The algorithm requires the initial data matrix as input $\mathbf{X}^{N\times n_{0}}$, the original trained weight matrices and biases of the layers and the user specified tolerances $\epsilon_{\ell}$. The output is a sequence of low-rank matrices for each dense layer.
\begin{algorithm}[h]
\SetAlgoLined
\SetKwInput{Input}{Input~}
\SetKwInput{Output}{Output~}
\Input{$\mathbf{X}, \mathbf{W}_{\ell}, \textbf{b}_{\ell}, \;\epsilon_{\ell}, \;\ell = 1,\ldots,L$}
$\mathbf{Y}_{0}=\mathbf{X}$\\
\For{$\ell$= 1,\ldots,L}{
$\mathbf{Y}_{\ell}= \textrm{ReLU}(\mathbf{Y}_{\ell-1}\mathbf{W}_{\ell}+\mathbf{1}_{N} \textbf{b}_{\ell}^T)$
}
\For{$\ell$= 1,\ldots, L}{
$\mathbf{M}_{\ell}^{i,j}=1$ if $\mathbf{Y}_{\ell}^{i,j}>0$, otherwise $0$ \\
$\mathbf{M}_{\ell}'^{i,j}=1$ if $\mathbf{Y}_{\ell}^{i,j}\leq0$, otherwise $0$\\
Solve (\ref{relaxed-optimization})
}
\Output{$\hat{\mathbf{U}}_{\ell},\; \ell=1,\ldots, L$}
\caption{DDLR Algorithm}
\label{algo-1}
\end{algorithm}
\vspace{0.5cm}
It should be noted that Algorithm~\ref{algo-1} requires the solution of a SDP (line $8$) for each layer. The solution of SDPs can present a computational bottleneck when weight matrices have large dimensions (e.g. the first dense layer of VGG-16) or the number of data samples $N$ used to solve~(\ref{relaxed-optimization}) is large. In such cases, to alleviate these issues one can \textit{1)} solve~(\ref{relaxed-optimization}) to suboptimality using fewer iterations and \textit{2)} use only a subset of the whole training set to solve~(\ref{relaxed-optimization}). Given the size of the layers in the networks studied in the experiments section we will be solving the SDPs to optimality by using only a sample from the original dataset used for training the network.
\section{Experiments}
We demonstrate the effectiveness of our method on three different datasets. An artificial nested spiral, the MNIST~\cite{lecun2010mnist} and the CIFAR-10~\cite{krizhevsky2009learning} datasets. Through experimentation we concluded that compression works well when the number of data samples used to solve~(\ref{relaxed-optimization}) is no less than $5\%$ of the data used to train the network. For this reason, and to deal with the scaling issues of solving SDPs multiple times, we will be training the networks with a subsample of the available data and we will be solving~(\ref{relaxed-optimization}) using a subset of size $N$ of that sample as presented in the following subsections. For each experiment carried out we use two different values of $N$ in order to study the performance of DDLR with respect to that sample complexity. The main method we will be comparing DDLR with is Net-Trim. Net-Trim on which our method is partially based, imposes a sparse structure on the layers post-training by minimizing the induced $\ell_1$ matrix norm~\cite{aghasi2017net}. Both DDLR and Net-Trim can be used to compress DNNs, removing redundancies from the networks and leading to faster inference. We will be comparing the compression level and the resulting accuracies obtained from these two methods. The benefits of DDLR regarding the possible inference speedup was discussed in the related work section.
For each of the following datasets we utilize Algorithm~\ref{algo-1} for different values of $\epsilon_{\ell}$ to compress a number of the hidden layers. For each experiment we report the relative accuracy on the test set of the compressed network with respect to the original accuracy of the uncompressed network. We measure the compression by reporting the fraction of parameters needed to be stored for the compressed network with respect to the original. For the sparse matrix experiments we assume that the parameters are stored in COO format. The COO format storage requirement is three times the number of positive entries of a matrix. It should be noted that it is possible to get the same value for the rank for more than one values of $\epsilon_{\ell}$. In such cases, we choose the solution that leads to higher accuracy on the test data.
\subsection{Spiral dataset}
The first dataset is a spiral of two-dimensional points representing two classes. The data points were generated by sampling points on the spiral and adding i.i.d. noise uniformly distributed in the interval $[0,3.5]$ for each dimension.
\begin{figure}[h]
\centering
\includegraphics[trim=0 0 0 32,clip, scale=0.55]{plot_original_boundary.pdf}
\caption{Spiral dataset data and decision boundary.}
\label{fig:Spiral_New_Data}
\end{figure}
In this experiment, we consider a DNN classifier with two hidden layers to label the points lying on the spiral. The dataset consists of a total of $1024$ points out of which $80\%$ points were used for training the DNN and the remaining $20\%$ were used for testing. The DNN classifier uses the ReLU activation function except for the last layer where the standard \emph{softmax} function is used. The dimensions of the network layers are $\mathbf{W}_1 \in \mathbb{R}^{2\times 80}, \mathbf{W}_2 \in \mathbb{R}^{80\times 80}$ and $\mathbf{W}_3 \in \mathbb{R}^{80\times 2}$. The DNN was trained by minimizing the cross entropy loss using the stochastic batch gradient descent algorithm with a batch size of $32$ for $1000$ epochs with learning rate $0.001$. The data points along with the decision boundary obtained from the trained DNN are shown in Figure~\ref{fig:Spiral_New_Data}.
We compress only the second layer $\mathbf{W}_2$, as the first and last ones are already low-rank given their dimensions, by utilizing Algorithm~\ref{algo-1}. We implemented the DDLR algorithm under two different scenaria, one using $N=256$ and another using $N=512$ data points for the compression, chosen randomly from the original training dataset. In order to obtain various rank approximations we use the following values for the compression error, $\epsilon_{\ell} \in [0.02, 0.05, 0.08, 0.1, 0.12, 0.15, 0.2, 0.25, 0.3, 0.5, 0.6]\cdot C$, where $C=\lVert Y_{\ell-1}\rVert_F$ is used for scaling purposes. We use the elbow rule to threshold the singular values of the solution of~(\ref{relaxed-optimization}) to obtain the final low-rank weight matrix. As expected, larger values of $\epsilon_{\ell}$ yield layers with lower rank. For both choices of $N$ DDLR seems to outperform Net-Trim achieving test accuracy close to the original using only $60\%$ of the initial parameters. The original accuracy is recovered with about $80\%$ of the original parameters.
\begin{figure}[h]
\centering
\hbox{\hspace{-1.4em} \includegraphics[scale=0.58]{spiral_results.pdf}}
\caption{Relative test accuracy for DDLR and Net-Trim with varying DNN size ratios on Spiral dataset.}
\label{fig:Spiral_LR_NLR_Comp}
\end{figure}
\subsection{MNIST dataset}
For the second set of experiments we use the LeNet-5 CNN architecture~\cite{lecun1998gradient} to classify the handwritten digits of the MNIST dataset. LeNet-5 has three dense layers of dimensions $\mathbf{W}_1\in\mathbb{R}^{256\times120},\mathbf{W}_2\in\mathbb{R}^{120\times84}$ and $\mathbf{W}_3\in\mathbb{R}^{84\times10}$ that follow the convolutional layers. We train LeNet-5 using $1024$ data samples from the original dataset, a $80\%$-$20\%$ train-test split, a batch size of $64$, $30$ epochs and a learning rate of $0.001$. Using Algorithm~\ref{algo-1} we impose a low-rank structure on the first two dense layers of LeNet-5 $\mathbf{W_1}$ and $\mathbf{W}_2$ using the following values of $\epsilon_{\ell}=[0.01,0.02,0.04,0.06,0.08,0.1,0.12,0.14,0.16,0.2,0.3]\cdot C$ for each layer, with $C=\lVert\mathbf{Y}_{\ell-1}\rVert_F$ being a scaling constant. We use $N=128$ and $N=256$ number of samples out of the $1024$ data points to compress the network. Figure~\ref{fig:MNIST_LR_NLR_Comp} presents the relative accuracy for different size ratios. DDLR achieves high compression while maintaining sufficient accuracy. With a $70\%$ reduction in the number of parameters DDLR can achieve a test accuracy less than $4\%$ lower than that of the original network for both values of $N$ while for $N=256$ with a $40\%$ reduction in parameters the accuracy is almost identical to the original. Interestingly, we observe that even for $N=128$ samples, which corresponds to slightly more than $10\%$ of the original data, we are able to obtain high compression associated with high accuracy.
\begin{figure}
\centering
\hbox{\hspace{-1.4em}\includegraphics[scale=0.58]{MNIST_results.pdf}}
\caption{Relative test accuracy for DDLR and Net-Trim with varying DNN size ratios on MNIST dataset.}
\label{fig:MNIST_LR_NLR_Comp}
\end{figure}
\subsection{CIFAR-10 dataset}
For the final set of experiments we classify the CIFAR-10 image dataset using again the LeNet-5 network. For CIFAR-10 the dense layers of Lenet-5 have dimensions $\mathbf{W}_1\in\mathbb{R}^{400\times120},\mathbf{W}_2\in\mathbb{R}^{120\times84}$ and $\mathbf{W}_3\in\mathbb{R}^{84\times10}$. We use $2048$ data points from CIFAR-10 to train our network and $N=128$ and $N=256$ subsamples for compression. For this experiment we compress the first two dense layers $\mathbf{W}_1$ and $\mathbf{W}_2$ using the following values for $\epsilon_{\ell}=[0.01,0.02,0.04,0.06,0.08,0.1,0.12,0.14,0.16,0.2,0.3]\cdot C$, where $C=\lVert\mathbf{Y}_{\ell-1}\rVert_F$. As expected, for larger $N$ both methods perform better with DDLR still outperforming Net-Trim. Quite astonishingly, we observe that with only $50\%$ of the original parameters DDLR achieves an accuracy less than $2\%$ worse in comparison to the accuracy of the original network for $N=256$. For the same relative accuracy on the other hand Net-Trim reduces only by $20\%$ the total number of parameters needed to be stored. Figure~\ref{fig:CIFAR_LR_NLR_Comp} contains the curves of the relative accuracies with respect to the parameter ratio.
\begin{figure}
\centering
\hbox{\hspace{-1.4em}\includegraphics[scale=0.58]{CIFAR_results.pdf}}
\caption{Relative test accuracy for DDLR and Net-Trim with varying DNN size ratios on CIFAR-10 dataset.}
\label{fig:CIFAR_LR_NLR_Comp}
\end{figure}
\section{conclusion and future work}
The DDLR Algorithm is an end-to-end approach that compresses a pretrained DNN by imposing low-rank structures on the fully connected layers while controlling for the overall accuracy decrease in the compressed DNN. We demonstrate in a number of datasets and DNN architectures that high parameter reduction can be achieved at a small loss in accuracy while requiring no retraining. Such reduction can be very significant for storing already trained models on edge devices. Furthermore, low-rank structured layers allow for fast matrix-vector multiplications without the need for specialized hardware which reduce inference time, something that is of vital importance for AI applications, especially on the edge.
The results of the experiments presented in this paper are rather encouraging but also limited due to the computational bottleneck of solving large scale SDPs. This drawback poses an interesting problem that requires theoretical and algorithmic development in future research. An interesting approach in that direction is a reformulation of the optimization problem~(\ref{relaxed-optimization}) in order to be solved using the Alternating Direction Method of Multipliers (ADMM) \cite{boyd2011distributed}. Such an approach can provide better scalability that will allow for compression of networks with larger hidden layers that have been trained on large datasets. Another interesting direction is to understand the impact of quantization on DNNs already compressed using DDLR, as such quantization can lead to significant additional reduction in the size of the networks.
\bibliographystyle{IEEEbib}
| {'timestamp': '2021-07-14T02:06:55', 'yymm': '2107', 'arxiv_id': '2107.05787', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05787'} | arxiv |
\section{Introduction}
Dengue is a mosquito-borne viral infection caused by four antigenically distinct dengue virus serotypes (DENV-1, DENV-2, DENV-3, DENV-4) and is transmitted by the bite of an infected female mosquito \textit{Aedes aegypti} as the main vector, and which is more common in rural areas, with \textit{Aedes albopictus} as a secondary vector. Dengue is a flu-like illness that affects individuals of all ages that could cause significant health, economic, and social burden in a population \cite{shepard2011economic}. The clinical profile of patients can range from asymptomatic infection to severe cases.
In recent years, the complex interaction of biological, socioeconomic, environmental, and climatic factors has facilitated the rapid emergence of this viral infection throughout the world, becoming endemic and a relevant public health problem in more than 100 countries \cite{zeng2021global}. In the last decades, the number of dengue cases reported to the World Health Organization (WHO) has increased from 505,430 cases in 2000 to more than 4.2 million in 2019 \cite{DengueanWHO,zeng2021global}.
Seasonal case patterns and vector abundance suggest that dengue transmission is sensitive to climatic and environmental factors \cite{morin2013climate, kolivras2010changes,christophrs1960aedes}. Climatic conditions can alter spatial and temporal dynamics of vector ecology, potentially increasing vector ranges, lengthening the duration of vector activity, and increasing the mosquito’s infectious period \cite{morin2013climate}. Precipitation provides habitats for the aquatic stages of the mosquito life cycle and strongly influences vector distribution \cite{kolivras2010changes, christophrs1960aedes, tun477effects}. On the other hand, water temperature plays a significant role in mosquito reproduction since this directly affects it survival at all stages of their life cycle \cite{ebi2016dengue}. Temperature increases are also linked with a faster rate of viral replication within the vector and with a shorter extrinsic incubation period \cite{morin2013climate}. Furthermore, higher humidity is associated with an increase in \textit{Ae. aegypti} feeding activity, which enhances the spread of the diseases.
The complexity of dengue transmission has driven many studies to assess its correlation with meteorological and ecological variables \cite{prabodanie2020coherence,ehelepola2015study,beltran2014spatiotemporal, cuong2016quantifying,thai2010dengue,johansson2009multiyear,cazelles2005nonstationary,simoes2013modeling,jury2008climate}. Most of these works evaluated the effects and correlation between dengue incidence and climate variables \cite{nitatpattana2007potential,nakhapakorn2020assessment}. There are other climate factors, like seasonal vegetation dynamics which may also influence the biology of the vector populations at relatively local scales affecting the dengue dynamics \cite{chaves2021modeling,mudele2021modeling,troyo2009urban}. Barrera et al. \cite{barrera2006ecological} suggested that dense vegetation can promote \textit{Ae. aegypti} pupal productivity by contributing organic material to the habitat, and influence water temperature and evaporation by creating shades. All these results show a correlation between dengue incidence and various climatic and environmental variables.
This study focuses on Costa Rica, where, after intense prevention and control campaigns, the mosquito \textit{Ae. aegypti} was eradicated in 1961. In 1970, the lack of continuity in active surveillance caused the mosquito to be found again on the Pacific coast. By September 1993, the first dengue case was reported in the country, and since then, dengue infections have been documented annually. The patterns and periodicity of transmission are different across the country. Despite the coastal regions being the most affected areas, trends observed over the years show variations in transmission peaks in all affected areas, posing a challenge for public health authorities to allocate and optimize available resources. In 2019, Costa Rica reported three times more cases than the previous year \cite{PAHO1}. The number of reported cases in 2019 is the highest in the history of dengue in Latin America \cite{PAHO1}.
This work aimed to study the incidence patterns of dengue in 32 different municipalities of Costa Rica and its correlation with climatic and vegetation variables using wavelet analysis. This method decomposes a time series in both the time and frequency domains, revealing how different periods change over time into non-stationary signals. Furthermore, wavelet analysis allows conclusions to be drawn about the synchronicity of the series for some periods. First, the wavelet power spectrum is computed to identify the periodicity present in the time series of dengue incidence. Then, using coherence analysis, we quantify associations between monthly dengue cases and local meteorological covariates, and examine the decomposed frequency components to identify possible time delays (phase differences) and significant associations.
Epidemic data is typically noisy, complex, and non-stationary. Changes in the periodicity over time are due to external factors or inherent characteristics of the disease. It is important to understand the mechanistic processes that lead to the spread of dengue and the external factors with which they can relate. Wavelet analysis allow a retrospective study to characterize outbreaks over time, which provides important guidelines for future modeling approaches in which explicit mechanisms can be incorporated.
This article is organized as follows: Section \ref{Methods}; describes the data and methods, Section \ref{Results}; present the results, and Section \ref{discussion} gives our final thoughts and discussion.
\section{Methods}
\label{Methods}
\subsection{Data}
For this study, we used data for 32 different locations, from January 2000 to December 2019. This data corresponds to weekly dengue incidence records provided by the Ministry of Health of Costa Rica. The data is aggregated monthly and is square-root transformed and standardize \cite{cazelles2005nonstationary}.
Costa Rica is a mountainous country located between the Caribbean Sea and Pacific Ocean. Thus, we use indices related with both ocean anomalies. El Niño Southern Oscillation (ENSO) is a natural phenomenon in the ocean-atmospheric system over the tropical Pacific; it is responsible for some anomalies such as changes in the sea surface temperatures (SST) \cite{hanley2003quantitative}. For this research, El Niño 1+2, El Niño 3, El Niño 4, and El Niño 3.4 indices \cite{CDG} were used. Data were accessed at [\url{https://www.cpc.ncep.noaa.gov/data/indices/ersst5.nino.mth.81-10.ascii}]. Information related to anomalies in the Atlantic Ocean is measured with the TNA index, abbreviation of Tropical North Atlantic, provides information on sea surface temperatures in the North-Eastern Tropical Atlantic Ocean \cite{TNA,wu2002tropical}. Data are available at [\url{https://www.esrl.noaa.gov/psd/data/correlation/tna.data}].
Normalized Difference Water Index (NDWI) represents the changes in the liquid water content of the leaves, giving a picture of the water stress of the vegetationr \cite{parselia2019satellite,gao1996ndwi,NDWI}. The time series of the Enhanced Vegetation Index (EVI) and the Normalized Difference Vegetation Index (NDVI) provide spatial and temporal information about vegetation \cite{GisGeography}. The NDVI has been widely used for remote sensing of vegetation and has been applied to mosquito studies and vector-borne diseases \cite{troyo2009urban,estallo2012effectiveness,lacaux2007classification}. EVI responds to canopy structural variations, including leaf area index (LAI), canopy type, plant physiognomy, and canopy architecture, and NDVI is more sensitive to chlorophyll. The two vegetation indices complement each other. \cite{matsushita2007sensitivity}. Land Surface Temperature (LST) is defined as a measure of how hot the surface of the Earth would feel to the touch \cite{yu2018land}. These last indices where download using the R package MODIS Tools, which extracts the information from MODIS Land Products Subsets [\url{https://modis.ornl.gov/data/modis_webservice.html}]. The MOD13Q1 product was used to EVI, NDVI, and NDVI data, and the MOD11A2 product to the night and day LST data.
\subsection{Wavelets analysis}
Wavelets have been used to study time series with different purposes: to evaluate the main characteristics of non-stationary time series \cite{talagala2015wavelet, cazelles2005nonstationary,chaves2006climate, nagao2008decreases,johansson2009multiyear,cuong2013spatiotemporal,simoes2013modeling}, to analyze spatial patterns \cite{cazelles2005nonstationary,thai2010dengue}, to study the relationship between population and environmental time series; finding the phase and/or synchrony patterns \cite{chaves2006climate,johansson2009multiyear,cazelles2005nonstationary}, and to study multiple time series \cite{d2012wavelets,aghabozorgi2015time}. Here, we used wavelet analysis to study patterns in dengue incidence in Costa Rica and identify its correlation with specific climate and vegetation variables in 32 different locations.
\subsubsection{Wavelet power spectra}
The wavelet analysis is based on a wavelet transform
defined as
\begin{equation}
W_x(s,\tau)=\dfrac{1}{\sqrt{s}}\int_{-\infty}^{\infty}x(t)\Psi^*\left(\dfrac{t-\tau}{s}\right)dt
=\int_{-\infty}^{\infty}x(t)\Psi^{*}_{s,\tau}(t)dt
\end{equation}
where $*$ denotes the complex conjugate form and $\Psi_{s,\tau}(t)$ represent a family of functions derived from a single function called the ``mother wavelet''. The signal is decomposed in these functions which can be expressed in terms of two parameters, one for the time position $\tau$, and the other for the scale of the wavelets $s$.
\begin{equation}
\Psi_{s,\tau}(t) = \dfrac{1}{\sqrt{s}}\Psi\left(\dfrac{t-\tau}{s}\right)
\end{equation}
For this study we use the Morlet mother
wavelet \cite{cazelles2007time, cazelles2008wavelet}:
\begin{equation}
\Psi(t) = \pi^{-1/4}e^{i\omega t}e^{\frac{-t^2}{2}}
\end{equation}
The local amplitude of any periodic component of the time series and how it evolves with time, can be retrieved from the modulus of its wavelet transform \cite{rosch2016waveletcomp}.
\begin{equation}
Ampl(s,\tau) = \dfrac{1}{s^{1/2}}|W(s,\tau)|
\end{equation}
The square of the amplitude has an interpretation as time-frequency (or time-period) called the wavelet power spectrum \cite{carmona1998practical}.
\begin{equation}
Power(s,\tau) = \dfrac{1}{s}|W(s,\tau)|^2
\end{equation}
\subsubsection{Wavelet coherence and phase difference}
To quantify the time series synchronization between dengue and the different climate and vegetation variables, we compute the wavelet coherence given by
\begin{equation}\
R_{x,y}(s,\tau) =\dfrac{|<W_{x,y}(s,\tau)>|^2}{|<W_x(s,\tau)>|^2|<W_y(s,\tau)>|^2}
\end{equation}
The angle brackets indicate smoothing in both time and frequency, $W_x(s, \tau) $ and $W_y(s,\tau)$ are the wavelet transform of the series $x(t)$ and $y(t)$, respectively. $W_{x,y}(s,\tau)=W_x(s,\tau)W_y^*(s,\tau)$ is the cross-wavelet transform \cite{cazelles2005nonstationary}. The value of $R_{x,y}(s,\tau)$ range between 0 and 1, where 1 represent a perfect linear relationship between the time series $x(t)$ and $y(t)$. Additional to this analysis, it is possible to compute the phase difference associated to the two signals, which gives information about series synchronization (i.e., in phase or out of phase). The Morlet wavelet is a complex wavelet, so the phase difference can be computed in terms of the real ($\mathcal{R}$) and the imaginary ($\mathcal{I}$) part, as shown in (\ref{eq:phase})
\begin{equation}
\Phi_{x,y}(s,\tau) = \dfrac{\mathcal{I}(<W_{x,y}(s,\tau)>)}{\mathcal{R}(<W_{x,y}(s,\tau)>)}
\label{eq:phase}
\end{equation}
The instantaneous time lag between the time series $x(t)$ and $y(t)$ is also computed \cite{cazelles2005nonstationary}.
Furthermore, Torrence and Compo \cite{torrence1998practical} offer a description of wavelet analysis and Cazellez et al. offer a perspective of the use of these techniques in ecological \cite{cazelles2008wavelet, cazelles2007time} or epidemic scenarios \cite{cazelles2014wavelet}.
All of the computations were done by using R version 2.4 (\url{ www.R-project.org}) \cite{team2013r} and the wavelet time series analyses were done with the algorithms implemented in the R package \textit{WaveletComp version 1.1} \cite{rosch2016waveletcomp}. All significance levels were based on 1000 bootstrap series and, to test the null hypothesis of \textit{non-periodicity}, significance is evaluated with simulation algorithms in which surrogate time series are provided with a similar spectrum (AR time series). \cite{rosch2016waveletcomp,roesch2014package}.
\section{Results}
\label{Results}
\subsection{Wavelet analysis – dengue periodicity}
In general, wavelet time series analysis revealed that the dominant periods for the incidence of dengue, in the 32 municipalities, are in the bands of 1, 2, and 3-yr, in accord with the periodicity range of dengue in Vietnam \cite{thai2010dengue}, Per\'u \cite{chowell2011influence} and Thailand \cite{cummings2004travelling, cazelles2005nonstationary}. Periods of 4 and 6-yr are observed in Siquirres, Talamanca, Turrialba, Upala, Golfito, Alajuela, Puntarenas, Matina, Osa, Santa Ana, Lim\'on, and Atenas, but this must be interpreted cautiously because of the short length of the time series. These periods are not stationary, they vary over time and space. Before 2008, the cycles of 1 and 2-yr leading in most locations. But, after 2008, the prevalent dengue periodicity change to cycles of 1 and 3-yr (see Figure \ref{fig:WaveletCanton}). The years 2008-2010 mark a decrease period in the variability of dengue incidence.
\begin{figure}
\captionsetup[subfigure]{labelformat=empty}
\subfloat[]{\includegraphics[scale=0.2]{Siquirres}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Talamanca}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Turrialba}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Upala}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{LaCruz}}\vspace{-0.15cm}\\
\subfloat[]{\includegraphics[scale=0.2]{Guacimo}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Golfito}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Esparza}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Garabito}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Desamparados}}\vspace{-0.15cm}\\
\subfloat[]{\includegraphics[scale=0.2]{Corredores}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Carrillo}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Canas}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Atenas}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Alajuela}}\vspace{-0.15cm}
\subfloat[]{\includegraphics[scale=0.2]{Alajuelita}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{PerezZeledon}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Pococi}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Puntarenas}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Quepos}}\vspace{-0.15cm}\\
\subfloat[]{\includegraphics[scale=0.2]{Matina}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{MontesdeOro}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Nicoya}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Orotina}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Parrita}}\vspace{-0.15cm}\\
\subfloat[]{\includegraphics[scale=0.2]{Osa}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Liberia}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Limon}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{SantaCruz}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{Sarapiqui}}\vspace{-0.15cm}\\
\subfloat[]{\includegraphics[scale=0.2]{SantaAna}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.2]{SanJose}}\vspace{-0.15cm}
\caption{Time series of monthly data for dengue incidence from 2000 to 2019 in 32 municipalities of Costa Rica.}
\label{Fig:DengueCases}
\end{figure}
\begin{figure}
\captionsetup[subfigure]{labelformat=empty}
\includegraphics[scale=0.9]{Wavelet_Cantones_Costa_Rica.pdf}
\caption{Wavelet power spectra (color map) of dengue incidence from 2000 to 2019, in 32 municipalities of Costa Rica (periodicity on y-axis, time on x-axis). Data to compute the wavelet power spectrum of dengue cases is square rooted and standardize; colors code for increasing power intensity, from blue to red; $95\%$ confidence levels are encircled by white lines, and shaded areas indicate the presence of significant edge effects. On the right side of each wavelet power spectra is the classical Fourier spectrum of the time series.}
\label{fig:WaveletCanton}
\end{figure}
\subsection{Coherence and phase analyses – synchrony between dengue incidence, climate and vegetation variables}
For each time series, the wavelet power spectrum is first calculated to determine the dominant periods individually and then the coherence between each covariate and the incidence of dengue is calculated.
\subsubsection*{Enhanced Vegetation Index (EVI)}
The index of vegetation shows a continues band for the period of 1-yr in the municipalities of La Cruz, Esparza, Santa Cruz, San Jos\'e, Santa Ana, Perez Zeled\'on, Puntarenas, Carrillo, Ca\~nas, Atenas, Alajuelita, Alajuela, Nicoya, Orotina, Desamparados, and Liberia. On the other hand, Siquirries, Turrialba, Pococ\'i, Matina, Montes de Oro, Osa, Corredores, Guacimo, Lim\'on have short time interval whit a significant periodicity on the scale of 1-yr. Golfito, Talamanca, Parrita, Upala, Quepos, Garabito, and Sarapiqu\'i do not reach significance in any period when simulations are compared to the null hypothesis.
Wavelet coherence analysis shows that EVI is significantly associated with dengue incidence in the 1-yr periodic band, for all municipalities except Quepos, Parrita, Upala, Golfito, and Garabito. For these places where there is no marked annual seasonality for the vegetation indices (Turrialba, Matina, Osa, Corredores, Guacimo, Lim\'on, Talamanca, and Sarapiqu\'i) the correlation with dengue incidence present small areas of high significance (see Figure S1).
Phase differences (see supplementary material) suggest that the annual wave of dengue and EVI are in phase in all localities with an approximate lag of 3 months. Something to highlight is that in Osa, a continuous band for the vegetation index is recorded in the period of 1-yr after 2011, and one year later, a band period with the same scale for the incidence of dengue is shown with a strong correlation with EVI from 2012 to 2017.
\subsubsection*{Normalized Difference Vegetation Index (NDVI)}
For NDVI, the wavelet analysis shows a marked and significant annual periodicity over time in the municipalities of La Cruz, Esparza, Santa Cruz, Santa Ana, Carrillo, Ca\~nas, Alajuela, Nicoya, Libera, Puntarenas, Atenas, and Orotina. For the rest of the localities, there is no correlation or the significant area is present in short periods throughout the time.
Analyzing the direct association between the incidence of dengue and the NDVI, a significant local coherence is observed in the 1-yr band for all municipalities listed above, where the annual periodicity of the NDVI is relevant. The correlation between dengue cases and DNVI for Siquirres, Desamparados, Peréz Zeledón, Pococí, Montes de Oro, Corredores, Sarapiquí, Guacimo, Talamanca, and Upala happen only in small interval of time. For Alajuenlita, Matina, Turrialba, Osa, Quepos, Parrita, Limón, Golfito, and Garabito there is not correlation (see Figure S2).
The phase difference (see supplementary material) reveals that the time series are in-phase. With total sync or an approximate delay of 3 months in Alajuela, Atenas, Ca\~nas, Carrillo, Desamparados, Esparza, La Cruz, Liberia, Nicoya, Puntarenas, Santa Ana, and Santa Cruz, where an increase in the vegetation index is followed by a rise in dengue cases.
\subsubsection*{Normalized Difference Water Index (NDWI)}
Similar to the results for EVI and NDVI, the wavelet coherence analysis for NDWI shows a high and significant coherence for the 1-yr periodic mode with the places located in the center and the North Pacific of the country (La Cruz, Esparza, Desamparados, Carrillo, Ca\~nas, Atenas, Alajuela, Alajuelita, Pococ\'i, Puntarenas, Montes de Oro, Nicoya, Orotina, Liberia, Santa Cruz, Santa Ana, and San José). For those places, the wavelet analysis of the NDWI time series shows a continuous high significant area in the period of one year throughout time. A weaker correlation is observed with the municipalities of Siquirres, Turrialba, Parrita, Corredores, Golfito, Sarapiquí, Matina, Limón, and Upala. There is not correlation in the municipalities of Talamanca, Guacimo, Garabito, and Quepos (see Figure S3).
The two-time series are in phase with a delay time of zero (full synchronization) at three months. NDWI is the leading time series in cities located in the North Pacific and Central Regions. While the leading series is not clearly defined in most of the municipalities of the Atlantic and the South Pacific.
\begin{figure}[H]
\centering
\subfloat[EVI]{\label{fig1:EVI}\includegraphics[scale=0.35]{EVI.pdf}}\hspace*{-1.3cm}
\subfloat[NDVI]{\label{fig1:NDVI}\includegraphics[scale=0.35]{NDVI.pdf}}\hspace*{-1.3cm}
\subfloat[NDWI]{\label{fig1:NDWI}\includegraphics[scale=0.35]{NDWI.pdf}}
\caption{Map of the wavelet coherence between the incidence of dengue and the corresponding index (EVI, NDVI, and NDWI). Dark green corresponds to those places where the area of high significance is more continues over time. Light green corresponds to those places where the correlation is only in short periods and yellow to those where there are no significant areas.}
\label{Map:VegetationIndices}
\end{figure}
\subsubsection*{Land Surface Temperature (LST)}
Wavelet power spectrum analysis shows a strong annual component for LSN and LSD in all municipalities. For LSN, a continuous band in the 1-yr is present in all cantons, while for LSD only a continuous band is observed for La Cruz, Esparza, Desamparados, Carrillo, Liberia, Osa, and Pococ\'i and a non-stationary behavior, in the same scale, for the rest of localities.
Wavelet coherence evinces a significant association of dengue incidence with seasonal temperature in the dominant wave of 1-yr. The lapse of time over which these patterns are correlated and are statistically significant varied across the time and geographic locations (see Figures S4-S5).
The phase difference for the 1-yr band indicates that land surface temperature and dengue incidence signal are out of phase. The positive peak of dengue lags behind the negative peak of the land surface temperature with a difference of 3 (in-phase) to 6 (completely mirror images of each other) months. This pattern is regular in all municipalities over time, except for Lim\'on, Corredores, Ca\~nas, Atenas, Perez Zeled\'on, Quepos, Parrita, Garabito, and Upala, where the incidence of dengue leads over LSD, LSN or both (supplementary material).
\subsubsection*{Tropical North Atlantic (TNA)}
The wavelet power spectrum for the TNA data shows a dominant period in the 1-yr, 18-month (1.5-yr), 3-yr, and 6-yr range (see Figure \ref{Fig:Wavelet_TNA}). The period of 6-yr should be taken carefully due to the series length.
The wavelet coherence analysis shows a significant correlation between the TNA index and the incidence of dengue in all municipalities (except for Matina and Quepos), especially in the band corresponding to the periods of 1 and 3-ys (see Figure S6). After 2011, there is a significant correlation between the time series in the one-year band for all localities except Alajuelita and Garabito.
For Desamparados, Santa Cruz, San Jos\'e, Santa Ana, P\'erez Zeled\'on, Carrillo, Atenas, Alajuelita, Alajuela, Nicoya, Orotina, Osa, Montes de Oro, Golfito, Upala, Garabito, and Sarapiqu\'i, the phase difference reveals that the dengue wave is in perfect synchronization with the TNA wave in the 3-yr band from 2009 to 2014, approximately. For all locations, TNA and dengue incidence signals are in phase, but the lagging and leading wave changes with geographic location and over time (see supplementary material).
\begin{figure}[H]
\centering
\subfloat{\includegraphics[scale=0.4]{Wavelet_TNA}}
\subfloat{\includegraphics[scale=0.4]{TNAPower}}
\caption{ (Left) Wavelet power spectrum of Tropical North Atlantic index from 2000 to 2019 (periodicity on y axis, time on x axis). Data to compute The wavelet power spectrum of TNA is standardize; colors code for increasing power intensity, from blue to red; $95\%$ confidence level are encircled by white lines, and shaded areas indicate the presence of significant edge effects. (Right) Average wavelet power spectrum.}
\label{Fig:Wavelet_TNA}
\end{figure}
\subsubsection*{Sea surface temperatures (ENSO SST)}
The wavelet power spectrum was performed for the four different Ni\~no indices: Ni\~no 1 + 2, Ni\~no 3, Ni\~ no 3.4, Ni\~ no 4 (see Figure \ref{fig:Wavelet_ENSO}). The results show that the dominant non-stationary peaks, for the four indices, are in the 1-yr, 1.5-yr, and 3-yr bands (see Figure \ref{fig:Wavelet_ENSO}).
\begin{figure}[H]
\captionsetup[subfigure]{labelformat=empty}
\centering
\subfloat[]{\includegraphics[scale=0.22]{Wavelet_N12}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.22]{N12Power}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.22]{Wavelet_N3}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.22]{N3Power}}\vspace{-0.15cm}\\
\subfloat[]{\includegraphics[scale=0.22]{Wavelet_N34}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.22]{N34Power}}\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.22]{Wavelet_N4}}
\vspace{-0.15cm}%
\subfloat[]{\includegraphics[scale=0.22]{N4Power}}
\vspace{-0.15cm}
\caption{(Color Maps) Wavelet power spectrum of Sea surface temperatures (ENSO SST) indeces from 2000 to 2019 (periodicity on y axis, time on x axis). Data to compute the wavelet power spectrum of ENSO SST indices is standardize; colors code for increasing power intensity, from blue to red; $95\%$ confidence level are encircled by white lines, and shaded areas indicate the presence of significant edge effects. (Red line) Average wavelet power spectrum for El Ni\~no 1+2, El Ni\~no, El Ni\~no 3.4, and El Ni\~no 4, respectively.}
\label{fig:Wavelet_ENSO}
\end{figure}
The coherence between the incidence of dengue and the Ni\~no 1 + 2 index is not clear. There is possible to identify small areas of significance between this and the dengue incidence in some places in the Pacific (Liberia, Puntarenas, Esparza, Garabito, Montes de Oro, Nicoya, Orotina and Carrillo) and the Atlantic (Matina, Siquirris, Pococ\'i, and Lim\'on) in the band of 1 year, from 2001 to 2007 approximately. On the other hand, Ni\~no 3, 3.4, and 4 are correlated with dengue incidence in the period of 1, 1.5, 2, and 3-yr. The correlation is non-stationary and vary over time and geographically. However, there is a strong correlation between those indices and dengue incidence in most of the localities in the period of 3-yr (see Figure \ref{fig:Map2}).
\begin{figure}[H]
\centering
\subfloat[El Ni\~no 3]{\label{fig1:NINO3}\includegraphics[scale=0.32]{NINO3.pdf}}
\subfloat[El Ni\~no 3.4]{\label{fig1:NINO34}\includegraphics[scale=0.32]{NINO34.pdf}}
\subfloat[El Ni\~no 4]{\label{fig1:NINO4}\includegraphics[scale=0.32]{NINO4.pdf}}
\caption{Map of the wavelet coherence between the incidence of dengue and the corresponding index (El Ni\~no 3, El Ni\~no 3.4, El Ni\~no 4). Red color corresponds to those localities that have an area of high significance in the band of 3-yr. The cream color corresponds to those places where there is a significant area for periods different to 3-yr.}
\label{fig:Map2}
\end{figure}
\begin{table}
\centering
\begin{adjustbox}{width=1\textwidth}
\begin{tabular}{llllllllll}
\rowcolor{gray}
\hline
\centering \textbf{Canton} & \centering\textbf{EVI} & \centering \textbf{NDVI} & \centering \textbf{NDWI}& \textbf{LSD}& \textbf{LSN}&\textbf{TNA} & \textbf{NI\~NO 3}&\centering \textbf{NI\~NO 34}& \textbf{NI\~NO 4}\\
\hline
La Cruz& x& x& x& x& x&P1 & P3& P3& P3\\
\rowcolor{gray!8}
Esparza & x& x& x& x& x& P1 & -- & P3 & P3\\
Puntarenas& x& x& x& x& x& P1 & -- & P3 & P3\\
\rowcolor{gray!8}
Carrillo & x& x& x& x& x& P1 & P3 & P3 & P3\\
Cañas & x& x& x& x& x& P1 & -- & P3 & P3\\
\rowcolor{gray!8}
Atenas & x& x& x& x& x& P1 & P3 & P3 & P3\\
Alajuela & x& x& x& x& x& P1 & P3 & P3 & P3\\
\rowcolor{gray!8}
Nicoya & x& x& x& x& x& P1 & P3 & P3 & P3\\
Orotina & x& x& x& x& x& P1 & P3 & P3 & P3\\
\rowcolor{gray!8}
Liberia & x& x& x& x& x& P1 & P3 & P3 & P3\\
Santa Cruz& x& x& x& x& x& P1 & P3 & P3 & P3\\
\rowcolor{gray!8}
Santa Ana & x& x& x& x& x& P1 & P3 & P3 & P3\\
San José & x& 2001/2007-2013/2017& x& x& x& P1 & P3 & P3 & P3\\
\rowcolor{gray!8}
Alajuelita &x & & x& x& x& -- & P3 & P3 & P3\\
Matina &2010/2013 & & & x& x& & -- & -- & P3\\
\rowcolor{gray!8}
Turrialba &2010/2014& & 2004/2008-2011/2015& x& x& P1 & -- & P3 & P3\\
Siquirres & x& 2011/2013 & 2003/2008-2010/2014& x& x& P1& -- & P3& P3\\
\rowcolor{gray!8}
Desamparados &x &2012/2017 & x& x& x& P1 & P3 & P3& P3\\
Perez Zeledón&x &2004/2006-2013/2018& x & x & x& P1 & P3& P3& P3\\
\rowcolor{gray!8}
Pococí& x& 2001/2003-2011/2014& x& x& x&P1& -- & --& P3\\
Montes de oro &x& 2000/2003-2013/2017& x& x& x& P1 & --& P3&P3\\
\rowcolor{gray!8}
Corredores &2005/2007 - 2013/2017& 2013/2015& 2005/2008-2015/2017& x & x & P1& P3& --& P3\\
Limón & 2010/2013 && 2007/2013& x & x &P1 & -- & -- & --\\
\rowcolor{gray!8}
Talamanca & 2011/2014& 2011/2014& & x& x& P1& P1 &-- & --\\
Sarapiquí& 2011/2014& 2012/2015& 2011/2015& x& x& P1& --&--&P3\\
\rowcolor{gray!8}
Guacimo &2010/2015& 2002-2011/2014& 2010/2014& x& x& P1& --& --& P3\\
Osa &2012/2017 & & 2013/2016 & x&x&P1 & P3 & P3 & P3\\
\rowcolor{gray!8}
Quepos & & & &x &x & & -- & -- & P3\\
Parrita & & &2013/2014 & x & x & P1 & P3 & P3 &P3\\
\rowcolor{gray!8}
Upala & &2013 & 2012/2015 & x& x&P1 &P3&P3&P3\\
Golfito & & & 2013/2017 & x& x &P1& P3& P3&P3\\
\rowcolor{gray!8}
Garabito& & & & x & x &-- & P3& P3& P3\\
\hline
\end{tabular}
\end{adjustbox}
\caption{(x) represent those places where there is a significant correlation between the incidence of dengue and the corresponding index. When the correlation time interval is short, the dates for the area of high significance are indicated. P1 represents places where there is a notable correlation in the 1-yr band for the incidence of dengue and TNA after 2011. P3 corresponds to those places where there is a strong correlation between the ENSO variables and the incidence of dengue in a band of 3-yr.}
\label{tab:SummaryResults1}
\end{table}
\begin{table}
\centering
\caption{Synchronization and lag results summary.}
\begin{adjustbox}{width=1\textwidth}
\begin{tabular}{|p{4cm}|p{15cm}|p{3cm}|p{3cm}|}
\rowcolor{gray}
\hline
\centering \textbf{Index} & \centering\textbf{Period and Phase} & \multicolumn{2}{c}{\textbf{Lag}}\\
\hline
\begin{minipage}[t]{\linewidth}%
\vspace{0.2cm}
EVI \\
NDVI\\
NDWI
\vspace{0.2cm}
\end{minipage}
&
\begin{minipage}[t]{\linewidth}%
\vspace{0.2cm}
\centering
Vegetation indices showed a strong correlation with dengue incidence in the 1-yr period. The time series move in-phase.
\end{minipage}
&
\multicolumn{2}{c|}{
\begin{minipage}[t]{6cm}
\vspace{0.2cm}
The lag is approximately 3 months, however, there are periods when both signals are in sync.
\end{minipage}}\\
\hline
\vspace{0.2cm}
LST (LSN-LSD)
&
\begin{minipage}[t]{\linewidth}%
\vspace{0.2cm}
LSN and LSD are correlated with dengue indices in the period of 1-yr. Time series move out of phase.
\vspace{0.2cm}
\end{minipage}
&
\multicolumn{2}{c|}{
3-6 Months}\\
\hline
\vspace{0.2cm}
TNA
&
\begin{minipage}[t]{\linewidth}%
\vspace{0.2cm}
The TNA series has dominant periods of 1, 1.5, and 3 years. It is in phase with the time series of dengue cases and there is a strong correlation with those in the periods of 1-yr and 3-yrs.
\vspace{0.2cm}
\end{minipage}
&
\vspace{0.2cm}
\centering
3 Months in the band of 1-yr
&
\vspace{0.2cm}
\centering\arraybackslash
6 Months in the band of 3-yr\\
\cline{1-4}
\rowcolor{gray!8}
\vspace{0.2cm}
ENSO SST
&
\begin{minipage}[t]{\linewidth}%
\vspace{0.2cm}
\centering
Non-stationary period in the band of 1-yr and 3 yr.
\vspace{0.2cm}
\end{minipage}
&
\centering
Lag in the period of 1-yr.
&
\centering\arraybackslash
Lag in the period of 3-yr. \\
\cline{1-4}
Ni\~no 3 & & 3 Months & 15 Months\\
\cline{3-4}
Ni\~no 4 & & 3-6 Months & 15 Months\\
\hline
\end{tabular}
\end{adjustbox}
\label{tab:SummaryResults2}
\end{table}
\section{Discussion}
\label{discussion}
Wavelet analysis was performed over monthly time series of dengue incidence and six different satellite climate and vegetation variables in Costa Rica (i) to detect and quantify dengue periodicity in 32 different cantons and (ii) to associate the relationship between dengue incidence, climate and vegetation variables in those places.
Wavelet power spectra showed that the dominant periods of dengue in the 32 locations in Costa Rica are in the 1, 2, and 3-yr bands. These periods are not stationary; they vary over time and space. After 2008, a high area of significance in the period of 3-yr appears in most places which, according to the wavelet coherence analysis, dengue incidence correlates with the Ni\~no 3, 3.4, 4, and TNA index in the same period.
The wavelet coherence analysis shows a strong correlation between the vegetation indices (EVI, NDVI, and NDWI) and the incidence of dengue in cantons located mainly in the center or North Pacific of the country. For cantons in the Atlantic or the South Pacific, the areas of significance are small or do not exist. The time series are in phase with a lag of 3 months, but there are some periods where the two series are in sync. The LSN and LSD indices are strongly correlated with the incidence of dengue in all municipalities. The time series are out-phase with a lag ranging from 3 to 6 months. The TNA is correlated with dengue cases in the periods of 1-yr and 3-ys. After 2011, there is a marked correlation in the 1-year band for all places except Matina, Quepos, Alajuelita, and Garabito. Ni\~no 3, 3.4, and 4 show a significant correlation in different band periods, but the correlation in the 3-yr band is dominant in most localities. On the other hand, the correlation between the Niño 1 + 2 index and the incidence of dengue is less clear.
Weather and climate influence disease ecology on many levels creating complex dynamics. Although it is known that dengue dynamics can be affected by various climatic and vegetation variables, not all of them must be present for successful spread. Human factors, such as behavior, immunity, and socioeconomic factors, could also contribute to dengue spread and complexity. This analysis showed that even in the same country, the variables correlated with dengue cases could change, highlighting the importance of analyzing a localized way.
As far as we know, this is the first study for Costa Rica that incorporates a wide variety of climatic variables and considers the cantons of interest to the health authorities. This type of analysis provides a better understanding of the local dynamics of diseases, which allows for improved prediction models and health interventions at specific sites. It can be enriched with the incorporation of new socioeconomic variables and with a cluster approach, which allows characterizing the regions and identifying the conditions and characteristics shared by the different cantons.
| {'timestamp': '2021-07-14T02:05:01', 'yymm': '2107', 'arxiv_id': '2107.05740', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05740'} | arxiv |
\section{Introduction}
Strong evidence has been found in psychology that human vision is able to parse a complex scene into part-whole hierarchies with many different levels from the low-level pixels to the high-level properties (\textit{e.g.} parts, objects, scenes) \citep{partwhole_evidence1, partwhole_evidence2}.
%
Constructing such a part-whole hierarchy enables neural networks to capture compositional representations directly from images, which can promisingly help to detect properties of many different levels with only one network.
To the best of our knowledge, most current visual feature extractors do not model such hierarchy explicitly.
%
Due to the lack of such part-whole hierarchy in representation modeling, existing feature extractors cannot find the compositional features directly from the network.
%
Ideal modeling of the visual representation should be able to model the part-whole hierarchy as humans do so that we can leverage representations of all levels directly from one backbone model.
Building up a framework that includes different levels of representations in the part-whole hierarchy is difficult for conventional neural networks as it requires neurons to dynamically respond to the input, while neural networks with fixed weights cannot dynamically allocate a group of neurons to represent a node in a parse tree \citep{glom}. With the rise of the Transformer \citep{transformer}, such a problem can be possibly resolved due to its dynamic nature.
%
\input{figures_n_tables/fig_det_perform}
In this paper, we show how to construct a simplest part-whole hierarchy for visual representation. The hierarchy of the proposed network has two levels. One represents the \textit{part}, which only contains the most essential information describing the visual input, and the other is for the \textit{whole}, which describes the visual input in a regular spatial coordinate frame system. Normally a part vector can be dynamically associated with several vectors of the whole, forming a one-to-many mapping between the two levels.
%
To obtain information for the part, we first apply an encoder between the two levels to fill each part with the features of the whole. Then the encoded part feature will be mapped back to the whole by a transformer-based decoder.
%
Such cross-level interaction is iteratively applied throughout the network, constituting a bi-directional pathway between the two levels.
\textbf{Our main contributions} are as follows:
(1) We propose Visual Parser (ViP) that can explicitly construct a part-whole hierarchy within the network for basic visual representations. This is the first step towards learning multi-level part-whole representations.
%
(2) With the help of such a part-whole hierarchy, the network can be more explainable compared with previous networks.
%
(3) ViP can be directly applied as a backbone for versatile uses. Experimental results also demonstrate that ViP can achieve very competitive results compared to the current state-of-the-art backbones. As shown in Figure \ref{fig:det_performance}, it outperforms all state-of-the-art CNN counterparts by a large margin on object detection.
\section{Method}
\label{sec:method}
\subsection{Overview}
The overall pipeline is shown in Figure \ref{fig:overview}. There are two inputs of ViP, including an input image and a set of learnable parameters. These parameters represent the prototype of the parts, and will be used as initial clues indicating the region that each part should associate with.
%
The entire network consists of several basic blocks (iterations). For block $i \in \{2, 3, ..., B\}$, there are two kinds of representations describing the two hierarchical levels. One is the part representation $\mathbf{p}^i \in \mathbb{R}^{N\times C}$ and the other is the whole feature maps $\mathbf{x}^i \in \mathbb{R}^{L\times C}$. Here $N$ is a pre-defined constant number indicating the number of parts within the input image, and $L$ is the number of pixels of the feature map, which is identical to \textit{width$\times$height}. $B, C$ are the numbers of blocks and channels respectively.
%
The representation of parts for each block is dynamically encoded from the corresponding whole feature maps through an attention-based approach. Given the representation of the part $\mathbf{p}^{i-1}$ and the whole $\mathbf{x}^{i-1}$ from the previous block $i-1$, an attention-based encoder is applied to fill the information of the whole into the part $\mathbf{p}^{i}$ of the current block. Since the attention mechanism assigns each pixel on the feature map with a weight indicating the affinity between the pixel and the corresponding part, only the spatial information in $\mathbf{x}^{i-1}$ that is semantically close to the input part $\mathbf{p}^{i-1}$ can be updated into $\mathbf{p}^{i}$.
Information within the encoded parts will be then transferred back into the feature maps, so each pixel on the feature map can interact with the information in a wider range. Since the information within the parts is highly condensed, the computational cost between the pixels and the parts is much lower than the original pixel-wise global attention \citep{nonlocal, botnet}. This encoder-decoder process constitutes the basic building block of ViP. By stacking the building block iteratively, the network can learn to construct a two-level part-whole hierarchy explicitly.
\input{figures_n_tables/fig_overview}
\subsection{Part Encoder}
The part encoder is responsible for extracting the part information based on the previous part-whole input. The encoder is implemented with an attention mechanism.
%
Given the part representation $\mathbf{p}^{i-1} \in \mathbb{R}^{N\times C}$ of the last block $i-1$, we first normalize it with Layer Normalization \citep{layernorm}, then use it as the query of the attention block. The whole feature map from the last block $\mathbf{x}^{i-1} \in \mathbb{R}^{L\times C}$ serves as the key and value after the normalization. The information of the whole will be condensed into the part representations via attention, which can be formulated as:
\begin{equation}
\begin{split}
&\mathbf{\hat{p}}^{i-1} = \mathbf{p}^{i-1} + \text{Attention}(\mathbf{p}^{i-1}+\mathbf{d}_e, \mathbf{x}^{i-1} + \mathbf{d}_w, \mathbf{x}^{i-1}),\\
\end{split}
\label{eq:attn_def}
\end{equation}
where $\mathbf{\hat{p}}^{i-1} \in \mathbb{R}^{N\times C}$ is the output of the attention block, and $\text{Attention}(\textit{query}, \textit{key}, \textit{value})$ denotes the attention mechanism. $\mathbf{d}_w \in \mathbb{R}^{L\times C}, \mathbf{d}_e \in \mathbb{R}^{N\times C}$ are positional encodings for the whole and the part respectively. The positional encoding $\mathbf{d}_w$ follows the sinusoidal design proposed in \citep{detr}, and $\mathbf{d}_e$ is a set of learnable weights.
We follow the common practice of the classic attention calculation, which first outputs an affinity matrix $\mathbf{M} \in \mathbb{R}^{N\times L}$ between the query and key and then use it to select information lying in the value.
\begin{equation}
\mathbf{M} = \frac{1}{\sqrt{C}} q(\text{LN}(\mathbf{p}^{i-1}+\mathbf{d}_e)) \cdot k(\text{LN}(\mathbf{x}^{i-1} + \mathbf{d}_w))^T,
\label{eq:softmax}
\end{equation}
where the functions $q(\cdot), k(\cdot)$ denote the linear mappings for the inputs of query and key, $\text{LN}$ is the Layer Normalization. Here we omit the learnable weights within LN for simplicity. The product of the query and the key is normalized by a temperature factor $\frac{1}{\sqrt{C}}$ to avoid it being one-hot after the lateral softmax calculation.
The softmax operation guarantees the sum of the affinity matrix on the whole dimension to be one, which can be formulated as:
\begin{equation}
\hat{M}_{a, b} = \frac{e^{M_{a, b}}}{\sum_l{e^{{M}_{a, l}}}}.
\end{equation}
The normalized affinity matrix can be easy to explain, as it assigns an independent weight to each spatial location indicating where each part is lying on the spatial feature maps. To aggregate these weighted spatial locations into part vectors, we follow the classic attention that weighted averaging the values together with the affinity matrix:
\begin{equation}
\text{Attention}(\mathbf{p}^{i-1}+\mathbf{d}_e, \mathbf{x}^{i-1} + \mathbf{d}_w, \mathbf{x}^{i-1}) = \hat{\mathbf{M}} \cdot v(\text{LN}(\mathbf{x}^{i-1})),
\end{equation}
where $v(\cdot)$ is the linear mapping for values, and $\hat{\mathbf{M}}$ is the affinity matrix after softmax.
\textbf{Reasoning across different parts.} After each part is filled with the information from the feature maps, we apply a part-wise reasoning module to enable information communication between parts. In order to save computational cost, we just apply a single linear projection with learnable weights $\mathbf{W}_{p} \in \mathbb{R}^{N\times N}$. An identity mapping and the normalization are also applied here as a residual block. The process of the part-wise reasoning can be formulated as:
\begin{equation}
\mathbf{\hat{p}}_r^{i-1} = \mathbf{\hat{p}}^{i-1} + \mathbf{W}_{p} \cdot \text{LN}(\mathbf{\hat{p}}^{i-1}),
\end{equation}
where $\mathbf{\hat{p}}_r^{i-1}$ represents the output for the part-wise reasoning.
\textbf{Activating the part representations.} The part representation learnt above may not be all meaningful since different objects may have different numbers of parts describing themselves. We thereby further apply a Multi-Layer Perceptron (MLP) that has two linear mappings with weight $\mathbf{W}_{f1}, \mathbf{W}_{f2} \in \mathbb{R}^{C\times C}$ and an activation function (GELU \citep{gelu}) $\sigma(\cdot)$ in its module. The activation function will only keep the useful parts to be active, while those identified to be less helpful will be squashed.
%
In this way, we obtain the part representation $\mathbf{p}^{i}$ for block $i$ by:
\begin{equation}
\begin{split}
\mathbf{p}^{i} &= \mathbf{\hat{p}}_r^{i-1} + \text{MLP}(\mathbf{\hat{p}}_r^{i-1}),\\
\text{MLP}(\mathbf{\hat{p}}_r^{i-1}) &= \sigma(\text{LN}(\mathbf{\hat{p}}_r^{i-1}) \cdot \mathbf{W}_{f1}) \cdot \mathbf{W}_{f2}.
\end{split}
\label{eq:rpn_mlp}
\end{equation}
The above process demonstrates that the part representation generated by the previous block will be used to initialize the parts of the next iteration. Thus the randomly initialized part representations will be gradually refined with the information from the whole within each block.
\input{figures_n_tables/fig_block}
\subsection{Whole Decoder}
As shown in Figure \ref{fig:block}, there are two inputs for the decoder, the part representation $\mathbf{p}^{i}$ and the whole representation $\mathbf{x}^{i-1}$. Interactions within the decoder can be divided into a part-whole global interaction between the parts and the feature maps, and a patch-based local attention between pixels in a local window of the whole feature maps.
\textbf{Part-whole global interaction.} We first apply the part-whole global attention to fill each pixel on the whole representations $\mathbf{x}^{i-1}$ with the global information encapsulated in the parts $\mathbf{p}^{i}$. The part-whole global attention completely follows the classic attention paradigm \citep{transformer}, which takes $\mathbf{x}^{i-1}$ as the query input, and $\mathbf{p}^{i}$ as inputs of the key and value. Therefore each pixel of the whole representation can have a long-range interaction with the encoded parts. Before feeding into the attention, both part and whole representations will be normalized by Layer Normalization. An identity mapping and a MLP are also applied as what does in common practice.
The process of the part-whole interaction in the decoder can be written as:
\begin{equation}
\begin{split}
\mathbf{{x}}^{i}_g &= \mathbf{x}^{i-1} + \text{Attention}(\mathbf{x}^{i-1}+\mathbf{d}_w, \mathbf{p}^{i}+\mathbf{d}_{d}, \mathbf{p}^{i}), \\
\mathbf{\hat{x}}^{i} &= \mathbf{x}^{i}_g + \text{MLP}(\mathbf{{x}}^{i}_g),
\end{split}
\end{equation}
where $\mathbf{d}_{d} \in \mathbb{R}^{N\times C}$ is the positional encoding for parts in decoders, the definitions of the attention mechanism and MLP are identical to those defined in Eq. \eqref{eq:attn_def} \eqref{eq:rpn_mlp}. Note that $\mathbf{d}_{d}$ is shared across all blocks of each stage. The axis that the softmax function normalizes on is the last dimension (specifically, the part dimension with $N$ inputs).
\textbf{Patch-based local attention.} The above process, in both the encoder and the decoder, has completed the cross-level interactions for the $i^{th}$ iteration. In addition to the long-range modeling that the cross-level interaction provided, we also apply a local attention for fine-grained feature modeling.
We divide the spatial feature maps into non-overlapping patches with size $k\times k$, then apply a multi-head self-attention module for all pixels within each patch. We denote the pixels of patch $t$ as $\mathbf{x}^{i}_t \in \mathbb{R}^{k^2 \times C}$, then the process of the local attention can be written as:
\begin{equation}
\begin{split}
\mathbf{\hat{x}}^{i}_t &= \mathbf{x}^{i}_t + \text{Attention}(\mathbf{x}^{i}_t, \mathbf{x}^{i}_t+\mathbf{r}^i, \mathbf{x}^{i}_t), \\
\mathbf{\hat{x}}^{i}_l &= \{\mathbf{\hat{x}}^{i}_1, ..., \mathbf{\hat{x}}^{i}_t, ..., \mathbf{\hat{x}}^{i}_{N_p}\},\\
\mathbf{x}^{i} &= \mathbf{\hat{x}}^{i}_l + \text{MLP}(\mathbf{\hat{x}}^{i}_l),
\end{split}
\end{equation}
where $N_p = \frac{L}{k^2}$ denotes the total number of patches, $\mathbf{r}^i \in \mathbb{R}^{k^{2}\times C}$ is the relative positional embedding. The implementation of the relative positional embedding follows the design in \citep{aa, botnet}. To save the computational cost, $\mathbf{r}^i$ is factorized into two embeddings $\mathbf{r}^i_h \in \mathbb{R}^{(2k-1)\times \frac{C}{2}}, \mathbf{r}^i_w \in \mathbb{R}^{(2k-1)\times \frac{C}{2}}$ for the dimension of height and width respectively.
\subsection{Architecture Specification.}
\label{sec:arch}
In this paper, we design five kinds of different variants called ViP-Mobile (Mo), ViP-Tiny (Ti), ViP-Small (S), ViP-Medium (M), ViP-Base (B) respectively.
These variants have some common features in design.
(1) Architectures of all these models are divided into four stages according to the spatial resolution $L$ of the feature map. Given an input with spatial size $H\times W$, the output spatial sizes of the feature maps for the four stages are $\frac{H}{4}\times\frac{W}{4}$, $\frac{H}{8}\times\frac{W}{8}$, $\frac{H}{16}\times\frac{W}{16}$ and $\frac{H}{32}\times\frac{W}{32}$.
(2) The expansion rates of the MLP within the encoder and the decoder, which indicates the ratio between the number of channels of the hidden output and the input, are set to be 1 and 3 separately.
(3) The patch size for the self-attention module of the decoder is set to $\{8, 7, 7, 7\}$ for four different stages.
(4) At the beginning of each stage, there is a patch embedding responsible for down-sampling and channel-wise expansion. We employ a separable convolution with normalization here with kernel size $3\times 3$ to perform the down-sampling operation for the whole representation. Since the number of channels of the part representation for each stage may vary, another linear operation is applied to align the number of channels between parts in different stages.
Apart from these common hyper-parameters, for a specific stage $s$, these variants mainly differ in the following aspects:
(1) The number of channels $C_s$,
(2) The number of parts $N_s$,
(3) The number of blocks $B_s$,
(4) The number of groups (heads) $G_s$ for the attention mechanism.
(5) For small models ViP-Mo, ViP-Ti and ViP-S, we employ a part encoder on top of the whole representation before the final global pooling and fully connected layer, while for ViP-M and ViP-B, we replace such encoder with a linear layer.
The overall architecture of the ViP family is shown in Table \ref{tab:table_net}. The detailed specification of the four variants can be found in the appendix.
\section{Related Work}
\textbf{Convolutional Neural Networks (CNNs).}
Conventional CNNs \citep{vggnet, googlenet, resnet, densenet, efficientnet, regnet} are prevalent in nearly all fields of computer vision since AlexNet \citep{alexnet} demonstrates its power for image recognition on ImageNet \citep{imagenet_cvpr09}. Now CNNs are still dominating nearly all major tasks in computer vision \textit{e.g.} image classification \citep{nfnet, lambdanet, efficientnet, resnet, regnet,sun2019fishnet}, object detection \citep{girshick2014rcnn,girshick2015fastrcnn,fasterrcnn,liu2016ssd,he2017mask,cascade-rcnn,focal_loss} and semantic segmentation \citep{long2015fully,chen2015semantic,yu2016multi,badrinarayanan2017segnet,zhao2017pspnet}.
\textbf{Part-whole hierarchies in visual representations.}
\citet{tu2005image} first devise a Bayesian framework to parse the image into a part-whole hierarchy for unifying all the major vision tasks.
Capsule Networks (CapsNets) \citep{dynamic_routing} were first proposed to use a dynamic routing algorithm to dynamically allocate neurons to represent a small portion of the visual input. There are some other extensive works based on CapsNets \citep{em_routing, stack_capsule, capsule_dot} showing remarkable performance on some small datasets, however, these works cannot be well scaled onto large datasets. The recent proposal of GLOM \citep{glom} gives an idea to build up a hierarchical representation with attention, but it gives no practical experiments. This paper borrows some ideas from these works to build a rather simple hierarchy with two levels for modeling basic visual representation.
For example, the iterative attention mechanism in our model is similar to the dynamic routing designed in CapsNet \citep{dynamic_routing} or iterative attention mechanism \citep{capsule_dot, slot_attention, detr}.
\textbf{Transformers and self-attention mechanism.}
With the success of Memory Networks \citep{memorynet} and Transformers \citep{transformer} for natural language modeling \citep{wu2019pay,Devlin2018,dai2019transformer,Yang2019xlnet}, lots of works in the field of computer vision attempted to migrate similar self-attention mechanism as an independent block into CNNs for image classification \citep{senet, glore, aa, visualtrans}, object detection \citep{hu2018relationnet, botnet, detr} and video action recognition \citep{jia2016dynamic, nonlocal,multiscale_trans}.
Recent works tried to replace all convolutional layers in neural networks with local attention layers to build up self-attention-based networks \citep{hu2018relationnet, sasa, san, cordonnier2019relationship, axial_attn, halonet}. To resolve the inefficiency problem, Vision Transformer (ViT) \citep{vit, deit} chose to largely reduce the image resolution and only retain the global visual tokens while processing. To aid the global token-based transformer with local inductive biases, there are several papers that incorporate convolution-like design into ViT \citep{t2t, cpvt, d2021convit, pit, cvt}. Apart from the token-based approach, concurrent works \citep{swin, pvt} that retain the spatial pyramids has also been proven to be effective. Different from the above existing works that extract either tokens or spatial feature maps for final prediction, ViP extracts both the token-based representations (the part) and spatial feature maps (the whole).
\textbf{Token-based global attention mechanism.} The interaction between the part and the whole is related to the token-based global attention mechanism. Recent works including \citep{glore, lambdanet, a2net, visualtrans} propose to tokenize the input feature map generated by the convolution block. Our work is different from theirs in three aspects:
(1) The part representations are explicitly and iteratively refined in ViP, while in these works, the tokens are latent bi-product of each block.
(2) We intend to design a hierarchy that can be used for final prediction while these works focus on designing a module then plug it into limited blocks of the network.
(3) In detail, the token extraction and the bi-directional pathway designed in ViP are quite different from their pipelines.
\input{figures_n_tables/table_imagenet}
\section{Experiments}
\label{sec:experiments}
\subsection{Image Classification on ImageNet-1K}
\textbf{Experimental Settings.} For image classification, we evaluate our models on ImageNet-1K \citep{imagenet_cvpr09}, which consists of 1.28M training images and 50K validation images categorized into 1,000 classes.
The network is trained for 300 epochs using AdamW \citep{adam} and a half-cosine annealing learning rate scheduler. The learning rate is warmed up for 20 epochs to reach the initial $1\times 10^{-3}$. Weight decays for {ViP-Mo,} ViP-Ti are set to be 0.03, while those for ViP-S, ViP-M are 0.05. The drop ratios of Stochastic Depth (\textit{a.k.a} DropPath) \citep{droppath} are linearly scaled from 0 to 0.1, 0.1, 0.2, 0.3 along the layer depth for each layer of ViP-Ti, ViP-S, ViP-M and ViP-B respectively. We do not apply Stochastic Depth to ViP-Mo during training.
The total training batch size is set to be 1024 for all model variants.
We primarily follow the settings of the data augmentation adopted in \citep{deit}, except for the repeat augmentation as we found it unhelpful towards the final prediction. Note that for all results for image classification on ImageNet reported in this paper, we did not use any external dataset for pre-training.
\textbf{ViP \textit{vs.} CNNs.} Table \ref{table:imagenet_final} compares ViP family with some of the state-of-the-art CNN models on ImageNet.
The RegNet is also better tuned using training tricks in \citep{deit}. ViP is both cost-efficient and parameter-efficient compared to these state-of-the-art models. For example, ViP-M can achieve a competitive $83.3\%$ with only 49.6M parameters and 8.0G FLOPS. The counterpart BOTNet-T5 needs 25.5M more parameters and 11.3G FLOPS to achieve similar performance. {When scaling the input to resolution 384$^2$, ViP-B is able to further improve its top-1 accuracy to $84.2\%$.}
\textbf{ViP \textit{vs.} ViT/DeiT.}
We first compare ViP to the token-based Vision Transformer (ViT), which radically reduces the image resolution at the beginning of the network. When both networks are trained from scratch on the training set of ImageNet-1K, ViP-Ti can outperform ViT-B by 1.1\% with only about $\frac{1}{7}$ of its number of parameters and a fraction of its FLOPS.
Another token-based vision transformer, DeiT, is also listed in Table \ref{table:imagenet_final} for comparison.
%
The basic structure of DeiT is identical to what was proposed in ViT but is trained with more data augmentations and regularization techniques.
%
When compare ViP with DeiT, we observe that ViP-Ti can surpass DeiT-Tiny by a significant \textbf{$6.8\%$}.
As for small models like ViP-S, it can outperform DeiT-S by $2.1\%$, which is even better than a way larger variant DeiT-B of the DeiT family. The remarkable improvement on ImageNet demonstrates the importance of retaining the local features within the network for image recognition.
\textbf{ViP \textit{vs.} HaloNet.}
To the best of our knowledge, HaloNet \citep{halonet} is the current state-of-the-art network on ImageNet-1K. Figure \ref{fig:halonet} shows the speed-accuracy Pareto curve of the ViP family compared to the HaloNet family. Note that the HaloNet is re-implemented by us on PyTorch. As shown in Figure \ref{fig:halonet}, ViP achieves better speed-accuracy trade-off than HaloNet. Concretely, ViP-S is 6.3$\times$ faster than HaloNet-H4 with similar top-1 accuracy on ImageNet-1K.
\textbf{ViP \textit{vs.} other state-of-the-art Transformers.}
As shown in Table \ref{table:imagenet_final}, ViP consistently outperforms previous state-of-the-art Transformer-based models in terms of accuracy and model size.
Especially, ViP-B achieves $83.8\%$ ImageNet top-1 accuracy, which is $0.5\%$ higher than Swin-B \cite{swin} with fewer parameters and FLOPS. A similar trend can also be observed when scaled onto larger models, \textit{e.g.} ViP-M achieves $83.3\%$ top-1 accuracy, outperforming TNT-B \cite{tnt}, T2T-ViT-24 \cite{t2t}, PVT-Large \cite{pvt} by $0.4\%$, $1.0\%$, $1.6\%$ respectively.
\input{figures_n_tables/table_retinanet}
\input{figures_n_tables/table_cascade_mask_rcnn}
\subsection{Object Detection and Instance Segmentation}
\textbf{Experimental settings.} For object detection and instance segmentation, we evaluate ViP on the challenging MS COCO dataset \citep{coco}, which contains 115k images for training (\emph{train-2017}) and 5k images (\emph{val-2017}) for validation. We train models on \emph{train-2017} and report the results on \emph{val-2017}. We measure our results following the official definition of Average Precision (AP) metrics given by MS COCO, which includes AP$_{50}$ and AP$_{75}$ (averaged over IoU thresholds $50$ and $75$) and AP$_{S}$, AP$_{M}$, AP$_{L}$ (AP at scale Small, Medium and Large). Annotations of MS COCO include both bounding boxes and polygon masks for object detection and instance segmentation respectively.
Experiments are implemented based on the open source mmdetection \citep{mmdetection} platform.
All models are trained under two different training schedules \emph{$1\times$} (12 epochs) and \emph{$3\times$} (36 epochs) using the AdamW \citep{adam} optimizer with the same weight decay set for image classification. After a 500 iteration's warming-up, the learning rate is initialized at $1\times 10^{-4}$ then decayed by 0.1 after [8, 11] and [27, 33] epochs for \emph{$1\times$} and \emph{$3\times$} respectively. For data augmentation, we only apply random flipping with a probability of 0.5 and scale jittering from 640 to 800. The batch size for each GPU is 2 and we use 8 GPUs to train the network for all experiments. Stochastic Depth is also applied here as what proposed on ImageNet.
We embed ViP into two popular frameworks for object detection and instance segmentation, RetinaNet \citep{focal_loss} and Cascade Mask-RCNN \citep{cascade-rcnn}.
When incorporating ViP into these frameworks, ViP serves as the backbone followed by a Feature Pyramid Network (FPN) \cite{lin17fpn} refining the multi-scale whole representations. All weights within the backbone are first pre-trained on ImageNet-1K, while those outside the backbone are initialized with Xavier \citep{xavier}.
\textbf{ViP can outperform ResNe(X)t with $~4\times$ less computational cost in RetinaNet.}
Table \ref{tab:retinanet} exhibits the experimental results when embedding different backbones into RetinaNet.
When trained under the $1\times$ schedule, our ViP-Ti can outperform its counterpart ResNet-18 by {$7.9$}, which is a large margin since it is even higher than the performance obtained by ResNet-101 ({$4\times$ larger than ViP-Ti in terms of FLOPS and parameters}). The ViP-S, which is just about the size of ResNet-50, can even outperforms the largest model ResNeXt-101-64$\times$4d listed in Table \ref{tab:retinanet} by a clear {$2.0$}. For larger variant ViP-M, it can further boost the performance to a higher level {$44.3$}.
%
The performance of the ViP family can be steadily boosted by the longer $3\times$ training schedule. As shown in Table \ref{tab:retinanet}, all variants of the ViP family can retain their superiority compared with their ResNe(X)t and PVT counterparts.
\textbf{ViP-Tiny can be comparable with the \emph{largest variant} of ResNe(X)t family in Cascade Mask RCNN.}
Table \ref{tab:cascade} shows the results when incorporating different backbones into Cascade Mask RCNN \citep{cascade-rcnn}. As shown in Table \ref{tab:cascade}, when trained under $1\times$ schedule, all variants of the ViP family can achieve significantly better performance compared to their counterparts. Notably, as a tiny model with only 11.2M parameters and 29G FLOPS, ViP-Ti can achieve comparable performance obtained by the largest variant in ResNe(X)t family ResNeXt-101-64$\times$4d which contains 81M parameters and 317G FLOPS. ViP also scales well with larger models. ViP-M further lifts the performance to 49.9 for object detection and 43.5 for instance segmentation.
%
When compared with state-of-the-art variants of ResNet family like ResNeSt \citep{zhang2020resnest}, ViP can also outperform them by a clear margin. Specifically, ViP-S and ViP-M outperforms ResNeSt-50 and ResNeSt-101 by $3.1$ and $2.2$ respectively on object detection and $2.7$ and $2.1$ on instance segmentation.
\input{figures_n_tables/fig_viz}
\subsection{Ablation studies}
\textbf{Number of parts:} As shown in Table \ref{tab:parts}, the number of parts $N$ is crucial when the model is small. Concretely, for ViP-Ti, $N$=32 can lead to a remarkable $0.8\%$ improvement on ImageNet compared to $N$=16. However, the improvement comes to be saturated when adding more parts into the network.
\textbf{Effects of the part-wise linear.} Different from the original design in Transformer \citep{transformer} that uses a self-attention module for part-wise communication, we replace it with a simple linear operation to save the computational cost. Introducing such a simple linear operation into ViP-S can lead to a $0.4\%$ gain on ImageNet with only a fractional increase in parameters (0.03M) and FLOPS (0.02G).
\textbf{Predicting on parts \textit{vs.} wholes.} As ViP has two levels, we can choose either of them for the final prediction. When using the parts for the final prediction, we employ an additional encoder on top of the whole before the final global pooling and fully connected layer to gather all parts obtained by the encoder. Otherwise, we replace the encoder with a linear projection.
Table \ref{tab:last_level} compares the results of predicting on the part representation. For small models like ViP-Ti and ViP-small, to predict on parts can lead to remarkable improvements ($+0.7\%$ and $+0.4\%$). However, predicting on part level encountered an overfitting problem when incorporated into ViP-M with a $0.6\%$ drop.
\subsection{Visualization}
\label{sec:viz}
The visualization results of a pre-trained ViP-S are shown as an example in Figure~\ref{fig:viz}.
We average all heads of the affinity matrix $\mathbf{M}$ in Eq. \eqref{eq:softmax} and then normalize it to [0, 255]. For each image, we visualize two parts in total for clearness.
It can be observed that the attention maps tend to cover more area in the shallow blocks, and then gradually focus on salient objects through multiple iterations. The observation suggests that the part encoder can effectively aggregate features from a part of the image, and the part representations can be refined with the information from the whole.
The visualization results show that a meaningful part-whole hierarchy is constructed by the proposed ViP.
\section{Conclusion}
In this work, we construct a framework that includes different levels of representations called Visual Parser (ViP). ViP divides visual representations into the part level and the whole level with a novel encoder-decoder interaction. Extensive experiments demonstrate that the proposed ViP can achieve very competitive results on three major vision tasks. Particularly, ViP outperforms the previous state-of-the-art CNN backbones by a large margin on object detection and instance segmentation.
Visualization results also indicate that the learned part representations are highly informative to the predicting classes. As the first step towards learning multi-level part-whole representations, our ViP is more explainable compared to previous architectures and shows great potential in visual modeling.
\input{acknowledgment}
\section{Appendix}
\subsection{Network Specification of ViP}
\input{figures_n_tables/table_specification}
The general specification of ViP is illustrated in Section~\ref{sec:arch}. Here in Table \ref{tab:detailed_spec} we show the detailed structure of different variants of the ViP family. Note that for small models including ViP-Mobile, ViP-Tiny, and ViP-Small, we apply another encoder at the end of the network but replacing MLP with the activation function GELU to predicting on the part level. While for larger models ViP-Medium and ViP-Base, we replace the encoder with a linear projection (with Batch Normalization \citep{ioffe2015batchnorm}) so that it can predict on the whole level.
\subsection{More Visualization Results}
\input{figures_n_tables/fig_viz_1}
Additional visualization results are shown in Figure \ref{fig:viz_1}. We follow the visualization method mentioned in Section~\ref{sec:viz}, and it is obvious that the proposed part encoder is robust and works well even for the complex scene.
{
\small
\bibliographystyle{plainnat}
| {'timestamp': '2022-01-11T02:11:49', 'yymm': '2107', 'arxiv_id': '2107.05790', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05790'} | arxiv |
\section{Introduction}
With the availability of large datasets \cite{deng2009imagenet,lin2014microsoft} in addition to the increase in computational power, the \acfp{dnn} have shown an outstanding performance in different tasks, such as image classification \cite{B0000,lecun1998gradient}, natural language processing \cite{B33333,cho2014learning}, object detection \cite{ren2015faster} and speech recognition \cite{hinton2012deep}. Despite their widespread use and phenomenal success,
these networks have shown that they are vulnerable to adversarial attacks. Szegedy {\it et al.} illustrated in \cite{szegedy2013intriguing} that small
and almost imperceptible perturbations added to a legitimate input image can easily fool the \acp{dnn} models and can make a misclassification with high confidence. The perturbed images are called \acp{ae}.
These adversarial attacks raise an important issue of the robustness of \acp{dnn} against these attacks, which limits their use and can be an obstacle to deploy them in sensitive applications such as self-driving cars, healthcare, video surveillance, etc. For instance, in Figure \ref{fig:figsys}, the initially clean input image is classified correctly as a stop sign by the \ac{dnn} model with high confidence. When carefully crafted perturbations are added to the input image, this leads it misclassified as a 120km/hr, which is significantly dangerous and can cause fatal consequences. Therefore, it is of paramount importance to improve the robustness of \acp{dnn} models, especially, if they are deployed in such critical applications.
Overall, unlike usual training, where the aim is to minimize the loss of \ac{dnn} classifier, an attacker tries to carefully craft an adversarial sample $x'$ by maximizing the loss with a small amount and thereby produce incorrect output. In other words, the attack tries to find the shortest adversarial direction $\Delta$ to inject the benign sample $x$ from its manifold into another one in order to mislead the \ac{dnn} model (see Figure \ref{fig:fig1}).
Various attacks are effective to generate an image-dependent \acp{ae} \cite{B16}, which limits its transferability to other images or models. Other methods \cite{moosavi2017universal} found some kind of universal perturbations that can fool a target classifier using any clean image. As shown in \cite{athalye2018synthesizing}, it is also possible
in the physical world to add 3D adversarial objects that can attack a \ac{dnn} model, thus creating a real security risk.
\begin{figure}[t!]
\centering
\includegraphics[width=0.49\textwidth]{AEsample3.pdf}
\caption{An example of adversarial attack in the context of street sign recognition. The introduction of a small imperceptible perturbation in the input image fools the \ac{dnn} classifier. The original image is classified as a \textit{Stop Sign} with 99.85\% confidence, while the adversarial example is classified as a \textit{120km/hr} with 99.91\% confidence.}
\label{fig:figsys}
\end{figure}
Consequently, several defense methods have been proposed attempting to correctly classify \acp{ae} and\linebreak thereby increasing model’s robustness. A defense\linebreak method aims to project the malicious sample $x'$ into it's data manifold to make the predicted label the same as the original sample $x$. Adversarial training \cite{madry2017towards,xie2019feature,carlini2018ground,kurakin2016adversarial,lee2017generative} is the most adopted technique that attempts to enhance the robustness against these vulnerabilities by integrating \acp{ae} to the clean ones into the training phase. However, such defense strategies do not generalize well against new/unknown attack models. Other defense methods try to reconstruct the \acp{ae} back to the training distribution by applying transformation on them. One of this approach consists to preprocess the \acp{ae} before feeding them to the \ac{dnn} model. For instance, denoising auto-encoders has been proposed in \cite{gu2014towards,bakhti2019ddsa} to remove/attenuate the perturbations. Similar approaches have been proposed based on generative models \cite{oord2016pixel}. These methods provided substantial results, however, systematically denoising each input image, can negatively impact the performance of clean images. Because, the denoiser can introduce blur if the denoising is incorrectly applied, which reduces the classification performance \cite{hendrycks2018benchmarking}. One of the possible solutions is to couple a defense strategy with a detection method as realized in the proposed work. Another limitation, generally these denoising-based approaches apply the denoising with a fixed non-adaptive strength, which is not optimal since certain adversarial perturbations are not distributed uniformly.
\begin{figure}[t!]
\centering
\includegraphics[width=0.45\textwidth]{fig1_cropped2.pdf}
\caption{Data distribution over the manifold. We restrict the manifold of benign samples $x$ between decision boundaries (the true class), the attacked sample $x'$ is injected out from its data manifold by a minimum $L_p$ norm based distance $\Delta$.}
\label{fig:fig1}
\end{figure}
Almost all existing defense methods are effective against some specific attacks, but fail to defend new or more powerful ones, especially, when the attacker knows the details of defense mechanism \cite{B16,B24,B29}. Therefore, many recent works have focused on detecting \acp{ae} \cite{B24,B29,B25,B8,B9,B15,B22,B23,B26,B27,lu2017safetynet} instead. The detection of \acp{ae} may be useful to warn users or to take security measures in order to avoid tragedies. Furthermore, for online machine learning service providers, the detection can be exploited to identify malicious clients and reject their inputs \cite{B25}. However, as shown in \cite{B29}, the existing \acp{ae} detection methods reported high detection accuracy, but have also obtained high false positive rate, meaning that they reject a significant amount of clean images, which can be considered a failure of these detection approaches.
In this paper, we propose a novel approach for defending against \acp{ae}, which is classifier-agnostic, i.e., it is designed in such a way that can be used with any classifier without any changes. Our method is two-stage framework comprising a separate detector network and a denoiser block, where the sample detected as adversarial is fed to the denoiser network in order to denoise it. However, for the ones that are detected as clean, they are fed directly to the classifier model. The detector is based on \ac{nss}, where we rely on the assumption that the presence of adversarial perturbations alters some statistical properties of natural images. Thus, quantifying these statistical outliers, i.e., deviations from the regularity, using scene statistics enables the building of a binary classifier capable of classifying a given image as legitimate or adversarial. For the denoiser, we used the \ac{bm3d} filter in order to clean up the attacked image from the adversarial perturbation. \ac{bm3d} is one of the best denoiser algorithm allowing to tackle non-uniform adversarial perturbations. In addition, we built a \ac{cnn} model that predicts the adequate strength of denoising, i.e., the parameters filter values, which best mitigate \acp{ae}. The experimental results showed that the proposed detection method achieves high detection accuracy, while providing a low false positive rate. In addition, the obtained results showed that the proposed defense method outperforms the state-of-the-art defense techniques under the strongest black-box, gray-box and white-box attacks on three datasets namely MNIST, CIFAR-10 and Tiny-ImageNet.
The rest of this paper is organized as follows: \linebreak Section \ref{sec:sec2} reviews some attack techniques and defense methods that have been proposed in the literature. Section \ref{sec:proposal} describes the proposed approach. The experimental results are presented and analyzed in Section \ref{sec:experimental}. Finally, Section \ref{sec:conclusion} concludes the paper. Table \ref{tab:tab1} summarizes most of the notations used in this paper
\begin{table}[t!]
\renewcommand{\arraystretch}{1.1}
\centering
\caption{Notations used in the paper.}
\adjustbox{max width=.49\textwidth}{%
\begin{tabular}{@{}ll@{}}
\toprule
Notations & Description \\ \midrule
$\xi$ & Image space. \\\hline
$I$ & Input image. \\\hline
$H \times W \times C$ & Height, width, channels of an image. \\\hline
$x$ & An instance of clean image. \\\hline
$x^\prime$ & A modified instance of $x$, adversarial image. \\\hline
$\tilde{x}$ & A filtered instance of $x^\prime$, denoised image. \\\hline
$c$ & The true class label of an input instance $x$. \\\hline
$f_\theta(x)$ & \begin{tabular}[c]{@{}l@{}} Output of a classifier model $f$ parameterized\\
by $\theta$, refers specifically to the predicted
\\likelihood for class $c$.
\end{tabular} \\\hline
$d(x, x^\prime)$ & Distance metric between $x$ and $x^\prime$. \\\hline
$\parallel \cdot \parallel_p$ & $L_p$ norm. \\\hline
$\nabla_x$ & Derivative with respect to $x$ (gradient). \\\hline
$\mathcal{L}$ & Loss function. \\\hline
$\mathcal{D}$ & Our detector block. \\\hline
$\mathcal{S}$ & Our denoiser block. \\\hline
$\widehat{I}$ & \begin{tabular}[c]{@{}l@{}} The \ac{mscn}\\ coefficients of image $I$.\end{tabular} \\\hline
$\beta$ & The shape parameter. \\\hline
$\sigma^2$ & The variance of a probability density function. \\\hline
$\eta$ & The Mean of the \acs{aggd}. \\\hline
$\tau_{3 D}$ & 3D linear transform. \\\hline
$\lambda_{3 D}$ & Threshold parameter of \acs{bm3d} filter. \\\hline
$f_X(x)$ & Probability density function. \\ \bottomrule
\end{tabular}
}
\label{tab:tab1}
\end{table}
\section{Related work}
\label{sec:sec2}
Adversarial examples are first introduced in this section, then different adversarial attacks are presented, and finally the state-of-the-art defense techniques are described.
\subsection{Adversarial examples}
Given an image space $\xi = [0, 1]^{H \times W \times C}$, a target classification model $f_\theta(\cdot)$ and a legitimate input image $x \in \xi$, an adversarial example is a perturbed image $x^\prime \in \xi$ such that $f(x^\prime) \neq f(x)$ and $d(x, x^\prime) \leq \epsilon$, where $\epsilon \geq 0$. $d$ is a distance metric used to measure the similarity between the perturbed and clean (unperturbed) input images~\cite{subQomex}. Three metrics are commonly used in the literature for generating \acp{ae} relying on $L_{p}$ norms, mainly $L_{0}$ distance, the Euclidean distance ($L_{2}$) and the {\it Chebyshev} distance ($L_{\infty}$ norm)~\cite{B16}.
\subsection{Adversarial Attacks}
Adversarial attacks fall into three main categories including black-box, gray-box and white-box attacks.\linebreak White-box attacks have a full access to both the defense technique and the target model's architecture and parameters, while black-box attacks have no access to the model's architecture and parameters. In this latter configuration, the attacker has only information on the output of the model (label or confidence score) for a given input. Finally, for gray-box attacks also referred as semi black-box attacks, the attacker is unaware of the defense block, but has full access to the architecture and parameters of the model.
In the following, we describe three attacks considered in the evaluation of our defense method. These attacks are widely used in the literature to assess the performance of defense techniques. For more details on adversarial attacks, the reader can refer to the review paper on \acp{ae}~\cite{DBLP:journals/corr/abs-1911-05268}.
\subsubsection{\Acl{fgsm} attack}
Goodfellow {\it et al.}~\cite{B5} introduced a fast attack method called \acf{fgsm}. The \ac{fgsm} performs only one step gradient update along the direction of the sign of gradient at each pixel as follows
\begin{equation}
x^\prime = x + \epsilon \, sign (\nabla_x \mathcal{L}_\theta(x, y)),
\end{equation}
where $\theta$ is the set of model's parameters and $\nabla_x \mathcal{L}$ computes the first derivative (gradient) of the loss function $\mathcal{L}$ with respect to the input $x$. The $sign( \cdot )$ function returns the sign of its input and $\epsilon$ is a small scalar value that controls the perturbation magnitude. The authors proposed to bound the adversarial perturbation under the {\it Chebyshev} distance $|| x - x^\prime||_\infty < \epsilon$.
\subsubsection{\Acl{pgd} attack}
The \acf{pgd} attack was introduced by Madry {\it et al.} in~\cite{B18} to build a robust deep learning models with adversarial training. The authors formulated the generation of an \ac{ae} as a composition of an inner maximization problem and an outer minimization problem.
Specifically, they introduced the following saddle point optimization problem
\begin{equation}
\begin{split}
& \min_\theta \rho(\theta), \\
\text{where } \; & \rho(\theta) = \mathbf{E}_{(x,y)\sim D} [\max_{\delta \in S} \mathcal{L}_\theta(x+\delta,y)],
\end{split}
\end{equation}
with $\mathbf{E}$ is a risk function, $\delta$ is the magnitude of the perturbation and $S$ is a set of allowed perturbations.
The inner maximization is the same as attacking a neural network by finding an adversarial example that maximizes the loss. On the other hand, the outer minimization aims to minimize the adversarial loss.
\subsubsection{\acl{cw} attack}
Carlini and Wagner~\cite{B16} introduced an attack that can be used under three different distance metrics: $L_0$, $L_2$ and $L_\infty$. The \ac{cw} attack aims at minimizing a trade-off between the perturbation intensity $|| \delta ||_p$ and the objective function $g(x^\prime)$, with $x^\prime=x+\delta$ and $g(x^\prime) \leq 0$ if and only if $f(x^\prime)=c$ and $f(x)\neq c$
\begin{equation}
\begin{split}
&\min_{\delta} || \delta ||_p + \lambda \, g(x+\delta), \\
&\text{such that } \; x+\delta \in [0, 1]^n,
\end{split}
\label{CW}
\end{equation}
where $c$ is the target class and $\lambda>0$ is a constant calculated empirically through a binary search.
In the case of the $L_2$ norm, the problem in (\ref{CW}) can be expressed as follows
\begin{equation}
\min_{\omega} \left |\left| \frac{1}{2} \left ( \tanh(\omega) +1 \right )-x \right | \right|_2^2 + \lambda \, g \left ( \frac{1}{2} \left ( \tanh(\omega) +1 \right ) \right ), \\
\label{CWL2}
\end{equation}
A change of variable introduces a new variable $\omega$ with $\delta = \frac{1}{2} \left ( \tanh(\omega) +1 \right ) - x$ that removes the constraint in~(\ref{CW}).
\subsection{Defenses against adversarial attacks}
\label{sec:DM}
As for the attacks, several defense techniques have been proposed in the literature in order to build more robust and resilient \acp{dnn} in \ac{ae}-prone context. Defending against adversarial attacks can fall into three categorizes: (1) adversarial training, (2) preprocessing, and (3) detecting \acp{ae}~\cite{B16b}.
\subsubsection{Adversarial training}
The adversarial training techniques consist in including \acp{ae} at the training stage of the model to build a robust classifier. Authors in \cite{DBLP:journals/corr/Moosavi-Dezfooli15,B4,liu2019rob} used benign samples with adversarial samples as data augmentation in the training process. In practice, different attacks can be used to generate the \acp{ae}. The optimized objective function can be formalized as a weighted sum of two classification loss functions as follows
\begin{equation}
\lambda \; \mathcal{L}_\theta( x , c ) + (1- \lambda) \; \mathcal{L}_\theta( x^\prime,c ) \,
\end{equation}
where $\lambda$ is a constant that controls the weighting of the loss terms between normal and \acp{ae}.
In \cite{madry2017towards}, the authors showed that using only the \ac{pgd} attack for data augmentation can achieve state-of-the-art defense performance on both MNIST and CIFAR-10 datasets. However, as demonstrated in \cite{schmidt2018adversarially}, achieving a good generalization under adversarial training is hard to achieve, especially against an unknown attack.
\subsubsection{Preprocessing}
The defense techniques in the preprocessing category process the input sample before its classification by the model. Authors in \cite{DBLP:journals/corr/abs-1711-01991} proposed a defense based on \ac{rrp}. The objective of this method is to attenuate the adversarial perturbation and introduce randomness through the transformations applied on the input sample. This randomness at the inference makes the gradient of the loss with respect to the input harder to compute. It has been shown in~\cite{athalye2018obfuscated} that defense techniques relying on randomization \cite{liu2018towards,lecuyer2019certified,dwork2009differential,li2019certified,dhillon2018stochastic} are effective under black-box and gray-box attacks, but they fail against the worst case scenario of white-box attack. The total variance minimization and JPEG compression have been investigated in~\cite{DBLP:journals/corr/DziugaiteGR16} as preprocessing transformations to project back the \ac{ae} to its original data subspace. To break the effect of these transformations, Athalye {\it et al.} \cite{DBLP:journals/corr/AthalyeS17} proposed a method named \ac{eot} to create adversaries that fool defenses based on such transformations. Other defense techniques rely on denoising process to remove or alleviate the effect of adversarial perturbations. The first denoising-based defense technique was proposed in~\cite{meng2017magnet} as a stack of auto-encoders to mitigate the adversarial perturbations. However, it has been shown in~\cite{zantedeschi2017efficient} that this technique is vulnerable to transferable attack generated by \ac{cw} attack in black-box setting. Author in \cite{DBLP:journals/corr/abs-1710-10766} introduced PixelDefend defense, which aims to process an input sample before passing it to the classifier. The PixelDefend technique trains a generative model such as PixelCNN architecture \cite{oord2016pixel} only on clean data in order to approximate the distributions of the data. It has also been shown in \cite{DBLP:journals/corr/abs-1710-10766} that the generative model can be used to detect \acp{ae} by comparing the input sample to the clean data under the generative model.
Similar to PixelDefend, Defense-GAN method \cite{samangouei2018defense} trains a generator for an ultimate goal to learn the distributions of clean images. Therefore, at the inference, this method transforms the \acp{ae} by finding a close benign image based on its distribution. Authors in~\cite{buckman2018thermometer} proposed a thermometer encoding to break the linear extrapolation behavior of classifiers by processing the input with an extremely nonlinear function. ME-Net \cite{yang2019me} uses matrix-estimation techniques to reconstruct the image after randomly dropping pixels in the input image according to a \hbox{probability $p$.} \addcomment{Borkar \textit{et al.} \cite{borkar2020defending} introduced trainable feature regeneration units, which regenerate activations of vulnerable convolutional filters into resilient features. They have shown that regenerating only the top 50\% ranked adversarial susceptible features in a few layers is enough to restore their robustness.}
\begin{figure*}[t!]
\centering
\includegraphics[scale=0.8]{Sheme_detect_denoise5.pdf}
\caption{Overview of the proposed defense method workflow composed of detector $\mathcal{D}$ and denoiser $\mathcal{S}$ blocks.}
\label{fig:fig2}
\end{figure*}
The gradient masking and obfuscated gradients have been explored to design defense techniques robust \linebreak against gradient based attacks. Meanwhile, \ac{bpda} \cite{athalye2018obfuscated} technique was proposed as a differentiable approximation for the defended model to obtain meaningful adversarial gradient estimates. The \ac{bpda} techniques enables to derive a differentiable approximation for a non-differentiable preprocessing transformation that can be explored with any gradient based attack. It has been shown that \ac{bpda} approximation breaks the majority of these preprocessing based defense techniques.
\subsubsection{Detecting adversarial samples}
Instead of trying to classify \acp{ae} correctly, which is difficult to achieve, many contributions have focused on only detecting these \acp{ae}. Grosse \textit{et al.} \cite{B23} proposed a technique that rely on statistical hypothesis on the input image to detect \acp{ae}, where the distribution of \acp{ae} statistically diverges from the data distribution. This hypothesis is explored to distinguish adversarial distributions from legitimate ones. Ma \textit{et al.} \cite{B27} explored the \ac{lid} concept for characterizing the dimensional properties of adversarial regions. The authors empirically showed that \ac{lid} of \acp{ae} is significantly higher than \ac{lid} of clean samples. Thus, they used the \ac{lid} of images as features to train a machine learning classifier to detect \acp{ae}. Xu \textit{et al.} \cite{B25} proposed a detection technique called \ac{fs}. Two \ac{fs} methods were considered to remove non-relevant features from the input: color bit-depth reduction and spatial smoothing, both with local and non-local smoothing. \ac{dnn}-based predictions of clean and squeezed samples are compared to detect \acp{ae}. More specifically, the input sample is labeled as adversarial when the $l_1$ distance between the two \ac{dnn} predictions of squeezed and unsequeezed samples is higher than a threshold value. Ma \textit{et al.} \cite{B15} proposed also another detection approach named \ac{nic}. This latter exploits two invariants in the \ac{dnn} classifier structure: the provenance channel and the activation value distribution channel. The \ac{nic} detector leverage these inveriants extracted from the \ac{dnn} classifier to perform runtime detection of adversarial samples. \addcomment{Under assumption that adversarial inputs leave activation fingerprints, i.e., the neuron activation values of clean and AEs are different, Eniser {\it et al.}~\cite{eniser2020raid} proposed a binary classifier that takes as inputs the differences in neuron activation values between clean and \acp{ae} inputs to detect if the input is adversarial or not. In~\cite{sheikholeslamiprovably}, a method for jointly training a provably robust classifier and detector was proposed. The authors proposed a verification scheme for classifiers with detection under adversarial settings. They extend the Interval Bound Propagation (IBP) method to account for robust objective, which enables verification of the network for provable performance guarantees. Authors in~\cite{aldahdooh2021selective} proposed a detection technique called \ac{sfad}. This latter uses the recent uncertainty method called SelectiveNet~\cite{selective2019} and integrates three detection modules. The first is selective detection module, which is a threshold-based detection derived from uncertainty of clean training data using SelectiveNet. The second is confidence detection module, which is threshold-based detection derived from softmax probabilities of clean training data from \ac{sfad}'s classifiers. \ac{sfad}'s classifiers analyze the representative data of last $N$-layers as a key point to present robust features of input data using autoencoding, up/down sampling, bottleneck, and noise blocks. The last module is ensemble prediction, which is mismatch based prediction between the detector and the baseline deep learning classifiers.}
The described detectors showed some limitations \cite{B29}, for instance they are effective against some specific attacks and lack generalization ability against different types of attacks. Also, they can achieve high accuracy but at the cost of increasing the \acl{fpr}, thus rejecting considerable legitimate inputs, which is not desired in real sensitive applications.
\section{Proposed Approach}
\label{sec:proposal}
In this paper, we propose a framework for defending against \acp{ae} \addcomment{in the digital domain, e.g., when attacking a computer vision system}. The proposed method consists of two main components that process the input sample before passing it to the classifier as shown in Figure~\ref{fig:fig2}. First, a detector block $\mathcal{D}$ distinguishes between clean sample $x$ and adversarial sample $x'$, and then a denoising block $\mathcal{S}$ alleviates perturbations in a sample detected as \ac{ae}.
In other words, this denoising block $\mathcal{S}$ aims to project the adversarial sample back into the manifold of $x$. Finally, the classifier is fed by a denoised sample in order to predict the sample label. These two blocks will be explored in more detail in the next two sections. \vspace{-3mm}
\subsection{Detector}
The detector $\mathcal{D}$ block relies on the concept of \ac{nss}. We assume that clean images possess certain regular statistical properties that are altered by adding adversarial perturbations. Thus, by characterizing these deviations from the regularity of natural statistics using \ac{nss}, it is possible to determine whether the input image $x$ is benign or malicious.
In order to extract scene statistics from input samples, we consider the efficient spatial \ac{nss} model~\cite{B0}, referred to as \ac{mscn} coefficients. The \ac{mscn} coefficients of a given input image $I$ are computed as follows
\begin{align}
\widehat{I}(i,j)=\frac{I(i,j)-\mu (i,j)}{\sigma (i,j)+c},
\label{eq:0}
\end{align}
where $i$ and $j$ are the pixel coordinates, and $c$ is a tiny constant added to avoid division-by-zero. The local mean $\mu$ and local standard deviation $\sigma$ are computed by (\ref{eq:mean}) and (\ref{eq:std}), respectively.
\begin{equation}
\mu(i,j)=\sum_{k=-3}^{3}\,\sum_{l=-3}^{3}\,w_{k,l} I_{k,l}(i,j).
\label{eq:mean}
\end{equation}
\begin{equation}
\sigma(i,j)=\sqrt{\sum_{k=-3}^{3}\,\sum_{l=-3}^{3}\,w_{k,l}(I_{k,l}(i,j)-\mu (i,j))^2}.
\label{eq:std}
\end{equation}
where $w=\{w_{k,l}|k=-3,...,3,l=-3,...,3\}$ is a 2D circularly-symmetric Gaussian weighting function.
\begin{figure*}[t!]
\centering
\subfigure[]{\label{fig:fig3a}\includegraphics[scale=0.30]{fig3.pdf}}\hspace{1.5mm}
\subfigure[]{\label{fig:fig3b}\begin{tikzpicture}[scale = 0.67]
\begin{axis}[
title={},
xlabel={MSCN},
ylabel={Number of coefficients (Normalized)},
xmin=-2.5, xmax=3.5,
ymin=0, ymax=1,
ytick={0,0.20,0.40,0.60,0.80,1.00},
xtick={-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3.0},
legend pos=north east,
ymajorgrids=true,
xmajorgrids=true,
grid style=dashed,
]
\addplot[
color=green,
mark=square,
]
coordinates {(-2.0284075875919214, 0.0004048582995951417)
(-1.9413355866337088, 0.0006747638326585695)
(-1.854263585675496, 0.0006747638326585695)
(-1.7671915847172837, 0.002699055330634278)
(-1.680119583759071, 0.0032388663967611335)
(-1.5930475828008583, 0.006612685560053981)
(-1.505975581842646, 0.009716599190283401)
(-1.4189035808844332, 0.01862348178137652)
(-1.3318315799262206, 0.026585695006747637)
(-1.244759578968008, 0.03805668016194332)
(-1.1576875780097953, 0.056950067476383266)
(-1.0706155770515828, 0.08083670715249662)
(-0.9835435760933702, 0.11147098515519568)
(-0.8964715751351575, 0.16842105263157894)
(-0.8093995741769451, 0.20418353576248313)
(-0.7223275732187324, 0.2941970310391363)
(-0.6352555722605198, 0.36531713900134954)
(-0.5481835713023071, 0.4341430499325236)
(-0.46111157034409445, 0.5302294197031039)
(-0.374039569385882, 0.6269905533063428)
(-0.28696756842766935, 0.739136302294197)
(-0.1998955674694567, 0.8205128205128205)
(-0.11282356651124426, 0.9314439946018893)
(-0.025751565553031597, 1.0)
(0.06132043540518106, 0.9674763832658569)
(0.14839243636339372, 0.8596491228070176)
(0.23546443732160638, 0.8086369770580297)
(0.32253643827981904, 0.6670715249662618)
(0.40960843923803125, 0.5155195681511471)
(0.4966804401962439, 0.42645074224021595)
(0.5837524411544566, 0.3832658569500675)
(0.6708244421126692, 0.3219973009446694)
(0.7578964430708819, 0.18488529014844804)
(0.8449684440290945, 0.1292847503373819)
(0.9320404449873072, 0.096221322537112)
(1.0191124459455199, 0.06774628879892038)
(1.1061844469037325, 0.04939271255060729)
(1.1932564478619447, 0.03454790823211876)
(1.2803284488201574, 0.0437246963562753)
(1.36740044977837, 0.01524966261808367)
(1.4544724507365827, 0.008367071524966262)
(1.5415444516947954, 0.006747638326585695)
(1.628616452653008, 0.0035087719298245615)
(1.7156884536112207, 0.0017543859649122807)
(1.802760454569433, 0.0006747638326585695)
(1.8898324555276456, 0.0005398110661268556)
(1.9769044564858582, 0.0002699055330634278)
(2.0639764574440713, 0.0004048582995951417)
(2.1510484584022835, 0.0002699055330634278)
(2.2381204593604958, 0.0001349527665317139)};
\addplot[
color=blue,
mark=Mercedes star,
]
coordinates {(-2.414627164146805, 0.0003977724741447892)
(-2.3185700131204503, 0.0011933174224343676)
(-2.2225128620940957, 0.002386634844868735)
(-2.126455711067741, 0.0031821797931583136)
(-2.0303985600413865, 0.0053699284009546535)
(-1.9343414090150322, 0.009148766905330152)
(-1.8382842579886778, 0.017899761336515514)
(-1.7422271069623232, 0.035003977724741446)
(-1.6461699559359686, 0.05827366746221162)
(-1.550112804909614, 0.10182975338106603)
(-1.4540556538832594, 0.18178202068416865)
(-1.357998502856905, 0.2790373906125696)
(-1.2619413518305505, 0.39737470167064437)
(-1.1658842008041959, 0.544351630867144)
(-1.0698270497778415, 0.6722354813046937)
(-0.9737698987514869, 0.7360779634049324)
(-0.8777127477251323, 0.7684964200477327)
(-0.7816555966987777, 0.7603420843277645)
(-0.6855984456724231, 0.7028639618138425)
(-0.5895412946460687, 0.6595067621320605)
(-0.49348414361971416, 0.6119729514717581)
(-0.3974269925933598, 0.5654335719968179)
(-0.3013698415670052, 0.49781225139220364)
(-0.2053126905406506, 0.44749403341288785)
(-0.10925553951429601, 0.41408114558472553)
(-0.013198388487941415, 0.4335719968178202)
(0.08285876253841318, 0.44172633253778837)
(0.17891591356476777, 0.48448687350835323)
(0.2749730645911219, 0.5753778838504375)
(0.3710302156174765, 0.6533412887828163)
(0.4670873666438311, 0.7426412092283214)
(0.5631445176701857, 0.8277645186953063)
(0.6592016686965403, 0.9357597454256166)
(0.7552588197228949, 1.0)
(0.8513159707492495, 0.9570405727923628)
(0.9473731217756041, 0.8056881463802705)
(1.0434302728019587, 0.5644391408114559)
(1.1394874238283128, 0.37291169451073986)
(1.2355445748546674, 0.23607796340493237)
(1.331601725881022, 0.12291169451073986)
(1.4276588769073766, 0.07438345266507558)
(1.5237160279337312, 0.034606205250596656)
(1.6197731789600853, 0.022275258552108195)
(1.7158303299864404, 0.011933174224343675)
(1.8118874810127945, 0.004375497215592681)
(1.9079446320391495, 0.0027844073190135244)
(2.0040017830655037, 0.0015910898965791568)
(2.1000589340918587, 0.0005966587112171838)
(2.196116085118213, 0.0001988862370723946)
(2.292173236144567, 0.0005966587112171838)};
\addplot[
color=purple,
mark=otimes*,
]
coordinates {(-2.341043936078205, 0.0009300162752848175)
(-2.248445867448091, 0.0011625203441060219)
(-2.1558477988179763, 0.0032550569634968614)
(-2.063249730187862, 0.0034875610323180655)
(-1.9706516615577476, 0.00906765868402697)
(-1.8780535929276332, 0.011857707509881422)
(-1.785455524297519, 0.026970471983259706)
(-1.6928574556674045, 0.04603580562659847)
(-1.60025938703729, 0.08230644036270635)
(-1.5076613184071757, 0.14252499418739828)
(-1.4150632497770612, 0.22692397116949548)
(-1.322465181146947, 0.3420134852359916)
(-1.2298671125168326, 0.4938386421762381)
(-1.1372690438867181, 0.6235759125784701)
(-1.044670975256604, 0.7340153452685422)
(-0.9520729066264895, 0.8198093466635666)
(-0.859474837996375, 0.8551499651243897)
(-0.7668767693662606, 0.8398046965821901)
(-0.6742787007361462, 0.788421297372704)
(-0.5816806321060319, 0.7693559637293652)
(-0.4890825634759175, 0.7021622878400372)
(-0.39648449484580306, 0.6686817019297838)
(-0.30388642621568884, 0.6338060916066031)
(-0.21128835758557418, 0.5900953266682167)
(-0.11869028895545997, 0.5512671471750755)
(-0.02609222032534575, 0.5338293420134852)
(0.06650584830476891, 0.5638223668914206)
(0.15910391693488313, 0.606370611485701)
(0.25170198556499734, 0.670076726342711)
(0.344300054195112, 0.7249476865845152)
(0.4368981228252262, 0.7700534759358288)
(0.5294961914553409, 0.850964891885608)
(0.6220942600854551, 0.9216461288072542)
(0.7146923287155693, 0.9667519181585678)
(0.807290397345684, 1.0)
(0.8998884659757982, 0.9130434782608695)
(0.9924865346059129, 0.7523831667054174)
(1.085084603236027, 0.575680074401302)
(1.1776826718661413, 0.38107416879795397)
(1.270280740496256, 0.25110439432690074)
(1.3628788091263702, 0.15182515694024645)
(1.4554768777564844, 0.08416647291327599)
(1.548074946386599, 0.04882585445245292)
(1.6406730150167133, 0.025807951639153684)
(1.7332710836468275, 0.013717740060451058)
(1.8258691522769421, 0.007207626133457335)
(1.9184672209070568, 0.0027900488258544524)
(2.0110652895371706, 0.0013950244129272262)
(2.1036633581672852, 0.0011625203441060219)
(2.1962614267974, 0.0009300162752848175)
};
\addplot[
color=black,
mark= halfdiamond*,
]
coordinates {(-2.664373924929378, 0.0014678899082568807)
(-2.5573391470001186, 0.0033027522935779817)
(-2.450304369070859, 0.0027522935779816515)
(-2.3432695911415995, 0.006972477064220183)
(-2.23623481321234, 0.007706422018348624)
(-2.1292000352830804, 0.011926605504587157)
(-2.022165257353821, 0.01926605504587156)
(-1.9151304794245618, 0.027155963302752294)
(-1.8080957014953023, 0.03688073394495413)
(-1.7010609235660428, 0.05908256880733945)
(-1.5940261456367835, 0.07944954128440367)
(-1.486991367707524, 0.11302752293577982)
(-1.3799565897782644, 0.17559633027522936)
(-1.272921811849005, 0.25761467889908257)
(-1.1658870339197456, 0.36403669724770643)
(-1.0588522559904863, 0.5275229357798165)
(-0.9518174780612267, 0.6928440366972477)
(-0.8447827001319672, 0.8297247706422018)
(-0.7377479222027079, 0.953394495412844)
(-0.6307131442734484, 1.0)
(-0.5236783663441891, 0.9510091743119266)
(-0.4166435884149293, 0.7462385321100917)
(-0.30960881048567, 0.5548623853211009)
(-0.2025740325564107, 0.44238532110091744)
(-0.09553925462715096, 0.38403669724770645)
(0.011495523302108346, 0.40110091743119264)
(0.11853030123136765, 0.43486238532110094)
(0.22556507916062696, 0.5394495412844037)
(0.3325998570898867, 0.7192660550458716)
(0.439634635019146, 0.9031192660550459)
(0.5466694129484053, 0.9917431192660551)
(0.6537041908776651, 0.9939449541284404)
(0.7607389688069244, 0.8673394495412844)
(0.8677737467361837, 0.6697247706422018)
(0.9748085246654434, 0.5223853211009174)
(1.0818433025947027, 0.34275229357798165)
(1.188878080523962, 0.2486238532110092)
(1.2959128584532218, 0.181651376146789)
(1.402947636382481, 0.10256880733944954)
(1.5099824143117404, 0.07192660550458715)
(1.6170171922409997, 0.04990825688073394)
(1.724051970170259, 0.031926605504587154)
(1.8310867480995192, 0.025137614678899082)
(1.9381215260287785, 0.015963302752293577)
(2.045156303958038, 0.011009174311926606)
(2.152191081887297, 0.009174311926605505)
(2.2592258598165564, 0.009174311926605505)
(2.3662606377458157, 0.006788990825688073)
(2.473295415675076, 0.0045871559633027525)
(2.5803301936043352, 0.0014678899082568807)
};
\legend{Org,FGSM,PGD,CW}
\end{axis}
\end{tikzpicture}}
\caption{Illustration of the relationship between natural scene statistics and adversarial perturbations. (a) \textit{top}: the original image and different attacked versions. \textit{bottom}: the \ac{mscn} coefficients of the images shown in the top row. (b) Histogram of \ac{mscn} coefficients for the original image and attacked images.}\label{fig:fig3}
\end{figure*}
\begin{figure*}[t!]
\centering
\includegraphics[width=0.80\textwidth]{fig4.pdf}
\caption{Overview of the proposed detection method workflow.}
\label{fig:fig4}
\end{figure*}
In order to demonstrate that \ac{mscn} coefficients are affected by adversarial perturbations, Figure \ref{fig:fig3} illustrates the \ac{mscn} coefficients of the original (clean) image and its associated attacked versions. We consider three white-box attacks used in the experiments, namely \ac{fgsm}, \ac{pgd} and \ac{cw}. First, according to the obtained class label, it is clear that all attacks have succeeded in fooling the \ac{dnn} model with high confidence, while the attacked images are visually very close to the original one. From Figure~\ref{fig:fig3a}, we can also see that the \ac{mscn} coefficients of the original image differ significantly from those of adversarial attacks.
In addition, in order to show how the \ac{mscn} coefficients vary with the presence of \acp{ae}, Figure \ref{fig:fig3b} plots the histogram of \ac{mscn} coefficients of images shown in Figure \ref{fig:fig3a} (top row). The original image exhibits a Gaussian-like \ac{mscn} distribution, while the same does not hold for the \acp{ae} which produce distributions with notable differences.
These results show that each attacked sample is characterized by its own histogram, which does not follow a Gaussian-like \ac{mscn} distributions like for the clean image. Based on that, we model these coefficients using the \ac{ggd} to estimate the parameters that are extracted from the scene statistics. The \ac{ggd} function is defined as follows
\begin{equation}
f_X(x; \beta, \sigma^2) = \frac{\beta}{2\alpha\Gamma(1/\beta)}e^{-\big(\frac{|x|}{\alpha}\big)^\beta},
\label{eq:1}
\end{equation}
where
$\alpha = \sigma \sqrt{\frac{\Gamma\big(\frac{1}{\beta}\big)}{\Gamma\big(\frac{3}{\beta}\big)}}$
and $\Gamma\left(\cdot\right)$ is the gamma function: $\Gamma \left( a \right) = \int\limits_0^\infty {t^{a - 1} e^{ - t} dt} \:, a >0$.
The value of $\beta$ controls the shape and $\sigma^2$ is the variance controller parameter. Due to the symmetry property of the \ac{mscn} coefficients, we used the moment-matching~\cite{B2} to estimate the couple $(\beta, \, \sigma^2)$. To perform more accurate detection, we add the adjacent coefficients to model the pairwise products of neighboring \ac{mscn} coefficients along four directions (1) horizontal $H$, (2) vertical $V$, (3) main-diagonal $D1$ and (4) secondary-diagonal $D2$~\cite{B0}. These orientations computed in Equation~(\ref{eq:orien}) have also certain regularities, which get altered in presence of adversary perturbations.
\begin{equation}
\begin{split}
&H(i,j) = \hat{I}(i,j) \hat{I}(i, j + 1),
\\&V(i,j) = \hat{I}(i,j) \hat{I}(i + 1, j),
\\&D1(i,j) = \hat{I}(i,j) \hat{I}(i + 1, j + 1),
\\&D2(i,j) = \hat{I}(i,j) \hat{I}(i + 1, j - 1).
\end{split}
\label{eq:orien}
\end{equation}
It is clear that the results of these pairwise products lead to an asymmetric distribution, so instead of using \ac{ggd}, we chose the \ac{aggd}, which is defined as follows
\begin{align}
f_X(x; \nu, \sigma_l^2, \sigma_r^2) =
\begin{cases}
\frac{\nu}{(\alpha_l + \alpha_r)\Gamma\big(\frac{1}{\nu}\big)}e^{\big(-\big(\frac{-x}{\alpha_l}\big)^\nu\big)} & x < 0 \\
\frac{\nu}{(\alpha_l + \alpha_r)\Gamma\big(\frac{1}{\nu}\big)}e^{\big(-\big(\frac{x}{\alpha_r}\big)^\nu\big)} & x \geq 0
\end{cases}
\label{eq:7}
\end{align}
where
$ \alpha_{side} = \sigma_{side} \sqrt{\frac{\Gamma\big(\frac{1}{\nu}\big)}{\Gamma\big(\frac{3}{\nu}\big)}}$
where $side$ can be either $r$ or $l$, $\nu$ represents the shape parameter and $\sigma_{side}^2$ expresses the left or the right variance parameters. So to estimate $(\nu ,{\sigma_l}^2,{\sigma_r}^2)$, we use the moment-matching as described in~\cite{B3}. Another parameter that is not reflected in the previous formula is the mean which is defined as follows
\begin{align}
\eta = (\alpha_r - \alpha_l) \frac{\Gamma\big(\frac{2}{\nu}\big)}{\Gamma\big(\frac{1}{\nu}\big)}
\label{eq:9}
\end{align}
The \ac{aggd} can be characterized by 4 features \- $(\eta,\nu,\sigma_l^2,\sigma_r^2)$ for each of the four pairwise products. The concatenation of the two \ac{ggd} parameters with the 16 \ac{aggd} ones results in 18 features ${\bf f}$ per image
\begin{multline*}
{\bf f} = \{ \beta, \, \sigma^2, \, \eta_H, \, \nu_H, \, \sigma_{l_{H}}^2, \, \sigma_{r_{H}}^2, \, \eta_V, \, \nu_V, \, \sigma_{l_{V}}^2, \, \sigma_{r_{V}}^2, \, \\\eta_{D1}, \, \nu_{D1}, \, \sigma_{l_{D1}}^2, \, \sigma_{r_{D1}}^2, \, \eta_{D2}, \, \nu_{D2}, \, \sigma_{l_{D2}}^2, \, \sigma_{r_{D2}}^2 \}
\label{eq:10}
\end{multline*}
This low number of considered features motivates the choice to train a \ac{svm} binary classification model for the detector as shown in Figure \ref{fig:fig4}. Thus, the \ac{svm} classifies each input image as either benign or \ac{ae}, where the sample detected as \ac{ae} is first processed by the denoiser, as detailed in the next section.
\subsection{Denoiser}
The aim of the denoiser block $\mathcal{S}$ is to alleviate the adversarial perturbations and thus project back the \ac{ae} into its original data manifold. In other words, the denoiser $\mathcal{S}$ tries to reconstruct from an adversarial example $x'$ a new sample $\tilde{x}$ such that $f_\theta(\tilde{x}) = f_\theta(x)$.
The denoiser block processes only input samples detected as \ac{ae}, whereas, the samples detected as clean are directly passed to the classifier. In this way, we enhance the robustness against these adversarial attacks without affecting the classification accuracy of clean samples.
\begin{figure*}[t!]
\centering
\subfigure[MNIST]{\label{fig:fig5a}\includegraphics[scale=0.85]{SchemaNet1.pdf}}\hspace{8mm}
\subfigure[CIFAR-10]{\label{fig:fig5b}\includegraphics[scale=0.85]{SchemaNet2.pdf}}
\subfigure[Tiny-ImageNet]{\label{fig:fig5c}\includegraphics[scale=0.85]{SchemaNet3.pdf}}
\caption{The proposed \acs{cnn} architectures used in the prediction of \acs{bm3d} parameters $\lambda_{3 D}$ for (a) MNIST, (b) CIFAR-10 and (c) Tiny-ImageNet datasets. The GlobalAveragePooling2D layer calculates the average of its input and outputs a single scalar value for each feature map.}
\label{fig:fig5}
\end{figure*}
The denoiser relies on the \acf{bm3d} filter initially proposed in~\cite{dabov2007image}. This denoiser is considered to be one of the best non-learning-based denoising methods, furthermore, some work has shown that BM3D even out-performs deep learning-based denoising approaches for some real-world applications \cite{plotz2017benchmarking}. In addition, the BM3D allows locally adaptive parameter tuning based on block or region, making it suitable for non-uniform adversarial perturbations distribution.
The \ac{bm3d} filter first gathers similar 2D patches $P$ of an image in a 3D-block denoted $\mathbf{P}(P)$. For a given patch $P$ of size $\kappa \times \kappa$, the filter searches for similar patches $Q$ within a window of size $n \times n$ in the image, where $n>\kappa$. The search window is extracted such that the patch $P$ is the window center. The similarity between two patches is measured as follows
\begin{align}
\mathbf{P}(P)=\left\{Q: d(P, Q) \leq \tau \right\},
\end{align}
where $d$ is the normalized quadratic distance and $\tau$ is a threshold value set to check whether two patches are similar or not. In order to speed up the process, from the similar $Q$ patches within the 3D-block $\mathbf{P}(P)$, only the $N$ closest patches to $P$ are selected to get the $\tilde{\mathbf{P}}(P)$ 3D group, where $P$ is included.
After the grouping step, a 3D linear transform $\tau_{3D}$ is applied on each 3D pile of correlated patches, followed by a shrinkage. Finally, the inverse of this isometric transform is applied to give an estimation of each patch as follows
\begin{align}
\tilde {\mathbf{P}}(P)=\tau_{3 D}^{-1}\left[ \gamma\left(\tau_{3 D}\left[ \tilde{\mathbf{P}}(P) \right ] \right) \right],
\end{align}
where $\gamma$ is a thresholding that depends on $\lambda_{3 D}$:
\begin{align}
\gamma(x)=\left\{\begin{array}{ll}
0 & \text { if } \quad|x| \leq \lambda_{3 D} \\
x & \text { otherwise }
\end{array}\right.
\end{align}
The above grouping and filtering procedures are improved in a second step using Wiener filtering. This step is nearly the same as the first one, with only two differences. The first difference consists in comparing the filtered patches instead of the original ones at the grouping step. The second difference relies in using the Wiener filtering to process the new 3D groups, instead of using linear transform and thresholding. For further details about the filtering process, the reader is referred to~\cite{dabov2007image}.
The performance of the \ac{bm3d} depends on its parameter settings. However, studies conducted in~\cite{bashar2016bm3d,lebrun2012analysis,mukherjee2019cnn} showed that the threshold $\lambda_{3 D}$ is the most crucial and significant parameter in \ac{bm3d}'s denoising process. Since \acp{ae} can contain different levels of adversarial perturbations, it is therefore important to choose the appropriate $\lambda_{3 D}$ parameter to mitigate each level of perturbation. To reach this goal, in this work, we use a \ac{cnn} to automatically predict the best $\lambda_{3 D}$ suited to each AE.
Inspired by the extension of \ac{bm3d} for color images initially investigated in~\cite{dabov2007image}, we propose to perform the grouping step relying only on the luminance component $Y$ after a color transformation from RGB color space to a luminance-chrominance color space, where $Y$ denotes luminance channel, while $U$ and $V$ refer to the two chrominance components. After building the 3D block on the $Y$ channel, we used it for all three channels, then the remaining \ac{bm3d}'s processes are applied to each channel separately. Therefore, three parameters of the thresholding $\lambda_{3 D}$ must be predicted, one per channel.
Thus, we performed the prediction of these thresholds under the RGB color space using a \ac{cnn} trained to derive, for each channel, an optimum value of $\lambda_{3 D}$. Figures~\ref{fig:fig5a}, \ref{fig:fig5b} and \ref{fig:fig5c} illustrate the three proposed architectures used to predict the optimal thresholding parameters for the three different image datasets, namely MNIST, CIFAR-10 and Tiny-ImageNet, respectively. These three different architectures have been proposed to adapt the \ac{cnn} to the complexity of parameters prediction which depends on the characteristics of the dataset including the dataset size, the color space and image resolution. The first architecture illustrated in Figure ~\ref{fig:fig5a} is fed with a grayscale image to predict a single $\lambda_{3 D}$ parameter, while architectures in Figures \ref{fig:fig5b} and \ref{fig:fig5c} are fed with the three RGB components of a color image to predict the three associated thresholding parameters, i.e., three $\lambda_{3 D}$ values.
The three networks are trained in a supervised learning fashion by minimizing a mean squared error loss function between the network output and the ground truth. The ground truth consists of a set of adversarial samples and the optimal denoising parameters enabling to back project an attacked image into its data manifold. To build the ground truth, an exhaustive denoising approach is conducted to denoise a set of adversarial samples perturbed by the \ac{pgd} attack at different $\epsilon$ magnitudes. The \ac{pgd} attack is selected based on the fact that adversarial training with \ac{pgd} attack tends to generalize well across a wide range of attacks \cite{B18}. So each sample is denoised with a set of $\lambda_{3 D}$ parameters in the interval $[ 0.0, 1.0]$ with a step of $0.125$. This denoising process can result in several samples that are correctly classified. Among these samples, only one maximizing the \ac{ssim} \cite{wang2004image} image quality metric is retained in the ground truth. The \ac{ssim} metric is computed between the original image $x$ and the denoised one $\tilde{x}$.
The \ac{ssim} image quality metric assesses the quality of the denoised image with respect to the original one by exploring the structural similarity. Preserving the structural similarity after denoising will contribute to achieve a correct classification by the model with a high confidence score. The $\lambda_{3 D}$ parameters selected for each attacked sample with the highest \ac{ssim} score are assigned as the training labels for that adversarial sample.
\section{Experimental results}
\label{sec:experimental}
We describe in this section the evaluation process of our defense method with respect to the state-of-the-art defense techniques on three well known datasets: MNIST, CIFAR-10 and Tiny-ImageNet. First, we describe the selected datasets and the training stage, then the robustness of the proposed approach is assessed under three types of attacks, namely black-box, gray-box and white-box attacks.
\subsection{Datasets}
We evaluated the robustness of our defense technique on \acp{cnn} models trained on three standard datasets, namely:
\begin{itemize}
\item \textbf{MNIST} dataset consists of grayscale hand-written 10 digits images of size $28\times28$. This dataset contains 70,000 images split into training, validation and testing sets with 50,000, 10,000 and 10,000 images, respectively.
\item \textbf{CIFAR-10} dataset contains color images of size $32\times32$. It has ten classes and 60,000 images divided into training and testing sets with 50,000 and 10,000 images, respectively.
\item \textbf{Tiny-ImageNet} dataset includes also color images of size $64\times64$ with a greater number of 200 classes. Each class includes 500, 50 and 50 images used for training, validation and testing, respectively.
\end{itemize}
We built our own \ac{cnn} classifier for MNIST dataset resulting in a state-of-the-art accuracy of $99.4\%$. For CIFAR-10 and Tiny-ImageNet datasets, we considered existing models achieving accuracy scores of 98.5\%~\cite{cubuk2019autoaugment} and 69.2\%~\cite{tiny}, respectively.
\begin{table*}[t]
\renewcommand{\arraystretch}{1.1}
\centering
\caption{Performance of the proposed defense method under black-box attacks.\label{tab:tab3}}
\begin{tabular}{l lcc cccc cc}
\toprule
\multicolumn{1}{l}{\multirow{2}{*}{\textbf{Dataset}}}&\multicolumn{1}{l}{\multirow{2}{*}{\textbf{Method}}} & \multicolumn{1}{c}{\multirow{2}{*}{\textbf{FGSM}}} & \multicolumn{4}{c}{\textbf{\acs{pgd}}} & \multicolumn{2}{c}{\textbf{CW}} \\
\cmidrule(lr){4-7}
\cmidrule(lr){8-9}
\multicolumn{1}{c}{} &\multicolumn{1}{c}{} & \multicolumn{1}{l}{} & \textbf{7 steps} & \textbf{20 steps}& \textbf{40 steps} & \textbf{100 steps} & \textbf{$\kappa=20$} & \textbf{$\kappa=50$} \\ \midrule
\multicolumn{1}{l}{\multirow{4}{*}{\rotatebox[origin=c]{0}{MNIST}}}& Madry \cite{madry2017towards} & 96.8\% &-&- & 96.0\% & 95.7\% &96.4\% & 97.0\% \\
&Thermometer \cite{buckman2018thermometer} & -&-&- & 41.1\% & - & - & - \\
& ME-Net \cite{yang2019me} & 93.2\% &-&- & 92.8\% & 92.2\% & 98.8\% & {98.7\%} \\
& {Our method} & \textbf{97.6\%} &\textbf{99.4\%} & \textbf{99.4\%} & \textbf{99.4\%} & \textbf{99.4\%} & \textbf{99.2\%} & \textbf{98.9\%} \\ \bottomrule
\multicolumn{1}{l}{\multirow{4}{*}{\rotatebox[origin=c]{0}{CIFAR-10}}}&Madry \cite{madry2017towards} & 67.0\% & 64.2\% & - & - &- & 78.7\% & - \\
& Thermometer \cite{buckman2018thermometer} & - & 77.7\% & - & - &- & - & - \\
& ME-Net \cite{yang2019me} & 92.2\% & 91.8\% & 91.8\% & 91.3\%&- & 93.6\% & \textbf{93.6\%} \\
&{Our method} & \textbf{95.7\%} & \textbf{98.3\%} & \textbf{98.2\%} & \textbf{98.2\%} &\textbf{97.9\%}& \textbf{93.8\%} & 92.8\% \\ \bottomrule
\multicolumn{1}{l}{\multirow{2}{*}{\rotatebox[origin=c]{0}{Tiny-ImageNet}}}&ME-Net \cite{yang2019me} & 67.1\% & 66.3\% & 60.0\% & 65.8\% &- & 67.6\% & \textbf{67.4\%} \\
& {Our method} & \textbf{67.7\%} & \textbf{68.8\%} & \textbf{69.1\%} & \textbf{69.1\%} &\textbf{68.9\%}& \textbf{68.3\%} & 67.2\% \\ \bottomrule
\end{tabular}
\end{table*}
\subsection{Training process}
{ \bf Detector }
The detector is trained with a blend of clean and attacked samples. For MNIST dataset, we have selected 1,000 clean samples and generated adversarial samples with the \ac{pgd} attack.
These 1,000 adversarial images with the associated 1,000 clean images are used for the training. The same process is carried-out for CIFAR-10 and Tiny-ImageNet datasets. The obtained features from each sample are provided as inputs to the \ac{svm} classifier. The Sigmoid kernel is used in the \ac{svm} model since it achieves a good accuracy for non-linear binary classification problems. \newline
{ \bf Denoiser } A separate \ac{cnn} model is trained to estimate the denoising parameters for each dataset. As described previously, the denoiser block deals only with attacked samples, based on that, we generated 10,000 samples with the \ac{pgd} attack. The three \ac{cnn} architectures for MNIST, CIFAR-10 and Tiny-ImageNet datasets are shown in Figures \ref{fig:fig5a}, \ref{fig:fig5b} and \ref{fig:fig5c}, respectively. We used the \ac{relu} as an activation function after each convolution layer. Some dropout layers are added to networks of color image datasets, i.e, CIFAR-10 and Tiny-ImageNet, with different rate to prevent over-fitting.
The \acp{cnn} of CIFAR-10 and Tiny-ImageNet datasets include batch normalization layers to stabilize and accelerate the learning process. We used for the three architectures a learning rate of 0.01 and a large momentum of 0.9. Finally, the architectures are trained using 64 epochs with a batch-size of 128 for MNIST and CIFAR-10 datasets, while 128 epochs with a batch-size of 32 for Tiny-ImageNet dataset.
\subsection{Results and analysis}
The performance of the proposed defense method are evaluated under $l_{\infty}$ bounded attacks~\cite{madry2017towards,buckman2018thermometer,yang2019me,song2017pixeldefend}. We compare our method with three state-of-the-art defense techniques on the three considered datasets under black-box, gray-box and white-box attacks, as recommended in~\cite{carlini2019evaluating}. The chosen defense techniques include one of the best performing adversarial training defenses developed by Madry {\it et al.}~\cite{madry2017towards} and two prepossessing methods including Thermometer~\cite{buckman2018thermometer} and ME-Net~\cite{yang2019me}. Furthermore, we investigate the effectiveness of the proposed detector block to detect the \acp{ae}.
\subsubsection{Defense block performance}
The robustness of the proposed defense method is assessed against three attacks: \acf{fgsm}, \acf{pgd} and \acf{cw}. The \ac{cw} implementation~\cite{B16} provided by the authors is used, while the implementations of \ac{fgsm} and \ac{pgd} attacks are from the open-source {\it CleverHans} library~\cite{cleverhans}.
\newline
\textbf{Black-box attacks}
This kind of attack is performed to fool a classifier model when an attacker can not perform back propagation to generate adversarial samples from the network model. Based on this, we train substitute networks for MNIST, CIFAR-10 and Tiny-ImageNet datasets to generate \acp{ae} with \ac{fgsm}, \ac{pgd} and \ac{cw} attacks. We set the attacks hyper-parameters as in \cite{yang2019me}, where we use for MNIST a perturbation magnitude $\epsilon$ of $0.3$ for both \ac{fgsm} and \ac{pgd}. This latter is used with two iteration configurations: 40 and 100 steps. Regarding CIFAR-10 and Tiny-ImageNet datasets, the \ac{pgd} attack is used with a magnitude perturbation $\epsilon$ of $0.03$ and four iteration configurations: 7, 20, 40 and 100 steps.
For the \ac{cw} attack, we consider two different confidence values of $\kappa=20$ and $\kappa=50$.
\begin{table*}[t]
\centering
\renewcommand{\arraystretch}{1.2}
\caption{Performance of the proposed defense method under gray-box attacks.\label{tab:tab4}}
\begin{tabular}{l lcc cccc cc}
\toprule
\multicolumn{1}{l}{\multirow{2}{*}{\textbf{Dataset}}}&\multicolumn{1}{l}{\multirow{2}{*}{\textbf{Method}}} & \multicolumn{1}{c}{\multirow{2}{*}{\textbf{FGSM}}} & \multicolumn{4}{c}{\textbf{\acs{pgd}}} & \multicolumn{2}{c}{\textbf{CW}} \\
\cmidrule(lr){4-7}
\cmidrule(lr){8-9}
\multicolumn{1}{c}{} &\multicolumn{1}{c}{} & \multicolumn{1}{l}{} & \textbf{7 steps} & \textbf{20 steps}& \textbf{40 steps} & \textbf{100 steps} & \textbf{$\kappa=20$} & \textbf{$\kappa=50$} \\ \midrule
\multicolumn{1}{l}{\multirow{2}{*}{\rotatebox[origin=c]{0}{MNIST}}}&ME-Net \cite{yang2019me} &-&- &96.2\% &95.9\%& 95.3\%&{98.8\%}&\textbf{98.7\%}\\
& {Our method} & \textbf{97.4\%} & \textbf{99.4\%} & \textbf{99.3\%} & \textbf{99.3\%} & \textbf{99.3\%} & \textbf{99.1\%} & {98.5\%} \\ \bottomrule
\multicolumn{1}{l}{\multirow{2}{*}{\rotatebox[origin=c]{0}{CIFAR-10}}}&ME-Net \cite{yang2019me} &85.1\% & 84.9\% & 84.0\% &82.9\%&- & \textbf{84.0}\% & \textbf{77.1\%} \\
& {Our method} & \textbf{88.4\%} & \textbf{95.0\%} &\textbf{94.8\%}& \textbf{94.8\%} &\textbf{94.5\%}& 83.7\% & 75.8\% \\ \bottomrule
\multicolumn{1}{l}{\multirow{2}{*}{\rotatebox[origin=c]{0}{Tiny-ImageNet}}}&ME-Net \cite{yang2019me}
&{66.5\%} &64.0\%& 62.6\%& 59.2\%&-&{58.3\%}&{58.2\%}\\
&{Our method} &\textbf{67.7\%}&\textbf{69.0\%}&\textbf{68.9\%}&\textbf{68.9\%}&\textbf{68.5\%}&\textbf{61.2\%} &\textbf{60.1\%}\\ \bottomrule
\end{tabular}
\end{table*}
Table \ref{tab:tab3} gives the performance of our defense method compared to the selected defenses under black-box attacks on the three datasets. We can notice that the proposed defense achieves the highest accuracy performance on the three datasets, except against \ac{cw} attack under $\kappa=50$ on the two color datasets. Moreover, most defense techniques are robust against the considered attacks on MNIST dataset, except the Thermometer defense which achieved the lowest accuracy of 41.1\%. We can also note, in MNIST dataset, that Madry's defense performs better than ME-Net which obtained $92.8\%$ and $92.2\%$ accuracy against \ac{pgd} attack at 40 and 100 steps, respectively. This can be explained by the fact that the \ac{pgd} \acp{ae} were included in the training set of the Madry defense. However, the preprocessing conducted in the ME-Net allows this method to achieve relatively higher classification accuracy for \ac{cw} attack compared to Madry's method. This is particularly true for CIFAR-10 dataset where ME-Net outperforms Madry's defense for all attacks considered. Finally, it is clear that our defense outperforms the considered defenses, for instance, it obtained the highest accuracies of $97.6\%$ and $98.9\%$ against FGSM and CW ($\kappa=50$) attacks, respectively. In addition, the proposed method achieves a constant accuracy of $99.4\%$ against \ac{pgd} attack despite the change in the number of iterations.
\newline
\textbf{Gray-box attacks}
In this setting, an adversary has knowledge of the hyper-parameters of the classifier without any information on the defense technique.
This kind of attacks are much stronger than black-box attacks in reducing the robustness of the defense mechanism. Table~\ref{tab:tab4} compares the accuracy performance of the proposed defense against gray-box attacks with respect to ME-Net technique on the three datasets. We can first of all notice that the accuracy is lower compared to the black-box attacks. However, our defense method outperforms the ME-Net defense at all attacks, except against \ac{cw} attack where similar performance is reported.
\newline
\textbf{White-box attacks}
In white-box attacks, an adversary has a full access to all hyper-parameters of the classifier architecture and the defense technique. We assessed the robustness of our defense method against such strong attacks using the \acf{bpda} attack~\cite{athalye2018obfuscated}. The proposed defense technique consists of a preprocessing method which is independent from the classifier model as shown in Figure~\ref{fig:fig2}. This causes gradient masking for gradient-based attacks. In other words, on the backward pass the gradient of the preprocessing step is non-differentiable and therefore useless for gradient-based attacks. The \ac{bpda} approximates the gradient of non-differentiable blocks, which makes it useful for evaluating our defense technique against white-box attacks.
\begin{table*}[t!]
\centering
\renewcommand{\arraystretch}{1.2}
\caption{Performance of the proposed defense method against \ac{bpda}-based \ac{pgd} under white-box attack at up to 1000 steps on the three datasets.\label{tab:tab5}}
\begin{tabular}{l l c ccccc}
\toprule
\multicolumn{1}{l}{\multirow{2}{*}{\textbf{Dataset}}} &\multicolumn{1}{c}{\multirow{2}{*}{\textbf{Method}}} & \multicolumn{5}{c}{\textbf{Attack steps}}\\
\cmidrule(lr){3-7}
\multicolumn{1}{c}{}&\multicolumn{1}{c}{} & \textbf{7} & \textbf{20} & \textbf{40} & \textbf{100} & \textbf{1000} \\ \midrule
\multicolumn{1}{l}{\multirow{3}{*}{\rotatebox[origin=c]{0}{MNIST}}}& Madry \cite{madry2017towards}&-& -& 93.2\% & 91.8\% & 91.6\% \\
&ME-Net \cite{yang2019me} &-&-& 94.0\% & 91.8\% & 91.0\%\\
&{Our method}&-&-&\textbf{95.3\%}&\textbf{94.9\%} &\textbf{94.7\%}\\ \bottomrule
\multicolumn{1}{l}{\multirow{3}{*}{\rotatebox[origin=c]{0}{CIFAR-10}}}& Madry \cite{madry2017towards}& 50.0\% & 47.1\% & 47.0\% & 46.9\% & 46.8\% \\
&ME-Net \cite{yang2019me} & \textbf{74.1\%} & 61.6\% & 57.4\% & 55.9\% & 55.1\%\\
&{Our method}&{71.2\%}&\textbf{70.6\%}&\textbf{70.3\%}&\textbf{69.9\%} &\textbf{69.6\%}\\ \bottomrule
\multicolumn{1}{l}{\multirow{3}{*}{\rotatebox[origin=c]{0}{Tiny-ImageNet}}}& Madry \cite{madry2017towards}& 23.3\% & 22.4\% & 22.4\% & 22.3\% & 22.1\% \\
&ME-Net \cite{yang2019me} & \textbf{38.8\%} & 30.6\% & 29.4\% & 29.0\% &28.5\%\\
& {Our method}&36.0\%&\textbf{35.8\%}&\textbf{35.7\%}&\textbf{35.2\%} &\textbf{34.8\%}\\ \bottomrule
\end{tabular}
\end{table*}
Thereby, we approximate the denoiser block with the identity function $g(x) = x$, which is often effective as reported in~\cite{tramer2020adaptive}. This approach enables to approximate the true gradient and thus to bypass the defense, which allows using a standard gradient-based attack based on \ac{bpda}. Similar to \cite{yang2019me}, we selected the \ac{bpda}-based \ac{pgd} attack to assess the efficiency of our method. Table~\ref{tab:tab5} gives the accuracy performance on the three datasets for different steps of the \ac{bpda}-based \ac{pgd} attack. We can notice that our defense outperforms Madry and ME-Net defense techniques on MNIST dataset. On CIFAR-10 and Tiny-ImageNet\linebreak datasets, the accuracy scores of our defense technique are higher than those of Madry and ME-Net defenses, except in the 7 iterations configuration. At this configuration, ME-Net defense outperforms our solution by around 3\% benefiting mainly from its randomness operation. However, the ME-Net defense performance would be lower against the \ac{eot} technique that estimates the gradient of random components~\cite{athalye2018obfuscated}.
\begin{figure}[t!]
\centering
\includegraphics[scale=0.6]{fig_8_3_comp.pdf}
\caption{Visual illustration of MNIST images sorted from top to bottom as clean images, attacked images using \ac{bpda}-based \ac{pgd} under white-box attack at 1000 steps with \hbox{$\epsilon=0.3$}, and denoised images by the proposed defense method. The predicted class
label and its corresponding probability are provided for each image.}
\label{fig:fig6}
\end{figure}
\begin{figure}[t!]
\centering
\includegraphics[scale=0.63]{fig_9_3_comp.pdf}
\caption{Visual illustration of CIFAR-10 images sorted from top to bottom as clean images, attacked images using \ac{bpda}-based \acs{pgd} under white-box attack at 1000 steps with \hbox{$\epsilon=0.3$}, and denoised by the proposed defense method. The predicted class
label and its corresponding probability are provided for each image.}
\label{fig:fig7}
\end{figure}
\begin{figure*}[t!]
\centering
\includegraphics[scale=0.65]{fig_10_1_comp.pdf}
\caption{Visual illustration of Tiny-ImageNet images sorted from top to bottom as clean images, attacked images using \ac{bpda}-based \ac{pgd} under white-box attack at 1000 steps with $\epsilon=0.03$, and denoised images by the proposed defense method. The predicted class
label and its corresponding probability are provided for each image.}
\label{fig:fig8}
\end{figure*}
Figures \ref{fig:fig6}, \ref{fig:fig7} and \ref{fig:fig8} illustrate four images from MNIST, CIFAR-10 and Tiny-ImageNet datasets, respectively. These images are illustrated in three configurations: clean, attacked with \ac{bpda}-based \ac{pgd} attack and denoised with the proposed denoiser block. We can notice that the adversarial perturbations are filtered by the denoiser block, while a slight blur is introduced to the denoised images. However, through the use of CNN-guided BM3D, the filtering is performed so that the introduced blur does not affect the classification performance.
Furthermore, in order to assess the performance of our defense technique in the worst case scenario, we changed the \ac{pgd} attack hyper-parameters under a white-box attack to see how the proposed method behaves against these perturbations. Figure~\ref{fig:fig11} illustrates the classification accuracy of the proposed technique against \ac{bpda}-based \ac{pgd} attack at different steps and perturbation magnitudes $\epsilon$. These figures clearly demonstrate the robustness of the proposed defense method vis-à-vis the increasing in both the number of steps and the magnitude of perturbation. The accuracy of the proposed method slightly decreases when increasing the number of steps, while it remains robust regarding the magnitude increase. For MNIST dataset, the classifier performs very well even at high perturbation magnitudes, especially when $\epsilon>0.4$ which generates a very noisy image, making its classification difficult even by a human eye. Despite these hard conditions, our defense method achieves more than $86\%$ accuracy in the case of $\epsilon=0.5$ and $1000$ steps under white-box attack. For the color datasets, which are much more challenging to defend, our technique allows to increase the classification accuracy by approximately more than $40\%$ and $25\%$ for CIFAR-10 and Tiny-ImageNet, respectively.
\begin{figure*}[h!]
\centering
\subfigure[MNIST, without defense]{\label{fig:fig11a}\includegraphics[width=0.3\textwidth]{fig11_a.pdf}}
\subfigure[CIFAR-10, without defense]{\label{fig:fig12a}\includegraphics[width=0.3\textwidth]{fig12_a.pdf}}
\subfigure[Tiny-ImageNet, without defense]{\label{fig:fig13a}\includegraphics[width=0.3\textwidth]{fig13_a.pdf}}
\subfigure[MNIST, with defense]{\label{fig:fig11b}\includegraphics[width=0.3\textwidth]{fig11_b.pdf}}
\subfigure[CIFAR-10, with defense]{\label{fig:fig12b}\includegraphics[width=0.3\textwidth]{fig12_b.pdf}}
\subfigure[Tiny-ImageNet, with defense]{\label{fig:fig13b}\includegraphics[width=0.3\textwidth]{fig13_b.pdf}}
\caption{Accuracy of the classifier against \ac{bpda}-based \ac{pgd} attack at three different steps for the three considered datasets.}
\label{fig:fig11}
\end{figure*}
\begin{figure*}[h!]
\centering
\subfigure[\ac{fgsm} attack]{\label{fig:fig14a}\includegraphics[width=0.3\textwidth]{fig14a.pdf}}
\subfigure[\acs{pgd} attack]{\label{fig:fig14b}\includegraphics[width=0.3\textwidth]{fig14b.pdf}}
\subfigure[\acs{cw} attack]{\label{fig:fig14c}\includegraphics[width=0.3\textwidth]{fig14c.pdf}}
\caption{ROC performance of the detector block against three attacks under white-box settings.}
\label{fig:fig14}
\end{figure*}
\subsubsection{Detector block performance}
The performance of the detector block is evaluated under the same conditions as the defense technique, while half of the images are benign and the other half are crafted using three white-box attacks including \ac{fgsm}, \ac{pgd} and \ac{cw}. Figure \ref{fig:fig14} summarizes the performance of our detector using \ac{roc} curves for different detection thresholds. The \ac{roc} curves are plotted with \ac{tpr} versus the \ac{fpr}. The area under the \ac{roc} curve (AUC) denotes the value measured by the entire two-dimensional area below the entire \ac{roc} curve. The higher the AUC, the better the model is to predict clean images as clean and \acp{ae} as attacked. In the evaluation of the detector, we only selected images that were successfully attacked, i.e., $f_\theta(x^\prime) \neq f_\theta(x)$ , with their benign state. We reach an AUC of about over $0.9970$ for all datasets against the three used attacks, which is not far from an ideal detector.
Furthermore, Table \ref{tab:tab6} reports the detection accuracy against the three attacks under white-box settings, as well as the \ac{fp}, i.e, the detector classifies a benign input as an \ac{ae}. An efficient and robust detector must achieve high accuracy and at the same time a low \ac{fp}. Our detector achieves $100\%$ detection accuracy for all white-box attacks and considered datasets, except for Tiny-ImageNet dataset against the strongest iterative \ac{cw} attack, where an accuracy of $98\%$ is reported. The later is an acceptable score because it is associated with a very low \ac{fp} of $2.3\%$.
\begin{table}[t!]
\centering
\renewcommand{\arraystretch}{1.2}
\caption{Accuracy and \acs{fp} of the detector against three attacks under white-box settings.\label{tab:tab6}}
\begin{tabular}{lllll}
\hline
\multicolumn{1}{l}{\textbf{Dataset}}& \multicolumn{1}{c}{\textbf{\acs{fgsm}}} & \multicolumn{1}{c}{\textbf{\acs{pgd}}} & \multicolumn{1}{c}{\textbf{\acs{cw}}}& \multicolumn{1}{c}{\textbf{\acs{fp}}(\%)} \\ \hline
\multirow{1}{*}{\rotatebox[origin=c]{0}{MNIST}} &\multicolumn{1}{c}{100\%}
& \multicolumn{1}{c}{100\%}
& \multicolumn{1}{c}{100\%}
& \multicolumn{1}{c}{1.9\%} \\ \hline
\multirow{1}{*}{{CIFAR-10}}
&\multicolumn{1}{c}{100\%}
& \multicolumn{1}{c}{100\%}
&\multicolumn{1}{c}{100\%}
& \multicolumn{1}{c}{2.0\%} \\ \hline
\multirow{1}{*}{{Tiny-ImageNet}}
&\multicolumn{1}{c}{100\%}
&\multicolumn{1}{c}{100\%}
&\multicolumn{1}{c}{98\%}
&\multicolumn{1}{c}{2.3\%} \\ \hline
\end{tabular}
\end{table}
\section{Conclusion}
\label{sec:conclusion}
\label{sec5}
In this paper, we have proposed a novel two-stage framework to defend against \acp{ae} involving detection of \acp{ae} followed by denoising. The detector relies on \ac{nss} of the input image, which are altered by the presence of adversarial perturbations. The samples detected as malicious are then processed by the denoiser with an adaptive \ac{bm3d} filter to project them back into there original manifold. The parameters of the \ac{bm3d} filter used to process the attacked image are estimated by a \ac{cnn}.
The performance of the proposed defense method is extensively evaluated against black-box, grey-box and white-box attacks on three standard datasets. The experimental results showed the effectiveness of our defense method in improving the robustness of \acp{dnn} in the presence of \acp{ae}. Moreover, the efficiency of the detector with high detection accuracy and low \ac{fp} helps to preserve the classification accuracy of the \ac{dnn} model on clean images. \addcomment{As future work, we plan to extend the proposed defense method to deal with adversarial attacks in the physical world.}
\section*{Conflict of interest}
The authors declare that they have no conflict of interest.
\vspace{-5mm}
| {'timestamp': '2021-07-14T02:06:46', 'yymm': '2107', 'arxiv_id': '2107.05780', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05780'} | arxiv |
\section{Introduction}
Scholarly Knowledge graphs are knowledge bases for representing scholarly knowledge~\cite{Jaradeh2019}. Faceted search is a method that augments traditional search systems with a faceted exploration system, allowing users to narrow down search results by applying multiple filters based on the classification of the properties~\cite{Feddoul2019}. A faceted classification system lists each knowledge component along various dimensions, called facets, facilitating the classifications to be reached and managed in multiple forms.
Although faceted search is exceptionally beneficial for knowledge retrieval, search engines have not used it for the scholarly literature. Google Scholar is a well-known example: Despite its vast database, it has facets just on the date and, thus, limited support for refining queries. The next section briefly describes how implementing a faceted search over scholarly knowledge supports granular refinement of search queries.
\begin{figure*}[t]
\includegraphics[width=\textwidth]{Figures/facets.png}
\caption{UI overview of faceted search use-case on COVID-19 contributions comparison in the ORKG. \\* 1) Filter icons to select the value for the properties. 2) If a filter icon is clicked, a dialogue box like (3) would appear. 3) A selection prompt of candidate facets. 4) Currently activated filters on the comparison. 5) Linked value objects (i.e., papers) that link back to all interconnected properties shown in the table. }
\label{fig:ui}
\end{figure*}
\section{Approach}
We implemented our faceted search system on top of Open Research Knowledge Graph (ORKG) Comparisons. The ORKG\footnote{\url{https://gitlab.com/TIBHannover/orkg}} is an online service that represents research contributions (papers) in the form of an interconnected knowledge graph~\cite{Oelen2019Comparing} and enables the generation of tabular representations of contributions as comparisons, which is the main focus of our system.
The data about each paper is defined in properties that each one has a predefined template. These templates support the dynamic and automated construction of facets for ORKG comparisons. Facets work on different types of data throughout comparisons. For String properties (i.e., properties that have strings for values), a user can select one or more values among all. This is also supported by an auto-complete feature to help find candidate options. For numerical data, users may not only want to filter by a distinct value but also by a range. Hence, different operators can be selected for the filtering process, specifically greater or smaller than a specific amount. Furthermore, a user can exclude values. Similarly, operators can be applied for values of type date. In addition to including or excluding a date, a duration can be selected as a valid filtering criterion. A date picker is activated on date properties so a user can easily select the date on a calendar. For example, papers that used a special method of research and got special value(s) in a specific duration of a particular location and so on, can easily be discovered.
Our system is empowered by these dynamic facets, which are inferred automatically from the property type, and the facets that would be different for each comparison, in contrast to other search systems which use just a predefined set of static facets.
\autoref{fig:ui} depicts an example of the faceted search performed on a COVID-19 contribution comparison, which consists of 31 papers. When the filter icon is pressed, a dialogue box containing the relevant values for the property appears, thus enabling the user to choose some of the candidate values. When applying a filter, the colour of the filter icon is highlighted in red, and a tool-tip is displayed when hovering over the mentioned icon with the selected value(s). Additionally, all applied filters are indicated clearly on top of the table. The results are directly reflected on the screen.
Furthermore, the system provides the opportunity to save these configurations and the subset of retrieved data as a new comparison to the database, with a permanent URL that can be shared with other researchers and users. We provide a link to the system to enable independent testing and investigation.\footnote{ \url{https://www.orkg.org/orkg/comparisons}}
\section{Challenges}
What made the problem of faceted search challenging are the following points:
\begin{itemize}
\item Knowledge graphs are heterogeneous by nature. Different KGs have different structure. Thus, they are not compatible with a strict search system. Various schemas and APIs make the exploration of federated systems even harder.
\item Completeness matters. The more complete the database is, the more data would be discovered. Unfortunately, some well-structured systems suffer from a complete data source~\cite{heist2020knowledge}.
\item Specifically concerning the ORKG, each paper is related to one or more research fields. Therefore, Finding the appropriate facet according to the user’s search expression is challenging.
\end{itemize}
The code of the system is publicly available and documented on GitLab.\footnote{ \url{https://gitlab.com/TIBHannover/orkg/orkg-frontend}}
\section{Conclusion}
Nowadays, knowledge graphs are central to the successful exploitation of knowledge available in the growing amount of digital data on the Web. Such technologies are essential to upgrade search systems from a keyword match to knowledge retrieval, which is vital for achieving the most relevant answer to a query, especially also in research. Despite remarkable gains by search portals, full-text scholarly search engines have remained ineffective. In this project, we implemented a faceted search system over a scholarly knowledge graph. To ease information retrieval, facets adapt to content. The more the knowledge graph is implemented in details, the search results would be more fine-grained. In future work, we will federate knowledge graphs to further improve dynamic faceted search. For instance, we intend to use GeoNames\footnote{\url{https://www.geonames.org/}} to enable spatial filtering on scholarly knowledge.
\begin{acks}
This work was funded by the Leibniz University of Hannover. The authors would like to thank Allard Oelen, Mohamad Yaser Jaradeh, and Kheir Eddine Farfar for helpful comments.
\end{acks}
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2021-07-14T02:04:47', 'yymm': '2107', 'arxiv_id': '2107.05738', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05738'} | arxiv |
\section{Introduction}
Intelligence is an emergent phenomenon that requires nothing more than the presence of matter and energy, the physical constraints of our present universe, and time. At the very least we know that the preceding statement is true by an existence proof, one that continues to demonstrate itself in the very act of the reader parsing it. There may be simpler ways to generate intelligence, and there are certainly paths to intelligence that are significantly more complex, but the only path that we have positive proof for so far is the evolution of life by natural selection. Put simply, an algorithm that can be described as ``the most likely things to persist will become more likely to persist" is at least capable of creating intelligence --- though the likelihood of this happening is unknown and shrouded in uncertainty \cite{kipping2020} \footnote{While I've often read that human existence is the result of a ``a single run" of an open-ended process \cite{stanley2019}, we have no way to no for certain how many similar ``runs" may have preceded (or will succeed) the experience of our own perspective. This is the anthropic principle in a nutshell \cite{carter1974}}. Consequently the study of intelligence, both natural and artificial, from a viewpoint informed by open-ended complexity is not only an alternative approach to building artificially intelligent systems, but a way to better understand the context of Earth-based intelligence as it fits into the larger universe.
One hallmark of modern approaches to artificial intelligence (AI), particularly in a reinforcement learning framework, is the ability of learning agents to exploit unintended loopholes in the way a task is specified \cite{amodei2016}. Known as specification gaming or reward hacking, this tendency constitutes the crux of the control problem and places an additional engineering burden of designing an ``un-hackable" reward function, the substantial effort of which may defeat the benefits of end-to-end learning \cite{singh2019}. An attractive alternative to manually specifying robust and un-exploitable rewards is to instead develop methods for intrinsic or learned rewards \cite{burda2018}. For tasks requiring complex exploration such as the ``RL-hard" Atari games Montezuma's Revenge and Pitfall, intrinsic exploration-driven reward systems are often necessary \cite{ecoffet2019}.
Games have a long history as a testing and demonstration ground for artificial intelligence. From MENACE, a statistical learning tic-tac-toe engine from the early 1960s \cite{gardner1962}, to the world champion level chess play of Deep Blue \cite{tan1995} and the lesser known Chinook's prowess at checkers \cite{schaeffer2007} in the 1990s, to the more recent demonstrations of the AlphaGo lineage \cite{silver2016, silver2017, silver2018, schrittwieser2020} and video game players like AlphaStar for StarCraft II \cite{vinyals2019} and OpenAI Five for Dota 2 \cite{berner2019} to name just a few. Games in general provide an opportunity to develop and demonstrate expert intellectual prowess, and consequently have long been an attractive challenge for AI. While impressive, even mastering several difficult games is but a small sliver of commonplace human and animal intelligence. The following statement may be debatable to some, but mastering the game of Go is not even the most interesting demonstration of intelligence one can accomplish with a Go board.
While taking breaks from more serious mathematical work, John H. Conway developed his Game of Life by playing with stones on a game board \cite{gardner1970}. The resulting Game demonstrated a system of simple rules that would later be proven to be computationally universal. Conway's Life did not found the field of cellular automata (CA), but it did motivate subsequent generations of research and play and is likely the most well known example of CA.
\section{Life-like cellular automata crash-course}
The Game of Life was invented by John H. Conway through mathematical play in the late 1960s, and it was introduced to the public in a column in Martin Gardner's ``Mathematical Games" in Scientific American in 1970 \cite{gardner1970}. The Game was immensely influential and inspired subsequent works in similar systems and cellular automata in general. Conway's Life demonstrated the emergence of complex behavior from simple rules and would later be proven a Turing complete system capable of universal computation \cite{rendell2014}.
\begin{figure}[tb]
\centerline{\includegraphics[scale=0.3]{moore_neighborhood.png}}
\caption{A Moore neighborhood in purple surrounding a cell in pink. }
\label{fig:moore}
\end{figure}
Conway's Life is based on the changing binary states of a 2-dimensional grid. Cell units in the grid change their state based on local information, determined solely by the sum of states of their immediate neighbors. The 3 by 3 grid surrounding each cell (excluding itself) is called a Moore neighborhood (Figure \ref{fig:moore}). Each cell's next state is fully determined by its current state and the sum of cell states in its Moore neighborhood. Cellular Automata (CA) based on this update configuration are known as ``Life-like". Different Life-like CA can be described by the rules they follow for transitioning from a state of 0 to a state of 1 (``birth") and maintaining a state of 1 (``survival"). Life-like rules can be written in a standard string format, with birth conditions specified by numbers preceded by the letter ``B" and survival conditions by numbers preceded by ``S", and birth and survival conditions separated by a slash. For example, the rules for Conway's Life are B3/S23, specifying the dead cells with 3 live neighbors become alive (state 1) and live cells with 2 or 3 live neighbors remain alive, all other cells will remain or transition to a dead state (state 0).
Including Conway's Life (B3/S23), there are $2^9 * 2^9 = 262,144$ possible rule variations in Life-like CA. Many of these rules support objects reminiscent of machine or biological entities in their behavior. Types of CA objects of particular interest include spaceships, objects that translocate across the CA grid as they repeat several states; puffers, spaceships that leave a path of persistent debris behind them, computational components like logic gates and memory, and many more. The update progression of a glider pattern under B368/S245 rules, also known as Morley or Move, is shown in Figure \ref{fig:morley0}. An active community continues to build new patterns and demonstrations of universal computation in Life-like CA \cite{conwaylifeforum}.
\begin{figure}[tb]
\centerline{\includegraphics[scale=0.25]{morley_glider_0.png}}
\centerline{\includegraphics[scale=0.25]{morley_glider_1.png}}
\centerline{\includegraphics[scale=0.25]{morley_glider_2.png}}
\caption{The first 2 updates of a glider pattern in the B368/S245 set of rules. The Moore neighborhood values are inset in each cell, with birth and survival denoted in purple and ``death" transitions denoted in pinkish yellow. Cells with a starting state of 0 and 3, 6, or 8 neighbors transition to a state of 1, while cells with a state of 1 with 2, 4, or 5 neighbors remain in a state of 1. All other cells transition to a state of 0.}
\label{fig:morley0}
\end{figure}
\section{Related Work}
Carle's Game combines the fields of cellular automata, open-ended machine learning, and evolutionary computation. The growth and dynamics of cellular automata have been extensively studied \cite{wolfram1983, schiff2005, eppstein2010, wolfram1984}, and thanks to the characteristics of complexity and universal computation of many CA \cite{wolfram1984, cook2004, conwaylifeforum}, CA make a good substrate for modeling physical phenomena \cite{toffoli1987}. Recent work in differentiable neural CA offer interesting possibilities for modern machine learning \cite{mordvintsev2020, randazzo2020, niklasson2021, randazzo2021}.
Open-endedness is often a desirable trait in artificial life and evolution simulations. Evolutionary computation applied to generic reinforcement learning (RL) tasks exhibits the same phenomena of specification gaming and reward hacking as seen in conventional RL algorithms. For example, with no costs associated with individual height, evolutionary selection for body plans and policies on the basis of forward travel often discovers the unintended solution of being very tall and falling over \cite{ha2019, sims1994a, sims1994c, lehman2020}. A more open-ended approach can limit the reward function surface that can be exploited, at least in principle, but the challenge of producing interesting results remains substantial. A system can apparently meet all the generally accepted traits of open-ended evolution and still produce uninteresting results \cite{hintze2019}.
Previous efforts to build artificial worlds include individual machine code programs competing for computational resources \cite{ray1991, ofria2005}, simulated creatures in physics simulators \cite{sims1994a} \cite{sims1994c} \cite{yaeger1997} \cite{spector2007}, games \cite{grbic2020, channon1997, suarez2019, soros2017}, or abstract worlds \cite{soros2014}. I find the open-ended universes based on cellular automata such as SmoothLife, Lenia, and genelife \cite{rafler2011, chan2019, mccaskill2019} particulary interesting. CA simulations are an attractive substrate for open-ended environments because they are not based on a facsimile of the physics of our own universe, nor are they an ad-hoc or abstract landscape. Instead they have their own internally consistent rules, analagous to physical laws in myriad alternative universes.
Unlike experiments in Lenia, SmoothLife, or genelife, in Carle's Game agents interact with a CA universe, but they are not of it. Instead the role of agents is more similar to that of the decades-long exploration of Life-like cellular automata by human experimenters. CARLE also has the ability to simulate any of the 262,144 possible Life-like rules, of which many exhibit interest patterns of growth and decay and/or Turing completeness \cite{eppstein2010, conwaylifeforum}.
Another possible advantage of CARLE comes from the simplicity of CA universes combined with execution on a graphics processing unit (GPU). CARLE is written with PyTorch \cite{paszke2019}, and the implementation of CA rules in the matrix multiplication and convolutional operations, operations that have been well-optimized in modern deep learning frameworks, makes hardware acceleration straightforward. Although CARLE does not take advantage of CA-specific speedup strategies like the HashLife algorithm \cite{gosper1984}, it uses vectorization and GPU acceleration to achieve in excess of 20,000 updates of a 64 by 64 cell grid per second. Combined with the expressiveness and versatility of Life-like cellular automata, it is my hope that these characteristics will make CARLE an enabling addition to available programs for investigating machine creativity and exploration.
\section{Carle's Game and the Cellular Automata Reinforcement Learning Environment}
\subsection{What's Included}
Carle's Game is built on top of CARLE, a flexible simulator for Life-like cellular automata written in Python \cite{vanrossum2009} with Numpy \cite{harris2020} and PyTorch. As CARLE is formulated as a reinforcement learning environment, it returns an observation consisting of the on/off state of the entire CA grid at each time step, and accepts actions that specify which cells to toggle before applying the next Life-like rule updates. The action space is a subset of the observation space and the (square) dimensions of both can be user-specified, with default values of an observation space of 128 by 128 cells and an action space of 64 by 64 cells. Although both are naturally 2D, they are represented as 4-dimensional matrices (PyTorch Tensors), {\itshape i.e.} with dimensions $Nx1xHxW$, or number of CA grids by 1 by height by width. If CARLE receives an action specifying every cell in the action space to be toggled, the environment is reset and all live cells are cleared. In addition to the CA simulation environment, CARLE with Carle's Game includes:
\begin{itemize}
\item{ {\bfseries Reward Wrappers: Growth, Mobiliy, and Exploration Bonuses.} CARLE always returns a reward of 0.0, but several reward wrappers are provided as part of CARLE and Carle's Game to provide motivation for agents to explore and create interesting patterns. Implemented reward wrappers include autoencoder loss and random network distillation exploration bonuses \cite{burda2018}, a glider/spaceship detector, and a reward for occupying specific regions of the CA universe. }
\item{ {\bfseries Starter Agents: HARLI, CARLA, and Toggle.} I have included several agent policies as a starting point for developing innovative new policies. These shouldn't be expected to be ideal architectures and experimenters are encouraged to explore. Starter agents include Cellular Automata Reinforcement Learning Agent (CARLA), a policy based on continuous-valued cellular automata rules, and HARLI (Hebbian Automata Reinforcement Learning Improviser), a policy again implemented in continuous-valued neural CA that learns to learn by optimizing a set of Hebbian plasticity rules. Finally, Toggle is an agent policy that optimizes a set of actions directly, which are only applied at the first step of simulation.}
\item{ {\bfseries Starter Algorithm: Covariance Matrix Adapataion Evolution Strategy (CMA-ES).} Carle's Game includes an implementation of CMA-ES \cite{hansen2016} for optimizing agent policies.}
\item{ {\bfseries Human-Directed Evolution.} In addition to reward wrappers that can be applied to CARLE, Carle's Game includes interactive evolution (implemented in a Jupyter notebook) to optimize agent policies with respect to human preferences.}
\end{itemize}
\subsection{Performance}
CARLE utilizes a combination of environment vectorization and GPU acceleration to achieve fast run times. On a consumer desktop with a 24-core processor (AMD 3960x Threadripper) and an Nvidia GTX 1060 GPU, CARLE runs at a speed of more than 22,000 updates per second of a 64 by 64 grid running Game of Life (B3/S23), amounting to about 90 million cell updates per second. Additional performance gains are likely available with lower precision operations with modern (RTX) GPU acceleration. To assess CARLE performance on other systems, I've provided the Jupyter notebook I used to create Figures \ref{fig:cpu_performance} and \ref{fig:cuda_performance}, available at \url{https://github.com/rivesunder/carles_game}
\begin{figure}[tb]
\centerline{\includegraphics[scale=0.25]{cpu_updates_performance.png}}
\caption{CARLE performance running on a 24-core CPU, measured in CA grid updates per second.}
\label{fig:cpu_performance}
\end{figure}
\begin{figure}[tb]
\centerline{\includegraphics[scale=0.25]{cuda_updates_performance.png}}
\caption{CARLE performance running with device set to an Nvidida GTX 1060 GPU, measured in CA grid updates per second.}
\label{fig:cuda_performance}
\end{figure}
\subsection{Reward Wrappers}
The reward hypothesis, also sometimes known as the reinforcement learning hypothesis, has a somewhat ambiguous attribution \cite{suttonreward, littmanreward}, but no matter who described the idea first it can be summarized as follows: intelligent behavior arises from an agent seeking to maximize the rewards it receives from its environment, or at least an agent's goals can be fully described as an effort to maximize cumulative rewards. Whether this is reflective of real-world intelligence is a discussion for another time, but it does mean that open-ended environments returning no nominal reward are a challenge for most RL algorithms.
While CARLE is formulated as a reinforcement learning environment and uses the \texttt{observation, reward, done, info = env.step(action)} Gym API \cite{brockman2016}, the environment always returns a reward value of 0.0. Ultimately Carle's Game uses crowd-sourced voting to evaluate user submissions, and judging machine creativity and exploration is likely to be just as subjective as judging the creative outputs of human artists and explorers. Designing a system of derived rewards, ideally in such a way as to instill an internal sense of reward for exploration, is a principal aspect of the Carle's Game challenge. I have included several examples of potential reward wrappers that intervene between the universe of CARLE and agents interacting with it to add rewards for agents to learn from. These may be used directly and in combination to generate reward proxies or serve as a template and inspiration for custom reward wrappers.
Carle's Game includes two implementation of exploration bonus rewards, one based on autoencoder loss and the other on random network distillation \cite{burda2018}. It also includes wrappers designed to reward moving machines such as spaceships and gliders and another that grants a reward for occupying specific cells in the top left corner. The corner bonus wrapper (Figure \ref{fig:cornerbonus} yields negative reward for live cells in the right hand corners and a positive reward for live cells in top left corner, and along the diagonal of the grid universe between the action space and the top left corner. The speed reward wrapper calculates the change between the center of mass of all live cells between time steps, and while machine exploration and crowd evaluation of submissions are open-ended and subjective, developing agents that can re-discover known patterns-of-interest like spaceships and gliders provides an attractive first step that parallels early human exploration of Conway's Life.
\begin{figure}[tb]
\centerline{\includegraphics[scale=0.2]{speeddetector_reward_0.png}}
\caption{Center of mass speed reward applied to a Game of Life glider. This reward wrapper ignores the cells in the action area (tinged in blue) when calculating the center of mass, resulting in a large reward spike when live cells first escape the action space, readily apparent in the reward curve. In this example, a Game of Life glider travels across the CA grid. After the glider exits the action space, the reward oscillates around the average speed of the object, reflecting the periodic diagonal motion of the glider.}
\label{fig:speeddetector}
\end{figure}
An example of the speed-based reward wrapper applied to a Life glider is shown in Figure \ref{fig:speeddetector}. This reward system considers cells inside of the action space to all have a central location of (0,0), leading to a large reward spike when an object first leaves the area available to agent manipulation. As CARLE simulates a toroidal CA universe, another reward spike occurs (not shown in Figure \ref{fig:speeddetector}) when an object leaves by one edge and returns by another. This boundary crossing advantage was exploited by agents in experiments described in section \ref{exp}.
\begin{figure}[tb]
\centerline{\includegraphics[scale=0.2]{fig_67_rnd_ae_reward.png}}
\caption{Exploration rewards based on random network distillation and autoencoder loss. In random network distillation, a prediction model attemps to learn the input-output mapping of a random network, while autoencoder reward is based on the autoencoder loss of reconstructing environment observations directly. Snapshots of the progression of a puffer object are displayed with a color map corresponding to the color of the corresponding step in the reward curves, lighter coloration indicates later time steps. Note the different scales for random network distillation and autoencoder based rewards. Unlike the autoencoder loss reward, the implementation of random network distillation in Carle's Game includes a fully-connected neural network layer at the output, allowing the reward system to be ``surprised" and generate higher reward when the puffer disappears of the edge of the of the CA grid and re-appears on the opposite side.}
\label{fig:rnd}
\end{figure}
Autoencoder loss and random network distillation approximate the novelty of a set of observations, as states that are visited less frequently lead to relatively poor performance compared to observations often encountered \cite{burda2018}. These offer slightly different behavior in practice. The autoencoder loss reward wrapper is implemented with a fully convolutional neural network model, and therefore exhibits translation equivariance in its response. Therefore the exploration bonus for a given pattern can be expected to be the same regardless of where on the CA grid the pattern appears. The implementation of random network distillation included with CARLE, on the other hand, includes fully connected neural networks in the final layers of both the random and the prediction network. The fully connected layers do not exhibit the translation equivariance of convolutional layers, so a jump in reward occurs when the Morley puffer leaves via one edge and appears on the opposite side of the grid, visible in Figure \ref{fig:rnd}. Both examples are demonstrated for the same progression of a common puffer in the Morley/move rule set (B368/S245).
\begin{figure}[tb]
\centerline{\includegraphics[scale=0.2]{cornerbonus_reward_0.png}}
\caption{A manually designed growth pattern that yields a positive cumulative reward from the CornerBonus wrapper (B3/S012345678 rules). The areas tinged in red generate a -1.0 reward for each live cell, the area tinged in purple returns a +1.0 reward for every live cell, and the area tinged in blue represents the action space.}
\label{fig:cornerbonus}
\end{figure}
\section{Carle's Game Baselines}
\begin{figure}[tb]
\centerline{\includegraphics[scale=0.2]{cornerbonus_toggle_training.png}}
\caption{}
\label{fig:corneragent}
\end{figure}
\subsection{Carle's Game Baselines: Discovering the Morley Glider, Corner-Seeking, and Hacking the Mobility Reward}
This section briefly presents CMA-ES training of agents using the corner bonus or a combination of the speed and random network distillation reward wrappers.
\subsubsection{Reaching for the Corner}
The first experiment used CMA-ES \cite{hansen2016} to optimize patterns directly using the ``Toggle" agent. The training curves are shown for 5 random seeds in Figure \ref{fig:corneragent}. Of the 5 random seeds, 4 experimental runs found a pattern that achieves a positive cumulative reward, {\itshape i.e.} a pattern that for the most part avoids the negative reward corners and occupies at least some of the positive reward cells. This experiment used the B3/S245678 growth set of rules, and an example of a manually designed pattern achieving positive cumulative reward on this task is shown in Figure \ref{fig:cornerbonus}.
\subsubsection{Rediscovering Gliders}
\label{exp}
A second experiment used the combination of random network distillation and a reward based on changing center of mass. This experiment was intended to investigate the ability of agents to learn to create gliders and small spaceships. Patterns were evolved directly using the Toggle agent, as well as dynamic agents CARLA and HARLI. This experiment was conducted using B368/S245 rules.
Experiments involving the Toggle agent managed to discover several patterns that produce gliders. It's worth noting that in preliminary experiments optimizing the Toggle agent with the speed bonus directly, evolution runs with small population sizes and no exploration bonuses often got stuck in local optima and failed to find mobile patterns. Figure \ref{fig:toggle_glider} demonstrates the discovery of a pattern that produces a glider, and another that produces a puffer.
\begin{figure}[tb]
\centerline{\includegraphics[scale=0.3]{toggle_glider_inset.png}}
\centerline{\includegraphics[scale=0.3]{toggle_puffer_inset.png}}
\caption{Patterns discovered by CMA-ES optimization of the Toggle agent. a) Pattern that produces a glider. b) Pattern that produces a puffer. The evolved patterns are shown inset in red.}
\label{fig:toggle_glider}
\end{figure}
\begin{figure}[tb]
\centerline{\includegraphics[scale=0.2]{carla_wave.png}}
\centerline{\includegraphics[scale=0.2]{carla_chaotic_border.png}}
\caption{Speed + RND reward strategies employed by CA-based agents CARLA and HARLI (CARLA examples shown here). a) Wave strategy: activating a line of cells at the action space boundaries creates a wave moving away from the action area, exploiting the center of mass calculations that consider all cells within the action space to be at $(0,0)$ b Chaotic boundary strategy: by continuously activating cells near the boundary, live cells continuously appear and disappear just outside of the action. So long as the live cells don't perfectly balance each other out, this results in a changing center of mass and a continuous stream of small rewards. Unlike the Toggle agent, CARLA and HARLI are dynamic and can continuously perturb the action space, and are not constrained to learn to produce a persistent mobile pattern. }
\label{fig:carla_glider}
\end{figure}
Perhaps unsurprisingly, the active agents trained in the speed reward experiment found surprising and unintended strategies to generate high rewards. The three strategies include resetting the environment, generating a ``wave", or maintaining a ``chaotic boundary". The reset strategy generates a high reward by clearing all live cells from the CA grid, effectively moving their center of mass from some finite value to the center of the grid. The wave strategy is often seen in the first few steps, and takes advantage of the ``B3" rule contribution to produce a moving line of live cells visible in Figure \ref{fig:carla_glider}a. The chaotic boundary strategy takes advantage of the jump in reward produced when live cells transiently appear just outside of the action space.
\begin{figure}[tb]
\centerline{\includegraphics[scale=0.3]{harli_reset_wave_exploit_reward_annotated.png}}
\caption{The HARLI agent continuously modifies its parameters according to Hebbian rules with evolved weights. Crucial time points related to the environment reset strategy are called out with black arrows. Subsequent steps use the chaotic boundary strategy for a continuous stream of small rewards.}
\label{fig:harli_exploit}
\end{figure}
While HARLI and CARLA agents both exploit similar wave and chaotic boundary strategies, HARLI also is capable of resetting the environnment by setting all toggles to 1. The reset and wave strategy used together generate extremely high average rewards that may be 10 times greater than a common Life glider. An interactive demonstration of the reset-wave strategy at several evolutionary snapshots (trained with 4 different B3/Sxxx rules) can be found at \url{https://github.com/riveSunder/harli_learning}, and an example of this strategy under B368/S245 rules is presented in the reward plot in Figure \ref{fig:harli_exploit}.
\section{Concluding Remarks}
As introduced in this paper, CARLE along with Carle's Game provides a fast and flexible framework for investigating machine creativity in open-ended environments. Optimizing initial patterns directly using the Toggle policy managed to re-discover both the glider and the common puffer in the B368/S245 Morley/Move rules. We also discussed two agents based on continuous-valued CA policies, which both managed to find effective (and frustratingly unintended) strategies for garnering rewards from a center of mass speed reward wrapper. These unintended strategies, which can be described as reward hacking exploits, underscore the challenge of providing motivation to machine learning agents in the face of complexity.
The environment CARLE is available at \url{https://github.com/rivesunder/carle} and the Carle's Game challenge, including the code used to produce the experiments and figures described in this article, is maintained at \url{https://github.com/rivesunder/carles_game}. I intend to actively maintain these projects at least until the IEEE Conference on Games in August 2021, where Carle's Game is among the competition tracks \cite{ieeecog}, and the code is permissively licensed under the MIT License.
| {'timestamp': '2021-07-14T02:06:54', 'yymm': '2107', 'arxiv_id': '2107.05786', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05786'} | arxiv |
\section{Introduction}
The contextual bandit is a sequential decision making problem that is widely deployed in practice across applications including health services \citep{TM17},
online advertisement \citep{li2010contextual,AbeBiermannLong2003}, and
recommendation systems \citep{ABC16}. At each
round, the learner observes a feature vector (or \emph{context}) and
an action set, then selects an action and receives a loss for the action selected. To facilitate generalization across contexts, the
learner has access to a family of policies (e.g., linear models or neural networks) that map contexts to actions. The objective of the learner is
to achieve cumulative loss close to that of the optimal policy in hindsight.
To develop efficient, general purpose algorithms, a common approach to contextual bandits is to reduce the problem to supervised learning primitives such as classification and regression
\citep{langford_epoch-greedy_2008,DHK11,A+12,AHK14,SyKrSch16,ABC16,LWA18}.
Recently, \citet{FR20} introduced \textup{\textsf{SquareCB}}\xspace, which provides the first optimal and efficient reduction from
$K$-armed contextual bandits to square loss regression, and can be applied whenever the learner has access to a well-specified model for the loss function (``realizability''). In light of this result, a natural question is whether this approach can be generalized beyond the realizable setting and, more ambitiously, whether we can shift from realizable to misspecified models \emph{without prior knowledge} of the amount of misspecification. A secondary question, which is relevant for practical applications, is whether the approach can be generalized to large or infinite action spaces. This is precisely the setting we study in the present paper, where the action set is large or infinite, but where the learner has a ``good'' feature representation available---that is, up to some {\em unknown} amount of misspecification.
Adequately handling misspecification has been a subject of intense recent interest even for the simple special case of linear contextual bandits. \citet{DKW19} questioned whether ``good'' is indeed enough, that is, whether we can learn efficiently even without realizability. \citet{LS19feature} gave a
positive answer to this question---provided the misspecification level
$\varepsilon$ is known in advance---and showed that the price of misspecification for linear contextual bandits scales as $\varepsilon\sqrt{d}T$, where $d$ is the dimension and $T$ is the time horizon. However, they left the adapting to unknown misspecification as an open question.
\paragraph{Our results.}
We provide an affirmative answer to all of the questions above.
We generalize \textup{\textsf{SquareCB}}\xspace to infinite action sets, and use this strategy to adapt to unknown misspecification by combining it with a \emph{bandit model selection} procedure akin to that of \citet{ALNS17}. Our algorithm is oracle-efficient, and adapts to misspecification efficiently and optimally whenever it has access to an online oracle for square loss regression. When specialized to linear contextual bandits, it resolves the question of \citet{LS19feature}.
On the technical side, a conceptual contribution of our work is to show that one can view the action selection scheme used by \textup{\textsf{SquareCB}}\xspace as an approximation to a log-barrier regularized optimization problem, which paves the way for a generalization to infinite action spaces. Another byproduct of our results is a generalization of the original
\textsf{CORRAL}\xspace algorithm \citep{ALNS17} for combining bandit algorithms, which is simple, flexible, and enjoys improved logarithmic factors.
\subsection{Related Work}
Contextual bandits are a well-studied problem, and misspecification in bandits and reinforcement learning has received much attention in recent years. Below we discuss a few results closely related to our own.
For linear bandits in $d$ dimensions, \citet{LS19feature} gave an algorithm with regret $\cO(d\sqrt{T} +\varepsilon\sqrt{d}T)$, and left adapting to unknown misspecification for changing action sets as an open problem. Concurrent work of \citet{PPARZLS20} addresses this problem for the special case where contexts and action sets are stochastic, and also leverages \textsf{CORRAL}\xspace-type aggregation of contextual bandit algorithms. Our results resolve this question in the general, fully adversarial setting.
\arxiv{
Within the literature general-purpose contextual bandit algorithms, our approach builds on a recent line of research that provides reductions to (online/offline) square loss regression \citep{foster2018practical,FR20,SX20,xu2020upper,foster2020instance}. In particular, our work builds on and provides a new perspective on the online regression reduction of \citet{FR20}.
The infinite-action setting we consider was introduced in \citet{FR20}, but algorithms were only given for the special case where the action set is the sphere; our work extends this to arbitrary action sets. Concurrent work of \citet{xu2020upper} gives a reduction to offline oracles that also accommodates infinite action sets. These results are not strictly comparable: An online oracle can always be converted to an offline oracle through online-to-batch conversion and hence is a stronger assumption, but when an online oracle \emph{is} available, our algorithm is more efficient. In addition, by working with online oracles, we support adversarially chosen contexts.
It bears mentioning that misspecification in contextual bandits can be formalized in many ways, some of which go beyond the setting we consider. One line of work reduces stochastic contextual bandits to oracles for cost-sensitive classification \citep{langford_epoch-greedy_2008,DHK11,A+12,AHK14}. These results are agnostic, meaning they make no assumption on the model, and in particular do not require realizability. However, in the presence of misspecification, this type of guarantee is somewhat different from what we provide here: rather than giving a bound on regret to the true optimal policy, these results give bounds on the regret to the best-in-class policy. Another line of work considers a model in which the feedback received
by the learning algorithm at each round may be arbitrarily corrupted
by an adaptive adversary \citep{seldin2014one,lmp18,gkt19,BKS20}. Typical results for
this setting incur additive error $\cO(C)$, where $C$ is the
total number of corrupted rounds. While this model was originally
considered in the context of non-contextual stochastic bandits, it has recently been
extended to Gaussian process bandit optimization, which is closely
related to the contextual bandit setting, though these results only
tolerate $C\leq\sqrt{T}$. While these results are complementary to our own, we mention in passing that our notion of misspecification satisfies
$\varepsilon\leq{}\sqrt{C/T}$, and hence our main theorem
(\pref{thm:main}) achieves additive error $\sqrt{CT}$ for this
corrupted setting (albeit, only with an oblivious adversary).
}
\neurips{
Within the literature general-purpose contextual bandit algorithms, our approach builds on a recent line of research that provides reductions to (online/offline) square loss regression \citep{foster2018practical,FR20,SX20,xu2020upper,foster2020instance}.
Besides the standard references on oracle-based agnostic contextual bandits (e.g., \cite{langford_epoch-greedy_2008,DHK11,A+12,AHK14}), $\epsilon$-misspecification is somewhat related to the recent stream of literature on bandits with adversarially-corrupted feedback~\cite{lmp18,gkt19,BKS20}. See the discussion in \ifsup Appendix \ref{sec:related_work}\else the supplementary material\fi.
}
\section{Problem Setting}
We consider the following contextual bandit protocol: At each round $t=1,\dots,T$, the learner first observes a context $x_t\in\cX$ and an action set $\cA_t\subseteq \cA$, where $\cA \subseteq \mathbb{R}^d$ is a compact action space; for simplicity, we assume throughout that $\cA = \{a \in \mathbb{R}^d \colon\norm{a}\leq 1\}$, but place no restriction on $\prn*{\cA_t}_{t=1}^{T}$. Given the context and action set, the learner chooses action $a_t\in\cA_t$, then observes a stochastic loss $\ell_t\in\brk{-1,+1}$ depending on the action selected. We assume that the sequence of context vectors $x_t$ and the associated sequence of action sets $\cA_t$ are generated by an oblivious adversary.
Let $\mu(a,x)\vcentcolon={}\En\brk*{\ell_t\mid{}x_t=x,a_t=a}$ denote the mean loss function, which we assume to be time-invariant, and which is unknown to the learner. We adopt a semi-parametric approach to modeling the losses, in which $\mu(a,x)$ is modelled as (approximately) linear in the action $a$, but can depend on the context $x$ arbitrarily \citep{FR20,xu2020upper,chernozhukov2019semi}. In particular, we assume the learner has access to a class of functions $\cF \subseteq{}\{f\colon \cX \rightarrow \mathbb{R}^d \}$ where for each $f\in\cF$, $\tri*{a,f(x)}$ is a prediction for the value of $\mu(a,x)$. In the well-specified/realizable setting, one typically assumes that there exists some $f^{\star}\in\cF$ such that $\mu(a,x)=\tri*{a,f^{\star}(x)}$. In this paper, we make no such assumption, but the performance of our algorithms will depend on how far this is from being true. In particular, we measure performance of the learner in terms of pseudoregret $\Reg$ against the best unconstrained policy:
\begin{align*}
\textstyle\Reg \vcentcolon= \mathbb{E}\brk*{\sum_{t=1}^T\mu(a_t,x_t)-\inf_{a\in\cA_t}\mu(a,x_t)}.
\end{align*}
Here, and throughout the paper, $\En\brk*{\cdot}$ denotes expectation with respect to both the randomized choices of the learner and the stochastic realization of the losses $\ell_t$.
This setup encompasses the finite-arm contextual bandit setting with $K$ arms by taking $\cA_t=\crl*{\mathbf{e}_1,\ldots,\mathbf{e}_K}$. Another important special case is the well-studied linear contextual bandit setting, where $\cF$ consists of constant vector-valued functions that do not depend on $\cX$. Specifically, for any $\Theta\subseteq\bbR^{d}$, take $\cF=\crl*{x\mapsto\theta\mid{}\theta\in\Theta}$. In this case, the prediction $\ip{a,f(x)}$ simplifies to $\ip{a,\theta}$, which a static linear function of the action. This special case recovers the most widely studied version of the linear contextual bandit problem \citep{AL99,Aue02,AST11,CLRS11,APS12,AG13,CG13}, as well as Gaussian process extensions \citep{skks10,KO11,DKC13,SGBK15}.
\subsection{Misspecification}
As mentioned above, contextual bandit algorithms based on modeling losses typically rely on the assumption of a \emph{well-specified model} (or, ``realizability''): That is, existence of a function $f^* \in \cF$ such that $\mu(a,x)=\ip{a,f^*(x)}$ for all $a \in \cA$ and $x \in \cX$ \citep{CLRS11,AST11,A+12,foster2018practical}. Since the assumption of \emph{exact} realizability does not typically hold in practice, a more recent line of work has begun to investigate algorithms for misspecified models.
In particular, \citet{CG13,GCG17,LS19feature,FR20,ZLKB20} consider a uniform $\epsilon$-misspecified setting in which
\begin{align}
\label{eq:old definition}
\textstyle\inf_{f\in \cF}\sup_{a \in \cA,x\in\cX}|\mu(a,x)-\ip{a,f(x)}| \leq \epsilon,
\end{align}
for some misspecification level $\epsilon >0$. Notably, \citet{LS19feature} show that for linear contextual bandits, regret must grow as $\Omega(d\sqrt{T}+\varepsilon\sqrt{d}T)$. Since $d\sqrt{T}$ is the optimal regret for a well-specified model, $\varepsilon\sqrt{d}T$ may be thought of as the price of misspecification.
We consider a weaker notion of misspecification. Given a sequence $S = (x_1,\cA_1), \ldots, (x_T,\cA_T)$ of context-action set pairs, we define the average misspecification level $\varepsilon_T(S)$ as
\begin{align}
\label{eq:eps definition}
%
%
\textstyle\varepsilon_T(S) \vcentcolon= \inf_{f\in\cF}\prn*{\frac{1}{T}\sum_{t=1}^{T}\sup_{a\in\cA_t}(\ip{a,f(x_t)}-\mu(a,x_t))^2}^{1/2}.
\end{align}
This quantity measures the misspecification level for the specific sequence $S$ at hand, and hence offers tighter guarantees than uniform misspecification. In particular, the uniform bound in \cref{eq:old definition} directly implies $\varepsilon_T(S)\leq\epsilon$ for all $S$ in \cref{eq:eps definition}, and $\varepsilon_T(S)=0$ whenever the model is well-specified.
We provide regret bounds that optimally adapt to $\varepsilon_T(S)$ for any given realization of the sequence $S$, with no prior knowledge of the misspecification level. The issue of adapting to unknown misspecification has not been addressed even for the stronger uniform notion \eqref{eq:old definition}. Indeed, previous efforts typically use prior knowledge of $\varepsilon$ to encourage conservative exploration when misspecification is large; see \citet[Appendix E]{LS19feature}, \citet[Section 5.1]{FR20}, \citet[Section 4.2]{CG13}, and \citet{ZLKB20} for examples. Naively adapting such schemes using, e.g., doubling tricks, presents difficulties because the quantities in \pref{eq:old definition} and \pref{eq:eps definition} do not appear to be estimable without knowledge of $\mu$.
\subsection{Regression Oracles}
Following \citet{FR20}, we assume access to an \emph{online regression oracle} $\mathsf{Alg}_{\mathrm{Sq}}$, which is simply an algorithm for sequential prediction with the square loss, using $\cF$ as a benchmark class. Concretely, the oracle operates under the following protocol. At each round $t \in [T]$, the algorithm receives a context $x_t \in \cX$, outputs a prediction $\hat y_t \in \mathbb{R}^d$ (in particular, we interpret $\ip{a,\hat y_t}$ as the predicted loss for action $a$), then observes an action $a_t\in\cA$ and loss $\ell_t\in\brk{-1,+1}$ and incurs error $(\ip{a_t,\hat y_t}-\ell_t)^2$. Formally, we make the following assumption.\footnote{As in \citet{FR20}, the \emph{square loss} itself does not play a crucial role, and can be replaced by any loss that is strongly convex with respect to the learner's predictions.}
\begin{assumption}
\label{ass:regression}
The regression oracle $\mathsf{Alg}_{\mathrm{Sq}}$ guarantees that for any (potentially adaptively chosen) sequence $\crl{(x_t,a_t,\ell_t)}_{t=1}^T$,
\begin{align*}
\textstyle\sum_{t=1}^T(\ip{a_t,\hat y_t}-\ell_t)^2 -\inf_{f\in\cF}\sum_{t=1}^{T}(\ip{a_t,f(x_t)}-\ell_t)^2 \leq \mathsf{Reg}_{\mathrm{Sq}}(T)\,,
\end{align*}
for some (non-data-dependent) function $\mathsf{Reg}_{\mathrm{Sq}}(T)$.
\end{assumption}
For the finite-action setting, this definition coincides with that of \citet{FR20}. To simplify the presentation of our results, we assume throughout the paper that $\mathsf{Reg}_{\mathrm{Sq}}(T)$ is a non-decreasing function of $T$.
While this type of oracle suffices for all of our results, our algorithms are stated more naturally in terms of a stronger notion of oracle that supports \emph{weighted} online regression. In this model, we follow the same protocol as in \pref{ass:regression}, except that at each time $t$, the regression oracle observes a weight $w_t\geq0$ at the same time as the context $x_t$, and the error incurred is given by $w_t\cdot(\tri{a_t,\hat{y}_t}-\ell_t)^{2}$. For technical reasons, we allow the oracle for this model to be randomized. We make the following assumption.
\begin{assumption}
\label{ass:weighted regression}
The weighted regression oracle $\mathsf{Alg}_{\mathrm{Sq}}$ guarantees that for any (potentially adaptively chosen) sequence $\crl{(w_t,x_t,a_t,\ell_t)}_{t=1}^T$,
\begin{align*}
\textstyle\mathbb{E}\left[\sum_{t=1}^Tw_t(\ip{a_t,\hat y_t}-\ell_t)^2 - \inf_{f\in\cF}\sum_{t=1}^{T}w_t(\ip{a_t,f(x_t)}-\ell_t)^2\right] \leq \mathbb{E}\brk[\big]{\max_{t\in[T]}w_t}\cdot\mathsf{Reg}_{\mathrm{Sq}}(T)\,,
\end{align*}
for some (non-data-dependent) function $\mathsf{Reg}_{\mathrm{Sq}}(T)$, where the expectation is taken with respect to the oracle's randomization.
\end{assumption}
We show in \ifsup \cref{app:oracles} (\pref{alg:oracle}) \else the supplementary material\fi that any unweighted regression oracle satisfying \cref{ass:regression} can be transformed into a randomized oracle for weighted regression that satisfies \cref{ass:weighted regression}, with no overhead in runtime. Hence, to simplify exposition, for the remainder of the paper we state our results in terms of weighted regression oracles satisfying \pref{ass:weighted regression}.
Online regression is a well-studied problem, and efficient algorithms are known for many standard function classes. One example, which is important for our applications, is the case where $\cF$ is linear.
\begin{example}[Linear Models]
\label{ex:ridge regression}
Suppose $\cF=\crl*{x\mapsto{}\theta\mid{}\theta\in\Theta}$, where $\Theta\subseteq\bbR^{d}$ is a convex set with $\nrm*{\theta}\leq{}1$. Then the online Newton step algorithm \citep{hazan2007logarithmic}
satisfies \cref{ass:regression} with $\mathsf{Reg}_{\mathrm{Sq}}(T) = \cO(d\log(T))$ and---via reduction \ifsup(\pref{alg:oracle})\fi---can be augmented to satisfy \cref{ass:weighted regression}.
\end{example}
Further examples include kernels \citep{VKMFC13}, generalized linear models \citep{KKSK11}, and standard nonparametric classes \citep{gaillard2015chaining}. We refer to \citet{FR20} for a more comprehensive discussion.
\paragraph{Additional notation.}
For a set $X$, we let $\Delta(X)$ denote the set of all probability distributions over $X$.
If $X$ is continuous, we restrict $\Delta(X)$ to distributions with \emph{countable} support.
We let $\nrm*{x}$ denote the euclidean norm for $x\in\bbR^{d}$. For any positive definite matrix $H\in\bbR^{d\times{}d}$, we denote the induced norm on $x \in \mathbb{R}^d$ by $\norm{x}^2_H=\ip{x,Hx}$. For functions
$f,g:X\to\bbR_{+}$, we write $f=\cO(g)$ if there exists some constant
$C>0$ such that $f(x)\leq{}Cg(x)$ for all $x\in{}X$. We write $f=\tilde{\cO}(g)$ if $f=\cO(g\max\crl*{1,\mathrm{polylog}(g)})$, and define $\tilde{\Omega}(\cdot)$ analogously.
For each $f\in\cF$, we let $\pi_f(\cdot,\cdot)$ denote the \emph{induced policy}, whose action at time $t$ is given by $\pi_f(x_t,\cA_t) \vcentcolon=\argmin_{a\in\cA_t}\ip{a,f(x_t)}$.
\section{Adapting to Misspecification: An Oracle-Efficient Algorithm}
\label{sec:main}
We now present our main result: an efficient reduction from contextual
bandits to online regression that adapts to unknown misspecification
$\varepsilon_T(S)$ and supports infinite action sets. Our main theorem is as
follows.
\begin{theorem}
\label{thm:main}
There exists an efficient reduction which, given access to a weighted regression oracle $\mathsf{Alg}_{\mathrm{Sq}}$
satisfying \pref{ass:weighted regression}, guarantees that for all sequences $S = (x_1,\cA_1),\ldots, (x_T,\cA_T)$,
\begin{align*}
\Reg = \cO\left(\sqrt{dT\mathsf{Reg}_{\mathrm{Sq}}(T) \log(T)}+ \epsilon_T(S)\sqrt{d}T\right).
\end{align*}
\end{theorem}
The algorithm has two main building blocks: First, we extend the reduction of
\citet{FR20} to infinite action sets via a new optimization-based
perspective and---in particular---show that the resulting algorithm has favorable
dependence on misspecification level when it is known in
advance. Then, we combine this reduction with a scheme that
aggregates multiple instances of the algorithm to adapt to unknown
misspecification. When the time required for a single query to
$\mathsf{Alg}_{\mathrm{Sq}}$ is $\cT_{\mathsf{Alg}_{\mathrm{Sq}}}$, the per-step runtime of our algorithm is $\tilde{\cO}\prn*{\cT_{\mathsf{Alg}_{\mathrm{Sq}}}+\abs{\cA_t}\cdot\mathrm{poly}(d)}$.
As an application, we solve an open problem
recently posed by \citet{LS19feature}: we exhibit an efficient
algorithm for infinite-action linear contextual bandits which
optimally adapts to unknown misspecification.
\begin{corollary}
\label{cor:main}
Let $\cF=\{x\mapsto{}\theta\mid\theta \in \mathbb{R}^d,\nrm{\theta} \leq 1\}$.
Then there exists an efficient algorithm that, for any sequence $S =
(x_1,\cA_1),\ldots, (x_T,\cA_T)$, satisfies
\begin{align*}
\Reg = \cO\left(d\sqrt{T}\log(T) + \epsilon_T(S)\sqrt{d}T\right).
\end{align*}
\end{corollary}
This result immediately follows from \cref{thm:main} by invoking the online
Newton step algorithm as the regression oracle, as in \pref{ex:ridge regression}.
Modulo logarithmic factors, this bound coincides with the one achieved
by \citet{LS19feature} for the simpler non-contextual linear bandit
problem, for which the authors present a matching lower bound.
The remainder of this section is dedicated to proving
\pref{thm:main}. The roadmap is as follows. First, we revisit the
reduction from $K$-armed contextual bandits to online regression by
\citet{FR20} and provide a new optimization-based perspective. This new viewpoint leads to a natural generalization from
the $K$-armed case to the infinite action case. We then provide an
aggregation-type procedure which combines multiple instances of this
algorithm to adapt to unknown misspecification, and finally put all
the pieces together to prove the main result. As an extension, we also
give a variant of the algorithm which enjoys improved bounds when the
action sets $\cA_t$ lie in low-dimensional subspaces of $\mathbb{R}^d$.
Going forward, we abbreviate
$\varepsilon_T(S)$ to $\varepsilon_T$ whenever the sequence $S$ is clear from context.
\subsection{Oracle Reductions with Finite Actions: An Optimization-Based Perspective}
\label{sec:k-armed}
A canonical special case of our setting is the finite-arm contextual
bandit problem, where
$\cA_t=\cK\vcentcolon=\{\mathbf{e}_1,\dots,\mathbf{e}_K\}$. For this setting,
\citet{FR20} proposed an efficient and optimal reduction called
\textup{\textsf{SquareCB}}\xspace, which is displayed in \cref{alg:dylan}. At each step,
the algorithm queries the oracle $\mathsf{Alg}_{\mathrm{Sq}}$ with the current context $x_t$ and
receives a loss predictor $\hat{\theta}_t\in\bbR^{K}$, where
$(\hat{\theta}_t)_i$ predicts the loss of action $i$. The algorithm then
samples an action using an \emph{inverse gap weighting} (IGW) scheme introduced by
\citet{AL99}.
\begin{wrapfigure}[11]{r}{6.7cm}
\vspace{-0.15cm}
\begin{algorithm}[H]
\caption{\textup{\textsf{SquareCB}}\xspace\\\citep{FR20}}
\label{alg:dylan}
\DontPrintSemicolon
\LinesNumberedHidden
\KwIn{Learning rate $\gamma$, horizon $T$.}
\KwInit{} Regression oracle $\mathsf{Alg}_{\mathrm{Sq}}$. \;
\For{$t= 1,\dots,T$}{
Receive context $x_t$.\;
Let $\hat\theta_t$ be the oracle's prediction for $x_t$.\;
Sample $I_t\sim \textsf{IGW}(\hat\theta_t,\gamma)$.\;
Play $a_t=\mathbf{e}_{I_t}$ and observe loss $\ell_t$.\;
Update $\mathsf{Alg}_{\mathrm{Sq}}$ with
$(x_t, a_t, \ell_t)$.
}
\end{algorithm}
\end{wrapfigure}
Specifically for parameter $\theta\in\bbR^{K}$ and learning
rate $\gamma>0$, we define $\textsf{IGW}(\theta,\gamma)$ as
the distribution $p\in\Delta(\brk*{K})$ obtained by first selecting
any $i^*\in\argmin_{i\in[K]}\theta_{i}$, then defining
\begin{align}
p_{i} = \begin{cases} \frac{1}{K+\gamma(\theta_{i} %
-\theta_{i^*})},&\mbox{ if }i\neq i^*,\\
1-\sum_{i'\neq i^*}p_{i},&\mbox{ otherwise.}
\end{cases}\label{eq:abe-long}
\end{align}
By choosing $\gamma\propto\sqrt{KT/(\mathsf{Reg}_{\mathrm{Sq}}(T)+\varepsilon_T)}$, one can
show that this algorithm
guarantees \[\Reg\leq\cO\prn*{\sqrt{KT\mathsf{Reg}_{\mathrm{Sq}}(T)}+\varepsilon_T\sqrt{K}T}.\] Since this
approach is the starting point for our results, it will be useful to sketch the
proof. For $p\in\Delta(\cA)$, let $H_p\vcentcolon=\mathbb{E}_{a\sim p}\brk{aa^\top}$
be the second moment matrix, and $\bar a_p \vcentcolon= \mathbb{E}_{a\sim p}[a]$ be the
mean action.
Let the sequence $S$ be fixed, and let $f^*\in\cF$ be any regression
function that attains the value of $\varepsilon_T(S)$ in \pref{eq:eps
definition}.\footnote{If the infimum is not obtained, it suffices to
apply the argument that follows with a limit sequence.} With $a^*_t
\vcentcolon=\pi_{f^*}(x_t,\cA_t)$ and $\theta^*_t\vcentcolon={}f^*(x_t)$, we have
\begin{align*}
&\textstyle\mathbb{E}\left[\sum_{t=1}^T\mu(a_t,x_t)-\inf_{a\in\cA_t}\mu(a,x_t)\right]\\&\leq \mathbb{E}\left[\sum_{t=1}^T\ip{a_t-a^*_t,\theta^*_t} \right] + 2 \varepsilon_T T\\
&\textstyle= \mathbb{E}\left[\sum_{t=1}^T\ip{\bar a_{p_t}-a^*_t,\theta^*} -\frac{\gamma}{4}\norm{\theta^*-\hat\theta_t}^2_{H_{p_t}} \right]+\mathbb{E}\left[\sum_{t=1}^T\frac{\gamma}{4}\norm{\theta^*-\hat\theta_t}^2_{H_{p_t}}\right] + 2 \varepsilon_T T\,.
\end{align*}
The first expectation term above is bounded by $\cO(KT/\gamma)$,
which is established by showing that $\textsf{IGW}(\hat{\theta},\gamma)$ is
an approximate solution to the per-round minimax problem
\neurips{\vspace{-0.5em}}
\begin{align}
\label{eq:minimax}
\min_{p\in\Delta(\cK)}\max_{\theta\in\mathbb{R}^K}\max_{a^*\in\cK}\ip{\bar a_p-a^*,\theta}-\frac{\gamma}{4}\norm{\hat\theta-\theta}^2_{H_p}\,,
\end{align}
with value $\cO(K/\gamma)$.
The second expectation term is bounded by
$\cO(\gamma\cdot(\mathsf{Reg}_{\mathrm{Sq}}(T)+\varepsilon_T{}T))$, which follows readily from the definition of the square loss regret
in \pref{ass:regression} (see the proof of \pref{thm:impreg} for
details). Choosing $\gamma$ to balance the terms leads to the result.
As a first step toward generalizing this result to infinite actions,
we propose a new distribution that \emph{exactly} solves the minimax
problem \eqref{eq:minimax}. This distribution is the solution to a
dual optimization problem based on \emph{log-barrier} regularization, and
provides a principled approach to deriving contextual bandit reductions.
\begin{lemma}
\label{lem:logbar opt}
For any $\theta\in\mathbb{R}^K$ and $\gamma >0$, the unique minimizer of \cref{eq:minimax} coincides with the unique minimizer of the $\textsf{log-barrier}(\theta,\gamma)$ optimization problem defined by
\begin{align}
\textstyle\label{eq:logbarrier_form}
\textsf{log-barrier}(\theta, \gamma) = \argmin_{p\in\Delta([K])}\crl[\bigg]{\langle p, \theta\rangle -\frac{1}{\gamma}\sum_{a\in[K]}\log(p_a)} = \left(\frac{1}{\lambda + \gamma\theta_{i} }\right)_{i=1}^K\,,
\end{align}
where $\lambda$ is the unique value that ensures that the weights on
the right-hand side above sum to one.
\end{lemma}
The $\textsf{IGW}$ distribution
is closely related to the $\textsf{log-barrier}$ distribution: Rather than finding
the optimal Lagrange multiplier $\lambda$ that solves the $\textsf{log-barrier}$
problem, the $\textsf{IGW}$ strategy simply plugs in $\lambda=K-\gamma\min_{i'}\theta_{i'}$, then shifts
weight to $p_{i^{\star}}$ to ensure the distribution is
normalized. Since the $\textsf{log-barrier}$ strategy solves the minimax problem
\pref{eq:minimax} exactly, plugging it into the results of
\citet{FR20} and \citet{SX20} in place of $\textsf{IGW}$ leads to slightly
improved constants. More importantly, this new perspective leads to a
principled way to extend these reductions to infinite actions.
\subsection{Moving to Infinite Action Sets: The Log-Determinant Barrier}
\label{sec:linear}
\begin{wrapfigure}[13]{r}{6.7cm}
\vspace{-0.1cm}
\begin{algorithm}[H]
\caption{\textup{\textsf{SquareCB.Lin}}\xspace}
\label{alg:logdet}
\DontPrintSemicolon
\LinesNumberedHidden
\KwIn{Learning rate $\gamma$, horizon $T$.}
\KwInit{} Regression oracle $\mathsf{Alg}_{\mathrm{Sq}}$. \;
\For{$t= 1,\dots,T$}{
Receive context $x_t$.\;
Let $\hat\theta_t$ be the oracle's prediction for $x_t$.\;
Play $a_t\sim \textsf{logdet-barrier}(\hat\theta_t,\gamma;\cA_t)$.\;
Observe loss $\ell_t$.\;
Update $\mathsf{Alg}_{\mathrm{Sq}}$ with
$(x_t, a_t, \ell_t)$.
}
\end{algorithm}
\vspace{-0.0in}
\end{wrapfigure}
To support infinite action sets, we replace the $\textsf{log-barrier}$
distribution with a generalization based on the log-determinant function.
In order to state the result, let $\dim(\cA)$ denote the dimension of the smallest affine linear subspace that contains $\cA$.
When $\dim(\cA)<d$, we adopt the convention that the determinant
function $\det(\cdot)$ takes
the product of only the first $\dim(\cA)$ eigenvalues of the matrix in
its argument.\footnote{This convention ensures that the solution to
the $\textsf{logdet-barrier}$ problem is well-defined.}
We define the $\textsf{logdet-barrier}$ distribution as follows.
\begin{definition}
For parameter $\theta \in \mathbb{R}^d$, action set $\cA\subset\mathbb{R}^d$, and
learning rate
$\gamma>0$, $\textsf{logdet-barrier}(\theta,\gamma;\cA)$ is defined as the set
of solutions to
\begin{align}
\textstyle\argmin_{p\in\Delta(\cA)} \crl*{\ip{\bar a_p,\theta} -\gamma^{-1} \log\det (H_p-\bar a_p\bar a^T_p)}\,.
\label{eq:logdet_barrier}
\end{align}
\end{definition}
In general, \pref{eq:logdet_barrier} does not admit a unique
solution; all of our results apply to \emph{any} minimizer. Our key
result is that the $\textsf{logdet-barrier}$ distribution also solves a minimax
problem analogous to that of \pref{eq:minimax}.
\begin{lemma}
\label{lem:logdet bound}
Any solution to $\textsf{logdet-barrier}(\hat{\theta},\gamma;\cA)$ satisfies
\begin{align}
\textstyle\max_{\theta\in\mathbb{R}^d}\max_{a^*\in\cA}\ip{\bar a_p-a^*,\theta} - \frac{\gamma}{4}\norm{\hat\theta-\theta}^2_{H_p}\leq \gamma^{-1}\dim(\cA).\label{eq:key_inequality}
\end{align}
\end{lemma}
By replacing the $\textsf{IGW}$ distribution with the $\textsf{logdet-barrier}$
distribution in \pref{alg:dylan}, we obtain an optimal reduction for
infinite action sets. This algorithm, which we call \squareCB.\textup{\textsf{Lin}}\xspace, is
displayed in \pref{alg:logdet}.
\begin{theorem}
\label{thm:infinite}
Given a regression oracle $\mathsf{Alg}_{\mathrm{Sq}}$
that satisfies \pref{ass:regression}, \squareCB.\textup{\textsf{Lin}}\xspace with
learning rate $\gamma\propto\sqrt{dT/(\mathsf{Reg}_{\mathrm{Sq}}(T)+\varepsilon)}$ guarantees
that for all sequences $S$ with $\varepsilon_T(S)\leq\varepsilon$,
\begin{align*}
\textstyle\Reg = \cO\left(\sqrt{dT\mathsf{Reg}_{\mathrm{Sq}}(T)}+ \varepsilon\sqrt{d}T\right)\,.
\end{align*}
\end{theorem}
The $\textsf{logdet-barrier}$ optimization problem is closely related to the
D-optimal experimental design problem, as well as the John ellipsoid problem
\citep{KT90,TY07}; the latter corresponds to the case where $\theta=0$ in
\pref{eq:logdet_barrier} \citep{KY05}. By adapting specialized
optimization algorithms for these problems (in particular, a
Frank-Wolfe-type scheme), we can efficiently solve the
$\textsf{logdet-barrier}$ problem.
\begin{proposition}
\label{prop:logdet_efficient}
An approximate minimizer for \eqref{eq:logdet_barrier} that achieves the same
regret bound up to a constant factor can be computed in time
$\tilde\cO\prn*{|\cA_t|\cdot\mathrm{poly}(d)}$ and memory
$\tilde{\cO}(\log\abs{\cA_t}\cdot\mathrm{poly}(d))$ per round.
\end{proposition}
The minimization algorithm, along with a full analysis for runtime and
memory complexity and impact on the regret, is provided in \ifsup \cref{app:logdet solver}\else the supplementary material\fi.
\subsection{Adapting to Misspecification: Algorithmic Framework}
\label{sec:adaptive}
The regret bound for \squareCB.\textup{\textsf{Lin}}\xspace in \pref{thm:infinite} achieves optimal
dependence on the dimension and misspecification level, but
requires an a-priori upper bound on $\varepsilon_T(S)$ to set the learning rate. We now turn our
attention to adapting to this parameter.
At a high level, our approach is to run multiple instances of \squareCB.\textup{\textsf{Lin}}\xspace,
each tuned to a different level of misspecification, then run an
aggregation procedure on top to learn the best instance. Specifically,
we initialize a collection of $M\vcentcolon={}\floor{\log(T)}$ instances of
\cref{alg:logdet} in which the learning rate for instance $m$ is tuned
for misspecification level $\varepsilon'_m \vcentcolon= \exp(-m)$ (that is, we
follow a geometric grid). It is straightforward to show that
there exists $m^{\star}\in\brk{M}$ such that the $m^{\star}$th instance
would enjoy optimal regret if we were to run it on the sequence
$S$. Of course, $m^{\star}$ is not known a-priori, so we run an aggregation (or,
``Corralling'') procedure to select the best
instance \citep{ALNS17}. This approach is, in general, not suitable for model selection,
since it typically requires prior knowledge of the optimal regret
bound to tune certain parameters appropriately
\citep{foster2019model}. Our conceptual insight is to show that adaptation to
misspecification is an exception to this rule, and offers a simple
setting where model selection for contextual bandits is possible.
\begin{wrapfigure}[12]{r}{8cm}
\vspace{-0.1cm}
\begin{algorithm}[H]
\caption{Corralling \\\citep{ALNS17}}
\label{alg:master}
\DontPrintSemicolon
\LinesNumberedHidden
\KwIn{Master algorithm $\mathsf{Master}$, $T$}
\KwInit{$(\mathsf{Base}_m)_{m=1}^M$ \;}
\For{$t= 1,\dots, T$}{
Receive context $x_t$.\;
Receive $A_t$, $q_{t,A_t}$ from $\mathsf{Master}$.\;
Pass $(x_t,\cA_t, q_{t,A_t},\rho_{t,A_t})$ to $\mathsf{Base}_{A_t}$.\;
$\mathsf{Base}_{A_t}$ plays $a_t$ and observes $\ell_t$.\;
Update $\mathsf{Master}$ with $\tilde\ell_{t,A_t}=(\ell_t+1)$.\;
}
\end{algorithm}
\end{wrapfigure}
We use the aggregation scheme in \cref{alg:master}, which is a
generalization of the \textsf{CORRAL}\xspace algorithm of \citet{ALNS17}.
The algorithm is initialized with $M$ \emph{base} algorithms, and uses a
multi-armed bandit algorithm with $M$ arms as a \emph{master}
algorithm whose role is to choose the base algorithm to follow at
each round.
In more detail, the master algorithm maintains a distribution $q_t\in\Delta(\brk*{M})$ over the
base algorithms. At each round $t$, it samples an algorithm $A_t\sim q_t$
and passes the current context $x_t$ into this algorithm, as well as
the sampling probability $q_{t,A_t}$, and an importance weight
$\rho_{t,A_t}$, where we define $\rho_{t,m}\vcentcolon={}1/\min_{s\leq
t}q_{s,m}$ for each $m$.
At this point, the base algorithm $A_t$ selected by the master
executes a standard contextual bandit round:
Given the context $x_t$, it selects an arm $a_t$,
receives the loss $\ell_t$, and updates its internal state. Finally,
the master updates its state with the action-loss pair
$(A_t,\tilde \ell_{t,A_t})$, where $\tilde
\ell_{t,A_t}\vcentcolon={}\ell_t+1$; for technical reasons related to our
choice of master algorithm, it is useful to
shift the loss by $1$ to ensure non-negativity.
Define the \emph{importance-weighted regret} for base algorithm $m$ as
\neurips{$\RegImp[m]\vcentcolon=\mathbb{E}\brk*{\sum_{t=1}^T\frac{\bbI\set{A_t=m}}{q_{t,m}}\left(\mu(a_t,x_t)-\inf_{a\in\cA_t}\mu(a,x_t)\right)}$}
\arxiv{\[\RegImp[m]\vcentcolon=\mathbb{E}\brk*{\sum_{t=1}^T\frac{\bbI\set{A_t=m}}{q_{t,m}}\left(\mu(a_t,x_t)-\inf_{a\in\cA_t}\mu(a,x_t)\right)},\]}
which is simply the pseudoregret incurred in the rounds where
\pref{alg:master} follows this base algorithm, weighted inversely
proportional to the probability that this occurs. It is
straightforward to show that for any choice for the master and base
algorithms, this scheme guarantees that
\begin{align}
\textstyle\Reg %
%
= \mathbb{E}\brk*{\sum_{t=1}^T\tilde\ell_{t,A_t}-\tilde\ell_{t,m^*}}+\RegImp[m^*]~
%
,\label{eq:corral_decomp}
\end{align}
where $\tilde \ell_{t,m}$ denotes the loss that the algorithm would have
suffered at round $t$ if the master algorithm had chosen $A_t=m$. In
other words, the regret of \pref{alg:master} is equal to the regret
$\Reg[M]\vcentcolon=\mathbb{E}[\sum_{t=1}^T\tilde\ell_{t,A_t}-\tilde\ell_{t,m^*}]$ of the master algorithm, plus the importance-weighted regret
of the optimal base algorithm $m^*$.
The difficulty in instantiating this general scheme lies in the fact
that the importance-weighted regret $\RegImp[m^*] $ of the optimal base
algorithm typically scales
with $\mathbb{E}[\rho_{T,m^*}^\alpha]\cdot\RegU[m^*]$, where
$\alpha\in[\frac{1}{2},1]$ is an algorithm-dependent parameter and
$\RegU[m]\vcentcolon=\mathbb{E}[\sum_{t=1}^T\bbI\set{A_t=m}\left(\mu(a_t,x_t)-\inf_{a\in\cA_t}\mu(a,x_t)\right)]$
denotes the unweighted regret of algorithm $m$. A-priori, the
$\mathbb{E}[\rho_{T,m^*}^\alpha]$ can be unbounded, leading to large regret.
The key to the analysis of \citet{ALNS17}, and the approach we follow
here, is to use a master algorithm
with \emph{negative regret} proportional to $\mathbb{E}[\rho_{T,m^*}^\alpha]$,
allowing to cancel this factor.
\begin{wrapfigure}[14]{r}{8cm}
\vspace{-1.15cm}
\begin{algorithm}[H]
\caption{\textup{\textsf{SquareCB.Lin+}}\xspace (for base alg. $m$)}
\label{alg:imp logdet}
\DontPrintSemicolon
\LinesNumberedHidden
\KwIn{$T$, $\mathsf{Reg}_{\mathrm{Sq}}(T)$}
\KwInit{} Weighted regression oracle $\mathsf{Alg}_{\mathrm{Sq}}$.\;
\For{$t= (\tau_1,\tau_2,\ldots)\subset [T]$}{
Receive context $x_t$ and $(q_{t,m},\rho_{t,m})$.\;
Set $\gamma_{t,m} =
\min\set{\frac{\sqrt{d}}{\varepsilon'_m},\sqrt{dT/(\rho_{t,m}\mathsf{Reg}_{\mathrm{Sq}}(T))}}$.\;
Set $w_t=\gamma_{t,m}/q_{t,m}$.\;
Compute oracle's prediction $\hat{\theta}_t$ for $x_t, w_t$.\;
Sample $a_t\sim \textsf{logdet-barrier}(\theta_t,\gamma_{t,m};\cA_t)$.\;
Play $a_t$ and observe loss $\ell_t$.\;
Update $\mathsf{Alg}_{\mathrm{Sq}}$ with $\prn*{w_t, x_t, a_t, \ell_t}$.
}
\end{algorithm}
\vspace{-0.0in}
\end{wrapfigure}
\subsubsection{Choosing the Base Algorithm}
As the first step towards instantiating the aggregation scheme above,
we specify the base algorithm. We use a modification to \squareCB.\textup{\textsf{Lin}}\xspace (denoted by $\textup{\textsf{SquareCB.Lin+}}\xspace$) based
on
importance weighting, which is designed to ensure that the
importance-weighted regret in \pref{eq:corral_decomp} is
bounded. Pseudocode for the $m$th base algorithm is given in
\pref{alg:imp logdet}.
\textup{\textsf{SquareCB.Lin+}}\xspace proceeds as follows. Let the instance $m$ be fixed, and
let $Z_{t,m}=\mathbb{I}\crl{A_t=m}$ indicate the event that this instance
is chosen to select an arm; note that we have $Z_{t,m}\sim \mathrm{Ber}(q_{t,m})$
marginally. When $Z_{t,m}=1$, instance $m$ receives $q_{t,m}$ and
$\rho_{t,m}=\max_{s\leq t}q_{s,m}^{-1}$ from the master
algorithm. The instance then follows the same update scheme as in the
vanilla version of \squareCB.\textup{\textsf{Lin}}\xspace, except that i) it uses an adaptive
learning rate $\gamma_{t,m}$, which is tuned based on $\rho_{t,m}$,
and ii) it uses a weighted square loss regression oracle
(as in \pref{ass:weighted regression}), with the weight $w_t$ set as a function
of $\gamma_{t,m}$ and $q_{t,m}$.
%
The importance weighted regret $\RegImp[m]$ for this scheme is bounded as follows.
\begin{theorem}
\label{thm:impreg}
When invoked within \cref{alg:master} using a weighted regression oracle satisfying \cref{ass:weighted regression},
the importance-weighted regret for each instance $m\in\brk*{M}$ of \cref{alg:imp logdet} satisfies
\begin{align}
\textstyle\RegImp[m] \leq
\frac{3}{2}\mathbb{E}[\sqrt{\rho_{T,m}}]\sqrt{dT\mathsf{Reg}_{\mathrm{Sq}}(T)} +
\left(\left(\frac{\varepsilon'_m}{\varepsilon_T}+\frac{\varepsilon_T}{\varepsilon'_m}
\right) \sqrt{d}+2\right)\varepsilon_T T.
\label{eq:impreg}
\end{align}
\end{theorem}
The key feature of this regret bound is that only the leading term
involving $\mathsf{Reg}_{\mathrm{Sq}}(T)$ depends on the importance weights, not the
second misspecification term. This means that the optimal tuning for
the master algorithm will depend on $d$, $T$, and
$\mathsf{Reg}_{\mathrm{Sq}}(T)$, but not on $\varepsilon_T$, which is critical to adapt without
prior knowledge of the misspecification. Another important feature is
that as long as $\varepsilon'_m$ is within a
constant factor of $\varepsilon_T$, the second term simplifies to
$\cO(\varepsilon_T\sqrt{d}T)$ as desired.
\subsubsection{Improved Master Algorithms for Combining Bandit Algorithms}
It remains to provide a master algorithm for use within
\pref{alg:master}. While it turns out the master algorithm proposed in
\citet{ALNS17} suffices for this task, we go a step further and
propose a new master algorithm called \emph{$(\alpha,R)$--hedged
FTRL}, which is simpler and enjoys slightly
improved regret, removing logarithmic factors. While this is not the
focus of the paper, we find it to be a useful secondary contribution because it
provides a new approach to designing master algorithms for
bandit aggregation. We hope it will find use more broadly.
The $(\alpha,R)$--hedged FTRL algorithm is parameterized by a regularizer and two scale parameters $\alpha\in(0,1)$ and $R>0$. We defer a precise definition and analysis to
\ifsup \cref{sec:hedged ftrl}\else supplementary material\fi, and state only the relevant result for our
aggregation setup here.
We consider a special case of the $(\alpha,R)$--hedged FTRL algorithm that we call \emph{$(\alpha,R)$--hedged Tsallis-INF}, which
instantiates the framework using the Tsallis entropy as a regularizer
\citep{AB09,ALT15,ZiSe18}. The key property of the algorithm is that
the regret with respect to a policy playing a fixed arm $m$ contains a
negative contribution proportional to $\rho_{T,m}^\alpha R$. The following result is a corollary of a
more general theorem, \ifsup \pref{thm:hedged ftrl} (\pref{sec:hedged ftrl})\else found in the supplementary material\fi.
\begin{corollary}
\label{cor:Tsallis-INF}
Consider the adversarial multi-armed bandit problem with $M$ arms
and losses $\tilde\ell_{t,m} \in [0,2]$. For any $\alpha\in(0,1)$ and
$R>0$, the $(\alpha,R)$--hedged Tsallis-INF algorithm with learning rate
$\eta=\sqrt{1/(2T)}$ guarantees that for all $m^{\star}\in\brk*{M}$,
\begin{align}
\textstyle\mathbb{E}\left[\sum_{t=1}^T\tilde\ell_{t,A_t}-\tilde\ell_{t,m^{\star}}\right] \leq 4\sqrt{2MT} + \mathbb{E}\left[\min\set{\frac{1}{1-\alpha},2\log(\rho_{T,m^{\star} })}M^\alpha -\rho_{T,m^{\star}}^\alpha \right]\cdot{}R\,.\label{eq:tsallis_regret}
\end{align}
\end{corollary}
\subsection{Putting Everything Together}
When invoked within \pref{alg:master}, $(\alpha,R)$-hedged Tsallis-INF
has a negative contribution to the cumulative regret which, for sufficiently large
$R$ and appropriate $\alpha$, can be used to offset the regret
incurred from importance-weighting the base algorithms. In particular,
$\prn*{\frac{1}{2},\frac{3}{2}\sqrt{dT\mathsf{Reg}_{\mathrm{Sq}}(T)}}$--hedged Tsallis-INF has
exactly the negative regret contribution needed to cancel the
importance weighting term in \pref{eq:impreg} if we use \textup{\textsf{SquareCB.Lin+}}\xspace
as the base algorithm. In more detail, we prove \pref{thm:main} by
combining the regret bounds for the master and base algorithms as follows.
\begin{proof}[Proof sketch for \cref{thm:main}]
Using \pref{eq:corral_decomp}, it suffices to bound the regret of
the bandit master $\Reg[M]$ and the importance-weighted regret
$\RegImp[m^{\star}]$ for the optimal instance $m^*$.
By \cref{cor:Tsallis-INF}, using
$\prn*{\frac{1}{2},\frac{3}{2}\sqrt{dT\mathsf{Reg}_{\mathrm{Sq}}(T)}}$--hedged Tsallis-INF as
the master algorithm gives
\begin{align*}
\textstyle\Reg[M] \leq \cO\prn*{\sqrt{dT\mathsf{Reg}_{\mathrm{Sq}}(T)\log(T)}} - \frac{3}{2}\mathbb{E}[\sqrt{\rho_{T,m^*}}]\sqrt{dT\mathsf{Reg}_{\mathrm{Sq}}(T)}.
\end{align*}
Whenever the misspecification level is not
trivially small, the geometric grid ensures that there exists
$m^{\star}\in\brk{M}$ such that
$e^{-1}\varepsilon_T\leq \varepsilon'_{m^*}\leq \varepsilon_T$. For this instance, \cref{thm:impreg} yields
\begin{align*}
\textstyle\RegImp[m^*] \leq
\frac{3}{2}\mathbb{E}[\sqrt{\rho_{T,m^*}}]\sqrt{dT\mathsf{Reg}_{\mathrm{Sq}}(T)} + \cO(\varepsilon_T\sqrt{d}T).
\end{align*}
Summing the two bounds using \pref{eq:corral_decomp} completes the proof.
\end{proof}
\subsection{Extension: Adapting to the Average Dimension}
\label{sec:sparse}
A well-known application for linear contextual bandits is the problem of
online news article recommendation, where the context $x_t$ is taken
to be a feature vector containing information about the user, and each
action $a\in\cA_t$ is the concatenation of $x_t$ with a feature representation
for a candidate article (e.g., \citet{li2010contextual}). In this
and other similar applications, it is often the case that while
examples lie in a high-dimensional space, the true dimensionality $\dim(\cA_t)$ of the action set is small, so that $d_{\mathrm{avg}}\vcentcolon=\frac{1}{T}\smash{\sum_{t=1}^T}\dim(\cA_t)\ll d$.
If we have prior knowledge of $d_{\mathrm{avg}}$ (or an upper bound thereof), we can
exploit this low dimensionality for tighter regret. In fact, following
the proof of \cref{thm:impreg} and \cref{thm:main}, and bounding
$\smash{\sum_{t=1}^T}\dim(A_t)$ by $d_{\mathrm{avg}}{}T$ instead of $dT$, it is fairly
immediate to show that
\cref{alg:master} enjoys improved regret $\Reg = \cO (\sqrt{d_{\mathrm{avg}}{}
\smash{T\mathsf{Reg}_{\mathrm{Sq}}(T)\log(T)}}+\varepsilon_T\sqrt{d_{\mathrm{avg}}{}}T)$, so long as $d_{\mathrm{avg}}$ is replaced by
$d$ in the algorithm's various parameter settings.
Our final result shows that it is possible to adapt to unknown $d_{\mathrm{avg}}{}$ and
unknown misspecification simultaneously. The key idea to apply a
doubling trick on top of \pref{alg:master}
\begin{theorem}
\label{thm:sparse}
There exists an algorithm that, under the same conditions as
\cref{thm:main}, satisfies
$\Reg = \cO\left(\sqrt{d_{\mathrm{avg}} T\mathsf{Reg}_{\mathrm{Sq}}(T)\log(T)}+\varepsilon_T\sqrt{d_{\mathrm{avg}}}T\right)$ without prior knowledge of $d_{\mathrm{avg}}$ or $\varepsilon_T$.
\end{theorem}
We remark that while the bound in \pref{thm:sparse} replaces
the $d$ factor in the reduction with the data-dependent quantity $d_{\mathrm{avg}}$,
the oracle's regret $\mathsf{Reg}_{\mathrm{Sq}}(T)$ may itself still depend on $d$ unless
a sufficiently sophisticated algorithm is used.
\section{Discussion}
We have given the first general-purpose, oracle-efficient
algorithms that adapt to unknown model
misspecification in contextual bandits. For infinite-action linear contextual bandits, our
results yield the first optimal algorithms that adapt to unknown
misspecification with changing action sets. Our results suggest a
number of interesting questions:
\begin{itemize}
\item Can our optimization-based perspective lead to new oracle-based
algorithms for more rich types of infinite action sets? Examples
include nonparametric action sets and structured (e.g., sparse) linear action sets.
\item Can our reduction-based techniques be lifted to more
sophisticated interactive learning settings such as reinforcement learning?
\end{itemize}
On the technical side, we anticipate that our new approach to reductions will find
broader use; natural extensions include reductions for offline oracles
\citep{SX20} and adapting to low-noise conditions
\citep{foster2020instance}.
\neurips{\clearpage}
\subsection*{Acknowledgements}
DF acknowledges the support of NSF TRIPODS grant \#1740751. We thank
Teodor Marinov and Alexander Rakhlin for
discussions on related topics.
\newpage
\neurips{\bibliographystyle{plainnat}}
| {'timestamp': '2021-07-14T02:05:29', 'yymm': '2107', 'arxiv_id': '2107.05745', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05745'} | arxiv |
\section{INTRODUCTION}
\iffalse
The increased prevalence of complicated and high-dimensional data in recent years has brought along with it the need for improved statistical techniques to guide practical data analyses. One such type of data with complex structure is functional data, in which observations are functions $X_i(t),~i =1, \dots, n, $ where the index $t$ (often representing time) ranges over some continuum $\mathcal{T}\subset \mathbb{R}$.
\fi
Functional data analysis (FDA) has found important applications in many fields of research (e.g. biology, ecology, economics) and has spawned considerable methodological work as a subfield of statistics \citep{rams:05, mull:16:3, ferr:06}. In particular, the analysis of univariate functional data has driven the majority of developments in this area such as functional principal component analysis \citep{klef:73}, regression \citep{card:99,yao:05}, and clustering \citep{jacq:14}. Much less work exists for multivariate functional data, which consist of samples of a finite dimensional vectors whose elements are random functions, while such data
arise in many applications.
Dimension reduction is a common approach to handle functional data with several components, with many studies focusing on extending univariate functional principal components analysis to the multivariate case \citep{chio:14,chio:16, happ:18}. Alternative approaches include projections of the component functions
or decomposition into marginal component processes and their interactions \citep{mull:14:1,mull:16:13}. Most methodological work was focused on traditional amplitude variation-based models for dimension reduction, though phase variation-based methods for multivariate functional data have also been investigated; \cite{brun:14} proposed a method for estimating multivariate structural means and \cite{park:17} introduced a model for clustering multivariate functional data in the presence of phase variation. \cite{carr:20} combined the notions of dimension reduction and phase variability through a multivariate version of the shape-invariant model \citep{knei:95}, in which component processes share a common latent structure which is time-shifted across components. However the assumption of a rigid shift-warping framework imposes a major parametric constraint on the warping structure and often the class of models described with simple shifts is not rich enough to apply to real-world datasets. Our main contribution is a less-restrictive alternative, in which time characterization of individual-specific temporal effects and component-specific effects is achieved through a nonparametric deformation model.
A major motivation for this framework is
that the component functions of a multivariate data vector often share a common structure which is subject to variation across modalities; the fundamental shape of growth curves is similar but not identical in timing patterns across body parts, for instance.
In addition to a latent shape curve, a such a shape-sharing model also requires characterization of individual- and component-level variation. While the idea of component-specific time effects has been previously explored through a time-shifting model, this was done within a restrictive parametric framework with limited practical applicability \citep{carr:20}. Allowing for more flexible and nuanced component effects substantially increases the viability of a component-warping approach and allows for improved data fidelity when describing component-specific effects which inform the time-dynamics of a larger system at work. This motivates a novel representation of multivariate functional data through a Latent Transport Model, which combines tools from time warping \citep{marr:15} and optimal transport theory \citep{vill:03}.
The organization of this paper is as follows. Section 2 discusses existing approaches to univariate curve registration and introduces the Latent Transport Model for component-warped multivariate functional data. We derive estimators of model components in Section 3 and illustrate the utility and performance of our methodology through data analysis and simulation studies in Sections 4 and 5, respectively. Lastly, asymptotic results are established in Section 6.
\section{CURVE REGISTRATION AND THE LATENT TRANSPORT MODEL}
\subsection{The Univariate Curve Registration Problem}
A classical univariate curve registration problem occurs when one has a sample of curves $X_i(t),~ i = 1,\dots,n,$ observed on an interval $T$ which are realizations of a fixed template $\xi(t)$ that is randomly time-warped and is characterized by monotone time-warping random functions $h_i(t)$, which correspond to random homeomorphisms of $T$,
\begin{equation}
X_i(t) = (\xi \circ h_i)(t), \quad \text{for all} \quad t\in \mathcal{T},\quad i=1,\dots,n.
\label{eq.1}
\end{equation}
Curve registration aims at estimating the time warping functions $h_i$, which are typically considered to be nuisance effects, in order to adjust for them before proceeding with further analysis, e.g., the estimation of $\xi(t)$. A version of this problem was first considered in \citep{sako:78} with the dynamic time warping algorithm.
A common approach is to align processes to some template function that carries the main features common across subjects. Versions of this are known as
landmark-based registration \citep{knei:92, knei:95}, pairwise curve alignment \citep{mull:08:6} or the Procrustes approach \citep{rams:98}, among many others; see
\cite{marr:15}.
While the curve registration literature is varied and rich in methodology,
any reasonably performing method that satisfies some basic regularity and identifiability conditions can be used for our purposes; the regularity conditions are indispensable to obtain theoretical guarantees.
We emphasize that our emphasis here is not on univariate warping, but rather on extending curve registration methodology to the multivariate case and to develop a Latent Transport Model, which provides a new representation for multivariate functional data.
\subsection{A Unified Model for Multivariate Time Dynamics}
Let $\{X_j\}_{j=1}^p$ denote a generic set of random functions with positive component processes $X_j$ in $L_2(\mathcal{T})$ defined on an interval $\mathcal{T}$ that for simplicity we assume to be $[0,1]$.
For such processes we introduce a Latent Transport Model (LTM). This model provides a representation of functional data that is particularly attractive when the functional forms of the component processes $X_j,~ j\in\{1,\dots,p\}$ have similar shapes. The general idea is to pool the information available for individual component processes to arrive at a useful representation of the multivariate process.
Denoting a random sample from a $p$-dimensional stochastic process by $\{\textbf{X}_i\}_{i=1}^n$, where $\bm{X}_i(t) = (X_{i1}(t),\dots,X_{ip}(t))^T$, at the core of this shared structure is a nonrandom latent curve $\lambda$, which characterizes the component curves through
\begin{equation}
X_{ij}(G^{-1}_{ij}(t)) = A_{ij} \lambda(t) , \quad i = 1,\dots, n,~j = 1,\dots, p.
\label{eq.2}
\end{equation}
The random amplitude factors $A$ and random time distortion functions $G$ reflect differences in realized curves across components and individuals. Without loss of generality we assume $\underset{t \in \mathcal{T}}{\sup}|\lambda(t)|=||\lambda||_\infty = 1 $ since it is always possible to rescale the latent curve without changing the model by defining new amplitude factors $\tilde{A}_{ij} := A_{ij} ||\lambda||_\infty$ and $\tilde{\lambda}(t) = \lambda(t)/||\lambda||_\infty$.
The distortion functions $G$ are elements of $\mathcal{W}$, the convex space of all smooth, strictly increasing functions with common endpoints, i.e., $\mathcal{W}:=\{g:\mathcal{T}\to \mathcal{T}~ |~g\in C^2(\mathcal{T}), ~ g(T_1)=T_1, ~ g(T_2)=T_2,~ g~\text{is a strictly increasing homeomorphism}\}$. The elements of this space represent random homeomorphisms of the time domain and capture the presence of non-linear phase variation. We further assume that functions $G$ may be decomposed into the mixed-effects form,
\begin{equation}
G_{ij}(t) = (\Psi_j \circ H_i) (t) , \quad i = 1,\dots, n,~ j = 1,\dots, p,
\label{eq.3}
\end{equation}
\noindent where the deterministic functions $\Psi$ describe the component-based effects of time distortion and the random functions $H$ describe the subject-level phase variation. In this decomposition the mapping $\Psi_j$ conveys the internal time scale of the $j^{th}$ component, while $H_i$ carries the internal time scale of the $i^{th}$ subject. These mappings may be seen as time transports from standard clock time, $id(t)\equiv t$, to the time of a given component or individual. As such we refer to the collection of functions $\varPsi = \{\Psi_j: j = 1,\dots, p\}$ as \textit{component-level transport functions} and the collection of functions $\mathcal{H} = \{H_i: i = 1,\dots, n\}$ as \textit{subject-level transport functions}.
For the random warping functions $H_i$
we assume that
$EH^{-1}_i(t) = t$ for $t \in \mathcal{T}$. This assumption is sometimes referred to as ``standardizing" the registration procedure \citep{knei:08} and is commonly made so that there is no net variation.
The component transport functions are also assumed to be standardized, but because they are deterministic and not random, the assumption becomes $\frac{1}{p}\sum_{j=1}^p\Psi^{-1}_j (t) = t$ for $t \in \mathcal{T}$. Together these conditions imply $E(\frac{1}{p}\sum_{j=1}^p G^{-1}_{ij} (t)) = t$.
Combining (\ref{eq.1}) and (\ref{eq.2}) yields the Latent Transport Model (LTM) for multivariate functional data,
\begin{equation}
X_{ij}(t) = A_{ij} \left(\lambda \circ \Psi_j \circ H_i\right) (t) , \quad i = 1,\dots, n, ~ j = 1,\dots, p.
\label{eq.4}
\end{equation}
With component-warped versions of the latent curve $\gamma_j = \lambda \circ \Psi_j$, the LTM can be equivalently expressed as
\begin{equation}
X_{ij}(t) = A_{ij} \left(\gamma_j \circ H_i\right) (t) , \quad i = 1,\dots, n, ~ j = 1,\dots, p.
\label{eq.5}
\end{equation}
In this form, the curves $\gamma_j(t)$ convey the ``typical" time progression of the latent curve according to the $j^{th}$ component's system time, so we refer to them as the $j^{th}$ \textit{component tempo functions}. The component tempo functions can be viewed as the synchronized processes for each component after accounting for random subject-level time distortions. Figure \ref{fig:figure1} provides a schematic of the data generating mechanism of the LTM for a simulated dataset.
\begin{figure}[!p]
\centering
\vspace{-10mm}
\includegraphics[width=\linewidth]{img/simfig_warps.pdf}
\caption{Schematic of the Latent Transport Model, where $\lambda$ denotes the latent base curve (top-left), $\Psi$ denotes component transports (bottom-left), $\gamma$ denotes component tempos (top-center), $H$ denotes random subject-wise time distortion functions (bottom-right), and $X$ denotes the observed multivariate curve data (top-right) resulting from the complete data generating mechanism.}
\label{fig:figure1}
\end{figure}
\subsection{Cross-Component Transport Maps}
\label{sec:xct}
\noindent\textit{Marginal Cross-Component Transports}\\
To understand and quantify the relative timings between any pair of components, $j,k\in\{1,\dots,p\}$, it is useful to define their \textit{cross-component transport} $T_{jk}$, which is the transport that, when applied to $j^{th}$ component, maps its tempo to that of the $k^{th}$ component, i.e.,
\begin{equation}
T_{jk} = \Psi^{-1}_{j}\circ\Psi_{k},
\end{equation}
so that $\gamma_j(T_{jk}) = \lambda \circ \Psi_{j} \circ \Psi^{-1}_{j} \circ \Psi_{k} = \lambda \circ \Psi_{k} = \gamma_k$. Because on domains $[0,1]$ the component transports $\Psi_{k}$ can be represented as distribution functions and are closed under composition, the cross-component transports (XCT) may also be represented as distribution functions.
For example, consider a pair of component processes, Component A and Component B, for which Component A tends to lag behind the latent curve, while the Component B precedes it. An example of this can be seen in the red and orange curves, respectively, in Figure \ref{fig:figure1}. The corresponding red transport, $\Psi_{A}$, falls below the diagonal and conveys the lagged tempo, while the orange transport, $\Psi_{B}$ lies above the diagonal and expresses an accelerated time. The transport function $T_{AB}$ then sits above the diagonal and represents the time-acceleration needed to bring the red tempo in line with the orange component.
\noindent\textit{Subject-Level Cross-Component Transports}\\
While the marginal XCTs describe the general time relations between components on a population level, we may also be interested in how an individual's component processes relate to one another. This perspective may be especially useful when trying to understand intercomponent dynamics which are mediated by covariate effects. Conceptually it is straightforward to extend the notion of cross-component transports to individuals by searching for the warping function $T^{(i)}_{jk}$ which brings the $i^{th}$ individual's $j^{th}$ component in line with the $k^{th}$. A natural definition under the LTM is then
\begin{equation}
T^{(i)}_{jk} = G^{-1}_{ij} \circ G_{ik},
\label{indiv_xct}
\end{equation}
since this choice gives $X_{ij}\circ T^{(i)}_{jk} \propto A_{ij} (\lambda \circ G_{ij} \circ G^{-1}_{ij} \circ G_{ik}) \propto (\lambda \circ G_{ik}) \propto X_{ik}$. In practice, this proportionality will become equality once random amplitude factors are dealt with during estimation.
The proposed cross-component transports represent intercomponent time dynamics and do not rely on an absolute clock time. Statistics based on the XCT model can be used in downstream analyses like hypothesis testing and regression. Data illustrations where this comes into play are given in Section~\ref{sec:data}
\section{MODEL ESTIMATION AND CURVE RECONSTRUCTION}
\label{sec:est}
\subsection{Pairwise Warping}
The model estimation procedure proposed here relies on solving several univariate warping problems of type $(1)$. Any of the warpingmethods described in Section 2 may be used for
practical implementation.
We use here the pairwise alignment method of \cite{mull:08:6}, which provides an explicit representation of warping functions and satisfies some properties required by our theory in order to derive convergence rates. This pairwise alignment is easily implemented with
the R package \texttt{fdapace} \citep{carr:20fdapace}.
Fix a component $j$ and to simplify notation write $U_i = X_{ij}/||X_{ij}||_\infty$ to denote a curve normalized by its maximum. For any two curves $U_i, U_{i'}, ~i,i'\in\{1,\dots,n\}$, the pairwise warping function $V_{i'i}: \mathcal{T}\to \mathcal{T}$ is the homeomorphism of the time domain which aligns $U_{i'}$ to $U_i$,
\begin{equation}
V_{i'i}(t) = H^{-1}_{i'}(H_{i}(t)), \quad\text{for all } t \in \mathcal{T}.
\end{equation}
Following \cite{mull:08:6}, we assume that the functions $v$ can be represented by a linear spline. Let $t_\ell = \ell/(L+1),$ for $\ell = 1, \dots, L, $ denote $L$ equidistant knots over $\mathcal{T}$ with $t_0 = 0$ and $t_{L+1}= 1$. For a warping function $v$, let $\theta=\theta(v) = [v(t_1),\dots,v(t_\ell)]^T$ so that
\begin{equation}
v(t) = \theta^T\alpha(t), \quad\text{for all } t \in \mathcal{T},
\label{eq:spline}
\end{equation}
\noindent where $\alpha(t) = [\alpha_1(t) , \dots, \alpha_{L+1}(t)]^T$ and $\alpha_\ell(t)$ are linear basis functions defined as $\alpha_\ell(t) = \alpha^{(1)}_\ell(t) - \alpha^{(2)}_{\ell+1}(t)$ with $ \alpha^{(1)}_\ell(t) = \dfrac{t - t_{\ell-1}}{t_\ell- t_{\ell-1}} \textbf{1}_{[t_{\ell-1},t_\ell)}$ and $ \alpha^{(2)}_\ell(t) = \dfrac{t - t_{\ell}}{t_\ell- t_{\ell-1}} \textbf{1}_{[t_{\ell-1},t_\ell)}$, for $\ell = 1,..,L+1$.
The parameter space $\Theta$ of the coefficient vector is
\begin{equation*}
\Theta = \{\theta\in\mathbb{R}^{L+1}: 0<\theta_1<\dots<\theta_{L+1}=1\}
\end{equation*}
\noindent so that the monotonicity constraint is satisfied.
We then express the pairwise warping function between subjects $i$ and $i'$ as
$V_{i'i}(\cdot) = \theta^T\alpha(\cdot),$ with $\theta\in\Theta$ and
the spline coefficient vector is obtained by solving the minimization problem
\begin{align}
\tilde{\theta}_{V_{i'i}} &= \underset{\theta\in\Theta}{\argmin} ~\mathcal{C}_{\eta_1}(\theta, U_i, U_{i'}), \nonumber \\
\quad\text{where~}\mathcal{C}_{\eta_1}(\theta, U_i, U_{i'}) &= \int_\mathcal{T} d^2\left(U_{i'}(\theta^T\alpha(t)),U_i(t)\right) dt + {\eta_1}\int_\mathcal{T}(\theta^T\alpha(t)-t)^2dt.
\label{eq:objfun}
\end{align}
Here $d$ is a distance and $\eta_1$ is a regularization parameter, which penalizes against heavy warping and guards against the ``pinching effect"
\citep{marr:15}.
In the original pairwise warping framework of \cite{mull:08:6}, the default distance was taken as $d^2(f(t),g(t)) = \int (f(t)-g(t))^2 \, dt$, which we also adopt here for the pre-standardized curves as
defined right after (\ref{eq.2}). We note that without the pre-standardization, this would correspond to using the semi-metric
$d^2_{\infty}(f(t),g(t)) =\left|\dfrac{f(t)}{~~||f||_\infty}-\dfrac{g(t)}{~~||g||_\infty}\right|^2$ in (\ref{eq:objfun}).
Once the $\tilde{\theta}_{V_{i'i}}$ have been obtained, we obtain representations of the pairwise subject warping functions
\begin{equation}
\tilde{V}_{i'i}(t) = \tilde{\theta}_{V_{i'i}}^T \alpha(t)\quad\text{for all } t \in \mathcal{T}.
\label{eq:pw}
\end{equation}
Since we assume $E(H^{-1}_i(t)) = t$ for all $t \in \mathcal{T}$, we have the identity $E[V_{i'i}(t)|H_i] = E[H^{-1}_{i'}\left(H_{i}(t)\right)|H_i]\\ = H_i(t)$, the empirical version of which leads to the estimates
\begin{equation}
\tilde{H}_{i}(t) = \frac{1}{n}\sum_{i'=1}^n \tilde{V}_{i'i}(t)\quad\text{for all } t \in \mathcal{T}.
\label{pw:est}
\end{equation}
\subsection{Component-wise Alignment}
For a fixed component $j$, consider the sample of univariate curves, $S_j:=\{X_{ij}\}_{i=1}^n$ that are contained in the sample of observed curves of size $n$ with associated normailzed curves
$X^*_{ij} = X_{ij}/||X_{ij}||_\infty$. Estimates of $\gamma_j$ and $H_i$ for the $j^{th}$ component are suggested by the relation
\begin{align}
X^*_{ij}(t) &= (\lambda\circ\Psi_j \circ H_i)(t),
\label{eq_univ}
\end{align}
which falls within the warping framework of type (\ref{eq.1}) with $\xi = \lambda\circ\Psi_j$, and $h_i = H_i$.
Replacing $X$ by $X^*$ in $(\ref{eq_univ})$ eliminates the random amplitude factors $A_{ij}$, because
$||X_{ij}||_\infty = A_{ij} ||\lambda\circ G_{ij}||_\infty = A_{ij}$; thus the normalized curves $X^*_{ij}(t) = (\lambda\circ\Psi_j\circ H_i)(t)$ do not depend on the $A_{ij}$.
Applying an estimation method like pairwise warping for each of the subcollections $S_1,\dots,S_p$, results in $p$ estimates of the subject-level warping function, $\tilde{H}^{(1)}_i(t),\dots,\tilde{H}^{(p)}_i(t)$. Taking the mean of the resulting $p$ warping functions then is a natural estimate for the subject-specific warp,
\begin{equation}
\hat{H}_i = p^{-1} \sum_{j=1}^p \tilde{H}^{(j)}_i, \quad i=1,\dots,n.
\end{equation}
\noindent Under this definition, the overall penalty parameter associated with the warping function is $\eta_1= \underset{1\leq j \leq p}{\max}~\eta_{1j},$ where $\eta_{1j}=10^{-4}\times \{n^{-1} \sum_{i=1}^n
\int_\mathcal{T} (X_{ij}(t)-\bar{X}_j(t))^2dt\}, ~j=1,\dots,p,$ is the default choice of penalty parameter for each of the $p$ registrations \citep{mull:08:6}. A plug-in estimate of $\gamma_j$ is then obtained by averaging the component-aligned curves,
\begin{equation}
\hat{\gamma}_j = n^{-1} \sum_{i = 1}^n (X_{ij}\circ \hat{H}_i^{-1})/||X_{ij}||_\infty,\quad\text{for}~j=1,\dots,p.
\end{equation}
\subsection{Global Alignment and Latent Curve Estimation}
A central idea of the LTM is that all univariate curves $X_{ij}$ contain information about the latent template function $\lambda$.
We therefore consider the full collection of curves, $S=\cup_{j=1}^p S_j$ and for the estimation of each individual $i$, select one of its component curves at random as a representative. Call this representative curve $Z_i$ and denote its normalized counterpart by $Z^*_i$. Selecting one of the components at random ensures that we have $P(Z_i = X_{ij}) = 1/p$ for all $i=1,\dots,n,~j=1,\dots,p$. The collection of curves $\{Z_i,~i=1,\dots,n\}$ can be thought of as realizations of $\lambda$ subject to some random distortion $D_i$, where $D_i=G_{ij}$ if the $j^{th}$ component curve is selected. Define $I_{ij}$ as the event that the curve $Z_i$ comes from the collection of $j^{th}$ component curves, $S_j$. Conditional on the event $I_{ij}$ (which happens with probability $1/p$ for all $i=1,\dots,n$), it follows that $D_{i} = G_{ij}= \Psi_j
\circ H_i$. Then, on average
\begin{equation}
E[D^{-1}_{i}] = E\{E[D^{-1}_{i}|I_{ij}]\} = \sum_{j=1}^p E[H^{-1}_i\circ \Psi^{-1}_j] P(I_{ij}) = p^{-1}\sum_{j=1}^p \Psi^{-1}_j = id,
\end{equation}
motivating the warping problem
\begin{equation}
Z^*_i = \lambda \circ D_i, \quad\text{for $i=1,\dots,n$}.
\end{equation}
The critical implication of this relation is that if we expand our scope to the full collection $S$ and apply a traditional method like pairwise warping to obtain $\hat{D}_{i}$ for all $i=1,\dots,n$, the latent curve can be estimated by averaging the globally-aligned curves,
\begin{equation}
\hat{\lambda} = n^{-1} \sum_{i = 1}^{n} (Z_{i}\circ \hat{D}_{i}^{-1})/||Z_{i}||_\infty.
\end{equation}
\noindent The estimators of the component transports are motivated by recalling that
\begin{align*}
{\gamma}_j = \lambda \circ \Psi_j , \quad j=1,\dots.,p.
\end{align*}
\noindent Using a spline representation similar to $(\ref{eq:spline})$, we write
\begin{equation}
\Psi_j(t) = \theta^T \alpha(t)
\label{eq:psispline}
\end{equation}
and estimate the component warps by solving the penalized minimization problem,
\begin{align}
\begin{split}
\tilde{\theta}_{\Psi_{j}} &= \underset{\theta\in\Theta}{\argmin} ~\mathcal{C}_{\eta_2}(\theta; \hat{\gamma}_j, \hat{\lambda}),\\
\mathcal{C}_{\eta_2}(\theta; \hat{\gamma}_j, \hat{\lambda})&= \int_\mathcal{T} d^2\left(\hat{\gamma}_j,\hat{\lambda}(\theta^T\alpha(t))\right) dt+\eta_2\int_\mathcal{T}(\theta^T\alpha(t)-t)^2dt,
\end{split}
\label{eq:objfun2}
\end{align}
\noindent with
$\eta_{2}=10^{-4}\times \{p^{-1} \sum_{j=1}^p
\int_\mathcal{T} (\hat{\gamma}_j(t)-\hat{\lambda}(t))^2dt\}$ as the default choice of penalty parameter in line with \cite{mull:08:6}.
Finally, we estimate the component warps as
\begin{equation}
\hat{\Psi}_j(t) = \tilde{\theta}_{\Psi_j}^T \alpha(t).
\end{equation}
Note that under the assumption of fully observed curves without measurement error, the amplitude factors $A_{ij}=||X_{ij}||_\infty$ are known. Often in practice, this is not realistic, and the factors must be estimated by, e.g., $\hat{A}_{ij}=||\tilde{X}_{ij}||_\infty$ where $\tilde{X}$ denotes a smoothing estimate of a function $X$ that is observed with noise, as described in the following section.
\subsection{Measurement Error}
In practice, the functions $X_{ij}$ are often contaminated with measurement error and available only on a discrete grid. In this situation an initial step is to perform smoothing on the discrete and noisy observations before applying the model estimation method of Sections 3.2 and 3.3.
Let $\{\bm{X}_i, ~i=1,\dots,n\}$ be a random sample of a $p$-dimensional stochastic process $\bm{X}$ in $L_2(\mathcal{T})\times\cdots\times L_2(\mathcal{T})$, where $\bm{X}_i(t) = (X_{i1}(t),\dots,X_{ip}(t))^T$. We assume that these processes are observed for $m$ equispaced points at the discrete times $t_{s}, ~s=1,\dots,m$. We write $\bm{Y}_{is} = (Y_{i1s},\dots,Y_{ips})^T$ to represent the $i^{th}$ subject's observation at time $t_{s}$, where \begin{equation}
\bm{Y}_{is} = \bm{X}_i(t_{is}) +\bm{\epsilon}_{is},
\label{eq:measurementerror}
\end{equation}
with i.i.d. zero mean measurement errors $\bm{\epsilon}_{is} = (\epsilon_{i1s},\dots,\epsilon_{ips})^T$ that are independent of $\bm{X}_i$
and have component-specific variances $\sigma^2_j<\infty$ for $j=1,\dots,p$.
Estimation of the smooth component curves, $\tilde{X}_{ij}$, may be performed by any smoothing technique, e.g. kernel methods, smoothing splines, or local polynomial fitting.
As an example we consider local linear smoothing. Let $K: \mathbb{R} \to \mathbb{R}$ represent a non-negative kernel function. Applying local linear smoothing with bandwidth $b$ leads to the estimates $\tilde{X}_{ij}(t) = \hat{\beta}^{(0)}_{ij}$, where for all $i=1,\dots,n,~j=1,\dots,p$ \begin{equation}
(\hat{\beta}^{(0)}_{ij},\hat{\beta}^{(1)}_{ij}) = \argmin_{\beta^{(0)}_{ij},\beta^{(1)}_{ij}} \sum_{s=1}^{m}K\left(\frac{t_{s}-t}{b}\right)(Y_{ijs}-\beta^{(0)}_{ij}-\beta^{(1)}_{ij}(t-t_{s}))^2,
\label{eq:lwls}
\end{equation}
Bandwidth selection may be data-adaptive \citep{rice:91}, but a subjective choice often suffices in practice.
After the smoothing step, estimation may be carried out by substituting $\tilde{X}_{ij}$ for $X_{ij}$ and implementing the procedure described in Sections 3.2 and 3.3.
Once all model components are estimated,
plug-in estimates of the composite distortion functions and marginal and subject-level component transport functions follow immediately,
\begin{align}
\hat{G}_{ij} &= \hat{\Psi}_j\circ \hat{H}_i, \label{eq:mixedwarp_est}\\
\hat{T}_{jk} &= \hat{\Psi}_j^{-1}\circ\hat{\Psi}_k,\label{eq:xct_est}\\
\hat{T}^{(i)}_{jk} &= \hat{G}_{ij}^{-1}\circ\hat{G}_{ik}, \quad \quad i=1,\dots,n, \quad j,k=1,\dots,p. \label{eq:subjxct_est}
\end{align}
\noindent Additionally, fitted curves based on the LTM are obtained as
\begin{align}
\hat{X}_{ij}(t) &= \hat{A}_{ij} (\hat{\lambda}\circ\hat{G}_{ij})(t)
=\hat{A}_{ij} (\hat{\lambda}\circ\hat{\Psi}_{j}\circ \hat{H}_i)(t), \,\, i=1,\dots,n, \,\, j,k=1,\dots,p.
\label{eq:recon}
\end{align}
These fits can be viewed as dimension reduction provided through the LTM, as they require only $n+p+1$ estimated functions as opposed to $np$ curves in the original data. In Section~6, we derive asymptotic results for these estimates.
\section{DATA APPLICATIONS}
\label{sec:data}
\subsection{Z\"urich Growth Study}
From 1954 to 1978, a longitudinal study on human growth and development was conducted at the University Children’s Hospital in Z\"urich. The sitting heights, arm lengths, and leg lengths of a cohort of children were measured on a dense time grid such that the resulting data can be viewed as multivariate functional data. We focus on the timing of pubertal growth spurts, which usually occur between ages 9 and 18. It is standard in the growth curve literature to work with the derivatives of the growth curves, i.e. the growth velocities, instead of the curves themselves \citep{gass:84}. The growth velocities have a peak during puberty, with the crest location representing the age when an individual is growing fastest. The timings and curvatures of these peaks are critical in informing growth patterns. Estimates of growth velocities for the three modalities of sitting height, leg length and arm length are displayed in Fig. \ref{fig:growthvel}, obtained via local linear smoothing. There is a well known difference in the timing of the pubertal spurts between boys and girls that is evident from Fig. \ref{fig:growthvel}; girls start the pubertal spurt earlier than boys. It is of further interest to study body shape changes as represented by the three growth modalities.
We demonstrate in the following that the proposed representation provided by the LTM facilitates such studies.
\begin{figure}[!t]
\centering
\includegraphics[width=\linewidth]{zls_boygirl.png}
\caption{Growth velocities (in cm/year) during puberty for boys (blue) and girls (red). Scaled component tempo functions are marked for boys and girls with dashed and dotted lines, respectively. }
\label{fig:growthvel}
\end{figure}
Component tempos for boys and girls are a simple way to summarize these differences (Fig. \ref{fig:growthvel}, dashed and dotted lines, respectively).
\begin{figure}[!t]
\centering
\includegraphics[width=\linewidth]{zls_gammapsi.png}
\caption{Component tempos $\gamma$ (left) and transports $\Psi$ (right) for growth modalities. The dashed line represents the tempo and transport for the latent tempo, $\lambda$.}
\label{fig:bary}
\end{figure}
Turning our attention to the joint time dynamics of the $p=3$ modalities, aiming to study body shape changes, we restrict our analysis to the boys for the sake of brevity.
To compare growth patterns we study the component tempos, which are displayed for each modality in the left panel of Fig.~\ref{fig:bary}. The dynamics of joint development can be seen by examining the order of peaks across modalities. In this case leg length is first, followed by arm length, while sitting height lags behind. The tempos obtain similar slopes during puberty, though leg length has the most gradual spurt and sitting height has the sharpest increase, This may reflect the fact that its lagged onset results in a smaller window between the onset of its growth spurt and the end of growth which is a consequence of the ossification of the epiphyses. We note that it is not impossible for an individual to experience some minor growth past the age of 18, but in the Z\"urich study such cases were rare and so this complication was ignored. The component transports displayed in Fig.~\ref{fig:bary} (right) further illustrate the nature of the body part tempos relative to the baseline latent system time. Remarkably, the tempo of arm length is nearly identical to the latent curve. This suggests that arm length can be used a representative modality which mirrors a child's overall growth.
\begin{figure}[!tp]
\centering
\includegraphics[width=\linewidth]{xct_matrix.png}
\caption{The cross-component transport matrix, which characterizes pairwise time relations between components.}
\label{fig:xct}
\end{figure}
The estimated cross-component transports, $\hat{T}_{jk},~j,k\in\{1,\dots,p\}$ as per (\ref{eq:xct_est}), are depicted in Figure~\ref{fig:xct} and illustrate the intercomponent time dynamics for the three growth modalities. An XCT map can be interpreted as the transport required in order to accelerate or decelerate the tempo of component $j$ to that of component $k$. Taking the transport between sitting height and leg length, $\hat{T}_{23}$ as an example, we see that the XCT map falls above the identity, indicating that sitting height's tempo must be accelerate in order to synchronize with that of leg length. This matches the interpretation that individuals tend to experience growth spurts in leg lengths before sitting height, reflected in Fig.~\ref{fig:bary}; see also
\cite{shee:99}.
\begin{figure}[!t]
\centering
\includegraphics[width=\linewidth]{img/zls_sit_to_leg.png}
\caption{The cross-component transport map $T_{12}$ which expresses the sitting height's timing patterns relative to the leg length's as a baseline. The peak of pubertal growth rate for the leg occurs at approximately age $13.5$, while the maximum growth velocity for sitting height growth occurs at approximately $T_{12}(13.5) \approx 14.5$ years old.}
\label{fig:sit_to_leg}
\end{figure}
The magnitude of the XCT map's deviation from the identity shows how dissimilar the two components are. For example, sitting height and leg length are the most distinct modalities of growth among those considered here, and their XCT map exhibits the most pronounced departure from the identity. An intuitive interpretation of the map is that $T_{jk}$ expresses the $k^{th}$ component's timing patterns relative to the $j^{th}$ component's as a baseline. For example, when the leg tempo is at time $t=13.5$, the comparable time point for the sitting height tempo is approximately at $T_{jk}(13.5) \approx 14.5$ as illustrated in Fig.~$\ref{fig:sit_to_leg}$.
\subsection{Air Pollutants in Sacramento, CA}
The study of air pollutants has been a topic of interest for atmospheric scientists and environmentalists alike for several decades. In particular, increased ground-level ozone (O$_3$) concentrations have been shown to have harmful effects on human health. Unlike many air pollutants, surface ozone is not directly emitted by sources of air pollution (e.g. road traffic); it is formed as a result of interactions between nitrogen oxides and volatile organic compounds in the presence of sunlight \citep{abdul:01}. Because of this interaction, compounds such as nitrogen dioxide are known and important precursors of increased ozone concentrations \citep{tu:07}.
The California Environmental Protection Agency has monitored hourly air pollutant concentrations at several station locations since the 1980s. Here we consider the sample of weekday trajectories of ozone (O$_3$), and nitrogen oxides (NO$_x$) concentrations during the summer of 2005 in Sacramento (Fig. \ref{fig:air_trajectory}). Smooth trajectories were obtained from raw data using locally linear weighted least squares. \cite{gerv:15} has previously investigated a similar dataset in the context of warped functional regression, where the primary aim was to model phase variation explicitly in order to relate the timing of peak concentrations of NO$_x$ to those of O$_3$. The chemistry of the compounds as well as a visual inspection of the curves suggests that NO$_x$ concentrations tend to peak around 8 a.m., reflecting standard morning commute hours and the impact of traffic emissions on air quality, while ozone levels peak around 2 to 3 p.m., indicating that the synthesis mechanism induces a lag of up to approximately 6 hours.
\begin{figure}[!t]
\centering
\includegraphics[width=\linewidth]{../img/epa_trajectory.png}
\caption{24-hour trajectories of NO$_x$ (left) and ozone (right), concentrations in parts per billion (ppb) on a log scale.}
\label{fig:air_trajectory}
\end{figure}
It is of interest if meteorological factors affect the rate of ozone synthesis. Individual component transports combined with Fr\'echet regression for distributions provide a natural framework to study this query \citep{pete:19}. Subject-specific transports from NO$_x$ concentrations to ozone concentrations, $T^{(i)}_{NO_x\to O_3}$, were calculated as per (\ref{eq:subjxct_est}) for each day. Global Fr\'echet regression was then applied through the model
\begin{align}
\begin{split}
\hat{m}_\oplus(x) &= \underset{T\in\mathcal{W}}{\argmin}~M_n(T,x),\\
M_n(T,x) &= n^{-1} \sum_{i=1}^n q_{in}d^2_W(T_i,T),
\end{split}
\end{align}
where $m_\oplus$ denotes the conditional Fr\'echet mean of the transport given the covariate $x$, the wind speed recorded a given day. Here, $d_W$ denotes the $2-$Wasserstein distance \citep{vill:03} and the weights are defined as $q_{in}=1+(x_i-\bar{x})(x-\bar{x})/\hat{s}^2_x$ \citep{pete:19}, where $\bar{x}$ and $\hat{s}^2_x$ represent the sample mean and variance of the observed wind speeds, respectively. The model was fit using the \texttt{R} package \texttt{frechet}. This relies on the key observation that the transports can be represented as distribution functions if the domain is normalized to $[0,1]$ \citep{frechet}.
\begin{figure}[!t]
\centering
\includegraphics[width=\linewidth]{../img/epa_xctreg.png}
\caption{Fr\'{e}chet regression of NO$_x$-to-O$_3$ cross-component transports onto daily max windspeeds in knots. Windier days correspond to more linear transport functions, which suggests O$_3$ synthesis more closely follow NO$_x$ emission. Less windy days are associated with more pronounced lags between the pollutants. }
\label{fig:freg}
\end{figure}
Figure $\ref{fig:freg}$ displays the observed transports and the fits obtained from Fr\'echet regression using windspeed as a predictor. The rainbow gradient corresponds to windspeeds ranging from 3 to 10 knots and their associated fitted transports are overlaid the original data. The regression fits suggest that days with lower windspeeds correspond with transports which are further from the diagonal, indicating an augmented lag between peak concentrations of NO$_x$ and ozone. On the other hand, days with high wind speeds have fitted transports very near the diagonal which suggests that windier settings accelerate the synthesis process. Intuitively this is reasonable, as more wind will result in a higher rate of collisions of the particles, and thus quicker production of ozone after peak NO$_x$ emission. The Fr\'echet $R^2_\oplus$ value was $0.44$, which suggests that wind speed explains a considerable amount of variation in the observed transports.
\section{SIMULATION STUDY}
\label{sec:sim}
In this section we illustrate the latent transport model through a simulated $p~=~4-$~dimensional dataset which exhibits intercomponent warping of a base latent curve. Component curves are simulated on a grid $\mathcal{T} = [0,1]$ traversed by increments of $0.05$ as
\begin{align}
X_{ij}(t_s) &= A_{ij} (\lambda \circ \Psi_j \circ H_i \circ R_{ij})(t_s) + \epsilon_{ijs},
\end{align}
\noindent where the latent curve is defined as $\lambda(t) = \lambda_0(t)/||\lambda_0||_\infty$, for $\lambda_0(t) = 20+15t^2-5\cos(4\pi t)+3\sin(\pi t^2)$, the random amplitudes are distributed as $A_{ij}\overset{iid}{\sim} \mathcal{N}(100,\sigma^2_A)$, the component distortion functions $\Psi_j,~j=1,\dots,4$ are mixtures of Beta distributions, and $H_i$ are random distortions of the unit interval. Specifically, we set $\Psi_j(t) = \vartheta B_t(a_j, b_j) + (1-\vartheta) t$ for $j=1,2$, where $B_t$ denotes the regularized incomplete Beta function, and $a = (2,1)^T$, $b = (2,1/2)^T$, and $\vartheta = 0.5$. Then we define $\Psi^{-1}_{j+2}(t) = 2t - \Psi^{-1}_{j}(t), ~j=1,2,$ so the net identity warp constraint $p^{-1}\sum_{j=1}^p \Psi^{-1}_j(t) = t$ is satisfied. The sources of random phase variation are introduced by the subject-level warping functions defined by $H^{-1}_i(t) = \dfrac{\exp(tw_i)-1}{\exp(w_i)-1}$ where $w_i\overset{iid}{\sim}\mathcal{N}(0, \sigma^2_W)$ and a random nuisance distortion function defined by $R^{-1}_{ij}(t) = \dfrac{\exp(t d_{ij})-1}{\exp(d_{ij})-1}$ where $d_{ij}\overset{iid}{\sim}\mathcal{N}(0, \sigma^2_D)$. Finally, measurement error is also added to contaminate the raw observations through the random variables $\epsilon_{ijs}\overset{iid}{\sim}\mathcal{N}(0, \sigma_E^2)$. The levels of these distortions was varied by choosing $\sigma_W=0,.5,1,$ $\sigma_D=0,.5,1,$ and $\sigma_E=0,1,5,10$. Figure \ref{fig:sim_psi} displays an example of simulated data and component warping functions for the case where $\sigma_W=0.5$, $\sigma_D=0$, and $\sigma_E=1$.
\begin{figure}[!t]
\centering
\vfill
\includegraphics[width=\linewidth]{../img/sim_warp_only.pdf}
\caption{Estimated (dashed) vs. true (solid) component transport functions (left) and cross-component transport functions (right) under the latent transport model at the noise setting with
$\sigma_W=0.5$, $\sigma_D=0.5$, and $\sigma_E=1$.}
\label{fig:sim_psi}
\vfill
\end{figure}
The component warping functions were chosen to induce both distortions which accelerate (or delay) the latent trajectory uniformly and more complicated distortions which alternate between stretching and shrinking the time domain. The former induces a simpler warping structure as the warping functions remain on either side of the diagonal. In some cases, these kinds of warps may be approximated adequately with simple shift parameters. On the other hand, a component transport which oscillating across the diagonal corresponds to a nuanced warping effect that requires added flexibility beyond that of shift-warping. The LTM satisfies this need for additional flexibility. We also provide details on the finite sample performance of our methods on the fits of both the latent curves and the realizations of the full process.
Pre-smoothing of curves was performed using local linear regression with the Epanechnikov kernel and the number of knots was set at $K=4$. We note that the choice of this hyperparameter did not drastically change the quality of estimates in practice unless it was set at a blatantly low value $(K\leq2)$, which then resulted in lack of fit, or raised excessively high $(K\geq7)$, which distorted the estimates of warping functions.
Estimates were obtained from fitting the model on a sample of $n=50$ $4-$dimensional processes at each noise level. This process was repeated for $B=250$ Monte Carlo runs and the results are summarized in terms of performance measures, including integrated squared errors for the estimated latent curve, component warps, and fitted processes,
\begin{align}
\begin{split}
\textit{LISE} = \int_0^1 \{\hat{\lambda}(t) -\lambda(t)\}^2dt, &~~
\textit{HMISE} = \frac{1}{n}\sum_{i=1}^n \int_0^1 \{\hat{H}_{i}(t)-H_{i}(t)\}^2dt,~ \text{and} \\
\textit{XMISE} = \frac{1}{np}\sum_{j=1}^p \sum_{i=1}^n &\int_0^1 \{\hat{X}_{ij}(t)-X_{ij}(t)\}^2dt, \quad \text{for}\quad j,k=1,\dots,p.
\label{eq:perform}
\end{split}
\end{align}
Tables $\ref{tab:sim_lambda} - \ref{tab:sim_fit}$ depict these quantities based on samples generated at each noise level.
For ease of reading, the quantities \textit{LISE} and \textit{HMISE} are magnified by a factor of $10^2$.
Table $\ref{tab:sim_lambda}$ shows that estimation of the latent curve $\lambda$ generally degrades with increased warping and nuisance distortion levels. Interestingly the effect of these distortions is comparable between levels when warping and nuisance distortions are 0 and 0.5, but jumps when warping or nuisance levels increase to 1, which reflects a severe amount of phase variation in terms of the warping distortion level. Effects on the integrated squared error for the latent curve are similar for both sources of distortion, $\sigma_W$ and $\sigma_D$. Increases in measurement error on the other hand do not seem to affect the quality of the estimate of $\lambda$ much. A potential explanation for this is the fact that the estimator of $\lambda$ is a global average, so additive measurement errors tend to cancel each other out.
{\renewcommand{\arraystretch}{1.2}
\begin{table}[!h]
\caption{\label{tab:sim_lambda} Integrated squared error of the latent curve estimates under simulated noise settings, magnified by factor of 100.}
\centering
\begin{tabular}{cccccc}
\multicolumn{2}{c}{\textit{LISE} $\times~ 10^2$}&\multicolumn{4}{c}{\textit{Measurement Error}}\\
\hline
\textit{Warping Distortion} & \textit{Nuisance Distortion}& $\sigma_{E}=0$& $\sigma_{E}=1$ & $\sigma_{E}=5$ & $\sigma_{E}=10$\\
\hline
\multirow{3}{*}{$\sigma_{W}=0$}& $\sigma_{D}=0.0$& 0.01 & 0.01 & 0.01 & 0.01 \\
&$\sigma_{D}=0.5$ & 0.00 & 0.00 & 0.01 & 0.01 \\
&$\sigma_{D}=1.0$& 0.09 & 0.08 & 0.06 & 0.08 \\
\hline
\multirow{3}{*}{$\sigma_{W}=0.5$} &$\sigma_{D}=0.0$& 0.01 & 0.01 & 0.01 & 0.01 \\
&$\sigma_{D}=0.5$ & 0.01 & 0.01 & 0.01 & 0.02 \\
&$\sigma_{D}=1.0$ & 0.10 & 0.09 & 0.07 & 0.09 \\
\hline
\multirow{3}{*}{$\sigma_{W}=1$} &$\sigma_{D}=0.0$& 0.11 & 0.10 & 0.08 & 0.10 \\
&$\sigma_{D}=0.5$& 0.13 & 0.11 & 0.09 & 0.11 \\
&$\sigma_{D}=1.0$ & 0.32 & 0.31 & 0.28 & 0.31 \\
\hline
\end{tabular}
\end{table}
}
As for the estimates of the subject-specific warping functions $H$, we see a similar trend across both kinds of distortion (Table $\ref{tab:sim_warp}$). As $\sigma_W$ increases, the warping function targets have a greater likelihood to be more extreme warps, which are harder to estimate. In addition the bias imposed by regularization is greater for these extreme cases. As expected, greater nuisance distortion also degrades performance. Measurement error is associated with generally worse performance, in contrast to its effect on the estimation of $\lambda$. Since the warping functions $H$ are subject-specific, and not averaged over the sample, they do not enjoy the robustness to measurement error that the latent curve displays.
{\renewcommand{\arraystretch}{1.2}
\begin{table}[t]
\caption{Mean integrated squared error (magnified by $10^2$) of the subject-level warping estimates $\hat{H}_i(t)$ under simulated noise settings.}
\label{tab:sim_warp}
\centering
\begin{tabular}{cccccc}
\multicolumn{2}{c}{\textit{HMISE} $\times~ 10^2$}&\multicolumn{4}{c}{\textit{Measurement Error}}\\
\hline
\textit{Warping Distortion} & \textit{Nuisance Distortion}& $\sigma_{E}=0$& $\sigma_{E}=1$ & $\sigma_{E}=5$ & $\sigma_{E}=10$\\
\hline
\multirow{3}{*}{$\sigma_{W}=0$}& $\sigma_{D}=0.0$& 0.00 & 0.00 & 0.01 & 0.02 \\
&$\sigma_{D}=0.5$ &0.02 & 0.02 & 0.02 & 0.03 \\
&$\sigma_{D}=1.0$& 0.15 & 0.15 & 0.12 & 0.10 \\
\hline
\multirow{3}{*}{$\sigma_{W}=0.5$} &$\sigma_{D}=0.0$& 0.00 & 0.00 & 0.01 & 0.02 \\
&$\sigma_{D}=0.5$ & 0.02 & 0.02 & 0.02 & 0.03 \\
&$\sigma_{D}=1.0$ & 0.15 & 0.15 & 0.12 & 0.11 \\
\hline
\multirow{3}{*}{$\sigma_{W}=1$} &$\sigma_{D}=0.0$& 0.12 & 0.12 & 0.13 & 0.21 \\
&$\sigma_{D}=0.5$& 0.14 & 0.13 & 0.15 & 0.22 \\
&$\sigma_{D}=1.0$ & 0.29 & 0.28 & 0.31 & 0.38 \\
\hline
\end{tabular}
\end{table}
}
Finally, performance measures for the sample of fitted curves are displayed in Table $\ref{tab:sim_fit}$. Mean integrated squared errors for fitted curves $X_{ij}$ can be thought of as a composite measure of the errors in estimates of the latent curve $\lambda$, component transports $\Psi_j$, individual warps $H_i$, and amplitude factors $A_{ij}$. Note that the amplitude factors vary substantially between components
and therefore the errors for fitted curves are much larger than that of the latent curve and warping functions.
The various distortions are seen to have a slightly different effect on \textit{XMISE} as compared to \textit{LISE} and \textit{HMISE}. Again, larger warping and nuisance distortions result in worse performance, however in the case of fitted curves, there is a difference between warping and nuisance distortion. Increasing the level of warping distortion $\sigma_W$ has less of an impact on \textit{XMISE} than does increasing that of nuisance distortion $\sigma_D$. For example, in the case of no measurement error, increasing $\sigma_D$ from 0 to 0.5 results in a roughly 175-fold increase in \textit{XMISE}, while a similar change in $\sigma_W$
increases the error by a factor of 6.5. A similar pattern occurs over all levels of measurement error. This observation suggests that increased nuisance distortion degrades the estimation of the component transports $\Psi_j$, as this effect is not present in the estimation of $\lambda$ or $H$, and the amplitude factors are invariant to distortion effects of all kinds. Measurement errors have a similar effect as for \textit{HMISE}, which again may be explained by the fact that fitted curves are subject-specific.
{\renewcommand{\arraystretch}{1.2}
\begin{table}[!ht]
\caption{Mean integrated squared error of the fitted curve estimates $\hat{X}_{ij}(t)$ under simulated noise settings. Note the increase in scale of the \textit{XMISE} when compared to \textit{LISE} and \textit{HMISE} is due to the fact that curves are scaled up by the amplitude factor which varies randomly around the value 100.}
\label{tab:sim_fit}
\centering
\begin{tabular}{cccccc}
\multicolumn{2}{c}{\textit{XMISE}}&\multicolumn{4}{c}{\textit{Measurement Error}}\\
\hline
\textit{Warping Distortion} & \textit{Nuisance Distortion}& $\sigma_{E}=0$& $\sigma_{E}=1$ & $\sigma_{E}=5$ & $\sigma_{E}=10$\\
\hline
\multirow{3}{*}{$\sigma_{W}=0$}& $\sigma_{D}=0.0$& 0.04 & 0.50 & 13.09 & 57.19 \\
&$\sigma_{D}=0.5$ & 6.97 & 7.35 & 20.05 & 63.65 \\
&$\sigma_{D}=1.0$& 80.98 & 81.50 & 92.78 & 140.97 \\
\hline
\multirow{3}{*}{$\sigma_{W}=0.5$} &$\sigma_{D}=0.0$& 0.26 & 0.74 & 13.32 & 57.37 \\
&$\sigma_{D}=0.5$ & 7.11 & 7.54 & 20.14 & 63.81 \\
&$\sigma_{D}=1.0$ & 80.75 & 81.84 & 93.75 & 143.37 \\
\hline
\multirow{3}{*}{$\sigma_{W}=1$} &$\sigma_{D}=0.0$& 17.35 & 19.22 & 34.28 & 91.97 \\
&$\sigma_{D}=0.5$& 25.48 & 25.20 & 42.68 & 98.38 \\
&$\sigma_{D}=1.0$ &104.60 & 102.80 & 120.65 & 181.99 \\
\hline
\end{tabular}
\end{table}
}
\section{THEORETICAL RESULTS}
\label{sec:theory}
Our results focus on convergence of the components of the XCT model described in (4) as the number of curves $n$ and the number of observations per curve $m$ tend to infinity. We require the following assumptions on (L) the components of the Latent Transport Model and (S) the smoothing methodology in the presence of discrete observations with measurement error.
\begin{enumerate}[label=(L\arabic*), mode=unboxed]
\setcounter{enumi}{0}
\item The latent curve $\lambda(t) \in C^2(D)$ is a bounded function. For any non-degenerate interval $\mathcal{T}_0\subset \mathcal{T}, ~0<\int_{\mathcal{T}_0}\lambda'(t)^2dt < \infty$.
\item For $j=1,\dots,p$, $\underset{1\leq i \leq n}{\sup} ~A_{ij} = \mathcal{O}_P(1)$ and $\underset{1\leq i \leq n}{\sup} ~A^{-1}_{ij} = \mathcal{O}_P(1)$.
\end{enumerate}
Assumption (L1) bounds the latent curves and its derivatives and ensures there are no flat stretches, ensuring identifiability of the model components.
(L2) ensures that the ranges of the random processes are bounded away from zero and infinity with high probability; this condition is needed for the uniform convergence of the smoothing estimate.
\begin{enumerate}[label=(S\arabic*), mode=unboxed]
\setcounter{enumi}{-1}
\item The time points $t_1,\dots,t_m$, where the sequence $m$ is assumed to depend on the sample size $n$, $m=m(n)$, correspond to a dense regular design with smooth design density $f$ with $\underset{t \in \mathcal{T}}{\inf }f(t)>0$ that generates the time points according to $t_s = F^{-1}(\frac{s-1}{m-1}), ~s=1,\dots,m,$ where $F^{-1}$ denotes the quantile function associated with $f$. The second derivative $f''$ is bounded, $\underset{t \in \mathcal{T}^\circ}{\sup}|f''(t)|<\infty$.
\item The kernel function $K$ is a probability density function with support $[-1,1]$, symmetric around zero, and uniformly continuous on its support, with $\int_{-1}^1 K^2(u)du<\infty$.
\item For each $j=1,\dots,p$, the sequences $m = m(n)$ and $b = b(n)$ satisfy (1) $0<b< \infty$, and (2) $m\to\infty$, $b\to0$, and $mb^2(\log b)^{-1}\to\infty$ as $n\to\infty$.
\end{enumerate}
\noindent These assumptions guarantee the consistent estimation of $n$ curves simultaneously, as shown in the following Proposition. We observe that (S2) is for example satisfied if the bandwidth sequence is chosen such that $b=b(n) \sim m(n)^{-1/6}$.
We next establish the rate of convergence for the smoothed curves and also the normalized versions to the true underlying processes.
\begin{proposition}
Under assumptions (S0$-$S2), if $E||X^{(\nu)}(t)||_\infty^2<\infty, ~\nu=0,1,2$, we have the uniform convergence
\begin{equation}
\underset{t \in \mathcal{T}}{\sup}|\tilde{X}_{ij}(t)-X_{ij}(t)| = \mathcal{O}_P(m^{-1/3}).
\end{equation}
The rate also extends to the standardized versions $X_{ij}^* = X_{ij}/||X_{ij}||_\infty$,
\begin{equation}
\underset{t \in \mathcal{T}}{\sup}\left|\frac{\tilde{X}_{ij}(t)}{||\tilde{X}_{ij}||_\infty}-\frac{X_{ij}(t)}{||X_{ij}||_\infty}\right| = \mathcal{O}_P(m^{-1/3}).
\end{equation}
\end{proposition}
The estimators of the latent curve and component transports involve averages of the smoothing estimates over the sample of curves as $n\to\infty$. The corresponding rates of convergence will thus rely on the uniform summability of the difference between the smoothed and true curves over $n$ and we then have a uniform rate of $\tau_m=m^{-(1-\delta)/3}$ for an arbitrarily small $\delta>0$ in lieu of the above rate $m^{-1/3}$; see Lemma 1 in the Appendix.
The proposed estimators also rely on the mechanics of the pairwise warping methods, whose convergence properties have been established in a general form in \cite{mull:08:6} and \cite{mull:20}. Lemma 2 in the Appendix states these rates in the specific framework of the Latent Transport Model.
We are now in a position to state our main result, which establishes rates of convergence for the estimators of the components of the Latent Transport Model as follows.
\begin{theorem}
Under assumptions (L1), (L2), and (S0$-$S2), with $\tau_m=m^{-(1-\delta)/3}$ for an arbitrarily small $\delta>0$ and penalty parameters $\eta_1, \eta_2$ as in (\ref{eq:objfun}), (\ref{eq:objfun2}), we have for all $i=1,\dots,n,~j=1,\dots,p$,
a. $\underset{t \in \mathcal{T}}{\sup}|\hat{H}_{i}(t) - H(t)| = \mathcal{O}_P(n^{-1/2}) + \mathcal{O}_P(\tau_m^{1/2})+ \mathcal{O}(\eta_1^{1/2})$,
b. $\underset{t \in \mathcal{T}}{\sup}|\hat{\gamma}_j(t) - \gamma_j(t)| = \mathcal{O}_P(n^{-1/2}) + \mathcal{O}_P(\tau_m^{1/2})+ \mathcal{O}(\eta_1^{1/2}) $
c. $\underset{t \in \mathcal{T}}{\sup}|\hat{\lambda}(t) - \lambda(t)| = \mathcal{O}_P(n^{-1/2})+ \mathcal{O}_P(\tau_m^{1/2})+ \mathcal{O}(\eta_1^{1/2})$,
d. $\underset{t \in \mathcal{T}}{\sup}|\hat{\Psi}_j(t) - \Psi_j(t)| = \mathcal{O}_P(n^{-1/2}) + \mathcal{O}_P(\tau_m^{1/2})+ \mathcal{O}(\max(\eta_1,\eta_2)^{1/2})$,
e. $\underset{t \in \mathcal{T}}{\sup}|\hat{G}_{ij}(t) - G_{ij}(t)| = \mathcal{O}_P(n^{-1/2}) + \mathcal{O}_P(\tau_m^{1/2})+ \mathcal{O}(\max(\eta_1,\eta_2)^{1/2})$, and
f. $|\hat{A}_{ij} - A_{ij}| = \mathcal{O}_P(m^{-1/6}).$
\end{theorem}
The three terms in the rates correspond, in order, to (1) the parametric rate achieved through the standard central limit theorem, (2) the smoothing rate which is dependent on the number of observations per curve $m$, and (3) a rate due to the well-known bias introduced by the penalty parameters used in the regularization steps. Additionally, if we suppose that $m$ is bounded below by a multiple of $n^{3(1-\delta)^{-1}}$, then the rates corresponding to the smoothing steps are bounded above by $n^{-1/2}$. If we take the penalty parameters to be $\eta_1\sim\eta_2=\mathcal{O}(n^{-1})$, a $n^{-1/2}$ rate of convergence can be achieved for each of the estimators in Theorem 1~$a.$-$e.$ Otherwise if $m\sim n^{\Delta(1-\delta)^{-1}}$, for any $\Delta<3$, the convergence is limited by the smoothing step and achieves the rate of $n^{-\Delta/6}$. This line of reasoning gives the following result for curves which are observed fully or on sufficiently dense designs.
\begin{corollary}
If the penalty parameters satisfy $\eta_1\sim\eta_2=\mathcal{O}(n^{-1})$ and the random trajectories are fully observed without error or the trajectories are recorded with at least a multiple of $m\sim n^{\Delta(1-\delta)^{-1}}$ observations per curve, with $\Delta>3$, then under the assumptions of Theorem 1, we have for~all~$i=1,\dots,n,~j=1,\dots,p$,
a. $\underset{t \in \mathcal{T}}{\sup}|\hat{H}_{i}(t) - H(t)| = \mathcal{O}_P(n^{-1/2})$,
b. $\underset{t \in \mathcal{T}}{\sup}|\hat{\gamma}_j(t) - \gamma_j(t)| = \mathcal{O}_P(n^{-1/2}) $
c. $\underset{t \in \mathcal{T}}{\sup}|\hat{\lambda}(t) - \lambda(t)| = \mathcal{O}_P(n^{-1/2})$,
d. $\underset{t \in \mathcal{T}}{\sup}|\hat{\Psi}_j(t) - \Psi_j(t)| = \mathcal{O}_P(n^{-1/2})$,
e. $\underset{t \in \mathcal{T}}{\sup}|\hat{G}_{ij}(t) - G_{ij}(t)| = \mathcal{O}_P(n^{-1/2})$, and
f. $|\hat{A}_{ij} - A_{ij}| = \mathcal{O}_P(n^{-1/2}).$
\end{corollary}
The asymptotic results for the cross-component transports then follow immediately from the rates established in Theorem 1.
\begin{theorem}
Under assumptions of Theorem 1 for~~$i=1,\dots,n,~1\leq j,k\leq p$,
a.
$\underset{t \in \mathcal{T}}{\sup}|\hat{T}_{jk}(t)- T_{jk}(t)| = \mathcal{O}_P(n^{-1/2}) + \mathcal{O}_P(\tau_m^{1/2})+ \mathcal{O}( \max(\eta_1,\eta_2)^{1/2}),$\quad\text{and}
b. $\underset{t \in \mathcal{T}}{\sup}|\hat{T}^{(i)}_{jk}(t)- T^{(i)}_{jk}(t)| = \mathcal{O}_P(n^{-1/2}) + \mathcal{O}_P(\tau_m^{1/2})+ \mathcal{O}( \max(\eta_1,\eta_2)^{1/2}).$
\end{theorem}
A similar corollary for cross-component transports follows in the case of fully observed curves or dense enough designs.
\begin{corollary}
If the penalty parameters satisfy $\eta_1\sim\eta_2=\mathcal{O}(n^{-1})$ and the random trajectories are fully observed without error or are recorded with at least a multiple of $m\sim n^{\Delta(1-\delta)^{-1}}$ observations per curve, with $\Delta>3$, then under the assumptions of Theorem 1, we have for~~$i=1,\dots,n,~1\leq j,k\leq p$,
a. $\underset{t \in \mathcal{T}}{\sup}|\hat{T}_{jk}(t)- T_{jk}(t)| = \mathcal{O}_P(n^{-1/2}),$\quad\text{and}
b. $\underset{t \in \mathcal{T}}{\sup}|\hat{T}^{(i)}_{jk}(t)- T^{(i)}_{jk}(t)| = \mathcal{O}_P(n^{-1/2}).$
\end{corollary}
Corollaries 1 and 2 suggest that, on dense enough measurement schedules, parametric rates of convergence are achievable for the components of the LTM. The collection of cross-component transports also exhibit the following algebraic structure.
\begin{remark}
For any cycle of components indexed by the sequence, $$\pi_1\to \pi_2\to \pi_3\to\dots \to \pi_L\to \pi_1,$$ with arbitrary length $L$ and $\pi_1,\dots,\pi_L\in \{1,\dots, p\}$, their respective cross-component transports satisfy
$$T_{\pi_1\pi_2} \circ T_{\pi_2\pi_3} \circ \dots \circ T_{\pi_L\pi_1} = id.$$
\end{remark}
\noindent This result ensures that the system of cross-component transport maps is free of internal inconsistencies. For example, if for three components $A$, $B$, and $C$, the pairwise transports $T_{AB}$ and $T_{BC}$ suggest that Component $A$ tends to precede Component $B$ which itself tends to precede Component $C$, this implies that the transport $T_{AC}$ must indicate that Component $A$ tends to precede Component $C$. Furthermore, mapping a component tempo through other components and then back to itself will result in the original component tempo, unchanged.
Next we consider the convergence rates of reconstructed curves as per (\ref{eq:recon}), putting all model components together.
\begin{theorem}
Under assumptions of Theorem 1 for~~$i=1,\dots,n,~j=1,\dots ,p$,
$$\underset{t \in \mathcal{T}}{\sup}|\hat{X}_{ij}(t)-X_{ij}(t)|= \mathcal{O}_P(n^{-1/2}) + \mathcal{O}_P(\tau_m^{1/2})+ \mathcal{O}( \max(\eta_1,\eta_2)^{1/2}).$$
\end{theorem}
Again a parametric rate is achievable on dense enough designs.
\begin{corollary}
If the penalty parameters satisfy $\eta_1\sim\eta_2=\mathcal{O}(n^{-1})$ and the random trajectories are fully observed without error or the trajectories are recorded with at least a multiple of $m\sim n^{\Delta(1-\delta)^{-1}}$ observations per curve, with $\Delta>3$, then under the assumptions of Theorem 1, we have for~$i=1,\dots,n,~j=1,\dots,p$,
$$\underset{t \in \mathcal{T}}{\sup}|\hat{X}_{ij}(t)-X_{ij}(t)|= \mathcal{O}_P(n^{-1/2}).$$
\end{corollary}
\section{CONCLUDING REMARKS}
In this paper we have introduce the Latent Transport Model (LTM) to represent and decompose multivariate functional data and to quantify their inter-component time dynamics. This model is an attractive alternative to current functional principal component based models and provides a simple representation for multivariate functional data that exhibit subject-specific and inter-component warping: Information concerning their time dynamics is synthesized and compressed into two fixed effect terms (the latent curve and a collection of component-level warping functions) and two random effect terms (a random amplitude vector and a collection of subject-level warping functions). This representation requires the estimation of only one random warping function and amplitude vector per subject, in addition to $p+1$ deterministic functions overall.
In some cases these components may be reduced even further. For example, when subject-level warping is negligible or part of a pre-processing step, a special case of the model arises in which time-dynamics are fully characterized by the $p+1$ fixed effect curves and one random scalar per component. Alternatively, if subject-level time warping is present but further dimension reduction is desired, transformation of warps by the LQD (or an alternative) transformation \citep{mull:16:1}
permits a Karhunen-Lo\`eve expansion in $\mathcal{L}^2-$space. Applying the LTM and truncating this expansion at an appropriate number of eigenfunctions, say $K_0$, creates a representation of multivariate functional data using only $p+K_0$ random scalars, as opposed to, for example, a standard FPCA representation which requires $p\times K_0$ variables.
The LTM serves both as an extension of existing univariate functional warping methods, as well as a model class for multivariate functional data analysis and registration. Future directions of note include implementing the LTM for alternative alignment algorithms besides pairwise warping, harnessing the flexibility of cross-component transport maps for imputation of components in partially observed multivariate functional data, or relaxing structural assumptions to allow for more flexible functional relationships between different latent curves for distinct subsets of components. Spatiotemporal applications are also promising for the LTM, in which the vector function components are indexed by location, as long as repeated observations are available. In such a situation, component warping functions may reveal time trends across geographic regions. In areas like spatiotemporal data analysis where the number of vector components is high, downstream application of dimension reduction techniques like multidimensional scaling may prove useful in comparing and understanding the mutual time dynamics across a large number of components.
\bibliography{syncfunc.bib}
\newpage
| {'timestamp': '2021-07-14T02:04:28', 'yymm': '2107', 'arxiv_id': '2107.05730', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05730'} | arxiv |
\section{Missing Proofs}
\subsection{Proof of \Cref{thm:path}}
\label{apd: Proof of thm:path}
\begin{definition}
We say that a matrix $A$ is \emph{totally unimodular} iff the determinant of every square submatrix of $A$ belongs to $\{0,-1,+1\}$.
\end{definition}
\begin{lemma}[Forklore]
\label{lem:forklore}
If a matrix $A\in \mathbb{R}^{m\times n}$ is totally unimodular and a vector $b\in\mathbb{R}^m$ is integral, then every extreme point of the polytope $\{x\in \mathbb{R}^n\mid Ax\leq b, x\geq 0\}$ is integral.
\end{lemma}
We show in the following lemma that the coefficient matrix in (LP-Primal) is totally unimodular, so (LP-Primal) has an integral optimal solution, and then \Cref{thm:path} follows from \Cref{lem:rounding}.
\begin{lemma}\label{lem:primal-tu}
The coefficient matrix $C$ in (LP-Primal) is totally unimodular.
\end{lemma}
\begin{proof}
We use the following Lemma from \cite{schrijver1998theory}.
\begin{lemma}[\!\!\cite{schrijver1998theory}] \label{lem:proposition-tu}
A matrix $A\in \mathbb{R}^{m\times n}$ is totally unimodular iff for any subset $R\subseteq [n]$, there exists a partition $R=R_1\cup R_2$, $R_1\cap R_2=\emptyset$, such that for any $j\in [m]$,
$$\sum_{i\in R_1}a_{ij}-\sum_{i\in R_2}a_{ij}\in \{0,-1,+1\}.$$
\end{lemma}
According to (LP-Primal), for all $i\in [m]$ and $j\in [n]$, $C_{ij}=1$ iff $e_i\in Q_j$. Let $R=\set{i_1,\ldots,i_k}$ be a subset of $[n]$ where $1\leq i_1<i_2<\ldots<i_k\leq n$.
We define $R_1=\{i_1,i_3,i_5,\ldots\}$ and $R_2=\{i_2,i_4,i_6,\ldots\}$.
Consider now any $j\in [n]$.
Since $Q_j$ is a path in graph $G$, the $1$-entries in $(C_{ij})_{i=1}^n$, the $j$th column of $C$, appear consecutively.
Therefore, the difference between $\sum_{i\in R_1}C_{ij}$ and $\sum_{i\in R_2}C_{ij}$ is at most 1.
From Lemma~\ref{lem:proposition-tu}, matrix $C$ is totally unimodular.
\end{proof}
\section{Missing Details from Section~\ref{sec: general graph}}\label{sec:appx_general_graph}
\subsection{Proof of Theorem~\ref{thm:bounded-degree-mahua}}
\notshow{
The graph $G=R_{a,b}$ that we will use is slightly modified from graph $H_{a.b}$, by replacing each high-degree vertex with a gadget:
Consider a high-degree vertex $v_i\in V(H_{a,b})$. Recall that it has $2a$ incident edges $\set{(v_i,u_{i,j}),(v_i,u_{i+1,j})\mid j\in [a]}$ in graph $H_{a,b}$ (see \Cref{fig:gadget_before}). The gadget for vertex $v_i$ is constructed as follows. We first place the vertices $u_{i,1},\ldots,u_{i,a},u_{i+1,1}\ldots,u_{i+1,a}$ on a circle in this order, and then for each $j\in [a]$, we draw a line segment connecting $u_{i,j}$ with $u_{i+1,j}$, such that every pair of these segments intersects, and no three segments intersect at the same point. We then replace each intersection with a new vertex. See Figure~\ref{fig:gadget_after} for an illustration.
\begin{figure}[htb]
\centering
\subfigure[The vertex $v_i$ and its incident edges in $H_{a,b}$. ]{\scalebox{0.26}{\includegraphics{gadget_before.jpg}}\label{fig:gadget_before}}
\hspace{1pt}
\subfigure[The gadget graph $K_i$.]{\scalebox{0.26}{\includegraphics{gadget_after.jpg}}\label{fig:gadget_after}}
\caption{An illustration of the gadget construction.}\label{fig:gadget}
\end{figure}
\iffalse
The two properties in the constructed value profile in the proof of Theorem~\ref{thm:lb-mahua} that are influenced by such gadget replacement are as follows:
\begin{enumerate}
\item There are $a$ parallel paths in the optimal offline allocation that use each edge in the graph exactly once.
\item For any large enough index set $S\subseteq[a]$, there are $2|S|$ paths not in optimal offline allocation such that for each $k\in S$ and segment $j$, the $k$th edge in segment $j$ appears exactly twice in this set of paths.
\end{enumerate}
If after all terminal vertices are replaced by the gadget graphs both properties can still hold, the proof of Theorem~\ref{thm:lb-mahua} can still go through.
\fi
}
\section{Missing Details from Section~\ref{sec:no_tie_breaking}}\label{sec:appx_no_tie_breaking}
\subsection{Missing Details from Section~\ref{sec:pathnt}}\label{sec:appx_no_tie_path}
\begin{prevproof}{Theorem}{thm: path_no_tie_lower_bound}
Let $G$ be a path consisting of three edges $e_1,e_2,e_3$, that appears on the path in this order. The instance is described below.
\begin{itemize}
\item Buyer 1 demands the path consisting of a single edge $e_1$, with value $1$;
\item Buyer 2 demands the path consisting of a single edge $e_3$, with value $1$;
\item Buyer 3 demands the path consisting of edges $e_1,e_2$, with value $2$; and
\item Buyer 4 demands the path consisting of edges $e_2,e_3$, with value $2$.
\end{itemize}
\iffalse
\begin{table}[H]
\centering
\begin{tabular}{ c|c|c}
Buyer & Demand & Value \\
\hline
$B_1$ & $e_1$ & 1 \\
\hline
$B_2$ & $e_3$ & 1 \\
\hline
$B_3$ & $e_1,e_2$ & 2\\
\hline
$B_4$ & $e_2,e_3$ & 2
\end{tabular}
\label{table:example_path}
\caption{Example for Path Graph}
\end{table}
\fi
It is clear that the optimal allocation is assigning $e_1$ to buyer 1 and $e_2,e_3$ to buyer 4 (or assigning $e_3$ to buyer 2 and $e_1,e_2$ to buyer 3). The optimal welfare $\mathsf{OPT}(G,\mathcal{F})=3$.
We now show that, for any prices $p_1,p_2,p_3$, there is an order $\sigma$ of the four buyers such that the obtained welfare is at most $2$, when the seller has no tie-breaking power. We distinguish between two cases.
\textbf{Case 1. $p_1\leq 1$ and $p_3\leq 1$.} We let buyers 1 and 3 come first and take edges $e_1$ and $e_3$ respectively. Note that the seller does not have the tie-breaking power. So the buyer can decide whether or not to take the path when the price equals the value. Now buyers 3 and 4 cannot get their paths. So the obtained welfare is $2$.
\textbf{Case 2. $p_1>1$ or $p_3>1$.} Assume without loss of generality that $p_1>1$. If $p_2+p_3\leq 2$, then we let buyer 4 come first and take edges $e_2$ and $e_3$. It is clear that no other buyer can get her path. So the total welfare is 2. If $p_2+p_3>2$, then $p_1+p_2+p_3>3$. Note that it is impossible in this case all edges are sold, since the hindsight optimal welfare is 3. Therefore, the obtained welfare is at most $2$.
\end{prevproof}
\begin{prevproof}{Lemma}{lem:price-strictly-positive}
Let $\varepsilon'=\frac{1}{n^2}\cdot\min_jv_j$. We construct another instance $\mathcal{F}'$ from $\mathcal{F}$ as follows. We add, for each $e\in E(G)$ a new buyer demanding the path consisting of a single edge $e$ with value $\varepsilon'$.
On one hand, it is easy to see that $y^*$ is still an optimal solution of this new instance. Let $p^*$ be any optimal solution for the corresponding dual LP for the new instance $\mathcal{F}$. Define $\varepsilon''=\frac{1}{2n}\min_{j:p*(Q_j)>v_j}(p^*(Q_j)-v_j)$ and $\varepsilon'=\min\{\varepsilon',\varepsilon''\}$. Clearly $p^*$ is also an optimal dual solution for the instance $\mathcal{F}$ and satisfies both properties.
\end{prevproof}
\begin{prevproof}{Lemma}{claim:covering_implies_optimal}
We denote $I=\bigcup_{j:Q_j\in \mathcal{Q}}Q_j$ and $\mathcal{Q}_I=\{Q_j\in \mathcal{Q}_A\mid Q_j\subseteq I\}$.
First, for each edge $e\notin E(I)$, we set its price $p(e)=+\infty$.
We will show that we can efficiently compute prices $\set{p(e)}_{e\in E(I)}$ for edges of $I$, such that (i) for each path $Q_j\in \mathcal{Q}$, $v_j>p(Q_j)$; (ii) for each path $Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}$, $v_j<p(Q_j)$; and (iii) $|p(e)-p^*(e)|\leq \varepsilon$, for every $e\in E(I)$.
Consider the item pricing $p$ which satisfies all three properties. By property (iii) and Lemma~\ref{lem:price-strictly-positive}, any buyer $j\not\in A$ can not afford her path, since $p(Q_j)\geq p^*(Q_j)-n\varepsilon>v_j$.
It is clear that the set $\set{p(e)}_{e\in E(G)}$ of prices achieves worst-case welfare $\sum_{Q_j\in \mathcal{Q}}v_j$. For buyers in $A$, according to the first two properties, only buyers $j$ where $Q_j\in \mathcal{Q}$ can purchase their demands. Thus the worst-case welfare is $\sum_{j:Q_j\in \mathcal{Q}}v_j$.
The existence of prices $\set{p(e)}_{e\in E(I)}$ that satisfy (i), (ii) is equivalent to the feasibility of the following system.
\begin{equation}\label{lp:covering-primal}
\left\{
\begin{array}{cccc}
\displaystyle \sum_{e\in Q_j}p(e) &< & v_j,&\forall Q_j\in\mathcal{Q};\\
\displaystyle \sum_{e\in Q_j}p(e) & >& v_j,&\forall Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}.
\end{array}
\right.
\end{equation}
From the definition of $A$, and since $\mathcal{Q}_I\subseteq\mathcal{Q}_A$, for each path $Q_j\in \mathcal{Q}_I$, $\sum_{e\in Q_j}p^*(e)= v_j$.
We denote $\alpha(e)=p(e)-p^*(e)$ for all $e\in E(I)$, then system~\eqref{lp:covering-primal} is feasible if the following system is feasible, for some small enough $\varepsilon'>0$.
\begin{equation}\label{lp:covering-primal2}
\left\{
\begin{array}{cccc}
\displaystyle \sum_{e\in Q_j}\alpha(e) &\le & -\varepsilon',&\forall Q_j\in\mathcal{Q};\\
\displaystyle \sum_{e\in Q_j}\alpha(e) & \ge & \varepsilon',&\forall Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}.
\end{array}
\right.
\end{equation}
\iffalse
Then system~\eqref{lp:covering-primal2} is feasible if and only if the following system is feasible, for a small enough constant $\sigma>0$.
\begin{equation}\label{lp:covering-primal3}
\left\{
\begin{array}{cccc}
\displaystyle \sum_{e\in Q_j}\alpha(e) &\le & -\sigma,&\forall Q_j\in\mathcal{Q};\\
\displaystyle \sum_{e\in Q_j}-\alpha(e) & \leq & -\sigma,&\forall Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}.
\end{array}
\right.
\end{equation}
\fi
From Farkas' Lemma,
system~\eqref{lp:covering-primal2} is feasible if and only if the following system is infeasible.
\begin{equation}\label{lp:covering-dual}
\left\{
\begin{array}{rccc}
\displaystyle \sum_{j:Q_j\in \mathcal{Q}}\beta_j\cdot\mathbbm{1}[e\in Q_j]-\sum_{j:Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}}\beta_j\cdot\mathbbm{1}[e\in Q_j] &=& 0,&\forall e\in E(I);\\
\displaystyle\sum_{j:Q_j\in \mathcal{Q}_I}\beta_j&>& 0;\\
\beta_j & \in & [0,1],&\forall Q_j\in \mathcal{Q}_I.
\end{array}
\right.
\end{equation}
where the additional constraints $\beta_j\le 1, \forall Q_j\in \mathcal{Q}_I$ will not influence the feasibility of the system due to scaling.
Next we will prove that system \eqref{lp:covering-dual} is feasible iff it admits an integral solution.
\begin{definition}
We say that a matrix $A$ is \emph{totally unimodular} iff the determinant of every square submatrix of $A$ belongs to $\{0,-1,+1\}$.
\end{definition}
\begin{lemma}[Forklore]
\label{lem:forklore}
If a matrix $A\in \mathbb{R}^{m\times n}$ is totally unimodular and a vector $b\in\mathbb{R}^m$ is integral, then every extreme point of the polytope $\{x\in \mathbb{R}^n\mid Ax\leq b, x\geq 0\}$ is integral.
\end{lemma}
\begin{lemma}[\cite{schrijver1998theory}] \label{lem:proposition-tu}
A matrix $A\in \mathbb{R}^{m\times n}$ is totally unimodular iff for any subset $R\subseteq [n]$, there exists a partition $R=R_1\cup R_2$, $R_1\cap R_2=\emptyset$, such that for any $j\in [m]$,
$$\sum_{i\in R_1}a_{ij}-\sum_{i\in R_2}a_{ij}\in \{0,-1,+1\}.$$
\end{lemma}
\begin{lemma}\label{lem:covering-integral-solu}
System~\eqref{lp:covering-dual} is feasible if and only if it admits an integral solution.
\end{lemma}
\begin{proof}
We prove that the coefficient matrix $C$ in system \eqref{lp:covering-dual} is totally unimodular.\footnote{The second inequality in system \eqref{lp:covering-dual} is strict inequality. We can modify it to an equivalent inequality $\sum_{j:Q_j\in \mathcal{Q}}\beta_j\geq \varepsilon_0$ for some sufficiently small $\varepsilon_0>0$ and then apply Lemma~\ref{lem:forklore}.} For any set of rows $R=\{i_1,i_2,\cdots,i_k\}$ such that $i_1<i_2<\cdots<i_k$, We define the partition $R_1=\{i_1,i_3,i_5,...\}$ be the set with odd index and $R_2=\{i_2,i_4,i_6,...\}$ be the set with even index. For every column $j$, $Q_j$ is an subpath and thus the ones (or -1s for $Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}$) in the vector $(C_{ij})_{i=1}^n$ are consecutive. Hence the difference between $\sum_{i\in R_1}C_{ij}$ and $\sum_{i\in R_2}C_{ij}$ is at most 1. By Lemma~\ref{lem:proposition-tu}, $C$ is totally unimodular.
\end{proof}
Assume for contradiction that \eqref{lp:covering-dual} is feasible, let $\beta^*\in \set{0,1}^{\mathcal{Q}_I}$ be an integral solution of \eqref{lp:covering-dual}.
Note that the constraints
$\sum_{j:Q_j\in \mathcal{Q}}\beta^*_j\cdot\mathbbm{1}[e\in Q_j]-\sum_{j:Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}}\beta^*_j\cdot\mathbbm{1}[e\in Q_j] = 0,\forall e\in E(I)$ and the fact that paths of $\mathcal{Q}$ are edge-disjoint
imply that the paths in set $\mathcal{Q}'=\{Q_j\mid \beta_j=1\}$ are edge-disjoint. Note that $\mathcal{Q}'\cap\mathcal{Q}=\emptyset$ and $\bigcup_{Q_j\in \mathcal{Q}'}Q_j=\bigcup_{Q_j\in \mathcal{Q}}Q_j$, and this is a contradiction to the assumption that the set $\mathcal{Q}$ is good.
Therefore, system \eqref{lp:covering-dual} is infeasible, and thus system \eqref{lp:covering-primal2} is feasible.
Let $(\alpha(e))_{e\in E(I)}$ be a solution of system~\eqref{lp:covering-primal2}, such that $\sum_{e\in E(I)} |\alpha(e)|\le \varepsilon$. It is clear that such a solution exists due to scaling.
We set $p(e)=p^*(e)+\alpha(e)$ for all $e\in E(I)$, and it is clear that the prices $\set{p(e)}_{e\in E(G)}$ satisfy all the properties of \Cref{claim:covering_implies_optimal}.
Moreover, prices $\set{p(e)}_{e\in E(G)}$ are positive.
\end{prevproof}
\begin{prevproof}{Theorem}{thm:path_no_tie}
We complete the proof of Theorem~\ref{thm:path_no_tie} using \Cref{claim:covering_implies_optimal}.
We denote $\mathcal{Q}_Y=\set{Q_1,Q_2,\ldots,Q_k}$, where the paths are indexed according to the order in which they appear on $G$.
First, for each edge $e\notin E(\mathcal{Q}_Y)$, we set its price $\tilde p(e)=+\infty$.
Therefore, any buyer $j$ with $e\in Q_j$ cannot take her demand path.
In fact, we may assume without loss of generality that $\bigcup_{1\le j\le k}Q_j=G$, since otherwise we can view each connected component (which is also a path) of graph $\bigcup_{1\le j\le k}Q_j$ as the whole graph, and compute prices for its edges separately.
We will compute three sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3\subseteq \mathcal{Q}_A$ of edge-disjoint paths, such that
\begin{enumerate}
\item every edge of $E(G)$ is contained in exactly two paths of $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$; and
\item \label{prop: good_cover} for each $t\in \set{1,2,3}$, if we further partition the set $\hat\mathcal{Q}_t$ into subsets $\hat\mathcal{Q}^1_t,\ldots,\hat\mathcal{Q}^{r_t}_t$, such the union of the paths in each set $\hat\mathcal{Q}^1_t$ forms a connected component (which is also a path) of graph $\bigcup_{Q_j\in \hat\mathcal{Q}_t}Q_j$, then each of the sets $\hat\mathcal{Q}^1_t,\ldots,\hat\mathcal{Q}^{r_t}_t$ is a good set of edge-disjoint paths.
\end{enumerate}
By definition, $\sum_{j:Q_j\in \hat\mathcal{Q}_1}v_j+\sum_{j:Q_j\in \hat\mathcal{Q}_2}v_j+\sum_{j:Q_j\in \hat\mathcal{Q}_3}v_j=2\cdot\mathsf{OPT}(G,\mathcal{F})$.
Assume without loss of generality that $\sum_{j:Q_j\in \hat\mathcal{Q}_1}v_j\ge (2/3)\cdot\mathsf{OPT}(G,\mathcal{F})$.
Set prices $\set{\tilde p(e)}_{e\in E(\mathcal{Q}_Y)}$ according to Lemma~\ref{claim:covering_implies_optimal}. And thus the item pricing $\tilde p$ achieves worst-case welfare at least $\sum_{j:Q_j\in \hat\mathcal{Q}_1}v_j\ge (2/3)\cdot\mathsf{OPT}(G,\mathcal{F})$.
\paragraph{Compute the sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$.}
We now compute the desired sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$ of edge-disjoint paths, which, from the above discussion, completes the proof of Theorem~\ref{thm:path_no_tie}.
We start by defining $\hat\mathcal{Q}$ to be the multi-set that contains, for each path $Q_j\in\mathcal{Q}_Y$, two copies $Q'_j,Q''_j$ of $Q_j$.
We initially set
\begin{itemize}
\item $\hat\mathcal{Q}_1=\set{Q'_{6r+3},Q'_{6r+4}\mid 1\le r\le k/6} \cup\set{Q''_{6r},Q''_{6r+1}\mid 1\le r\le k/6}$;
\item $\hat\mathcal{Q}_2=\set{Q'_{6r+1},Q'_{6r+2}\mid 1\le r\le k/6} \cup\set{Q''_{6r+4},Q''_{6r+5}\mid 1\le r\le k/6}$; and
\item $\hat\mathcal{Q}_3=\set{Q'_{6r+2},Q'_{6r+3}\mid 1\le r\le k/6} \cup\set{Q''_{6r+2},Q''_{6r+3}\mid 1\le r\le k/6}$.
\end{itemize}
See Figure~\ref{fig:path-1} for an illustration.
Clearly, sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$ partition $\hat\mathcal{Q}$, each contains edge-disjoint paths, and every edge appears twice in paths of $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$.
However, sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$ may not satisfy Property~\ref{prop: good_cover}.
We will then iteratively modify sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$, such that at the end Property~\ref{prop: good_cover} is satisfied.
Throughout, we also maintain graphs $G_t=\bigcup_{Q\in \hat{\mathcal{Q}}_t}Q$, for each $t\in \set{1,2,3}$. As sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$ change, graphs $G_1,G_2,G_3$ evolve.
We start by scanning the path $G$ from left to right, and process, for each connected component of graphs $G_1,G_2,G_3$, as follows.
\iffalse
\begin{enumerate}
\item No two paths with same color share the same edge;
\item No three contiguous paths have the same color;
\item For each endpoint shared by at most three paths, all of the paths are colored differently;
\item For each endpoint shared by 4 paths, all three colors are used to color these paths, and two paths with the same color are
\begin{enumerate}
\item both from $\mathcal{Q}_Y$, or
\item both from $\mathcal{Q}'_Y:=\mathcal{Q}^*\setminus\mathcal{Q}_Y$, the second copy of the optimal solution.
\end{enumerate}
\end{enumerate}
Such coloring is guaranteed to exist. In fact, for every $Q_j\in \mathcal{Q}_Y$, let $g(Q_j)=j\text{ mod }6$. For every $Q_j'\in \mathcal{Q}_Y'$, let $g(Q_j')=(j+3)\text{ mod }6$. We color a path blue if its $g$-value is 0 or 1, red if its $g$-value is 2 or 3, and green if its $g$-value is 4 or 5. One can easily verify that the above coloring satisfies all the properties.
\fi
We first process the connected component in $G_1$ formed by the single path $Q_1''$. Clearly, set $\set{Q_1''}$ is good, since if there are other paths $\hat Q,\hat Q'\in \mathcal{Q}_A$ such that $\hat Q,\hat Q'$ are edge-disjoint and $\hat Q\cup \hat Q'=Q_1$, then the set $\set{\hat Q,\hat Q',Q_2,\ldots,Q_k}$ corresponds to another integral optimal solution $\hat y^*$ of (LP-Primal) with $\sum_{j\in [m]}\hat y^*_j=k+1>k=\sum_{j\in [m]}\hat y^*_j$, a contradiction to the definition of $y^*$. We do not modify path $Q''_1$ in $\hat{\mathcal{Q}}_1$ and continue to the next iteration.
We then process the connected component in $G_2$ formed by the paths $Q_1',Q_2'$. If the set $\set{Q_1',Q_2'}$ is good, then we do not modify this component and continue to the next iteration. Assume now that the set $\set{Q_1',Q_2'}$ is not good.
From similar arguments, there exist two other paths $Q^*_1,Q^*_2\in \mathcal{Q}_A$, such that $Q^*_1,Q^*_2$ are edge-disjoint and $Q^*_1\cup Q^*_2=Q_1\cup Q_2$.
We then replace the paths $Q'_1,Q'_2$ in $\hat{\mathcal{Q}}_2$ by paths $Q^*_1,Q^*_2$.
Let $v^*_1$ be the vertex shared by paths $Q^*_1,Q^*_2$, so $v^*_1\ne v_1$. We distinguish between the following cases.
\textbf{Case 1. $v^*_1$ is to the left of $v_1$ on path $G$.}
As shown in Figure~\ref{fig:path-2}, we keep the path $Q^*_2$ in $\hat{\mathcal{Q}}_2$, and move path $Q^*_1$ to $\hat{\mathcal{Q}}_3$.
Clearly, we create two new connected components: one in $G_3$ formed by a single path $Q^*_1$, and the other in $G_2$ formed by a single path $Q^*_2$.
From similar arguments, the corresponding singleton sets $\set{Q^*_1}, \set{Q^*_2}$ are good.
\textbf{Case 2. $v^*_1$ is to the right of $v_1$ on path $G$.}
As shown in Figure~\ref{fig:path-4}, we keep the path $Q^*_2$ in $\hat{\mathcal{Q}}_2$, move path $Q^*_1$ to $\hat{\mathcal{Q}}_1$ and additionally move the path $Q'_1$ processed in previous iteration to $\hat{\mathcal{Q}}_2$.
Clearly, we create two new connected components: one in $G_1$ formed by a single path $Q^*_1$, and the other in $G_2$ formed by a single path $Q^*_2$.
From similar arguments, the corresponding singleton sets $\set{Q^*_1}, \set{Q^*_2}$ are good.
Note that we have additionally moved $Q'_1$ to $\hat{\mathcal{Q}}_2$, but since we did not change the corresponding component, the singleton set $\set{Q'_1}$ is still good.
\begin{figure}[htb]
\centering
\subfigure[An illustration of paths in set $\hat{\mathcal{Q}}_1\cup \hat{\mathcal{Q}}_2\cup \hat{\mathcal{Q}}_3$ at the beginning.]{\scalebox{0.4}{\includegraphics{interval_1.jpg}}\label{fig:path-1}}
\subfigure[An illustration of path modification in Case 1.]{\scalebox{0.4}{\includegraphics{interval_2.jpg}}\label{fig:path-2}}
\subfigure[An illustration of path modification in Case 2.]{\scalebox{0.4}{\includegraphics{interval_4.jpg}}\label{fig:path-4}}
\subfigure[How old and new paths/components may possibly interact.]{\scalebox{0.39}{\includegraphics{interval_3.jpg}}\label{fig:path-3}}
\caption{Illustrations of the algorithm for computing path sets $\hat{\mathcal{Q}}_1,\hat{\mathcal{Q}}_2,\hat{\mathcal{Q}}_3$.}
\end{figure}
We continue processing the remaining connected components in the same way until all components are good. We will show that, every time a connected component is not good and the corresponding two paths are replaced with two new paths, the connected components in $G_1,G_2,G_3$ that we have processed in previous iterations will stay good. Therefore, the algorithm will end up producing good components in $G_1,G_2,G_3$ consisting of a good set of one or two edge-disjoint paths.
To see why this is true, consider an iteration where we are processing a component consisting of paths $Q''_i, Q''_{i+1}$, and there exists edge-disjoint paths $Q^*_i,Q^*_{i+1}$ such that $Q^*_i\cup Q^*_{i+1}=Q''_i\cup Q''_{i+1}$, while the endpoint $v^*_i$ shared by $Q^*_i$ and $Q^*_{i+1}$ is an endpoint of a processed component, as shown in Figure~\ref{fig:path-3}.
Note that this is the only possibility that the new components may influence the previous components,
However, we will show that this is impossible.
Note that $Q''_{i}\in \mathcal{Q}_Y$.
We denote by $Q^r$ the path with endpoints $v^*_i$ and $v_i$, then clearly paths $Q^*_i, Q^r$ are not in $\mathcal{Q}_Y$, edge-disjoint and satisfy that $Q_{i}=Q^*_i\cup Q^r$.
Consider now the set $(\mathcal{Q}_Y\setminus \set{Q_{i}})\cup \set{Q^*_i, Q^r}$. It is clear that this set corresponds to another integral optimal solution $\hat y^*$ of (LP-Primal) with $\sum_{j\in [m]}\hat y^*_j=k+1>k=\sum_{j\in [m]}\hat y^*_j$, a contradiction to the definition of $y^*$.
\end{prevproof}
\subsection{Missing Details from Section~\ref{sec:specialgraphsnt}}\label{sec:appx_no_tie_special_graph}
\begin{prevproof}{Theorem}{thm:star}
The optimal allocation can be computed efficiently by ~\cite{tarjan1985decomposition}. Let $\mathcal{Q}$ be the set of paths in the optimal allocation, so $\mathsf{OPT}=\sum_{j:Q_j\in \mathcal{Q}}v_j$.
We set the prices on the edges of $G$ as follows. Let $\varepsilon'=\varepsilon/5$.
For each path $Q_j\in \mathcal{Q}$, if it contains a single edge $e_i$, then we set the price of $e_i$ to be $(1-\varepsilon')\cdot v_j$; if it contains two edges $e_i,e_{i'}$, then we set the price of both $e_i$ and $e_{i'}$ to be $(\frac{1}{2}-\varepsilon')\cdot v_j$.
For each edges that does not belong to any path of $\mathcal{Q}$, we set its price to be $+\infty$.
We now show that the above prices will achieve worst-case welfare at least $(\frac{1}{2}-\varepsilon')\cdot\mathsf{OPT}$. For a path $Q_j$ that contains a single edges $e_i$, clearly $e_i$ will be taken by some buyer (not necessarily $j$) at price $(1-\varepsilon')\cdot v_j$, for any arriving order $\sigma$. For a path $Q_{j'}$ that contains two edges $e_{i},e_{i'}$, we notice that buyer $j'$ can afford her demand path. Thus for any order $\sigma$, at least one of $e_{i},e_{i'}$ will be sold at price $(\frac{1}{2}-\varepsilon')\cdot v_{j'}$, otherwise buyer $j'$ must have purchased $Q_{j'}$. Hence for any order $\sigma$, the total price of the sold edges is at least $(\frac{1}{2}-\varepsilon')\cdot\mathsf{OPT}$. Since all buyers have non-negative utility, the worst-case welfare is also at least $(\frac{1}{2}-\varepsilon')\cdot\mathsf{OPT}\geq \frac{\mathsf{OPT}}{2+\varepsilon}$.
\end{prevproof}
\begin{prevproof}{Theorem}{thm:spider-no-tiebreak}
Let $\mathcal{Q}$ be the set of paths in the optimal allocation.
We define $\mathcal{Q}_1$ to be the set of all paths in $\mathcal{Q}$ that contains the center of the spider, and we define $\mathcal{Q}_2=\mathcal{Q}\setminus \mathcal{Q}_1$. For each path $Q\in \mathcal{Q}_1$, let $j_Q$ be the buyer who is allocated her demand path $Q$ in the optimal allocation. Define $G_Q$ to be the graph obtained by taking the union of all (one or two) legs whose edge sets intersect with $E(Q)$, and we denote $E_Q=E(G_Q)$. Since paths in $\mathcal{Q}_1$ are edge-disjoint, clearly for any $Q,Q'\in \mathcal{Q}_1$, $E_Q\cap E_{Q'}=\emptyset$. For any edge set $E$, let $\mathcal{F}|_E\subseteq \mathcal{F}$ be the sub-instance that contains all buyer $j$ where $Q_j$ has edges only in $E$. Then $\mathsf{OPT}(G,\mathcal{F})=\sum_{Q\in\mathcal{Q}_1}\mathsf{OPT}(G_Q,\mathcal{F}|_{E_Q})$.
Let $e_{Q,1}$ and $e_{Q,2}$ be the two edges that are in Q and has the spider center as one endpoint.\footnote{$e_{Q,1}=e_{Q,2}$ if the spider center is one endpoint of path $Q$.}
Define $G'_Q$ to be the graph with edge set $E'_Q=\{e|e\in E_Q\setminus Q\}$. In other words, $G'_Q$ contains all edges not in $Q$ but in $E_Q$. Clearly we have $\mathsf{OPT}(G_Q,\mathcal{F}|_{E_Q})=\mathsf{OPT}(G'_Q,\mathcal{F}|_{E'_Q})+v_{j_Q}$. Define $G''_Q$ to be the graph with edge set $E''_Q=Q\setminus\{e_{Q,1},e_{Q,2}\}$; in other words, $G''_Q$ is the graph formed edges in $Q$, but excluding the center of the spider. Note that $E_Q=E'_Q\cup E''_Q\cup \{e_{Q,1},e_{Q,2}\}$. See Figure \Cref{fig:spider_proof} for an illustration.
\begin{figure}[h]
\centering
\includegraphics[scale=0.12]{spider_proof.jpg}
\caption{An illustration of edge sets. Edges of $E'_Q$ are shown in green, and edges of $E''_Q$ are shown in red.\label{fig:spider_proof}}
\end{figure}
Let $\alpha_Q=\frac{\mathsf{OPT}(G''_Q,\mathcal{F}|_{E''_Q})}{v_{j_Q}}$. Clearly $\alpha_Q\leq 1$, since $E''_Q\subseteq Q$. We will construct the price vector $p$ as follows. For every $Q\in \mathcal{Q}_1$, we will first construct two price vectors $p_1$ and $p_2$ on $E_Q$. Then depending on the instance, we will either choose $p(e)=p_1(e),\forall e\in E_Q$, or $p(e)=p_2(e),\forall e\in E_Q$. For every $e\not\in \cup_{Q\in \mathcal{Q}_1}E_Q$, we set $p(e)=+\infty$. Now fix any $Q\in \mathcal{Q}_1$ and any $\varepsilon'>0$.
\paragraph{Construction of $p_1$.} For each $e\in E'_Q$, let $p_1(e)=+\infty$. For each $e\in E''_Q$, let $p_1(e)=p^*(e)+\frac{1}{n}\varepsilon'$, where $p^*=\{p^*(e)\}_{e\in E''_Q}$ is the set of prices from Theorem~\ref{thm:path} on $G''_Q$, whose worst-case welfare is $\mathsf{OPT}(G''_Q,\mathcal{F}|_{E''_Q})$. For $e=e_{Q,1}$ or $e_{Q,2}$, $p_1(e)=\frac{(1-\alpha_Q)v_{j_Q}}{2}-\varepsilon'$. Then no buyer $j$ where $Q_j$ contains an edge in $E'_Q$ can afford her path. Also, we notice that since $p^*$ is the optimal solution in (LP-Dual) for instance $(G''_Q,\mathcal{F}|_{E''_Q})$, every buyer $j$ where $Q_j$ has edges only in $E''_Q$ satisfies $v_j\leq p^*(Q_j)$. Thus none of them can afford her path in $p_1$, as $p_1(e)<p^*(e)$ for all $e\in E''_Q$.
Moreover, the total price of edges in $Q$ is $\sum_{e\in E''_Q}p_1(e)+p_1(e_{Q,1})+p_1(e_{Q,2})<\mathsf{OPT}(G''_Q,\mathcal{F}|_{E''_Q})+\varepsilon'+(1-\alpha_Q)v_{j_Q}-2\varepsilon'<v_{j_Q}$.
Consider any item pricing $p$ such that $p(e)=p_1(e),\forall e\in E_Q$. From the arguments above, only buyer $j$ whose $Q_j$ contains $e_{Q,1}$ or $e_{Q,2}$ may afford her path. Thus at least one of $e_{Q,1}$ and $e_{Q,2}$ must be sold under $p$ at price $\frac{(1-\alpha_Q)v_{j_Q}}{2}-\varepsilon'$, for any buyers' arriving order $\sigma$. Otherwise, all edges in $E''_Q$ must also be unsold and buyer $j_Q$ should have purchased her path $Q$, contradiction. Thus the contributed welfare from edges in $E_Q$ is at least $\frac{(1-\alpha_Q)v_{j_Q}}{2}-\varepsilon'$.
\paragraph{Construction of $p_2$.} For each $e\in E'_Q\cup E''_Q$, let $p_2(e)$ be the price of edge $e$ by applying Theorem~\ref{thm:path_no_tie} to $G'_Q\cup G''_Q$, which is a union of at most two path graphs. For $e=e_{Q,1}$ or $e_{Q,2}$, set $p_2(e)=+\infty$.
Then by Theorem~\ref{thm:path_no_tie},
if $p(e)=p_2(e),\forall e\in E_Q$,
the contributed welfare from edges in $E_Q$ is at least $\frac{2}{3}\mathsf{OPT}(G'_Q\cup G''_Q,\mathcal{F}|_{G'_Q\cup G''_Q})= \frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F}|_{G'_Q})+\frac{2}{3}\mathsf{OPT}(G''_Q,\mathcal{F}|_{G''_Q})=\frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F}|_{E'_Q})+\frac{2}{3}\alpha_Qv_{j_Q}$, for any buyers' arriving order $\sigma$.
Now for any $Q\in \mathcal{Q}_1$, we choose the price with a higher contributed welfare: If $\frac{(1-\alpha_Q)v_{j_Q}}{2}-\varepsilon'>\frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F})+\frac{2}{3}\alpha_Qv_{j_Q}$, we choose $p(e)=p_1(e),\forall e\in E_Q$ and choose $p(e)=p_2(e)$ otherwise. Thus the worst-case welfare of item pricing $p$ is at least
\begin{eqnarray*}
& &\sum_{Q\in \mathcal{Q}_1}\max\left(\frac{(1-\alpha)v_{j_Q}}{2}-\varepsilon',\frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F}|_{E'_Q})+\frac{2}{3}\alpha_Qv_{j_Q}\right)\\
&\geq&\sum_{Q\in \mathcal{Q}_1}\frac{4}{7}\left(\frac{(1-\alpha)v_{j_Q}}{2}-\varepsilon'\right)+\frac{3}{7}\left(\frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F}|_{E'_Q})+\frac{2}{3}\alpha_Qv_{j_Q}\right)\\
&=&\sum_{Q\in \mathcal{Q}_1}\left(\frac{2}{7}v_{j_Q}+\frac{2}{7}\mathsf{OPT}(G'_Q,\mathcal{F}|_{E'_Q})-\frac{4}{7}\varepsilon'\right)\\
&=&\sum_{Q\in \mathcal{Q}_1}\left(\frac{2}{7}\mathsf{OPT}(G_Q,\mathcal{F}|_{E_Q})-\frac{4}{7}\varepsilon'\right)>\frac{2}{7}\mathsf{OPT}(G,\mathcal{F})-\frac{4n}{7}\varepsilon'.
\end{eqnarray*}
Choosing $\varepsilon'=\frac{\varepsilon\cdot \mathsf{OPT}(G,\mathcal{F})}{10n}$ finishes the proof. By~\cite{tarjan1985decomposition}, the optimal allocation for any instance on trees can be computed efficiently. Thus the price vector $p$ can also be computed efficiently according to the construction above.
\end{prevproof}
\begin{prevproof}{Theorem}{thm:cycle_without_tie}
Let $\mathcal{Q}^*$ be the subset of $\set{Q_1,\ldots,Q_m}$ that, over all subsets of edge-disjoint paths in $\set{Q_1,\ldots,Q_m}$ that maximizes its total value, maximizes its cardinality. For every $Q\in \mathcal{Q}^*$, let $v(Q)$ be the value of the buyer who receives demand path $Q$ in the optimal allocation $\mathcal{Q}^*$. So $\mathsf{OPT}(G,\mathcal{F})=\sum_{Q\in \mathcal{Q}^*}v(Q)$.
We distinguish between the following cases.
\textbf{Case 1. $\bigcup_{Q\in \mathcal{Q}^*}Q \ne G$.} Let $e'$ be an edge of $G$ that does not belong to any path of $\mathcal{Q}^*$. We first set the price of $e'$ to be $p(e')=+\infty$. Since $G\setminus e$ is a path, from Theorem~\ref{thm:path_no_tie}, there exist prices $\set{p(e)}_{e\in G\setminus e'}$ that achieves the worst-case welfare $\frac{2}{3}\cdot\sum_{Q\in \mathcal{Q}^*}v(Q)=\frac{2}{3}\cdot \mathsf{OPT}(G,\mathcal{F})$.
\textbf{Case 2. $\bigcup_{Q\in \mathcal{Q}^*}Q = G$ and $|\mathcal{Q}^*|\ge 4$.} Let $Q'\in \mathcal{Q}^*$ be the path of $\mathcal{Q}^*$ with minimum value.
Since $|\mathcal{Q}^*|\ge 4$, $\sum_{Q\in \mathcal{Q}^*}v(Q)\ge \frac 3 4 \cdot\mathsf{OPT}(G,\mathcal{F})$. We first set the prices for all edges of $Q'$ to be $+\infty$. We then consider the graph $G\setminus Q'$. From the similar analysis as in Case 1, we get that there exist prices $\set{p(e)}_{e\in G\setminus Q'}$ that achieves the worst-case welfare $\frac{2}{3}\cdot\sum_{Q\in \mathcal{Q}\setminus\set{Q'}}v(Q)=\frac{2}{3}\cdot\frac 3 4\cdot \mathsf{OPT}(G,\mathcal{F})=\mathsf{OPT}(G,\mathcal{F})/2$.
\textbf{Case 3. $\bigcup_{Q\in \mathcal{Q}^*}Q = G$ and $|\mathcal{Q}^*|=2$.} Let $Q$ be the path in $\mathcal{Q}^*$ with largest value, so $v(Q)\ge \mathsf{OPT}(G,\mathcal{F})/2$. We first set the prices for all edges of $G\setminus Q$ to be $+\infty$. From the choice of $\mathcal{Q}^*$, there does not exist a set of edge-disjoint demand paths, whose union is exactly $Q$ and total value equals $v(Q)$. From \Cref{claim:covering_implies_optimal}, there exist prices $\set{p(e)}_{e\in Q}$ that achieves the worst-case welfare $v(Q)\ge \mathsf{OPT}(G,\mathcal{F})/2$
\textbf{Case 4. $\bigcup_{Q\in \mathcal{Q}^*}Q = G$ and $|\mathcal{Q}^*|=3$.} Denote $\mathcal{Q}^*=\set{Q_1,Q_2,Q_3}$, where the endpoints for paths $Q_1$ ($Q_2$ and $Q_3$, resp.) are $a,b$ ($b,c$ and $c,a$, resp.).
If some path of $\mathcal{Q}^*$ has value less than $\mathsf{OPT}(G,\mathcal{F})/4$, then we set the prices for all edges of this path to be $+\infty$, and then from the similar analysis in Case 2, there exist prices $\set{p(e)}_{e\in G\setminus Q'}$ that achieves the worst-case welfare at least $\mathsf{OPT}(G,\mathcal{F})/2$.
Now assume that $v(Q_1),v(Q_2),v(Q_3)\ge \mathsf{OPT}(G,\mathcal{F})/4$.
Let $Q'_1=Q_2\cup Q_3$. If there does not exist a set of two edge-disjoint demand paths, whose union is exactly $Q'_1$ and total value equals $v(Q'_1)$, then we set the prices for all edges of $Q_1$ to be $+\infty$, and then from the similar analysis in Case 3, there exist prices $\set{p(e)}_{e\in G\setminus Q'}$ that achieves the worst-case welfare $v(Q_2)+v(Q_3)\ge \mathsf{OPT}(G,\mathcal{F})/2$.
Therefore, there exist demand paths $P_1,P'_1$ with $P_1\cup P'_1=Q_2\cup Q_3$ and $v(P_1)+v(P'_1)=v(Q_2)+v(Q_3)$.
Similarly, there exist demand paths $P_2,P'_2$ with $P_2\cup P'_2=Q_3\cup Q_1$ and $v(P_2)+v(P'_2)=v(Q_3)+v(Q_1)$; and there exist demand paths $P_3,P'_3$ with $P_3\cup P'_3=Q_1\cup Q_2$ and $v(P_3)+v(P'_3)=v(Q_1)+v(Q_2)$.
Now consider the path $P_1,P'_1,P_2,P'_2,P_3,P'_3$.
For similar reasons, the value of each of these paths is at least $\mathsf{OPT}(G,\mathcal{F})/4$.
From the above discussion, the union of them contains each edge of $G$ exactly twice. Therefore, either $P_1\cup P'_1\cup P_2$ or $P'_2\cup P_3\cup P'_3$ is a path of $G$ with total value at least $\frac{3}{4}\cdot\mathsf{OPT}(G,\mathcal{F})$. From similar analysis in Case 2, there exist prices $\set{p(e)}_{e\in G\setminus Q'}$ that achieves the worst-case welfare $\frac{2}{3}\cdot\frac 3 4\cdot \mathsf{OPT}(G,\mathcal{F})=\mathsf{OPT}(G,\mathcal{F})/2$.
\end{prevproof}
\section{Missing Details from Section~\ref{sec:congestion}}\label{sec:appx_resource_aug}
\begin{prevproof}{Theorem}{thm: congestion_c}
Let $\mathcal{Q}=\set{Q_{j_1},\ldots,Q_{j_t}}$ be an independent set with maximum total value.
Denote $J=\set{j_1,\ldots,j_t}$, so $\mathsf{OPT}(U,\mathcal{F})=\sum_{j\in J}v_j$. Denote $v=\mathsf{OPT}(U,\mathcal{F})$.
$U'=\bigcup_{Q\in \mathcal{Q}}Q$, so $U'\subseteq U$ and $|U'|\le n$.
Note that $v=\sum_{j:Q_j\in \mathcal{Q}}v_j$.
We now define the prices on items of $U$ as follows.
For each element $i\notin U'$, we define $p^1(i)=\ldots=p^c(i)=+\infty$.
For each element $i\in U'$ and for each $1\le k\le c$, we define $p^k(i)=\frac{1}{2n}\cdot n^{(k-1)/c}$.
We now show that these prices achieve worst-case welfare $\Omega(v/n^{1/c})$.
Consider the remaining items of $U$ at the end of the selling process.
Clearly, all copies of items in $U\setminus U'$ must be unsold. Fix any buyers' order. We distinguish between the following cases.
\textbf{Case 1. Some element of $U'$ is sold out.} From the definition of prices in $\set{p^{k}(i)\mid i\in U, 1\le k\le c}$, for each $i\in U'$, $p^c(i)=\frac{v}{2}\cdot n^{-1/c}$. Therefore, if all $c$ copies of the item $i$ are sold, then the $c$-th copy is sold at price $p^c(i)=\frac{v}{2}\cdot n^{-1/c}$. It follows that the welfare is $\frac{v}{2}\cdot n^{-1/c}=\Omega(v\cdot n^{-1/c})$.
\textbf{Case 2. No elements of $U'$ are sold out.}
For each $i\in U'$, we define $\tilde p(i)=p^{k+1}(i)$ iff $k$ copies of $i$ are sold. Since no elements of $U'$ are sold out, $\tilde p(i)$ is well-defined for all $i\in U'$. If $k\geq 1$ copies of item $i$ are sold, the total prices of the sold copies of $i$ is at least $p^{k}(i)=\tilde p(i)\cdot n^{-1/c}>(\tilde p(i)-\frac{v}{2n})n^{-1/c}$; If $k=0$ copies of item $i$ are sold,
it also holds that $(\tilde p(i)-\frac{v}{2n})n^{-1/c}=0$. Since each buyer has a non-negative utility, the total welfare is at least $\sum_{i\in U'}(\tilde p(i)-\frac{v}{2n})n^{-1/c}\geq n^{-1/c}\sum_{i\in U'}\tilde p(i)-\frac{v}{2}n^{-1/c}$.
Let $\tilde\mathcal{Q}\subseteq\mathcal{Q}$ be the demand sets of $\mathcal{Q}$ that are sold. If $\sum_{j:Q_j\in \tilde\mathcal{Q}}v_j\ge \frac{v}{4}$, then the welfare of the pricing is already $\Omega(v\cdot n^{-1/c})$. Otherwise, $\sum_{j:Q_j\in \tilde\mathcal{Q}}v_j< \frac{v}{4}$, then $\sum_{j:Q_j\in \mathcal{Q}\setminus\tilde\mathcal{Q}}v_j>\frac{3v}{4}$. Since none of the buyers in $\mathcal{Q}\setminus\tilde\mathcal{Q}$ are sold, it means that the total prices of all items at the end of the selling process is at least $\frac{3v}{4}$, since $\sum_{i\in U'}\tilde p(i)
\ge
\sum_{Q\in \mathcal{Q}\setminus \tilde\mathcal{Q}}\tilde p(Q)
\ge
\sum_{j:Q_j\in \mathcal{Q}\setminus \tilde\mathcal{Q}}\tilde v_j
>\frac{3v}{4}$. The theorem follows since the total welfare is at least $n^{-1/c}\sum_{i\in U'}\tilde p(i)-\frac{v}{2}\cdot n^{-1/c}=\Omega(v\cdot n^{-1/c})$.
\end{prevproof}
\begin{prevproof}{Theorem}{thm: congestion_c lower bound}
Let $r$ be the number such that $n=\binom{r}{c+1}$, so $r=O(c\cdot n^{1/(c+1)})$.
Denote $I=\set{1,\ldots,r}$ and let $U=\set{u_J\mid J\subseteq I, |J|=c+1}$, namely $U$ contains $\binom{r}{c+1}=n$ elements, where each element is indexed by a size-$(c+1)$ subset $J$ of $I$.
We define the buyer profile as follows.
There are $(c+1)r+1$ buyers: buyer $B_0$, and, for each $1\le k\le c+1, 1\le j\le r$, a buyer named $B^k_j$.
The demand set for buyer $B_0$ is $S_0=U$, and her value is $|U|=\binom{r}{c+1}$.
For each $1\le j\le r$ and for each $1\le k\le c+1$, the demand set of buyer $B^k_j$ is $Q^k_j=\set{u_J\mid j\in J}$, and her value is $v(S^k_j)=|S^k_j|=\binom{r-1}{c}$.
Clearly optimal allocation when each item has supply 1 is to assign all elements of $U$ to $B_0$, and the optimal welfare is $\mathsf{OPT}(U,\mathcal{F})=|U|=\binom{r}{c+1}$.
Moreover, it is easy to verify that any $c+1$ demand sets of $\set{Q^k_j}_{1\le k\le c+1,1\le j\le r}$ shares at least one element of $U$.
We claim that any set of prices can achieve worst-case welfare at most $c\cdot\binom{r-1}{c}$.
Note that this finishes the proof of Theorem~\ref{thm: congestion_c lower bound}, since $$\frac{c\cdot\binom{r-1}{c}}{\mathsf{OPT}(U,\mathcal{F})}=\frac{c\cdot\binom{r-1}{c}}{\binom{r}{c+1}}=\frac{c\cdot\binom{r-1}{c}}{\frac{r}{c+1}\cdot\binom{r-1}{c}}=\frac{c(c+1)}{r}=O\left(\frac{c+1}{n^{1/(c+1)}}\right).$$
It remains to prove the claim.
Let $\set{p^k(u)\mid u\in U, 1\le k\le c}$ be any set of prices.
We will iteratively construct an order $\sigma$ on buyers, such that if the buyers come to the auction according to this order, the achieved welfare is at most $c\cdot\binom{r-1}{c}$.
Initially. $\sigma$ is an empty sequence.
Throughout, we maintain a set $\set{\tilde p(u)}_{u\in U}$ of prices, such that at any time, $\tilde p(u)$ is the price of the cheapest available copy of item $u$. Initially, $\tilde p(u)=p^1(u)$ for all $u\in U$.
We perform a total of $c$ iterations, and now we fix some $1\le k\le c$ and describe the $k$-th iteration. We first check whether or not there is a set $Q_j^k$ with $\tilde p(Q_j^k)\le v(Q_j^k)$. If so, assume $\tilde p(Q_{j_k}^k)\le v(Q^k_{j_k})$, then we add the buyer $B^k_{j_k}$ to the end of the current sequence $\sigma$, update the price $\tilde p(u)$ for all items $u\in Q^k_{j_k}$ to their next price in $\set{p^k(u)\mid 1\le k\le c}$. And then continue to the next iteration. Otherwise, since every element of $U$ appears in exactly $c+1$ sets of $Q^k_1,\ldots,Q^k_{r}$, and $\sum_{1\le j\le r}v(Q^k_j)=r\binom{r-1}{c}=(c+1)\binom{r}{c+1}=(c+1)\cdot |U|$, we get that $\tilde p(U)> |U|$.
Therefore, no buyer can afford her demand set, and the welfare will be $0$. In this case, we add all buyers to the end of $\sigma$ and terminate the algorithm.
We now analyze the algorithm. If the algorithm is terminated before it completes $c$ iterations, then from the construction above, the buyer $B_0$ will not get her demand set. Also, since any $c+1$ other demand sets share an element of $U$, at most $c$ other buyers may get their demand sets. Therefore, the welfare is at most $c\cdot\binom{r-1}{c}$.
Assume that the algorithm successfully completes $c$ iterations. From the description of the algorithm, in each iteration, some buyer from $\set{B^k_j\mid 1\le k\le c+1,1\le j\le r}$ will be added to the sequence, and moreover, this buyer will get her demand set under order $\sigma$.
Therefore, after $c$ iterations, we added $c$ distinct buyers to the sequence that will get their demand sets.
Since any $c+1$ demand sets shares an element of $U$, we know that no other buyer may get her demand set anymore, so the welfare is at most $c\cdot\binom{r-1}{c}$.
\end{prevproof}
\begin{prevproof}{Theorem}{thm: lower_bound_congestion}
We will use the graph $H_{a,b}$ constructed in \Cref{thm:lb-mahua}. For convenience, we will work with the multi-graph $L_{a,b}$.
The parameters $a,b$ are set such that $b=a+2(c+1)^{c+2}a^{c+2}$ and $n=ab$, so $a=\Theta(n^{1/(c+3)})$.
We now define the buyer profile. Recall that in \Cref{thm:lb-mahua} the buyer profile $\mathcal{F}=\mathcal{F}^*\cup(\bigcup_{S\subseteq [a], |S|\ge \sqrt{a}}\mathcal{F}_S)$, where $\mathcal{F}^*$ contains, for each $r\in [a]$, a buyer $B^*_r$ demanding the path $Q^{(r)}=(r,r,\ldots,r)$ with value $1$.
The buyer profile $\hat\mathcal{F}$ that we will use in this subsection is similar to $\mathcal{F}$.
Specifically, we will keep the buyers in $\mathcal{F}^*$, but will also additionally construct, for each set $S\subseteq [a]$ such that $|S|\ge \sqrt{ca}$ (instead of $|S|\ge \sqrt{a}$), a set $\hat\mathcal{F}_S$ of buyers, whose demand paths and values satisfy the following properties.
\iffalse
\begin{enumerate}
\item Each buyer $(Q,v)\in \mathcal{F}_S$ satisfy $Q\in S^{b}$ and $v=1+\epsilon$ for small constant $\epsilon$. In other words, each buyer in $\mathcal{F}_S$ demands a path that only uses edges with index in $S$ in each segment.
\item For each edge $e$ being the $k$th edge in some segment of the graph for $k\in S$, $e$ belongs to $c+1$ paths demanded by buyers in $\mathcal{F}_S$. In other words, the paths demanded by the buyers in $\mathcal{F}_S$ exactly covers paths $\{Q_k:k\in S\}$ for $c+1$ times.
\item For buyer $(Q,v)\in \mathcal{F}_S$ and $k\in S$, the vector $Q$ contains $k$. In other words, the path demand by the buyers in $\mathcal{F}_S$ must intersect $Q_k$ for every $k\in S$, which makes sure that $\mathcal{F}_S\cap\mathcal{F}_{S'}=\emptyset$ for two demand sets constructed by different index sets $S$ and $S'$.
\item Consider $c+1$ index sets $S_1\cap S_2\cap\cdots\cap S_{c+1}\neq\emptyset$. Then for any $(Q^i,1+\epsilon)\in \mathcal{F}_{S_i}$, $1\leq i\leq c+1$, $Q^1\cap Q^2\cap\cdots\cap Q^{c+1}\neq\emptyset$. In other words, for any $c+1$ paths $Q^{1},\cdots,Q^{c+1}$ demanded by buyers that are not in the optimal offline allocation, if they both intersect the same path $Q_k$ in $\mathsf{OPT}$, then the paths must include the same edge.
\end{enumerate}
\fi
\begin{enumerate}
\item \label{prop'1}For each $S$, set $\hat\mathcal{F}_S$ contains $(c+1)|S|$ buyers, and every pair $Q,Q'$ of demand paths in $\hat\mathcal{F}_S$ share some edge, and the value for each demand path is $1+\epsilon$.
\item \label{prop'3}For each demand path $Q$ in $\hat\mathcal{F}_S$, the index sequence $(j^Q_1,\ldots,j^Q_b)$ that $Q$ corresponds to satisfies that (i) $j^Q_i\in S$ for each $i\in [b]$; and (ii) the set $\set{j^Q_1,\ldots,j^Q_b}$ contains all element of $S$.
\item \label{prop'4}The union of all demand paths in $\hat\mathcal{F}_S$ covers the graph $\bigcup_{r\in S}Q^{(r)}$ exactly $c+1$ times. In other words, for each $i\in [b]$, the multi-set $\set{j^Q_i\mid Q\in \hat\mathcal{F}_S}$ contains each element of $S$ exactly twice.
\item \label{prop'5}For any $c+1$ subsets $S_1,\ldots,S_{c+1}$ of $[a]$, such that $|S_t|\ge \sqrt{ca}$ for each $t\in [c\!+\!1]$ and $\bigcap_{t}S_t\ne \emptyset$, for any $c+1$ demand paths $Q_1,\ldots,Q_{c+1}$ such that $Q_t\in \hat\mathcal{F}_{S_t}$ for each $t\in [c\!+\!1]$, $\bigcap_{t}E(Q_t)\ne \emptyset$.
\end{enumerate}
Suppose that we have successfully constructed the sets $\set{\hat\mathcal{F}_S}_{S\subseteq [a], |S|\ge \sqrt{ca}}$ that satisfy the above properties.
We then let $\mathcal{F}$ be the union of $\mathcal{F}^*$ and, for each set $S\subseteq [a], |S|\ge \sqrt{ca}$, $c$ distinct copies of set $\hat\mathcal{F}_S$. In other words, for each buyer in $\set{\hat\mathcal{F}_S}_{S\subseteq [a], |S|\ge \sqrt{ca}}$, we duplicate $c$ buyers and add all of them into our buyer profile.
This completes the description of $\hat\mathcal{F}$.
From the above properties, it is easy to see that $\mathsf{OPT}(L_{a,b},\hat\mathcal{F})=a$, which is achieved by giving each buyer in $\mathcal{F}^*$ her demand path.
We will prove that any prices on edges of $L_{a,b}$ may achieve worst-case welfare $O(\sqrt{ca})$. Since $a=\Theta(n^{1/(c+3)})$, $\sqrt{a}=\Theta(n^{1/(2c+6)})$, which completes the proof of \Cref{thm: lower_bound_congestion}.
Consider now any set $\set{p^k(e)\mid e\in E(L_{a,b}), k\in [c]}$ of prices on edges of $L_{a,b}$.
From Properties \ref{prop'3} and \ref{prop'5}, it is easy to see that at most $\sqrt{ca}$ buyers from $\hat{\mathcal{F}}\setminus \mathcal{F}^*$ can get their demand paths simultaneously. We consider the following arrival order of the buyers in $\hat\mathcal{F}$. The buyers in $\hat\mathcal{F}$ are divided into $(c+1)$ groups, where each of the first $c$ groups contains a copy of each buyer from $(\bigcup_{S\subseteq [a], |S|\ge \sqrt{a}}\mathcal{F}_S)$, and the last group contains all buyers of $\mathcal{F}^*$. The buyers come to the auction according to their group index: All buyers from the first group come first (buyers within the same group come at an arbitrary order), and then all buyers from the second group come, etc.
Assume that we pause the selling process right after all buyers from the first $ca$ groups have come.
Currently for each edge $e\in E(L_{a,b})$, some copies of it were taken and there is a price $p^*(e)$ on its next copy.
We distinguish between the following two cases.
\paragraph{Case 1. At least $\sqrt{ca}$ buyers in $\mathcal{F}^*$ can afford their demand paths at prices $\set{p^*(e)}_{e\in E(L_{a,b})}$.}
We let $S$ be the set that contains all indices $r\in [a]$ such that the buyer $B^*_r$ can afford her demand path $Q^{(r)}$ at prices $\set{p^*(e)}_{e\in E(L_{a,b})}$, so $|S|\ge \sqrt{ca}$. Similar to \Cref{lem:ratio-Lab}, it is easy to show that at least one buyer in $\hat\mathcal{F}_S$ can afford her demand path, and therefore all $c$ copies of this buyer in $\hat\mathcal{F}$ will get their demand paths. This implies that $p^*(Q^{(r)})=+\infty$ for all $r\in S$, contradicting with the assumption in this case.
\paragraph{Case 2. At most $\sqrt{ca}$ buyers in $\mathcal{F}^*$ can afford their demand paths at prices $\set{p^*(e)}_{e\in E(L_{a,b})}$.}
Similar to Lemma~\ref{lem:ratio-Lab}, the optimal welfare is at most $(2+\epsilon)\sqrt{ca}$.
$\ $
It remains to construct the sets $\set{\hat\mathcal{F}_S}_{S\subseteq [a], |S|\ge \sqrt{ca}}$ that satisfy the required properties. The construction is almost identical to that of \Cref{thm:lb-mahua}. The only difference is that we need to construct a $(c+1)s\times b$ matrix $M'_S$, instead of a $2s\times b$ matrix. Accordingly, we first place $(c+1)$ copies of matrix $N_S$ vertically as the first $s$ columns of $M'_S$, and then for the next $b-s$ columns, we let each column to be each column be an independent random permutation on elements of the multiset that contains, for each element of $S$, $(c+1)$ copies of it. It is easy to verify that, with $b=a+2(c+1)^{c+2}a^{c+2}$, all the desired properties are satisfied with high probability.
\iffalse
Now we show how to construct the sets of demanded paths in $\mathcal{F}_S$ that satisfy all of the properties. The construction is almost identical to the case of $c=1$, except we need to increase $b$. Let $s=|S|$. There are $(c+1)s$ paths to construct, and we will construct the $(c+1)s\times b$ matrix formed by the vectors corresponding to the paths for each set $S$. The same as in the case of $c=1$, we start with an empty matrix, and will add the columns sequentially to satisfy the properties. Every element in the matrix will be selected from $S$, thus Property 1 is satisfied. For each column, each element in $S$ appears exactly $c+1$ times, which is necessary and sufficient to satisfy Property 2.
The first $s$ columns of the matrix corresponding to $S$ form a matrix such that every element in $S$ appear in each row by exactly once. This can be done by letting the first row be all elements in $S$, then each subsequent row be constructed by rotating the previous row to the right by one element. Then Property 3 is satisfied since each row (i.e. path) already contains each element in $S$.
The next $b-s$ columns of the matrix corresponding to $S$ are first constructed as follows. Suppose that $S=\{e_1,e_2,\cdots,e_s\}$, then each column is a random permutation of $(e_1,e_1,\cdots,e_1,e_2,e_2,\cdots,e_2,\cdots,e_s,e_s,\cdots,e_s)^{\top}$, where each $e_i$ appears $c+1$ times.
For any $c+1$ rows in the matrices corresponding to $S_1,\cdots,S_{c+1}$ that all contains element $i$, the probability that they have the same element $i$ in any column is at least $\left(\frac{1}{(c+1)a}\right)^{c+1}$; this is true since for any $j$ rows in the matrix corresponding to $S$, the probability that they have the same specific element $i\in S$ is $\frac{c+1}{(c+1)|S|}\cdot\frac{c}{(c+1)|S|-1}\cdots\frac{c+2-j}{(c+1)|S|-j}>\left(\frac{1}{(c+1)a}\right)^j$.
Thus the probability that $c+1$ rows from $\mathcal{F}_{S_1},\cdots,\mathcal{F}_{S_{c+1}}$ with $|S_1\cap \cdots\cap S_{c+1}|\geq 1$ have different elements in each of the last $b-a$ columns is at most $(1-((c+1)a)^{-(c+1)})^{b-a}=(1-((c+1)a)^{-(c+1)})^{2a^{c+2}(c+1)^{c+2}}=((1-((c+1)a)^{-(c+1)})^{((c+1)a)^{c+1}})^{2a(c+1)}<2^{-2a(c+1)}$.
Notice that there are at most $2^a$ index sets $S$, thus at most $2a\cdot 2^a$ rows in total, which leads to at most $2^{(a+1)(c+1)}a^{(c+1)}<2^{2a(c+1)}$ tuples of $c+1$ rows. By union bound, the probability that there exist $c+1$ rows from $\mathcal{F}_{S_1},\cdots,\mathcal{F}_{S_{c+1}}$ with $|S_1\cap \cdots\cap S_{c+1}|\geq 1$ have different elements in each of the last $b-a$ columns is less than $2^{-2a(c+1)}\cdot2^{2a(c+1)}=1$, which means that there is a realization such that for every $c+1$ rows from matrices corresponding to index sets $\mathcal{F}_{S_1},\cdots,\mathcal{F}_{S_{c+1}}$, if $S_1\cap \cdots\cap S_{c+1}\neq \emptyset$, then the $c+1$ rows have the same element in some column. This implies that Property 4 is satisfied.
Therefore the above procedure constructs a demand set of buyers that satisfy all properties needed for the proof of the hardness result. By $n=ab=\Theta(c+1)^{c+3}a^{c+3}$, we know that item pricing can get at most $O(\mathsf{OPT}/(1+\sqrt{a/c}))=O(\mathsf{OPT}/(n^{1/(2c+6)}/c))$ welfare. This finishes the proof of the theorem.
\fi
\end{prevproof}
\section{Missing Details from Section~\ref{sec:special_graph}}\label{sec:appx_special_graphs}
\subsection{Missing Details from Section~\ref{sec:star_and_spider}}\label{subsec:appx_star_and_spider}
\begin{prevproof}{Lemma}{lem:matching-half-integral}
Let $y$ be any optimal solution of (LP-Primal) that is an extreme point of the polytope defined by (LP-Primal).
Denote $J=\set{j\mid 0<y_j<1}$. We define a graph $\hat H$ according to $J$ as follows.
The vertex set of $\hat H$ contains
(i) a vertex $u_i$ for each edge $e_i\in E(G)$; and
(ii) a vertex $\hat u_i$, for all $1\le i\le m$ such that there exists a buyer $B_j$ with $j\in J$ whose demand path $Q_j$ contains a single edge $e_i$.
In other words, $V(\hat H)=\set{u_1,\ldots,u_m}\cup \set{\hat u_i\mid \exists j\in J, Q_j=(e_{i})}$.
The edge set of $\hat H$ contains
(i) an edge $(u_i,u_{i'})$ for each demand path $Q_j=(e_{i},e_{i'})$ with $j\in J$; and
(ii) an edge $(u_i,\hat u_{i})$ for each demand path $Q_j=(e_{i})$ with $j\in J$.
In other words, $E(\hat H)=\set{(u_i,u_{i'})\mid \exists j\in J, Q_j=(e_{i},e_{i'})}\cup \set{(u_i,\hat u_{i})\mid \exists j\in J, Q_j=(e_{i})}$.
We say that a graph is \emph{Eulerian} iff the degree for each vertex is even. It is folklore that every Eulerian graph contains a trail that visits each edge once.
We use the following claim and its simple corollary.
\begin{claim}
\label{clm: no eulerian subgraph}
$\hat H$ does not contain an Eulerian subgraph with even number of edges.
\end{claim}
\begin{proof}
Assume the contrast that graph $\hat H$ does contain an Eulerian subgraph, and let $(u_{r_1},\ldots, u_{r_t},u_{r_1})$ be the trail that visits each edge of this Eulerian subgraph exactly once (note that such a trail may not contain vertices of $\set{\hat u_i\mid \exists j\in J, Q_j=(e_{i})}$).
Define
$$\hat J_0=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \set{r_k,r_{k+1}}=\set{i,i'}\text{ for some even }1\le k\le t};$$
and
$$\hat J_1=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \exists\text{ odd }k, \set{r_k,r_{k+1}}=\set{i,i'}}.$$
Clearly, sets $\hat J_0$ and $\hat J_1$ are disjoint.
We define $z\in \set{-1,0,1}^n$ to be the $n$-dimensional vector, such that, for each $1\le j\le n$, $z_j=1$ iff $j\in \hat J_0$, $z_j=-1$ iff $j\in \hat J_1$, and $z_j=0$ otherwise.
Let $\varepsilon$ be any constant such that $0<\varepsilon<\min\set{y_j,1-y_j \mid j\in J}$.
Clearly, vectors $y+\epsilon z$ and $y-\epsilon z$ are both feasible solutions of (LP-Primal). This contradicts the fact that $y$ is an extreme point of the polytope defined by (LP-Primal).
\end{proof}
As a corollary, all cycles of $\hat H$ contains odd number of edges, and all odd-cycles in $\hat H$ are vertex-disjoint. We further prove the following claim.
\begin{claim}
\label{clm: odd cycle in disjoint component}
Every odd cycle of $\hat H$ belongs to a distinct connected component of $\hat H$.
\end{claim}
\begin{proof}
If $\hat H$ does not contain any odd cycle or only contains one odd cycle, then there is nothing to prove. Assume the contrast that $\hat H$ contains two odd-cycles $C,C'$ lying in the same connected component of $\hat H$. Let $P$ be a path connecting a vertex $u$ of $C$ to a vertex $u'$ of $C'$.
Let $V(C)=\set{u,u_{i_1},\ldots,u_{i_r}}$, $V(C')=\set{u',u_{i'_1},\ldots,u_{i'_s}}$, and
$V(P)=\set{u,u_{i''_1},\ldots,u_{i''_t},u'}$, where $r,s$ are even and the vertices are indexed according to the order in which they appear on $C$, $C'$ or $P$.
Define
$$ J_0=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \set{i_k,i_{k+1}}=\set{i,i'}\text{ for some even }0\le k\le r};$$
$$ J_1=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \set{i_k,i_{k+1}}=\set{i,i'}\text{ for some odd }0\le k\le r};$$
$$ J_0'=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \set{i_k,i_{k+1}}=\set{i,i'}\text{ for some even }0\le k\le s};$$
$$ J_1'=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \set{i_k,i_{k+1}}=\set{i,i'}\text{ for some odd }0\le k\le s};$$
$$\quad \quad J_0''=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \set{i_k,i_{k+1}}=\set{i,i'}\text{ for some even }0\le k\le t}; \text{ and}$$
$$ J_1''=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \set{i_k,i_{k+1}}=\set{i,i'}\text{ for some odd }0\le k\le t};$$
Let $z\in \set{0,1}^n$ be the vector such that for each $1\le j\le n$, $z_j=1$ iff $j\in J_0$, $z_j=-1$ iff $j\in J_1$, and $z_j=0$ otherwise.
We define vectors $z',z''$ according to sets $ J'_0, J'_1$ and sets $ J''_0, J''_1$ similarly.
Let $\varepsilon$ be any constant such that $0<\varepsilon<\min\set{y_j,1-y_j \mid j\in J}$.
If $t$ is odd, then we let $\tilde z=\epsilon z+ \epsilon z'-2\epsilon z''$; if $t$ is even, then we let $\tilde z=\epsilon z- \epsilon z'-2\epsilon z''$.
Clearly, vectors $y+\tilde z$ and $y-\tilde z$ are both feasible solutions of (LP-Primal). This contradicts the fact that $y$ is an extreme point of the polytope defined by (LP-Primal).
\end{proof}
As a corollary, each connected component of $\hat H$ is either a tree itself, or the union of an odd cycle with some disjoint trees, each sharing a distinct vertex with the cycle.
We further prove the following claim.
\begin{claim}
\label{clm: no tree component}
No connected component of $\hat H$ is a tree.
\end{claim}
\begin{proof}
Assume the contrast that $\hat H$ has a connected component that is a tree. Let $T$ be such a tree and we root $T$ at an arbitrary vertex of $T$.
We say that an edge $(u',u'')$ (where $u'$ is the parent vertex of $u''$ in $T$) of $T$ is a \emph{type-$0$} edge iff the tree-distance between $u$ and $u'$ in $T$ is even; otherwise we say that it is a \emph{type-$1$} edge.
We define
$ J_0=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } (u_i,u_{i'})\text{ is a type-0 edge}}$,
and
$ J_1=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } (u_i,u_{i'})\text{ is a type-1 edge}}$.
Claim~\ref{clm: no tree component} follows from similar arguments in the proof of Claim~\ref{clm: no eulerian subgraph}.
\end{proof}
Via similar arguments in the proof of Claim~\ref{clm: odd cycle in disjoint component}, we can prove the following claim.
\begin{claim}
\label{clm: no odd cycle plus something component}
No connected component of $\hat H$ contains an odd-cycle and at least one non-cycle edge.
\end{claim}
Combining Claim~\ref{clm: no eulerian subgraph}, Claim \ref{clm: odd cycle in disjoint component}, Claim~\ref{clm: no tree component} and Claim~\ref{clm: no odd cycle plus something component}, every connected component of $\hat H$ is a single odd-cycle.
It remains to show that all coordinates of $\set{y_j}_{j\in J}$ are $1/2$. Consider an odd cycle $C$ with $V(C)=\set{u_{i_1},\ldots,u_{i_r}}$ (where $r$ is odd), where the vertices are indexed in the same order in which they appear on $C$.
For each $1\le t\le r$, let $Q_{j_t}$ be the path that contains edges $e_{i_t},e_{i_{t+1}}$.
Via similar arguments in the proof of Claim~\ref{clm: odd cycle in disjoint component}, we can show that $y_{j_t}+y_{j_{t+1}}=1$ for all $1\le t\le r$. Since $r$ is odd, we conclude that $y_{j_t}=1/2$ for all $1\le t\le r$. This completes the proof of Lemma~\ref{lem:matching-half-integral}.
\end{prevproof}
\begin{prevproof}{Lemma}{lem:spider-half-integral}
We provide the proof of Lemma~\ref{lem:spider-half-integral}, using Lemma~\ref{lem:matching-half-integral}.
We first modify the buyer profile as follows. For each edge $e$ of $G$, we add a buyer $B_e$ who demands the path that contains a single edge $e$ and has value $0$ upon the path. Equivalently, we consider the following linear program.
\begin{eqnarray*}
\mbox{(LP-1)} &\text{maximize }
\sum_{j\in [n]}v_j\cdot y_j\\
\mbox{s.t.}
& \hat y_i+\sum_{j: e_i\in Q_j}y_j= 1&\forall\text{ }1\le i\le m\\
& y_j\ge 0&\forall\text{ } j\in [n]\\
& \hat y_i\ge 0&\forall\text{ } 1\le i\le m
\end{eqnarray*}
It is easy to see that (LP-1) is equivalent to (LP-Primal), in the sense that (i) their optimal values are the same; and (ii) any optimal solution to (LP-1) naturally induces an optimal solution to (LP-Primal), and vice versa.
Consider now an optimal solution $y^*=(y^*_j)_{j\in [n]}$ of (LP-Primal). We define $\hat y^*\in [0,1]^m$ as: for each $1\le i\le m$, $\hat y^*_i=1- \sum_{j: e_i\in Q_j}y^*_j$. It is easy to see that $(y^*,\hat y^*)$ is an optimal solution of (LP-1).
We will now construct a star graph $H$ and a buyer profile $\mathcal{F}'$ on $H$ as follows. Assume that the spider graph $G$ contains $\ell$ legs, and the $k$-th leg is denoted by $L_k$ (so $E(G)=\bigcup_{1\le k\le \ell}E(L_k)$).
Then $H$ is a star graph with $\ell$ edges, that are denoted by $\tilde e_{1}, \tilde e_2,\ldots,\tilde e_{\ell}$, respectively.
We now construct the buyer profile $\mathcal{F}'$ iteratively.
Denote $\mathcal{Q}=\set{Q_1,\ldots,Q_n}\cup \set{(e_i)\mid e_i\in E(G)}$.
Throughout, we maintain: (i) for each path $Q\in \mathcal{Q}$, a real number $x_Q$, that is initialized as follows: if $Q=Q_j$ for some $j\in [n]$, then $x_Q=y^*_j$; if $Q=(e_i)$ for some $e_i\in E(G)$, then $x_Q=\hat y^*_i$; and
(ii) a buyer profile $\mathcal{F}'$, that initially contains no buyers.
In each iteration, we will add one buyer into $\mathcal{F}'$ and modify the values $\set{x_Q}_{q\in \mathcal{Q}}$. We will maintain the invariant that for each $1\le k\le \ell$, the sum $Z_e=\sum_{Q: e\in Q}x_Q$ are the same for all edges $e\in E_k$ of the $k$-th leg are the same (but the sums $Z_e,Z_{e'}$ may be distinct for edges $e,e'$ that belong to distinct legs). Clearly, initially this invariant holds.
We now describe an iteration. Let $\hat Q=\arg_{Q\in \mathcal{Q}: x_Q\ne 0}\min\set{x_Q}$.
We consider the following two cases.
\textbf{Case 1. Path $\hat Q$ contains edges from two distinct legs.} Assume path $\hat Q$ contains some edges from $L_{k_1},L_{k_2}$. Let $P_1$ be the subpath of $L_{k_1}$ formed by edges of $L_{k_1}\setminus \hat Q$, and we define $P_2$ similarly. We denote by $v_1,v'_1$ the endpoints of $P_1$, where $v'_1$ is the leaf of the leg $L_{k_1}$. We use the following claim.
\begin{claim}
\label{clm: extending path}
If $P_1\ne \emptyset$, then there exists an path $Q\in \mathcal{Q}$, such that (i) $x_Q\ge x_{\hat Q}$; and (ii) $Q$ is a subpath of $P_1$ and contains $v_1$ as one of its endpoints.
\end{claim}
\begin{proof}
Denote by $\hat e,\hat e'$ the edges incident to $v_1$, where $\hat e$ belongs to $\hat Q$ and $\hat e'$ belongs to $P_1$.
Assume for contradiction that there is no such $Q$, then any path $Q\in \mathcal{Q}$ with $x_Q>0$ that contains edge $\hat e'$ must also contain edge $\hat e$. However, since edges $\hat e,\hat e'$ belong to the same leg, and the path $\hat Q$ contains $\hat e$ but not $\hat e'$, the invariant that $Z_{\hat e}=Z_{\hat e'}$ cannot hold, a contradiction.
\end{proof}
As an easy corollary of Claim~\ref{clm: extending path}, we can find a set $\mathcal{Q}'_1\subseteq \mathcal{Q}$ of paths, such that (i) the paths of $\mathcal{Q}'_1$ are edge-disjoint; (ii) the union of paths of $\mathcal{Q}'_1$ is $P_1$; and (iii) for each $Q\in \mathcal{Q}'_1$, the value $x_Q\ge x_{\hat Q}>0$.
Similarly, we can find a set $\mathcal{Q}'_2\subseteq \mathcal{Q}$ of paths, such that (i) the paths of $\mathcal{Q}'_2$ are edge-disjoint; (ii) the union of paths of $\mathcal{Q}'_2$ is $P_2$; and (iii) for each $Q\in \mathcal{Q}'_2$, the value $x_Q\ge x_{\hat Q}>0$.
Therefore, if we set $\mathcal{Q}'=\set{\hat Q}\cup \mathcal{Q}'_1\cup \mathcal{Q}'_2$, then the paths of $\mathcal{Q}'$ are edge-disjoint, their union is $L_{k_1}\cup L_{k_2}$, and for each path $Q\in \mathcal{Q}'$, $x_Q\ge x_{\hat Q}$.
We then add a buyer to $\mathcal{F}'$ as follows. Its demand path $P$ contains two edges $\tilde e_{k_1}, \tilde e_{k_1}$, and its value is defined as $v(P)=\sum_{Q\in \mathcal{Q}'}v(Q)$.
We also define $w^*_P=x_{\hat Q}$, and then we decrease the value $x_Q$ for all $Q\in \mathcal{Q}'$ by $x_{\hat Q}$.
\textbf{Case 2. Path $\hat Q$ contains edges from one leg.} Assume path $\hat Q$ contains only edges of $L_{k_1}$. We define path $P_1$ similarly as in Case 1. Via similar arguments, we can compute a set $\mathcal{Q}'_1$ of edge-disjoint paths whose union is $P_1$, and $x_Q\ge x_{\hat Q}> 0$ for each path $Q\in \mathcal{Q}'_1$.
We denote by $v_2$ the endpoint of $\hat Q$ that is closer to the center of the spider.
If $v_2$ is the center then we set $\mathcal{Q}'_2=\emptyset$.
Otherwise, by repeatedly applying Claim~\ref{clm: extending path} to the subpath of $L_{k_1}$ between $v_2$ and the center (that we denote by $P_2$), we can compute a set $\mathcal{Q}'_2$ of edge-disjoint paths with $x_Q\ge x_{\hat Q}> 0$ for each path $Q\in \mathcal{Q}'_2$, such that the union of paths of $\mathcal{Q}'_2$ is either $P_2$ or the union of $P_2$ with some other entire leg $L_{k_2}$.
Assume the former, then we add a buyer to $\mathcal{F}'$ as follows. Its demand path $P$ contains one edge $\tilde e_{k_1}$, and its value is defined as $v(P)=\sum_{Q\in \mathcal{Q}'}v(Q)$, where $\mathcal{Q}'=\set{\hat Q}\cup \mathcal{Q}'_1\cup \mathcal{Q}'_2$.
Assume the latter, then we add a buyer to $\mathcal{F}'$ as follows. Its demand path $P$ contains two edges $\tilde e_{k_1},e_{k_2}$, and its value is defined as $v(P)=\sum_{Q\in \mathcal{Q}'}v(Q)$.
In both cases, we also define $w^*_P=x_{\hat Q}$, and then we decrease the value $x_Q$ for all $Q\in \mathcal{Q}'$ by $x_{\hat Q}$.
We say that paths in $\mathcal{Q}'$ \emph{contributes} to path $P$.
This finishes the description of an iteration.
Clearly, after each iteration, the invariant that for each $1\le k\le \ell$, the sum $Z_e$ are the same for all edges $e\in E_k$ of the $k$-th leg still holds. Moreover, the number of paths $Q$ in $\mathcal{Q}$ with $x_Q>0$ is decreased by at least one after each iteration. Therefore, the algorithm terminates in $m+n$ iterations.
At the end, $x_Q=0$ for all paths $Q\in \mathcal{Q}$.
Let $\mathcal{F}'=\set{(P,v_P)}_{P\in \mathcal{P}}$ be the buyer profile that we get at the end of the algorithm.
It is easy to see that (i) for each $j\in [n]$, $y^*_{j}=\sum_{P: Q_j\text{ contributes to }P}w^*_P$, and for each $1\le i\le n$, $\hat y^*_j=\sum_{P: (e_i)\text{ contributes to }P}w^*_P$; and (ii) $\sum_{P\in \mathcal{P}}v_P\cdot w^*_P=\sum_{j\in [n]}v_j\cdot y^*_j$.
We consider the following linear program.
\begin{eqnarray*}
\mbox{(LP-2)} &\text{maximize }
\sum_{P\in \mathcal{P}}v_P\cdot w_P\\
\mbox{s.t.}
& \sum_{P: \tilde e_i\in P}w_P= 1&\forall\text{ }1\le i\le \ell\\
& w_P\ge 0&\forall\text{ } P\le \mathcal{P}
\end{eqnarray*}
We now show that $w^*=(w^*_P)_{P\in \mathcal{P}}$ is an optimal solution of (LP-2). Assume the contrast that there exists another feasible solution $w'=(w'_P)_{P\in \mathcal{P}}$ of (LP-2), such that $\sum_{P\in \mathcal{P}}v_P\cdot w^*_P<\sum_{P\in \mathcal{P}}v_P\cdot w'_P$.
We define vector $y'\in [0,1]^n$ as: for each $j\in [n]$, $y'_j=\sum_{P: Q_j\text{ contributes to }P}w'_P$, and define vector $\hat y'\in [0,1]^n$ as: for each $1\le i\le n$, $\hat y'_j=\sum_{P: (e_i)\text{ contributes to }P}w'_P$. It is easy to see that $(y',\hat y')$ is a feasible solution to (LP-1), and moreover, $\sum_{j\in [n]}v_j\cdot y'_j=\sum_{P\in \mathcal{P}}v_P\cdot w'_P>\sum_{P\in \mathcal{P}}v_P\cdot w^*_P=\sum_{j\in [n]}v_j\cdot y^*_j$. This causes a contradiction to the optimality of $(y^*,\hat y^*)$.
Therefore, from Lemma~\ref{lem:matching-half-integral}, $w^*$ is half-integral. Since for each $j\in [n]$, $y^*_{j}=\sum_{P: Q_j\text{ contributes to }P}w^*_P$, and for each $1\le i\le n$, $\hat y^*_j=\sum_{P: (e_i)\text{ contributes to }P}w^*_P$, $(y^*,\hat y^*)$ is also half-integral. It follows that $y^*$ is half-integral.
\end{prevproof}
\begin{prevproof}{Lemma}{lem:tree-coloring}
We construct an algorithm that partitions the set $\mathcal{Q}$ of paths into $d+1$ subsets $\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}$.
We root $T$ at an arbitrarily chosen vertex $r\in V(T)$, and we say that a vertex $v\in V(T)$ is \emph{at the $i$-th level} iff the tree-distance between $v$ and $r$ in $T$ is $i$.
The algorithm will compute the sets $\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}$ iteratively.
Initially, all sets are set to be $\emptyset$.
The algorithm proceeds sequentially in phases. In the $i$-th phase, the algorithm process all vertices at the $i$-th level one-by-one.
Upon processing a vertex $v$, we will assign all paths containing at least one edge of $E_v$ to some set of $\set{\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}}$, where $E_v$ is the set of edges connecting $v$ to some of its children.
Fix an integer $i$ and a vertex $v$ at the $i$-th level, and we now describe the iteration of processing the vertex $v$. Let $\mathcal{Q}(v)$ contain all paths of $\mathcal{Q}$ that contains at least one edge connecting $v$ to some of its children.
The $\mathcal{Q}(v)$ can be partitioned into three subsets:
set $\mathcal{Q}^0(v)$ contains all paths of $\mathcal{Q}(v)$ that are already assigned to some set of $\set{\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}}$;
set $\mathcal{Q}^1(v)$ contains all paths of $\mathcal{Q}(v)$ that are not yet already assigned and contains exactly $1$ edge of $E_v$; and
set $\mathcal{Q}^2(v)$ contains all paths of $\mathcal{Q}(v)$ that are not yet already assigned and contains exactly $2$ edges of $E_v$.
Note that each path of $\mathcal{Q}^0(v)$ must contain the edge $\hat e$ connecting $v$ to its parent vertex and exactly one edge of $E_v$, so they must belong to distinct sets of $\set{\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}}$.
We construct an auxiliary graph $H$ as follows.
The vertex set is $V(H)=\set{u_{\hat e}}\cup \set{u_e\mid e\in E_v}\cup \set{\hat u_Q\mid Q\in \mathcal{Q}^1(v)}$. The edge set is partitioned into three subsets $E(H)=E_0\cup E_1\cup E_2$, where
$E_0=\set{(u_e,v)\mid Q\in \mathcal{Q}^0(v), e= Q\cap E_v}$, $E_1=\set{(u_e,\hat u_Q)\mid Q\in \mathcal{Q}^1(v), e= Q\cap E_v}$, and
$E_2=\set{(u_e,u_{e'})\mid Q\in \mathcal{Q}^2(v), \set{e,e'}= Q\cap E_v}$.
Clearly, every path of $\mathcal{Q}(v)$ correspond to an edge in $E(H)$, that we denote by $f_Q$.
It is clear from the definition of $H$ that, for every pair $Q,Q'$ of paths in $\mathcal{Q}(v)$, $Q$ and $Q'$ are edge-disjoint iff edges $f_{Q}$ and $f_{Q'}$ of $E(H)$ do not share a vertex.
Since every edge $e\in E_v$ is contained in at most $d$ paths of $\mathcal{Q}(v)$, from the definition of graph $H$, every vertex in $H$ has degree at most $d$.
From Vizing's Theorem~\cite{vizing1964estimate,misra1992constructive}, we can efficiently find a coloring of all edges of $E(H)$ with $d+1$ colors, such that edges with same color do not share vertices.
Note that, since all edges in $\set{f_Q\mid \mathcal{Q}^{0}(v)}$ share the vertex $u_{\hat e}$, these edges will have different colors in any valid edge-coloring.
We now assign, for each $Q\in \mathcal{Q}^{0}(v)$, all paths $Q'$ of $\mathcal{Q}(v)$ whose corresponding edge $f_{Q'}\in \mathcal{Q}(v)$ has the same color as edge $f_Q$, to the same set of $\set{\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}}$.
And then we assign, for any color that is not used by edges in $\set{f_Q\mid Q\in \mathcal{Q}^{0}(v)}$, all paths whose corresponding edge $f_{Q'}\in \mathcal{Q}(v)$ has this color to a distinct set of $\set{\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}}$ that does not contain paths of $ \mathcal{Q}^{0}(v)$.
This completes the iteration of processing the vertex $v$.
Since edges of have different colors, it is clear that, after this iteration, each set of $\set{\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}}$ contains edge-disjoint paths.
Therefore, if we keep processing all vertices in this way, then we obtain a valid partition of the original set $\mathcal{Q}$ of paths into at most $d+1$ subsets $\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}$, such that the paths in each subset are edge-disjoint.
\end{prevproof}
\subsection{Cycles}\label{sec:cycle}
Now we consider the case where $G$ is a cycle. We denote $V(G)=\set{u_1,\ldots,u_{m}}$, where the vertices appear on the cycle in this order. Therefore, $E(G)=\{(u_i,u_{i+1})\mid 1\le i\le m\}$ (here $u_{m+1}=u_1$). For every pair $a,b$ of distinct integers in $\set{1,\ldots,m}$, we denote by $P_{a,b}$ the path $(u_a,u_{a+1},\ldots,u_b)$.
\begin{theorem}
\label{thm:cycle}
$\emph{\textnormal{\textsf{gap}}}(\mathsf{Cycle})\leq 2$. Moreover, the prices that achieve the competitive ratio 2 can be computed efficiently.
\end{theorem}
\begin{proof}
Let $\mathcal{Q}^*\subseteq\set{Q_1,\ldots,Q_n}$ be the set of edge-disjoint paths that achieves the optimal welfare, namely $\mathsf{OPT}(G,\mathcal{F})=\sum_{Q_j\in \mathcal{Q}^*}v_j$.
We distinguish between the following two cases.
\textbf{Case 1. $|\mathcal{Q}^*|=1$.} Assume without loss of generality that $\mathcal{Q}^*=\set{Q_1}=\set{P_{a,b}}$. We first set the prices for all edges of $G\setminus P_{a,b}$ to be $+\infty$. Consider now the instance $(G',\mathcal{F}')$, where $G'=P_{a,b}$ and $\mathcal{F}'=\set{(Q_i,v_i)\in \mathcal{F}\mid Q_i\subseteq P_{a,b}}$. Clearly, $\mathsf{OPT}(G,\mathcal{F})=\mathsf{OPT}(G',\mathcal{F}')=v_1$. Since $G'$ is a path, from Theorem~\ref{thm:path}, there exist prices $\set{p'_i}_{i\in P_{a,b}}$ on edges of $P_{a,b}$ that achieves the worst-case welfare $\mathsf{OPT}(G',\mathcal{F}')$. We now set $p_i=p'_i$ for each $i\in P_{a,b}$. It is easy to verify that prices $\set{p_i}_{i\in [m]}$ achieve the worst-case welfare $\mathsf{OPT}(G,\mathcal{F})$.
\textbf{Case 2. $|\mathcal{Q}^*|\ge 2$.} Assume without loss of generality that $\mathcal{Q}^*=\set{Q_1,\ldots,Q_k}$, with $v_1\le \ldots \le v_k$.
If $E(G)\ne\bigcup_{1\le j\le k}E(Q_j)$, then we set $p_i=+\infty$ for all edges of $E(G)\setminus \bigcup_{1\le j\le k}E(Q_j)$ and consider the instance $(G',\mathcal{F}')$, where $G'= \bigcup_{1\le j\le k}Q_j$ and $\mathcal{F}'=\set{(Q_j,v_j)\in \mathcal{F}\mid Q_j\subseteq G'}$. Clearly, $\mathsf{OPT}(G,\mathcal{F})=\mathsf{OPT}(G',\mathcal{F}')=\sum_{1\le i\le k}v_i$ and $G'$ is the union of a set of vertex-disjoint paths. Again by Theorem~\ref{thm:path}, there exist $\set{p_i}_{i\in E(G)}$ achieves the worst-case welfare $\mathsf{OPT}(G,\mathcal{F})$. Now suppose $E(G)= \bigcup_{1\le i\le k}E(Q_i)$, i.e. $Q^*$ covers the whole cycle. We set $p_i=+\infty$ for all edges of $Q_1$ and consider the instance $(G',\mathcal{F}')$, where $G'= \bigcup_{2\le j\le k}Q_j$ and $\mathcal{F}'=\set{(Q_j,v_j)\in \mathcal{F}\mid Q_j\subseteq G'}$. Clearly, since $v_1$ is the smallest among all $v_j$s, $\mathsf{OPT}(G',\mathcal{F}')=\sum_{2\le j\le k}v_j\ge \mathsf{OPT}(G,\mathcal{F})/2$ and $G'$ is a line graph. By Theorem~\ref{thm:path}, there exist prices $\set{p_i}_{i\in [m]}$ that achieve the worst-case welfare $\mathsf{OPT}(G,\mathcal{F})/2$.
\end{proof}
To complement Theorem~\ref{thm:cycle}, we show in the following theorem that the competitive ratio $1/2$ for cycles is tight.
\begin{theorem}
\label{thm: cycle_lower_bound}
For any $\epsilon>0$, $\emph{\textnormal{\textsf{gap}}}(\mathsf{Cycle})>2-\epsilon$.
\end{theorem}
\begin{proof}
For any $\epsilon>0$, we construct an instance $(G,\mathcal{F})$ such that no set of prices can achieve worst-case welfare at least $\frac{1}{2-\epsilon}\cdot\mathsf{OPT} (G,\mathcal{F})$, when the seller has the tie-breaking power. We set integers $m=10\cdot\lceil1/\epsilon\rceil$ and $k=m/2+1$. The instance $(G,\mathcal{F})$ is defined as follows.
$G$ is a cycle with $m$ vertices. $\mathcal{F}=\set{(Q_j,v_j)\mid 1\le j\le m+2}$.
Specifically, for each $1\le j\le m$, we define $Q_j=P_{j,k+j}$, and we define $Q_{m+1}=P_{1,k}$ and $Q_{m+2}=P_{k,1}$.
See \Cref{fig:cycle}.
For each $1\le j\le m$, we define the value $v_j=k+1$.
For each $j=m+1,m+2$, we define the value $v_j=k-1$.
\begin{figure}[h]
\centering
\includegraphics[width=0.4\columnwidth]{cycle_example.jpg}
\caption{An illustration of paths $Q_1,Q_{m+1},Q_{m+2}$.\label{fig:cycle}}
\end{figure}
In the instance there are $m$ paths with length $m/2+1$, and 2 paths with length $m/2$. It is clear that the optimal solution is $\set{Q_{m+1},Q_{m+2}}$, so $\mathsf{OPT} (G,\mathcal{F})=m$.
We will prove that there do not exist prices that achieve worst-case welfare strictly larger than $k+1$. Let $\{p_i\}_{i\in [m]}$ be any set of prices. We consider two cases. Assume first that $\sum_{i\in [m]}p_i\ge m+1$. Since $v_{m+1}=v_{m+2}=m/2$, at least one of buyers $m+1$ and $m+2$ cannot afford its path. Note that any path in $\{Q_1,...,Q_m\}$ intersects with all other paths. Thus for any arrival order, the achieved welfare is at most $k+1$.
Assume now that $\sum_{i\in [m]}p_i< m+1$. We claim that at least one of the buyers $1,\ldots,m$ can afford her path with a strictly positive utility. It implies that the worst-case welfare is at most $k+1$, since if such a buyer comes first and takes her path, all other demand paths are blocked.
To prove the claim, we notice that each edge appears in exactly $k$ paths of $\set{Q_1,\ldots,Q_m}$, so $\sum_{1\le j\le m}p(Q_j)=k\cdot \sum_{i\in [m]}p(e)\le k(m+1)$. On the other hand, $\sum_{1\le j\le m}v_j=(k+1)m\ge k(m+1)$. Therefore, there exists some $1\le j\le m$ such that $p(Q_j)<v_j$. Thus the worst-case welfare of any item pricing is at most $k+1<\frac{m}{2-\epsilon}$, for $m=10\cdot\lceil1/\epsilon\rceil$.
\end{proof}
\section{Future Work}\label{sec:future}
We study the worst-case welfare of item pricing in the tollbooth problem.
There are several future directions following out results. Firstly, in the paper we assume that all buyers' value are all public. A possible future direction is to study the Bayesian setting where the seller does not have direct access to each buyer's value, but only know the buyers' value distributions. Secondly, we focus on the tollbooth problem where each buyer demands a fixed path on a graph. An alternative setting is that each buyer has a starting vertex and a terminal vertex on the graph, and she has a fixed value for getting routed through any path on the graph. Such a setting is equivalent to the tollbooth problem when the underlying graph is a tree, where a constant competitive ratio is proved in our paper.
However, there may exist more than one path between two vertices in a graph beyond tree, and thus the buyer is not single-minded in this setting. In the paper we have shown that item pricing may not approximate the optimal welfare well in the tollbooth problem. It remains open whether the item pricing performs well in the alternative setting.
Thirdly, the power of tie-breaking hasn't been studied much in the literature on mechanism design. It would be interesting to see other scenarios where the tie-breaking power also makes much difference.
\section{General Set Packing}
\label{sec: general case}
In this section we consider the general case. We denote by $U=\set{1,\ldots,n}$ the ground set of items, and for each $1\le j\le m$, we denote by $S_j$ be the demand set of buyer $B_j$, and let $v_j$ be its value.
The main result in this section is summarized in the following theorem.
\begin{theorem}
\label{thm:general_case}
For any given buyer-profile $\mathcal{F}=\set{(S_j,v_j)}_{1\le j\le m}$, there exists a set of prices on items of $U$, that achieves worst-case revenue at least $\Omega(\mathsf{OPT}(U,\mathcal{F})/\sqrt{n})$, even without the power of tie breaking.
\end{theorem}
\begin{proof}
Let $\mathcal{S}=\set{S_1,\ldots,S_m}$.
We say that a subset $\tilde \mathcal{S}$ of $\mathcal{S}$ is \emph{independent} iff the sets in $\tilde\mathcal{S}$ are mutually disjoint.
Let $\mathcal{S}^*$ be the independent subset of $\mathcal{S}$ that, over all independent subsets of $\mathcal{S}$, maximizes the total value, namely $\mathcal{S}^*=\arg_{\tilde \mathcal{S} \subseteq \mathcal{S}: \tilde \mathcal{S} \text{ is independent}}\max\set{\sum_{S_j\in \tilde\mathcal{S}}v_j}$.
We denote $\mathcal{S}^*=\set{S_{j_1},\ldots,S_{j_t}}$, $J=\set{j_1,\ldots,j_t}$ and $\hat S=\bigcup_{j\in J}S_J$, so $\mathsf{OPT}(U,\mathcal{F})=\sum_{j\in J}v_j$.
Let $p=\set{p(i)}_{1\le i\le n}$ be a set of prices. We say that a demand set $S_j$ \emph{survives} the price $p$, or that the buyer $B_j$ can \emph{afford} her demand set $S_j$ under the price $p$, iff $v_j>p(S_j)=\sum_{i\in S_j}p(i)$. For convenience, we sometimes refer to $v_j$ by $v(S_j)$.
For brevity, we denote $\mathsf{OPT}=\mathsf{OPT}(U,\mathcal{F})$.
We compute the prices that achieves worst-case revenue $\Omega(\mathsf{OPT}/\sqrt{n})$ in two steps.
In the first step, for each item that does not belong to set $\hat S$, we set its price to be $+\infty$; while for each item in $\hat S$, we set its price to be $\mathsf{OPT}/100|\hat S|$. Denote by $\mathcal{S}'$ the set of all demand sets that survive the prices set in the first step.
Clearly, each set in $\mathcal{S}'$ is a subset of $\hat S$.
We show in the following claim that the sets of $\mathcal{S}^*$ that survive the prices in the first step contain most of the value in $\mathcal{S}^*$.
\begin{observation}
\label{obs:most_value_survive}
$\sum_{S\in (\mathcal{S}^*\cap \mathcal{S}')}v(S)\ge 0.99\cdot\mathsf{OPT}$.
\end{observation}
\begin{proof}
By definition,
$$\sum_{S\in \mathcal{S}^*\setminus \mathcal{S}'}v(S)\le \sum_{S\in \mathcal{S}^*\setminus \mathcal{S}'}p(S)\le
\frac{\mathsf{OPT}}{100|\hat S|}\cdot \left(\sum_{S\in \mathcal{S}^*\setminus \mathcal{S}'}|S|\right)
\le
\frac{\mathsf{OPT}}{100|\hat S|}\cdot |\hat S|=0.01\cdot \mathsf{OPT},
$$
where the last inequality is because the subset $\mathcal{S}^*$ is independent and the sets in $\mathcal{S}^*$ are all subsets of $\hat S$. It follows that
$\sum_{S\in (\mathcal{S}^*\cap \mathcal{S}')}v(S)=\sum_{S\in \mathcal{S}^*}v(S)-\sum_{S\in (\mathcal{S}^*\setminus \mathcal{S}')}v(S)\ge \mathsf{OPT}-0.01\cdot\mathsf{OPT}= 0.99\cdot\mathsf{OPT}$.
\end{proof}
In the second step, we first compute a hitting set $H$ of sets in $\mathcal{S}'$ with minimum size. Specifically, we compute (by brute force) a subset $H$ of $\hat S$ that, among all subsets of $\hat S$ that intersects every set in $\mathcal{S}'$, minimizes the cardinality.
We distinguish between two cases, depending on whether or not $|H|$ is sufficiently large.
\textbf{Case 1. $|H|>\sqrt{n}$.}
In this case we simply let the prices set in the first step be the final prices of the items. We claim that these prices guarantee the worst-case revenue of at least $0.01\cdot\mathsf{OPT}/\sqrt{n}$. To see this, notice that (i) for every set $S_j\notin \mathcal{S}'$, whenever buyer $B_j$ comes, she cannot afford her demand set $S_j$ (since $p(S_j)=+\infty>v(S_j)$); and (ii) no matter in what order come the buyers, the set of sold items in $\hat S$ at the end of the selling process must form a hitting set of all sets of $\mathcal{S}'$ (since otherwise there exists a set $S_j\in \mathcal{S}'$ with none of its items sold at the end of the selling process; but then when buyer $B_j$ comes in the selling process, all items of $S_j$ are available, and $p(S_j)<v_j$, a contradiction). Therefore, the number of sold items in $\hat S$ is at least $\sqrt{n}$. Recall that each item in $\hat S$ was priced $\mathsf{OPT}/100|\hat S|$, we can therefore conclude that the revenue is at least
$\sqrt{n}\cdot(\mathsf{OPT}/100|\hat S|)\ge 0.01\cdot\mathsf{OPT}/\sqrt{n}$.
\textbf{Case 2. $|H|\le \sqrt{n}$.}
In this case, for each item $i\in H$, we increase the current price of $i$ (which is the price of item $i$ set in the first step) by $\mathsf{OPT}/100|H|$. We let these modified prices be the final prices.
We first show in that there exists at least one set in $\mathcal{S}^*\cap \mathcal{S}'$ that survives $\tilde p$.
Assume for contradiction that no sets in $\mathcal{S}^*\cap \mathcal{S}'$ survived the price $\tilde p$.
Since the sets in $\mathcal{S}^*\cap \mathcal{S}'$ are mutually disjoint,
$$\sum_{S\in (\mathcal{S}^*\cap \mathcal{S}')} v(S)\le
\sum_{S\in (\mathcal{S}^*\cap \mathcal{S}')} \tilde p(S) \le
\frac{\mathsf{OPT}}{100|\hat S|}\cdot |\hat S|+ \frac{\mathsf{OPT}}{100|H|}\cdot|H|\le 0.02\cdot\mathsf{OPT},$$
a contradiction to Observation~\ref{obs:most_value_survive}.
As a result, at least one set in $\mathcal{S}'$ survives $\tilde p$, and therefore, at the end of the the selling process, at least one buyer will get her demand set (which is not necessarily a set in $\mathcal{S}^*\cap \mathcal{S}'$).
On the other hand, since each set in $\mathcal{S}'$ contains an item in $H$, the price for each set in $\mathcal{S}'$ is at least $\mathsf{OPT}/100|H|\ge 0.01\cdot\mathsf{OPT}/\sqrt{n}$.
Therefore, we will obtain revenue at least $0.01\cdot\mathsf{OPT}/\sqrt{n}$.
\end{proof}
We complement Theorem~\ref{thm:general_case} with the following theorem.
\begin{theorem}\label{thm:general_hardness}
For each integer $n>0$, there is a buyer-profile $\mathcal{F}=\set{(S_j,v_j)}_{1\le j\le m}$, such that any set of prices on items of $U$ can achieve worst-case revenue at most $O(\mathsf{OPT}(U,\mathcal{F})/\sqrt{n})$, even with the power of tie breaking.
\end{theorem}
\begin{proof}
Let $r$ be the largest integer such that $n\ge \binom{r}{2}$, so $r=\Theta(\sqrt{n})$.
Let $K_r$ be a complete graph on $r$ vertices, and denote its vertex set by $V(K_r)=\set{u_1,u_2,\ldots,u_r}$.
The ground set is defined to be the union of the set of all edges in $K_r$ and some other arbitrary $n-\binom{r}{2}$ elements, namely $E(K_r)\subseteq U$. There are $r+1$ buyers $B_0,B_1,\ldots,B_{r}$. The buyer $B_0$ demands the set of all edges, namely $S_0=E(K_r)$, with value $v_0=1$. For each $1\le i\le r$, the buyer $B_i$ demands the set of incident edges of vertex $u_i$, namely $S_i=\set{(u_i,u_j)\mid 1\le j\le r, j\ne i}$), with value $v_i=3/r$.
Since for any $1\le j_1 < j_2\le r$, the demand sets $S_{j_1}$ and $S_{j_2}$ intersect, the optimal allocation is to assign all edges to buyer $B_0$, so $\mathsf{OPT}(U,\mathcal{F})=1$. However, as we will show now, any set $\set{p(e)}_{e\in E(K_r)}$ of prices will only guarantee to achieve revenue at most $3/r$.
In fact, if there exists $1\le j\le r$, such that $p(S_j)=\sum_{e\in S_j}p(e)< 3/r$, then we let the buyer $B_j$ comes first, so $B_j$ will get her demand set $S_j$ at price less than $3/r$. Since $S_j$ intersects every other demand set, no matter in what order come the other buyers, the revenue obtained by this selling process is at most $3/r$. Consider now the case where for each $1\le j\le r$, $p(S_j)\ge 3/r$.
Since every edge appears in exactly two demand sets of $\set{S_1,\ldots,S_r}$, $p(S_0)=\sum_{1\le j\le r}p(S_j)/2$, so $p(S_0)\ge r(3/r)/2=3/2>1$ and buyer $B_0$ cannot afford her demand set, either.
Therefore, in this case the selling process ends up achieving revenue $0$.
\end{proof}
\section{Competitive Ratio for General Graphs}
\label{sec: general graph}
In this section we study the competitive ratio when $G$ is a general graph. Again in this section we assume that the seller owns the tie-breaking power. We will start by showing an $\Omega(m^{1/8})$ lower bound by constructing an instance in the serial-parallel graph (Section~\ref{subsec: general graph lower bound}). Then we use a modification of this instance to prove lower bounds in grids and outerplanar graphs (Sections~\ref{subsec: grid lower bound},~\ref{subsec: lower bound outerplanar}). At last, we prove an upper bound for the competitive ratio in general graphs, that depends on the number of buyers (Section~\ref{sec:generalgraphub}).
\subsection{Lower Bound for General Graphs}
\label{subsec: general graph lower bound}
\begin{theorem}\label{thm:lb-mahua}
$\emph{\textnormal{\textsf{gap}}}(\emph{\textsf{General\text{ }Graphs}})=\Omega(m^{1/8})$, i.e., there exist a graph $G$ with $|E(G)|=m$ and a buyer profile $\mathcal{F}$ on $G$, such that no set of prices on edges of $G$ can achieve worst-case welfare $\Omega(\mathsf{OPT}(G,\mathcal{F})/m^{1/8})$.
\end{theorem}
The remainder of this subsection is dedicated to the proof of Theorem~\ref{thm:lb-mahua}. We will construct the graph $G$ as follows.
For convenience, we will construct a family of graphs $\set{H_{a,b}}_{a,b\in \mathbb{Z}}$, in which each graph is featured by two parameters $a,b$ that are positive integers. We will set the exact parameters that will be used for the proof of \Cref{thm:lb-mahua} later.
For a pair $a,b$ of integers, graph $H_{a,b}$ is defined as follows. The vertex set is $V(H_{a,b})=V_1\cup V_2$, where $V_1=\set{v_0,\ldots,v_{b}}$ and $V_2=\set{u_{i,j}\mid 1\le i\le b,1\le j\le a}$. The edges set is $E(H_{a,b})=\bigcup_{1\le i\le b}E_i$, where $E_i=\set{(v_{i-1},u_{i,j}), (v_{i},u_{i,j})\mid 1\le j\le a}$. See \Cref{fig:mahua} for an example.
Equivalently, if we define the multi-graph $L_{a,b}$ to be the graph obtained from a length-$b$ path by duplicating each of its edges $a$ times, then we can view $H_{a,b}$ as obtained from $L_{a,b}$ by subdividing each edge by a new vertex.
\begin{figure}[htb]
\centering
\includegraphics[width=0.7\columnwidth]{mahua.jpg}
\caption{An illustration of graph $H_{4,4}$.\label{fig:mahua}}
\end{figure}
Let $a,b$ be such that $b=a+3a^3$ and choose $G=H_{a,b}$. Clearly $m=|E(G)|=2ab$, so $a=\Theta(m^{1/4})$ and $b=\Theta(m^{3/4})$. For convenience, we can simply work with graph $L_{a,b}$, since every path in $L_{a,b}$ is also a path in $H_{a,b}$.
Note that $V(L_{a,b})=\set{v_0,\ldots,v_{b}}$, and we denote by $e_{i,1},\ldots,e_{i,a}$ the edges in $L_{a,b}$ connecting $v_{i-1}$ and $v_{i}$.
For brevity, we use the index sequence $(j_1,j_2,\ldots,j_b)$ to denote the path consisting of edges $e_{1,j_1},e_{2,j_2},\ldots,e_{b,j_b}$, where each index $j_t\in [a]$, for each $t\in [b]$. It is clear that a pair of paths $(j_1,j_2,\ldots,j_b)$ and $(j'_1,j'_2,\ldots,j'_b)$ are edge-disjoint iff for each $t\in [b]$, $j_t\ne j'_t$. In the proof we will construct a buyer profile $\mathcal{F}$ on the multi-graph $L_{a,b}$. Clearly it can be converted to a buyer profile on graph $H_{a,b}$, with the same lower bound of competitive ratio. We prove the following lower bound of competitive ratio for $L_{a,b}$. Theorem~\ref{thm:lb-mahua} follows directly from Lemma~\ref{lem:ratio-Lab} where $a=\Theta(m^{1/4})$ and $b=\Theta(m^{3/4})$.
\begin{lemma}\label{lem:ratio-Lab}
$\emph{\textnormal{\textsf{gap}}}(L_{a,b})\geq \sqrt{a}$.
\end{lemma}
\begin{proof}
We define $\mathcal{F}$ on graph $L_{a,b}$ as follows. We will first define a set $\mathcal{F}^*$ of buyer profile, and then define, for each subset $S\subseteq [a]$ with $|S|\ge \sqrt{a}$, a buyer profile $\mathcal{F}_S$, where the buyers in different sets are distinct. Then we define $\mathcal{F}=\mathcal{F}^*\cup(\bigcup_{S\subseteq [a], |S|\ge \sqrt{a}}\mathcal{F}_S)$.
Let the set $\mathcal{F}^*$ contain, for each $r\in [a]$, a buyer $r$ with $Q^{(r)}=(r,r,\ldots,r)$ and $v_r=1$.
Clearly, demand paths of buyers in $\mathcal{F}^*$ are edge-disjoint. In the construction we will guarantee that $\mathsf{OPT}(L_{a,b},\mathcal{F})=a$, achieved by giving each buyer in $\mathcal{F}^*$ her demand path.
Before we construct the sets $\set{\mathcal{F}_S}_{S\subseteq [a], |S|\ge \sqrt{a}}$, we will first state some desired properties of sets $\set{\mathcal{F}_S}$, and use it to finish the proof of \Cref{lem:ratio-Lab}. Let $\varepsilon>0$ be an arbitrarily small constant.
\begin{enumerate}
\item \label{prop1}For each $S$, set $\mathcal{F}_S$ contains $2|S|$ buyers, and every pair $Q,Q'$ of demand paths in $\mathcal{F}_S$ share an edge. The value for every buyer appeared in $\mathcal{F}_S$ is $1+\epsilon$.
\item \label{prop3}For each demand path $Q$ in $\mathcal{F}_S$, the index sequence $(j^Q_1,\ldots,j^Q_b)$ that $Q$ corresponds to satisfies that (i) $j^Q_i\in S$ for each $i\in [b]$; and (ii) the set $\set{j^Q_1,\ldots,j^Q_b}$ contains all element of $S$.
\item \label{prop4}The union of all demand paths in $\mathcal{F}_S$ covers the graph $\bigcup_{r\in S}Q^{(r)}$ exactly twice. In other words, for each $i\in [b]$ and every $r\in S$, there are exactly two demand paths $Q$ appeared in $\mathcal{F}_S$ that satisfy $j_i^Q=r$.
\item \label{prop5}For any pair $S,S'\subseteq [a]$ such that $|S|,|S'|\ge \sqrt{a}$ and $S\cap S'\ne \emptyset$, and for any demand path $Q$ appeared in $\mathcal{F}_S$ and $Q'$ appeared in $\mathcal{F}_{S'}$, $Q$ and $Q'$ share some edge.
\end{enumerate}
Suppose we have successfully constructed the sets
$\set{\mathcal{F}_S}_{S\subseteq [a], |S|\ge \sqrt{a}}$ that satisfy all the above properties. We then define $\mathcal{F}=\mathcal{F}^*\cup(\bigcup_{S\subseteq [a], |S|\ge \sqrt{a}}\mathcal{F}_S)$.
From the above properties, it is easy to see
that $\mathsf{OPT}(L_{a,b},\mathcal{F})=a$, which is achieved by giving each buyer in $\mathcal{F}^*$ her demand path.
We will prove that any prices on edges of $L_{a,b}$ achieve worst-case welfare $O(\sqrt{a})$.
Consider now any set of prices on edges of $L_{a,b}$. We distinguish between the following two cases.
\paragraph{Case 1: At least $\sqrt{a}$ buyers in $\mathcal{F}^*$ can afford their demand paths.}
We let $S$ be the set that contains all indices $r\in [a]$ such that the buyer $r$ can afford her demand path $Q^{(r)}$, so $|S|\ge \sqrt{a}$.
Consider the set $\mathcal{F}_S$ of buyers that we have constructed.
We claim that at least some buyers of $\mathcal{F}_S$ can also afford her demand path. To see why this is true, note that by Property~\ref{prop1}, $\mathcal{F}_S$ contains $2|S|$ buyers with total value $(2+2\epsilon)|S|$, while the total price of edges in $\bigcup_{r\in S}Q^{(r)}$ is at most $|S|$. Therefore, by Property~\ref{prop4}, there must exist a buyer in $\mathcal{F}_S$ that can afford her demand path.
We then let this buyer come first and get her demand path $Q$. Then from Property \ref{prop3}, all buyers $r\in S$ can not get their demand paths since their demand paths share an edge with $Q$. All buyers $r\in [a]/S$ can not afford their demand paths. Moreover, for any buyers' arriving order, let $\mathcal{Q}=\{Q_1,...,Q_K\}$ ($Q_1=Q$) be the set of demand paths that are allocated eventually. We argue that $K\leq \sqrt{a}$. For every $k=1,\ldots,K$, $Q_k$ must come from the profile $\bigcup_{S\subseteq [a], |S|\ge \sqrt{a}}\mathcal{F}_S$. Let $S_k\subseteq [a]$ be the set that $Q_k$ appears in $\mathcal{F}_{S_k}$. Then by Property \ref{prop1} and \ref{prop5}, we have $S_{k_1}\cap S_{k_2}=\emptyset$ for any $k_1,k_2\in [K],k_1\not=k_2$. Thus we have $K\leq \sqrt{a}$ since $|S_k|\geq \sqrt{a}$ for every $k$.
Hence, the achieved welfare is at most $(1+\varepsilon)\sqrt{a}$, for any buyers' arriving order.
\paragraph{Case 2. Less that $\sqrt{a}$ buyers in $\mathcal{F}^*$ can afford their demand paths.}
Similar to Case 1, at most $\sqrt{a}$ buyers from sets $\bigcup_{S\subseteq [a], |S|\ge \sqrt{a}}\mathcal{F}_S$ can get their demand sets simultaneously. Therefore, the total welfare is at most $(1+\varepsilon)\sqrt{a}+\sqrt{a}=O(\sqrt{a})$.
$\ $
It remains to construct the sets $\set{\mathcal{F}_S}_{S\subseteq [a], |S|\ge \sqrt{a}}$ that satisfy all the above properties.
We now fix a set $S\subseteq [a]$ with $|S|\ge \sqrt{a}$ and construct the set $\mathcal{F}_S$.
Denote $s=|S|$.
Since each path can be represented by a length-$b$ sequence, we simply need to construct a $(2s\times b)$ matrix $M_S$, in which each row corresponds to a path in $L_{a,b}$.
We first construct the first $s$ columns of the matrix.
Let $N_S$ be an $s\times s$ matrix, such that every row and every column contains each element of $S$ exactly once (it is easy to see that such a matrix exists).
We place two copies of $N_S$ vertically, and view the obtained $(2s\times s)$ matrix as the first $s$ columns of $M_S$.
We then construct the remaining $b-s\geq3a^3$ columns of matrix $M_S$.
Let $S'$ be the multi-set that contains two copies of each element of $S$.
We then let each column be an independent random permutation on elements of $S'$.
This completes the construction of the matrix $M_S$.
We then add a buyer associated with every path above with value $1+\varepsilon$. This completes the construction of the set $\mathcal{F}_S$.
We prove that the randomized construction satisfies all the desired properties, with high probability. For Property \ref{prop1}, clearly $\mathcal{F}_{S}$ contains $2|S|$ buyers, and the value associated with each demand path is $1+\varepsilon$. For every pair of distinct rows in $M_S$, the probability that their entries in $j$-th column for any $j>s$ are identical is $1/2s$, so the probability that the corresponding two paths are edge-disjoint is at most $(1-1/2s)^{3a^3}$.
From the union bound over all pairs of rows, the probability that there exists a pair of edge-disjoint demand paths in $\mathcal{F}_S$ is at most
$\binom{s}{2}\cdot(1-1/2s)^{3a^3}\le a^2\cdot e^{-a^2}$.
Property \ref{prop3} is clearly satisfied by the first $s$ column of matrix $M_S$.
Property \ref{prop4} is clearly satisfied by the construction of matrix $M_S$.
Therefore, from the union bound on all subsets $S\subseteq[a]$ with $|S|\ge \sqrt{a}$, the probability that Properties \ref{prop1},\ref{prop3}, and \ref{prop4} are not satisfied by all sets $\set{\mathcal{F}_S}_{S\subseteq [a], |S|\ge \sqrt{a}}$ is $ a^2\cdot e^{-a^2}\cdot 2^{a}<e^{-a}$.
For Property~\ref{prop5}, consider any pair $S,S'$ of such sets and any row in the matrix $M_S$ and any row in the matrix $M_{S'}$.
Since $S\cap S'\neq \emptyset$, the probability that they have the same element in any fixed column is at least $(1/|S|)\cdot(1/|S'|)\geq 1/a^2$, so the probability that the corresponding two paths are edge-disjoint is at most $(1-a^{-2})^{3a^3}<e^{-3a}$.
From the union bound, the probability that Property~\ref{prop5} is not satisfied is at most $e^{-3a}\cdot (2^a\cdot 2a)^2<e^{-a}$.
Altogether, our randomized construction satisfies all the desired properties with high probability. Thus there must exist a deterministic construction of $\mathcal{F}_S$ that satisfies all the properties. This completes the proof of \Cref{lem:ratio-Lab}.
\end{proof}
\subsection{Lower Bound for Grids}\label{subsec: grid lower bound}
We notice that in the graph $L_{a,b}$ and $H_{a,b}$ that we constructed in Theorem~\ref{thm:lb-mahua}, the maximum degree among all vertices is $2a$, which is a polynomial of $m$. Therefore, it is reasonable to ask
the large competitive ratio is due to the existence of high-degree vertices that are shared by many demand paths.
In this section, we show a negative answer to this question. We prove that a $poly(m)$ lower bound of the competitive ratio when $G$ is restricted to be a grid.
\begin{theorem}
\label{thm:bounded-degree-mahua}
Let $G$ be the $(\sqrt{m}\times \sqrt{m})$-grid (so that $G$ has $\Theta(m)$ edges). Then $\emph{\textnormal{\textsf{gap}}}(G)=\Omega(m^{1/20})$.
\end{theorem}
The proof is enabled by replacing each high-degree vertex in the graph $H_{a,b}$ with a gadget, so that every vertex in the modified graph $G$ has degree at most 4. Formally, the graph $G=R_{a,b}$ is constructed as follows.
Consider a high-degree vertex $v_i\in V(H_{a,b})$. Recall that it has $2a$ incident edges $\set{(v_i,u_{i,j}),(v_i,u_{i+1,j})\mid j\in [a]}$ in graph $H_{a,b}$ (see \Cref{fig:gadget_before}). The gadget for vertex $v_i$ is constructed as follows. We first place the vertices $u_{i,1},\ldots,u_{i,a},u_{i+1,1}\ldots,u_{i+1,a}$ on a circle in this order, and then for each $j\in [a]$, we draw a line segment connecting $u_{i,j}$ with $u_{i+1,j}$, such that every pair of these segments intersects, and no three segments intersect at the same point. We then replace each intersection with a new vertex. See Figure~\ref{fig:gadget_after} for an illustration.
\begin{figure}[htb]
\centering
\subfigure[The vertex $v_i$ and its incident edges in $H_{a,b}$. ]{\scalebox{0.25}{\includegraphics{gadget_before.jpg}}\label{fig:gadget_before}}
\hspace{1pt}
\subfigure[The gadget graph $K_i$.]{\scalebox{0.25}{\includegraphics{gadget_after.jpg}}\label{fig:gadget_after}}
\caption{An illustration of the gadget construction.}\label{fig:gadget}
\end{figure}
Now the modified graph can be embedded in the grid since each vertex has degree at most 4.
Denote by $K_i$ the resulting graph after constructing the gadget, as shown in Figure~\ref{fig:gadget_after}. We use the following lemma.
\begin{lemma}\label{lem:disjointsort}
Let $\sigma$ be any permutation on $[a]$, then graph $K_i$ contains a set $\mathcal{P}_i=\set{P_{i,j}\mid j\in [a]}$ of edge-disjoint paths, such that path $P_{i,j}$ connects vertex $u_{i,j}$ to vertex $u_{i+1,\sigma(j)}$.
\end{lemma}
Before proving \Cref{lem:disjointsort}, we first give the proof of \Cref{thm:bounded-degree-mahua} using \Cref{lem:disjointsort}.
\begin{prevproof}{Theorem}{thm:bounded-degree-mahua}
First, the graph $R_{a,b}$ is obtained by taking the union of all graphs $\set{K_i}_{0\le i\le b}$, while identifying, for each $i\in [b]$ and $j\in [a]$, the vertex $u_{i,j}$ in $K_{i-1}$ with the vertex $u_{i,j}$ in $K_{i}$.
Clearly, the maximum vertex degree in graph $R_{a,b}$ is $4$.
We now show that we can easily convert the buyer-profile $\mathcal{F}$ on graph $H_{a,b}$ into a buyer-profile $\hat\mathcal{F}$ on graph $R_{a,b}$, while preserving all desired properties.
Consider first the buyers $1,\ldots,a$ in $\mathcal{F}^*$.
Let $\sigma_i$ be the identity permutation on $[a]$, for each $i\in [b]$. From \Cref{lem:disjointsort}, there exist sets $\set{\mathcal{P}^*_i}_{i\in [b]}$ of edge-disjoint paths, where $\mathcal{P}^*_i=\set{P^*_{i,j}\mid j\in [a]}$ for each $i\in [b]$.
We then let $\hat{\mathcal{F}^*}$ contains, for each $j\in [a]$, a buyer $\hat B^*_j$ demanding the path $\hat Q_j$ with value $1$, where $\hat Q_j$ is the sequential concatenation of paths $P^*_{1,j},\ldots,P^*_{b,j}$. Clearly, paths $\set{\hat Q_j}_{j\in [a]}$ are edge-disjoint.
Consider now a set $S\subseteq [a]$ with $|S|\ge \sqrt{a}$.
Recall that in $\mathcal{F}_S$ we have $2|S|$ buyers, whose demand paths cover the paths $\set{Q^{(j)}\mid j\in S}$ exactly twice.
Therefore, for each $i\in [b]$, the way that these paths connect vertices of $U_{i-1}=\set{u_{i-1,j}\mid j\in [a]}$ to vertices of $U_{i}=\set{u_{i,j}\mid j\in [a]}$ form two perfect matchings between vertices of $U_{i-1}$ and vertices of $U_{i}$.
From \Cref{lem:disjointsort}, there are two sets $\mathcal{P}_i,\mathcal{P}'_i$ of edge-disjoint paths connecting vertices of $U_{i-1}$ and vertices of $U_{i}$. We then define, for each demand path $Q=(j_0, j_1,\ldots,j_b)$\footnote{We can arbitrarily assign additionally the path $Q$ with some index $j_0\in S$, such that each index of $S$ is assigned to exactly two demand paths in $\mathcal{D}_S$.} in $\mathcal{F}_S$, its corresponding path $\hat Q$ to be the sequential concatenation of, the corresponding path in $\mathcal{P}_1\cup\mathcal{P}'_1$ that connects $u_{0,j_0}$ to $u_{1,j_1}$, the corresponding path in $\mathcal{P}_2\cup\mathcal{P}'_2$ that connects $u_{1,j_1}$ to $u_{2,j_2}$, all the way to the corresponding path in $\mathcal{P}_b\cup\mathcal{P}'_b$ that connects $u_{b-1,j_b-1}$ to $u_{b,j_b}$. It is easy to verify that all desired properties are still satisfied.
Lastly, to ensure that the graph $R_{a,b}$ can be embedded into the $(\sqrt{m}\times\sqrt{m})$-grid, we need $\sqrt{n}=a^2b$, where $b=a+3a^3$. Thus $a=\Theta(m^{1/10})$.
\Cref{thm:bounded-degree-mahua} now follows from Lemma~\ref{lem:ratio-Lab}.
\end{prevproof}
It remains to prove \Cref{lem:disjointsort}.
\begin{proof}[Proof of Lemma~\ref{lem:disjointsort}]
We prove by induction on $a$. The base case where $a=1$ is trivial. Assume that the lemma is true for all integers $a\le r-1$. Consider the case where $a=r$.
For brevity of notations, we rename $K_i$ by $K$, $\mathcal{P}_i$ by $\mathcal{P}$, $u_{i,j}$ by $u_{j}$ and $u_{i+1,j}$ by $u'_{j}$.
Recall that the graph $K$ is the union of $r$ paths $W_1,\ldots,W_{r}$, where path $W_j$ connects vertex $u_{j}$ to vertex $u'_{r+1-j}$, such that every pair of these paths intersect at a distinct vertex.
Recall that we are also given a permutation $\sigma$ on $[r]$, and we are required to find a set $\mathcal{P}=\set{P_j\mid j\in [r]}$ of edge-disjoint paths in $K$, such that the path $P_j$ connects $u_j$ to $u'_{\sigma(j)}$.
We first define the graph $K'=K\setminus W_{r}$, and we define an one-to-one mapping $f:[r\!-\!1]\to \set{2,\ldots,r}$ as follows. For each $j\in [r\!-\!1]$ such that $\sigma(j)\in \set{2,\ldots,r}$, we set $f(j)=\sigma(j)$; for $j\in [r\!-\!1]$ such that $\sigma(j)=1$, we set $f(j)=\sigma(r)$.
Note that $K'$ is a graph consisting of $(r\!-\!1)$ pairwise intersecting paths, and $f$ is a one-to-one mapping from the left set of vertices of $K'$ to the right set of vertices of $K'$.
From the induction hypothesis, there is a set $\mathcal{P}'=\set{P'_j\mid j\in [r\!-\!1]}$ of edge-disjoint paths, such that path $P'_j$ connects $u_j$ to $u'_{f(j)}$.
If $\sigma(r)=1$, then we simply let $\mathcal{P}=\mathcal{P}'\cup \set{W_r}$, and it is easy to check that the set $\mathcal{P}$ of paths satisfy the desired properties.
Assume now that $\sigma(r)\ne 1$, then the path $P'_{\sigma^{-1}(a)}$ is currently connecting $u_{\sigma^{-1}(a)}$ to $u'_k$, which is a wrong destination.
Observe that $W_r$ connects $u_k$ to $u'_1$ and is edge-disjoint with $P'_{\sigma^{-1}(a)}$. Moreover, it is easy to see that $P'_{\sigma^{-1}(a)}$ must intersect with $W_r$ at at least one vertex. Let $x$ be the intersection that are closest to $u_k$ on $W_r$. We then define the path $P_k$ as the concatenation of (i) the subpath of $W_k$ between $u_k$ and $x$, and (ii) the subpath of $P'_{\sigma^{-1}(a)}$ between $x$ and $u'_{\sigma(k)}$. Similarly. we define the path $P_{\sigma^{-1}(a)}$ as the concatenation of (i) the subpath of $P'_{\sigma^{-1}(a)}$ between $u_{\sigma^{-1}(a)}$ and $x$, and (ii) the subpath of $W_r$ between $x$ and $u'_1$.
We then let $\mathcal{P}=(\mathcal{P}'\setminus \set{P'_{\sigma^{-1}(a)}})\cup \set{P_k,P_{\sigma^{-1}(a)}}$, and it is easy to check that the set $\mathcal{P}$ of paths satisfy the desired properties.
\end{proof}
\subsection{Lower Bound for Outerplanar Graphs}
\label{subsec: lower bound outerplanar}
By embedding the serial-parallel graph constructed in the proof of Theorem~\ref{thm:lb-mahua}, we also prove that a polylogarithmic competitive ratio is unavoidable for outerplanar graphs.
\begin{theorem}\label{thm:outerplanar_lower}
$\emph{\textnormal{\textsf{gap}}}(\mathsf{Outerplanar})=\Omega((\frac{\log m}{\log\log m})^{1/2})$.
\end{theorem}
\begin{proof}
We will show that there is an outerplanar graph $G$ with $m$ edges, such that we can embed the graph $L_{a,b}$ (constructed in \Cref{sec: general graph}) into $G$, and then \Cref{thm:outerplanar_lower} follows immediately from \Cref{lem:ratio-Lab}.
In fact, it is easy to embed $a$ parallel paths into an outerplanar graph with $2^{a-1}$ edges (as \Cref{fig: embedding}). Therefore, we can embed the graph $L_{a,b}$ into an outerplanar graph with $2^{a-1}\cdot b$ edges. Setting $b=a+3a^3$ and $2^{a-1}\cdot b=m$, we have $a=\Omega(\log m/\log \log m)$.
From \Cref{lem:ratio-Lab}, we conclude that $\textnormal{\textsf{gap}}(\textsf{Outerplanar})=\Omega((\frac{\log m}{\log\log m})^{1/2})$.
\begin{figure}[htb]
\centering
\includegraphics[scale=0.3]{embedding.jpg}
\caption{An illustration of embedding parallel paths between two vertices in an outerplanar graph. Edges of the same color represent such a path.}\label{fig: embedding}
\end{figure}
\end{proof}
\subsection{Upper Bound for General Graphs}\label{sec:generalgraphub}
At last, we prove the following upper bound for the competitive ratio in any tollbooth problem (on general graphs). The competitive ratio depends on the number of buyers in the auction. Note that when $n$ is sub-exponential on $m$, the competitive ratio proved in \Cref{thm:general_graph} is better than the competitive ratio $O(\sqrt{m})$ proved in~\cite{cheung2008approximation,chin2018approximation}.
\begin{theorem}
\label{thm:general_graph}
For any given instance $(G,\mathcal{F})$ with $|E(G)|=m$ and $|\mathcal{F}|=n$, there exists a set of prices on edges of $G$ that achieves worst-case welfare $\Omega(\mathsf{OPT}(G,\mathcal{F})/(m^{0.4}\cdot\log^2m\cdot\log n))$.
\end{theorem}
The remainder of the section is dedicated to the proof of Theorem~\ref{thm:general_graph}. Choose parameter $\alpha=1/10$. Denote $\mathcal{F}=\set{(Q_j,v_j)}_{j\in [n]}$.
Let $\mathcal{Q}=\set{Q_{j_1},\ldots,Q_{j_t}}$ be the independent set of paths that, among all independent subsets of $\set{Q_1,\ldots,Q_n}$, maximizes its total value, namely $\mathcal{Q}=\arg_{\tilde \mathcal{Q} : \tilde \mathcal{Q} \text{ is independent}}\max\set{\sum_{j:Q_j\in \tilde\mathcal{Q}}v_j}$. For every $Q\in \mathcal{Q}$, we denote $v(Q)$ the value of the buyer who is allocated her demand path $Q$ in the optimal allocation $\mathcal{Q}$. We denote $J=\set{j_1,\ldots,j_t}$, so $\mathsf{OPT}(G,\mathcal{F})=\sum_{j\in J}v_j$.
We first pre-process the set $\mathcal{Q}$ as follows.
For each integer $1\le k\le \log m$, we denote by $\mathcal{Q}_{k}$ the subset of paths in $\mathcal{Q}$ that whose length lies in the interval $[2^{k-1}, 2^k)$. Clearly, there exists some integer $k^*$ with $v(\mathcal{Q}_{k^*})=\sum_{Q\in \mathcal{Q}_{k^*}}v(Q)\ge \Omega(\mathsf{OPT}/\log m)$. We denote $\mathcal{Q}^*=\mathcal{Q}_{k^*}$ and denote $L=2^{k^*-1}$, so the length of each path in $\mathcal{Q}^*$ lies in $[L,2L)$.
Let $v^*$ be the maximum value of a path in $\mathcal{Q}^*$, namely $v^*=\max\set{v_j\mid Q_j\in \mathcal{Q}^*}$. We let $\mathcal{Q}^*_0$ contains all paths in $\mathcal{Q}^*$ with value at most $v^*/m^2$. Then, for each integer $1\le t\le 2\log n$, we denote by $\mathcal{Q}^*_{t}$ the subset of paths in $\mathcal{Q}^*$ whose length lie in the interval $(v^*/2^{t}, v^*/2^{t-1}]$.
Clearly, the total value of the paths in $\mathcal{Q}^*_0$ is at most $m\cdot (v^*/m^2)= v^*/m$ (since $|\mathcal{Q}^*_0|\le |\mathcal{Q}^*|\le m$). Therefore, there exists some integer $t^*$ with $v(\mathcal{Q}^*_{t^*})=\sum_{Q\in \mathcal{Q}^*_{t^*}}v(Q)\ge \Omega(v(\mathcal{Q}^*)/\log m)$. We denote $\mathcal{Q}'=\mathcal{Q}^*_{t^*}$ and denote $\hat v=v^*/2^{t^*}$, so the value of each path of $\mathcal{Q}'$ lies in $(\hat v,2\hat v]$.
So far we obtain a set $\mathcal{Q}'$ of paths, and two parameters $L,\hat v$, such that
\begin{enumerate}
\item all paths in $\mathcal{Q}'$ have length in $[L, 2L)$;
\item all paths in $\mathcal{Q}'$ have value in $(\hat v, 2\hat v]$;
\item the total value of all paths in $\mathcal{Q}'$ is $\Omega(\mathsf{OPT}/\log^2 m)$.
\end{enumerate}
We use the following observations.
\begin{observation}
\label{obs:few_paths}
If $|\mathcal{Q}'|<m^{1/2-\alpha}$, then there exist prices on edges of $G$ achieving worst-case welfare $\Omega(\mathsf{OPT}/(m^{1/2-\alpha}\cdot\log^2m))$.
\end{observation}
\begin{proof}
Let $Q$ be a path in $\mathcal{Q}'$ with largest value, so $v(Q)\ge v(\mathcal{Q}')/m^{1/2-\alpha}$.
We first set the price of each edge of $E(G\setminus Q)$ to be $+\infty$.
From Theorem~\ref{thm:path}, we know that there is a set of prices on edges of $Q$, that achieves the worst-case welfare $\Omega(v(Q))$.
Therefore, we obtain a set of prices for all edges in the graph, that achieves worst-case welfare $v(Q)=\Omega(v(\mathcal{Q}')/m^{1/2-\alpha})=\Omega(\mathsf{OPT}/(m^{1/2-\alpha}\cdot\log^2m))$.
\end{proof}
\begin{observation}
\label{obs:small_lengths}
If $L < m^{1/2-\alpha}$, then there exist prices on edges of $G$ achieving worst-case welfare $\Omega(\mathsf{OPT}/(m^{1/2-\alpha}\cdot\log^2m))$.
\end{observation}
\begin{proof}
We define the edge prices as the following.
For each path $Q\in \mathcal{Q}'$ and for each edge $e\in Q$, we set its price $\tilde p(e)$ to be $v(Q)/2L$, and we set the price for all other edges to be $+\infty$.
Note that, for each $Q\in \mathcal{Q}'$, $\tilde p(Q)=\sum_{e\in Q}\tilde p(e) =|E(Q)|\cdot(v(Q)/2L)< v(Q)$.
Therefore, no matter what order in which the buyers come, at the end of the selling process, for each $Q\in \mathcal{Q}'$, at least one edge is taken at the price of $v(Q)/2L$. It follows that the welfare is at least
$\sum_{Q\in \mathcal{Q}'} v(Q)/(2L)=\Omega(v(\mathcal{Q}')/m^{1/2-\alpha})=\Omega(\mathsf{OPT}/(m^{1/2-\alpha}\cdot\log^2m))$.
\end{proof}
From the above observations, we only need to consider the case where $|\mathcal{Q}'|\ge m^{1/2-\alpha}$ and $L\ge m^{1/2-\alpha}$. Since $|\mathcal{Q}'|\cdot L\le \sum_{Q\in \mathcal{Q}'}|E(Q)|\le m$, we get that $|\mathcal{Q}'|, L\le m^{1/2+\alpha}$. We can also assume without loss of generality that $\hat v=1$, namely each path of $\mathcal{Q}'$ has value in $(1,2]$. We now perform the following steps.
\paragraph{Step 1. Construct a random subset $\mathcal{Q}''$ of $\mathcal{Q}'$.}
Let $\mathcal{Q}''$ be a subset of $\mathcal{Q}'$ obtained by including each path $Q\in \mathcal{Q}'$ independently with probability $1/2$. Then we set the price for each edge that is not contained in any path of $\mathcal{Q}''$ to be $+\infty$.
From Chernoff's bound, with high probability $v(\mathcal{Q}'')\ge v(\mathcal{Q}')/3$, so $v(\mathcal{Q}'')\ge \Omega(\mathsf{OPT}/\log^2 m)$. Let $\tilde\mathcal{Q}$ be the set of all paths in $\set{Q_1,\ldots,Q_n}$ that do not contain an edge whose price is $+\infty$, namely the set $\tilde\mathcal{Q}$ contains all paths that survive the current price. Here we say a path $Q$ survives a price $p$, if $\sum_{e\in E(Q)}p(e)<v(Q)$, i.e. the buyer's value is higher than the price of her demand path.
Note that the set $\tilde\mathcal{Q}$ may contain paths of any length.
We use the following observation.
\begin{observation}
\label{obs:touching_too_many_opt_paths}
With high probability, all paths in $\tilde\mathcal{Q}$ intersect at most $2\log n$ paths in $\mathcal{Q}''$.
\end{observation}
\begin{proof}
For each path $Q$, if it intersects with at least $2\log n$ paths in $\mathcal{Q}'$, then the probability that it belongs to $\tilde\mathcal{Q}$ is at most $(1/2)^{2\log n}=1/n^2$. From the union bound, the probability that there exists a path of $\set{Q_1,\ldots,Q_n}$ that intersects at least $2\log n$ paths in $\mathcal{Q}'$ and is still contained in $\tilde\mathcal{Q}$ is at most $n\cdot(1/n^2)=1/n$. Observation~\ref{obs:touching_too_many_opt_paths} then follows.
\end{proof}
\paragraph{Step 2. Analyze a special set of short surviving paths.}
We set $L'=m^{1/4-\alpha/2}$, and let $\tilde\mathcal{Q}'$ contains all paths in $\tilde\mathcal{Q}$ with length less than $L'$. Clearly, $\tilde\mathcal{Q}'\cap\mathcal{Q}''=\emptyset$.
Let $\hat\mathcal{Q}$ be a max-total-value independent subset of $\tilde\mathcal{Q}'$.
We distinguish between the following two cases on the value of $v(\hat\mathcal{Q})$.
\textbf{Case 1. $v(\hat\mathcal{Q})\ge v(\mathcal{Q}'')/100L'$.}
We will show that in this case, there exist prices on edges of $G$ that achieve worst-case welfare $\Omega(\mathsf{OPT}/(m^{1/2-\alpha}\cdot\log^2m))$.
We define the edge prices as follows.
For each path $Q\in \hat\mathcal{Q}$ and for each edge of $Q$, we set its price to be $v(Q)/L'$, and we set the price for all other edges to be $+\infty$.
Similar to Observation~\ref{obs:small_lengths}, the worst-case welfare is at least
$\sum_{Q\in \hat\mathcal{Q}} v(Q)/L'=\Omega(v(\hat\mathcal{Q})/L')=
\Omega(v(\mathcal{Q}'')/L'^2)=
\Omega(\mathsf{OPT}/(m^{1/2-\alpha}\cdot\log^2m))$.
\textbf{Case 2. $v(\hat\mathcal{Q})\le v(\mathcal{Q}'')/100L'$.}
We set the prices of the edges in two stages.
In the first stage, for each path $Q\in\hat\mathcal{Q}$ and for each edge in $Q$, we set its price $p(e)$ to be $v(Q)$, and for all other edges that belong to some path of $\mathcal{Q}''$, we set its price to be $0$.
Recall that we have already set the price for all edges that do not belong to a path of $\mathcal{Q}''$ to be $+\infty$.
We prove the following observations.
\begin{observation}
No path in $\tilde \mathcal{Q}'$ survives price $p$.
\end{observation}
\begin{proof}
Assume by contradiction that there is a path $Q$ with length $|E(Q)|< L'$ that survives the price $p$. Let $\hat\mathcal{Q}'$ be the set of paths in $\hat\mathcal{Q}$ that intersect $Q$. From the definition, $v(Q)>\sum_{e\in E(Q)}p(e)\ge v(\hat\mathcal{Q}')$. Consider the set $(\hat\mathcal{Q}\setminus \hat\mathcal{Q}')\cup\set{Q}$. From the above discussion, this set is an independent set of paths with length less than $L'$, with total value at least the total value of $\hat\mathcal{Q}$, while containing strictly less paths than $\hat\mathcal{Q}$. This leads to a contradiction to the optimality of $\hat\mathcal{Q}$.
\end{proof}
\begin{observation}
\label{obs: surviving value large}
The total value of all paths in $\mathcal{Q}''$ that survives $p$ is at least $0.99\cdot v(\mathcal{Q}'')$.
\end{observation}
\begin{proof}
For each path $Q\in\mathcal{Q}''$ that does not survive the price $p$, its value is below $\sum_{e\in E(Q)}p(e)$. Since paths in $\mathcal{Q}''$ are edge-disjoint, the total value of paths in $\mathcal{Q}''$ that do not survive the price $p$ is at most $\sum_{e\in E(\mathcal{Q}'')}p(e)\le \sum_{Q\in \hat\mathcal{Q}}L'\cdot v(Q)\le L'\cdot v(\hat \mathcal{Q})\le v(\mathcal{Q}'')/100$. Observation~\ref{obs: surviving value large} then follows.
\end{proof}
We now modify the price $p$ in the first stage as the following. For each path $Q\in \mathcal{Q}''$ and for each edge $e\in Q$, we increase its price by $v(Q)/4L$. Note that the prices of all other edges are already set to be $+\infty$ before the first stage. This completes the definition of the prices on edges. We now show that these prices will achieve worst-case welfare $\Omega(\mathsf{OPT}/(m^{1/2-\alpha}\cdot\log^2m\cdot\log n))$, thus completing the proof of \Cref{thm:general_graph}.
First, since the total price on all edges of $\mathcal{Q}''$ is at most $v(\mathcal{Q}'')/100+\sum_{Q\in \mathcal{Q}''}2L\cdot(v(Q)/4L)\le 0.51\cdot v(\mathcal{Q}'')$, the set of paths in $\mathcal{Q}''$ that survives the ultimate price has total value at least $0.49\cdot v(\mathcal{Q}'')$.
We denote this set by $\hat{\mathcal{Q}''}$.
Since all path in $\mathcal{Q}''$ has length $[L,2L)$ and value $(\hat v,2\hat v]$, $|\hat\mathcal{Q}''|\ge 0.49|\mathcal{Q}''|/4\ge 0.1|\mathcal{Q}''|$.
Denote by $\bar\mathcal{Q}$ the resulting set of paths that is being taken in the selling process. It is clear that
\begin{itemize}
\item each path $Q'\in \bar\mathcal{Q}$ has length at least $L'$;
\item for each path $Q\in\hat\mathcal{Q}''$, there is a path $Q'\in \bar\mathcal{Q}$ that intersects $Q$; and
\item each path $Q'\in \bar\mathcal{Q}$ intersects at most $2\log n$ paths in $\hat\mathcal{Q}''$.
\end{itemize}
Altogether, we get that $|\bar{\mathcal{Q}}|\ge |\hat\mathcal{Q}''|/(2\log n)$, the length of each path in $\bar{\mathcal{Q}}$ is at least $L'$, and each edge of $E(\bar{\mathcal{Q}})$ has price at least $\min_{e\in E(\hat\mathcal{Q}'')}\set{p(e)}$. Therefore, the total value of paths in $\bar{\mathcal{Q}}$ is at least
\[\frac{|\hat\mathcal{Q}''|}{2\log n}\cdot L'\cdot \min_{e\in E(\hat\mathcal{Q}'')}\set{p(e)}\ge \frac{|\hat\mathcal{Q}''|}{2\log n}\cdot L'\cdot \Omega\left(\frac{v(\mathcal{Q}'')}{|\mathcal{Q}''|\cdot L}\right)
=\Omega\left(\frac{v(\mathcal{Q}'')\cdot L'}{L\cdot \log n}\right)
\ge\Omega\left(\frac{\mathsf{OPT}}{m^{1/2-\alpha}\cdot\log^2m\log n}
\right),\]
where the last inequality is obtained by combining $L\le m^{1/2+\alpha}$, $L'=m^{1/4-\alpha/2}$ and $\alpha=1/10$.
\section{Introduction}
Welfare maximization in combinatorial auctions is one of the central problems in market design. The auctioneer is selling $m$ heterogeneous items to $n$ self-interested buyers. She aims to find a welfare-maximizing allocation, and designs payments to incentivize all buyers to truthfully report their private preferences. We consider the special case that every buyer is \emph{single-minded}, which means that the buyer is only interested in buying a certain subset of items, and has value $0$ if she does not get the whole subset. While the celebrated VCG mechanism~\cite{vickrey1961counterspeculation,clarke1971multipart,groves1973incentives} is truthful and maximizes the welfare, markets in the real world often prefer to implement simpler mechanisms, such as \emph{item pricing}.
In an item-pricing mechanism, each item is given an individual price. Buyers come to the auction sequentially and choose the favorite bundle (among the remaining items) that maximizes their own utilities. For a single-minded buyer, she will purchase her demand set if and only if all items in the set are available, and the total price of the items is at most her value.
The performance of an item-pricing mechanism is measured by its \emph{worst-case welfare}, that is, the minimum sum of buyers' value achieved by the mechanism when the buyers arrive in any adversarial order.
In this setting, the Walrasian equilibrium \cite{arrow1951extension,debreu1951coefficient} for gross-substitutes buyers provides a set of prices as well as a welfare-maximizing allocation, such that every buyer receives her favorite bundle~\cite{kelso1982job}, which allows us to maximize the welfare using an item-pricing mechanism. However, such an equilibrium (or a set of prices) may not exist when the buyers are single-minded.
In the paper we focus on a special case of the above problem known as the \emph{tollbooth problem}~\cite{guruswami2005profit}, where the set of commodities and demands are represented by edges and paths in a graph.
This setting has found various real-world applications.
For instance, a network service provider wants to sell bandwidth along with the links of a network by pricing on every single link, and each customer is only interested in buying a specific path in the network. In this setting, every item in the auction is an edge in some graph $G$ representing the network, and every buyer is single-minded and is only interested in buying all edges of a specific path of $G$.
We additionally impose the restriction that each commodity (edge) may be given to at most one buyer, which means that if an edge was taken by some previous buyer, then buyers who come afterward whose demand set contains this edge may no longer take it.
Similar to the general case, Walrasian equilibrium is not guaranteed to exist for the tollbooth problem. Moreover, Chen and Rudra~\cite{chen2008walrasian} proved that the problem of determining the existence of a Walrasian equilibrium and the problem of computing such an equilibrium (if it exists) are both NP-hard for the tollbooth problems on general graphs.
Therefore, an investigation of the power and limits of item pricing is a natural next step towards a deeper understanding of the tollbooth problem. For an item-pricing mechanism, its \emph{competitive ratio} is the ratio between the hindsight optimal welfare, i.e. the optimal welfare achieved by any feasible allocation of items to buyers, and the worst-case welfare of the item-pricing mechanism. In the paper, we study the best (smallest) competitive ratio among all item-pricing mechanisms in a given instance of the tollbooth problem.
The tollbooth problem has been extensively studied in the literature. One line of work~\cite{grigoriev2006sell,elbassioni2009profit,guruswami2005profit,gamzu2010sublogarithmic,kortsarzprofit} aims to efficiently compute prices of items as well as a special subset of buyers called \emph{winners} while maximizing the total welfare, such that it is feasible to allocate the demand sets to all winners, and every winner can afford her bundle.
There is a major difference between all works above and our setting. In all works above, it is only required that the set of buyers who get their demand sets can afford their demand sets. But there might be other buyers who could afford their demand sets as well but eventually did not get them (or equivalently, not selected as winners).
Since the arriving order is adversarial in our setting, these buyers might come before the winners and take their demand sets. The winners may no longer get their demand sets since some items in their demand sets are already taken.
Therefore, the set of prices computed in the works above may not end up achieving the worst-case welfare equal to the total value of all winners.
It is not hard to see that our item-pricing mechanisms are stronger than the settings in the works above: If a set of prices has a competitive ratio $\alpha$ in our setting, then such a set of prices is automatically an $\alpha$-approximation in the setting of the works above, but the converse is not true.
The previous work whose setting is closest to ours is \cite{cheung2008approximation} by Cheung and Swamy. They studied envy-free pricing in the tollbooth problem, which additionally requires that the losers (buyers who did not get their demand sets) can not afford their demand sets. Envy-free pricing achieves the same welfare in any arrival order. They constructed an algorithm in the multi-supply setting, that takes any LP-based $\alpha$-approximation solution to the optimal welfare, and returns an envy-free pricing mechanism that achieves approximation ratio $O(\alpha\cdot\log u)$, where $u$ is the maximum supply of an item. When the supply of each edge is 1, the algorithm obtains a $2\alpha$-approximation. Since the best efficient LP-based algorithm~\cite{chekuri2007multicommodity} achieves a $4$-approximation algorithm when the underlying graph is a tree, the algorithm in \cite{cheung2008approximation} achieves a competitive ratio $8$ by envy-free pricing on trees. In our paper, we improve their results by computing an item pricing that achieves competitive ratio $3$ on trees.
Additionally, we analyze the competitive ratio beyond trees, e.g. cycles and outerplanar graphs. We remark that in~\cite{cheung2008approximation}, the approximation ratio compares the optimal welfare with the profit of the pricing, which is the total prices of all sold edges. In fact, all positive results in our paper also work for profit, as the profit and welfare of the item-pricing mechanisms in the proofs are the same. In the paper, we define the competitive ratio using the welfare of the pricing instead of the profit, in order to have a consistent notation for both lower and upper bounds.
\subsection{Our Results}\label{subsec:result}
We study the best competitive ratio (the ratio between the optimal welfare and the worst-case welfare) achieved by any item-pricing mechanism in the tollbooth problem. Our results can be summarized in the following four aspects.
\vspace{-.1in}
\paragraph{1. Item pricing for special graphs.} We first consider the case where the seller has tie-breaking power. It is folklore (see e.g. \cite{cheung2008approximation,chawla2017stability}) that when the seller has tie-breaking power and $G$ is a single path, the competitive ratio of the problem is 1, i.e., there exists an item-pricing mechanism that achieves the optimal welfare. However, for graphs beyond paths, even when $G$ is a star, the competitive ratio can be strictly larger than 1. In the paper, we show that for simple families of graphs (e.g. trees, cycles, or outerplanar graphs), the competitive ratio is $O(1)$ or a polylogarithm of $m$.
A summary of the results is shown in Table~\ref{tab:graphresults}. In particular, we prove that the competitive ratio of any tree is at most 3, which improves the 8-approximation obtained in~\cite{cheung2008approximation}.
\begin{result}
When the seller has tie-breaking power, the competitive ratio is at most 3 for any tollbooth problem on trees. Moreover, a set of prices that achieves the desired ratio can be computed in polynomial time.
\end{result}
\begin{table}[h]
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Graph Class & Lower Bound (with Tie) & Upper Bound (with Tie) & Upper Bound (no Tie)\\
\hline
Path & \multicolumn{2}{|c|}{$1$ (\cite{cheung2008approximation,chawla2017stability})} & 3/2 (tight, Thm~\ref{thm:path_no_tie_hardness},~\ref{thm:path_no_tie})\\
\hline
Star & \multicolumn{2}{|c|}{$3/2$ (Thm~\ref{thm:star2},~\ref{thm: star lower bound})} & 2 (Thm~\ref{thm:star})\\
\hline
Spider & \multicolumn{2}{|c|}{$3/2$ (Thm~\ref{thm:spiderimproved},~\ref{thm: star lower bound})} & 7/2 (Thm~\ref{thm:spider-no-tiebreak})\\
\hline
Tree & $3/2$ (Thm~\ref{thm: star lower bound}) & $3$ (Thm~\ref{thm: tree}) & 7 (Thm~\ref{thm:tree-no-tiebreak})\\
\hline
Cycle & \multicolumn{2}{|c|}{$2$ (Thm~\ref{thm:cycle},~\ref{thm: cycle_lower_bound})} & 2 (Thm~\ref{thm:cycle_without_tie})\\
\hline
Outerplanar & $\Omega((\frac{\log m}{\log\log m})^{1/2})$ (Thm~\ref{thm:outerplanar_lower})& $O(\log^{2} m)$ (Thm~\ref{thm:outerplanar}) & $O(\log^{2} m)$ (\Cref{thm:outerplanar_without_tie})\\
\hline
\end{tabular}
\caption{Summary of results for special families of graphs.}\label{tab:graphresults}
\end{table}
\vspace{-.1in}
\paragraph{2. Item pricing for general graphs.}
In contrast with our results for special families of graphs, we show that, for general graphs, the competitive ratio can be polynomial in the number of its edges, even when the graph is a grid.
In \cite{cheung2008approximation} and \cite{chin2018approximation}, the competitive ratio was proved to be $O(\sqrt{m})$. This bound also holds for the general single-minded combinatorial auctions, where the demand of every agent is an arbitrary set rather than a single path. Here the $O(\sqrt{m})$-competitive ratio was shown to be tight up to a constant by Feldman et al.~\cite{feldman2015welfare}.
In this paper we prove an alternative bound $O(m^{0.4}\log^2 m\log n)$ on the competitive ratio
in any tollbooth problem with a general underlying graph (Theorem~\ref{thm:general_graph}). When $n$, the number of buyers in the auction, is subexponential on $m$, our competitive ratio is better than the previous ratio $O(\sqrt{m})$.
\begin{result}\label{inforthm:general_graph}
The competitive ratio for any tollbooth problem is $O(m^{0.4}\log^2 m\log n)$. On the other hand, there exists a tollbooth problem instance such that the competitive ratio is $\Omega(m^{1/8})$. Moreover, there exist a constant $\alpha\in (0,1)$ and an instance on grid such that the competitive ratio is $\Omega(m^{\alpha})$. Here $m$ is the number of edges and $n$ is the number of buyers.
\end{result}
\vspace{-.1in}
\paragraph{3. Without tie-breaking power.}
In addition to the set of prices, a key factor that can significantly affect the welfare of an item-pricing mechanism is the \emph{tie-breaking} rule. For example, if Walrasian equilibrium exists, item pricing can achieve the optimal welfare, but requires carefully breaking ties among all the favorite bundles of every buyer. In most scenarios studied in previous works, it is assumed that the auctioneer can cleverly convince the buyer to break ties properly so as to maximize welfare. However, in real markets, buyers often come to the mechanism themselves and simply purchase an arbitrary favorite bundle that maximizes their own utility. Therefore it is possible that the absence of tie-breaking power may influence the welfare achieved by the mechanism. In the paper, we also compare the welfare guarantee of the best item-pricing mechanism in both settings of the tollbooth problem: the setting where the auctioneer has the power of deciding whether or not to allocate the demand path to the buyer, when the total price of edges in the path equals her value; and the setting where the buyer decides whether or not to purchase the demand path in the same scenario.
As discussed above, when $G$ is a single path and the seller has tie-breaking power, there exists an item pricing that achieves the optimal welfare. However, when the seller has no tie-breaking power, we present an instance where $G$ is a single path, that no item pricing can achieve more than $2/3$-fraction of the hindsight optimal welfare (Theorem~\ref{thm:path_no_tie_hardness}). On the other hand, we prove that such a $3/2$-approximation is achievable via item pricing (Theorem~\ref{thm:path_no_tie}).
\begin{result}
The competitive ratio for any tollbooth problem on a single path is at most $3/2$, when the seller has no tie-breaking power. Moreover, the ratio is tight.
\end{result}
We also provide upper bounds for the competitive ratio in the no tie-breaking case, when the graph $G$ belongs to some special families of graphs.
See also Table~\ref{tab:graphresults} for a summary of the results.
\vspace{-.1in}
\paragraph{4. Resource augmentation.} We also study the problem where the seller has more resource to allocate, and want to compare the welfare achieved in this case to the optimal offline allocation without such additional resource. To be more specific, comparing to the optimal offline allocation with supply 1 for each item, the seller has augmented resources and is allowed to sell $c$ copies of each item to the buyers. In the literature studying offline path allocation problems on graphs (e.g. \cite{chuzhoy2016polylogarithmic}) and previous work using the techniques of resource augmentation (e.g. \cite{kalyanasundaram2000speed,koutsoupias1999weak,sleator1985amortized,young1994k,caragiannis2016truthful}), even slightly increased resources usually improves the competitive ratio significantly. However in our problem, we prove that for any constant $c>1$, there exists an instance such that the competitive ratio with augmented resources is $m^{\Omega(1/c)}$, even we allow different item prices for different copies (\Cref{thm: lower_bound_congestion}). In other words, a competitive ratio that is polynomial in $m$ is unavoidable in the tollbooth problem, even if the capacity of each edge is augmented by a constant. We also prove an almost-matching upper bound of $O(m^{1/c})$ in this setting (\Cref{thm: congestion_c}). The approximation holds for any single-minded welfare maximization problem, where each buyer may demand any set of items instead of edges in a path.
\begin{result}
For any constant integer $c>0$, consider the tollbooth problem where each edge has $c$ copies to sell. There is an instance, such that for any set of prices $\set{p^{k}(i)\mid i\in [m], 1\le k\le c}$ where $p^{k}(i)$ represent the price for the $k$-th copies of edge $i$, the item-pricing mechanism
achieves worst-case welfare an $O(m^{-1/(2c+6)})$-fraction of the optimal welfare when each edge has supply 1. On the other hand, there exists an item pricing that achieves worst-case welfare an $\Omega(m^{-1/c})$-fraction of the optimal welfare when each edge has supply 1.
\end{result}
\subsection{Our Approach and Techniques}
\paragraph{Techniques for upper bounds.} We use two major tools for computing prices that achieve good worst-case welfare. First, we consider the natural LP relaxation for computing the optimal allocation. It is a common technique that the variables of the dual LP can be interpreted as prices for corresponding items (see e.g.~\cite{bikhchandani1997competitive,nisan2006communication,cheung2008approximation,chawla2017stability,leme2020computing}).
\begin{equation}\label{equ:primal}
\begin{aligned}
\mbox{(LP-Primal)}~~~~\max &~~\sum_{j\in [n]}v_j\cdot y_j \\
\text{subject to} &~~\sum_{j: i\in Q_j}y_j\leq 1 &~~\forall i\in [m]\\%, i=1 ,..., n\\
&~~y_j\geq 0 &~~\forall j\in [n]
\end{aligned}
\end{equation}
\begin{equation}\label{equ:dual}
\begin{aligned}
\mbox{(LP-Dual)}~~~~~~\max &~~\sum_{i\in [m]}p_i \\
\text{subject to} &~~\sum_{i\in Q_j}p_i\geq v_j &~~\forall j\in [n]\\%, i=1 ,..., n\\
&~~p_i\ge 0 &~~\forall i\in [m]
\end{aligned}
\end{equation}
We show (in~\Cref{lem:rounding}) that for any optimal fractional solution $y^*$, there is a price vector $p^*$ such that only buyers $j$ with $y^*_j>0$ can afford their demand sets.
Moreover, such a price vector can be efficiently computed.
This reduces the task of computing prices of items to the task of finding a subset of buyers, such that (i) their demand paths are ``as vertex-disjoint as possible''; and (ii) their total value of the demand sets is a good approximation of the optimal objective value of (LP-Primal). We use the above tools to prove the competitive ratio for stars and spiders.
The above LP-based approach is similar to~\cite{cheung2008approximation}, where they prove an $8$-approximation when $G$ is a tree. To obtain the improved competitive ratio $3$ for trees, we use a new approach that makes use of our result for spider graphs. We start with an optimal allocation (which corresponds to a set $\mathcal{P}$ of demand paths), and then construct an algorithm (in \Cref{lem:treetospider}) that partitions the paths of $\mathcal{P}$ into two subsets $\mathcal{P}=\mathcal{P}_1\cup\mathcal{P}_2$, such that the graph obtained by taking the union of all paths in $\mathcal{P}_t$ is a spider, for each $t\in \set{1,2}$.
Then the task of computing the price on the edges of a tree is reduced to that of a spider, while losing a factor of $2$ in the competitive ratio.
\vspace{-.1in}
\paragraph{Techniques for lower bounds.} The hard instance for the $\Omega(m^{1/8})$ competitive ratio
is constructed on a simple series-parallel graph (see Figure~\ref{fig:mahuaintro}). In the hard instance, every buyer demands a path connecting the left-most vertex to the right-most vertex, and the value for each demand path is roughly the same.
The demand paths are constructed carefully, such that (i) each edge of the graph is contained in approximately the same number of demand paths; and (ii) the demand paths are intersecting in some delicate way.
We can then show that, for any price vector $p$, if we denote by $\mathcal{P}$ the set of affordable (under $p$) demand paths, then either the maximum cardinality of an independent subset of $\mathcal{P}$ is small, or there is a path in $\mathcal{P}$ that intersects all other paths in $\mathcal{P}$. Either way, we can conclude that the optimal worst-case welfare achieved by any item-pricing mechanism is small.
\begin{figure}[h]
\centering
\includegraphics[width=0.7\columnwidth]{mahua.jpg}
\caption{A series-parallel graph with large competitive ratio.\label{fig:mahuaintro}}
\end{figure}
\subsection{Other Related Work}
\paragraph{Walrasian equilibrium for single-minded buyers.} A closely related problem of our setting is the problem of finding market-clearing item prices for single-minded buyers. Unlike maximizing the total value of agents allocated in our setting, a Walrasian equilibrium requires every buyer with a positive utility to be allocated. The existence of the Walrasian equilibrium is proven to be NP-hard, while satisfying $\frac{2}{3}$ of the buyers is possible \cite{chen2004complexity,huang2005approximation,deng2007walrasian,chen2008walrasian}. The hardness of the problem extends to selling paths on graphs, and is efficiently solvable when the underlying graph is a tree \cite{chen2008walrasian}.
\vspace{-.1in}
\paragraph{Profit maximization for single-minded buyers.}
For the general profit maximization for single-minded buyers with unlimited supply, Guruswami et al.~\cite{guruswami2005profit} proved an $O(\log n+\log m)$-approximation. The result was improved to an $O(\log B+\log \ell)$-approximation ratio by Briest and Krysta~\cite{briest2006single}, and then to an $O(\log B)$-approximation by Cheung and Swamy~\cite{cheung2008approximation}. Here $B$ is the maximum number of sets containing an item and $\ell$ is the maximum size of a set. Balcan and Blum~\cite{balcan2006approximation} gave an $O(\ell^2)$-approximation algorithm. Hartline and Koltun~\cite{hartline2005near} gave an FPTAS with a bounded number of items. On the other hand, the problem was proved to be NP-hard for both the limited-supply~\cite{grigoriev2006sell} and unlimited-supply~\cite{guruswami2005profit,briest2006single} case, and even hard to approximate~\cite{demaine2008combination}.
\vspace{-.1in}
\paragraph{Profit maximization for the tollbooth problem.}
Grigoriev et al.~\cite{grigoriev2006sell} proved that the problem is polynomial-time solvable when the underlying graph $G$ is a tree, and it is NP-complete to approximate within factor $O(m^{1-\varepsilon})$ when $G$ is a grid, where $m$ is the number of buyers. Elbassioni et al.~\cite{elbassioni2009profit} studied the case where $G$ is a tree and obtained an $O(\log m)$-approximation even when edges have multiple supplies, improving upon the $O(\log n+\log m)$-approximation obtained in~\cite{guruswami2005profit}, where $m$ is the number of edges in the graph. When edges have an unlimited supply, the approximation ratio was further improved to $O(\log m/\log \log m)$ in~\cite{gamzu2010sublogarithmic}. Moreover, Kortsarz et al.~\cite{kortsarzprofit} studied the case where $G$ is a rooted tree and every demand path is a subpath of some root-to-leaf path of $G$. They showed that any such instance can be reduced to the tree case, by losing a constant factor in the approximation ratio.
It worths mentioning that the tollbooth problem on star graphs analyzed in our paper is similar to the graph pricing problem (where prices are given to vertices, and each buyer takes an edge) studied by Balcan and Blum~\cite{balcan2006approximation}, while they considered the unlimited supply setting. They obtained a 4-approximation, which was later shown to be tight by Lee~\cite{lee2015hardness} unless the Unique Games Conjecture is false.
For the multiple and limited supply case, Friggstad et al.~\cite{friggstad2019graph} obtained an $8$-approximation.
\vspace{-.1in}
\paragraph{Pricing for online welfare maximization with tie-breaking power.} The problem of online resource allocation for welfare maximization has been extensively studied in the prophet inequality literature. In the full-information setting where all buyers' values are known, bundle pricing achieves $2$-approximation to optimal offline welfare \cite{cohen2016invisible}, even when the buyers' values are arbitrary over sets of items. In a Bayesian setting where the seller knows all buyers' value distributions, item pricing achieves a 2-approximation in welfare for buyers with fractionally subadditive values \cite{krengel1978semiamarts,samuel1984comparison,kleinberg2012matroid,feldman2014combinatorial}, and an $O(\log\log m)$-approximation for subadditive buyers \cite{dutting2020log}. For general-valued buyers that demand at most $k$ items, item pricing can achieve a tight $O(k)$-approximation \cite{dutting2020prophet}. \cite{chawla2017stability} studied the problem of interval allocation on a path graph, and achieves $(1-\varepsilon)$-approximation via item pricing when each item has supply $\Omega(k^6/\varepsilon^3)$, and each buyer has a fixed value for getting allocated any path she demands. \cite{chawla2019pricing} further extends the results to general path allocation on trees and gets a near-optimal competitive ratio via anonymous bundle pricing.
\paragraph{Pricing for online welfare maximization without tie-breaking power.} When the seller does not have tie-breaking power, \cite{cohen2016invisible,leme2020computing} show that when there is a unique optimal allocation for online buyers with gross-substitutes valuation functions, static item pricing can achieve the optimal welfare. When the optimal allocation is not unique, \cite{cohen2016invisible,berger2020power} show that a dynamic pricing algorithm can obtain the optimal welfare for gross-substitutes buyers, but for not more general buyers. \cite{hsu2016prices} shows that if the buyers have matroid-based valuation functions, when the supply of each item is more than the total demand of all buyers, the minimum Walrasian equilibrium prices achieve near-optimal welfare. \cite{cohen2016invisible,eden2019max} shows that for an online matching market, when the seller has no tie-breaking power, static item pricing gives at least $0.51$-fraction of the optimal offline welfare, and no more than $\frac{2}{3}$.
\subsection{Organization}
In Section~\ref{sec:prelim} we describe the settings of the problems studied in the paper in detail. In Section~\ref{sec:special_graph}, we present our results on the competitive ratio for some special families of graphs, including stars and spiders (Section~\ref{sec:star_and_spider}), trees (Section~\ref{sec:tree}), cycles (Section~\ref{sec:cycle}) and outerplanar graphs (Section~\ref{sec:outerplanar}). In Section~\ref{sec: general graph}, we prove upper and lower bounds for general graphs and lower bounds for grids.
In Section~\ref{sec:no_tie_breaking} we present our results in the settings where the seller does not have tie-breaking power, on path (Section~\ref{sec:pathnt}), stars, spiders, trees and cycles (Section~\ref{sec:specialgraphsnt}). In Section~\ref{sec:congestion}, we present our results in the setting the capacity of edges in the graph is augmented by a constant.
Finally we discuss possible future directions in Section~\ref{sec:future}.
\section{Introduction}
Welfare maximization in combinatorial auctions is one of the central problems in market design. The auctioneer is selling multiple heterogeneous items to self-interested buyers. She aims to find a welfare-maximizing allocation, and designs payments to incentivize all buyers to report their private preferences truthfully. We consider the special case that every buyer is \emph{single-minded} (that is, the buyer is only interested in buying a certain subset of items), and has welfare $0$ if she does not get the whole subset. While the celebrated VCG mechanism~\cite{vickrey1961counterspeculation,clarke1971multipart,groves1973incentives} is truthful and maximizes the welfare, markets in the real world often prefer to implement simpler mechanisms, such as \emph{item pricing}.
In an item-pricing mechanism, each item is given an individual price. Buyers come to the auction sequentially and choose the favorite bundle (among the remaining items) that maximizes their own utilities. For a single-minded buyer, she will purchase her demand set if and only if all items in the set are remaining, and the total prices of the items are at most her value.
The welfare of a buyer is her value for her demand set if she takes it, or $0$ if she does not take it. The total welfare is the sum of the welfare of all buyers.
The performance of an item-pricing mechanism is measured by its \emph{worst-case welfare}, that is, the minimum welfare achieved by the mechanism when the buyers arrive in any adversarial order.
In this setting, the Walrasian equilibrium \cite{arrow1951extension,debreu1951coefficient} for gross-substitute buyers provides a set of prices as well as a welfare-maximizing allocation, such that every buyer receives her favorite bundle~\cite{kelso1982job}, which allows us to maximize the welfare using an item-pricing mechanism. However, such an equilibrium (or a set of prices) may not exist when the buyers are single-minded.
In the paper we focus on a special case of the above problem known as the \emph{tollbooth problem}~\cite{guruswami2005profit}, where the set of commodities and demands are represented by edges and paths in a graph.
This setting has found various real-world applications.
For instance, a network service provider wants to sell bandwidth along with the links of a network by pricing on every single link. And each customer is only interested in buying a single path in the network. Every item in the auction is an edge in some graph $G$ representing the network, and every buyer is single-minded and is only interested in buying all edges of a specific path of $G$.
We additionally impose the restriction that each commodity (edge) may be given to at most one buyer, which means that if an edge was taken by some previous buyer, then buyers who come afterward whose demand set contains this edge may no longer take it.
Similar to the general case, Walrasian equilibrium is not guaranteed to exist for the tollbooth problem.
Chen and Rudra~\cite{chen2008walrasian} proved that the problem of determining the existence of a Walrasian equilibrium and the problem of computing such an equilibrium (if it exists) are both NP-hard for the tollbooth problems on general graphs, but can be done efficiently when the underlying graph $G$ is a tree.
Therefore, an investigation of the power and limits of item pricing is a natural next step towards a deeper understanding of the tollbooth problem. For any item pricing mechanism, the \emph{competitive ratio} is the ratio between the hindsight optimal welfare, i.e. the optimal welfare achieved by any feasible allocation of items to buyers, and the worst-case welfare of the item-pricing mechanism. In the paper, we study the competitive ratio in any instance of the tollbooth problem, which is the best (smallest) competitive ratio among all item-pricing mechanisms.
There has been various great work studying the tollbooth problem under different settings. One line of work aims to efficiently compute prices of items as well as a special subset of buyers called \emph{winners} while maximizing the total welfare, such that it is feasible to allocate the demand sets to all winners, and every winner can afford her bundle. Grigoriev et al.~\cite{grigoriev2006sell} proved that the problem is polynomial-time solvable when the underlying graph $G$ is a tree, but it is NP-complete to approximate within factor $O(m^{1-\varepsilon})$ when $G$ is a grid, where $m$ is the number of buyers. Elbassioni et al.~\cite{elbassioni2009profit} studied the case where $G$ is a tree and obtained an $O(\log n)$-approximation even when edges have multiple supplies, improving upon the $O(\log n+\log m)$-approximation obtained in~\cite{guruswami2005profit}, where $n$ is the number of edges in the graph. When edges have an unlimited supply, the approximation ratio was further improved to $O(\log n/\log \log n)$ in~\cite{gamzu2010sublogarithmic}.
There is a major difference between all works above and our setting. In all works above, it is only required that the set of buyers who get their demand sets can afford their demand sets. But there might be other buyers who could afford their demand sets as well but eventually did not get them (or equivalently, not selected as winners).
Since the arriving order is adversarial in our setting, these buyers might come before the winners and take their demand sets. The winners may no longer get their demand sets since some items in their demand sets are already taken.
Therefore, the set of prices computed in the works above may not end up achieving the worst-case welfare equal to the total value of all winners.
It is not hard to see that our item-pricing mechanisms are stronger than the settings in the works above: If a set of prices has a competitive ratio $\alpha$ in our setting, then such a set of prices is automatically an $\alpha$-approximation in the setting of the works above, but the converse is not true.
The previous work whose setting is closest to ours is \cite{cheung2008approximation} by Cheung and Swamy. They studied envy-free pricing in the tollbooth problem, which additionally requires that the losers (buyers who did not get their demand sets) can not afford their demand sets. Envy-free pricing achieves the same welfare in any arrival order. They constructed an algorithm in the multi-supply setting, that takes any LP-based $\alpha$-approximation solution to the optimal welfare, and returns an envy-free pricing mechanism that achieves approximation ratio $O(\alpha\cdot\log u)$, where $u$ is the maximum supply of an item. When the supply of each edge is 1, the algorithm obtained a $2\alpha$-approximation. Since the best efficient LP-based algorithm~\cite{chekuri2007multicommodity} achieves a $4$-approximation algorithm when the underlying graph is a tree, the algorithm in \cite{cheung2008approximation} achieves a competitive ratio $8$ by envy-free pricing on trees. In our paper, we improve their results by computing an item pricing that achieves competitive ratio $3$ on trees.
Additionally, we analyze the competitive ratio beyond trees, e.g. cycles and outerplanar graphs. We remark that in~\cite{cheung2008approximation}, the approximation ratio compares the optimal welfare with the profit of the pricing, which is the total prices of all sold edges. In fact, all positive results in our paper also work for profit, as the profit and welfare of the item-pricing mechanisms in the proofs are the same. In the paper, we define the competitive ratio using the welfare of the pricing instead of the profit to have a consistent notation for both lower and upper bounds.
In addition to prices, a key factor that can significantly affect the welfare of an item-pricing mechanism is the \emph{tie-breaking} rule. For example, if Walrasian equilibrium exists, item pricing can achieve the optimal welfare, but requires carefully breaking ties among all the favorite bundles of every buyer. In most scenarios studied in previous work, it is assumed that the auctioneer can cleverly convince the buyer to break ties properly so as to maximize welfare. However, in real markets, buyers often come to the mechanism themselves and simply purchase an arbitrary favorite bundle that maximizes their own utility. Therefore it is possible that the absence of tie-breaking power may influence the welfare achieved by the mechanism. In this paper, we also compare the welfare guarantee of the best item-pricing mechanism in both settings of the tollbooth problem: the setting where the auctioneer has the power of deciding whether or not to allocate the demand path to the buyer, when the total price of edges in the path equals her value; and the setting where the buyer decides whether or not to purchase the demand path in the same scenario. We show that the gap between the two settings do exist, even in a special case of the tollbooth problem, where graph $G$ is a single path\footnote{This special case is also known as the \emph{highway} problem.}.
\subsection{Results and Techniques}\label{subsec:result}
\notshow{
\todo{Maybe move to preliminary.} We study the power and limitation of item pricing in single-minded welfare maximization problem. In particular, a seller sells $n$ heterogeneous items to $m$ buyers, and the objective is to maximize social welfare. Each buyer is single-minded: in other words, each buyer $i$ demands a set $S_j\subseteq[n]$ with value $v_i$, and the buyer's value for any set $S$ is $v_j$ if $S_j\subseteq S$, and $0$ otherwise. Each buyer's value is publicly known to the seller, and the seller wants to sell the items through item price $p_i$ for each item $i$.
In an item pricing mechanism with price vector $p$, buyers arrive in some order $\sigma$; and when each buyer $j$ arrives, the buyer purchases the set $S_j$ demanded by her if all items in $S_j$ are not sold and $v_j>\sum_{i\in S_j}p_i$. When $v_j=\sum_{i\in S_j}p_i$, the buyer has utility 0 for her demanded set of items, and we study the following two types of seller:
\begin{itemize}
\item A seller \textit{with tie-breaking power}: if $v_j=\sum_{i\in S_j}p_i$, then the seller can decide whether to allocate $S_j$ to buyer $j$.
\item A seller \textit{without tie-breaking power}: if $v_j=\sum_{i\in S_j}p_i$, then buyer $j$ can decide whether to purchase $S_j$ from the seller.
\end{itemize}
The \textit{competitive ratio} of any item pricing algorithm with price vector $\mathbf{p}$, is defined by the ratio of the following two quantities:
\begin{itemize}
\item The hindsight optimal welfare, which is the total value of the buyers in an optimal offline allocation; and
\item The worst-case total value of sets allocated to the buyers when the buyers' arrival order $\sigma$ is adversarial.
\end{itemize}
}
\paragraph{Item pricing for special graphs.} We first consider the case where the seller has tie-breaking power. It is folklore (see e.g. \cite{cheung2008approximation,chawla2017stability}) that when the seller has tie-breaking power and $G$ is a single path, the competitive ratio of the problem is 1, i.e., there exists an item-pricing mechanism that achieves the optimal welfare. We study the competitive ratio when $G$ belongs to some special families of graphs.
A summary of the results is shown in Table~\ref{tab:graphresults}. In particular, we prove that the competitive ratio of any tree is at most 3, which improves the 8-approximation obtained in~\cite{cheung2008approximation}. Moreover, for all special families where an $O(1)$ upper bound on the competitive ratio is proved, a set of prices that achieves the desired ratio can also be computed efficiently. The main takeaway is that: the competitive ratio of the tollbooth problem is small when the graph belongs to some simple families, (e.g. trees, cycles, or outerplanar graphs).
\begin{informaltheorem}
When the seller has tie-breaking power, the competitive ratio is $O(1)$ for any graph $G$ in the following graph classes: stars, spiders, trees, and cycles. Moreover, a set of prices that achieves the desired ratio can be computed in polynomial time. For any outerplanar graph, the competitive ratio is $O(\log^2 n)$.
\end{informaltheorem}
\begin{table}[h]
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Graph Class & Lower Bound (with Tie) & Upper Bound (with Tie) & Upper Bound (no Tie)\\
\hline
Path & \multicolumn{2}{|c|}{$1$ (\cite{cheung2008approximation,chawla2017stability})} & 3/2 (tight, Thm~\ref{thm:path_no_tie_hardness},~\ref{thm:path_no_tie})\\
\hline
Star & \multicolumn{2}{|c|}{$3/2$ (Thm~\ref{thm:star2},~\ref{thm: star lower bound})} & 2 (Thm~\ref{thm:star})\\
\hline
Spider & \multicolumn{2}{|c|}{$3/2$ (Thm~\ref{thm:spiderimproved},~\ref{thm: star lower bound})} & 7/2 (Thm~\ref{thm:spider-no-tiebreak})\\
\hline
Tree & $3/2$ (Thm~\ref{thm: star lower bound}) & $3$ (Thm~\ref{thm: tree}) & 7 (Thm~\ref{thm:tree-no-tiebreak})\\
\hline
Cycle & \multicolumn{2}{|c|}{$2$ (Thm~\ref{thm:cycle},~\ref{thm: cycle_lower_bound})} & 2 (Thm~\ref{thm:cycle_without_tie})\\
\hline
Outerplanar & $\Omega((\frac{\log n}{\log\log n})^{1/2})$ (Thm~\ref{thm:outerplanar_lower})& $O(\log^{2} n)$ (Thm~\ref{thm:outerplanar}) & $O(\log^{2} n)$ (\Cref{thm:outerplanar_without_tie})\\
\hline
\end{tabular}
\caption{Summary of results for special families of graphs.}\label{tab:graphresults}
\end{table}
\paragraph{Item pricing for general graphs.} We then consider the general graph case. In \cite{cheung2008approximation} and \cite{chin2018approximation}, the competitive ratio was proved to be $O(\sqrt{n})$. This bound also holds for the general single-minded combinatorial auctions, where the demand of every agent is an arbitrary set rather than a single path, where the $O(\sqrt{n})$-competitive ratio was shown to be tight up to a constant by Feldman et al.~\cite{feldman2015welfare}.
In this paper we prove an alternative bound $O(n^{0.4}\log^2 n\log m)$ on the competitive ratio
in any tollbooth problem with a general underlying graph (Theorem~\ref{thm:general_graph}). When $m$, the number of buyers in the auction, is subexponential on $n$, our competitive ratio is better than the previous ratio $O(\sqrt{n})$. On the other hand, we prove a lower bound $\Omega(n^{1/8})$ by constructing an instance in a special serial-parallel graph (Theorem~\ref{thm:lb-mahua}). Moreover, we show that a polynomial competitive ratio is unavoidable even when the graph is a grid.
\begin{informaltheorem}\label{inforthm:general_graph}
The competitive ratio for any tollbooth problem is $O(n^{0.4}\log^2 n\log m)$. On the other hand, there exists a tollbooth problem instance such that the competitive ratio is $\Omega(n^{1/8})$. Moreover, there exist a constant $\alpha\in (0,1)$ and an instance on grid such that the competitive ratio is $\Omega(n^{\alpha})$. Here $n$ is the number of edges and $m$ is the number of buyers.
\end{informaltheorem}
\paragraph{Without tie-breaking power.} As mentioned above, when $G$ is a single path and the seller has tie-breaking power, there exists an item pricing that achieves the optimal welfare. However, when the seller has no tie-breaking power, we present an instance where $G$ is a single path, that no item pricing can achieve more than $2/3$-fraction of the hindsight optimal welfare (Theorem~\ref{thm:path_no_tie_hardness}). On the other hand, we prove that such a $3/2$-approximation is achievable via item pricing (Theorem~\ref{thm:path_no_tie}).
We also provide upper bounds for the competitive ratio in the no tie-breaking case, when the graph $G$ belongs to some special families of graphs. We prove that the competitive ratio is $O(1)$. See also Table~\ref{tab:graphresults} for a summary of the results.
\paragraph{Resource augmentation.} We also study the problem where the seller has more resource to allocate, and want to compare the welfare achieved in this case to the optimal offline allocation without such additional resource. To be more specific, comparing to the optimal offline allocation with supply 1 for each item, the seller has augmented resources and is allowed to sell $c$ copies of each item to the buyers. In the literature studying offline path allocation problems on graphs (e.g. \cite{chuzhoy2016polylogarithmic}) and previous work using the techniques of resource augmentation general (e.g. \cite{kalyanasundaram2000speed,koutsoupias1999weak,sleator1985amortized,young1994k,caragiannis2016truthful}), even slightly increased resources usually improves the competitive ratio significantly. However in our problem, we prove that for any constant $c>1$, there exists an instance such that the competitive ratio with augmented resources is $n^{\Omega(1/c)}$ (\Cref{thm: lower_bound_congestion}). In other words, a competitive ratio that is polynomial in $n$ is unavoidable in the tollbooth problem, even if the capacity of each edge is augmented by a constant. We also prove an almost-matching upper bound of $O(n^{1/c})$ in this setting (\Cref{thm: congestion_c}). The approximation holds for any single-minded welfare maximization problem, where each buyer may demand a set of items instead of a path.
\paragraph{Techniques for upper bounds.} We use two major tools for computing prices that achieve good worst-case welfare. First, we consider the natural LP relaxation for computing the optimal allocation. It is a common technique that the variables of the dual LP can be interpreted as prices for corresponding items (see e.g.~\cite{bikhchandani1997competitive,nisan2006communication,cheung2008approximation,chawla2017stability,leme2020computing}).
\begin{equation}\label{equ:primal}
\begin{aligned}
\mbox{(LP-Primal)}~~~~\max &~~\sum_{j\in [m]}v_j\cdot y_j \\
\text{subject to} &~~\sum_{j: i\in Q_j}y_j\leq 1 &~~\forall i\in [n]\\%, i=1 ,..., n\\
&~~y_j\geq 0 &~~\forall j\in [m]
\end{aligned}
\end{equation}
\begin{equation}\label{equ:dual}
\begin{aligned}
\mbox{(LP-Dual)}~~~~~~\max &~~\sum_{i\in [n]}p_i \\
\text{subject to} &~~\sum_{i\in Q_j}p_i\geq v_j &~~\forall j\in [m]\\%, i=1 ,..., n\\
&~~p_i\ge 0 &~~\forall i\in [n]
\end{aligned}
\end{equation}
We show (in~\Cref{lem:rounding}) that for any optimal fractional solution $y^*$, there is a price vector $p^*$ such that only buyers $j$ with $y^*_j>0$ can afford their demand sets.
Moreover, such a price vector can be efficiently computed.
This reduces the task of computing prices of items to the task of finding a subset of buyers, such that (i) their demand paths are ``as vertex-disjoint as possible''; and (ii) their total value of the demand sets is a good approximation of the optimal objective value of (LP-Primal).
Second, to deal with trees, we start with an optimal allocation (which corresponds to a set $\mathcal{P}$ of demand paths), and then construct an algorithm (in \Cref{lem:treetospider}) that partitions the paths of $\mathcal{P}$ into two subsets $\mathcal{P}=\mathcal{P}_1\cup\mathcal{P}_2$, such that the graph obtained by taking the union of all paths in $\mathcal{P}_t$ is a spider, for each $t\in \set{1,2}$.
Then the task of computing the price on the edges of a tree is reduced to that of a spider, while losing a factor of $2$ in the competitive ratio.
\paragraph{Techniques for lower bounds.} The hard instance for the $\Omega(n^{1/8})$ competitive ratio
is constructed on a simple series-parallel graph (see Figure~\ref{fig:mahuaintro}). In the hard instance, every buyer demands a path connecting the left-most vertex to the right-most vertex, and the value for each demand path is roughly the same.
The demand paths are constructed carefully, such that (i) each edge of the graph is contained in approximately the same number of demand paths; and (ii) the demand paths are intersecting in some delicate way.
We can then show that, for any price vector $p$, if we denote by $\mathcal{P}$ the set of affordable (under $p$) demand paths, then either the maximum cardinality of an independent subset of $\mathcal{P}$ is small, or there is a path in $\mathcal{P}$ that intersects all other paths in $\mathcal{P}$. Either way, we can conclude that the optimal worst-case welfare achieved by any item-pricing mechanism is small.
\begin{figure}[h]
\centering
\includegraphics[width=0.7\columnwidth]{mahua.jpg}
\caption{A series-parallel graph with large competitive ratio.\label{fig:mahuaintro}}
\end{figure}
\subsection{Other Related Work}
\paragraph{Walrasian equilibrium for single-minded buyers.} A closely related problem of our setting is the problem of finding market-clearing item prices for single-minded buyers. Unlike maximizing the total value of agents allocated in our setting, a Walrasian equilibrium requires every buyer with a positive utility to be allocated. The existence of the Walrasian equilibrium is proven to be NP-hard, while satisfying $\frac{2}{3}$ of the buyers is possible \cite{chen2004complexity,huang2005approximation,deng2007walrasian,chen2008walrasian}. The hardness of the problem extends to selling paths on graphs, and is efficiently solvable when the underlying graph is a tree \cite{chen2008walrasian}.
\paragraph{Profit maximization for single-minded buyers.}
For the general profit maximization for single-minded buyers with unlimited supply, Guruswami et al.~\cite{guruswami2005profit} proved an $O(\log n+\log m)$-approximation. The result was improved to an $O(\log B+\log \ell)$-approximation ratio by Briest and Krysta~\cite{briest2006single}, and then to an $O(\log B)$-approximation by Cheung and Swamy~\cite{cheung2008approximation}. Here $B$ is the maximum number of sets containing an item and $\ell$ is the maximum size of a set. Balcan and Blum~\cite{balcan2006approximation} gave an $O(\ell^2)$-approximation algorithm. Hartline and Koltun~\cite{hartline2005near} gave an FPTAS with a bounded number of items. On the other hand, the problem was proved to be NP-hard for both the limited-supply~\cite{grigoriev2006sell} and unlimited-supply~\cite{guruswami2005profit,briest2006single} case, and even hard to approximate~\cite{demaine2008combination}. It worths mentioning that the tollbooth problem on star graphs analyzed in our paper is similar to the graph pricing problem (where prices are given to vertices, and each buyer takes an edge) studied by Balcan and Blum~\cite{balcan2006approximation}, while they considered the unlimited supply setting. They obtained a 4-approximation, which was later shown to be tight by Lee~\cite{lee2015hardness} unless the Unique Games Conjecture is false.
For the multiple and limited supply case, Friggstad et al.~\cite{friggstad2019graph} obtained an $8$-approximation.
\paragraph{Pricing for welfare maximization with online buyers.} The problem of online resource allocation for welfare maximization has been extensively studied in the prophet inequality literature. In the full-information setting where all buyers' values are known, bundle pricing achieves $2$-approximation to optimal offline welfare \cite{cohen2016invisible}, even when the buyers' values are arbitrary over sets of items. In a Bayesian setting where the seller knows all buyers' value distributions, item pricing achieves a 2-approximation in welfare for buyers with fractionally subadditive values \cite{krengel1978semiamarts,samuel1984comparison,kleinberg2012matroid,feldman2014combinatorial}, and an $O(\log\log n)$-approximation for subadditive buyers \cite{dutting2020log}. For general-valued buyers that demand at most $k$ items, item pricing can achieve a tight $O(k)$-approximation \cite{dutting2020prophet}. \cite{chawla2017stability} studied the problem of interval allocation on a path graph, and achieves $(1-\varepsilon)$-approximation via item pricing when each item has supply $\Omega(k^6/\varepsilon^3)$, and each buyer has a fixed value for getting allocated any path she demands. \cite{chawla2019pricing} further extends the results to general path allocation on trees and gets a near-optimal competitive ratio via anonymous bundle pricing.
\subsection{Organization}
In Section~\ref{sec:prelim} we describe the settings of the problems studied in the paper in detail. In Section~\ref{sec:special_graph}, we present our results on the competitive ratio for some special families of graphs, including stars and spiders (Section~\ref{sec:star_and_spider}), trees (Section~\ref{sec:tree}), cycles (Section~\ref{sec:cycle}) and outerplanar graphs (Section~\ref{sec:outerplanar}). In Section~\ref{sec: general graph}, we prove upper and lower bounds for general graphs and lower bounds for grids.
In Section~\ref{sec:no_tie_breaking} we present our results in the settings where the seller does not have tie-breaking power, on path (Section~\ref{sec:pathnt}), stars, spiders, trees and cycles (Section~\ref{sec:specialgraphsnt}). In Section~\ref{sec:congestion}, we present our results in the setting the capacity of edges in the graph is augmented by a constant.
Finally we discuss possible future directions in Section~\ref{sec:future}.
\notshow{
\znote{
\begin{itemize}
\item define notation $\textnormal{\textsf{gap}}$ (probably using another symbol), and restate all results using this notation (both in intro and the main body).
\item his/her?
\item welfare/revenue?
\item $+\infty$ to be replaced by a large enough constant
\end{itemize}
}
}
\subsection{Motivation: The Walrasian Equilibrium}
\subsubsection{Definition}
$n$ items, $m$ buyers. Each buyer has a fixed valuation $v:2^{[n]}\to \mathbb{R}$.
Price $p\in\mathbb{R}^n$ for each item.
Demand set: $D(v_i,p)=\arg\max_{S\subseteq[n]}(v_i(S)-p(S))$, i.e. the utility-maximizing set.
Market Equilibrium: disjoint $S_1,\cdots,S_m$, $S_i\in D(v_i,p)$, $\cup S_j=[n]$.
First welfare theorem: In equilibrium, the welfare is maximized.
Gross substitutes valuations $v$: for any $p\leq p'$ and $S\in D(v,p)$, there exists $X\in D(v,p')$ such that $S\cap\{i|p_i=p'_i\}\subseteq X$.
Some examples of GS valuation function:
\begin{itemize}
\item Unit-demand
\item Additive
\item Matching valuations: $v(S)=$ maximum matching from $S$
\end{itemize}
GS is a subclass of submodular functions.
\subsection{Existence of Equilibrium}
\begin{theorem}
\ [Kelso-Crawford '82] When all agents have GS valuations, then Walrasian Equilibrium always exists.
\end{theorem}
Walrasian Equilibrium does not exist beyond GS valuation, see the following theorem.
\begin{theorem}
\ [Gul-Stachetti '00](seemingly with error, reproved by [Berger-Eden-Feldman '20]) If $v_1$ is not GS, then there exists unit-demand buyers $v_2,\cdots, v_n$ such that $(v_1,\cdots,v_n)$ does not have Walrasian Equilibrium.
\end{theorem}
\begin{theorem}\label{thm:lp}
\ [Nisan-Segal '06] Walrasian Equilibrium exists iff the LP for welfare maximization has integral optimal solution. \\
$\max\sum_{i,S}v_{i}(S)x_{iS}$
\end{theorem}
Theorem~\ref{thm:lp} is the literature that formulates the problem using primal and dual lp, and relates the dual variables to prices and utilities.
There should be more theorems on the existence of Walrasian equilibrium beyond GS, see ``Why Prices Need Algorithms'' by Roughgarden and Talgam-Cohen.
\subsubsection{Approximation of Walrasian Equilibrium via Prophet Inequality}
\begin{theorem}
\ [Feldman-Gravin-Lucier '15] When all agents have XOS (fractionally subadditive) valuations, then static item pricing gives 2-approx in welfare. Works even for Bayesian setting.
\end{theorem}
\begin{theorem}
\ [Dütting-Kesselheim-Lucier '20] When all agents have subadditive valuations, then static item pricing gives $O(\log\log n)$-approx in welfare. Works even for Bayesian setting.
\end{theorem}
Main open question: When all agents have subadditive valuations, can static item pricing give $O(1)$-approx in welfare, even for fixed valuation?
\subsection{Hardness Results}
\begin{theorem}
\ [Feldman-Gravin-Lucier '15] When all agents demands intervals of size at most $n$, item pricing cannot do better than $n$-approx. (One single minded buyer demanding the entire interval with value $n-\varepsilon$, another unit-demand buyer demanding each item with value 1.)
\end{theorem}
\begin{theorem}
\ [Trevisan '01] Computational hardness result: $o(k/2^{O(\sqrt{\log k})})$-approx integral offline allocation for single-minded buyers that demands sets of size at most $n$ cannot be found efficiently, via reduction to maximum independent set, even in the case where all demand-sets have size at most $k$.
\end{theorem}
\section{Stars and Spiders}
\input{star_and_spider_new}
\input{tree.tex}
\input{cycle.tex}
\input{outerplanar}
\input{general_graph}
\input{no_tie_breaking}
\input{resource_aug}
\input{future_work}
\bibliographystyle{abbrv}
\section{Competitive Ratios without the Tie-Breaking Power}\label{sec:no_tie_breaking}
In this section, we consider the scenario where the seller does not have the tie-breaking power.
\subsection{Path}\label{sec:pathnt}
We first focus on the case when $G$ is a single path. Unlike the scenario with tie-breaking power, where the optimal welfare can be obtained with some set of prices (Theorem~\ref{thm:path}), the competitive ratio may be strictly larger than 1 when the seller has no tie-breaking power.
\begin{theorem}\label{thm:path_no_tie_hardness}
\label{thm: path_no_tie_lower_bound}
$\textnormal{\textsf{gap}}_{\textnormal{\textsf{NT}}}(\mathsf{Path})\geq 3/2$, i.e. there exists a path graph $G$ and an instance $\mathcal{F}$, such that any set of prices achieves worst-case welfare at most $2/3\cdot \mathsf{OPT}(G,\mathcal{F})$, when the seller has no tie-breaking power.
\end{theorem}
\begin{proof}
Let $G$ be a path consisting of three edges $e_1,e_2,e_3$, that appears on the path in this order. The instance is described below.
\begin{itemize}
\item Buyer 1 demands the path consisting of a single edge $e_1$, with value $1$;
\item Buyer 2 demands the path consisting of a single edge $e_3$, with value $1$;
\item Buyer 3 demands the path consisting of edges $e_1,e_2$, with value $2$; and
\item Buyer 4 demands the path consisting of edges $e_2,e_3$, with value $2$.
\end{itemize}
It is clear that the optimal allocation is assigning $e_1$ to buyer 1 and $e_2,e_3$ to buyer 4 (or assigning $e_3$ to buyer 2 and $e_1,e_2$ to buyer 3). The optimal welfare $\mathsf{OPT}(G,\mathcal{F})=3$.
We now show that, for any prices $p_1,p_2,p_3$, there is an order $\sigma$ of the four buyers such that the obtained welfare is at most $2$, when the seller has no tie-breaking power. We distinguish between two cases.
\textbf{Case 1. $p_1\leq 1$ and $p_3\leq 1$.} We let buyers 1 and 3 come first and take edges $e_1$ and $e_3$ respectively. Note that the seller does not have the tie-breaking power. The buyer can decide whether or not to take the path when the price equals the value. Now buyers 3 and 4 cannot get their paths. So the obtained welfare is $2$.
\textbf{Case 2. $p_1>1$ or $p_3>1$.} Assume without loss of generality that $p_1>1$. If $p_2+p_3\leq 2$, then we let buyer 4 come first and take edges $e_2$ and $e_3$. It is clear that no other buyer can get her path. So the total welfare is 2. If $p_2+p_3>2$, then $p_1+p_2+p_3>3$. Note that it is impossible in this case all edges are sold, since the hindsight optimal welfare is 3. Therefore, the obtained welfare is at most $2$.
\end{proof}
In Theorem~\ref{thm:path_no_tie} we prove that the competitive ratio $3/2$ is tight for path graphs, when the seller has no tie-breaking power.
\begin{theorem}
\label{thm:path_no_tie}
$\textnormal{\textsf{gap}}_{\textnormal{\textsf{NT}}}(\mathsf{Path})\leq 3/2$. Moreover, the prices that achieve the competitive ratio 3/2 can be computed efficiently.
\end{theorem}
\begin{proof}
From \Cref{thm:path}, (LP-Primal) has an integral optimal solution. We denote by $y^*$ the integral optimal solution of (LP-Primal) that maximizes $\sum_{j\in [n]}y^*_j$. Note that $y^*$ can be computed by solving a slightly different LP that is obtained from (LP-Primal) by changing its objective to $\sum_{j\in [n]}(v_j+\varepsilon')\cdot y_j$, for some small enough $\varepsilon'>0$.
Define $Y=\set{j\mid y^*_j=1}$ and
$\mathcal{Q}_Y=\set{Q_j\mid y^*_j=1}$.
\begin{lemma}\label{lem:price-strictly-positive}
There is an $\varepsilon>0$ and an optimal solution $\set{p^*(e)}_{e\in E(G)}$ for (LP-Dual), such that
(i) for each edge $e\in E(\mathcal{Q}_Y)$, $p^*(e)\geq \varepsilon$; and (ii)
for each $j\in [m]$, either $p^*(Q_j)=v_j$, or $p^*(Q_j)>v_j+m\varepsilon$.
\end{lemma}
\begin{prevproof}{Lemma}{lem:price-strictly-positive}
Let $\varepsilon'=\frac{1}{m^2}\cdot\min_jv_j$. We construct another instance $\mathcal{F}'$ from $\mathcal{F}$ as follows. We add, for each $e\in E(G)$ a new buyer demanding the path consisting of a single edge $e$ with value $\varepsilon'$.
On one hand, it is easy to see that $y^*$ is still an optimal solution of this new instance. Let $p^*$ be any optimal solution for the corresponding dual LP for the new instance $\mathcal{F}$. Define $\varepsilon''=\frac{1}{2m}\min_{j:p*(Q_j)>v_j}(p^*(Q_j)-v_j)$ and $\varepsilon=\min\{\varepsilon',\varepsilon''\}$. Clearly $p^*$ is also an optimal dual solution for the instance $\mathcal{F}$ and satisfies both properties.
\end{prevproof}
Now choose $\varepsilon>0$ and the prices $p^*$ from Lemma~\ref{lem:price-strictly-positive}. We define $A=\set{j\mid v_j=p^*(Q_j)}$ and $\mathcal{Q}_A=\set{Q_j\mid j\in A}$.
\begin{definition}
We say that a set $\mathcal{Q}\subseteq \mathcal{Q}_A$ of edge-disjoint paths is \emph{good}, iff set $\mathcal{Q}_A\setminus \mathcal{Q}$ does not contain another subset $\mathcal{Q}'$ of $|\mathcal{Q}'|\ge 2$ edge-disjoint paths, such that
$\bigcup_{j:Q_j\in \mathcal{Q}'}Q_j=\bigcup_{j:Q_j\in \mathcal{Q}}Q_j$.
\end{definition}
We prove the following lemma about good edge-disjoint paths.
\begin{lemma}\label{claim:covering_implies_optimal}
There is an efficient algorithm that, given a good set $\mathcal{Q}$ of edge-disjoint paths, computes a set of positive prices $p=\{p(e)\}_{e\in E(\mathcal{Q})}$
that achieves worst-case welfare at least $\sum_{Q_j\in \mathcal{Q}}v_j$.
\end{lemma}
\begin{proof}
We denote $I=\bigcup_{Q_j\in \mathcal{Q}}Q_j$ and $\mathcal{Q}_I=\{Q_j\in \mathcal{Q}_A\mid Q_j\subseteq I\}$.
First, for each edge $e\notin E(I)$, we set its price $p(e)=+\infty$.
Therefore, all buyers $j$ with $Q_j\notin \mathcal{Q}_I$ cannot get her demand path.
We will show that we can efficiently compute prices $\set{p(e)}_{e\in E(I)}$ for edges of $I$, such that (i) for each path $Q_j\in \mathcal{Q}$, $v_j>p(Q_j)$; and (ii) for each path $Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}$, $v_j<p(Q_j)$.
It is clear that the set $\set{p(e)}_{e\in E(G)}$ of prices achieves worst-case welfare $\sum_{Q_j\in \mathcal{Q}}v_j$.
The existence of prices $\set{p(e)}_{e\in E(I)}$ is equivalent to the feasibility of the following system.
\begin{equation}\label{lp:covering-primal}
\left\{
\begin{array}{cccc}
\displaystyle \sum_{e\in Q_j}p(e) &< & v_j,&\forall Q_j\in\mathcal{Q};\\
\displaystyle \sum_{e\in Q_j}p(e) & >& v_j,&\forall Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}.
\end{array}
\right.
\end{equation}
From the definition of $A$, and since $\mathcal{Q}_I\subseteq\mathcal{Q}_A$, for each path $Q_j\in \mathcal{Q}_I$, $\sum_{e\in Q_j}p^*(e)= v_j$.
We denote $\alpha(e)=p(e)-p^*(e)$ for all $e\in E(I)$, then system~\eqref{lp:covering-primal} is feasible if the following system is feasible, for some small enough $\varepsilon'>0$.
\begin{equation}\label{lp:covering-primal2}
\left\{
\begin{array}{cccc}
\displaystyle \sum_{e\in Q_j}\alpha(e) &\le & -\varepsilon',&\forall Q_j\in\mathcal{Q};\\
\displaystyle \sum_{e\in Q_j}\alpha(e) & \ge & \varepsilon',&\forall Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}.
\end{array}
\right.
\end{equation}
\iffalse
Then system~\eqref{lp:covering-primal2} is feasible if and only if the following system is feasible, for a small enough constant $\sigma>0$.
\begin{equation}\label{lp:covering-primal3}
\left\{
\begin{array}{cccc}
\displaystyle \sum_{e\in Q_j}\alpha(e) &\le & -\sigma,&\forall Q_j\in\mathcal{Q};\\
\displaystyle \sum_{e\in Q_j}-\alpha(e) & \leq & -\sigma,&\forall Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}.
\end{array}
\right.
\end{equation}
\fi
From Farkas' Lemma,
system~\eqref{lp:covering-primal2} is feasible if and only if the following system is infeasible.
\begin{equation}\label{lp:covering-dual}
\left\{
\begin{array}{rccc}
\displaystyle \sum_{Q_j\in \mathcal{Q}}\beta_j\cdot\mathbbm{1}[e\in Q_j]-\sum_{Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}}\beta_j\cdot\mathbbm{1}[e\in Q_j] &=& 0,&\forall e\in E(I);\\
\displaystyle\sum_{Q_j\in \mathcal{Q}_I}\beta_j&>& 0;\\
\beta_j & \in & [0,1],&\forall Q_j\in \mathcal{Q}_I.
\end{array}
\right.
\end{equation}
where the additional constraints $\beta_j\le 1, \forall Q_j\in \mathcal{Q}_I$ will not influence the feasibility of the system due to scaling.
Next we will prove that system \eqref{lp:covering-dual} is feasible iff it admits an integral solution.
\begin{definition}
We say that a matrix $A$ is \emph{totally unimodular} iff the determinant of every square submatrix of $A$ belongs to $\{0,-1,+1\}$.
\end{definition}
\begin{lemma}[Folklore]
\label{lem:forklore}
If a matrix $A\in \mathbb{R}^{n\times m}$ is totally unimodular and a vector $b\in\mathbb{R}^n$ is integral, then every extreme point of the polytope $\{x\in \mathbb{R}^m\mid Ax\leq b, x\geq 0\}$ is integral.
\end{lemma}
\begin{lemma}[\cite{schrijver1998theory}] \label{lem:proposition-tu}
A matrix $A\in \mathbb{R}^{n\times m}$ is totally unimodular iff for any subset $R\subseteq [n]$, there exists a partition $R=R_1\cup R_2$, $R_1\cap R_2=\emptyset$, such that for any $j\in [m]$,
$$\sum_{i\in R_1}a_{ij}-\sum_{i\in R_2}a_{ij}\in \{0,-1,+1\}.$$
\end{lemma}
\begin{lemma}\label{lem:covering-integral-solu}
System~\eqref{lp:covering-dual} is feasible if and only if it admits an integral solution.
\end{lemma}
\begin{proof}
We prove that the coefficient matrix $C$ in system \eqref{lp:covering-dual} is totally unimodular.\footnote{The second inequality in system \eqref{lp:covering-dual} is strict inequality. We can modify it to an equivalent inequality $\sum_{j:Q_j\in \mathcal{Q}}\beta_j\geq \varepsilon_0$ for some sufficiently small $\varepsilon_0>0$ and then apply Lemma~\ref{lem:forklore}.} For any set of rows $R=\{i_1,i_2,\cdots,i_k\}$ such that $i_1<i_2<\cdots<i_k$, We define the partition $R_1=\{i_1,i_3,i_5,...\}$ be the set with odd index and $R_2=\{i_2,i_4,i_6,...\}$ be the set with even index. For every column $j$, $Q_j$ is an subpath and thus the ones (or -1s for $Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}$) in the vector $(C_{ij})_{i=1}^m$ are consecutive. Hence the difference between $\sum_{i\in R_1}C_{ij}$ and $\sum_{i\in R_2}C_{ij}$ is at most 1. By Lemma~\ref{lem:proposition-tu}, $C$ is totally unimodular.
\end{proof}
Assume for contradiction that \eqref{lp:covering-dual} is feasible, let $\beta^*\in \set{0,1}^{\mathcal{Q}_I}$ be an integral solution of \eqref{lp:covering-dual}.
Note that the constraints
$\sum_{j:Q_j\in \mathcal{Q}}\beta^*_j\cdot\mathbbm{1}[e\in Q_j]-\sum_{j:Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}}\beta^*_j\cdot\mathbbm{1}[e\in Q_j] = 0,\forall e\in E(I)$ and the fact that paths of $\mathcal{Q}$ are edge-disjoint
imply that the paths in set $\mathcal{Q}'=\{Q_j\mid \beta_j=1\}$ are edge-disjoint. Note that $\mathcal{Q}'\cap\mathcal{Q}=\emptyset$ and $\bigcup_{Q_j\in \mathcal{Q}'}Q_j=\bigcup_{Q_j\in \mathcal{Q}}Q_j$, and this is a contradiction to the assumption that the set $\mathcal{Q}$ is good.
Therefore, system \eqref{lp:covering-dual} is infeasible, and thus system \eqref{lp:covering-primal2} is feasible.
Let $(\alpha(e))_{e\in E(I)}$ be a solution of system~\eqref{lp:covering-primal2}, such that $\sum_{e\in E(I)} |\alpha(e)|\le \varepsilon$. It is clear that such a solution exists due to scaling.
We set $p(e)=p^*(e)+\alpha(e)$ for all $e\in E(I)$, and it is clear that the prices $\set{p(e)}_{e\in E(G)}$ satisfy all the properties of \Cref{claim:covering_implies_optimal}.
Moreover, prices $\set{p(e)}_{e\in E(G)}$ are positive.
\end{proof}
We now complete the proof of Theorem~\ref{thm:path_no_tie} using \Cref{claim:covering_implies_optimal}.
We denote $\mathcal{Q}_Y=\set{Q_1,Q_2,\ldots,Q_k}$, where the paths are indexed according to the order in which they appear on $G$.
First, for each edge $e\notin E(\mathcal{Q}_Y)$, we set its price $\tilde p(e)=+\infty$.
Therefore, any buyer $j$ with $e\in Q_j$ cannot take her demand path.
In fact, we may assume without loss of generality that $\bigcup_{1\le j\le k}Q_j=G$, since otherwise we can view each connected component (which is also a path) of graph $\bigcup_{1\le j\le k}Q_j$ as the whole graph, and compute prices for its edges separately.
We will compute three sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3\subseteq \mathcal{Q}_A$ of edge-disjoint paths, such that
\begin{enumerate}
\item every edge of $E(G)$ is contained in exactly two paths of $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$; and
\item \label{prop: good_cover} for each $t\in \set{1,2,3}$, if we further partition the set $\hat\mathcal{Q}_t$ into subsets $\hat\mathcal{Q}^1_t,\ldots,\hat\mathcal{Q}^{r_t}_t$, such the union of the paths in each set $\hat\mathcal{Q}^1_t$ forms a connected component (which is also a path) of graph $\bigcup_{Q_j\in \hat\mathcal{Q}_t}Q_j$, then each of the sets $\hat\mathcal{Q}^1_t,\ldots,\hat\mathcal{Q}^{r_t}_t$ is a good set of edge-disjoint paths.
\end{enumerate}
By definition, $\sum_{Q_j\in \hat\mathcal{Q}_1}v_j+\sum_{Q_j\in \hat\mathcal{Q}_2}v_j+\sum_{Q_j\in \hat\mathcal{Q}_3}v_j=2\cdot\mathsf{OPT}(G,\mathcal{F})$.
Assume without loss of generality that $\sum_{Q_j\in \hat\mathcal{Q}_1}v_j\ge (2/3)\cdot\mathsf{OPT}(G,\mathcal{F})$.
Then from Lemma~\ref{claim:covering_implies_optimal}, there exist prices $\set{\tilde p(e)}_{e\in E(\mathcal{Q}_Y)}$ that achieves worst-case welfare at least $\sum_{Q_j\in \hat\mathcal{Q}_1}v_j\ge (2/3)\cdot\mathsf{OPT}(G,\mathcal{F})$.
\paragraph{Compute the sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$.}
We now compute the desired sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$ of edge-disjoint paths, which, from the above discussion, completes the proof of Theorem~\ref{thm:path_no_tie}.
We start by defining $\hat\mathcal{Q}$ to be the multi-set that contains, for each path $Q_j\in\mathcal{Q}_Y$, two copies $Q'_j,Q''_j$ of $Q_j$.
We initially set
\begin{itemize}
\item $\hat\mathcal{Q}_1=\set{Q'_{6r+3},Q'_{6r+4}\mid 1\le r\le k/6} \cup\set{Q''_{6r},Q''_{6r+1}\mid 1\le r\le k/6}$;
\item $\hat\mathcal{Q}_2=\set{Q'_{6r+1},Q'_{6r+2}\mid 1\le r\le k/6} \cup\set{Q''_{6r+4},Q''_{6r+5}\mid 1\le r\le k/6}$; and
\item $\hat\mathcal{Q}_3=\set{Q'_{6r+2},Q'_{6r+3}\mid 1\le r\le k/6} \cup\set{Q''_{6r+2},Q''_{6r+3}\mid 1\le r\le k/6}$.
\end{itemize}
See Figure~\ref{fig:path-1} for an illustration.
Clearly, sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$ partition $\hat\mathcal{Q}$, each contains edge-disjoint paths, and every edge appears twice in paths of $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$.
However, sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$ may not satisfy Property~\ref{prop: good_cover}.
We will then iteratively modify sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$, such that at the end Property~\ref{prop: good_cover} is satisfied.
Throughout, we also maintain graphs $G_t=\bigcup_{Q\in \hat{\mathcal{Q}}_t}Q$, for each $t\in \set{1,2,3}$. As sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$ change, graphs $G_1,G_2,G_3$ evolve.
We start by scanning the path $G$ from left to right, and process, for each each connected component of graphs $G_1,G_2,G_3$, as follows.
We first process the connected component in $G_1$ formed by the single path $Q_1''$. Clearly, set $\set{Q_1''}$ is good, since if there are other paths $\hat Q,\hat Q'\in \mathcal{Q}_A$ such that $\hat Q,\hat Q'$ are edge-disjoint and $\hat Q\cup \hat Q'=Q_1$, then the set $\set{\hat Q,\hat Q',Q_2,\ldots,Q_k}$ corresponds to another integral optimal solution $\hat y^*$ of (LP-Primal) with $\sum_{j\in [n]}\hat y^*_j=k+1>k=\sum_{j\in [n]}\hat y^*_j$, a contradiction to the definition of $y^*$. We do not modify path $Q''_1$ in $\hat{\mathcal{Q}}_1$ and continue to the next iteration.
We then process the connected component in $G_2$ formed by the paths $Q_1',Q_2'$. If the set $\set{Q_1',Q_2'}$ is good, then we do not modify this component and continue to the next iteration. Assume now that the set $\set{Q_1',Q_2'}$ is not good.
From similar arguments, there exist two other paths $Q^*_1,Q^*_2\in \mathcal{Q}_A$, such that $Q^*_1,Q^*_2$ are edge-disjoint and $Q^*_1\cup Q^*_2=Q_1\cup Q_2$.
We then replace the paths $Q'_1,Q'_2$ in $\hat{\mathcal{Q}}_2$ by paths $Q^*_1,Q^*_2$.
Let $v^*_1$ be the vertex shared by paths $Q^*_1,Q^*_2$, so $v^*_1\ne v_1$. We distinguish between the following cases.
\textbf{Case 1. $v^*_1$ is to the left of $v_1$ on path $G$.}
As shown in Figure~\ref{fig:path-2}, we keep the path $Q^*_2$ in $\hat{\mathcal{Q}}_2$, and move path $Q^*_1$ to $\hat{\mathcal{Q}}_3$.
Clearly, we create two new connected components: one in $G_3$ formed by a single path $Q^*_1$, and the other in $G_2$ formed by a single path $Q^*_2$.
From similar arguments, the corresponding singleton sets $\set{Q^*_1}, \set{Q^*_2}$ are good.
\textbf{Case 2. $v^*_1$ is to the right of $v_1$ on path $G$.}
As shown in Figure~\ref{fig:path-4}, we keep the path $Q^*_2$ in $\hat{\mathcal{Q}}_2$, move path $Q^*_1$ to $\hat{\mathcal{Q}}_1$ and additionally move the path $Q'_1$ processed in previous iteration to $\hat{\mathcal{Q}}_2$.
Clearly, we create two new connected components: one in $G_1$ formed by a single path $Q^*_1$, and the other in $G_2$ formed by a single path $Q^*_2$.
From similar arguments, the corresponding singleton sets $\set{Q^*_1}, \set{Q^*_2}$ are good.
Note that we have additionally moved $Q'_1$ to $\hat{\mathcal{Q}}_2$, but since we did not change the corresponding component, the singleton set $\set{Q'_1}$ is still good.
\begin{figure}[h]
\centering
\subfigure[An illustration of paths in set $\hat{\mathcal{Q}}_1\cup \hat{\mathcal{Q}}_2\cup \hat{\mathcal{Q}}_3$ at the beginning.]{\scalebox{0.4}{\includegraphics{interval_1.jpg}}\label{fig:path-1}}
\subfigure[An illustration of path modification in Case 1.]{\scalebox{0.4}{\includegraphics{interval_2.jpg}}\label{fig:path-2}}
\subfigure[An illustration of path modification in Case 2.]{\scalebox{0.4}{\includegraphics{interval_4.jpg}}\label{fig:path-4}}
\subfigure[How old and new paths/components may possibly interact.]{\scalebox{0.39}{\includegraphics{interval_3.jpg}}\label{fig:path-3}}
\caption{Illustrations of the algorithm for computing path sets $\hat{\mathcal{Q}}_1,\hat{\mathcal{Q}}_2,\hat{\mathcal{Q}}_3$.}
\end{figure}
We continue processing the remaining connected components in the same way until all components are good. We will show that, every time a connected component is not good and the corresponding two paths are replaced with two new paths, the connected components in $G_1,G_2,G_3$ that we have processed in previous iterations will stay good. Therefore, the algorithm will end up producing good components in $G_1,G_2,G_3$ consisting of a good set of one or two edge-disjoint paths.
To see why this is true, consider an iteration where we are processing a component consisting of paths $Q''_i, Q''_{i+1}$, and there exists edge-disjoint paths $Q^*_i,Q^*_{i+1}$ such that $Q^*_i\cup Q^*_{i+1}=Q''_i\cup Q''_{i+1}$, while the endpoint $v^*_i$ shared by $Q^*_i$ and $Q^*_{i+1}$ is an endpoint of a processed component, as shown in Figure~\ref{fig:path-3}.
Note that this is the only possibility that the new components may influence the previous components,
However, we will show that this is impossible.
Note that $Q''_{i}\in \mathcal{Q}_Y$.
We denote by $Q^r$ the path with endpoints $v^*_i$ and $v_i$, then clearly paths $Q^*_i, Q^r$ are not in $\mathcal{Q}_Y$, edge-disjoint and satisfy that $Q_{i}=Q^*_i\cup Q^r$.
Consider now the set $(\mathcal{Q}_Y\setminus \set{Q_{i}})\cup \set{Q^*_i, Q^r}$. It is clear that this set corresponds to another integral optimal solution $\hat y^*$ of (LP-Primal) with $\sum_{j\in [n]}\hat y^*_j=k+1>k=\sum_{j\in [n]}\hat y^*_j$, a contradiction to the definition of $y^*$.
\end{proof}
\subsection{Other Special Families of Graphs}\label{sec:specialgraphsnt}
We bound the competitive ratio for the no tie-breaking case, when $G$ is in special families of graphs discussed in Section~\ref{sec:special_graph}. For star and spider graphs, we prove that the competitive ratios are at most $2$ and $7/2$ respectively.
\begin{theorem}
\label{thm:star}
For any $\varepsilon>0$, $\textnormal{\textsf{gap}}_{\textnormal{\textsf{NT}}}(\mathsf{Star})\leq 2+\varepsilon$. Moreover, the prices that achieve the competitive ratio $2+\varepsilon$ can be computed efficiently.
\end{theorem}
\begin{proof}
The optimal allocation can be computed efficiently by ~\cite{tarjan1985decomposition}. Let $\mathcal{Q}$ be the set of paths in the optimal allocation, so $\mathsf{OPT}=\sum_{j:Q_j\in \mathcal{Q}}v_j$.
We set the prices on the edges of $G$ as follows. Let $\varepsilon'=\varepsilon/5$.
For each path $Q_j\in \mathcal{Q}$, if it contains a single edge $e_i$, then we set the price of $e_i$ to be $(1-\varepsilon')\cdot v_j$; if it contains two edges $e_i,e_{i'}$, then we set the price of both $e_i$ and $e_{i'}$ to be $(\frac{1}{2}-\varepsilon')\cdot v_j$.
For each edges that does not belong to any path of $\mathcal{Q}$, we set its price to be $+\infty$.
We now show that the above prices will achieve worst-case welfare at least $(\frac{1}{2}-\varepsilon')\cdot\mathsf{OPT}$. For a path $Q_j$ that contains a single edges $e_i$, clearly $e_i$ will be taken by some buyer (not necessarily $j$) at price $(1-\varepsilon')\cdot v_j$, for any arriving order $\sigma$. For a path $Q_{j'}$ that contains two edges $e_{i},e_{i'}$, we notice that buyer $j'$ can afford her demand path. Thus for any order $\sigma$, at least one of $e_{i},e_{i'}$ will be sold at price $(\frac{1}{2}-\varepsilon')\cdot v_{j'}$, otherwise buyer $j'$ must have purchased $Q_{j'}$. Hence for any order $\sigma$, the total price of the sold edges is at least $(\frac{1}{2}-\varepsilon')\cdot\mathsf{OPT}$. Since all buyers have non-negative utility, the worst-case welfare is also at least $(\frac{1}{2}-\varepsilon')\cdot\mathsf{OPT}\geq \frac{\mathsf{OPT}}{2+\varepsilon}$.
\end{proof}
\begin{theorem}\label{thm:spider-no-tiebreak}
For any $\varepsilon>0$, $\textnormal{\textsf{gap}}_{\textnormal{\textsf{NT}}}(\mathsf{Spider})\leq 7/2+\varepsilon$. Moreover, the prices that achieve the competitive ratio $7/2+\varepsilon$ can be computed efficiently.
\end{theorem}
\begin{proof}
Let $\mathcal{Q}$ be the set of paths in the optimal allocation.
We define $\mathcal{Q}_1$ to be the set of all paths in $\mathcal{Q}$ that contains the center of the spider, and we define $\mathcal{Q}_2=\mathcal{Q}\setminus \mathcal{Q}_1$. For each path $Q\in \mathcal{Q}_1$, let $j_Q$ be the buyer who is allocated her demand path $Q$ in the optimal allocation. Define $G_Q$ to be the graph obtained by taking the union of all (one or two) legs whose edge sets intersect with $E(Q)$, and we denote $E_Q=E(G_Q)$. Since paths in $\mathcal{Q}_1$ are edge-disjoint, clearly for any $Q,Q'\in \mathcal{Q}_1$, $E_Q\cap E_{Q'}=\emptyset$. For any edge set $E$, let $\mathcal{F}|_E\subseteq \mathcal{F}$ be the sub-instance that contains all buyer $j$ where $Q_j$ has edges only in $E$. Then $\mathsf{OPT}(G,\mathcal{F})=\sum_{Q\in\mathcal{Q}_1}\mathsf{OPT}(G_Q,\mathcal{F}|_{E_Q})$.
Let $e_{Q,1}$ and $e_{Q,2}$ be the two edges that are in Q and has the spider center as one endpoint.\footnote{$e_{Q,1}=e_{Q,2}$ if the spider center is one endpoint of path $Q$.}
Define $G'_Q$ to be the graph with edge set $E'_Q=\{e|e\in E_Q\setminus Q\}$. In other words, $G'_Q$ contains all edges not in $Q$ but in $E_Q$. Clearly we have $\mathsf{OPT}(G_Q,\mathcal{F}|_{E_Q})=\mathsf{OPT}(G'_Q,\mathcal{F}|_{E'_Q})+v_{j_Q}$. Define $G''_Q$ to be the graph with edge set $E''_Q=Q\setminus\{e_{Q,1},e_{Q,2}\}$; in other words, $G''_Q$ is the graph formed edges in $Q$, but excluding the center of the spider. Note that $E_Q=E'_Q\cup E''_Q\cup \{e_{Q,1},e_{Q,2}\}$. See \Cref{fig:spider_proof} for an illustration.
\begin{figure}[h]
\centering
\includegraphics[scale=0.12]{spider_proof.jpg}
\caption{An illustration of edge sets. Edges of $E'_Q$ are shown in green, and edges of $E''_Q$ are shown in red.\label{fig:spider_proof}}
\end{figure}
Let $\alpha_Q=\frac{\mathsf{OPT}(G''_Q,\mathcal{F}|_{E''_Q})}{v_{j_Q}}$. Clearly $\alpha_Q\leq 1$, since $E''_Q\subseteq Q$. We will construct the price vector $p$ as follows. For every $Q\in \mathcal{Q}_1$, we will first construct two price vectors $p_1$ and $p_2$ on $E_Q$. Then depending on the instance, we will either choose $p(e)=p_1(e),\forall e\in E_Q$, or $p(e)=p_2(e),\forall e\in E_Q$. For every $e\not\in \cup_{Q\in \mathcal{Q}_1}E_Q$, we set $p(e)=+\infty$. Now fix any $Q\in \mathcal{Q}_1$ and any $\varepsilon'>0$.
\paragraph{Construction of $p_1$.} For each $e\in E'_Q$, let $p_1(e)=+\infty$. For each $e\in E''_Q$, let $p_1(e)=p^*(e)+\frac{1}{m}\varepsilon'$, where $p^*=\{p^*(e)\}_{e\in E''_Q}$ is the set of prices from Theorem~\ref{thm:path} on $G''_Q$, whose worst-case welfare is $\mathsf{OPT}(G''_Q,\mathcal{F}|_{E''_Q})$. For $e=e_{Q,1}$ or $e_{Q,2}$, $p_1(e)=\frac{(1-\alpha_Q)v_{j_Q}}{2}-\varepsilon'$. Then no buyer $j$ where $Q_j$ contains an edge in $E'_Q$ can afford her path. Also, we notice that since $p^*$ is the optimal solution in (LP-Dual) for instance $(G''_Q,\mathcal{F}|_{E''_Q})$, every buyer $j$ where $Q_j$ has edges only in $E''_Q$ satisfies $v_j\leq p^*(Q_j)$. Thus none of them can afford her path in $p_1$, as $p_1(e)<p^*(e)$ for all $e\in E''_Q$.
Moreover, the total price of edges in $Q$ is $\sum_{e\in E''_Q}p_1(e)+p_1(e_{Q,1})+p_1(e_{Q,2})<\mathsf{OPT}(G''_Q,\mathcal{F}|_{E''_Q})+\varepsilon'+(1-\alpha_Q)v_{j_Q}-2\varepsilon'<v_{j_Q}$.
Consider any item pricing $p$ such that $p(e)=p_1(e),\forall e\in E_Q$. From the arguments above, only buyer $j$ whose $Q_j$ contains $e_{Q,1}$ or $e_{Q,2}$ may afford her path. Thus at least one of $e_{Q,1}$ and $e_{Q,2}$ must be sold under $p$ at price $\frac{(1-\alpha_Q)v_{j_Q}}{2}-\varepsilon'$, for any buyers' arriving order $\sigma$. Otherwise, all edges in $E''_Q$ must also be unsold and buyer $j_Q$ should have purchased her path $Q$, contradiction. Thus the contributed welfare from edges in $E_Q$ is at least $\frac{(1-\alpha_Q)v_{j_Q}}{2}-\varepsilon'$.
\paragraph{Construction of $p_2$.} For each $e\in E'_Q\cup E''_Q$, let $p_2(e)$ be the price of edge $e$ by applying Theorem~\ref{thm:path_no_tie} to $G'_Q\cup G''_Q$, which is a union of at most two path graphs. For $e=e_{Q,1}$ or $e_{Q,2}$, set $p_2(e)=+\infty$.
Then by Theorem~\ref{thm:path_no_tie},
if $p(e)=p_2(e),\forall e\in E_Q$,
the contributed welfare from edges in $E_Q$ is at least $\frac{2}{3}\mathsf{OPT}(G'_Q\cup G''_Q,\mathcal{F}|_{G'_Q\cup G''_Q})= \frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F}|_{G'_Q})+\frac{2}{3}\mathsf{OPT}(G''_Q,\mathcal{F}|_{G''_Q})=\frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F}|_{E'_Q})+\frac{2}{3}\alpha_Qv_{j_Q}$, for any buyers' arriving order $\sigma$.
Now for any $Q\in \mathcal{Q}_1$, we choose the price with a higher contributed welfare: If $\frac{(1-\alpha_Q)v_{j_Q}}{2}-\varepsilon'>\frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F})+\frac{2}{3}\alpha_Qv_{j_Q}$, we choose $p(e)=p_1(e),\forall e\in E_Q$ and choose $p(e)=p_2(e)$ otherwise. Thus the worst-case welfare of item pricing $p$ is at least
\begin{eqnarray*}
& &\sum_{Q\in \mathcal{Q}_1}\max\left(\frac{(1-\alpha)v_{j_Q}}{2}-\varepsilon',\frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F}|_{E'_Q})+\frac{2}{3}\alpha_Qv_{j_Q}\right)\\
&\geq&\sum_{Q\in \mathcal{Q}_1}\frac{4}{7}\left(\frac{(1-\alpha)v_{j_Q}}{2}-\varepsilon'\right)+\frac{3}{7}\left(\frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F}|_{E'_Q})+\frac{2}{3}\alpha_Qv_{j_Q}\right)\\
&=&\sum_{Q\in \mathcal{Q}_1}\left(\frac{2}{7}v_{j_Q}+\frac{2}{7}\mathsf{OPT}(G'_Q,\mathcal{F}|_{E'_Q})-\frac{4}{7}\varepsilon'\right)\\
&=&\sum_{Q\in \mathcal{Q}_1}\left(\frac{2}{7}\mathsf{OPT}(G_Q,\mathcal{F}|_{E_Q})-\frac{4}{7}\varepsilon'\right)>\frac{2}{7}\mathsf{OPT}(G,\mathcal{F})-\frac{4m}{7}\varepsilon'.
\end{eqnarray*}
Choosing $\varepsilon'=\frac{\varepsilon\cdot \mathsf{OPT}(G,\mathcal{F})}{10m}$ finishes the proof. By~\cite{tarjan1985decomposition}, the optimal allocation for any instance on trees can be computed efficiently. Thus the price vector $p$ can also be computed efficiently according to the construction above.
\end{proof}
For trees, we prove that the competitive ratio is at most 7. Theorem~\ref{thm:tree-no-tiebreak} follows directly from Lemma~\ref{lem:treetospider} and Theorem~\ref{thm:spider-no-tiebreak}.
\begin{theorem}\label{thm:tree-no-tiebreak}
For any $\varepsilon>0$, $\textnormal{\textsf{gap}}_{\textnormal{\textsf{NT}}}(\mathsf{Tree})\leq 7+\varepsilon$. Moreover, the prices that achieve the competitive ratio $7+\varepsilon$ can be computed efficiently.
\end{theorem}
For cycles, it is easy to prove that $\textnormal{\textsf{gap}}_{\textnormal{\textsf{NT}}}(\mathsf{Cycle})\leq 3$, if we apply Theorem~\ref{thm:path_no_tie} instead of Theorem~\ref{thm:path} in the proof of Theorem~\ref{thm:cycle}.
In fact, we show in the following theorem that $\textnormal{\textsf{gap}}_{\textnormal{\textsf{NT}}}(\mathsf{Cycle})\leq 2$, with a more careful analysis. Thus by Theorem~\ref{thm: cycle_lower_bound}, the competitive ratio 2 is also tight for the no tie-breaking case.
\begin{theorem}
\label{thm:cycle_without_tie}
$\textnormal{\textsf{gap}}_{\textnormal{\textsf{NT}}}(\mathsf{Cycle})\leq 2$. Moreover, the prices that achieve the competitive ratio $2$ can be computed efficiently.
\end{theorem}
\begin{proof}
Let $\mathcal{Q}^*$ be the subset of $\set{Q_1,\ldots,Q_n}$ that, over all subsets of edge-disjoint paths in $\set{Q_1,\ldots,Q_n}$ that maximizes its total value, maximizes its cardinality. For every $Q\in \mathcal{Q}^*$, let $v(Q)$ be the value of the buyer who receives demand path $Q$ in the optimal allocation $\mathcal{Q}^*$. So $\mathsf{OPT}(G,\mathcal{F})=\sum_{Q\in \mathcal{Q}^*}v(Q)$.
We distinguish between the following cases.
\textbf{Case 1. $\bigcup_{Q\in \mathcal{Q}^*}Q \ne G$.} Let $e'$ be an edge of $G$ that does not belong to any path of $\mathcal{Q}^*$. We first set the price of $e'$ to be $p(e')=+\infty$. Since $G\setminus e$ is a path, from Theorem~\ref{thm:path_no_tie}, there exist prices $\set{p(e)}_{e\in G\setminus e'}$ that achieves the worst-case welfare $\frac{2}{3}\cdot\sum_{Q\in \mathcal{Q}^*}v(Q)=\frac{2}{3}\cdot \mathsf{OPT}(G,\mathcal{F})$.
\textbf{Case 2. $\bigcup_{Q\in \mathcal{Q}^*}Q = G$ and $|\mathcal{Q}^*|\ge 4$.} Let $Q'\in \mathcal{Q}^*$ be the path of $\mathcal{Q}^*$ with minimum value.
Since $|\mathcal{Q}^*|\ge 4$, $\sum_{Q\in \mathcal{Q}^*}v(Q)\ge \frac 3 4 \cdot\mathsf{OPT}(G,\mathcal{F})$. We first set the prices for all edges of $Q'$ to be $+\infty$. We then consider the graph $G\setminus Q'$. From the similar analysis as in Case 1, we get that there exist prices $\set{p(e)}_{e\in G\setminus Q'}$ that achieves the worst-case welfare $\frac{2}{3}\cdot\sum_{Q\in \mathcal{Q}\setminus\set{Q'}}v(Q)=\frac{2}{3}\cdot\frac 3 4\cdot \mathsf{OPT}(G,\mathcal{F})=\mathsf{OPT}(G,\mathcal{F})/2$.
\textbf{Case 3. $\bigcup_{Q\in \mathcal{Q}^*}Q = G$ and $|\mathcal{Q}^*|=2$.} Let $Q$ be the path in $\mathcal{Q}^*$ with largest value, so $v(Q)\ge \mathsf{OPT}(G,\mathcal{F})/2$. We first set the prices for all edges of $G\setminus Q$ to be $+\infty$. From the choice of $\mathcal{Q}^*$, there does not exist a set of edge-disjoint demand paths, whose union is exactly $Q$ and total value equals $v(Q)$. From \Cref{claim:covering_implies_optimal}, there exist prices $\set{p(e)}_{e\in Q}$ that achieves the worst-case welfare $v(Q)\ge \mathsf{OPT}(G,\mathcal{F})/2$.
\textbf{Case 4. $\bigcup_{Q\in \mathcal{Q}^*}Q = G$ and $|\mathcal{Q}^*|=3$.} Denote $\mathcal{Q}^*=\set{Q_1,Q_2,Q_3}$, where the endpoints for paths $Q_1$ ($Q_2$ and $Q_3$, resp.) are $a,b$ ($b,c$ and $c,a$, resp.).
If some path of $\mathcal{Q}^*$ has value less than $\mathsf{OPT}(G,\mathcal{F})/4$, then we set the prices for all edges of this path to be $+\infty$, and then from the similar analysis in Case 2, there exist prices $\set{p(e)}_{e\in G\setminus Q'}$ that achieves the worst-case welfare at least $\mathsf{OPT}(G,\mathcal{F})/2$.
Now assume that $v(Q_1),v(Q_2),v(Q_3)\ge \mathsf{OPT}(G,\mathcal{F})/4$.
Let $Q'_1=Q_2\cup Q_3$. If there does not exist a set of two edge-disjoint demand paths, whose union is exactly $Q'_1$ and total value equals $v(Q'_1)$, then we set the prices for all edges of $Q_1$ to be $+\infty$, and then from the similar analysis in Case 3, there exist prices $\set{p(e)}_{e\in G\setminus Q'}$ that achieves the worst-case welfare $v(Q_2)+v(Q_3)\ge \mathsf{OPT}(G,\mathcal{F})/2$.
Therefore, there exist demand paths $P_1,P'_1$ with $P_1\cup P'_1=Q_2\cup Q_3$ and $v(P_1)+v(P'_1)=v(Q_2)+v(Q_3)$.
Similarly, there exist demand paths $P_2,P'_2$ with $P_2\cup P'_2=Q_3\cup Q_1$ and $v(P_2)+v(P'_2)=v(Q_3)+v(Q_1)$; and there exist demand paths $P_3,P'_3$ with $P_3\cup P'_3=Q_1\cup Q_2$ and $v(P_3)+v(P'_3)=v(Q_1)+v(Q_2)$.
Now consider the path $P_1,P'_1,P_2,P'_2,P_3,P'_3$.
For similar reasons, the value of each of these paths is at least $\mathsf{OPT}(G,\mathcal{F})/4$.
From the above discussion, the union of them contains each edge of $G$ exactly twice. Therefore, either $P_1\cup P'_1\cup P_2$ or $P'_2\cup P_3\cup P'_3$ is a path of $G$ with total value at least $\frac{3}{4}\cdot\mathsf{OPT}(G,\mathcal{F})$. From similar analysis in Case 2, there exist prices $\set{p(e)}_{e\in G\setminus Q'}$ that achieves the worst-case welfare $\frac{2}{3}\cdot\frac 3 4\cdot \mathsf{OPT}(G,\mathcal{F})=\mathsf{OPT}(G,\mathcal{F})/2$.
\end{proof}
At the last of this section, we consider outerplanar graphs. We show that the competitive ratio for any instance in the outerplanar graph is also $O(\log^2 m)$, in the no tie-breaking case. The proof of Theorem~\ref{thm:outerplanar_without_tie} is the same as Theorem~\ref{thm:outerplanar_lower}, with the only difference of applying Theorem~\ref{thm:spider-no-tiebreak} instead of Theorem~\ref{thm:spiderimproved} for spider graphs. The proof is omitted.
\begin{theorem}
\label{thm:outerplanar_without_tie}
$\textnormal{\textsf{gap}}_{\textnormal{\textsf{NT}}}(\mathsf{Outerplanar})=O(\log^2 m)$.
\end{theorem}
\subsection{Outerplanar Graphs}\label{sec:outerplanar}
At the end of this section, we consider outerplanar graphs. A graph $G$ is \emph{outerplanar} if and only if it admits a planar drawing, in which all vertices of $G$ lie on the boundary of the outer face. It's a natural generalization of trees and cycles.
The main result in this subsection is the following theorem.
\iffalse
\begin{definition}
For any graph $G$ and $r>1$, we say graph $G$ has competitive ratio $r$ if for any buyer profile, there exists a pricing that achieves revenue at least $\mathsf{OPT}/r$. Denote $\textnormal{\textsf{gap}}(G)$ the infimum of $r$ such that $G$ has competitive ratio $r$.
\end{definition}
\fi
\begin{theorem}\label{thm:outerplanar}
$\emph{\textnormal{\textsf{gap}}}({\emph{\textsf{Outerplanar}}})=O(\log^2 m)$.
\end{theorem}
To prove Theorem~\ref{thm:outerplanar}, we use the following lemma. It takes any cut $(S,T)$ of $G$, and bounds the competitive ratio for graph $G$ by the size of the cut and the competitive ratio for the subgraphs induced by $S$ and $T$.
\begin{lemma}\label{lem:approx-by-cut}
Let $G$ be a graph and $(S,T)$ be a cut of $G$, then $\emph{\textnormal{\textsf{gap}}}(G)\le \max\{\emph{\textnormal{\textsf{gap}}}(G[S]),\emph{\textnormal{\textsf{gap}}}(G[T])\}+|E(S,T)|$, where $G[S]$ \emph($G[T]$, resp.\emph) is the subgraph of $G$ induced by vertices of $S$ \emph($T$, resp.\emph).
\end{lemma}
\begin{proof}
Let $\mathcal{F}=\set{(Q_j,v_j)\mid j\in [n]}$ be any instance on graph $G$.
Let $\mathcal{Q}^*$ be the subset of $\set{Q_1,\ldots,Q_n}$ that, over all subsets of edge-disjoint paths in $\set{Q_1,\ldots,Q_n}$, maximizes its total value, namely $\mathsf{OPT}(G,\mathcal{F})=\sum_{Q_j\in \mathcal{Q}^*}v_j$.
We denote by $\mathcal{Q}'$ the set of paths in $\mathcal{Q}^*$ that contains an edge of $E(S,T)$, and we denote $\mathcal{Q}''=\mathcal{Q}^*\setminus \mathcal{Q}'$.
Since paths in $\mathcal{Q}^*$ are edge-disjoint, $|\mathcal{Q}'|\leq|E(S,T)|$.
On one hand, let $Q_j$ be the path in $\mathcal{Q}'$ with the largest value $v_j$, so $v_j\ge v(\mathcal{Q}')/|E(S,T)|$. From~\Cref{thm:path} and by setting the price for all edges of $G\setminus Q_j$ to be $+\infty$, we can show that there exist prices that achieve worst-case welfare at least $v_j\ge v(\mathcal{Q}')/|E(S,T)|$, where $v(\mathcal{Q}')=\sum_{Q_j\in \mathcal{Q}'}v_j$.
Put in another way,
$$\frac{v(\mathcal{Q}')}{|E(S,T)|}\ge \frac{v(\mathcal{Q}^*)}{\textnormal{\textsf{gap}}(G)}.$$
On the other hand, note that every path of $\mathcal{Q}''$ lies entirely in either graph $G[S]$ or graph $G[T]$.
Denote by $\mathcal{Q}''_S$ ($\mathcal{Q}''_T$, resp.) the set of paths $\mathcal{Q}''$ that lie entirely in graph $G[S]$ ($G[T]$, resp.).
By setting the price of all edges of $E(S,T)$ to be $+\infty$, and from the definition of $\textnormal{\textsf{gap}}(G[S]),\textnormal{\textsf{gap}}(G[T])$, we get that $$\frac{v(\mathcal{Q}''_S)}{\textnormal{\textsf{gap}}(G[S])}+\frac{v(\mathcal{Q}''_T)}{\textnormal{\textsf{gap}}(G[T])}\geq \frac{v(\mathcal{Q}^*)}{\textnormal{\textsf{gap}}(G)}.$$
Since $v(\mathcal{Q}^*)=v(\mathcal{Q}')+v(\mathcal{Q}'')$, it is easy to derive from the above inequalities that ${\textnormal{\textsf{gap}}}(G)\le |E(S,T)|+\max\{{\textnormal{\textsf{gap}}}(G[S]),{\textnormal{\textsf{gap}}}(G[T])\}$.
\end{proof}
The high-level plan for the proof of \Cref{thm:outerplanar} is to perform a graph decomposition and then use induction. Intuitively, we would like to compute a cut $(S,T)$ of $G$, such that $|S|,|T|\le 0.9m$ and $|E(S,T)|\le O(\log m)$.
If $G$ contains such a cut, from \Cref{lem:approx-by-cut}, $\textnormal{\textsf{gap}}(G)\leq \max\{\textnormal{\textsf{gap}}(G[S]),\textnormal{\textsf{gap}}(G[T])\}+O(\log m)$. Since graphs $G[S],G[T]$ contain at most $0.9m$ vertices each, it is easy to get by induction that $\textnormal{\textsf{gap}}(G)=O(\log^2 m)$. If $G$ does not contain such a cut, then we will show that graph $G$ must have the a special structure. Formally, for any edge $e=(u,v)$, consider the two arcs on the circle with $u$ and $v$ as the endpoints. We say that $e$ is \emph{good}, iff both arcs contain at least $0.1m$ vertices of $G$. We prove that, if $G$ does not contain a cut mentioned above, then all good edges must share an common endpoint.
See Figure~\ref{fig:outerplanar3} for an illustration of this special structure.
Next we prove directly that $\textnormal{\textsf{gap}}(G)=O(\log^2 m)$ when $G$ have the above structure. In the proof we remove edges properly (by setting the item price to be $+\infty$) such that the new underlying graph become a spider graph, and also the new instance still has a high enough optimal welfare. Then by applying Theorem~\ref{thm:spiderimproved}, we obtain the desired set of prices.
Now we give the complete proof of the Theorem.
\begin{prevproof}{Theorem}{thm:outerplanar}
We will prove by induction that, for every outerplanar graph $G$ on $m$ vertices, $\textnormal{\textsf{gap}}(G)\le 200\log^2m$.
The base case where $m=2$ is trivial.
Assume that the claim is true for all outerplanar graphs on less than $m$ vertices. Consider now any outerplanar graph $G$ on $m$ vertices.
We say that a cut $(S,T)$ in $G$ is \emph{balanced} iff $|S|,|T|\leq 0.9m$. Assume first that $G$ contains a balanced cut $(S,T)$ of size at most $2\log m$. Note that graphs $G[S],G[T]$ contain at most $0.9m$ vertices each. From the induction hypothesis, $\textnormal{\textsf{gap}}(G[S]),\textnormal{\textsf{gap}}(G[T])\le 200\log^2(0.9m)$. Therefore, from~\Cref{lem:approx-by-cut},
$$\textnormal{\textsf{gap}}(G)\leq \max\{\textnormal{\textsf{gap}}(G[S]),\textnormal{\textsf{gap}}(G[T])\}+2\log m\leq 200\log^2(0.9m)+2\log m< 200\log^2m.$$
We assume from now on that graph $G$ does not contain a balanced cut of size at most $2\log m$.
We fix a planar drawing of $G$, where all vertices lie on the boundary of a disc $\mathcal{D}$, and all edges lie entirely inside $\mathcal{D}$.
Denote by $\Gamma$ the set of non-outer faces of the planar drawing. For each face $F\in \Gamma$, the boundary $\partial(F)$ of $F$ is defined to be the subgraph of $G$ consisting of all vertices and edges of $G$ whose images are incident to $F$.
Clearly, for any pair $F_1,F_2$ of faces in $\Gamma$, $\partial(F_1)$ and $\partial(F_2)$ share at most one edge.
Let $e$ be an edge of $G$ and let $F\in \Gamma$ be a face that $e$ is incident to. Note that the image of $e$, together with the boundary of $\mathcal{D}$, decomposes $\mathcal{D}$ into two smaller discs $\mathcal{D}^1_e,\mathcal{D}^2_e$. Assume that face $F$ lies entirely in disc $\mathcal{D}^1_e$. We define the \emph{length of $e$ away from face $F$}, denoted by $\ell(e,F)$, as the number of vertices in whose image lie in disc $\mathcal{D}_2$ (including the endpoints of $e$) minus one. See Figure~\ref{fig:outerplanar1} for an example.
\begin{figure}[H]
\centering
\subfigure[An illustration of the length of $e$ away from $F$: $\ell(e,F)=5$.]{\scalebox{0.3}{\includegraphics{outerplanar1.jpg}}\label{fig:outerplanar1}}
\hspace{10pt}
\subfigure[The curve connecting the interior of $F$ to the boundary of $\mathcal{D}$.]{\scalebox{0.115}{\includegraphics{outerplanar2.jpg}} \label{fig:outerplanar2}}
\hspace{10pt}
\subfigure[An illustration of the layout of all good edges.]{\scalebox{0.45}{\includegraphics{outerplanar3.jpg}} \label{fig:outerplanar3}}
\caption{Illustrations of notions and objects in the proof of \Cref{thm:outerplanar}.}\label{fig: inner_path}
\end{figure}
We prove the following lemmas.
\begin{lemma}\label{route-with-log-intersect}
Let $F$ be a face in $\Gamma$ and let $e$ be an edge of $\partial(F)$. Let $\mathcal{D}^1_e,\mathcal{D}^2_e$ be smaller discs formed by the image of $e$ and the boundary of $\mathcal{D}$, where face $F$ lies entirely in disc $\mathcal{D}^1_e$. Then there is a curve, with one endpoint lying in the interior of $F$ and the other endpoint lying on the boundary of $\mathcal{D}^2_e$, that intersects the image of at most $\log(\ell(e,F))$ edges of $G$. (See the red curve in Figure~\ref{fig:outerplanar2} for an example.)
\end{lemma}
\begin{proof}
We prove by induction on the value of $\ell(e,F)$. The base case where $\ell(e,F)=2$ is trivial. Assume the claim is true for all graphs $G$ and all such pairs $(e,F)$ satisfying that $\ell(e,F)<k$. Consider now a pair $(e,F)$ in $G$ such that $\ell(e,F)=k$.
We incrementally construct the desired curve, as follows.
Let $x_0$ be an arbitrary point in the interior of $F$.
Note that edge $e$ is incident to two faces $F,F_1$. Let $x_1$ be an arbitrary point in the interior of $F_1$, and let $\gamma_1$ be a curve connecting $x_0$ to $x_1$, while intersecting with only the image of $e$.
Let $e_1,\ldots,e_r$ be all other edges incident to $F_1$. Clearly, $\sum_{1\le i\le r}\ell(e,F_1)\le \ell(e,F)$.
If $r=1$, then $F_1$ is the outer face, and there is a curve $\gamma_2$ connecting $x_1$ to the boundary of $\mathcal{D}^2_e$ that is disjoint from the drawing of $G$.
If $r>1$, then we may assume without loss of generality that $\ell(e_1,F_1)\leq \ell(e,F)/2$. From the induction hypothesis, there is a curve $\gamma_2$ connecting $x_1$ to a point on the boundary of $\mathcal{D}^2_e$, that intersects the image of at most $\log(\ell(e_1,F_1))$ edges of $G$. Let $\gamma$ be the concatenation of curves $\gamma_1,\gamma_2$. It is easy to verify that $\gamma$ connects a point in the interior of $F$ to a point on the boundary of $\mathcal{D}^2_e$, intersecting the image of at most $\log(\ell(e_1,F_1))+1\le \log(\ell(e,F))$ edges of $G$.
\end{proof}
We use Lemma~\ref{route-with-log-intersect} to derive two sufficient conditions for the existence of a balanced cut.
\begin{lemma}\label{lem:exist-balance-cut}
Let $F$ be a face and let $E(F)=E(\partial(F))$ be its incident edges.
Then graph $G$ contains a balanced cut with size at most $2\log m$ if one of the following conditions hold:
(i) there are two edges $e_1,e_2\in E(F)$ that do not share any endpoint, and $\ell(e_1,F),\ell(e_2,F)\ge 0.1m$; (ii) there exist three edges $e_1,e_2,e_3\in E(F)$, such that $\ell(e_1,F),\ell(e_2,F),\ell(e_3,F)\ge 0.1m$.
\end{lemma}
\begin{proof}
We first prove (i). Denote $e_1=(u,u')$ and $e_2=(v,v')$, such that vertices $u,u',v',v$ appear on the boundary of $\mathcal{D}$ in this order.
Let $\Lambda$ ($\Lambda'$, resp) be the part of the boundary of disc $\mathcal{D}$ between vertices $u,v$ ($u',v'$, resp.).
Since $e_1,e_2$ are both incident to $F$, consider the edge $e=(u,v)$, and it is easy to see that either $e\in E(G)$, or we can add $e$ to $G$ so that graph $G\cup\set{e}$ is still an outerplanar graph, whose corresponding drawing can be obtained from the drawing of $G$ by adding a curve connecting $u$ to $v$ in face $F$.
In either case, we can apply \Cref{route-with-log-intersect} to compute a curve $\gamma$ connecting a point $x$ in the interior of $F$ to a point on $\Lambda$, intersecting the image of at most $\log m$ edges of $G$.
Similarly, we can compute a curve $\gamma'$ connecting $x$ to a point on $\Lambda'$, intersecting the image of at most $\log m$ edges of $G$.
Let $E'$ be the set of edges whose images are intersected by either $\gamma$ or $\gamma'$, then it is easy to verify that $E'$ is a balanced cut of $G$ with size at most $2\log m$.
We now prove (ii). Denote $e_1=(u_1,v_1)$, $e_2=(u_2,v_2)$ and $e_3=(u_3,v_3)$.
Let $x$ be a point in the interior of $F$, and denote by $\Gamma_i$ the part of the boundary of disc $\mathcal{D}$ between vertices $u_i,v_i$, for each $i\in \set{1,2,3}$.
From \Cref{route-with-log-intersect}, for each $i\in \set{1,2,3}$, we can compute a curve $\gamma_i$ connecting $x$ to a point $w_i$ on curve $\Gamma_i$, and we denote by $E'_i$ the set of edges in $G$ whose images are intersected by curve $\gamma_i$.
From \Cref{route-with-log-intersect}, $|E'_1|,|E'_2|,|E'_3|\leq\log m$.
Since $\ell(e_1,F),\ell(e_2,F),\ell(e_3,F)\ge 0.1m$, it is easy to see that at least one of $E'_1\cup E'_2, E'_2\cup E'_3,E'_3\cup E'_1$ is a balanced cut of $G$ with size at most $2\log m$.
\end{proof}
Back to the proof of Theorem~\ref{thm:outerplanar}. Now we will apply Lemma~\ref{lem:exist-balance-cut} to show that, if $G$ does not contain a balanced cut of size at most $2\log m$, then $G$ must have the following special structure. For an edge $e$, let $F_e,F'_e$ be the two faces that $e$ is incident to. We say that $e$ is \emph{good}, iff $\ell(e,F_e)\ge 0.1m$ and $\ell(e,F_e')\ge 0.1m$.
We now show that, if $G$ does not contain a balanced cut of size at most $2\log m$, then all good edges share an common endpoint.
Assume the contrast that not all good edges share an common endpoint.
If we only focus on the subgraph induced by all good edges (and its natural drawing induced by the drawing of $G$), then either (i) there exists a face $F$ and two boundary edges $e_1,e_2$ of $F$, such that $e_1,e_2$ do not share endpoints, or (ii) there exists two faces $F_1,F_2$ and three edges $e_1,e_2,e_3$, such that $e_1,e_2$ are boundary edges of $F_1$, $e_2,e_3$ are boundary edges of $F_2$, and $e_1,e_3$ do not share edge. In either case, it is not hard to see from \Cref{lem:exist-balance-cut} that we can compute a balanced cut with size at most $2\log m$.
We denote by $u$ the common vertices of all good edges, denote by $v_1,\ldots,v_r$ the other endpoints of the good edges, and denote by $\Lambda_0,\ldots,\Lambda_r$ the parts of the boundary of $\mathcal{D}$, where $\Lambda_i$ is the part between vertices $v_{i}$ and $v_{i+1}$ (here we view $u=v_0=v_{r+1}$), then each curve of $\Lambda_0,\ldots,\Lambda_r$ contains the image of at most $0.1m$ vertices (see \Cref{fig:outerplanar3}).
Now we prove that the competitive ratio of any graph $G$ with the above structure is $O(\log^2 m)$.
Let $\mathcal{Q}^*$ be the subset of $\set{Q_1,\ldots,Q_n}$ that, over all subsets of edge-disjoint paths in $\set{Q_1,\ldots,Q_n}$, maximizes its total value.
Let $\mathcal{Q}_1=\{Q\in \mathcal{Q}^*\mid E(Q)\cap \delta_G(u)=\emptyset\}$ be all demand paths which do not visit $u$. Here $\delta_G(u)$ is the set of edges in $G$ incident to $u$. Let $\mathcal{Q}_2=\mathcal{Q}^*\setminus \mathcal{Q}_1$. We distinguish between the following cases.
\paragraph{Case 1. $v(\mathcal{Q}_1)\ge v(\mathcal{Q}^*)(1-1/(16\log m))$.}
In this case we first set the price for all edges of $\delta_G(u)$ to be $+\infty$. Equivalently, we delete edges of $\delta_G(u)$ from the graph. Let $G'$ be the remaining graph. It is easy to see that the $E(G')$ can be partitioned into subsets $E_0,\ldots,E_r$, where set $E_i$ contains all edges whose both endpoints lie in curve $\Lambda_i$.
From similar arguments in the proof of \Cref{route-with-log-intersect}, it is easy to compute a cut $(S,T)$ of $G'$ such that $|E(S,T)|\le \log (0.1 m)$ and $|S|, |T|\le 0.6m$.
From \Cref{lem:approx-by-cut}, we get that
$\textnormal{\textsf{gap}}(G')\le \max\set{\textnormal{\textsf{gap}}(G'[S]),\textnormal{\textsf{gap}}(G'[T])}+\log (0.1m)\le 200\log^2(0.6m)+\log (0.1m)$.
Altogether,
$$\textnormal{\textsf{gap}}(G)\le \bigg(1-\frac{1}{16\log m}\bigg)^{-1}\textnormal{\textsf{gap}}(G')\le \bigg(1+\frac{1}{15\log m}\bigg)\bigg(\log (0.1m)+200\log^2(0.6m)\bigg)\le 200\log^2m.$$
\paragraph{Case 2. $v(\mathcal{Q}_2)\ge v(\mathcal{Q}^*)/(16\log m)$.}
In this case we first set the price for all edges of $E(G)\setminus E(\mathcal{Q}_2)$ to be $+\infty$. Equivalently, we only consider the graph $G''$ obtained by taking the union of all paths in $\mathcal{Q}_2$.
For every $Q\in \mathcal{Q}_2$, let $I_Q\subseteq \{v_1,\ldots,v_{r+1}\}$ be the set of $v_j$s such that either (i) $Q\cap (E_{j-1}\cup E_j)\not=\emptyset$; or (ii) One endpoint of $Q$ is $v_j$. Since each path $Q\in \mathcal{Q}_2$ contains at least an edge of $\delta_G(u)=\set{(v_t,u)\mid 1\le t\le r}$, $I_Q$ must induce either one or two consecutive subsequences of $\{0,\ldots,r\}$: Before and after visiting $u$, the path $Q$ must both visit $v_j$s that form a consecutive sequence.
We notice that for every $0\le t\le r$, $E_t$ contains at most $\log(0.1m)$ edge-disjoint paths. Otherwise, there is a curve from the interior of $\mathcal{D}$ to curve $\Lambda_t$, that intersects the image of at least $\log(0.1m)+1$ edges of $E_t$. It contradicts with Lemma~\ref{route-with-log-intersect}. Note that the paths in $\mathcal{Q}_2$ are edge-disjoint. Then for every $t\in \{1,\ldots,r+1\}$, $v_t$ is contained in at most $2\log(0.1m)+1\leq 2\log m$ $I_Q$ sets for $Q\in \mathcal{Q}_2$: At most $\log(0.1m)$ paths coming from $v_{t-1}$, at most $\log(0.1m)$ paths coming from $v_{t+1}$, and 1 path that contains the edge $(u,v_t)$.
\begin{lemma}\label{lem:color-k-interval}(Theorem 1 of \cite{gyarfas1985chromatic})
Fix any integer $k\geq 1$. Let graph $G$ be a single line. For any $j=1,\ldots,n$, let $A_j$ be a set of edges that forms a union of $k$ closed intervals in $G$. Suppose that every edge in $G$ appears in at most $r$ sets of $A_j$, for some $r\geq 2$, then set $\{A_j\}_{j=1}^n$ can be $2k(r-1)$-colored, such that all sets with any single color are node-disjoint.
\end{lemma}
From Lemma~\ref{lem:color-k-interval} and the definition of $I_Q$, the paths in $\mathcal{Q}_2$ can be $(8\log m)$-colored, such that paths with the same color are node-disjoint, except for their common vertex $u$.
Therefore, there exists a set $\mathcal{Q}'_2\subseteq\mathcal{Q}_2$ of paths that are node-disjoint except at $u$, and $v(\mathcal{Q}'_2)\ge v(\mathcal{Q}'_2)/(8\log m)$. Note that the graph formed by the union of all paths in $\mathcal{Q}'_2$ is a spider graph. Therefore, from Theorem~\ref{thm:spiderimproved},
$$\textnormal{\textsf{gap}}(G)\le (16\log m)\cdot \textnormal{\textsf{gap}}(G'')\le (16\log m)\cdot(8\log m)\cdot (3/2)\le 200\log^2m.$$
This completes the proof of \Cref{thm:outerplanar}.
\end{prevproof}
\subsection{Paths}\label{sec:path}
In this section we consider the case where $G$ is a path.
Let $E(G)=\set{e_1,\ldots,e_n}$, where the edges are indexed according to the order in which they appear on the path.
The following theorem was proved in \cite{chawla2017stability}.
For completeness, we provide its proof in \Cref{apd: Proof of thm:path}.
\begin{theorem}
[Corollary of Lemma 2.1 in \cite{chawla2017stability}]
\label{thm:path}
There is an efficient algorithm, that, given any path graph $G$ and any buyer-profile $\mathcal{F}=\set{(Q_j,v_j)}_{j\in [m]}$, computes a set of prices on edges of $G$ that achieves worst-case welfare $\mathsf{OPT}(G,\mathcal{F})$, with the power of tie-breaking. Moreover, (LP-Primal) has an integral optimal solution.
\end{theorem}
\notshow{
\begin{proof}
Consider the following linear program.
\begin{eqnarray*}
\mbox{(P)} &\text{maximize }
\sum_{j\in [m]}v_j\cdot y_j\\
\mbox{s.t.}
&\sum_{j: e_i\in Q_j}y_j\leq 1&\forall\text{ }1\le i\le L\\
& y_j\ge 0&\forall\text{ } j\in [m]
\end{eqnarray*}
\begin{claim}\label{thm:lp-primal}
(P) has an integral optimal solution.
\end{claim}
\begin{proof}
The inequalities $\sum_{j: e_i\in Q_j}y_j\leq 1$ are equivalent to $A\textbf{y}\leq \textbf{1}$, where matrix $A=(A_{ij})_{i,j}$ satisfies $A_{ij}={\mathds{1}}[x_i\in Q_j], \forall i\in [L],j\in [m]$. Note that $A$ is a 0-1 matrix, where 1s appear consecutively in every row. Thus $A$ is totally \todo{Todo} unimodular. Every vertex in the feasible polytope is an integral solution. Thus (LP-Primal) has an integral optimal solution.
\end{proof}
The dual of (LP-Primal) is as follows:
\begin{eqnarray*}
\mbox{(LP-Dual)} &\text{minimize }
\sum_{1\le i\le L}p_i\\
\mbox{s.t.}
&\sum_{i: e_i\in Q_j}p_i\geq v_j&\forall\text{ } j\in [m]\\
& p_i\ge 0&\forall\text{ } 1\le i\le L
\end{eqnarray*}
Let $y^*$ be any optimal integral solution for (LP-Primal), and
let $p^*=\{p_i^*\}_{i\in [L]}$ be any optimal solution for (LP-Dual). Then by strong duality, $\sum_{j}v_jy^*_j=\sum_{i}p^*_i=\mathsf{OPT}$.
Moreover, from the complementary slackness, for each $j\in [m]$ such that $\sum_{i: e_i\in Q_j}p^*_i>v_j$, we have $y^*_j=0$.
Now consider the set of prices $p^*$. We show that, no matter in what order come the buyers, the final allocation is guaranteed to be $y^*$ with a proper tie-breaking policy. Thus the selling process always obtains welfare $\mathsf{OPT}$.
For every buyer $j$, consider the following two cases.
The first case is when $y^*_j=0$, from the constraint of (LP-Dual), $\sum_{i: e_i\in Q_j}p^*_i\geq v_j$. Since the seller has the power of tie-breaking, it can be guaranteed that buyer $j$ does not get any edge when she comes to the auction: Either she is not willing to buy the edge, or she is indifferent buying or not, but the seller chooses not to sell to her.
The second case is when $y^*_j=1$, from the above discussion, we must have $\sum_{i: e_i\in Q_j}p^*_i=v^*_j$. Now the seller chooses to sell the edges in $Q_j$ to buyer $j$.
It is immediate to verify that the above tie-breaking policy guarantees that the final allocation of this selling process is $y^*$, no matter in what order come the buyers. And the welfare of this selling process is $\mathsf{OPT}$. The set of prices $p^*$ can be computed in polynomial time by solving the dual LP.
\end{proof}
}
The main result in this section is the following theorem.
\begin{theorem}
\label{thm:path_no_tie}
There is an efficient algorithm, that, given any path graph $G$ and any buyer-profile $\mathcal{F}=\set{(Q_j,v_j)}_{j\in [m]}$, computes a set of prices on edges of $G$ that achieves worst-case welfare at least $(2/3)\cdot \mathsf{OPT}(G,\mathcal{F})$, without the power of tie-breaking.
\end{theorem}
\begin{proof}
From \Cref{thm:path}, (LP-Primal) has an integral optimal solution. We denote by $y^*$ the integral optimal solution of (LP-Primal) that maximizes $\sum_{j\in [m]}y^*_j$. Note that $y^*$ can be computed by solving a slightly different LP that is obtained from (LP-Primal) by changing its objective to $\sum_{j\in [m]}(v_j+\varepsilon')\cdot y_j$, for some small enough $\varepsilon'>0$.
Define $Y=\set{j\mid y^*_j=1}$ and
$\mathcal{Q}_Y=\set{Q_j\mid y^*_j=1}$.
Define $\varepsilon=\frac{1}{n^2}\cdot\min\set{v_j\mid j\in [m]}$.
We prove the following claim.
\begin{claim}
There is an optimal solution $p^*=(p^*(e))_{e\in E(G)}$ for (LP-Dual), such that
(i) for each edge $e\in E(\mathcal{Q}_Y)$, $p^*(e)\geq \varepsilon$; and (ii)
for each $j\in [m]$, $p^*(Q_j)\geq v_j$.
\end{claim}
\begin{proof}
We construct another buyer-profile $\mathcal{F}'$ from $\mathcal{F}$ as follows. We add, for each $e\in E(G)$ a new buyer demanding the path consisting of a single edge $e$ with value $\varepsilon$.
On one hand, it is easy to see that $y^*$ is still an optimal solution of this new instance. Let $p^*$ be any optimal solution for the correponding dual LP for the new instance. Clearly $p^*$ is also an optimal solution of (LP-Dual) and satisfies both properties.
\end{proof}
We define $A=\set{j\mid v_j=p^*(Q_j)}$ and $\mathcal{Q}_A=\set{Q_j\mid j\in A}$.
We say that a set $\mathcal{Q}\subseteq \mathcal{Q}_A$ of edge-disjoint paths is \emph{good}, iff set $\mathcal{Q}_A\setminus \mathcal{Q}$ does not contain another subset $\mathcal{Q}'$ of $|\mathcal{Q}'|\ge 2$ edge-disjoint paths, such that
$\bigcup_{Q_j\in \mathcal{Q}'}Q_j=\bigcup_{Q_j\in \mathcal{Q}}Q_j$.
We use the following lemma.
\begin{lemma}\label{claim:covering_implies_optimal}
There is an efficient algorithm, that, given a good set $\mathcal{Q}$ of edge-disjoint paths, computes a set of positive prices $p=\{p(e)\}_{e\in E(\mathcal{Q})}
that achieves worst-case welfare at least $\sum_{Q_j\in \mathcal{Q}}v_j$
\end{lemma}
\begin{proof}
We denote $I=\bigcup_{Q_j\in \mathcal{Q}}Q_j$ and $\mathcal{Q}_I=\{Q_j\in \mathcal{Q}_A\mid Q_j\subseteq I\}$.
First, for each edge $e\notin E(I)$, we set its price $p(e)=+\infty$.
Therefore, all buyers $j$ with $Q_j\notin \mathcal{Q}_I$ cannot get her demand path.
We will show that we can efficiently compute prices $\set{p(e)}_{e\in E(I)}$ for edges of $I$, such that (i) for each path $Q_j\in \mathcal{Q}$, $v_j>p(Q_j)$; and (ii) for each path $Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}$, $v_j<p(Q_j)$.
It is clear that the set $\set{p(e)}_{e\in E(G)}$ of prices achieves worst-case welfare $\sum_{Q_j\in \mathcal{Q}}v_j$.
The existence of prices $\set{p(e)}_{e\in E(I)}$ is equivalent to the feasibility of the following system.
\begin{equation}\label{lp:covering-primal}
\left\{
\begin{array}{cccc}
\displaystyle \sum_{e\in Q_j}p(e) &< & v_j,&\forall Q_j\in\mathcal{Q};\\
\displaystyle \sum_{e\in Q_j}p(e) & >& v_j,&\forall Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}.
\end{array}
\right.
\end{equation}
From the definition of $A$, and since $\mathcal{Q}_I\subseteq\mathcal{Q}_A$, for each path $Q_j\in \mathcal{Q}_I$, $\sum_{e\in Q_j}p^*(e)= v_j$.
We denote $\alpha(e)=p(e)-p^*(e)$ for all $e\in E(I)$, then system~\eqref{lp:covering-primal} is feasible if the following system is feasible, for some small enough $\varepsilon'>0$.
\begin{equation}\label{lp:covering-primal2}
\left\{
\begin{array}{cccc}
\displaystyle \sum_{e\in Q_j}\alpha(e) &\le & -\varepsilon',&\forall Q_j\in\mathcal{Q};\\
\displaystyle \sum_{e\in Q_j}\alpha(e) & \ge & \varepsilon',&\forall Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}.
\end{array}
\right.
\end{equation}
\iffalse
Then system~\eqref{lp:covering-primal2} is feasible if and only if the following system is feasible, for a small enough constant $\sigma>0$.
\begin{equation}\label{lp:covering-primal3}
\left\{
\begin{array}{cccc}
\displaystyle \sum_{e\in Q_j}\alpha(e) &\le & -\sigma,&\forall Q_j\in\mathcal{Q};\\
\displaystyle \sum_{e\in Q_j}-\alpha(e) & \leq & -\sigma,&\forall Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}.
\end{array}
\right.
\end{equation}
\fi
From Farkas' Lemma,
system~\eqref{lp:covering-primal2} is feasible if and only if the following system is infeasible.
\begin{equation}\label{lp:covering-dual}
\left\{
\begin{array}{rccc}
\displaystyle \sum_{Q_j\in \mathcal{Q}}\beta_j\cdot\mathbbm{1}[e\in Q_j]-\sum_{Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}}\beta_j\cdot\mathbbm{1}[e\in Q_j] &=& 0,&\forall e\in E(I);\\
\displaystyle\sum_{Q_j\in \mathcal{Q}_I}\beta_j&>& 0;\\
\beta_j & \in & [0,1],&\forall Q_j\in \mathcal{Q}_I.
\end{array}
\right.
\end{equation}
where the additional constraints $\beta_j\le 1, \forall Q_j\in \mathcal{Q}_I$ will not influence the feasibility of the system due to scaling.
By similar arguments in the proof of \Cref{lem:primal-tu}, we can show that the coefficient matrix in system \eqref{lp:covering-dual} is totally unimodular. Therefore, system \eqref{lp:covering-dual} is feasible iff it admits an integral solution.
\iffalse
\begin{lemma}\label{lem:covering-integral-solu}
System~\eqref{lp:covering-dual} is feasible if and only if it admits an integral solution.
\end{lemma}
\begin{proof}
We prove that the coefficient matrix $C$ in system \eqref{lp:covering-dual} is totally unimodular. Similar to the proof of Theorem~\ref{lem:primal-tu}, for any set of rows $R=\{i_1,i_2,\cdots,i_k\}$ such that $i_1<i_2<\cdots<i_k$, We define the partition $R_1=\{i_1,i_3,i_5,...\}$ be the set with odd index and $R_2=\{i_2,i_4,i_6,...\}$ be the set with even index. For every column $j$, $Q_j$ is an subpath and thus the ones (or -1s for $Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}$) in the vector $(C_{ij})_{i=1}^n$ are consecutive. Hence the difference between $\sum_{i\in R_1}C_{ij}$ and $\sum_{i\in R_2}C_{ij}$ is at most 1. By Lemma~\ref{lem:proposition-tu}, $C$ is totally unimodular.
\end{proof}
\fi
Assume for contradiction that \eqref{lp:covering-dual} is feasible, let $\beta^*\in \set{0,1}^{\mathcal{Q}_I}$ be an integral solution of \eqref{lp:covering-dual}.
Note that the constraints
$\sum_{Q_j\in \mathcal{Q}}\beta^*_j\cdot\mathbbm{1}[e\in Q_j]-\sum_{Q_j\in \mathcal{Q}_I\setminus \mathcal{Q}}\beta^*_j\cdot\mathbbm{1}[e\in Q_j] = 0,\forall e\in E(I)$ and the fact that paths of $\mathcal{Q}$ are edge-disjoint
imply that the paths in set $\mathcal{Q}'=\{Q_j\mid \beta_j=1\}$ are edge-disjoint. Note that $\mathcal{Q}'\cap\mathcal{Q}=\emptyset$ and $\bigcup_{Q_j\in \mathcal{Q}'}Q_j=\bigcup_{Q_j\in \mathcal{Q}}Q_j$, and this is a contradiction to the assumption that the set $\mathcal{Q}$ is good.
Therefore, system \eqref{lp:covering-dual} is infeasible, and system \eqref{lp:covering-primal2} is feasible.
Let $(\alpha(e))_{e\in E(I)}$ be a solution of system~\eqref{lp:covering-primal2}, such that $\sum_{e\in E(I)} |\alpha(e)|\le \varepsilon$. It is clear that such a solution exists due to scaling.
We set $p(e)=p^*(e)+\alpha(e)$ for all $e\in E(I)$, and it is clear that the set $\set{p(e)}_{e\in E(G)}$ of prices satisfies the property of \Cref{claim:covering_implies_optimal}.
Moreover, prices $\set{p(e)}_{e\in E(G)}$ are positive.
\end{proof}
We now complete the proof of Theorem~\ref{thm:path_no_tie} using \Cref{claim:covering_implies_optimal}.
We denote $\mathcal{Q}_Y=\set{Q_1,Q_2,\ldots,Q_k}$, where the paths are indexed according to the order in which they appear on $G$.
First, for each edge $e\notin E(\mathcal{Q}_Y)$, we set its price $\tilde p(e)=+\infty$.
Therefore, any buyer $j$ with $e\in Q_j$ cannot take her demand path.
In fact, we may assume without loss of generality that $\bigcup_{1\le j\le k}Q_j=G$, since otherwise we can view each connected component (which is also a path) of graph $\bigcup_{1\le j\le k}Q_j$ as the whole graph, and compute prices for its edges separately.
We will compute three sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3\subseteq \mathcal{Q}_A$ of edge-disjoint paths, such that
\begin{enumerate}
\item every edge of $E(G)$ is contained in exactly two paths of $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$; and
\item \label{prop: good_cover} for each $t\in \set{1,2,3}$, if we further partition the set $\hat\mathcal{Q}_t$ into subsets $\hat\mathcal{Q}^1_t,\ldots,\hat\mathcal{Q}^{r_t}_t$, such the union of the paths in each set $\hat\mathcal{Q}^1_t$ forms a connected component (which is also a path) of graph $\bigcup_{Q_j\in \hat\mathcal{Q}_t}Q_j$, then each of the sets $\hat\mathcal{Q}^1_t,\ldots,\hat\mathcal{Q}^{r_t}_t$ is a good set of edge-disjoint paths.
\end{enumerate}
By definition, $\sum_{Q_j\in \hat\mathcal{Q}_1}v_j+\sum_{Q_j\in \hat\mathcal{Q}_2}v_j+\sum_{Q_j\in \hat\mathcal{Q}_3}v_j=2\cdot\mathsf{OPT}(G,\mathcal{F})$.
Assume without loss of generality that $\sum_{Q_j\in \hat\mathcal{Q}_1}v_j\ge (2/3)\cdot\mathsf{OPT}(G,\mathcal{F})$.
Then from Lemma~\ref{claim:covering_implies_optimal}, there exist prices $\set{\tilde p(e)}_{e\in E(\mathcal{Q}_Y)}$ that achieves worst-case welfare at least $\sum_{Q_j\in \hat\mathcal{Q}_1}v_j\ge (2/3)\cdot\mathsf{OPT}(G,\mathcal{F})$.
\paragraph{Compute the sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$.}
We now compute the desired sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$ of edge-disjoint paths, which, from the above discussion, completes the proof of Theorem~\ref{thm:path_no_tie}.
We start by defining $\hat\mathcal{Q}$ to be the multi-set that contains, for each path $Q_j\in\mathcal{Q}_Y$, two copies $Q'_j,Q''_j$ of $Q_j$.
We initially set
\begin{itemize}
\item $\hat\mathcal{Q}_1=\set{Q'_{6r+3},Q'_{6r+4}\mid 1\le r\le k/6} \cup\set{Q''_{6r},Q''_{6r+1}\mid 1\le r\le k/6}$;
\item $\hat\mathcal{Q}_2=\set{Q'_{6r+1},Q'_{6r+2}\mid 1\le r\le k/6} \cup\set{Q''_{6r+4},Q''_{6r+5}\mid 1\le r\le k/6}$; and
\item $\hat\mathcal{Q}_3=\set{Q'_{6r+2},Q'_{6r+3}\mid 1\le r\le k/6} \cup\set{Q''_{6r+2},Q''_{6r+3}\mid 1\le r\le k/6}$.
\end{itemize}
See Figure~\ref{fig:path-1} for an illustration.
Clearly, sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$ partition $\hat\mathcal{Q}$, each contains edge-disjoint paths, and every edge appears twice in paths of $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$.
However, sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$ may not satisfy Property~\ref{prop: good_cover}.
We will then iteratively modify sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$, such that at the end Property~\ref{prop: good_cover} is satisfied.
Throughout, we also maintain graphs $G_t=\bigcup_{Q\in \hat{\mathcal{Q}}_t}Q$, for each $t\in \set{1,2,3}$. As sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$ change, graphs $G_1,G_2,G_3$ evolve.
We start by scanning the path $G$ from left to right, and process, for each each connected component of graphs $G_1,G_2,G_3$, as follows.
\iffalse
\begin{enumerate}
\item No two paths with same color share the same edge;
\item No three contiguous paths have the same color;
\item For each endpoint shared by at most three paths, all of the paths are colored differently;
\item For each endpoint shared by 4 paths, all three colors are used to color these paths, and two paths with the same color are
\begin{enumerate}
\item both from $\mathcal{Q}_Y$, or
\item both from $\mathcal{Q}'_Y:=\mathcal{Q}^*\setminus\mathcal{Q}_Y$, the second copy of the optimal solution.
\end{enumerate}
\end{enumerate}
Such coloring is guaranteed to exist. In fact, for every $Q_j\in \mathcal{Q}_Y$, let $g(Q_j)=j\text{ mod }6$. For every $Q_j'\in \mathcal{Q}_Y'$, let $g(Q_j')=(j+3)\text{ mod }6$. We color a path blue if its $g$-value is 0 or 1, red if its $g$-value is 2 or 3, and green if its $g$-value is 4 or 5. One can easily verify that the above coloring satisfies all the properties.
\fi
We first process the connected component in $G_1$ formed by the single path $Q_1''$. Clearly, set $\set{Q_1''}$ is good, since if there are other paths $\hat Q,\hat Q'\in \mathcal{Q}_A$ such that $\hat Q,\hat Q'$ are edge-disjoint and $\hat Q\cup \hat Q'=Q_1$, then the set $\set{\hat Q,\hat Q',Q_2,\ldots,Q_k}$ corresponds to another integral optimal solution $\hat y^*$ of (LP-Primal) with $\sum_{j\in [m]}\hat y^*_j=k+1>k=\sum_{j\in [m]}\hat y^*_j$, a contradiction to the definition of $y^*$. We do not modify path $Q''_1$ in $\hat{\mathcal{Q}}_1$ and continue to the next iteration.
We then process the connected component in $G_2$ formed by the paths $Q_1',Q_2'$. If the set $\set{Q_1',Q_2'}$ is good, then we do not modify this component and continue to the next iteration. Assume now that the set $\set{Q_1',Q_2'}$ is not good.
From similar arguments, there exist two other paths $Q^*_1,Q^*_2\in \mathcal{Q}_A$, such that $Q^*_1,Q^*_2$ are edge-disjoint and $Q^*_1\cup Q^*_2=Q_1\cup Q_2$.
We then replace the paths $Q'_1,Q'_2$ in $\hat{\mathcal{Q}}_2$ by paths $Q^*_1,Q^*_2$.
Let $v^*_1$ be the vertex shared by paths $Q^*_1,Q^*_2$, so $v^*_1\ne v_1$. We distinguish between the following cases.
\textbf{Case 1. $v^*_1$ is to the left of $v_1$ on path $G$.}
As shown in Figure~\ref{fig:path-2}, we keep the path $Q^*_2$ in $\hat{\mathcal{Q}}_2$, and move path $Q^*_1$ to $\hat{\mathcal{Q}}_3$.
Clearly, we create two new connected components: one in $G_3$ formed by a single path $Q^*_1$, and the other in $G_2$ formed by a single path $Q^*_2$.
From similar arguments, the corresponding singleton sets $\set{Q^*_1}, \set{Q^*_2}$ are good.
\textbf{Case 2. $v^*_1$ is to the right of $v_1$ on path $G$.}
As shown in Figure~\ref{fig:path-4}, we keep the path $Q^*_2$ in $\hat{\mathcal{Q}}_2$, move path $Q^*_1$ to $\hat{\mathcal{Q}}_1$ and additionally move the path $Q'_1$ processed in previous iteration to $\hat{\mathcal{Q}}_2$.
Clearly, we create two new connected components: one in $G_1$ formed by a single path $Q^*_1$, and the other in $G_2$ formed by a single path $Q^*_2$.
From similar arguments, the corresponding singleton sets $\set{Q^*_1}, \set{Q^*_2}$ are good.
Note that we have additionally moved $Q'_1$ to $\hat{\mathcal{Q}}_2$, but since we did not change the corresponding component, the singleton set $\set{Q'_1}$ is still good.
\begin{figure}[h]
\centering
\subfigure[An illustration of paths in set $\hat{\mathcal{Q}}_1\cup \hat{\mathcal{Q}}_2\cup \hat{\mathcal{Q}}_3$ at the beginning.]{\scalebox{0.4}{\includegraphics{interval_1.jpg}}\label{fig:path-1}}
\subfigure[An illustration of path modification in Case 1.]{\scalebox{0.4}{\includegraphics{interval_2.jpg}}\label{fig:path-2}}
\subfigure[An illustration of path modification in Case 2.]{\scalebox{0.4}{\includegraphics{interval_4.jpg}}\label{fig:path-4}}
\subfigure[How old and new paths/components may possibly interact.]{\scalebox{0.39}{\includegraphics{interval_3.jpg}}\label{fig:path-3}}
\caption{Illustrations of the algorithm for computing path sets $\hat{\mathcal{Q}}_1,\hat{\mathcal{Q}}_2,\hat{\mathcal{Q}}_3$.}
\end{figure}
We continue processing the remaining connected components in the same way until all components are good. We will show that, every time a connected component is not good and the corresponding two paths are replaced with two new paths, the connected components in $G_1,G_2,G_3$ that we have processed in previous iterations will stay good. Therefore, the algorithm will end up producing good components in $G_1,G_2,G_3$ consisting of a good set of one or two edge-disjoint paths.
To see why this is true, consider an iteration where we are processing a component consisting of paths $Q''_i, Q''_{i+1}$, and there exists edge-disjoint paths $Q^*_i,Q^*_{i+1}$ such that $Q^*_i\cup Q^*_{i+1}=Q''_i\cup Q''_{i+1}$, while the endpoint $v^*_i$ shared by $Q^*_i$ and $Q^*_{i+1}$ is an endpoint of a processed component, as shown in Figure~\ref{fig:path-3}.
Note that this is the only possibility that the new components may influence the previous components,
However, we will show that this is impossible.
Note that $Q''_{i}\in \mathcal{Q}_Y$.
We denote by $Q^r$ the path with endpoints $v^*_i$ and $v_i$, then clearly paths $Q^*_i, Q^r$ are not in $\mathcal{Q}_Y$, edge-disjoint and satisfy that $Q_{i}=Q^*_i\cup Q^r$.
Consider now the set $(\mathcal{Q}_Y\setminus \set{Q_{i}})\cup \set{Q^*_i, Q^r}$. It is clear that this set corresponds to another integral optimal solution $\hat y^*$ of (LP-Primal) with $\sum_{j\in [m]}\hat y^*_j=k+1>k=\sum_{j\in [m]}\hat y^*_j$, a contradiction to the definition of $y^*$.
\end{proof}
We complement \Cref{thm:path_no_tie} with the following theorem.
\begin{theorem}\label{thm:path_no_tie_hardness}
\label{thm: path_no_tie_lower_bound}
There exists a path graph $G$ and a buyer-profile $\mathcal{F}$, such that any set of prices on edges of $G$ can achieve worst-case revenue at most $(2/3)\cdot \mathsf{OPT}(G,\mathcal{F})$, without the power of tie-breaking.
\end{theorem}
\begin{proof}
Let $G$ be a path consisting of three edges $e_1,e_2,e_3$, that appears on the path in this order. The buyer-profile is described below.
\begin{itemize}
\item Buyer $B_1$ demands the path consisting of a single edge $e_1$, with value $1$;
\item Buyer $B_2$ demands the path consisting of a single edge $e_3$, with value $1$;
\item Buyer $B_3$ demands the path consisting of edges $e_1,e_2$, with value $2$; and
\item Buyer $B_4$ demands the path consisting of edges $e_2,e_3$, with value $2$.
\end{itemize}
\iffalse
\begin{table}[H]
\centering
\begin{tabular}{ c|c|c}
Buyer & Demand & Value \\
\hline
$B_1$ & $e_1$ & 1 \\
\hline
$B_2$ & $e_3$ & 1 \\
\hline
$B_3$ & $e_1,e_2$ & 2\\
\hline
$B_4$ & $e_2,e_3$ & 2
\end{tabular}
\label{table:example_path}
\caption{Example for Path Graph}
\end{table}
\fi
It is clear that the optimal allocation is assigining the $e_1$ to $B_1$ and $e_2,e_3$ to $B_4$ (or assigning $e_3$ to $B_2$ and $e_1,e_2$ to buyer $B_3$), and the optimal welfare is $\mathsf{OPT}(G,\mathcal{F})=3$.
We now show that, for any prices $p(e_1),p(e_2),p(e_3)$ on edges $e_1,e_2,e_3$, there is an order of the four buyers, such that, if the buyers come in this order and make decisions with the power of tie-breaking, the resulting welfare is at most $2$.
Note that this completes the proof of \Cref{thm: path_no_tie_lower_bound}.
We distinguish between different cases.
\textbf{Case 1. $p(e_1)\leq 1$ and $p(e_3)\leq 1$.} We let buyers $B_1$ and $B_2$ come first and take edges $e_1$ and $e_3$, respectively (note that the seller does not have the power of tie-breaking, so buyers can decide whether or not to take their path when the price equals their value). Now buyers $B_3, B_4$ cannot get their paths, so the resulting welfare is $2$.
\textbf{Case 2. $p(e_1)>1$ or $p(e_3)>1$.} Assume without loss of generality that $p(e_1)>1$. If $p(e_2)+p(e_3)\leq 2$, then we let buyer $B_4$ come first and take edges $e_2$ and $e_3$. It is clear that no other buyer can get her path, so the resulting welfare is 2. If $p(e_2)+p(e_3)>2$, so $p(e_1)+p(e_2)+p(e_3)>3$. Note that it is impossible in this case all edges are sold. Therefore, the resulting welfare is at most $2$.
\end{proof}
\section{Our Model}\label{sec:prelim}
In this section, we introduce our model in more detail.
A seller wants to sell a set $[m]$ of $m$ heterogeneous items to $n$ buyers. Each buyer $j$ is single-minded: She demands a set $Q_j\subseteq[m]$ with a positive value $v_j$. Her value for a subset $S\subseteq [m]$ of items is $v_j$ if $Q_j\subseteq S$, and $0$ otherwise. For every buyer $j$, the set $Q_j$ and the value $v_j$ are known to the seller. The seller aims to maximize the welfare, that is, the sum of all buyers' value who get their demand sets. As a special case of the above auction, in the \emph{tollbooth problem}, there is an underlying graph $G$. We denote $V(G)$ and $E(G)$ the vertex and edge set of $G$. Every item in the auction corresponds to an edge in $E(G)$. Let $E(G)=\{e_1,\ldots,e_m\}$. For simplicity, we use the index $i$ to represent the edge $e_i$ as well. For every agent $j$, her demand set $Q_j$ is a single path in graph $G$. For a set of paths $\mathcal{Q}$, denote $E(\mathcal{Q})=\bigcup_{Q\in \mathcal{Q}}E(Q)$. We say that paths in $\mathcal{Q}$ are \emph{edge-disjoint} (\emph{node-disjoint}, resp.) if all paths in $\mathcal{Q}$ do not share edges (vertices, resp.).
In the paper we focus on a special class of mechanisms called \emph{item pricing} mechanisms. In an item pricing mechanism, the seller first computes a posted price $p(e_i)$ (or $p_i$) for every edge $e_i$ in the graph.\footnote{In the paper we allow the posted price $p_i$ to be $\infty$. It means that the price for edge $i$ is sufficiently large, such that no buyer $j$ with $i\in Q_j$ can afford her demand path.} The buyers then arrive one-by-one in some order $\sigma$. When each buyer $j$ arrives, if any edge in her demand set $Q_j$ is unavailable (taken by previous buyers), then she gets anything and pays 0. Otherwise, she compares her value $v_j$ with the total price $p(Q_j)=\sum_{i\in Q_j}p_i$:
\begin{enumerate}
\item If $p(Q_j)<v_j$, she takes all edges in $Q_j$ by paying $p(Q_j)$; edges in $Q_j$ then become unavailable;
\item If $p(Q_j)>v_j$, she takes nothing and pays $0$;
\item If $p(Q_j)=v_j$, then whether she takes all edges in $Q_j$ at price $p(Q_j)$ depends on the specification about tie-breaking.
\end{enumerate}
We consider the following two different settings of tie-breaking. We say that the seller has the \emph{tie-breaking power}, if the item pricing mechanism is also associated with a tie-breaking rule. Specifically, whenever $p(Q_j)=v_j$ happens for some buyer $j$, the mechanism decides whether the buyer takes the edges or not, according to the tie-breaking rule. Given any price vector $p=\{p_i\}_{i\in [m]}$ and arrival order $\sigma$, we denote by $\mathsf{Wel}(\mathcal{Q},v; p,\sigma)$ the maximum welfare achieved by the mechanism among all tie-breaking rules. In the other setting, where the seller does not have the tie-breaking power, whenever $p(S_j)=v_j$ happens for some buyer $j$, the buyer herself can decide whether she takes the edges or not. For every price vector $p$ and arrival order $\sigma$, we denote by $\mathsf{Wel}_{\mathsf{NT}}(\mathcal{Q},v; p,\sigma)$ the worst-case (minimum) welfare achieved by the mechanism, over all tie-breaking decisions made by the buyers.
For any graph $G$, an instance in this problem can be represented as a tuple $\mathcal{F}=(\mathcal{Q},v)=(\{Q_j\}_{j\in [n]},\{v_j\}_{j\in [n]})$ that we refer to as a \emph{buyer profile}. An \emph{allocation} of the items to the buyers is a vector $y\in \set{0,1}^m$, such that for each item $i\in [m]$, $\sum_{j\in [n], i\in Q_j}y_j\le 1$.
Namely, for every $j$, $y_j=1$ if and only if buyer $j$ takes her demand set $Q_j$.
The welfare of an allocation $y$ is therefore $\sum_{j\in [n]}v_jy_j$.
We denote by $\mathsf{OPT}(G,\mathcal{F})$ the optimal welfare over all allocations, and use $\mathsf{OPT}$ for short when the instance is clear from the context.
Given any item pricing mechanism, we define the \emph{competitive ratio} as the ratio of the following two quantities: (i) the hindsight optimal welfare, which is the total value of the buyers in the optimal offline allocation; and (ii) the maximum among all choices of prices, of the worst-case welfare when the buyers' arrival order $\sigma$ is adversarial. Formally, for any instance $\mathcal{F}=(\mathcal{Q},v)$,
$$\textnormal{\textsf{gap}}(\mathcal{F})=\frac{\mathsf{OPT}(G,\mathcal{F})}{\max_{p}\min_{\sigma}\mathsf{Wel}(\mathcal{Q},v; p,\sigma)}.$$
In the paper, we analyze the competitive ratio when $G$ has different special structures. For ease of notation, for any graph $G$, denote $\textnormal{\textsf{gap}}(G)$ the largest competitive ratio $\textnormal{\textsf{gap}}(\mathcal{F})$ for any instance $\mathcal{F}$ with underlying graph $G$. And given a graph family $\mathcal{G}$, we denote $\textnormal{\textsf{gap}}(\mathcal{G})=\max_{G\in \mathcal{G}}\textnormal{\textsf{gap}}(G)$. For instance, $\textnormal{\textsf{gap}}(\mathsf{Tree})$ represents the worst competitive ratio among all trees. For the case when the seller has no tie-breaking power, we define $\textnormal{\textsf{gap}}_{\textnormal{\textsf{NT}}}(\mathcal{Q},v)$, $\textnormal{\textsf{gap}}_{\textnormal{\textsf{NT}}}(G)$ and $\textnormal{\textsf{gap}}_{\textnormal{\textsf{NT}}}(\mathcal{G})$ similarly.
\section{Resource Augmentation}\label{sec:congestion}
We consider the case where each item has augmented resources. In this section we prove results in the general combinatorial auction with single-minded buyers. To distinguish from the tollbooth problem setting, let $U=\set{1,\ldots,m}$ be the item set. Given a buyer profile $\mathcal{F}=\set{(Q_j,v_j)}_{j\in [n]}$, we denote by $\mathsf{OPT}(U,\mathcal{F})$ the maximum welfare by allocating items in $U$ to the buyers, such that each item is assigned to at most one buyer.
The seller, however, has more resources to allocate during the selling process. For each item $i\in U$, the seller has $c$ copies of the item, and each copy is sold to at most one buyer. In an item-pricing mechanism, the seller is allowed to set different prices for different copies. Formally, for each item $i\in U$, the seller sets $c$ prices $p^1(i)\leq\ldots\leq p^c(i)$, such that for each $1\le k\le c$, the $k$-th copy of item $i$ is sold at price $p^k(i)$.
When a buyer comes, if $k-1$ copies of item $i$ has already been sold, the buyer can purchase item $i$ with price $p^k(i)$. Again we define the worst-case welfare of an item pricing as the minimum welfare among all the buyers' arriving order.
With the augmented resources, the seller can certainly achieve more welfare than in the case with a single unit per item.
We show that item pricing can achieve worst-case welfare $\Omega(m^{-1/c})\cdot\mathsf{OPT}(U,\mathcal{F})$.
\begin{theorem}
\label{thm: congestion_c}
For any buyer profile $\mathcal{F}=\set{(Q_j,v_j)}_{j\in [n]}$ and any integer $c>0$, there exists a set\\ $\set{p^{k}(i)\mid i\in U, 1\le k\le c}$ of prices on items of $U$, that achieves worst-case welfare $\Omega(m^{-1/c})\cdot\mathsf{OPT}(U,\mathcal{F})$, even when the seller has no tie-breaking power.
\end{theorem}
\begin{proof}
Let $\mathcal{Q}=\set{Q_{j_1},\ldots,Q_{j_t}}$ be an independent set with maximum total value.
Denote $J=\set{j_1,\ldots,j_t}$, so $\mathsf{OPT}(U,\mathcal{F})=\sum_{j\in J}v_j$. Denote $v=\mathsf{OPT}(U,\mathcal{F})$.
$U'=\bigcup_{Q\in \mathcal{Q}}Q$, so $U'\subseteq U$ and $|U'|\le m$.
Note that $v=\sum_{j:Q_j\in \mathcal{Q}}v_j$.
We now define the prices on items of $U$ as follows.
For each element $i\notin U'$, we define $p^1(i)=\ldots=p^c(i)=+\infty$.
For each element $i\in U'$ and for each $1\le k\le c$, we define $p^k(i)=\frac{1}{2m}\cdot m^{(k-1)/c}$.
We now show that these prices achieve worst-case welfare $\Omega(v/m^{1/c})$.
Consider the remaining items of $U$ at the end of the selling process.
Clearly, all copies of items in $U\setminus U'$ must be unsold. Fix any buyers' order. We distinguish between the following cases.
\textbf{Case 1. Some element of $U'$ is sold out.} From the definition of prices in $\set{p^{k}(i)\mid i\in U, 1\le k\le c}$, for each $i\in U'$, $p^c(i)=\frac{v}{2}\cdot m^{-1/c}$. Therefore, if all $c$ copies of the item $i$ are sold, then the $c$-th copy is sold at price $p^c(i)=\frac{v}{2}\cdot m^{-1/c}$. It follows that the welfare is $\frac{v}{2}\cdot m^{-1/c}=\Omega(v\cdot m^{-1/c})$.
\textbf{Case 2. No elements of $U'$ are sold out.}
For each $i\in U'$, we define $\tilde p(i)=p^{k+1}(i)$ iff $k$ copies of $i$ are sold. Since no elements of $U'$ are sold out, $\tilde p(i)$ is well-defined for all $i\in U'$. If $k\geq 1$ copies of item $i$ are sold, the total prices of the sold copies of $i$ is at least $p^{k}(i)=\tilde p(i)\cdot m^{-1/c}>(\tilde p(i)-\frac{v}{2m})m^{-1/c}$; If $k=0$ copies of item $i$ are sold,
it also holds that $(\tilde p(i)-\frac{v}{2m})m^{-1/c}=0$. Since each buyer has a non-negative utility, the total welfare is at least $\sum_{i\in U'}(\tilde p(i)-\frac{v}{2m})m^{-1/c}\geq m^{-1/c}\sum_{i\in U'}\tilde p(i)-\frac{v}{2}m^{-1/c}$.
Let $\tilde\mathcal{Q}\subseteq\mathcal{Q}$ be the demand sets of $\mathcal{Q}$ that are sold. If $\sum_{j:Q_j\in \tilde\mathcal{Q}}v_j\ge \frac{v}{4}$, then the welfare of the pricing is already $\Omega(v\cdot m^{-1/c})$. Otherwise, $\sum_{j:Q_j\in \tilde\mathcal{Q}}v_j< \frac{v}{4}$, then $\sum_{j:Q_j\in \mathcal{Q}\setminus\tilde\mathcal{Q}}v_j>\frac{3v}{4}$. Since none of the buyers in $\mathcal{Q}\setminus\tilde\mathcal{Q}$ are sold, it means that the total prices of all items at the end of the selling process is at least $\frac{3v}{4}$, since $\sum_{i\in U'}\tilde p(i)
\ge
\sum_{Q\in \mathcal{Q}\setminus \tilde\mathcal{Q}}\tilde p(Q)
\ge
\sum_{j:Q_j\in \mathcal{Q}\setminus \tilde\mathcal{Q}}\tilde v_j
>\frac{3v}{4}$. The theorem follows since the total welfare is at least $m^{-1/c}\sum_{i\in U'}\tilde p(i)-\frac{v}{2}\cdot m^{-1/c}=\Omega(v\cdot m^{-1/c})$.
\end{proof}
On the other hand, in \Cref{thm: congestion_c lower bound} we show that a polynomial dependency on $m$ in the competitive ratio is in fact unavoidable.
\begin{theorem}
\label{thm: congestion_c lower bound}
For any integer $c>0$, there exists a ground set $U$ with $|U|=m$ and a buyer profile $\mathcal{F}=\set{(Q_j,v_j)}_{j\in [n]}$, such that any set $\set{p^{k}(i)\mid i\in U, 1\le k\le c}$ of prices achieves worst-case welfare $O(c\cdot m^{-1/(c+1)})\cdot \mathsf{OPT}(U,\mathcal{F})$, even the seller has tie-breaking power.
\end{theorem}
\begin{proof}
Let $r$ be the number such that $m=\binom{r}{c+1}$, so $r=O(c\cdot m^{1/(c+1)})$.
Denote $I=\set{1,\ldots,r}$ and let $U=\set{u_J\mid J\subseteq I, |J|=c+1}$, namely $U$ contains $\binom{r}{c+1}=m$ elements, where each element is indexed by a size-$(c+1)$ subset $J$ of $I$.
We define the buyer profile as follows.
There are $(c+1)r+1$ buyers: buyer $B_0$, and, for each $1\le k\le c+1, 1\le j\le r$, a buyer named $B^k_j$.
The demand set for buyer $B_0$ is $S_0=U$, and her value is $|U|=\binom{r}{c+1}$.
For each $1\le j\le r$ and for each $1\le k\le c+1$, the demand set of buyer $B^k_j$ is $Q^k_j=\set{u_J\mid j\in J}$, and her value is $v(S^k_j)=|S^k_j|=\binom{r-1}{c}$.
Clearly optimal allocation when each item has supply 1 is to assign all elements of $U$ to $B_0$, and the optimal welfare is $\mathsf{OPT}(U,\mathcal{F})=|U|=\binom{r}{c+1}$.
Moreover, it is easy to verify that any $c+1$ demand sets of $\set{Q^k_j}_{1\le k\le c+1,1\le j\le r}$ shares at least one element of $U$.
We claim that any set of prices can achieve worst-case welfare at most $c\cdot\binom{r-1}{c}$.
Note that this finishes the proof of Theorem~\ref{thm: congestion_c lower bound}, since $$\frac{c\cdot\binom{r-1}{c}}{\mathsf{OPT}(U,\mathcal{F})}=\frac{c\cdot\binom{r-1}{c}}{\binom{r}{c+1}}=\frac{c\cdot\binom{r-1}{c}}{\frac{r}{c+1}\cdot\binom{r-1}{c}}=\frac{c(c+1)}{r}=O\left(\frac{c+1}{m^{1/(c+1)}}\right).$$
It remains to prove the claim.
Let $\set{p^k(u)\mid u\in U, 1\le k\le c}$ be any set of prices.
We will iteratively construct an order $\sigma$ on buyers, such that if the buyers come to the auction according to this order, the achieved welfare is at most $c\cdot\binom{r-1}{c}$.
Initially. $\sigma$ is an empty sequence.
Throughout, we maintain a set $\set{\tilde p(u)}_{u\in U}$ of prices, such that at any time, $\tilde p(u)$ is the price of the cheapest available copy of item $u$. Initially, $\tilde p(u)=p^1(u)$ for all $u\in U$.
We perform a total of $c$ iterations, and now we fix some $1\le k\le c$ and describe the $k$-th iteration. We first check whether or not there is a set $Q_j^k$ with $\tilde p(Q_j^k)\le v(Q_j^k)$. If so, assume $\tilde p(Q_{j_k}^k)\le v(Q^k_{j_k})$, then we add the buyer $B^k_{j_k}$ to the end of the current sequence $\sigma$, update the price $\tilde p(u)$ for all items $u\in Q^k_{j_k}$ to their next price in $\set{p^k(u)\mid 1\le k\le c}$. And then continue to the next iteration. Otherwise, since every element of $U$ appears in exactly $c+1$ sets of $Q^k_1,\ldots,Q^k_{r}$, and $\sum_{1\le j\le r}v(Q^k_j)=r\binom{r-1}{c}=(c+1)\binom{r}{c+1}=(c+1)\cdot |U|$, we get that $\tilde p(U)> |U|$.
Therefore, no buyer can afford her demand set, and the welfare will be $0$. In this case, we add all buyers to the end of $\sigma$ and terminate the algorithm.
We now analyze the algorithm. If the algorithm is terminated before it completes $c$ iterations, then from the construction above, the buyer $B_0$ will not get her demand set. Also, since any $c+1$ other demand sets share an element of $U$, at most $c$ other buyers may get their demand sets. Therefore, the welfare is at most $c\cdot\binom{r-1}{c}$.
Assume that the algorithm successfully completes $c$ iterations. From the description of the algorithm, in each iteration, some buyer from $\set{B^k_j\mid 1\le k\le c+1,1\le j\le r}$ will be added to the sequence, and moreover, this buyer will get her demand set under order $\sigma$.
Therefore, after $c$ iterations, we added $c$ distinct buyers to the sequence that will get their demand sets.
Since any $c+1$ demand sets shares an element of $U$, we know that no other buyer may get her demand set anymore, so the welfare is at most $c\cdot\binom{r-1}{c}$.
\end{proof}
In \Cref{thm: lower_bound_congestion}, we prove that a polynomial welfare gap also exists in the tollbooth problem. We adapt the series-parallel graph $H_{a,b}$ used in \Cref{thm:lb-mahua} and show that a polynomial competitive ratio is unavoidable in the tollbooth problem, even each edge has a constant $c$ number of copies. Note that the benchmark we are comparing to is $\mathsf{OPT}(G,\mathcal{F})$, the optimal welfare when each edge has supply 1.
\begin{theorem}
\label{thm: lower_bound_congestion}
In the tollbooth problem, for any constant integer $c>0$, there exists a graph $G$ with $m$ edges and a buyer profile $\mathcal{F}=\set{(Q_j,v_j)}_{j\in [n]}$, such that any set $\set{p^{k}(e)\mid e\in E(G), k\in [c]}$ of prices achieves worst-case welfare $O(m^{-1/(2c+6)})\cdot \mathsf{OPT}(G,\mathcal{F})$.
\end{theorem}
\begin{proof}
We will use the graph $H_{a,b}$ constructed in \Cref{thm:lb-mahua}. For convenience, we will work with the multi-graph $L_{a,b}$.
The parameters $a,b$ are set such that $b=a+2(c+1)^{c+2}a^{c+2}$ and $m=ab$, so $a=\Theta(m^{1/(c+3)})$.
We now define the buyer profile. Recall that in \Cref{thm:lb-mahua} the buyer profile $\mathcal{F}=\mathcal{F}^*\cup(\bigcup_{S\subseteq [a], |S|\ge \sqrt{a}}\mathcal{F}_S)$, where $\mathcal{F}^*$ contains, for each $r\in [a]$, a buyer $B^*_r$ demanding the path $Q^{(r)}=(r,r,\ldots,r)$ with value $1$.
The buyer profile $\hat\mathcal{F}$ that we will use in this subsection is similar to $\mathcal{F}$.
Specifically, we will keep the buyers in $\mathcal{F}^*$, but will also additionally construct, for each set $S\subseteq [a]$ such that $|S|\ge \sqrt{ca}$ (instead of $|S|\ge \sqrt{a}$), a set $\hat\mathcal{F}_S$ of buyers, whose demand paths and values satisfy the following properties.
\begin{enumerate}
\item \label{prop'1}For each $S$, set $\hat\mathcal{F}_S$ contains $(c+1)|S|$ buyers, and every pair $Q,Q'$ of demand paths in $\hat\mathcal{F}_S$ share some edge, and the value for each demand path is $1+\epsilon$.
\item \label{prop'3}For each demand path $Q$ in $\hat\mathcal{F}_S$, the index sequence $(j^Q_1,\ldots,j^Q_b)$ that $Q$ corresponds to satisfies that (i) $j^Q_i\in S$ for each $i\in [b]$; and (ii) the set $\set{j^Q_1,\ldots,j^Q_b}$ contains all element of $S$.
\item \label{prop'4}The union of all demand paths in $\hat\mathcal{F}_S$ covers the graph $\bigcup_{r\in S}Q^{(r)}$ exactly $c+1$ times. In other words, for each $i\in [b]$, the multi-set $\set{j^Q_i\mid Q\in \hat\mathcal{F}_S}$ contains each element of $S$ exactly twice.
\item \label{prop'5}For any $c+1$ subsets $S_1,\ldots,S_{c+1}$ of $[a]$, such that $|S_t|\ge \sqrt{ca}$ for each $t\in [c\!+\!1]$ and $\bigcap_{t}S_t\ne \emptyset$, for any $c+1$ demand paths $Q_1,\ldots,Q_{c+1}$ such that $Q_t\in \hat\mathcal{F}_{S_t}$ for each $t\in [c\!+\!1]$, $\bigcap_{t}E(Q_t)\ne \emptyset$.
\end{enumerate}
Suppose that we have successfully constructed the sets $\set{\hat\mathcal{F}_S}_{S\subseteq [a], |S|\ge \sqrt{ca}}$ that satisfy the above properties.
We then let $\mathcal{F}$ be the union of $\mathcal{F}^*$ and, for each set $S\subseteq [a], |S|\ge \sqrt{ca}$, $c$ distinct copies of set $\hat\mathcal{F}_S$. In other words, for each buyer in $\set{\hat\mathcal{F}_S}_{S\subseteq [a], |S|\ge \sqrt{ca}}$, we duplicate $c$ buyers and add all of them into our buyer profile.
This completes the description of $\hat\mathcal{F}$.
From the above properties, it is easy to see that $\mathsf{OPT}(L_{a,b},\hat\mathcal{F})=a$, which is achieved by giving each buyer in $\mathcal{F}^*$ her demand path.
We will prove that any prices on edges of $L_{a,b}$ may achieve worst-case welfare $O(\sqrt{ca})$. Since $a=\Theta(m^{1/(c+3)})$, $\sqrt{a}=\Theta(m^{1/(2c+6)})$, which completes the proof of \Cref{thm: lower_bound_congestion}.
Consider now any set $\set{p^k(e)\mid e\in E(L_{a,b}), k\in [c]}$ of prices on edges of $L_{a,b}$.
From Properties \ref{prop'3} and \ref{prop'5}, it is easy to see that at most $\sqrt{ca}$ buyers from $\hat{\mathcal{F}}\setminus \mathcal{F}^*$ can get their demand paths simultaneously. We consider the following arrival order of the buyers in $\hat\mathcal{F}$. The buyers in $\hat\mathcal{F}$ are divided into $(c+1)$ groups, where each of the first $c$ groups contains a copy of each buyer from $(\bigcup_{S\subseteq [a], |S|\ge \sqrt{a}}\mathcal{F}_S)$, and the last group contains all buyers of $\mathcal{F}^*$. The buyers come to the auction according to their group index: All buyers from the first group come first (buyers within the same group come at an arbitrary order), and then all buyers from the second group come, etc.
Assume that we pause the selling process right after all buyers from the first $ca$ groups have come.
Currently for each edge $e\in E(L_{a,b})$, some copies of it were taken and there is a price $p^*(e)$ on its next copy.
We distinguish between the following two cases.
\paragraph{Case 1. At least $\sqrt{ca}$ buyers in $\mathcal{F}^*$ can afford their demand paths at prices $\set{p^*(e)}_{e\in E(L_{a,b})}$.}
We let $S$ be the set that contains all indices $r\in [a]$ such that the buyer $B^*_r$ can afford her demand path $Q^{(r)}$ at prices $\set{p^*(e)}_{e\in E(L_{a,b})}$, so $|S|\ge \sqrt{ca}$. Similar to \Cref{lem:ratio-Lab}, it is easy to show that at least one buyer in $\hat\mathcal{F}_S$ can afford her demand path, and therefore all $c$ copies of this buyer in $\hat\mathcal{F}$ will get their demand paths. This implies that $p^*(Q^{(r)})=+\infty$ for all $r\in S$, contradicting with the assumption in this case.
\paragraph{Case 2. At most $\sqrt{ca}$ buyers in $\mathcal{F}^*$ can afford their demand paths at prices $\set{p^*(e)}_{e\in E(L_{a,b})}$.}
Similar to Lemma~\ref{lem:ratio-Lab}, the optimal welfare is at most $(2+\epsilon)\sqrt{ca}$.
$\ $
It remains to construct the sets $\set{\hat\mathcal{F}_S}_{S\subseteq [a], |S|\ge \sqrt{ca}}$ that satisfy the required properties. The construction is almost identical to that of \Cref{thm:lb-mahua}. The only difference is that we need to construct a $(c+1)s\times b$ matrix $M'_S$, instead of a $2s\times b$ matrix. Accordingly, we first place $(c+1)$ copies of matrix $N_S$ vertically as the first $s$ columns of $M'_S$, and then for the next $b-s$ columns, we let each column to be each column be an independent random permutation on elements of the multiset that contains, for each element of $S$, $(c+1)$ copies of it. It is easy to verify that, with $b=a+2(c+1)^{c+2}a^{c+2}$, all the desired properties are satisfied with high probability.
\end{proof}
\subsection{Path}\label{sec:pathnt}
We first focus on the case when $G$ is a single path. Unlike the scenario with tie-breaking power, where the optimal welfare can be obtained with some set of prices (Theorem~\ref{thm:path}), the competitive ratio may be strictly larger than 1 when the seller has no tie-breaking power.
\begin{theorem}\label{thm:path_no_tie_hardness}
\label{thm: path_no_tie_lower_bound}
$\textnormal{\textsf{gap}}_{\textnormal{\textsf{NT}}}(\mathsf{Path})\geq 3/2$, i.e. there exists a path graph $G$ and an instance $\mathcal{F}$, such that any set of prices achieves worst-case welfare at most $2/3\cdot \mathsf{OPT}(G,\mathcal{F})$, when the seller has no tie-breaking power.
\end{theorem}
In Theorem~\ref{thm:path_no_tie} we prove that the competitive ratio $3/2$ is tight for path graphs, when the seller has no tie-breaking power.
\begin{theorem}
\label{thm:path_no_tie}
$\textnormal{\textsf{gap}}_{\textnormal{\textsf{NT}}}(\mathsf{Path})\leq 3/2$. Moreover, the prices that achieve the competitive ratio 3/2 can be computed efficiently.
\end{theorem}
Before giving a proof sketch of Theorem~\ref{thm:path_no_tie}, we first present some definitions and lemmas required in the proof. From \Cref{thm:path}, (LP-Primal) has an integral optimal solution. We denote by $y^*$ the integral optimal solution of (LP-Primal) that maximizes $\sum_{j\in [m]}y^*_j$. Note that $y^*$ can be computed by solving a slightly different LP that is obtained from (LP-Primal) by changing its objective to $\sum_{j\in [m]}(v_j+\varepsilon')\cdot y_j$, for some small enough $\varepsilon'>0$.
Define $Y=\set{j\mid y^*_j=1}$ and
$\mathcal{Q}_Y=\set{Q_j\mid y^*_j=1}$.
\begin{lemma}\label{lem:price-strictly-positive}
There is an $\varepsilon>0$ and an optimal solution $\set{p^*(e)}_{e\in E(G)}$ for (LP-Dual), such that
(i) for each edge $e\in E(\mathcal{Q}_Y)$, $p^*(e)\geq \varepsilon$; and (ii)
for each $j\in [m]$, either $p^*(Q_j)=v_j$, or $p^*(Q_j)>v_j+n\varepsilon$.
\end{lemma}
Now choose $\varepsilon>0$ and the prices $p^*$ from Lemma~\ref{lem:price-strictly-positive}. We define $A=\set{j\mid v_j=p^*(Q_j)}$ and $\mathcal{Q}_A=\set{Q_j\mid j\in A}$.
\begin{definition}
We say that a set $\mathcal{Q}\subseteq \mathcal{Q}_A$ of edge-disjoint paths is \emph{good}, iff set $\mathcal{Q}_A\setminus \mathcal{Q}$ does not contain another subset $\mathcal{Q}'$ of $|\mathcal{Q}'|\ge 2$ edge-disjoint paths, such that
$\bigcup_{j:Q_j\in \mathcal{Q}'}Q_j=\bigcup_{j:Q_j\in \mathcal{Q}}Q_j$.
\end{definition}
We prove the following lemma about good edge-disjoint paths.
\begin{lemma}\label{claim:covering_implies_optimal}
There is an efficient algorithm that, given a good set $\mathcal{Q}$ of edge-disjoint paths, computes a set of positive prices $p=\{p(e)\}_{e\in E(G)}
that achieves worst-case welfare at least $\sum_{Q_j\in \mathcal{Q}}v_j$
\end{lemma}
Now we are ready to sketch the proof of \Cref{thm:path_no_tie}. We will prove Theorem~\ref{thm:path_no_tie} using \Cref{claim:covering_implies_optimal}.
We denote $\mathcal{Q}_Y=\set{Q_1,Q_2,\ldots,Q_k}$, where the paths are indexed according to the order in which they appear on $G$.
First, for each edge $e\notin E(\mathcal{Q}_Y)$, we set its price $\tilde p(e)=+\infty$.
Therefore, any buyer $j$ with $e\in Q_j$ cannot take her demand path.
In fact, we may assume without loss of generality that $\bigcup_{1\le j\le k}Q_j=G$, since otherwise we can view each connected component (which is also a path) of graph $\bigcup_{1\le j\le k}Q_j$ as the whole graph, and compute prices for its edges separately.
The crucial step of the proof is to compute three sets $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3\subseteq \mathcal{Q}_A$ of edge-disjoint paths, such that
\begin{enumerate}
\item \label{prop: cover_twice} every edge of $E(G)$ is contained in exactly two paths of $\hat\mathcal{Q}_1,\hat\mathcal{Q}_2,\hat\mathcal{Q}_3$; and
\item \label{prop: good_cover} for each $t\in \set{1,2,3}$, consider every connected component in the graph generated from paths in $\hat\mathcal{Q}_t$. Then set of paths in every connected component is a good set of edge-disjoint paths.
\end{enumerate}
By property~\eqref{prop: cover_twice}, $\sum_{j:Q_j\in \hat\mathcal{Q}_1}v_j+\sum_{j:Q_j\in \hat\mathcal{Q}_2}v_j+\sum_{j:Q_j\in \hat\mathcal{Q}_3}v_j=2\cdot\mathsf{OPT}(G,\mathcal{F})$.
Assume without loss of generality that $\sum_{j:Q_j\in \hat\mathcal{Q}_1}v_j\ge (2/3)\cdot\mathsf{OPT}(G,\mathcal{F})$.
Then we can set prices $\set{\tilde p(e)}_{e\in E(\hat\mathcal{Q}_1)}$ according to Lemma~\ref{claim:covering_implies_optimal}, and $+\infty$ price for all other edges. By Lemma~\ref{claim:covering_implies_optimal}, the item pricing $\tilde p$ achieves worst-case welfare at least $\sum_{j:Q_j\in \hat\mathcal{Q}_1}v_j\ge (2/3)\cdot\mathsf{OPT}(G,\mathcal{F})$.
\section{Competitive Ratio for Special Graphs}\label{sec:special_graph}
In this section, we first analyze the competitive ratio when the underlying graph $G$ has special structures. Throughout this section, we assume that the seller has tie-breaking power. In Section~\ref{sec:no_tie_breaking}, we consider the case where the seller does not have tie-breaking power.
Given any instance $\mathcal{F}$, the hindsight optimal welfare is captured by an integer program. The relaxed linear program (LP-Primal) is shown in Equation~\eqref{equ:primal} in Section~\ref{subsec:result}. Its dual (LP-Dual) is shown in Equation~\eqref{equ:dual}.
We denote $\mathsf{OPT}_{\mathsf{LP}}(\mathcal{Q}, v)$ (or $\mathsf{OPT}_{\mathsf{LP}}$ if the instance is clear from context) the optimum of (LP-Primal). Clearly, $\mathsf{OPT}_{\mathsf{LP}}(\mathcal{Q},v)\geq \mathsf{OPT}(\mathcal{Q}, v)$. We first present a lemma that is useful throughout this section. The lemma shows that for any feasible integral solution achieved by rounding from the optimal fractional solution, we are able to compute prices to guarantee selling to the exact same set of buyers.
\begin{lemma}\label{lem:rounding}
Let $y^*$ be any optimal solution of (LP-Primal) and let $y'\in \set{0,1}^n$ be any feasible integral solution of (LP-Primal), such that for each $j\in [n]$, $y'_j=0$ if $y_j^*=0$.
Then there exists a price vector $p=\set{p_i}_{i\in [m]}$ that achieves worst-case welfare $\sum_{j\in [n]}v_j\cdot y_j'$, if the seller has the power of tie-breaking. Moreover, the price vector $p$ can be computed efficiently.
\end{lemma}
\begin{proof}
Let $p^*=\{p^*_i\}_{i\in [m]}$ be any optimal solution for (LP-Dual).
We will show that, for any buyers' arrival order $\sigma$, with a proper tie-breaking rule, we can ensure with the prices $p^*$ that the outcome of the selling process is $y'$, and therefore it achieves welfare $\sum_{j\in [n]}v_j\cdot y_j'$.
Consider now a buyer $j$.
Assume first that $y_j'=0$, from the constraint of (LP-Dual), $\sum_{i\in Q_j}p^*_i\geq v_j$.
If $\sum_{i\in Q_j}p^*_i> v_j$, then the buyer $j$ cannot afford her demand set.
If $\sum_{i\in Q_j}p^*_i= v_j$, since the seller has the power of tie-breaking, the seller can choose not to give the demand set to her.
Assume now that $y_j'=1$, so $y_j^*>0$. From the complementary slackness, $\sum_{i \in Q_j}p^*_i=v_j$. The seller can sell the demand set $Q_j$ to buyer $j$.
Since $y'$ is a feasible solution of (LP-Primal), no items will be given to more than one buyer.
Moreover, it is easy to verify that the above tie-breaking rule ensures that this selling process's outcome is exactly $y'$, for any buyers' arrival order $\sigma$. Therefore, the worst-case welfare is $\sum_{j\in [n]}v_j\cdot y_j'$. The set of prices $p^*$ can be computed in polynomial time by solving the (LP-Dual).
\end{proof}
An immediate corollary of Lemma~\ref{lem:rounding} is for the highway problem, i.e. $G$ is a single path. In this case, there is always an integral optimal solution for (LP-Primal)~\cite{cheung2008approximation,schrijver1998theory}. Thus by Lemma~\ref{lem:rounding}, there exist prices that achieve worst-case welfare the same as optimal welfare.
\begin{theorem}
[\cite{cheung2008approximation,chawla2017stability}]
\label{thm:path}
$\emph{\textnormal{\textsf{gap}}}(\mathsf{Path})=1$.
\end{theorem}
In the rest of this section, we consider different graph classes $\mathcal{G}$ and bound $\textnormal{\textsf{gap}}(\mathcal{G})$.
\subsection{Spiders}\label{sec:spider}
\iffalse
\begin{theorem}
\label{thm:spider}
If we (the seller) has the power of tie-breaking (or not), then there is an efficient algorithm, that, given any buyer-profile $\set{(Q_j,v_j)}_{j\in [m]}$ in the spider graph, computes a set of prices $\set{p_e}_{e\in G}$ that achieves the revenue at least $1/3$ (or $\frac{2}{7}$) the optimal offline welfare.
\end{theorem}
\begin{proof}
We first find the optimal integral offline allocation that maximizes the total value. Consider an path composed by $L=L_1\cup L_2$ two legs of the graph such that a path $Q=Q_1\cup Q_2$ is allocated on both legs in the offline allocation. Let $e_1\in Q_1\subseteq L_1,e_2\in Q_2\subseteq L_2$ be the edges adjacent to the center. Denote by $\mathsf{OPT}_{out}(L)$ be the total value of paths from $L\setminus Q$ in the optimal solution, in other words, the welfare contributed from edges unrelated to $Q$. Thus the optimal welfare from this leg is $\mathsf{OPT}(L)=\mathsf{OPT}_{out}(L)+v(Q)$. Denote by $\mathsf{OPT}_{in}(L)$ be the optimal value of paths from $Q\setminus\{e_1,e_2\}$, in other words, the optimal welfare that can get collected from $Q$ that are unrelated to the center. $\mathsf{OPT}_{in}(L)$ is a part of optimal offline allocation, but will appear in our later analysis.
Suppose that $\mathsf{OPT}_{in}(L)=\delta v(Q)$. Clearly $\delta\leq 1$, since $\mathsf{OPT}_{out}(L)+\mathsf{OPT}_{in}(L)$ is also a feasible value of allocation on $L$, thus $\mathsf{OPT}_{out}(L)+\mathsf{OPT}_{in}(L)\leq \mathsf{OPT}(L)=\mathsf{OPT}_{out}(L)+v(Q)$.
Consider the following two pricing algorithms $p_L^1$ and $p_L^2$.
Pricing $p_L^1$ set prices $p_L^1(e_1)=p_L^1(e_2)=\frac{1-\delta}{2}v(Q)$ to the edges connected to the center; for any edge $e\in Q\setminus\{e_1,e_2\}$, $p_L^1(e)$ equals the dual price in the LP solving $\mathsf{OPT}_{in}(L)$ (when we do not have tie-breaking, add arbitrarily small $\varepsilon$ to the price of edges in $Q\setminus\{e_1,e_2\}$ and reduce the price of edges $e_1$, $e_2$ such that $p_L^1(Q)=v(Q)$); for any edge $e\in L\setminus Q$, $p_L^1(e)=+\infty$. Notice that the buyer allocated path $Q$ in the optimal solution can still afford to purchase that path, since $p_L^1(Q)=2\cdot\frac{1-\delta}{2}v(Q)+\mathsf{OPT}_{in}(L)=v(Q)$; any buyer purchasing $e_1$ or $e_2$ will contribute at least $\frac{1-\delta}{2}v(Q)$ to this leg $L$; any buyer that demands a path in $e\in Q\setminus\{e_1,e_2\}$ has value at most the price according to the discussion in Theorem~\ref{thm:path}, thus can be filtered out by tie-breaking (or additional price); any buyer that demands a path intersecting $L\setminus Q$ cannot afford to pay the infinite price. Thus the revenue $\mathsf{REV}(p_L^1)$ contributed to $L$ in pricing $p_L^1$ is at least $\frac{1-\delta}{2}v(Q)$.
Pricing $p_L^2$ set prices $p_L^2(e)$ for each edge $e\in L\setminus\{e_1,e_2\}$ to be the dual price in the LP solving the optimal welfare for $L\setminus\{e_1,e_2\}$; $p_L^2(e_1)=p_L^2(e_2)=+\infty$. The revenue contributed to $L$ in pricing $p_L^2$ is
\begin{equation}\label{eqn:spider-pricing2}
\mathsf{REV}(p_L^2)\geq\mathsf{OPT}(L\setminus\{e_1,e_2\})\geq \mathsf{OPT}_{in}(L)+\mathsf{OPT}_{out}(L)=\delta v(Q)+\mathsf{OPT}_{out}(L).
\end{equation}
Thus the better of the two item pricings grants revenue
\begin{eqnarray*}
\max(\mathsf{REV}(p_L^1),\mathsf{REV}(p_L^2))&\geq& \frac{2}{3}\mathsf{REV}(p_L^1)+\frac{1}{3}\mathsf{REV}(p_L^2)\\
&\geq&\frac{2}{3}\cdot\frac{1-\delta}{2}v(Q)+\frac{1}{3}(\delta v(Q)+\mathsf{OPT}_{out}(L))\\
&=&\frac{1}{3}(v(Q)+\mathsf{OPT}_{out}(L))=\frac{1}{3}\mathsf{OPT}(L).
\end{eqnarray*}
For each pair of legs such that a path is allocated in the optimal allocation, we run the better of the two pricings above. For a leg such that the paths allocated on it do not cross the center, the performance is only better. Such item pricing gives $\frac{1}{3}$-approximation to the optimal welfare.
For the case without tie-breaking, we have $\mathsf{REV}(p_L^2)\geq \frac{2}{3}(\delta v(Q)+\mathsf{OPT}_{out}(L))$, thus $\max(\mathsf{REV}(p_L^1),\mathsf{REV}(p_L^2))\geq \frac{2}{7}\mathsf{OPT}(L)$.
\end{proof}
\subsection{An improved approximation ratio for spiders}
\fi
In this section we consider the case where graph $G$ is a spider. The main result of this section is summarized in the following theorem.
\begin{theorem}
\label{thm:spiderimproved}
There is an efficient algorithm, that, given any spider graph $G$ and any buyer-profile $\mathcal{F}=\set{(Q_j,v_j)}_{j\in [m]}$, computes a set of prices on edges of $G$ that achieves the worst-case revenue equal at least $(2/3)\cdot\mathsf{OPT}(G,\mathcal{F})$, with the power of tie-breaking.
\end{theorem}
The remainder of this section is dedicated to the proof of Theorem~\ref{thm:spiderimproved}.
Similarly as in the proof of Theorem~\ref{thm:star2}, we consider the linear program (LP-Primal). We use the following lemma, whose proof is similar to that of Lemma~\ref{lem:matching-half-integral} and is deferred to Section~\ref{sec: Proof of spider-half-integral}.
\begin{lemma}\label{lem:spider-half-integral}
If $G$ is a spider graph, then (LP-Primal) has a half-integral optimal solution $y^*$. Moreover, such a solution can be computed efficiently.
\end{lemma}
Denote by $\mathsf{OPT}_{\mathsf{LP}}$ the optimal value of (LP-Primal), and let $y^*$ be a half-integral optimal solution of (LP-Primal) given by Lemma~\ref{lem:spider-half-integral}.
Denote $J_{1/2}=\set{j\mid y^*_j=1/2}$ and $J_1=\set{j\mid y^*_j=1}$.
Clearly, paths of $\set{Q_j\mid j\in J_{1}}$ are edge-disjoint, and they are also edge-disjoint from paths of $\set{Q_j\mid j\in J_{1/2}}$.
We will show that we can efficiently compute a subset $J'\subseteq J_{1/2}$, such that (i) the paths of $\set{Q_j\mid j\in J'}$ are edge-disjoint; and (ii) the total value of paths in $\set{Q_j\mid j\in J'}$ is at least $\frac{1}{3}\cdot \sum_{j\in J_{1/2}}v_j$.
We claim that this implies Theorem~\ref{thm:spiderimproved}. To see why this is true, consider (LP-Dual) and any optimal solution $p^*=\{p^*(e)\}_{e\in E(G)}$ of (LP-Dual), and then we simply set, for each edge $e\in E(G)$, its price to be $p^*(e)$. From strong duality and complementary slackness, for each $j\in J'\cup J_1$, $\sum_{i: e_i\in Q_j}p^*(e_i)=v_j$, and for each $j\notin J'\cup J_1$, $\sum_{i: e_i\in Q_j}p^*(e_i)\le v_j$. Therefore, we may apply the power of tie-breaking such that only buyers of $\set{B_j\mid j\in J'\cup J_1}$ may get their demand paths at price $p^*$, and this ensures that the revenue we obtain at the end of the algorithm is at least $\sum_{ j\in J'\cup J_1}v_j\ge \frac{2}{3}\cdot (\frac{1}{2}\cdot\sum_{j\in J_{1/2}}v_j+\sum_{j\in J_{1}}v_j)= \frac{2}{3}\cdot \mathsf{OPT}_{\mathsf{LP}}$.
It remains to show how to compute the subset $J'$ with desired properties. We use the following lemma.
\begin{lemma}\label{lem:tree-coloring}
Let $T$ be a tree, let $d\geq 2$ be an integer and let $\mathcal{Q}$ be a set of paths in $T$, such that every edge of $T$ appears in at most $d$ paths of $\mathcal{Q}$, then we can efficiently compute a partition of $\mathcal{Q}$ into $d+1$ subsets $\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}$, such that for every $1\le i\le d+1$, paths in $\mathcal{Q}_i$ are edge-disjoint.
\end{lemma}
We provide the proof of Lemma~\ref{lem:tree-coloring} later, after we complete the proof of Theorem~\ref{thm:spiderimproved} using it.
Define $\mathcal{Q}=\set{Q_j\mid j\in J_{1/2}}$. Since $y^*$ is a feasible solution of (LP-Primal), $y^*_j=1/2$ for each $j\in J_{1/2}$ and $y^*_j=1$ for each $j\in J_{1}$, every edge of $G$ is contained in at most $2$ paths of $\mathcal{Q}$. Since $G$ is a spider graph, $G$ is also a tree.
From Lemma~\ref{lem:spider-half-integral}, we can efficiently obtain a partition $(\mathcal{Q}_1,\mathcal{Q}_2, \mathcal{Q}_3)$ of $\mathcal{Q}$, such that for each $1\le i\le 3$, paths in $\mathcal{Q}_i$ are edge-disjoint.
Therefore, at least one of sets $\mathcal{Q}_1,\mathcal{Q}_2,\mathcal{Q}_3$ contains edge-disjoint paths of total value at least $\frac{1}{3}\sum_{Q\in \mathcal{Q}}v(Q)=\frac{1}{3}\sum_{j\in J_{1/2}}v_j$.
We now show the proof of Lemma~\ref{lem:tree-coloring}.
\begin{proof}[Proof of Lemma~\ref{lem:tree-coloring}.]
We construct an algorithm that partitions the set $\mathcal{Q}$ of paths into $d+1$ subsets $\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}$.
We root $T$ at an arbitrarily chosen vertex $r\in V(T)$, and we say that a vertex $v\in V(T)$ is \emph{at the $i$-th level} iff the tree-distance between $v$ and $r$ in $T$ is $i$.
The algorithm will compute the sets $\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}$ iteratively.
Initially, all sets are set to be $\emptyset$.
The algorithm proceeds sequentially in phases. In the $i$-th phase, the algorithm process all vertices at the $i$-th level one-by-one.
Upon processing a vertex $v$, we will assign all paths containing at least one edge of $E_v$ to some set of $\set{\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}}$, where $E_v$ is the set of edges connecting $v$ to some of its children.
Fix an integer $i$ and a vertex $v$ at the $i$-th level, and we now describe the iteration of processing the vertex $v$. Let $\mathcal{Q}(v)$ contain all paths of $\mathcal{Q}$ that contains at least one edge connecting $v$ to some of its children.
The $\mathcal{Q}(v)$ can be partitioned into three subsets:
set $\mathcal{Q}^0(v)$ contains all paths of $\mathcal{Q}(v)$ that are already assigned to some set of $\set{\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}}$;
set $\mathcal{Q}^1(v)$ contains all paths of $\mathcal{Q}(v)$ that are not yet already assigned and contains exactly $1$ edge of $E_v$; and
set $\mathcal{Q}^2(v)$ contains all paths of $\mathcal{Q}(v)$ that are not yet already assigned and contains exactly $2$ edges of $E_v$.
Note that each path of $\mathcal{Q}^0(v)$ must contain the edge $\hat e$ connecting $v$ to its parent vertex and exactly one edge of $E_v$, so they must belong to distinct sets of $\set{\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}}$.
We construct an auxiliary graph $H$ as follows.
The vertex set is $V(H)=\set{u_{\hat e}}\cup \set{u_e\mid e\in E_v}\cup \set{\hat u_Q\mid Q\in \mathcal{Q}^1(v)}$. The edge set is partitioned into three subsets $E(H)=E_0\cup E_1\cup E_2$, where
$E_0=\set{(u_e,v)\mid Q\in \mathcal{Q}^0(v), e= Q\cap E_v}$, $E_1=\set{(u_e,\hat u_Q)\mid Q\in \mathcal{Q}^1(v), e= Q\cap E_v}$, and
$E_2=\set{(u_e,u_{e'})\mid Q\in \mathcal{Q}^2(v), \set{e,e'}= Q\cap E_v}$.
Clearly, every path of $\mathcal{Q}(v)$ correspond to an edge in $E(H)$, that we denote by $f_Q$.
It is clear from the definition of $H$ that, for every pair $Q,Q'$ of paths in $\mathcal{Q}(v)$, $Q$ and $Q'$ are edge-disjoint iff edges $f_{Q}$ and $f_{Q'}$ of $E(H)$ do not share a vertex.
Since every edge $e\in E_v$ is contained in at most $d$ paths of $\mathcal{Q}(v)$, from the definition of graph $H$, every vertex in $H$ has degree at most $d$.
From Vizing's Theorem~\cite{vizing1964estimate,misra1992constructive}, we can efficiently find a coloring of all edges of $E(H)$ with $d+1$ colors, such that edges with same color do not share vertices.
Note that, since all edges in $\set{f_Q\mid \mathcal{Q}^{0}(v)}$ share the vertex $u_{\hat e}$, these edges will have different colors in any valid edge-coloring.
We now assign, for each $Q\in \mathcal{Q}^{0}(v)$, all paths $Q'$ of $\mathcal{Q}(v)$ whose corresponding edge $f_{Q'}\in \mathcal{Q}(v)$ has the same color as edge $f_Q$, to the same set of $\set{\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}}$.
And then we assign, for any color that is not used by edges in $\set{f_Q\mid Q\in \mathcal{Q}^{0}(v)}$, all paths whose corresponding edge $f_{Q'}\in \mathcal{Q}(v)$ has this color to a distinct set of $\set{\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}}$ that does not contain paths of $ \mathcal{Q}^{0}(v)$.
This completes the iteration of processing the vertex $v$.
Since edges of have different colors, it is clear that, after this iteration, each set of $\set{\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}}$ contains edge-disjoint paths.
Therefore, if we keep processing all vertices in this way, then we obtain a valid partition of the original set $\mathcal{Q}$ of paths into at most $d+1$ subsets $\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}$, such that the paths in each subset are edge-disjoint.
\end{proof}
We also study the case where the seller does not have the power of tie-breaking.
\begin{theorem}\label{thm:spider-no-tiebreak}
For any constant $\varepsilon>0$, there is an efficient algorithm, that, given any spider graph $G$ and any buyer-profile $\mathcal{F}=\set{(Q_j,v_j)}_{j\in [m]}$, computes a set of prices on edges of $G$ that achieves the worst-case revenue equal at least $(\frac{2}{7}-\varepsilon)\cdot\mathsf{OPT}(G,\mathcal{F})$, without the power of tie-breaking.
\end{theorem}
\begin{proof}
Let $\mathcal{Q}$ be the set of paths in the optimal allocation.
We define $\mathcal{Q}_1$ to be the set of all paths in $\mathcal{Q}$ that contains the center of the spider, and we define $\mathcal{Q}_2=\mathcal{Q}\setminus \mathcal{Q}_1$. For each path $Q\in \mathcal{Q}_1$, we define $G_Q$ to be the graph obtained by taking the union of all (one or two) legs whose edge sets intersect with $E(Q)$, and we denote $E_Q=E(G_Q)$. Then $E(G)=\bigcup_{Q\in \mathcal{Q}_1}E_Q$, and $\mathsf{OPT}(G,\mathcal{F})=\sum_{Q\in\mathcal{Q}_1}\mathsf{OPT}(G_Q,\mathcal{F})$.
Let $e_{Q,1}$ (and possibly $e_{Q,2}$) be the one (or two) edges that are in Q and has the spider center as one endpoint.
Define $G'_Q$ to be the graph with edge set $E'_Q=\{e|e\in E_Q\setminus Q\}$; in other words, $G'_Q$ contains all edges not in $Q$ but in $E_Q$, and $G''_Q$ contains all. Then $\mathsf{OPT}(G_Q,\mathcal{F})=\mathsf{OPT}(G'_Q,\mathcal{F})+v(Q)$. Define $G''_Q$ to be the graph with edge set $E''_Q=Q\setminus\{e_{Q,1},e_{Q,2}\}$; in other words, $G''_Q$ is the graph formed edges in $Q$, but excluding the center of the spider.
Let $\alpha_Q=\frac{\mathsf{OPT}(G''_Q,\mathcal{F})}{v(Q)}$. Clearly $\alpha_Q\leq 1$, since $E''_Q\subseteq Q$. The item pricing $p$ we construct sets one of the following two item pricings $p_1$ and $p_2$ on $E_Q$.
\begin{enumerate}
\item For each $e\in E'_Q$, $p_1(e)>\mathsf{OPT}(G,\mathcal{F})$ is large enough to prevent anyone from buying it; for each $e\in E''_Q$, $p_1(e)=p^*(e)+\frac{1}{n}\varepsilon$, where $p^*$ is the dual prices $p$ from Theorem~\ref{thm:path} on $G''_Q$ with welfare $\mathsf{OPT}(G''_Q,\mathcal{F})$; for each $e=e_{Q,1}$ or $e_{Q,2}$, $p_1(e)=\frac{(1-\alpha_Q)v(Q)}{2}-\varepsilon$. Then no buyer demanding a path containing an edge in $E'_Q$ can afford to pay her path. Also since the utility of any buyer in $\mathcal{F}$ is at most 0 in $p^*$, thus no buyer demanding a path with only edges in $E''_Q$ can afford to purchase her path. Also since the total price of edges in $Q$ is $\sum_{e\in E''_Q}p_1(e)+p_1(e_{Q,1})+p_1(e_{Q,2})<\mathsf{OPT}(G''_Q,\mathcal{F})+\varepsilon+(1-\alpha_Q)v(Q)-2\varepsilon<v(Q)$, thus the buyer with demand $Q$ has positive utility for purchasing her path. Therefore, if item pricing $p$ sets $p_1$ for edges in $E_Q$, at least one of $e_{Q,1}$ and $e_{Q,2}$ is sold under $p$, which contributes $\frac{(1-\alpha_Q)v(Q)}{2}-\frac{1}{n}\varepsilon$ revenue from edges in $E_Q$.
\item For each $e\in E'_Q\cup E''_Q$, $p_2(e)$ is the price of edge $e$ by applying Theorem~\ref{thm:path_no_tie} to $G'_Q\cup G''_Q$, which is a union of at most two path graphs; for each $e=e_{Q,1}$ or $e_{Q,2}$, $p_2(e)>\mathsf{OPT}(G,\mathcal{F})$ is large enough to prevent anyone from buying it. Then if item pricing $p$ sets $p_2$ for edges in $E_Q$, the total revenue from the two legs is at least $\frac{2}{3}\mathsf{OPT}(G'_Q\cup G''_Q,\mathcal{F})\geq \frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F})+\frac{2}{3}\mathsf{OPT}(G''_Q,\mathcal{F})=\frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F})+\frac{2}{3}\alpha_Qv(Q)$.
\end{enumerate}
Let item pricing $p$ sets prices $p_1$ on $E_Q$ if $\frac{(1-\alpha_Q)v(Q)}{2}-\varepsilon>\frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F})+\frac{2}{3}\alpha_Qv(Q)$, and sets prices $p_1$ on $E_Q$ otherwise. Then the revenue of $p$ is lower bounded by
\begin{eqnarray*}
& &\sum_{Q\in \mathcal{Q}_1}\max\left(\frac{(1-\alpha)v(Q)}{2}-\varepsilon,\frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F})+\frac{2}{3}\alpha_Qv(Q)\right)\\
&\geq&\sum_{Q\in \mathcal{Q}_1}\frac{4}{7}\left(\frac{(1-\alpha)v(Q)}{2}-\varepsilon\right)+\frac{3}{7}\left(\frac{2}{3}\mathsf{OPT}(G'_Q,\mathcal{F})+\frac{2}{3}\alpha_Qv(Q)\right)\\
&=&\sum_{Q\in \mathcal{Q}_1}\left(\frac{2}{7}v(Q)+\frac{2}{7}\mathsf{OPT}(G'_Q,\mathcal{F})-\frac{4}{7}\varepsilon\right)\\
&=&\sum_{Q\in \mathcal{Q}_1}\left(\frac{2}{7}\mathsf{OPT}(G_Q,\mathcal{F})-\frac{4}{7}\varepsilon\right)>\frac{2}{7}\mathsf{OPT}(G,\mathcal{F})-\frac{4n}{7}\varepsilon.
\end{eqnarray*}
The theorem is proved by scaling $\varepsilon$ properly.
\end{proof}
\subsubsection{Proof of Lemma~\ref{lem:spider-half-integral}}
\label{sec: Proof of spider-half-integral}
In this section we provide the proof of Lemma~\ref{lem:spider-half-integral}, using Lemma~\ref{lem:matching-half-integral}.
We first modify the buyer profile as follows. For each edge $e$ of $G$, we add a buyer $B_e$ who demands the path that contains a single edge $e$ and has value $0$ upon the path. Equivalently, we consider the following linear program.
\begin{eqnarray*}
\mbox{(LP-1)} &\text{maximize }
\sum_{j\in [m]}v_j\cdot y_j\\
\mbox{s.t.}
& \hat y_i+\sum_{j: e_i\in Q_j}y_j= 1&\forall\text{ }1\le i\le n\\
& y_j\ge 0&\forall\text{ } j\in [m]\\
& \hat y_i\ge 0&\forall\text{ } 1\le i\le n
\end{eqnarray*}
It is easy to see that (LP-1) is equivalent to (LP-Primal), in the sense that (i) their optimal values are the same; and (ii) any optimal solution to (LP-1) naturally induces an optimal solution to (LP-Primal), and vice versa.
Consider now an optimal solution $y^*=(y^*_j)_{j\in [m]}$ of (LP-Primal). We define $\hat y^*\in [0,1]^n$ as: for each $1\le i\le n$, $\hat y^*_i=1- \sum_{j: e_i\in Q_j}y^*_j$. It is easy to see that $(y^*,\hat y^*)$ is an optimal solution of (LP-1).
We will now construct a star graph $H$ and a buyer profile $\mathcal{F}'$ on $H$ as follows. Assume that the spider graph $G$ contains $\ell$ legs, and the $k$-th leg is denoted by $L_k$ (so $E(G)=\bigcup_{1\le k\le \ell}E(L_k)$).
Then $H$ is a star graph with $\ell$ edges, that are denoted by $\tilde e_{1}, \tilde e_2,\ldots,\tilde e_{\ell}$, respectively.
We now construct the buyer profile $\mathcal{F}'$ iteratively.
Denote $\mathcal{Q}=\set{Q_1,\ldots,Q_m}\cup \set{(e_i)\mid e_i\in E(G)}$.
Throughout, we maintain: (i) for each path $Q\in \mathcal{Q}$, a real number $x_Q$, that is initialized as follows: if $Q=Q_j$ for some $j\in [m]$, then $x_Q=y^*_j$; if $Q=(e_i)$ for some $e_i\in E(G)$, then $x_Q=\hat y^*_i$; and
(ii) a buyer profile $\mathcal{F}'$, that initially contains no buyers.
In each iteration, we will add one buyer into $\mathcal{F}'$ and modify the values $\set{x_Q}_{q\in \mathcal{Q}}$. We will maintain the invariant that for each $1\le k\le \ell$, the sum $Z_e=\sum_{Q: e\in Q}x_Q$ are the same for all edges $e\in E_k$ of the $k$-th leg are the same (but the sums $Z_e,Z_{e'}$ may be distinct for edges $e,e'$ that belong to distinct legs). Clearly, initially this invariant holds.
We now describe an iteration. Let $\hat Q=\arg_{Q\in \mathcal{Q}: x_Q\ne 0}\min\set{x_Q}$.
We consider the following two cases.
\textbf{Case 1. Path $\hat Q$ contains edges from two distinct legs.} Assume path $\hat Q$ contains some edges from $L_{k_1},L_{k_2}$. Let $P_1$ be the subpath of $L_{k_1}$ formed by edges of $L_{k_1}\setminus \hat Q$, and we define $P_2$ similarly. We denote by $v_1,v'_1$ the endpoints of $P_1$, where $v'_1$ is the leaf of the leg $L_{k_1}$. We use the following claim.
\begin{claim}
\label{clm: extending path}
If $P_1\ne \emptyset$, then there exists an path $Q\in \mathcal{Q}$, such that (i) $x_Q\ge x_{\hat Q}$; and (ii) $Q$ is a subpath of $P_1$ and contains $v_1$ as one of its endpoints.
\end{claim}
\begin{proof}
Denote by $\hat e,\hat e'$ the edges incident to $v_1$, where $\hat e$ belongs to $\hat Q$ and $\hat e'$ belongs to $P_1$.
Assume for contradiction that there is no such $Q$, then any path $Q\in \mathcal{Q}$ with $x_Q>0$ that contains edge $\hat e'$ must also contain edge $\hat e$. However, since edges $\hat e,\hat e'$ belong to the same leg, and the path $\hat Q$ contains $\hat e$ but not $\hat e'$, the invariant that $Z_{\hat e}=Z_{\hat e'}$ cannot hold, a contradiction.
\end{proof}
As an easy corollary of Claim~\ref{clm: extending path}, we can find a set $\mathcal{Q}'_1\subseteq \mathcal{Q}$ of paths, such that (i) the paths of $\mathcal{Q}'_1$ are edge-disjoint; (ii) the union of paths of $\mathcal{Q}'_1$ is $P_1$; and (iii) for each $Q\in \mathcal{Q}'_1$, the value $x_Q\ge x_{\hat Q}>0$.
Similarly, we can find a set $\mathcal{Q}'_2\subseteq \mathcal{Q}$ of paths, such that (i) the paths of $\mathcal{Q}'_2$ are edge-disjoint; (ii) the union of paths of $\mathcal{Q}'_2$ is $P_2$; and (iii) for each $Q\in \mathcal{Q}'_2$, the value $x_Q\ge x_{\hat Q}>0$.
Therefore, if we set $\mathcal{Q}'=\set{\hat Q}\cup \mathcal{Q}'_1\cup \mathcal{Q}'_2$, then the paths of $\mathcal{Q}'$ are edge-disjoint, their union is $L_{k_1}\cup L_{k_2}$, and for each path $Q\in \mathcal{Q}'$, $x_Q\ge x_{\hat Q}$.
We then add a buyer to $\mathcal{F}'$ as follows. Its demand path $P$ contains two edges $\tilde e_{k_1}, \tilde e_{k_1}$, and its value is defined as $v(P)=\sum_{Q\in \mathcal{Q}'}v(Q)$.
We also define $w^*_P=x_{\hat Q}$, and then we decrease the value $x_Q$ for all $Q\in \mathcal{Q}'$ by $x_{\hat Q}$.
\textbf{Case 2. Path $\hat Q$ contains edges from one leg.} Assume path $\hat Q$ contains only edges of $L_{k_1}$. We define path $P_1$ similarly as in Case 1. Via similar arguments, we can compute a set $\mathcal{Q}'_1$ of edge-disjoint paths whose union is $P_1$, and $x_Q\ge x_{\hat Q}> 0$ for each path $Q\in \mathcal{Q}'_1$.
We denote by $v_2$ the endpoint of $\hat Q$ that is closer to the center of the spider.
If $v_2$ is the center then we set $\mathcal{Q}'_2=\emptyset$.
Otherwise, by repeatedly applying Claim~\ref{clm: extending path} to the subpath of $L_{k_1}$ between $v_2$ and the center (that we denote by $P_2$), we can compute a set $\mathcal{Q}'_2$ of edge-disjoint paths with $x_Q\ge x_{\hat Q}> 0$ for each path $Q\in \mathcal{Q}'_2$, such that the union of paths of $\mathcal{Q}'_2$ is either $P_2$ or the union of $P_2$ with some other entire leg $L_{k_2}$.
Assume the former, then we add a buyer to $\mathcal{F}'$ as follows. Its demand path $P$ contains one edge $\tilde e_{k_1}$, and its value is defined as $v(P)=\sum_{Q\in \mathcal{Q}'}v(Q)$, where $\mathcal{Q}'=\set{\hat Q}\cup \mathcal{Q}'_1\cup \mathcal{Q}'_2$.
Assume the latter, then we add a buyer to $\mathcal{F}'$ as follows. Its demand path $P$ contains two edges $\tilde e_{k_1},e_{k_2}$, and its value is defined as $v(P)=\sum_{Q\in \mathcal{Q}'}v(Q)$.
In both cases, we also define $w^*_P=x_{\hat Q}$, and then we decrease the value $x_Q$ for all $Q\in \mathcal{Q}'$ by $x_{\hat Q}$.
We say that paths in $\mathcal{Q}'$ \emph{contributes} to path $P$.
This finishes the description of an iteration.
Clearly, after each iteration, the invariant that for each $1\le k\le \ell$, the sum $Z_e$ are the same for all edges $e\in E_k$ of the $k$-th leg are the same still holds. Moreover, the number of paths $Q$ in $\mathcal{Q}$ with $x_Q>0$ is decreased by at least one after each iteration. Therefore, the algorithm terminates in $n+m$ iterations.
At the end, $x_Q=0$ for all paths $Q\in \mathcal{Q}$.
Let $\mathcal{F}'=\set{(P,v_P)}_{P\in \mathcal{P}}$ be the buyer profile that we get at the end of the algorithm.
It is easy to see that (i) for each $j\in [m]$, $y^*_{j}=\sum_{P: Q_j\text{ contributes to }P}w^*_P$, and for each $1\le i\le n$, $\hat y^*_j=\sum_{P: (e_i)\text{ contributes to }P}w^*_P$; and (ii) $\sum_{P\in \mathcal{P}}v_P\cdot w^*_P=\sum_{j\in [m]}v_j\cdot y^*_j$.
We consider the following linear program.
\begin{eqnarray*}
\mbox{(LP-2)} &\text{maximize }
\sum_{P\in \mathcal{P}}v_P\cdot w_P\\
\mbox{s.t.}
& \sum_{P: \tilde e_i\in P}w_P= 1&\forall\text{ }1\le i\le \ell\\
& w_P\ge 0&\forall\text{ } P\le \mathcal{P}
\end{eqnarray*}
We now show that $w^*=(w^*_P)_{P\in \mathcal{P}}$ is an optimal solution of (LP-2). Assume the contrast that there exists another feasible solution $w'=(w'_P)_{P\in \mathcal{P}}$ of (LP-2), such that $\sum_{P\in \mathcal{P}}v_P\cdot w^*_P<\sum_{P\in \mathcal{P}}v_P\cdot w'_P$.
We define vector $y'\in [0,1]^m$ as: for each $j\in [m]$, $y'_j=\sum_{P: Q_j\text{ contributes to }P}w'_P$, and define vector $\hat y'\in [0,1]^n$ as: for each $1\le i\le n$, $\hat y'_j=\sum_{P: (e_i)\text{ contributes to }P}w'_P$. It is easy to see that $(y',\hat y')$ is a feasible solution to (LP-1), and moreover, $\sum_{j\in [m]}v_j\cdot y'_j=\sum_{P\in \mathcal{P}}v_P\cdot w'_P>\sum_{P\in \mathcal{P}}v_P\cdot w^*_P=\sum_{j\in [m]}v_j\cdot y^*_j$. This causes a contradiction to the optimality of $(y^*,\hat y^*)$.
Therefore, from Lemma~\ref{lem:matching-half-integral}, $w^*$ is half-integral. Since for each $j\in [m]$, $y^*_{j}=\sum_{P: Q_j\text{ contributes to }P}w^*_P$, and for each $1\le i\le n$, $\hat y^*_j=\sum_{P: (e_i)\text{ contributes to }P}w^*_P$, $(y^*,\hat y^*)$ is also half-integral. It follows that $y^*$ is half-integral.
\iffalse
Without loss of generality the same as in the star case we assume each edge is fully allocated. Suppose that we can partition paths $Q_j$ with positive allocation $y_j^*$ into multiple groups $\mathcal{Q}_1,\mathcal{Q}_2,\cdots,\mathcal{Q}_s$ with allocation $z_1,z_2,\cdots,z_s$ respectively, such that
\begin{itemize}
\item For each group $\mathcal{Q}_k$, the paths in it are edge-disjoint, and let $\cup\mathcal{Q}_k$ denote the union of the paths in $\mathcal{Q}_k$;
\item For each group $\mathcal{Q}_k$, $\cup\mathcal{Q}_k$ is either a full leg of the spider, or two full legs of the spider;
\item Each edge $e_i$ is allocated fractionally to exactly 1 group: $\sum_{j:e_i\in \mathcal{Q}_k}z_k=1$;
\item Each path $Q_j$ has the same total weight in the groups as before: $\sum_{k:Q_j\in \mathcal{Q}_k}z_k=y^*_j$.
\end{itemize}
Then we can treat the graph as a star, and each group $\mathcal{Q}_k$ as a ``mega path'' $\cup\mathcal{Q}_k$ with allocation $z_k$ and value $\sum_{Q_j\in \mathcal{Q}_k}v_j$ and apply Lemma~\ref{lem:matching-half-integral} in the star case.
Now we show that such collection $\mathcal{Q}_1,\mathcal{Q}_2,\cdots,\mathcal{Q}_\ell$ of sets of paths always exists. In fact, we prove the following stronger lemma.
\begin{lemma}\label{lem:findpathinspider}
Let $\mathcal{Q}$ be a collection of paths $Q_j$ with allocation $y_j$, such that for each leg $L$ of the spider, any two edges have equal total allocation $y_L$. Formally, there exists a constant $y_L$ such that for any $e_i\in L$, $\sum_{Q_j\ni e_i}y_j=y_L$.
\end{lemma}
\begin{proof}[Proof of Lemma~\ref{lem:findpathinspider}]
When there is only one path $Q_j$ in $\mathcal{Q}$, we only need to define $Q_1$ to contain only this path with allocation $z_1=y^*_j$. If there are multiple paths in $\mathcal{Q}$, find a path $Q_j\in \mathcal{Q}$ with minimum allocation $y_j$. Construct $\mathcal{Q}_1=\{Q_j\}$, and we will add more paths to it later.
Assume that $Q_j$ is contained in leg $L$, the case where $Q_j$ is contained in two legs is exactly the same. We also assume that the edges in $L$ ordered from center are $e_1,e_2,\cdots,e_t$, and $Q_j=\{e_\ell,e_{\ell+1},\cdots,e_{r-1},e_r\}$. If $r\neq t$, then there must exist a path $Q$ starting at edge $e_{r+1}$ and ends at some edge $e_a$ such that $a\geq r+1$: otherwise, every path in $\mathcal{Q}$ containing $e_{r+1}$ must contain $e_r$, then the total weight of paths in $\mathcal{Q}$ containing $e_{r+1}$ is strictly less than the total weight of paths in $\mathcal{Q}$ containing $e_r$, which contradicts the assumption of the lemma. Let $Q=\{e_{r+1},e_{r+2},\cdots,e_{r'}\}$, and we add $Q$ to $\mathcal{Q}_1$. Repeatedly find path $Q$ that is connected to $\cup\mathcal{Q}_1$ and add $Q$ to $\mathcal{Q}_1$, until $e_t\in \cup\mathcal{Q}_1$. Similarly, we can grow $\mathcal{Q}_1$ from the other end $e_{\ell}$, until $\cup\mathcal{Q}_1$ ends at edge $e_1$ or the end of another leg $L'$. By this way we find a set of disjoint and connected paths $\mathcal{Q}_1$ that span exactly one or two legs of the graph.
Figure~\ref{fig:spidertostar} gives an illustration of such expansion.
\begin{figure}[h]
\centering
\includegraphics[width=0.9\columnwidth]{spidertostar.pdf}
\caption{Examples of the expansion of path $Q_1$ and $Q_2$. We find a sequence of paths including $Q_1$ that span exactly two legs, and a sequence of paths including $Q_2$ that span exactly one leg.\label{fig:spidertostar}}
\end{figure}
Let $z_1=y_j$, and set $y_{j'}\leftarrow y_{j'}-y_j$ for all $Q_{j'}\in \mathcal{Q}_1$. The remaining set of paths still satisfy the assumption of the lemma, and the above process reduces the total number of paths with positive allocation by at least 1. Thus repeatedly apply the above process and we can find the feasible groups of path sets. This finishes the proof of Lemma~\ref{lem:findpathinspider}, and Lemma~\ref{lem:spider-half-integral} suffices.
\end{proof}
\fi
\iffalse
\todo{the following theorem is currently false}
\begin{theorem}
If we (the seller) has the power of tie-breaking, then there is an efficient algorithm, that, given any buyer-profile $\set{(Q_j,v_j)}_{j\in [m]}$, computes a set of prices $\set{p_e}_{e\in G}$ that achieves the revenue equal to the optimal offline welfare.
\end{theorem}
\begin{proof}
Let $H'$ be a weighted graph defined as follows. The vertex set of $H'$ is $\set{u_i\mid e_i\in E(G)}$. The edge set of $H'$ is $\set{(u_i,u_{i'})\mid \exists j, Q_j=(e_i,e_{i'})}$, and the weight for the edge $(u_i,u_{i'})$ is set to be $v_j$, that we also denote by $v(i,i')$.
We augment $H'$ into another graph $H$ as follows. For each $1\le i\le L$, if there exists a buyer whose demand is the single edge $e_i$, then we add a new node $w_i$, and connect $w_i$ to $u_i$ via an edge, whose weight is set to be the value of this buyer on this single-edge path, that we denote by $v(i)$.
Therefore, there is an one-to-one correspondence between the buyers and the edges in $H$.
It is clear that an optimal (offline) allocation corresponds to an maximum weight matching in $H$. We compute an optimal matching $M$ in $H$. We will now show that there is a set of prices $\set{p_e}_{e\in G}$ on the edges of $G$, such that, no matter what order in which the buyers come, the selling process (with the seller having tie-breaking power) can lead to the optimal allocation corresponding to $M$, and achieves the revenue $\mathsf{OPT}$, the welfare of the allocation corresponding to $M$.
Consider the following feasibility linear program.
\begin{eqnarray*}
\mbox{} &\text{minimize } 0\\
\mbox{s.t.}
& p_i+p_{i'}\leq v(i,i') &\forall\text{ } e=(u_i,u_{i'})\in M\\
& p_i\leq v(i) &\forall\text{ } e=(u_i,w_{i})\in M\\
& p_i+p_{i'}\geq v(i,i') &\forall\text{ } e=(u_i,u_{i'})\in E(H)\setminus M\\
& p_i\geq v(i) &\forall\text{ } e=(u_i,w_{i})\in E(H)\setminus M\\
& p_i\ge 0&\forall\text{ } 1\le i\le L
\end{eqnarray*}
Assume that the above LP is infeasible, then there exist four sets $\set{\alpha(i,i')}_{(u_i,u_{i'})\in M}$, $\set{\beta(i)}_{(u_i,w_{i})\in M}$, $\set{\gamma(i,i')}_{(u_i,u_{i'})\in E(H)\setminus M}$, $\set{\theta(i)}_{(u_i,w_{i})\in E(H)\setminus M}$
of real numbers, such that:
\begin{eqnarray*}
& \sum_{i}\beta(i)v(i)+\sum_{(i,i')}\alpha(i,i')v(i,i')<\sum_{i}\theta(i)v(i)+\sum_{(i,i')}\gamma(i,i')v(i,i')\\
& \beta(i)+\sum_{i':(u_i,u_{i'})\in M}\alpha(i,i')\geq \theta(i)+\sum_{i':(u_i,u_{i'})\in E(H)\setminus M}\gamma(i,i') &\forall\text{ } 1\le i\le L\\
& \alpha(i,i')\ge 0, \beta(i)\ge 0, \gamma(i,i')\ge 0, \theta(i)\ge 0&\forall\text{ } 1\le i,i'\le L
\end{eqnarray*}
{\color{red} Todo.}
\end{proof}
\fi
\subsection{Stars}\label{sec:star}
In this section we consider the case where graph $G$ is a star, and we denote $E(G)=\set{e_1,\ldots,e_n}$. The main result of this section is summarized in the following theorem.
\begin{theorem}
\label{thm:star2}
There is an efficient algorithm, that, given any star graph $G$ and any buyer-profile $\mathcal{F}=\set{(Q_j,v_j)}_{1\le j\le m}$, computes a set of prices on edges of $G$ that achieves the worst-case revenue equal at least $(2/3)\cdot\mathsf{OPT}(G,\mathcal{F})$, with the power of tie-breaking.
\end{theorem}
\begin{proof}
\iffalse
Consider the following weighted graph $H$: For every edge $e_i$ in $G$, construct a node $a_i$ in $H$; For every buyer $j$, add a dummy node $b_j$ to $H$; For every buyer $j$, since $G$ is a star, her demand set $Q_j$ is of size at most 2. If $|Q_j|=2$, add edge $\hat{e}_j=(a_i,a_{i'})$ with weight $v_j$ to $H$ where $Q_j=\{e_i,e_{i'}\}$. Otherwise, add edge $\hat{e}_j=(a_i,b_j)$ with weight $v_j$ to $H$ where $Q_j=\{e_i\}$. Note that every buyer's demand now becomes an edge in graph $H$. Then the optimal offline welfare is equal to the total weight of maximum weight matching in $H$. (LP-Primal) describes the LP relaxation of a maximum weight matching problem. We have the following lemma.
\fi
Consider the following linear program.
\begin{eqnarray*}
\mbox{(LP-Primal)} &\text{maximize }
\sum_{1\le j\le m}v_j\cdot y_j\\
\mbox{s.t.}
&\sum_{j: e_i\in Q_j}y_j\leq 1&\forall\text{ }1\le i\le n\\
& y_j\ge 0&\forall\text{ } 1\le j\le m
\end{eqnarray*}
The following lemma can be seen as a corollary of Claim 7 in~\cite{matchingLP}, which is probably a folklore result. For completeness, we provide its proof in Section~\ref{sec: proof of matching-half-integral}.
\begin{lemma}\label{lem:matching-half-integral}
If $G$ is a star graph, then (LP-Primal) is half-integral, and for each optimal solution $y^*\in \set{0,\frac 1 2,1}^{n}$, if we denote $J^*=\set{j\mid y^*_j=\frac{1}{2}}$ and define the graph $H$ as $V(H)=\set{u_i\mid e_i\in \bigcup_{j\in J^*}E(Q_j)}$ and $E(H)=\set{(u_i,u_{i'})\mid \exists j\in J^*, Q_j=(e_i,e_{i'})}$, then $H$ is the union of vertex-disjoint odd-length cycles.
\end{lemma}
Below is the Dual LP for (LP-Primal).
\begin{eqnarray*}
\mbox{(LP-Dual)} &\text{minimize }
\sum_{1\le i\le n}p(i)\\
\mbox{s.t.}
&\sum_{i: e_i\in Q_j}p(e_i)\geq v_j&\forall\text{ } 1\le j\le m\\
& p(e_i)\ge 0&\forall\text{ } 1\le i\le n
\end{eqnarray*}
We denote by $\mathsf{OPT}$ the optimal value of (LP-Primal), so $\mathsf{OPT}\ge \mathsf{OPT}(G,\mathcal{F})$.
Let $y^*=(y^*_j)_{1\le j\le m}$ be an optimal solution for (LP-Primal) and let $p^*=(p^*(e_i))_{1\le i\le n}$ be an optimal solution for (LP-Dual). From the strong duality, $\sum_{1\le j\le m}v_jy^*_j=\sum_{1\le i\le n}p^*(e_i)=\mathsf{OPT}$.
From the complementary slackness, for each $1\le j\le m$, $p^*(Q_j)=\sum_{i: e_i\in Q_j}p^*(e_i)\geq v_j$, and $p^*(Q_j)>v_j$ implies $y^*_j=0$.
We will show that, if we set, for each edge $e_i\in E(G)$, its price as $p^*(i)$, then we will obtain worst-case revenue at least $(2/3)\cdot\mathsf{OPT}$, which is at least $(2/3)\cdot\mathsf{OPT}(G,\mathcal{F})$, with the power of tie-breaking.
We now specify how we will use the power of tie-breaking.
Let $\mathcal{B}^0$ ($\mathcal{B}^1,\mathcal{B}^{1/2}$, resp.) be the set of all buyer $B_j$ with $y_j^*=0$ ($1,\frac{1}{2}$, resp.).
Note that for each $1\le j\le m$, $p^*(Q_j)\geq v_j$, and for each buyers $B_j$ in $\mathcal{B}^{1},\mathcal{B}^{1/2}$, $p^*(Q_j)=v_j$.
First, if some buyer of $\mathcal{B}^0$ comes, then either $p^*(Q_j)>v_j$, in which case the buyer cannot afford her demand path, or $p^*(Q_j)=v_j$, and in this case we do not let him take her demand path, using the power of tie-breaking.
Second, if some buyer of $\mathcal{B}^1$ comes, then $p^*(Q_j)=v_j$, and we let him take her demand path, using the power of tie-breaking.
It remains to consider buyers in $\mathcal{B}^{1/2}$.
We denote $J=\set{j\mid y^*_j=\frac{1}{2}}$.
From Lemma~\ref{lem:matching-half-integral}, the graph $H$ is the union of vertex-disjoint odd-length cycles.
It is easy to see that the edge set of every cycle can be partitioned into three subsets, such that the edges in each subset are vertex-disjoint. Therefore, the edges of $H$ can be partitioned into three subsets $E(H)=E_1\cup E_2\cup E_3$, such that the edges in set $E_w$ do not share vertices, for each $w\in \set{1,2,3}$.
Note that each edge of $H$ corresponds to a buyer $B_j$ and a demand path $Q_j$. We then define the weight of an edge $e\in E(H)$ as the value of the demand path $Q_j$ that it corresponds to, and we define the weight of $E_w$ as the total weight of all edges of $E_w$, for each $w\in \set{1,2,3}$.
Then the total weight of all edges in $H$ is $\sum_{j\in J}v_j$.
Assume without loss of generality that $E_1$ has the largest weight among $E_1,E_2,E_3$, then the total weight of $E_1$ is at least $\frac 1 3\cdot \sum_{j\in J}v_j$.
Whenever some buyer of $\mathcal{B}^{1/2}$ that corresponds to an edge of $E_1$ comes, we let him take her demand path, using the power of tie-breaking.
Whenever some buyer of $\mathcal{B}^{1/2}$ that corresponds to an edge of $E_2,E_3$ comes, we do not let him take her demand path, using the power of tie-breaking.
Clearly, in the above way of using the power of tie breaking, eventually buyers of $\mathcal{B}^1$ and buyers of $\mathcal{B}^{1/2}$ that correspond to an edge of $E_1$ will get their demand paths, at price $p^*$.
Therefore, the revenue we obtain is at least
$\sum_{B_j\in \mathcal{B}^1}v_j+\frac{1}{3}\cdot \sum_{j\in J}v_j\geq \frac{2}{3}\cdot\left(\sum_{B_j\in \mathcal{B}^1}v_j+\frac{1}{2}\cdot \sum_{j\in J}v_j\right)=\frac{2}{3}\cdot \mathsf{OPT}.$
\end{proof}
We complement Theorem~\ref{thm:star2} with the following theorem.
\begin{theorem}
\label{thm: star lower bound}
For any $\varepsilon>0$, there is a star graph $G$ together with a buyer profile $\mathcal{F}$, such that any set of prices on edges of $G$ can achieve worst-case revenue at most $(\frac{2}{3}+\varepsilon)\cdot\mathsf{OPT}(G,\mathcal{F})$, even with the power of tie-breaking.
\end{theorem}
\begin{proof}
Consider a star graph with four edges $e_1,e_2,e_3,e_4$.
The buyer-profile $\mathcal{F}$ is described as follows:
\begin{itemize}
\item Buyer $B_1$ demands the path $Q_1$ consisting of edges $e_1, e_2$, with value $v_1=1$;
\item Buyer $B_2$ demands the path $Q_2$ consisting of edges $e_1, e_3$, with value $v_2=2+\varepsilon'$;
\item Buyer $B_3$ demands the path $Q_3$ consisting of edges $e_1,e_4$, with value $v_3=2+\varepsilon'$;
\item Buyer $B_4$ demands the path $Q_4$ consisting of edges $e_3,e_4$, with value $v_4=2$.
\end{itemize}
It is clear that the optimal allocation is assigning the edges $e_1,e_2$ to $B_1$, and assigning the edges $e_3,e_4$ to $B_4$, and the optimal welfare is $\mathsf{OPT}(G,\mathcal{F})=3$. However, we will show that any set of prices on the edges may achieve the worst-case revenue at most $2+\varepsilon'$, even with the power of tie-breaking. Setting $\varepsilon'=3\varepsilon$, this implies Theorem~\ref{thm: star lower bound}.
Let $\set{p(e_i)}_{1\le i\le 4}$ be any set of prices.
If $p(Q_1)>1$, then the buyer $B_1$ cannot afford her demand path $Q_1$. Since each pair of paths in $Q_2, Q_3, Q_4$ shares an edge, at most one of buyers $B_2, B_3, B_4$ may get her demand path, so the revenue is at most $2+\varepsilon'$.
If $p(Q_4)>2$, then via similar arguments we can show that the revenue is at most $2+\varepsilon'$.
Consider now the case where $p(Q_1)\le 1$ and $p(Q_4)\le 2$. We have $p(e_1)\le 1$, and one of $p(e_3),p(e_4)$ is at most $1$. Assume w.l.o.g. that $p(e_3)\le 1$. We let the buyer $B_3$ comes first.
Note that $p(Q_3)=p(e_1)+p(e_3)\le 2<2+\varepsilon'$. Therefore, $B_3$ will get her demand path at price at most $2$, and later on no other buyer may get her path. Altogether, the worst-case revenue for any set $\set{p(e_i)}_{1\le i\le 4}$ of prices is at most $2+\varepsilon'$. This completes the proof of Theorem~\ref{thm: star lower bound}.
\end{proof}
We also consider the case where we do not have the power of tie-breaking in the following theorem.
\begin{theorem}
\label{thm:star}
For any $\epsilon>0$, there is an efficient algorithm, that, given any star graph $G$ and any buyer-profile $\mathcal{F}=\set{(Q_j,v_j)}_{1\le j\le m}$, computes a set of prices on edges of $G$ that achieves the worst-case revenue at least $(\frac{1}{2}-\epsilon)\cdot\mathsf{OPT}(G,\mathcal{F})$, even without the power of tie-breaking.
\end{theorem}
\begin{proof}
We first show that we can efficiently compute the optimal allocation. \todo{Should be removed?}
Let $\mathcal{Q}$ be the set of paths in the optimal allocation, so $\mathsf{OPT}=\sum_{Q_j\in \mathcal{Q}}v_j$.
We set the prices on the edges of $G$ as follows.
For each path $Q_j\in \mathcal{Q}$, if it contains a single edge $e_i$, then we set the price of $e_i$ to be $(1-\epsilon)\cdot v_j$; if it contains two edges $e_i,e_{i'}$, then we set the price of both $e_i$ and $e_{i'}$ to be $(\frac{1}{2}-\epsilon)\cdot v_j$.
For each edges that does not belong to any path of $\mathcal{Q}$, we set its price to be $+\infty$.
We now show that the above prices will achieve worst-case revenue at least $(\frac{1}{2}-\epsilon)\cdot\mathsf{OPT}(G,\mathcal{F})$, even without the power of tie-breaking. For a path $Q_j$ that contains a single edges $e_i$, it is clear that no matter in what order come the buyers, this edge will be taken by some buyer (not necessarily $B_j$) at price $v_j$.
For a path $Q_{j'}$ that contains two edges $e_{i},e_{i'}$, since the price for each of the edges is $(\frac{1}{2}-\epsilon)\cdot v_{j'}$, and the buyer $j'$ demands both of them with value $v_j$, it is clear that no matter in what order come the buyers, at least one of $e_{i},e_{i'}$ will be taken by some buyer (not necessarily $B_{j'}$) at price $(\frac{1}{2}-\epsilon)\cdot v_{j'}$. Altogether, we conclude that the revenue guaranteed by the pricing is at least $(\frac{1}{2}-\epsilon)\cdot\mathsf{OPT}(G,\mathcal{F})$.
\end{proof}
\subsubsection{Proof of Lemma~\ref{lem:matching-half-integral}}
\label{sec: proof of matching-half-integral}
In this section we provide the proof of Lemma~\ref{lem:matching-half-integral} for completeness.
Let $y$ be any optimal solution of (LP-Primal) that is an extreme point of the polytope defined by (LP-Primal).
Denote $J=\set{j\mid 0<y_j<1}$. We define a graph $\hat H$ according to $ J$ as follows.
The vertex set of $\hat H$ contains
(i) a vertex $u_i$ for each edge $e_i\in E(G)$; and
(ii) a vertex $\hat u_i$, for all $1\le i\le n$ such that there exists a buyer $B_j$ with $j\in J$ whose demand path $Q_j$ contains a single edge $e_i$.
In other words, $V(\hat H)=\set{u_1,\ldots,u_n}\cup \set{\hat u_i\mid \exists j\in J, Q_j=(e_{i})}$.
The edge set of $\hat H$ contains
(i) an edge $(u_i,u_{i'})$ for each demand path $Q_j=(e_{i},e_{i'})$ with $j\in J$; and
(ii) an edge $(u_i,\hat u_{i})$ for each demand path $Q_j=(e_{i})$ with $j\in J$.
In other words, $E(\hat H)=\set{(u_i,u_{i'})\mid \exists j\in J, Q_j=(e_{i},e_{i'})}\cup \set{(u_i,\hat u_{i})\mid \exists j\in J, Q_j=(e_{i})}$.
We say that a graph is \emph{Eulerian} iff the degree for each vertex is even. It is folklore that every Eulerian graph contains a trail that visits each edge once.
We use the following claim and its simple corollary.
\begin{claim}
\label{clm: no eulerian subgraph}
$\hat H$ does not contain an Eulerian subgraph with even number of edges.
\end{claim}
\begin{proof}
Assume the contrast that graph $\hat H$ does contain an Eulerian subgraph, and let $(u_{r_1},\ldots, u_{r_t},u_{r_1})$ be the trail that visits each edge of this Eulerian subgraph exactly once (note that such a trail may not contain vertices of $\set{\hat u_i\mid \exists j\in J, Q_j=(e_{i})}$).
Define
$$\hat J_0=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \set{r_k,r_{k+1}}=\set{i,i'}\text{ for some even }1\le k\le t};$$
and
$$\hat J_1=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \exists\text{ odd }k, \set{r_k,r_{k+1}}=\set{i,i'}}.$$
Clearly, sets $\hat J_0$ and $\hat J_1$ are disjoint.
We define $z\in \set{-1,0,1}^m$ to be the $m$-dimentional vector, such that, for each $1\le j\le m$, $z_j=1$ iff $j\in \hat J_0$, $z_j=-1$ iff $j\in \hat J_1$, and $z_j=0$ otherwise.
Let $\varepsilon$ be any constant such that $0<\varepsilon<\min\set{y_j,1-y_j \mid j\in J}$.
Clearly, vectors $y+\epsilon z$ and $y-\epsilon z$ are both feasible solutions of (LP-Primal). This contradicts the fact that $y$ is an extreme point of the polytope defined by (LP-Primal).
\end{proof}
As a corollary, all cycles of $\hat H$ contains odd number of edges, and all odd-cycles in $\hat H$ are vertex-disjoint. We further prove the following claim.
\begin{claim}
\label{clm: odd cycle in disjoint component}
Every odd cycle of $\hat H$ belongs to a distinct connected component of $\hat H$.
\end{claim}
\begin{proof}
If $\hat H$ does not contain any odd cycle or only contains one odd cycle, then there is nothing to prove. Assume the contrast that $\hat H$ contains two odd-cycles $C,C'$ lying in the same connected component of $\hat H$. Let $P$ be a path connecting a vertex $u$ of $C$ to a vertex $u'$ of $C'$.
Let $V(C)=\set{u,u_{i_1},\ldots,u_{i_r}}$, $V(C')=\set{u',u_{i'_1},\ldots,u_{i'_s}}$, and
$V(P)=\set{u,u_{i''_1},\ldots,u_{i''_t},u'}$, where $r,s$ are even and the vertices are indexed according to the order in which they appear on $C$, $C'$ or $P$.
Define
$$ J_0=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \set{i_k,i_{k+1}}=\set{i,i'}\text{ for some even }0\le k\le r};$$
$$ J_1=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \set{i_k,i_{k+1}}=\set{i,i'}\text{ for some odd }0\le k\le r};$$
$$ J_0'=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \set{i_k,i_{k+1}}=\set{i,i'}\text{ for some even }0\le k\le s};$$
$$ J_1'=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \set{i_k,i_{k+1}}=\set{i,i'}\text{ for some odd }0\le k\le s};$$
$$\quad \quad J_0''=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \set{i_k,i_{k+1}}=\set{i,i'}\text{ for some even }0\le k\le t}; \text{ and}$$
$$ J_1''=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } \set{i_k,i_{k+1}}=\set{i,i'}\text{ for some odd }0\le k\le t};$$
Let $z\in \set{0,1}^m$ be the vector such that for each $1\le j\le m$, $z_j=1$ iff $j\in J_0$, $z_j=-1$ iff $j\in J_1$, and $z_j=0$ otherwise.
We define vectors $z',z''$ according to sets $ J'_0, J'_1$ and sets $ J''_0, J''_1$ similarly.
Let $\varepsilon$ be any constant such that $0<\varepsilon<\min\set{y_j,1-y_j \mid j\in J}$.
If $t$ is odd, then we let $\tilde z=\epsilon z+ \epsilon z'-2\epsilon z''$; if $t$ is even, then we let $\tilde z=\epsilon z- \epsilon z'-2\epsilon z''$.
Clearly, vectors $y+\tilde z$ and $y-\tilde z$ are both feasible solutions of (LP-Primal). This contradicts the fact that $y$ is an extreme point of the polytope defined by (LP-Primal).
\end{proof}
As a corollary, each connected component of $\hat H$ is either a tree itself, or the union of an odd cycle with some disjoint trees, each sharing a distinct vertex with the cycle. contains odd number of edges, and all odd-cycles in $\hat H$ are vertex-disjoint. We further prove the following claim.
\begin{claim}
\label{clm: no tree component}
No connected component of $\hat H$ is a tree.
\end{claim}
\begin{proof}
Assume the contrast that $\hat H$ has a connected component that is a tree. Let $T$ be such a tree and we root $T$ at an arbitrary vertex of $T$.
We say that an edge $(u',u'')$ (where $u'$ is the parent vertex of $u''$ in $T$) of $T$ is a \emph{type-$0$} edge iff the tree-distance between $u$ and $u'$ in $T$ is even; otherwise we say that it is a \emph{type-$1$} edge.
We define
$ J_0=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } (u_i,u_{i'})\text{ is a type-0 edge}}$,
and
$ J_1=\set{j\mid Q_j=(e_i,e_{i'}), \text{ s.t. } (u_i,u_{i'})\text{ is a type-1 edge}}$.
Claim~\ref{clm: no tree component} follows from similar arguments in the proof of Claim~\ref{clm: no eulerian subgraph}.
\end{proof}
Via similar arguments in the proof of Claim~\ref{clm: odd cycle in disjoint component}, we can prove the following claim.
\begin{claim}
\label{clm: no odd cycle plus something component}
No connected component of $\hat H$ contains an odd-cycle and at least one non-cycle edge.
\end{claim}
Combining Claim~\ref{clm: no eulerian subgraph}, Claim \ref{clm: odd cycle in disjoint component}, Claim~\ref{clm: no tree component} and Claim~\ref{clm: no odd cycle plus something component}, every connected component of $\hat H$ is a single odd-cycle.
It remains to show that all coordinates of $\set{y_j}_{j\in J}$ are $1/2$. Consider an odd cycle $C$ with $V(C)=\set{u_{i_1},\ldots,u_{i_r}}$ (where $r$ is odd), where the vertices are indexed in the same order in which they appear on $C$.
For each $1\le t\le r$, let $Q_{j_t}$ be the path that contains edges $e_{i_t},e_{i_{t+1}}$.
Via similar arguments in the proof of Claim~\ref{clm: odd cycle in disjoint component}, we can show that $y_{j_t}+y_{j_{t+1}}=1$ for all $1\le t\le r$. Since $r$ is odd, we conclude that $y_{j_t}=1/2$ for all $1\le t\le r$. This completes the proof of Lemma~\ref{lem:matching-half-integral}.
\iffalse
We start with any optimal fractional solution $y$ from the LP. Assume that every edge is fully allocated, i.e. $\sum_{j: e_i\in Q_j}y_j=1$ for each edge $e_i$. This is without loss of generality since for every path on the graph we can add a dummy buyer with value $0$, and this will not change the optimal welfare and the prices in the dual LP.
Construct the following dual graph $G'$ of the star graph $G$ according to the fractional allocation $y$. For each edge $e_i\in G$, there is a corresponding vertex $i\in G$. For each path $Q_j=(e_i,e_{i'})$ with allocation $y_j>0$, there is an edge $e'=(i,i')\in G'$ with weight $w(e')=y_j$ and value $v_j$; if the path $Q_j=(e_i)$ contains only a single edge, there is a self loop $e'=(i,i)\in G'$ with weight $w(e')=y_j$. Since each edge is fully allocated in $G$, the sum of weight of the edges connected to any vertex in $G'$ is 1. An example of the transformation is shown in Figure~\ref{fig:startograph}, where orange paths have positive allocation.
\begin{figure}[h]
\centering
\includegraphics[width=0.7\columnwidth]{startograph.pdf}
\znote{subfigure}
\caption{An example of the dual graph of paths on the star.\label{fig:startograph}}
\end{figure}
For any isolated edge $(i,i')\in G'$ that is not connected to any other edge, since the sum of weight of the edges connected to any vertex in $G'$ is 1, the allocation of corresponding path $(e_i,e_{i'})$ is also 1. For any cycle in $G'$ with odd number of edges, if there is no other edge connected to it, the only case where the sum of weight of the edges connected to any vertex in such isolated odd cycle is 1 is when the weight of all edges of the odd cycle is $\frac{1}{2}$, and the allocation of the corresponding path is also $\frac{1}{2}$. To prove that there exists an optimal half-integral solution, we only need to show that there exists an alternative assignment of weights on the edges, such that the sum of weighted value of edges is unchanged, and the graph of edges with positive weight only contains isolated edges and isolated odd cycles.
We start with any optimal weight assignment $w$ on the edges in $G'$. If $G'$ contains any even-length cycle $i_1\to i_2\to\cdots\to i_{2k}\to i_{2k+1}=i_1$ ignoring self-loops, the weight of each edge $(i_{t},i_{t+1})$ must be in range $(0,1)$ since the total weight of the edges connected to any vertex in $G'$ is 1. Define $\epsilon=\min_{1\leq t\leq 2k}\min(w(i_t,i_{t+1}),1-w(i_t,i_{t+1}))$ be the smallest difference between the weight of any edge in the cycle and 0 or 1. Let $w'$ be the following assignment of weights on the edges: for any edge $e'\in G'$ that is not in the cycle, $w'(e')=w(e')$; for any integer $1\leq\ell\leq k$, $w'(i_{2\ell-1},i_{2\ell})=w(i_{2\ell-1},i_{2\ell})+\epsilon$, $w'(i_{2\ell},i_{2\ell+1})=w(i_{2\ell},i_{2\ell+1})-\epsilon$. Let $w''$ be the following weight assignment on the edges: for any edge $e'\in G'$ that is not in the cycle, $w''(e')=w(e')$; for any integer $1\leq\ell\leq k$, $w''(i_{2\ell-1},i_{2\ell})=w(i_{2\ell-1},i_{2\ell})-\epsilon$, $w''(i_{2\ell},i_{2\ell+1})=w(i_{2\ell},i_{2\ell+1})+\epsilon$. Intuitively, in $w'$ and $w''$, for each pair of connected edges in the cycle, the weight of one edge reduces by $\epsilon$, while the weight of the other edge increases by $\epsilon$. See Figure~\ref{fig:evencycle} for a transformation example.
\begin{figure}[h]
\centering
\includegraphics[width=0.7\columnwidth]{evencycle.pdf}
\caption{An example of the two possible perturbations of an even cycle.\label{fig:evencycle}}
\end{figure}
Then by the definition of $\epsilon$, the weight of each edge in $w'$ and $w''$ is still between 0 and 1, while the total weight of the edges connected to any vertex is still 1. Thus $w'$ and $w''$ are two feasible weight assignments on edges, and the average of $w'(e')$ and $w''(e')$ on any edge $e'\in G'$ is exactly $w(e')$. Therefore one of $w'$ and $w''$ has at least the same total weighted value as $w$; actually since $w$ is optimal, both $w'$ and $w''$ has the same total weighted value as $w$. Notice that by definition of $\epsilon$, there exists an edge $(i_t,i_{t+1})$ such that its weight in one of $w'$ and $w''$ (without loss of generality assume it's $w'$) is either 0 or 1. If $w'(i_t,i_{t+1})=0$, then the number of edges of positive weight in $w'$ is smaller than $w$; if $w'(i_t,i_{t+1})=1$, then since the total weight of the edges connected to $i_t$ is still 1, we know that $w'(i_{i-1},i_t)=0$, thus the number of edges of positive weight in $w'$ is smaller than $w$. This means that we can then replace the optimal allocation $w$ with $w'$, and after repeating the operation for finite number of rounds
the remaining graph $G'$ will have no even cycle.
What's the structure of the graph $G'$ with no even cycle? Each connected component must be a ``tree of odd cycles'', which can be constructed by starting with a tree $T$, and replace some nodes of the tree by cycles of odd length. Notice that since each edge in $G'$ has a positive weight, each leaf node in $T$ must be replaced by a self-loop in $G'$, otherwise such connected component must be an isolated edge. If $G'$ does not only contain isolated edges and isolated cycles, then $G'$ must contain a subgraph $H$ with the following structure: $H$ consists of two odd cycles $C_1:i_1\to i_2\to\cdots\to i_{2k+1}\to i_{2k+2}=i_1)$ and $C_2:i'_1\to i'_2\to \cdots\to i'_{2\ell+1}\to i'_{2\ell+2}=i'_1$, while there is a stem path $L:i_1=i''_1\to i''_2\to\cdots\to i''_s=i'_1$ between the two cycles. We allow the length of the stem path to be zero. If a cycle is a self loop, we will merge it with the stem path: for example, if $C_2$ is a self loop, we will set $L$ to be $i_1=i''_1\to i''_2\to\cdots\to i''_s\to i''_s$. In the later proof, when we refer to a cycle $C_i$, we will assume that it has length at least 3. Define $\epsilon=\min\left(\frac{1}{2}\min_{e'\in L}\min(w(e'),1-w(e')),\min_{e'\in H\setminus L}\min(w(e'),1-w(e'))\right)$ be the smallest difference between the weight of any edge in the subgraph and 0 or 1, while the difference doubled for the edges not on the stem. Similar to the case of even cycle, we find two different weight allocations of edges $w'$ and $w''$, such that
\begin{itemize}
\item The weight of each edge not in $H$ is unchanged in $w'$ and $w''$ compared to $w$;
\item The weight of each edge in $L$ increases or decreases by $2\epsilon$ in $w'$ and $w''$;
\item The weight of each edge in $H\setminus L$ increases or decreases by $\epsilon$ in $w'$ and $w''$;
\item The total weight of the edges connected to any vertex is still 1 in $w'$ and $w''$.
\end{itemize}
See Figure~\ref{fig:oddcycle} for a transformation example without self-loop, and Figure~\ref{fig:oddselfcycle} for a transformation example with one of the odd cycles being a self-loop.
\begin{figure}[h]
\centering
\includegraphics[width=0.7\columnwidth]{oddcycle.pdf}
\caption{An example of the two possible perturbations of two connected odd cycles without self-loop.\label{fig:oddcycle}}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[width=0.7\columnwidth]{oddselfcycle.pdf}
\caption{An example of the two possible perturbations of two connected odd cycles with self-loop.\label{fig:oddselfcycle}}
\end{figure}
The same as in the even-cycle case, the weight of each edge in $w'$ and $w''$ is still between 0 and 1. Thus $w'$ and $w''$ are two feasible weight assignments on edges, and the average of $w'(e')$ and $w''(e')$ on any edge $e'\in G'$ is exactly $w(e')$, then both $w'$ and $w''$ has the same total weighted value as $w$. Notice that by definition of $\epsilon$, there exists an edge in $H$ such that its weight in one of $w'$ and $w''$ (without loss of generality assume it's $w'$) is either 0 or 1. Using the same argument as in the even-cycle case the number of edges of positive weight in $w'$ is smaller than $w$. Then we can then replace the optimal allocation $w$ with $w'$, and after repeating the operation for finite number of rounds the remaining graph $G'$ will have no subgraph with such a structure like $H$.
After the above operations, we finally get a graph $G'$ such that each of its connected component is either an edge or an odd cycle. This finishes the proof of the lemma.
\fi
\subsection{Stars and Spiders}\label{sec:star_and_spider}
We first consider the case where the underlying graph $G$ is a star or a spider graph. A \emph{spider} $G$ is a tree with one vertex $u$ of degree at least 3 and all others with degree at most 2. In other words, $E(G)$ can be decomposed into $k$ paths, where any two paths only intersect at $u$. Star is a special spider graph, where all vertices other than $u$ has degree 1.
See \Cref{fig:star_spider} for an example.
\begin{figure}[h]
\centering
\subfigure[A star.]{\scalebox{0.08}{\includegraphics{star.jpg}}}
\hspace{5pt}
\subfigure[A spider.]{\scalebox{0.08}{\includegraphics{spider.jpg}}}
\caption{An illustration of stars and spiders.\label{fig:star_spider}}
\end{figure}
As a warm-up, we first prove that the competitive ratio of any star graph is at most $3/2$. For star graphs, let $E(G)=\{e_1,\ldots,e_m\}$.
\begin{theorem}
\label{thm:star2}
$\emph{\textnormal{\textsf{gap}}}(\mathsf{Star})\leq 3/2$. Moreover, the set of prices that achieves the competitive ratio $3/2$ can be computed efficiently.
\end{theorem}
Here is our plan for the proof: We round the optimal solution of (LP-Primal) to get a feasible integral solution with a total value of at least $2/3\cdot \mathsf{OPT}$, and then apply Lemma~\ref{lem:rounding}. One crucial lemma we use here is that, if the input graph is a star, then (LP-Primal) contains a half-integral optimal solution, i.e. an vector in $\{0,\frac{1}{2},1\}^n$ that achieves the optimal objective value. This lemma was also proved in~\cite{matchingLP}.
For completeness, we include a proof of Lemma~\ref{lem:matching-half-integral} in Appendix~\ref{subsec:appx_star_and_spider}.
\begin{lemma}\label{lem:matching-half-integral}\cite{matchingLP}
If $G$ is a star graph, then (LP-Primal) is half-integral, and for each optimal solution $y^*\in \set{0,\frac 1 2,1}^{n}$, if we denote $J^*=\set{j\mid y^*_j=\frac{1}{2}}$ and define the graph $H$ as $V(H)=\set{u_i\mid e_i\in \bigcup_{j\in J^*}Q_j}$ and $E(H)=\set{(u_i,u_{i'})\mid \exists j\in J^*, Q_j=\{e_i,e_{i'}\}}$, then $H$ is the union of vertex-disjoint odd-length cycles.
\end{lemma}
\begin{prevproof}{Theorem}{thm:star2}
Without loss of generality, we assume that for every $i,i'\in [m]$, at most one buyer has demand path $\{e_i,e_{i'}\}$, otherwise we only keep the buyer with the largest value. Let $y^*$ be the optimal solution of (LP-Primal). Let $\mathcal{B}^0$ ($\mathcal{B}^1,\mathcal{B}^{1/2}$, resp.) be the set of all buyer $j$ with $y_j^*=0$ ($1,\frac{1}{2}$, resp.).
For buyers in $\mathcal{B}^{1/2}$, define the graph $H$ as $V(H)=\set{u_i\mid e_i\in \bigcup_{j\in \mathcal{B}^{1/2}}Q_j}$ and $E(H)=\set{(u_i,u_{i'})\mid \exists j\in \mathcal{B}^{1/2}, Q_j=\{e_i,e_{i'}\}}$, then from Lemma~\ref{lem:matching-half-integral}, $H$ is the union of vertex-disjoint odd-length cycles. It's easy to verify that the edge set of every cycle can be partitioned into three subsets, such that the edges in each subset are vertex-disjoint. Therefore, the edges of $H$ can be partitioned into three subsets $E(H)=E_1\cup E_2\cup E_3$, such that the edges in set $E_w$ do not share vertices, for each $w\in \set{1,2,3}$.
Note that each edge of $H$ corresponds to the demand path $Q_j$ of a unique buyer $j\in \mathcal{B}^{1/2}$. For simplicity we denote $\hat{e}_j$ the edge of $H$ matched to buyer $j$. Without loss of generality, assume $\sum_{j:\hat{e}_j\in E_1}\geq \frac{1}{3}\cdot \sum_{j\in \mathcal{B}^{1/2}}v_j$. We construct a feasible integral solution $y$ as follows. For every $j\in \mathcal{B}^1$, let $y_j=y_j^*=1$; For every $j\in \mathcal{B}^{1/2}$ such that $\hat{e}_j\in E_1$, let $y_j=1$; For other $j$, let $y_j=0$. Note that the fact that edges in $E_1$ is node-disjoint implies that demand paths $\{Q_j\mid \hat{e}_j\in E_1\}$ are edge-disjoint. Also, since $y^*$ is feasible, it's clear that the demand path for buyer $j\in \mathcal{B}^1$ does not intersect with the demand path for $j\in \mathcal{B}^{1/2}$. Thus $y$ is feasible.
To finish the proof, we notice that
$$\sum_{j:y_j=1}v_j\geq \sum_{j\in \mathcal{B}^1}v_j+\frac{1}{3}\cdot \sum_{j\in \mathcal{B}^{1/2}}v_j\geq \frac{2}{3}\cdot\left(\sum_{B_j\in \mathcal{B}^1}v_j+\frac{1}{2}\cdot \sum_{j\in \mathcal{B}^{1/2}}v_j\right)=\frac{2}{3}\cdot \mathsf{OPT}_{\mathsf{LP}}\geq \frac{2}{3}\mathsf{OPT}.$$
Applying Lemma~\ref{lem:rounding} finishes the proof.
\end{prevproof}
We prove in the following theorem that the $3/2$ competitive ratio is tight for star graphs.
\begin{theorem}
\label{thm: star lower bound}
For any $\varepsilon>0$, $\emph{\textnormal{\textsf{gap}}}(\mathsf{Star})>3/2-\varepsilon$.
\end{theorem}
\begin{proof}
Consider a star graph with four edges $e_1,e_2,e_3,e_4$.
The instance $\mathcal{F}$ is described as follows:
\begin{itemize}
\item Buyer 1 demands the path $Q_1$ consisting of edges $e_1, e_2$, with value $v_1=1$;
\item Buyer 2 demands the path $Q_2$ consisting of edges $e_1, e_3$, with value $v_2=2+\varepsilon$;
\item Buyer 3 demands the path $Q_3$ consisting of edges $e_1,e_4$, with value $v_3=2+\varepsilon$;
\item Buyer 4 demands the path $Q_4$ consisting of edges $e_3,e_4$, with value $v_4=2$.
\end{itemize}
It is clear that the optimal allocation is assigning the edges $e_1,e_2$ to buyer 1, and assigning the edges $e_3,e_4$ to buyer 4. The optimal welfare is $\mathsf{OPT}(G,\mathcal{F})=3$. However, we will show that any set of prices on the edges achieve the worst-case welfare at most $2+\varepsilon$. Then $\textnormal{\textsf{gap}}(\text{Star})\geq \frac{3}{2+\varepsilon}>\frac{3}{2}-\varepsilon$.
Let $\set{p_i}_{1\le i\le 4}$ be any set of prices.
If $p(Q_1)>1$, then buyer 1 cannot afford her demand path $Q_1$. Since each pair of paths in $Q_2, Q_3, Q_4$ shares an edge, at most one of buyers $2,3,4$ may get her demand path, so the welfare is at most $2+\varepsilon$.
If $p(Q_4)>2$, then via similar arguments we can show that the welfare is at most $2+\varepsilon$.
Consider now the case where $p(Q_1)=p_1+p_2\le 1$ and $p(Q_4)=p_3+p_4\le 2$. We have $p_1\le 1$, and one of $p_3,p_4$ is at most $1$. Assume w.l.o.g. that $p_3\le 1$. We let buyer 3 comes first.
Note that $p(Q_3)=p_1+p_3\le 2<2+\varepsilon$. Therefore, buyer 3 will get her demand path, and later on no other buyer may get her path. Altogether, the worst-case welfare for any set of prices is at most $2+\varepsilon$. This completes the proof of Theorem~\ref{thm: star lower bound}.
\end{proof}
Now we come to spider graphs. We prove that the competitive ratio is at most $3/2$ for any spider graph. Note that the ratio is tight according to Theorem~\ref{thm: star lower bound}.
\begin{theorem}
\label{thm:spiderimproved}
$\emph{\textnormal{\textsf{gap}}}(\mathsf{Spider})\leq 3/2$. Moreover, the set of prices that achieves the competitive ratio $3/2$ can be computed efficiently.
\end{theorem}
Similar to the proof of Theorem~\ref{thm:star2}, we prove in the following lemma that (LP-Primal) has a half-integral optimal solution. The proof uses Lemma~\ref{lem:matching-half-integral}
and is postponed to Appendix~\ref{subsec:appx_star_and_spider}.
\begin{lemma}\label{lem:spider-half-integral}
If $G$ is a spider graph, then (LP-Primal) has a half-integral optimal solution. Moreover, such a solution can be computed efficiently.
\end{lemma}
\begin{prevproof}{Theorem}{thm:spiderimproved}
Let $y^*$ be a half-integral optimal solution of (LP-Primal) given by Lemma~\ref{lem:spider-half-integral}. Denote $\mathcal{B}^{1/2}=\set{j\mid y^*_j=1/2}$ and $\mathcal{B}^1=\set{j\mid y^*_j=1}$. Since $y^*$ is feasible, paths $\set{Q_j\mid j\in \mathcal{B}^1}$ are edge-disjoint, and they do not share the same edge with paths $\set{Q_j\mid j\in \mathcal{B}^{1/2}}$. We will show that we can efficiently compute a subset $\mathcal{B}'\subseteq \mathcal{B}^{1/2}$, such that (i) the paths $\set{Q_j\mid j\in \mathcal{B}'}$ are edge-disjoint; and (ii) the total value of paths in $\set{Q_j\mid j\in \mathcal{B}'}$ is at least $\frac{1}{3}\cdot \sum_{j\in \mathcal{B}^{1/2}}v_j$. If so, we let $y_j=\mathbf{1}[j\in \mathcal{B}^1\cup \mathcal{B}']$. Then $y=\{y_j\}_{j\in [n]}$ is a feasible integral solution of (LP-Primal). Moreover,
$$\sum_{j:y_j=1}v_j\geq \sum_{j\in \mathcal{B}^1}v_j+\frac{1}{3}\cdot \sum_{j\in \mathcal{B}^{1/2}}v_j\geq \frac{2}{3}\cdot\left(\sum_{B_j\in \mathcal{B}^1}v_j+\frac{1}{2}\cdot \sum_{j\in \mathcal{B}^{1/2}}v_j\right)=\frac{2}{3}\cdot \mathsf{OPT}_{\mathsf{LP}}\geq \frac{2}{3}\mathsf{OPT}.$$
Thus applying Lemma~\ref{lem:rounding} finishes the proof.
To find a subset $\mathcal{B}'$ that satisfies both properties, we prove the following structural lemma for trees. The proof of the lemma is postponed to Appendix~\ref{subsec:appx_star_and_spider}.
\begin{lemma}\label{lem:tree-coloring}
Let $T$ be a tree, let $d\geq 2$ be an integer and let $\mathcal{Q}$ be a set of paths in $T$, such that every edge of $T$ appears in at most $d$ paths of $\mathcal{Q}$, then we can efficiently compute a partition of $\mathcal{Q}$ into $d+1$ subsets $\mathcal{Q}_1,\ldots,\mathcal{Q}_{d+1}$, such that for every $1\le i\le d+1$, paths in $\mathcal{Q}_i$ are edge-disjoint.
\end{lemma}
Now since $y^*$ is a feasible solution of (LP-Primal), $y^*_j=1/2$ for each $j\in \mathcal{B}^{1/2}$. Thus every edge of $G$ is contained in at most $2$ paths in $\mathcal{Q}=\{Q_j\mid j\in \mathcal{B}^{1/2}\}$. By Lemma~\ref{lem:spider-half-integral}, we can efficiently obtain a partition $(\mathcal{Q}_1,\mathcal{Q}_2, \mathcal{Q}_3)$ of $\mathcal{Q}$, such that for each $1\le i\le 3$, paths in $\mathcal{Q}_i$ are edge-disjoint.
Therefore, at least one of sets $\mathcal{Q}_1,\mathcal{Q}_2,\mathcal{Q}_3$ contains edge-disjoint paths of total value at least $\frac{1}{3}\sum_{j\in \mathcal{B}^{1/2}}v_j$. This completes the proof of Theorem~\ref{thm:spiderimproved}.
\end{prevproof}
\subsection{Trees}\label{sec:tree}
Now we consider trees. In this section we prove that the competitive ratio of any tree graph is at most 3.
\begin{theorem}
\label{thm: tree}
$\emph{\textnormal{\textsf{gap}}}(\mathsf{Tree})\leq 3$. Moreover, the prices that achieve the competitive ratio 3 can be computed efficiently.
\end{theorem}
The remainder of this section is dedicated to the proof of \Cref{thm: tree}. In Section~\ref{sec:star_and_spider}, we prove that when $G$ is a spider (and star), there exists a half-integral optimal solution for (LP-Primal). This is necessary to achieve a feasible allocation through rounding, whose total welfare is at least $2/3\cdot \mathsf{OPT}$. However, this does not hold for general tree graphs. In fact, we show in Lemma~\ref{lem:tree-example} that, for trees, the optimal solution for (LP-Primal) may contain a positive value with an arbitrarily large denominator.
\begin{lemma}\label{lem:tree-example}
For any integer $d>0$, there exists a tree $G$ and an instance $\mathcal{F}$, such that every coordinate of the unique optimal solution of (LP-Primal) is either $1/d$ or $(d-1)/d$.
\end{lemma}
\begin{proof}
We construct a tree $G$ as follows. The vertex set is $V(G)=\set{u_i,v_i\mid 0\le i\le 2d}$. The edge set is $E(G)=\set{u_0,v_0}\cup \set{(u_i,u_0),(v_i,v_0)\mid 1\le i\le 2d}$.
Consider the following instance $\mathcal{F}$: It contains (i) for each $1\le j\le 2d$, a buyer $B_j$ that demands the path $Q_j=(u_j,u_0,v_0,v_j)$ with value $3$; (ii) for each $1\le k\le d$, a buyer $B^u_k$ that demands the path $Q^u_k=(u_{2k-1},u_0,u_{2k})$ with value $2$; and (iii) for each $1\le k\le d$, a buyer $B^v_k$ that demands the path $Q^v_k=(v_{2k},v_0,v_{2k+1})$ with value $2$. See Figure~\ref{fig:d-integral} for an illustration.
It is not hard to see that $G$ is a tree, and in the unique optimal solution $y$ of (LP-Primal), for each path $Q_j$, $y_j=1/d$; and for each path $Q^u_k$ and each path $Q^v_{k'}$, $y_{u,k}=y_{v,k'}=(d-1)/d$.
\begin{figure}[h]
\centering
\includegraphics[width=0.4\columnwidth]{d-integral.jpg}
\caption{An illustration of graph $G$, where paths of $\set{Q_1,\ldots,Q_{2d}}$ are shown in orange, and paths of $\set{Q^u_1,\ldots,Q^u_{k}}\cup \set{Q^v_1,\ldots,Q^v_{k}}$ are shown in purple.\label{fig:d-integral}}
\end{figure}
\end{proof}
To prove Theorem~\ref{thm: tree}, we use a different approach from Section~\ref{sec:star_and_spider}. We prove the following structural lemma, which partitions a set of edge-disjoint paths into two sets, such that each set of paths forms a union of vertex-disjoint spider graphs. And then we apply Theorem~\ref{thm:spiderimproved} to get the desired set of prices.
\begin{lemma}\label{lem:treetospider}
Let $P_1,\ldots,P_n$ be edge-disjoint paths, such that the graph $G=\bigcup_{j\in [n]}P_j$ is a tree, then the set $\mathcal{P}=\set{P_1,\ldots,P_n}$ can be partitioned into two sets $\mathcal{P}=\mathcal{P}'\cup\mathcal{P}''$, such that both the graph induced by paths in $\mathcal{P}'$ and the graph induced by paths in $\mathcal{P}''$ are the union of vertex-disjoint spiders.
\end{lemma}
\begin{proof}
We choose arbitrarily a vertex $r\in V(G)$ as designate it as the root of the tree.
We iteratively construct a sequence of subsets of $\mathcal{P}$ as follows.
We first let $\mathcal{P}_1$ contains all paths of $\mathcal{P}$ that contains the vertex $r$.
Then for each $i>1$, as long as $\mathcal{P}\ne \bigcup_{1\le t\le i-1}\mathcal{P}_t$, we let $\mathcal{P}_i$ contains all paths in $\mathcal{P}\setminus \left(\bigcup_{1\le t\le i-1}\mathcal{P}_t\right)$ that shares a vertex with a path in $\mathcal{P}_{i-1}$.
We continue this process until all paths of $\mathcal{P}$ are included in sets $\mathcal{P}_1,\ldots,\mathcal{P}_k$ for some $k$.
See Figure~\ref{fig:spider_decomp} for an illustration.
We then let $\mathcal{P}'=\bigcup_{0\le t\le \lfloor{k/2}\rfloor}\mathcal{P}_{2t+1}$ and $\mathcal{P}''=\bigcup_{1\le t\le \lfloor{k/2}\rfloor}\mathcal{P}_{2t}$. This completes the construction of the sets $\mathcal{P}',\mathcal{P}''$. Clearly, sets $\mathcal{P}'$ and $\mathcal{P}''$ partition $\mathcal{P}$.
\begin{figure}[ht]
\centering
\subfigure[The graph $G$. Paths are shown in distinct colors.]{\scalebox{0.25}{\includegraphics{spider_decomp_layout.jpg}}\label{fig:non_crossing_representation}}
\hspace{1pt}
\subfigure[The paths in $\mathcal{P}_1$ are shown in dash lines.]{\scalebox{0.25}{\includegraphics{spider_decomp_1.jpg}}}
\subfigure[The paths in $\mathcal{P}_2$ are shown in dash lines.]{\scalebox{0.25}{\includegraphics{spider_decomp_2.jpg}}}
\hspace{1pt}
\subfigure[The paths in $\mathcal{P}_3$ are shown in dash lines.]{\scalebox{0.25}{\includegraphics{spider_decomp_3.jpg}}}
\caption{An illustration of decomposing paths into subsets $\mathcal{P}_1,\mathcal{P}_2,\mathcal{P}_3$.\label{fig:spider_decomp}}
\end{figure}
It remains to show that the graph induced by the paths in $\mathcal{P}'$ is the union of vertex-disjoint spiders. The proof for $\mathcal{P}''$ is similar.
First, for $0\le t<t'\le \lfloor{k/2}\rfloor$, we show that the paths in $\mathcal{P}_{2t+1}$ are vertex-disjoint from the paths in $\mathcal{P}_{2t'+1}$. Assume for contradiction that this is false, and let $P\in \mathcal{P}_{2t+1}, P'\in \mathcal{P}_{2t'+1}$ be a pair of paths that share a common vertex. However, according to the process of constructing the sets $\mathcal{P}_1,\ldots,\mathcal{P}_k$, if $P$ is included in $\mathcal{P}_{2t+1}$ while $P'$ is not included in any set of $\mathcal{P}_1,\ldots,\mathcal{P}_{2t+1}$, since $P'$ shares a vertex with $P'$, $P'$ should be included in the set $\mathcal{P}_{2t+2}$ rather than $\mathcal{P}_{2t'+1}$, a contradiction.
We then show that, for each $0\le t\le \lfloor{k/2}\rfloor$, the paths in $\mathcal{P}_{2t+1}$ form disjoint spiders. Clearly the paths in $\mathcal{P}_1$ form a spider, since they are edge-disjoint paths that share only the root $r$ of tree $G$. Consider now some $t\ge 1$.
Let $v,v'$ be any two distinct vertices of $V(\mathcal{P}_{2t})\cap V(\mathcal{P}_{2t+1})$. We denote by $\mathcal{P}_{2t+1}(v)$ ($\mathcal{P}_{2t+1}(v')$, resp.) the subset of paths in $\mathcal{P}_{2t+1}$ that contains the vertex $v$ ($v'$, resp.).
We claim that the paths in $\mathcal{P}_{2t+1}(v)$ are vertex-disjoint from the paths in $\mathcal{P}_{2t+1}(v')$.
Note that, if the claim is true, since the paths in $\mathcal{P}_{2t+1}(v)$ only shares a single node $v$ (as otherwise there is a cycle caused by some pair of paths in $\mathcal{P}_{2t+1}(v)$, a contradiction to the fact that graph $G=\bigcup_{j\in [n]}P_i$ is a tree), it follows that the paths in $\mathcal{P}_{2t+1}(v)$ form a spider, and altogether, the paths in $\mathcal{P}'$ form vertex-disjoint spiders.
It remains to prove the claim.
Assume that this is false. Let $P_{2t+1}\in \mathcal{P}_{2t+1}(v), P'_{2t+1}\in \mathcal{P}_{2t+1}(v')$ be a pair of paths that shares a common vertex $u$, with $u\ne v,v'$. Note that, from our process of constructing the sets $\mathcal{P}_1,\ldots,\mathcal{P}_k$, there are two sequences of paths $P_1,P_2,\ldots,P_{2t}$ and $P'_1,P'_2,\ldots,P'_{2t}$, such that
(i) for each $1\le s\le 2t$, $P_{s}, P'_{s}\in \mathcal{P}_s$;
(ii) for each $1\le s\le 2t$, $P_{s}$ shares a vertex with $P_{s+1}$, and $P'_{s}$ shares a vertex with $P'_{s+1}$.
Since $P_1$ and $P'_1$ shares the root $r$ of tree $G$, it follows that the graph consisting of paths in $\set{P_s,P'_s \mid 1\le s\le 2t+1}$ contains a cycle, a contradiction to the fact that $G$ is a tree.
\end{proof}
\begin{prevproof}{Theorem}{thm: tree}
Let $\mathcal{Q}^*$ be the subset of $\set{Q_1,\ldots,Q_n}$ that, over all subsets of edge-disjoint paths in $\set{Q_1,\ldots,Q_n}$, maximizes its total value, namely $\mathsf{OPT}(G,\mathcal{F})=\sum_{Q_j\in \mathcal{Q}^*}v_j$. Clearly, graph $G^*=\bigcup_{Q\in \mathcal{Q}^*}Q$ is the union of a number of disjoint trees. We further partition $\mathcal{Q}^*=\bigcup_{1\le t\le k}\mathcal{Q}^*_t$, such that the union of paths in each $\mathcal{Q}^*_t$ forms a connected component of $G^*$, and is therefore a tree (a subtree of $G$). We then apply Lemma~\ref{lem:treetospider} to each set $\mathcal{Q}^*_t$. Assume the partition for $\mathcal{Q}^*_t$ is $\mathcal{Q}^{(1)}_t\cup \mathcal{Q}^{(2)}_t$ such that $\sum_{Q_j\in \mathcal{Q}^{(1)}_t}v_j\geq \sum_{Q_j\in\mathcal{Q}^{(2)}_t}v_j$. Denote $\hat\mathcal{Q}^*=\bigcup_{1\le t\le k}\mathcal{Q}^{(1)}_t$. Then clearly $\hat G^*=\bigcup_{Q\in \hat\mathcal{Q}^*}Q$ is the union of disjoint spiders and $\sum_{Q_j\in \hat\mathcal{Q}^*}v_j\geq \frac{1}{2}\mathsf{OPT}(G,\mathcal{F})$. Thus by \Cref{thm:spiderimproved}, there exists a set of prices $p$ that achieves worst-case welfare at least $\frac{1}{3}\mathsf{OPT}(G,\mathcal{F})$.
It remains to show that such a price vector $p$ can be computed efficiently. Firstly, computing the hindsight optimal solution $\mathcal{Q}^*$ is equivalent to computing the maximum weight edge-disjoint paths in a tree, for which a polynomial-time algorithm exists~\cite{tarjan1985decomposition}. According to the proof of Lemma~\ref{lem:treetospider}, partitioning $\mathcal{Q}^*$ clearly takes polynomial time. Thus the price vector can be computed efficiently by Theorem~\ref{thm:spiderimproved} that the corresponding set of prices can be computed efficiently in spider graphs.
\end{prevproof}
\iffalse
\mingfeinote{move to the no tie-breaking section}
The same reduction works when the seller does not have tie-breaking power. The following theorem follows from \Cref{thm:spider-no-tiebreak}.
\begin{theorem}\label{thm:tree-no-tiebreak}
For any constant $\varepsilon>0$, there is an efficient algorithm, that, given any tree $G$ and any buyer-profile $\mathcal{F}=\set{(Q_j,v_j)}_{j\in [n]}$, computes a set of prices on edges of $G$ that achieves the worst-case revenue equal at least $(\frac{1}{7}-\varepsilon)\cdot\mathsf{OPT}(G,\mathcal{F})$, without the power of tie-breaking.
\end{theorem}
\fi
| {'timestamp': '2021-07-14T02:02:36', 'yymm': '2107', 'arxiv_id': '2107.05690', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05690'} | arxiv |
\section{Introduction}
In order to understand the 3D world, an intelligent agent must be able to perform quick inferences about a scene's appearance and shape from unseen viewpoints given few observations. Being able to synthesize images at target camera viewpoints efficiently given sparse source views serves a fundamental purpose in building intelligent visual behaviour \cite{katerina1,katerina2,katerina3}. The problem of learning to synthesize novel views has been widely studied in literature, with approaches ranging from traditional small-baseline view synthesis relying on multi-plane imaging \cite{mpi1, mpi2, mpi3, llff}, flow estimation \cite{appearanceflow, multiview2novelview}, to explicitly modeling 3D geometry via point-clouds \cite{npbg}, meshes \cite{softraster}, and voxels \cite{enr}.
\begin{figure}[t]
\begin{center}
\vskip -0.5in
\centerline{\includegraphics[width=1.0\linewidth]{figs/fig1_v2.pdf}}
\vskip -0.55in
\caption{Our model performs scene-agnostic and category-agnostic novel view synthesis in real time. A complete 3D geometry of the scene is estimated through a single forward pass. Our model consistently produces higher quality results comparing to the state-of-the-art view synthesis approach pixelNeRF \cite{pixelNeRF}, while being over $400$x faster in rendering time.}
\label{fig:intro}
\vskip -0.3in
\end{center}
\end{figure}
A recent wave of approaches for view synthesis have adopted continuous radiance field representations \cite{pixelNeRF, srn,nerf,grf,nerfies}, where scenes are represented as a continuous function that shares its domain with the signal being fitted (\eg a function that takes points in $\mathbb{R}^3$ as input, to model a 3D signal), as opposed to discrete representations where the 3D signals are encoded in a discrete geometric structure like a volume \cite{enr} or a mesh \cite{softraster}. Although continuous radiance field representations enjoy the benefits of being resolution-free or modeling view-dependent effects, they are not efficient for real-world use cases that require real-time performance. Typically, radiance field representations have the following disadvantages. First, being computationally costly to obtain when implicitly modeled \cite{nerf, nerfies, derf}, \eg the model parameters are optimized via gradient descent for each object or scene, usually taking tens of hours on commodity hardware. Second, requiring to densely capture observations of the scene being modeled \cite{nerf, nerfies, derf} for optimization. Third, not being able to amortize the rendering cost across views, since radiance fields are evaluated independently for every pixel being rendered \cite{pixelNeRF,grf}. This dramatically impacts the practicality of radiance field, since rendering an image can take seconds on modern GPUs.
What makes an approach for novel view synthesis useful? While photo-realistic results have been obtained with continuous/implicit representations, these approaches are severely impacted by capture, optimization and rendering time, hindering their practicality for deployment in systems that require real-time performance, \eg the ability to infer views of unseen objects in real-time from sparse observations. Our approach enjoys the following benefits: \textit{(i)} the scene representation is fast to obtain, as it does not require gradient-based optimization for new scenes and can be obtained from sparse observations, and \textit{(ii)} it is efficient to render, since it models the complete 3D geometry and appearance in a single forward pass, allowing for amortized rendering. Our experiments show that despite the simplicity of our method, our performance notably matches or beats recent state-of-the-art baselines based on few-shot continuous scene representations across different metrics and settings, producing accurate novel view reconstruction, while rendering objects over $400$x faster than the state-of-the-art, pixelNeRF \cite{pixelNeRF}. In addition, we find that the 3D geometry learned by our model in an unsupervised manner (i.e. without the need to train with 3D geometry supervision) is extremely compelling and very efficient to obtain, requiring only a single forward pass of the model.
\section{Related Work}
Learning to synthesize novel views of an object or a scene given one or more sparse observation has been widely studied in the literature \cite{mpi1,mpi2,mpi3,llff, extremeviewsynthesis,appearanceflow,monocularviewsyn,multiview2novelview,enr,tbn,npbg,srn}. A unifying problem definition for this set of approaches is to predict a target view given a source view/s, conditioned on a relative camera transformation. One set of approaches focuses on small and/or wide baseline view synthesis where the goal is to synthesize a parallax effect by using multi-plane imaging \cite{mpi1, mpi2, mpi3}, local light-field fusion \cite{llff} or cost volume estimation \cite{extremeviewsynthesis}. Another set of approaches focuses on learning a free-form 2D flow field that takes pixels from a single \cite{appearanceflow} or multiple source views \cite{multiview2novelview} and reconstructs a target view given the relative camera transformation between source/s and target.
In addition, there is an extensive literature on tackling view synthesis with voxel grid 3D representations \cite{enr, tbn, deepvoxels, von, hologan, platonicgan, neuralvolumes, tungcommonsense}. Although our approach uses a voxel grid 3D representation, it differs from existing work in the following. As opposed to \cite{enr, tbn, tungcommonsense} where convolutional 2D decoders are used to generate an image, our approach uses volumetric rendering to directly render an image from the explicit voxel grid representation. In contrast to \cite{deepvoxels, neuralvolumes}, our approach can generalize to multiple objects without per scene training/optimization. Moreover, our approach is trained in a category-agnostic way as opposed to \cite{von, hologan, platonicgan}, and it is trained on a large set of object categories (as opposed to 4 object categories in \cite{tungcommonsense}) which can be generalized to unseen object categories (cf. Sect. \ref{sec:experiments}).
In order to deal with the limitations of voxel grids, implicit representations that model continuous radiance fields for view interpolation \cite{nerf,nerfies,derf,sharf} have been proposed. These approaches learn a radiance field for every scene or object by fitting the parameters of a model (using gradient descent) to a dense set of views of a scene and then interpolating between those views. Note that this setting is different from the novel view synthesis setting where the problem is to predict a target view given a sparse source view and a relative camera transformations. However, recent approaches have applied continuous radiance fields to the novel view synthesis problem \cite{pixelNeRF, grf}, showing that it is possible to model multiple objects or scenes within a single model and extrapolating to object categories unseen during training. We can group recent approaches to novel view synthesis with implicit and continuous radiance field representations into two mutually exclusive categories. In the first category we find approaches that provide an efficient approach to explicitly encode source views into a continuous representation but are inefficient during rendering due not being able to amortize the rendering process across views \cite{pixelNeRF,grf,ibrnet} (see Sect. \ref{sec:rendering} for details). In the second category, we find recent approaches that enable efficient rendering through amortized rendering \cite{plenoctrees,fastnerf,nex} but where their continuous representation is implicit, and must be fitted via gradient descent for every new object or scene (typically taking days on commodity hardware).
In this paper we present a simple yet powerful approach for novel view synthesis which explicitly encodes sources views into a volumetric representation that enables amortized rendering. Thus combining the best of both types of recent approaches for novel view synthesis.
\begin{figure*}[!t]
\begin{center}
\centerline{\includegraphics[width=0.85\linewidth]{figs/arch_v3.pdf}}
\caption{Our model is comprised of three main components: a) a 2D U-Net image encoder, b) a 3D U-Net scene encoder, and c) an amortized rendering process. The 2D U-Net encoder generates a 2D feature map $\mathbf{F}_s$ from the input image $\mathbf{I}_s$. The feature map is then projected into a latent volume $\mathbf{Z}_s$ via an inverse project step. A 3D U-Net network maps $\mathbf{Z}_s$ into an RGB$\alpha$ volume $\mathbf{V}_s$. This RGB$\alpha$ volume is applied a relative pose transformation $\mathbf{P}_{st}$ to match the target view pose $\mathbf{P}_t$, and the resulting image $\hat{\mathbf{I}}_t$ is created by rendering the RGB$\alpha$ using a simple volume rendering process that is amortized across views.}
\label{fig:arch}
\end{center}
\vskip -0.3in
\end{figure*}
\section{Methodology}
\label{sec:Methodology}
The novel view synthesis problem is defined as follows. Given a set $\mathcal{S} = \{ (\mathbf{I}_i, \mathbf{P}_i)\}_{i=0}^{n}$ of one or more source views, where a view is defined as an image $\mathbf{I}_i \in \mathbb{R}^{3 \times h \times w}$ together with the camera pose $\mathbf{P}_i \in SO(3)$, we want to learn a model $f_\theta$ that can reconstruct a ground-truth target image $\mathbf{I}_t$ conditioned on its pose $ \mathbf{P}_t$, where the predicted target image is obtained as $\hat{\mathbf{I}}_t = f_\theta(\mathcal{S}, \mathbf{P}_t)$.
We design $f_\theta$ as a simple fully convolutional model that allows amortized rendering. Our model processes a source view through a 2D U-Net encoder \cite{unet} to produce a feature map that is projected onto a latent volumetric representation via an inverse projection step. This volumetric representation is further processed with a 3D U-Net model to learn an RGB$\alpha$ volume\footnote{Note that we do not supervise training with an RGB$\alpha$ volume, the model is forced to learn the RGB$\alpha$ volume through the rendering process.} to which the relative pose transformation between source and target views is applied, and finally rendered into the predicted target view. We illustrate our pipeline in Fig. \ref{fig:arch}.
\subsection{Encoding}
\label{sec:encoding}
The initial step of our model is to encode the source $\mathbf{I}_s \in \mathbb{R}^{3 \times h \times w}$ with a fully convolutional U-Net encoder that produces a feature map $\mathbf{F}_s \in \mathbb{R}^{c \times h \times w}$ that preserves the spatial resolution of the source image. Once a feature map $\mathbf{F}_s$ is obtained, we cast the features along rays into a latent volumetric tensor using the perspective camera matrix. In practice we perform an inverse projection step to back-project $\mathbf{F}_s$ into a latent volumetric tensor $\mathbf{Z}_s \in \mathbb{R}^{c \times d_s \times h_s \times w_s}$, where $d_s, h_s, w_s$ are depth, height and width for the volumetric representation \footnote{We used intrinsic camera parameters for the inverse projection step, which we assume to be constant.}.
Instead of reshaping 2D feature maps into a 3D volumetric representation \cite{enr, tbn}, we found that using an inverse projection step is beneficial to preserve the 3D geometry and texture information (cf. Sect. \ref{sec:experiments} for empirical evidence).
\subsection{Learning a Renderable Volume}
After the inverse projection step we simply process $\mathbf{Z}_s$ with a 3D U-Net \cite{atlas} model and predict a final volume $\mathbf{V}_s \in \mathbb{R}^{4 \times d_s \times h \times w}$. At this stage $\mathbf{V}_s$ encodes an RGB$\alpha$ volume of the object or scene that can be efficiently rendered. Similar to \cite{pixelNeRF,enr} we apply the relative transformation $\mathbf{P}_{st} = \mathbf{P}_t \mathbf{P}_{s}^{-1}$ between source and target camera poses to the volumetric representation $\mathbf{V}_s$ to obtain a transformed volumetric representation $\mathbf{V}_t$ that is aligned with the target view. We define this transformation operation as a function $\mathcal{T}(\mathbf{P}, \mathbf{V})$ that takes as input a rigid transformation $\mathbf{P} \in SO(3)$ and a volume $\mathbf{V}$ and applies the rigid transformation to the volume. Note that we define $\mathbf{P} \in SO(3)$, however, our formulation naturally extends to other transformations groups (\eg non-rigid or free-form deformations).
\subsection{Amortized Rendering}
\label{sec:rendering}
We now turn to the task of rendering an RGB$\alpha$ volume $\mathbf{V}$ into an image. Recent work on modeling scenes with continuous neural radiance fields \cite{nerf} has shown great results by using the rendering equation \cite{volumerendering} in order to model pixels. At rendering time, \cite{nerf} propose to obtain a pixel value by tracing the camera ray $\mathbf{r}$ from the near plane $t_n$ to the far plane $t_f$, and the expected color of a 2D pixel can be calculated as follows (see \cite{nerf} for details):
\begin{equation}
\label{eq:nerf_int}
\begin{aligned}
C(\mathbf{r}) = \int_{t_n}^{t_f} T(t) \sigma(\mathbf{r}(t)) \mathbf{c}(\mathbf{r}(t),\mathbf{d}) dt\\
\end{aligned}
\end{equation}
where $T(t)=\exp(-\int_{t_n}^{t_f} \sigma(\mathbf{r}(s)) ds)$ denotes the accumulated transmittance between the near plane and the current point $\mathbf{r}(t)$ along the ray. In practice, numerical quadrature and stratified sampling strategies are adopted to discretize the continuous integral and make the computation viable.
However, a critical problem of the sampling process in NeRF \cite{nerf} is that it prevents the rendering process to be \textit{amortized} across views. This is because each ray integral in Eq. \ref{eq:nerf_int} is independent and points sampled to approximate one ray integral are not reusable for other ray integrals in the scene. Our approach side-steps the need to perform sampling by modelling the scenes complete geometry and appearance as an RGB$\alpha$ volume $\mathbf{V} \in \mathbb{R}^{4\times d_s \times h \times w}$. This allows us to amortize rendering across views (since all rendered images of a scene share the same RGB$\alpha$ volume) obtaining dramatic rendering speed improvements without sacrificing reconstruction accuracy with respect to recent baselines \cite{pixelNeRF}.
Before rendering our RGB$\alpha$ volume $\mathbf{V}$, we apply a perspective deformation (using intrinsic camera parameters) on the viewing frustum using inverse warping and trilinear sampling \cite{stn} (see Appendix for details). For a given pixel location $(i, j)$, the expected color $\hat{C}$ is calculated as:
\begin{equation}
\hat{C}_{i,j} = \sum_{k=1}^{d_s} T_{i,j}^k \alpha_{i,j}^k \mathbf{c}_{i,j}^k \mbox{, where } T_{i,j}^k = \prod_{m=1}^{k-1} (1-\alpha_{i,j}^m)
\end{equation}
where $\mathbf{c}_{i,j}^k$ is the color value encoded in the first $3$ channels of $\mathbf{V}_t$ and $\alpha_{i,j}^k$ is the value at the last channel.
\subsection{Multiple View Aggregation}
Our model can take an arbitrary number of source views in $\mathcal{S}$ as input. In order to do so, we first obtain latent volumes $\mathbf{Z}_i$ for each source view $i$ using the same encoding process as in Sect. \ref{sec:encoding}. Next, we take an arbitrary source view $i^*$ in the set of source views as the origin of the coordinate system. Latent volumes $\mathbf{Z}_i$ are then aligned to this origin using the relative transformation $\mathbf{P}_{i, i^*}$ between corresponding pose $\mathbf{P}_i$ and origin pose $\mathbf{P}_{i^*}$. After that, we pool the aligned volumes by taking the mean across views:
\begin{equation}
\bar{\mathbf{Z}} = \frac{1}{n} \sum_{i\in n} \mathcal{T}(\mathbf{P}_{i, i^*}, \mathbf{Z}_i)
\end{equation}
Finally, the pooled volumetric latent $\bar{\mathbf{Z}}$ is fed to our 3D U-Net to generate an RGB$\alpha$ volume $\mathbf{V}$ which can be efficiently rendered as outlined in Sect. \ref{sec:rendering}.
\subsection{Training}
Similar to \cite{enr, pixelNeRF}, we sample tuples of source and target views together with their relative transformation $(\mathbf{I}_s, \mathbf{I}_t, \mathbf{P}_{st})$ during training. We use the model $f_\theta$ to predict the target from source $\hat{\mathbf{I}}_t = f_\theta(\mathbf{I}_s, \mathbf{P}_{st})$ and minimize a rendering loss. The rendering loss is a weighted sum of $\ell_2$ loss and SSIM \cite{ssim} loss, defined as
\begin{equation}
\begin{aligned}
\mathcal{L}_{\mathrm{render}}
& = \sum_{t} \|f_\theta(\mathbf{I}_s, \mathbf{P}_{st}) - \mathbf{I}_t\|^2_2 \\
& + \lambda \mathcal{L}_{\mathrm{ssim}} (f_\theta(\mathbf{I}_s, \mathbf{P}_{st}), \mathbf{I}_t)
\end{aligned}
\end{equation}
One advantage of our formulation is that it supports the use of structural losses like SSIM \cite{ssim} during training. The SSIM loss has been previously proved useful for view synthesis \cite{enr}, and are not directly applicable to NeRF-like methods \cite{pixelNeRF}, as they randomly sample sparse rays from each image during training due to the computational constraints.
\section{Experiments}
\label{sec:experiments}
Our model is evaluated on a series of well established ShapeNet \footnote{licensed for non-commercial research purposes} \cite{shapenet} benchmarks where it achieves similar or better visual quality compared to the state-of-the-art method pixelNeRF \cite{pixelNeRF} and other recent baselines \cite{enr,srn}, while rendering objects in real time. We also evaluate the 3D reconstruction capabilities of our model, where it outperforms baseline unsupervised 3D reconstruction models. The following sections detail evaluations on category-specific view synthesis for scenes with single and multiple objects, as well as category-agnostic, multi-category, and unseen-category objects. 3D reconstruction is evaluated in Section \ref{sec:3D_recon}, and the design and effectiveness of different components of our model are discussed in Section \ref{sec:design_ablation}.
\subsection{Novel View Synthesis}
\label{sec:view_synthesis}
In the novel view synthesis experiments we compare our approach with several state-of-the-art techniques: ENR\cite{enr}, pixelNeRF \cite{pixelNeRF}, DVR \cite{dvr}, and SRN \cite{srn}. Our SSIM, PSNR, and LPIPS \cite{lpips} scores demonstrates that we produce comparable or better rendering quality than pixelNeRF \cite{pixelNeRF} with an explicit volumetric scene representation, while increasing the rendering speed $100\times$ per view, allowing us to render scenes in real-time as show in Table \ref{tb:render_inference_perf_comparison}.
\subsubsection{Category-Specific View Synthesis of Single Objects}
We evaluate our model on the ShapeNet chairs and cars categories in single-view and two-view settings, following the same experimental protocol as baseline methods \cite{srn, enr, pixelNeRF}. These category-specific datasets contain $6,591$ different chairs and $3,514$ different cars. Each object has 50 views sampled uniformly on the full sphere, rendering images resolution $128 \times 128$ pixels.
Following pixelNeRF, we train a single model for both the single-view and two-view settings. During training, we randomly choose either one or two source views to predict the target view. For evaluation, we use either one or two source views of an unseen object and predict 250 target views. Additionally, we also report the rendering time comparison between pixelNeRF and our method.
Despite its simplicity, our model obtains very competitive results compared to pixelNeRF, as shown in Table \ref{tb:SRN_datasets}. In general, we don't observe obvious mistakes made by our model when visually inspecting results. Fig. \ref{fig:srn} shows a random subset of source and predicted targets.
In Table \ref{tb:render_inference_perf_comparison} we show the average inference and rendering time of both pixelNeRF and our approach.
The inference time is defined as the interval of time required to generate scene information (2D feature maps for pixelNeRF and 3D feature maps for our model) from the source views. The rendering time is the time required to render a target view given scene information. We compute per-view rendering time and per-object rendering time, where per-object rendering time is accumulated by rendering a total of $250$ views. To conduct a fair comparison, we equate the effective image batch size between pixelNeRF and our model. All the run times are reported on an NVIDIA Tesla V100 GPU. As shown in Table \ref{tb:render_inference_perf_comparison}, our per-view rendering time is $0.0178s$, $100$x faster than pixelNeRF, taking $1.9047s$ to render an image. In other words, our model achieves a rendering speed of $56$ FPS, which enables a real-time rendering experience. By amortizing the rendering step across multiple views, our model renders 250 views in $1.022s$ ($245$ FPS), while pixelNeRF renders the same 250 views in $474.8606s$ ($0.5$ FPS). This translates to over a $400$x speedup. In addition, we test the generalization capabilities of our model on real world data. We use the model trained with ShapeNet cars categories and perform novel view synthesis on real car images from \cite{realcar}. We found our model can generate plausible novel views with less artifacts and blurry effects compared to pixelNeRF \cite{pixelNeRF}. The complete experiments protocol and qualitative visualizations can be found in the appendix.
\begin{table}[ht]
\caption{Results on category-specific novel view synthesis for ShapeNet chairs and cars. Our method achieves competitive results compared to state-of-the-art approaches.}
\vskip -0.1in
\label{tb:SRN_datasets}
\begin{center}
\begin{adjustbox}{width=1\linewidth}
\begin{small}
{
\begin{tabular}{cccccccccc}
\toprule
\multirow{2}{*}{Data} &\multirow{2}{*}{Methods} & \multicolumn{2}{c}{1-view} & \multicolumn{2}{c}{2-view} \\
\cmidrule(lr){3-4}
\cmidrule(lr){5-6}
& & PSNR$\uparrow$ & SSIM$\uparrow$ & PSNR$\uparrow$ & SSIM$\uparrow$\\
\midrule
\multirow{4}{*}{Chairs}
& ENR & 22.83 & - & - & -\\
& SRN & 22.89 & 0.89 & 24.48 & 0.92\\
& pixelNeRF & \textbf{23.72} & 0.91 & \textbf{26.20}& \textbf{0.94}\\
& Ours & 23.21 & \textbf{0.92} & 25.25 & \textbf{0.94}\\
\midrule
\multirow{4}{*}{Cars}
& ENR & 22.26 & - & - & -\\
& SRN & 22.25 & 0.89 & 24.84 & 0.92\\
& pixelNeRF & \textbf{23.17} & 0.90 & \textbf{25.66} & \textbf{0.94}\\
& Ours & 22.83 & \textbf{0.91} & 24.64 & 0.93\\
\bottomrule
\end{tabular}
}
\end{small}
\end{adjustbox}
\end{center}
\vskip -0.2in
\end{table}
\begin{table}[ht]
\caption{Results on category-specific novel view synthesis for multiple chairs. Compared to pixelNeRF, our method predicts much more coherent synthesis results, and it beats pixelNeRF by a significant margin on all three metrics.}
\vskip -0.1in
\label{tb:multi_chair}
\begin{center}
\begin{small}
{
\begin{tabular}{cccccccccc}
\toprule
\multirow{2}{*}{Methods} & \multicolumn{3}{c}{2-view} \\
\cmidrule(lr){2-4}
& PSNR$\uparrow$ & SSIM$\uparrow$ & LPIPS $\downarrow$\\
\midrule
SRN & 14.67 & 0.664 & 0.431\\
pixelNeRF & 23.40 & 0.832 & 0.207\\
Ours & \textbf{24.13} & \textbf{0.907} & \textbf{0.098}\\
\bottomrule
\end{tabular}
}
\end{small}
\end{center}
\vskip -0.2in
\end{table}
\begin{table}[ht]
\caption{Inference and rendering time (in seconds) analysis between pixelNeRF and our method. We show our model can achieve over $100$x faster per-frame and over $400$x faster per-object rendering speed. }
\vskip -0.1in
\label{tb:render_inference_perf_comparison}
\begin{center}
\begin{adjustbox}{width=1\linewidth}
\begin{small}
{
\begin{tabular}{cccccc}
\toprule
\multirow{2}{*}{} & \multicolumn{2}{c}{pixelNeRF} & \multicolumn{2}{c}{Ours}\\
\cmidrule(lr){2-5}
& Inference & Rendering & Inference & Rendering\\
\midrule
Per-view & 0.0053 & 1.8994 & 0.0146 & 0.0032\\
Per-object & 0.0053 & 474.8553 & 0.0146 & 1.0074\\
\bottomrule
\end{tabular}
}
\end{small}
\end{adjustbox}
\end{center}
\vskip -0.2in
\end{table}
\subsubsection{Category-Specific View Synthesis of Multiple Objects}
We further extend the category-specific evaluation to the multiple-chair dataset proposed by pixelNeRF. This dataset consists of images rendered with two randomly located and oriented chairs. The dataset is designed so that the model cannot simply rely on certain semantic cues such as the symmetric property of a chair to perform geometry completion. The learned model should be flexible and robust enough to represent scenes instead of a single object. All images are rendered with a resolution of $128 \times 128$.
We report reconstruction quality metrics in Table \ref{tb:multi_chair}. Despite the increased complexity of this setting, our simple model outperforms pixelNeRF across metrics, and exceeds the object-centric method SRN \cite{srn} by a large margin. Fig. \ref{fig:multi_chair} shows randomly sampled qualitative results. We observe that the views rendered by our model have cleaner geometry than pixelNeRF, which fails to predict a reasonable geometry at certain angles and suffers from ghosting artifacts.
\begin{figure*}[!t]
\begin{center}
\centerline{\includegraphics[width=1.0\textwidth]{figs/srn_6.pdf}}
\vskip -0.1in
\caption{\textbf{Qualitative results on category-specific single chair \& single car.} The model can either take (a) single view or (b) two views as input to synthesis novel views. We find similar rendering quality comparing to pixelNeRF \cite{pixelNeRF} and better geometry prediction comparing to ENR \cite{enr} and SRN \cite{srn}. }
\label{fig:srn}
\end{center}
\end{figure*}
\begin{figure*}[!t]
\begin{center}
\centerline{\includegraphics[width=1.0\textwidth]{figs/muilti_chair_3.pdf}}
\caption{\textbf{Qualitative results on category-specific multiple chairs.} The models take two-view images as input. Compared to pixelNeRF, our model renders a cleaner appearance and more complete geometry for chairs with complex shapes.}
\label{fig:multi_chair}
\end{center}
\end{figure*}
\begin{figure*}[!t]
\begin{center}
\centerline{\includegraphics[width=0.95\linewidth]{figs/multi_cat_unseen_2.pdf}}
\caption{\textbf{Qualitative results on (a) category-agnostic and (b) unseen-category datasets.} We test the capacity of our model by training it across different categories in a single-view setting. We evaluate the performance on both seen an unseen categories. We consistently observe cleaner views predicted by our model compared to the baseline.}
\label{fig:multi_cat_unseen}
\end{center}
\vskip -0.3in
\end{figure*}
\subsubsection{Category-agnostic View Synthesis}
The category-agnostic setting is much more challenging than the category-specific one, because the model needs capacity to jointly learn objects across a range of completely different categories. To evaluate our model in the category-agnostic setting, we follow the same training protocol as baseline method \cite{nmr} and evaluate on 13 different categories. Each object was rendered in 24 different views with a resolution of $64 \times 64$. We summarize our results in Table \ref{tb:NMR_datasets}. Our model beats all baseline methods in every metric. The qualitative visualization in Fig. \ref{fig:multi_cat_unseen} indicates our model can generate more clean geometry compared to pixelNeRF, which is corroborates the results obtained by our method in the multi-chair dataset.
\begin{table*}[!t]
\caption{\textbf{Quantitative results on category-agnostic view synthesis.} Our model beats all baselines with a noticeable margin in terms of the mean metrics. The LPIPS score for our mode is significant better compared to state-of-the-art methods in all categories.}
\vskip -0.2in
\label{tb:NMR_datasets}
\begin{center}
\begin{adjustbox}{width=1\linewidth}
\begin{small}
{
\begin{tabular}{cccccccccccccccc}
\toprule
Metrics & Methods & plane & bench & cbnt. & car & chair & disp. & lamp & spkr. & rifle & sofa & table & phone & boat & mean\\
\midrule
\multirow{4}{*}{PSNR$\uparrow$}
& DVR & 25.29 & 22.64 & 24.47 & 23.95 & 19.91 & 20.86 & 23.27 & 20.78 & 23.44 & 23.35 & 21.53 & 24.18 & 25.09 & 22.70\\
& SRN & 26.62 & 22.20 & 23.42 & 24.40 & 21.85 & 19.07 & 22.17 & 21.04 & 24.95 & 23.65 & 22.45 & 20.87 & 25.86 & 23.28\\
& pixelNeRF & 29.76 & 26.35 & 27.72 & 27.58 & 23.84 & \textbf{24.22} & \textbf{28.58} & 24.44 & \textbf{30.60} & 26.94 & 25.59 & 27.13 & \textbf{29.18} & 26.80\\
& Ours & \textbf{30.15} & \textbf{27.01} & \textbf{28.77} & \textbf{27.74} & \textbf{24.13} & 24.13 & 28.19 & \textbf{24.85} & 30.23 & \textbf{27.32} & \textbf{26.18} & \textbf{27.25} & 28.91 & \textbf{27.08} \\
\midrule
\multirow{4}{*}{SSIM$\uparrow$}
& DVR & 0.905 & 0.866 & 0.877 & 0.909 & 0.787 & 0.814 & 0.849 & 0.798 & 0.916 & 0.868 & 0.840 & 0.892 & 0.902 & 0.860\\
& SRN & 0.901 & 0.837 & 0.831 & 0.897 & 0.814 & 0.744 & 0.801 & 0.779 & 0.913 & 0.851 & 0.828 & 0.811 & 0.898 & 0.849\\
& pixelNeRF & 0.956 & 0.928 & 0.924 & 0.946 & 0.876 & \textbf{0.871} & 0.914 & \textbf{0.869} & \textbf{0.970} & 0.919 & 0.913 & 0.925 & 0.940 & 0.910\\
& Ours & \textbf{0.957} & \textbf{0.930} & \textbf{0.925} & \textbf{0.948} & \textbf{0.877} & \textbf{0.871} & \textbf{0.916} & \textbf{0.869} & \textbf{0.970} & \textbf{0.920} & \textbf{0.914} & \textbf{0.926} & \textbf{0.941} & \textbf{0.920} \\
\midrule
\multirow{4}{*}{LPIPS$\downarrow$}
& DVR & 0.095 & 0.129 & 0.125 & 0.098 & 0.173 & 0.150 & 0.172 & 0.170 & 0.094 & 0.119 & 0.139 & 0.110 & 0.116 & 0.130\\
& SRN & 0.111 & 0.150 & 0.147 & 0.115 & 0.152 & 0.197 & 0.210 & 0.178 & 0.111 & 0.129 & 0.135 & 0.165 & 0.134 & 0.139 \\
& pixelNeRF & 0.084 & 0.116 & 0.105 & 0.095 & 0.146 & 0.129 & 0.114 & 0.141 & 0.066 & 0.116 & 0.098 & 0.097 & 0.111 & 0.108\\
& Ours & \textbf{0.061} & \textbf{0.080} & \textbf{0.076} & \textbf{0.085} & \textbf{0.103} & \textbf{0.105} & \textbf{0.091} & \textbf{0.116} & \textbf{0.048} & \textbf{0.081} & \textbf{0.071} & \textbf{0.080} & \textbf{0.094} & \textbf{0.082}\\
\bottomrule
\end{tabular}
}
\end{small}
\end{adjustbox}
\end{center}
\vskip -0.12in
\end{table*}
\subsubsection{Unseen-Category View Synthesis}
In order to evaluate how our model generalizes to categories not seen during training, we follow the settings in pixelNeRF, and use only three object categories for training, namely airplane, car, and chair. We then evaluate on 10 unseen object categories. Table \ref{tb:NMR_datasets_unseen} compares the performance of our method with several baselines. We achieve state-of-the-art performance in SSIM and LPIPS, while performing slightly worse than pixelNeRF \cite{pixelNeRF} on PSNR. Fig. \ref{fig:multi_cat_unseen} indicates that our method is able to learn a good object prior, allowing it to generate feasible geometry for unseen categories such as benches and sofas. We also observe that the novel view images predicted by pixelNeRF are consistently more blurry, which explains its better performance on PSNR. On contrary, our model predicts sharp images that are more favorable by human perception, resulting in better metrics like LPIPS.
\begin{table*}[!t]
\caption{\textbf{Quantitative results on unseen-category view synthesis.} Our model obtains slightly worse PSNR, similar SSIM and better LPIPS metrics when compared to pixelNeRF.}
\vskip -0.2in
\label{tb:NMR_datasets_unseen}
\begin{center}
\begin{adjustbox}{width=0.85\linewidth}
\begin{small}
{
\begin{tabular}{cccccccccccccccc}
\toprule
Metrics & Methods & bench & cbnt. & disp. & lamp & spkr. & rifle & sofa & table & phone & boat & mean\\
\midrule
\multirow{4}{*}{PSNR$\uparrow$}
& DVR & 18.37 & 17.19 & 14.33 & 18.48 & 16.09 & 20.28 & 18.62 & 16.20 & 16.84 & 22.43 & 17.72 \\
& SRN & 18.71 & 17.04 & 15.06 & 19.26 & 17.06 & 23.12 & 18.76 & 17.35 & 15.66 & 24.97 & 18.71 \\
& pixelNeRF & \textbf{23.79} & \textbf{22.85} & \textbf{18.09} & \textbf{22.76} & \textbf{21.22} & \textbf{23.68} & \textbf{24.62} & \textbf{21.65} & \textbf{21.05} & \textbf{26.55} & \textbf{22.71}\\
& Ours & 23.10 & 22.27 & 17.01 & 22.15 & 20.76 & 23.22 & 24.20 & 20.54 & 19.59 & 25.77 & 21.90 \\
\midrule
\multirow{4}{*}{SSIM$\uparrow$}
& DVR & 0.754 & 0.686 & 0.601 & 0.749 & 0.657 & 0.858 & 0.755 & 0.644 & 0.731 & 0.857 & 0.716\\
& SRN & 0.702 & 0.626 & 0.577 & 0.685 & 0.633 & 0.875 & 0.702 & 0.617 & 0.635 & 0.875 & 0.684\\
& pixelNeRF & 0.863 & 0.814 & \textbf{0.687} & 0.818 & 0.778 & 0.899 & 0.866 & \textbf{0.798} & \textbf{0.801} & 0.896 & \textbf{0.825}\\
& Ours & \textbf{0.865} & \textbf{0.819} & 0.686 & \textbf{0.822} & \textbf{0.785} & \textbf{0.902} & \textbf{0.872} & 0.792 & 0.796 & \textbf{0.898} & \textbf{0.825} \\
\midrule
\multirow{4}{*}{LPIPS$\downarrow$}
& DVR & 0.219 & 0.257 & 0.306 & 0.259 & 0.266 & 0.158 & 0.196 & 0.280 & 0.245 & 0.152 & 0.240\\
& SRN & 0.282 & 0.314 & 0.333 & 0.321 & 0.289 & 0.175 & 0.248 & 0.315 & 0.324 & 0.163 & 0.280 \\
& pixelNeRF & 0.164 & 0.186 & 0.271 & 0.208 & 0.203 & 0.141 & 0.157 & 0.188 & 0.207 & 0.148 & 0.182\\
& Ours & \textbf{0.135} & \textbf{0.156} & \textbf{0.237} & \textbf{0.175} & \textbf{0.173} & \textbf{0.117} & \textbf{0.123} & \textbf{0.152} & \textbf{0.176} & \textbf{0.128} & \textbf{0.150}\\
\bottomrule
\end{tabular}
}
\end{small}
\end{adjustbox}
\end{center}
\end{table*}
\subsection{3D Reconstruction}
\label{sec:3D_recon}
We now turn to the task of evaluating the 3D geometry learned by our approach in a self-supervised manner by minimizing a novel view synthesis objective. In this setting, we evaluate 3D reconstruction by taking the mean intersection-over-union (mIoU) over the predicted $\alpha$ volume (the last channel of $\mathbf{V}_s$) and the corresponding ground truth occupancy volume. We compare our model to several unsupervised 3D reconstruction methods: PrGAN \cite{progan}, PlatonicGAN/3D \cite{platonicgan}, Multi.-View \cite{yan2016perspective}, and 3DGAN\cite{wu2016learning}. PlatonicGAN and PrGAN adopt a adversarial approach to learn 3D reconstruction given a single image with a canonical view. For this evaluation, we utilize the model trained with category-agnostic supervision and report results on the \textit{airplane} class as introduced in \cite{platonicgan}. The predicted alpha volume is binarized using a threshold $\tau=0.05$. The ground truth data is obtained from the ShapeNet voxelized volumes \cite{3dr2n2} and upsampled from $32^3$ to $64^3$ via nearest-neighbor interpolation. We then calculate the mIoU score and report in Table \ref{tb:3D_datasets}. Results of other models are directly taken from PlatonicGAN \cite{platonicgan}.
As shown in Table \ref{tb:3D_datasets}, our model predicts accurate 3D reconstruction, outperforming the best baseline by $10\%$ in mIoU. We attribute this boost in performance to the fact that our model can easlily tap large quantities of data in a category-agnostic manner. Whereas in GAN approaches like PlatonicGAN category-agnostic training has traditionally been a very an extremely difficult problem, preventing these approaches to tap large quantities of data for view synthesis. Fig. \ref{fig:3D_voxel_grid_visualization} shows qualitative 3D reconstruction results where we observe that our model produces accurate 3D models of objects. Furthermore, we extend the 3D reconstruction evaluation by including two \textbf{supervised} baselines V-LSMs\cite{vlsm} and 3D-R2N2 \cite{3dr2n2}. Our model obtains a mIoU of 63.25\% averaged across categories, while V-LSMs achieves 61.5\% and 3D-R2N2 achieves 55.1\%. Complete comparison details can be found in the appendix.
\begin{table}[t]
\caption{\textbf{Quantitative results for 3D geometry reconstruction on Airplanes class.} Our model outperforms all baseline models in terms of single-view 3D reconstruction. }
\vskip -0.1in
\label{tb:3D_datasets}
\begin{center}
\begin{adjustbox}{width=1\linewidth}
\begin{small}
{
\begin{tabular}{ccccccccccc}
\toprule
& PrGAN & PlatonicGAN & Multi.-View & 3DGAN & PlatonicGAN 3D & Ours \\
\midrule
mIoU$\uparrow$ & 0.11 & 0.20 & 0.36 & 0.46 & 0.44 & \textbf{0.58} \\
\bottomrule
\end{tabular}
}
\end{small}
\end{adjustbox}
\end{center}
\end{table}
\begin{figure*}[t]
\begin{center}
\centerline{\includegraphics[width=1.0\linewidth]{figs/3Drecon_4.pdf}}
\caption{\textbf{Qualitative results for 3D geometry reconstruction.} We visualize the predicted $\alpha$ volume with its raw resolution $64^3$ and the ground truth volume with its raw resolution $32^3$. With a single-forward pass, our model can perform 3D geometry reconstruction given a single view of objects from 13 different categories. Our model trained with only 2D supervision consistently predicts meaningful and full geometry.}
\label{fig:3D_voxel_grid_visualization}
\end{center}
\vskip -0.1in
\end{figure*}
\begin{table}[!t]
\caption{\textbf{Ablation studies on different model components.} We show the effectiveness of various model components, trained with a $1/4$ size of the ShapeNet chairs dataset. }
\vskip -0.1in
\label{tb:ablation}
\begin{center}
\begin{adjustbox}{width=1\linewidth}
\begin{small}
{
\begin{tabular}{ccccccc}
\toprule
& - inv projection & - 2D U-Net & - 3D U-Net & - half 3D resolution & Full\\
\midrule
PSNR & 20.62 & 21.10 & 21.45 & 21.82 & 21.94 \\
\bottomrule
\end{tabular}
}
\end{small}
\end{adjustbox}
\end{center}
\vskip -0.2in
\end{table}
\subsection{Ablation Studies}
\label{sec:design_ablation}
To better understand the benefits of each component of our model, we perform ablation studies by excluding one of each of the following components: inverse projection, 2D U-Net, 3D U-Net, or halved 3D voxel resolution. We use a $1/4$ training split of the ShapeNet chairs dataset and evaluate the performance on the full test split. Table \ref{tb:ablation} summarizes our findings. Starting from the right-most column, we sequentially remove and replace the components with their simplified variants and measure the model performance using the PSNR metric. It turns out that each component contributes \textit{[0.1, 0.5]} metric improvements. The inverse projection component is essential in terms of preserving the implicit geometric and texture information, in comparison to naively reshaping 2D feature volume into 3D \cite{enr, tbn}. 2D/3D U-Nets are useful to synthesize abstract geometry while preserving texture with skip connections, in comparison to single-path ResNet network structure. The halved 3D resolution is beneficial in reducing the tensor memory footprint and increasing the receptive field.
\section{Conclusion}
We have presented a simple yet effective approach to perform novel view synthesis of objects without explicit 3D supervision. Contrary to recent developments using radiance fields for view synthesis, our approach is neither continuous nor implicit. Despite the simplicity of our approach, we demonstrate that our model obtains comparable or even better performance than recent state-of-the-art approaches for few shot view synthesis using radiance fields \cite{pixelNeRF}, while rendering objects at over $400$x speed up. In addition, our model learns accurate 3D geometry in a self-supervised manner, relaxing the need of a large amount of 3D geometry data, and surpassing recent baselines for unsupervised learning of 3D geometry.
As a future work (appendix), we plan to investigate the use of explicit sparse space representations such as octrees \cite{ogn, deepOCN, plenoctrees}, mixture of volumetric primitives \cite{mvp}, and scene graphs \cite{neuralscenegraph, giraffe} to increase our geometric capacity. Our current model cannot produce view-dependent lighting effects. This limitation can be addressed with a more informative material representation and a shading model that incorporates view direction, lighting, and surface information. We can also utilize techniques such as spherical harmonics \cite{sphericalharmonic} or a learned multilayer perceptron (MLP) to synthesize the color with view-dependent specular effects. By doing so during rendering time, we can leverage more advanced rendering techniques such as deferred rendering to better estimate the radiance field that captures both incoming light and material properties.
\newpage
{\small
\bibliographystyle{ieee_fullname}
| {'timestamp': '2021-12-10T02:04:20', 'yymm': '2107', 'arxiv_id': '2107.05775', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05775'} | arxiv |
\section{Introduction}
The release of large pre-trained language models like BERT~\cite{bert} has shaken-up Natural Language Processing and Information Retrieval.
These models have shown a strong ability to adapt to various tasks by simple fine-tuning. At the beginning of 2019, \textit{Nogueira and Cho}~\cite{passage_ranking} achieved state-of-the-art results -- by a large margin -- on the MS MARCO passage re-ranking task, paving the way for LM-based neural ranking models. Because of strict efficiency requirements, these models have initially been used as re-rankers in a two-stage ranking pipeline, where first-stage retrieval -- or candidate generation -- is conducted with bag-of-words models (e.g. BM25) that rely on inverted indexes. While BOW models remain strong baselines~\cite{neural_hype}, they suffer from the long standing vocabulary mismatch problem, where relevant documents might not contain terms that appear in the query. Thus, there have been attempts to substitute standard BOW approaches by learned (neural) rankers. Designing such models poses several challenges regarding efficiency and scalability: therefore there is a need for methods where most of the computation can be done offline and online inference is fast.
Dense retrieval with approximate nearest neighbors search has shown impressive results \cite{xiong2021approximate,lin2020distill,ding2020rocketqa}, but is still combined with BOW models because of its inability to explicitly model term matching. Hence, there has recently been a growing interest in learning \emph{sparse representations} for queries and documents~\cite{snrm, dai2019contextaware,nogueira2019document,zhao2020sparta,sparterm2020}. By doing so, models can inherit from the desirable properties of BOW models like exact-match of (possibly latent) terms, efficiency of inverted indexes and interpretability. Additionally, by modeling implicit or explicit (latent, contextualized) \emph{expansion} mechanisms -- similarly to standard expansion models in IR -- these models can reduce the vocabulary mismatch.
The contributions of this paper are threefold:
\begin{enumerate*}
\item we build upon SparTerm~\cite{sparterm2020}, and show that a mild tuning of hyperparameters brings improvements that largely outperform the results reported in the original paper;
\item we propose the SParse Lexical AnD Expansion (SPLADE) model, based on a logarithmic activation and sparse regularization. SPLADE performs an efficient document expansion~\cite{sparterm2020, MacAvaney_2020}, with competitive results with respect to complex training pipelines for dense models like ANCE~\cite{xiong2021approximate};
\item finally, we show how the sparsity regularization can be controlled to influence the trade-off between efficiency (in terms of the number of floating-point operations) and effectiveness.
\end{enumerate*}
\section{Related Works}
\input{sota}
\section{Sparse Lexical representations for first-stage ranking}
\input{method}
\section{Experimental setting and results}
\input{experiments}
\section{Conclusion}
Recently, dense retrieval based on BERT has demonstrated its superiority for first-stage retrieval, questioning the competitiveness of traditional sparse models. In this work, we have proposed SPLADE, a sparse model revisiting query/document expansion. Our approach relies on in-batch negatives, logarithmic activation and FLOPS regularization to learn effective and efficient sparse representations. SPLADE is an appealing candidate for initial retrieval: it rivals the latest state-of-the-art dense retrieval models, its training procedure is straightforward, its sparsity/FLOPS can be controlled explicitly through the regularization, and it can operate on inverted indexes. In reason of its simplicity, SPLADE is a solid basis for further improvements in this line of research.
\bibliographystyle{ACM-Reference-Format}
\balance
\subsection{SparTerm}
SparTerm predicts term importance -- in BERT WordPiece vocabulary ($|V|=30522$) -- based on the logits of the Masked Language Model (MLM) layer. More precisely, let us consider an input query or document sequence (after WordPiece tokenization) $t=(t_1,t_2,...,t_N)$, and its corresponding BERT embeddings $(h_1,h_2,...,h_N)$. We consider the importance $w_{ij}$ of the token $j$ (vocabulary) for a token $i$ (of the input sequence):
\begin{equation}
w_{ij} = \text{transform}(h_i)^T E_j + b_j \quad j \in \{1,...,|V|\}
\label{equation_1}
\end{equation}
where $E_j$ denotes the BERT input embedding for token $j$, $b_j$ is a token-level bias, and transform$(.)$ is a linear layer with GeLU activation and LayerNorm. Note that Eq.~\ref{equation_1} is equivalent to the MLM prediction, thus it can be also be initialized from a pre-trained MLM model. The final representation is then obtained by summing importance predictors over the input sequence tokens, after applying ReLU to ensure the positivity of term weights:
\begin{equation}
w_j=g_j \times \sum_{i \in t}\label{eq_model} \text{ReLU}(w_{ij})
\end{equation}
where $g_j$ is a binary mask (gating) described latter.
The above equation can be seen as a form of query/document \emph{expansion}, as observed in \cite{sparterm2020,MacAvaney_2020}, since for each token of the vocabulary the model predicts a new weight $w_j$.
SparTerm~\cite{sparterm2020} introduces two sparsification schemes that turn off a large amount of dimensions in query and document representations, allowing to efficiently retrieve from an inverted index:
{ \bf lexical-only} is a BOW masking, i.e. $g_j=1$ if token $j$ appears in $t$, and 0 otherwise;
{\bf expansion-aware} is a lexical/expansion-aware binary gating mechanism, where $g_{j}$ is \emph{learned}. To preserve the original input, it is forced to 1 if the token $j$ appears in $t$.
\noindent Let $s(q,d)$ denote the ranking score obtained via dot product between $q$ and $d$ representations from Eq. \eqref{eq_model}. Given a query $q_i$, a positive document $d_i^+$ and a negative document $d_i^-$, SparTerm is trained by minimzing the following loss:
\begin{equation}\mathcal{L}_{rank} = - \log\frac{e^{s(q_i,d_i^+)}}{e^{s(q_i,d_i^+)} + e^{s(q_i,d_i^-)}}
\end{equation}
\paragraph{\bf Limitations}
SparTerm expansion-aware gating
is somewhat intricate, and the model cannot be trained end-to-end: the gating mechanism is learned beforehand,
and \emph{fixed} while fine-tuning the matching model with $\mathcal{L}_{rank}$, therefore preventing the model to learn the optimal sparsification strategy for the ranking task. Moreover, the two lexical and expansion-aware strategies do perform almost equally well, questioning the actual benefits of expansion.
\subsection{SPLADE: SParse Lexical AnD Expansion model}
In the following, we propose slight, but essential changes to the SparTerm model that dramatically improve its performance.
\paragraph{\bf Model} We introduce a minor change in the importance estimation from Eq.~\ref{eq_model}, by introducing a log-saturation effect which
prevents some terms to dominate and
naturally ensures sparsity in representations:
\begin{equation}
w_{j}=\sum_{i \in t} \log \left(1 + \text{ReLU}(w_{ij}) \right)
\label{eq_model_log}
\end{equation}
While it is intuitive that using a log-saturation prevents some terms from dominating -- drawing a parallel with axiomatic approaches in IR and $\log$(tf) models~\cite{10.1145/1008992.1009004} -- the implied sparsity can seem surprising at first, but,
according to our experiments, it obtains better experimental results and allows already to obtain sparse solutions \emph{without any regularization}.
\paragraph{\bf Ranking loss}
Given a query $q_i$ in a batch, a positive document $d_i^+$, a (hard) negative document $d_i^-$ (e.g. coming from BM25 sampling), and a set of negative documents in the batch (positive documents from other queries) $\{d_{i,j}^-\}_j$, we consider the ranking loss from~\cite{ding2020rocketqa}, which can be interpreted as the maximization of the probability of the document $d_i^+$ being relevant among the documents $d_i^+, d_i^-$ and $\{d_{i,j}^-\}$:
\begin{equation}\mathcal{L}_{rank-IBN} = - \log\frac{e^{s(q_i,d_i^+)}}{e^{s(q_i,d_i^+)} + e^{s(q_i,d_i^-)} + \sum_j e^{s(q_i,d_{i,j}^-)}}
\end{equation}
The \emph{in-batch negatives} (IBN) sampling strategy is widely used for training image retrieval models, and has shown to be effective in learning first-stage rankers~\cite{karpukhin2020dense,ding2020rocketqa,lin2020distill}.
\paragraph{\bf Learning sparse representations}
The idea of learning sparse representations for first-stage retrieval dates back to SNRM~\cite{snrm}, via $\ell_1$ regularization. Later, \cite{paria2020minimizing} pointed-out that minimizing the $\ell_1$ norm of representations does not result in the most efficient index, as nothing ensures that posting lists are evenly distributed. Note that this is even more true for standard indexes due to the Zipfian nature of the term frequency distribution.
To obtain a well-balanced index, \textit{Paria et al.} \cite{paria2020minimizing} introduce the \texttt{FLOPS} regularizer, a smooth relaxation of the average number of floating-point operations necessary to compute the score of a document, and hence directly related to the retrieval time. It is defined using $a_j$ as a continuous relaxation of the activation (i.e. the term has a non zero weight) probability $p_j$ for token $j$, and estimated for documents $d$ in a batch of size $N$ by
$\bar{a}_j=\frac{1}{N} \sum_{i=1}^N w^{(d_i)}_{j}$.
This gives the following regularization loss
$$
\ell_{\texttt{FLOPS}} = \sum_{j\in V} {\bar a}_j^2 = \sum_{j \in V} \left( \frac{1}{N} \sum_{i=1}^N w_j^{(d_i)} \right)^2
$$
This differs from the $\ell_1$ regularization used in SNRM~\cite{snrm} where the ${\bar a}_j$ are not squared: using $\ell_{\texttt{FLOPS}}$ thus pushes down high average term weight values, giving rise to a more balanced index.
\paragraph{\bf Overall loss}
We propose to combine the best of both worlds for end-to-end training of sparse, expansion-aware representations of documents and queries. Thus, we discard the binary gating in SparTerm, and instead learn our log-saturated model (Eq. \ref{eq_model_log}) by jointly optimizing ranking and regularization losses:
\begin{equation}
\mathcal{L} = \mathcal{L}_{rank-IBN} + \lambda_q \mathcal{L}^{q}_{\texttt{reg}} + \lambda_d \mathcal{L}^{d}_{\texttt{reg}}
\end{equation}
where $\mathcal{L}_{\texttt{reg}}$ is a sparse regularization ($\ell_1$ or $\ell_{\texttt{FLOPS}}$). We use two distinct regularization weights ($\lambda_d$ and $\lambda_q$) for queries and documents -- allowing to put more pressure on the sparsity for queries, which is critical for fast retrieval.
\section{Introduction}
ACM's consolidated article template, introduced in 2017, provides a
consistent \LaTeX\ style for use across ACM publications, and
incorporates accessibility and metadata-extraction functionality
necessary for future Digital Library endeavors. Numerous ACM and
SIG-specific \LaTeX\ templates have been examined, and their unique
features incorporated into this single new template.
If you are new to publishing with ACM, this document is a valuable
guide to the process of preparing your work for publication. If you
have published with ACM before, this document provides insight and
instruction into more recent changes to the article template.
The ``\verb|acmart|'' document class can be used to prepare articles
for any ACM publication --- conference or journal, and for any stage
of publication, from review to final ``camera-ready'' copy, to the
author's own version, with {\itshape very} few changes to the source.
\section{Template Overview}
As noted in the introduction, the ``\verb|acmart|'' document class can
be used to prepare many different kinds of documentation --- a
double-blind initial submission of a full-length technical paper, a
two-page SIGGRAPH Emerging Technologies abstract, a ``camera-ready''
journal article, a SIGCHI Extended Abstract, and more --- all by
selecting the appropriate {\itshape template style} and {\itshape
template parameters}.
This document will explain the major features of the document
class. For further information, the {\itshape \LaTeX\ User's Guide} is
available from
\url{https://www.acm.org/publications/proceedings-template}.
\subsection{Template Styles}
The primary parameter given to the ``\verb|acmart|'' document class is
the {\itshape template style} which corresponds to the kind of publication
or SIG publishing the work. This parameter is enclosed in square
brackets and is a part of the {\verb|documentclass|} command:
\begin{verbatim}
\documentclass[STYLE]{acmart}
\end{verbatim}
Journals use one of three template styles. All but three ACM journals
use the {\verb|acmsmall|} template style:
\begin{itemize}
\item {\verb|acmsmall|}: The default journal template style.
\item {\verb|acmlarge|}: Used by JOCCH and TAP.
\item {\verb|acmtog|}: Used by TOG.
\end{itemize}
The majority of conference proceedings documentation will use the {\verb|acmconf|} template style.
\begin{itemize}
\item {\verb|acmconf|}: The default proceedings template style.
\item{\verb|sigchi|}: Used for SIGCHI conference articles.
\item{\verb|sigchi-a|}: Used for SIGCHI ``Extended Abstract'' articles.
\item{\verb|sigplan|}: Used for SIGPLAN conference articles.
\end{itemize}
\subsection{Template Parameters}
In addition to specifying the {\itshape template style} to be used in
formatting your work, there are a number of {\itshape template parameters}
which modify some part of the applied template style. A complete list
of these parameters can be found in the {\itshape \LaTeX\ User's Guide.}
Frequently-used parameters, or combinations of parameters, include:
\begin{itemize}
\item {\verb|anonymous,review|}: Suitable for a ``double-blind''
conference submission. Anonymizes the work and includes line
numbers. Use with the \verb|\acmSubmissionID| command to print the
submission's unique ID on each page of the work.
\item{\verb|authorversion|}: Produces a version of the work suitable
for posting by the author.
\item{\verb|screen|}: Produces colored hyperlinks.
\end{itemize}
This document uses the following string as the first command in the
source file:
\begin{verbatim}
\documentclass[sigconf]{acmart}
\end{verbatim}
\section{Modifications}
Modifying the template --- including but not limited to: adjusting
margins, typeface sizes, line spacing, paragraph and list definitions,
and the use of the \verb|\vspace| command to manually adjust the
vertical spacing between elements of your work --- is not allowed.
{\bfseries Your document will be returned to you for revision if
modifications are discovered.}
\section{Typefaces}
The ``\verb|acmart|'' document class requires the use of the
``Libertine'' typeface family. Your \TeX\ installation should include
this set of packages. Please do not substitute other typefaces. The
``\verb|lmodern|'' and ``\verb|ltimes|'' packages should not be used,
as they will override the built-in typeface families.
\section{Title Information}
The title of your work should use capital letters appropriately -
\url{https://capitalizemytitle.com/} has useful rules for
capitalization. Use the {\verb|title|} command to define the title of
your work. If your work has a subtitle, define it with the
{\verb|subtitle|} command. Do not insert line breaks in your title.
If your title is lengthy, you must define a short version to be used
in the page headers, to prevent overlapping text. The \verb|title|
command has a ``short title'' parameter:
\begin{verbatim}
\title[short title]{full title}
\end{verbatim}
\section{Authors and Affiliations}
Each author must be defined separately for accurate metadata
identification. Multiple authors may share one affiliation. Authors'
names should not be abbreviated; use full first names wherever
possible. Include authors' e-mail addresses whenever possible.
Grouping authors' names or e-mail addresses, or providing an ``e-mail
alias,'' as shown below, is not acceptable:
\begin{verbatim}
\author{Brooke Aster, David Mehldau}
\email{dave,judy,steve@university.edu}
\email{firstname.lastname@phillips.org}
\end{verbatim}
The \verb|authornote| and \verb|authornotemark| commands allow a note
to apply to multiple authors --- for example, if the first two authors
of an article contributed equally to the work.
If your author list is lengthy, you must define a shortened version of
the list of authors to be used in the page headers, to prevent
overlapping text. The following command should be placed just after
the last \verb|\author{}| definition:
\begin{verbatim}
\renewcommand{\shortauthors}{McCartney, et al.}
\end{verbatim}
Omitting this command will force the use of a concatenated list of all
of the authors' names, which may result in overlapping text in the
page headers.
The article template's documentation, available at
\url{https://www.acm.org/publications/proceedings-template}, has a
complete explanation of these commands and tips for their effective
use.
Note that authors' addresses are mandatory for journal articles.
\section{Rights Information}
Authors of any work published by ACM will need to complete a rights
form. Depending on the kind of work, and the rights management choice
made by the author, this may be copyright transfer, permission,
license, or an OA (open access) agreement.
Regardless of the rights management choice, the author will receive a
copy of the completed rights form once it has been submitted. This
form contains \LaTeX\ commands that must be copied into the source
document. When the document source is compiled, these commands and
their parameters add formatted text to several areas of the final
document:
\begin{itemize}
\item the ``ACM Reference Format'' text on the first page.
\item the ``rights management'' text on the first page.
\item the conference information in the page header(s).
\end{itemize}
Rights information is unique to the work; if you are preparing several
works for an event, make sure to use the correct set of commands with
each of the works.
The ACM Reference Format text is required for all articles over one
page in length, and is optional for one-page articles (abstracts).
\section{CCS Concepts and User-Defined Keywords}
Two elements of the ``acmart'' document class provide powerful
taxonomic tools for you to help readers find your work in an online
search.
The ACM Computing Classification System ---
\url{https://www.acm.org/publications/class-2012} --- is a set of
classifiers and concepts that describe the computing
discipline. Authors can select entries from this classification
system, via \url{https://dl.acm.org/ccs/ccs.cfm}, and generate the
commands to be included in the \LaTeX\ source.
User-defined keywords are a comma-separated list of words and phrases
of the authors' choosing, providing a more flexible way of describing
the research being presented.
CCS concepts and user-defined keywords are required for for all
articles over two pages in length, and are optional for one- and
two-page articles (or abstracts).
\section{Sectioning Commands}
Your work should use standard \LaTeX\ sectioning commands:
\verb|section|, \verb|subsection|, \verb|subsubsection|, and
\verb|paragraph|. They should be numbered; do not remove the numbering
from the commands.
Simulating a sectioning command by setting the first word or words of
a paragraph in boldface or italicized text is {\bfseries not allowed.}
\section{Tables}
The ``\verb|acmart|'' document class includes the ``\verb|booktabs|''
package --- \url{https://ctan.org/pkg/booktabs} --- for preparing
high-quality tables.
Table captions are placed {\itshape above} the table.
Because tables cannot be split across pages, the best placement for
them is typically the top of the page nearest their initial cite. To
ensure this proper ``floating'' placement of tables, use the
environment \textbf{table} to enclose the table's contents and the
table caption. The contents of the table itself must go in the
\textbf{tabular} environment, to be aligned properly in rows and
columns, with the desired horizontal and vertical rules. Again,
detailed instructions on \textbf{tabular} material are found in the
\textit{\LaTeX\ User's Guide}.
Immediately following this sentence is the point at which
Table~\ref{tab:freq} is included in the input file; compare the
placement of the table here with the table in the printed output of
this document.
\begin{table}
\caption{Frequency of Special Characters}
\label{tab:freq}
\begin{tabular}{ccl}
\toprule
Non-English or Math&Frequency&Comments\\
\midrule
\O & 1 in 1,000& For Swedish names\\
$\pi$ & 1 in 5& Common in math\\
\$ & 4 in 5 & Used in business\\
$\Psi^2_1$ & 1 in 40,000& Unexplained usage\\
\bottomrule
\end{tabular}
\end{table}
To set a wider table, which takes up the whole width of the page's
live area, use the environment \textbf{table*} to enclose the table's
contents and the table caption. As with a single-column table, this
wide table will ``float'' to a location deemed more
desirable. Immediately following this sentence is the point at which
Table~\ref{tab:commands} is included in the input file; again, it is
instructive to compare the placement of the table here with the table
in the printed output of this document.
\begin{table*}
\caption{Some Typical Commands}
\label{tab:commands}
\begin{tabular}{ccl}
\toprule
Command &A Number & Comments\\
\midrule
\texttt{{\char'134}author} & 100& Author \\
\texttt{{\char'134}table}& 300 & For tables\\
\texttt{{\char'134}table*}& 400& For wider tables\\
\bottomrule
\end{tabular}
\end{table*}
Always use midrule to separate table header rows from data rows, and
use it only for this purpose. This enables assistive technologies to
recognise table headers and support their users in navigating tables
more easily.
\section{Math Equations}
You may want to display math equations in three distinct styles:
inline, numbered or non-numbered display. Each of the three are
discussed in the next sections.
\subsection{Inline (In-text) Equations}
A formula that appears in the running text is called an inline or
in-text formula. It is produced by the \textbf{math} environment,
which can be invoked with the usual
\texttt{{\char'134}begin\,\ldots{\char'134}end} construction or with
the short form \texttt{\$\,\ldots\$}. You can use any of the symbols
and structures, from $\alpha$ to $\omega$, available in
\LaTeX~\cite{Lamport:LaTeX}; this section will simply show a few
examples of in-text equations in context. Notice how this equation:
\begin{math}
\lim_{n\rightarrow \infty}x=0
\end{math},
set here in in-line math style, looks slightly different when
set in display style. (See next section).
\subsection{Display Equations}
A numbered display equation---one set off by vertical space from the
text and centered horizontally---is produced by the \textbf{equation}
environment. An unnumbered display equation is produced by the
\textbf{displaymath} environment.
Again, in either environment, you can use any of the symbols and
structures available in \LaTeX\@; this section will just give a couple
of examples of display equations in context. First, consider the
equation, shown as an inline equation above:
\begin{equation}
\lim_{n\rightarrow \infty}x=0
\end{equation}
Notice how it is formatted somewhat differently in
the \textbf{displaymath}
environment. Now, we'll enter an unnumbered equation:
\begin{displaymath}
\sum_{i=0}^{\infty} x + 1
\end{displaymath}
and follow it with another numbered equation:
\begin{equation}
\sum_{i=0}^{\infty}x_i=\int_{0}^{\pi+2} f
\end{equation}
just to demonstrate \LaTeX's able handling of numbering.
\section{Figures}
The ``\verb|figure|'' environment should be used for figures. One or
more images can be placed within a figure. If your figure contains
third-party material, you must clearly identify it as such, as shown
in the example below.
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{sample-franklin}
\caption{1907 Franklin Model D roadster. Photograph by Harris \&
Ewing, Inc. [Public domain], via Wikimedia
Commons. (\url{https://goo.gl/VLCRBB}).}
\Description{A woman and a girl in white dresses sit in an open car.}
\end{figure}
Your figures should contain a caption which describes the figure to
the reader.
Figure captions are placed {\itshape below} the figure.
Every figure should also have a figure description unless it is purely
decorative. These descriptions convey what’s in the image to someone
who cannot see it. They are also used by search engine crawlers for
indexing images, and when images cannot be loaded.
A figure description must be unformatted plain text less than 2000
characters long (including spaces). {\bfseries Figure descriptions
should not repeat the figure caption – their purpose is to capture
important information that is not already provided in the caption or
the main text of the paper.} For figures that convey important and
complex new information, a short text description may not be
adequate. More complex alternative descriptions can be placed in an
appendix and referenced in a short figure description. For example,
provide a data table capturing the information in a bar chart, or a
structured list representing a graph. For additional information
regarding how best to write figure descriptions and why doing this is
so important, please see
\url{https://www.acm.org/publications/taps/describing-figures/}.
\subsection{The ``Teaser Figure''}
A ``teaser figure'' is an image, or set of images in one figure, that
are placed after all author and affiliation information, and before
the body of the article, spanning the page. If you wish to have such a
figure in your article, place the command immediately before the
\verb|\maketitle| command:
\begin{verbatim}
\begin{teaserfigure}
\includegraphics[width=\textwidth]{sampleteaser}
\caption{figure caption}
\Description{figure description}
\end{teaserfigure}
\end{verbatim}
\section{Citations and Bibliographies}
The use of \BibTeX\ for the preparation and formatting of one's
references is strongly recommended. Authors' names should be complete
--- use full first names (``Donald E. Knuth'') not initials
(``D. E. Knuth'') --- and the salient identifying features of a
reference should be included: title, year, volume, number, pages,
article DOI, etc.
The bibliography is included in your source document with these two
commands, placed just before the \verb|\end{document}| command:
\begin{verbatim}
\bibliographystyle{ACM-Reference-Format}
\subsection{BOW models for IR}
Dense retrieval based on BERT Siamese models~\cite{sentence_bert} has become the standard approach for candidate generation in Question Answering and IR~\cite{guu2020realm,karpukhin2020dense,xiong2020approximate,lin2020distill,ding2020rocketqa}.
While the backbone of these models remains the same,
recent works highlight the critical aspects of the training strategy to obtain state-of-the-art results, ranging from improved negative sampling~\cite{xiong2020approximate,ding2020rocketqa} to distillation~\cite{hofstatter2020improving,lin2020distill}. ColBERT~\cite{colbert} pushes things further: the postponed token-level interactions allow to efficiently apply the model for first-stage retrieval, benefiting of the effectiveness of modeling fine-grained interactions, at the cost of storing embeddings for each (sub)term -- raising concerns about the actual scalability of the approach for large collections.
To the best of our knowledge, very few studies have discussed the impact of using \emph{approximate} nearest neighbors (ANN) search on IR metrics~\cite{boytsov2018efficient, tu2020approximate}.
Due to the moderate size of the MS MARCO collection, results are usually reported with an \emph{exact}, brute-force search, therefore giving no indication on the effective computing cost.
An alternative to dense indexes is term-based ones.
Building on standard BOW models, \textit{Zamani et al.} first introduced SNRM~\cite{snrm}: the model embeds documents and queries in a sparse high-dimensional latent space by means of $\ell_1$ regularization on representations.
However, SNRM effectiveness remains limited and its efficiency has been questioned~\cite{paria2020minimizing}.
More recently, there have been attempts to transfer the knowledge from pre-trained LM to sparse approaches.
Based on BERT, DeepCT~\cite{dai2019contextaware, 10.1145/3366423.3380258, 10.1145/3397271.3401204} focused on learning contextualized term weights in the full vocabulary space -- akin to BOW term weights.
However, as the vocabulary associated with a document remains the same, this type of approach does not solve the vocabulary mismatch, as acknowledged by the use of query expansion for retrieval \cite{dai2019contextaware}.
A first solution to this problem consists in expanding documents using generative approaches such as doc2query~\cite{nogueira2019document} and docTTTTTquery~\cite{doct5} to predict expansion words for documents. The document expansion adds new terms to documents -- hence fighting the vocabulary mismatch -- as well as repeats existing terms, implicitly performing re-weighting by boosting important terms. These methods are however limited by the way they are trained (predicting queries), which is indirect in nature and limit their progress.
A second solution to this problem, that has been chosen by recent works such as~\cite{sparterm2020,MacAvaney_2020,zhao2020sparta}, is to estimate the importance of each term of the vocabulary \emph{implied by} each term of the document, i.e. to compute an interaction matrix between the document or query tokens and all the tokens from the vocabulary. This is followed by an aggregation mechanism (roughly sum for SparTerm~\cite{sparterm2020}, max for EPIC~\cite{MacAvaney_2020} and SPARTA~\cite{zhao2020sparta}), that allows to compute an importance weight for each term of the vocabulary, for the full document or query.
However, EPIC and SPARTA (document) representations are not sparse enough by construction -- unless resorting on top-$k$ pooling -- contrary to SparTerm, for which fast retrieval is thus possible. Furthermore, the latter does not include (like SNRM) an \emph{explicit} sparsity regularization, which hinders its performance. Our SPLADE model relies on such regularization, as well as other key changes, that boost both the efficiency and the effectiveness of this type of models.
| {'timestamp': '2021-07-14T02:03:41', 'yymm': '2107', 'arxiv_id': '2107.05720', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05720'} | arxiv |
\section{Arrow Debreu Market Model}
In the Arrow--Debreu (AD) market model, agents do not have fixed budgets $w_i$ but obtain their budget from their shares in the items sold on the market. Each agent $i$ has an endowment, $e_{i} = \{{e}_{ij}\}_j$,
where $e_{ij}$ denotes agent $i$'s endowment of item $j$. We assume unit supply of each item, i.e., $\sum_i e_{ij} = 1$ for every $j$. At prices $p$, each agent $i$ has $w_i:=p^\top e_i$ money to spend.
\begin{defi}[AD equilibrium] In an AD market with utilities $\{u_i\}_i$ and endowments $\{e_i\}_i$, the allocations and prices $(\{x_{i}\}_{i}, \{p_j\}_j)$ form a market equilibrium if
\begin{itemize}
\setlength\itemsep{0em}
\item $x_i \in D_i(p, w_i)$;
\item $\sum_i x_{ij} \leq 1$, and if $p_j > 0$, then $\sum_i x_{ij} = 1$.
\end{itemize}
\end{defi}
Note that scaling the prices $p$ in a market equilibrium by any positive factor results in another equilibrium. Therefore, in the definition of an approximate market equilibrium, we include the normalization constraint $\sum_j p_j \geq 1$.
\begin{defi}[approximate AD equilibrium] In an AD market with utilities $\{u_i\}_i$ and endowments $\{e_i\}_i$ that satisfies assumption \eqref{eq:V-max}, the allocations and prices $(\{x_{i}\}_{i}, \{p_j\}_j)$ form a $(\sigma, \lambda)$-approximate market equilibrium if
\begin{itemize}
\setlength\itemsep{0em}
\item $u_i(x_i) \geq V_i(p, w_i) - \lambda$;
\item $p^\top x_i \leq w_i + \sigma$;
\item $\sum_i x_{ij} \leq 1$, and $\sum_j p_j (1 - \sum_i x_{ij}) \leq \sigma $;
\item $\sum_j p_j \geq 1$.
\end{itemize}
\end{defi}
In contrast to Fisher markets, equilibrium existence in AD markets is guaranteed only under certain assumptions. In fact, already for separable PLC utilities and arbitrary endowments, it is NP-hard to decide whether an equilibrium exists~\cite{VaziraniY11}.
Correspondingly, our results on Arrow--Debreu markets apply only for the more restrictive piecewise-linear concave (PLC) utilities, and under the assumption that every agent has a positive share in every item. Our assumptions are the following:
\begin{equation}
\label{AD-assumptions}
\begin{aligned}
u_i(x_i) &= \min_l \Big\{\sum_j a_{ij}^l x_{ij} + b_i^l\Big\},\mbox{ and }\min_lb_i^l=0 \quad \quad \forall i\, ,\qquad \quad a_{ij}^l\geq 0 \quad\forall i,j,l\\
e_{ij} &> 0 \quad \forall i, j \enspace .
\end{aligned}
\end{equation}
Any PLC utility can be affinely transformed to the above form; hence, $\min_l b_i^l=0$ \hide{and $a_{ij}^l\le 1$} is without loss of generality.
Note that $\min_l b_i^l=0$ guarantees that $u_i(0)=0$; thus, these utilities are regular.
Under the even stronger assumption that all $a_{ij}^l$'s are positive, existence follows from the classical theorem of Arrow and Debreu. Note that under this assumption, all equilibria are also thrifty.
\begin{theorem}[market equilibrium existence \cite{arrow1954existence}] \label{thm::exist-ad}
If the utilities satisfy \eqref{AD-assumptions} and further all coefficients $a_{ij}^l > 0$, then a market equilibrium always exists.
\end{theorem}
\section{Approximate Arrow-Debreu market equilibrium}\label{sec:ad}
In this section, we show how to compute an approximate Arrow-Debreu (AD) market equilibrium with \eqref{AD-assumptions}, when either the number of agents or items is constant. We note that while an equilibrium is only guaranteed to exists with $a_{ij}^l>0$ (Theorem~\ref{thm::exist-ad}), we show the existence of approximate equilibria under the weaker assumption $a_{ij}^l\ge0$.
Both for a fixed number of items and fixed number of agents, the key is to perturb the utilities to $\xi$-robust utilities. However, we use a different, simpler perturbation as in \eqref{lp::nametwo-utility-constraint} using that the utilities are PLC.
\begin{equation}\label{eq:bu}
\bar u^{\xi}_i(x_i) = \min_l \left\{\sum_j \left(a_{ij}^l + \frac{\xi}{m}\right) x_{ij} + b_i^l\right\}\, .
\end{equation}
\begin{lemma}\label{lem::ad-u-1}
$\bar u_i^{\xi}$ is a $\xi$-$\text{robust}$ utility function. Additionally, for any $x_i$, $\bar u^{\xi}_i(x_i) \geq u_i(x_i)$, and for any $x_i\in [0,1]^m$, $\bar u^{\xi}_i(x_i) \leq u_i(x_i) + \xi$.
\end{lemma}
\begin{proof}
For the $\xi$-robustness, regularity is immediate by assumption \eqref{AD-assumptions}.
The other property in the definition follows since
with additional $\sigma$ amount of money, agent $i$ can buy each item with amount $\frac{\sigma}{\sum_j p_j}$, which, in total, provides at least $\frac{\sigma \xi}{\sum_j p_j}$ additional amount of utility. The other bounds are immediate.
\end{proof}
\subsection{Fixed number of agents}
Similar to the Fisher market case, we first show how to compute market equilibrium with $\xi$-\text{robust}\ utilities, and then we show how to approximate the PLC utilities by $\xi$-\text{robust}\ utilities.
For $\xi$-robust utilities, the algorithm is a simple modification of the one in Section~\ref{sec::cal-equilibrium-nametwo}. The main difference is that the budgets are not fixed but defined according to the prices.
We guess the equilibrium utilities (approximately) for all players, $\{\tilde{u}_i\}_i$, and then calculate the allocation by \eqref{lp::cal-allocation}. We use the linear system comprising \eqref{dual-lp::utility-upper-used}, \eqref{lp::budget-constraint-used}, and \eqref{lp::market-clear} and the following additional constraints:
\begin{align*}
&p^\top e_{i} = w_i\quad \forall i\, , \\
&\sum_j p_j = 1\, . \numberthis \label{lp::endowment-budget}
\end{align*}
We can obtain the following similarly to Theorem~\ref{thm::fisher-market-constant-item-first}:
\begin{theorem} \label{thm::ad-pp}
Suppose the utility functions are $\xi$-\text{robust}\ and the Arrow Debreu market equilibrium $(\{x^*_i\}_i, \{p^*_j\}_j)$ exists. For any $\{\tilde{u}_i\}_i$, $\{x_{i}\}_i$ and $\{p_j\}_j$ such that \eqref{lp::cal-allocation}, \eqref{dual-lp::utility-upper-used}, \eqref{lp::budget-constraint-used}, \eqref{lp::market-clear}, \eqref{lp::endowment-budget} holds, $(\{x_i\}_i, \{p_j\}_j)$ is a $(n\delta/\xi,2 \delta)$-approximate equilibrium.
\hide{\begin{enumerate}
\item for any $i$, $\tilde{u}_i + \delta + \eta \geq \max_{x_{ij} \geq 0, p^\top x_i \leq p^\top e_{i}} \{ \min \{\sum_j a_{ij}^l x_{ij} + b_i^l\}$;
\item for any $i$, $u_i(x_i) \geq \tilde{u}_i$;
\item for any $i$, $ p^\top x_i \leq w_i + \frac{n\delta \sum_i w_i}{\xi}$;
\item for any $j$, $\sum_i x_{ij} \leq 1$;
\item $\sum_j p_j ( 1 - \sum_i x_{ij} ) \leq \frac{n\delta \sum_i w_i}{\xi}$;
\item for any $i$, $p^\top e_{i} = w_i$;
\item $\sum_j p_j \geq 1$.
\end{enumerate}}
Additionally, if ${u}^*_i - \delta < \tilde{u}_i \leq {u}^*_i$ for all $i$, then for any $\{x_i\}_i$ such that $\eqref{lp::cal-allocation}$ holds, $\{p^*_j\}_j$ is a solution to \eqref{dual-lp::utility-upper-used}, \eqref{lp::budget-constraint-used}, \eqref{lp::market-clear}, and \eqref{lp::endowment-budget}.
\end{theorem}
\iffalse
\begin{proof} Note that $\sum_i w_i = \sum_i p^\top e_{i} = \sum_j p_j = 1$.
The first part holds by Theorem~\ref{thm::fisher-market-constant-item-first} and \eqref{lp::endowment-budget}. For the remaining parts, let $w_i^* = {p^*}^\top e_{i}$. Since, $(\{w_i^*\}_i, \{x_i^*\}_i, \{p_j^*\}_j)$ is a thrifty Fisher market equilibrium. By Theorem~\ref{thm::fisher-market-constant-item-first}, $\{p^*_j\}_j$ is a solution to \eqref{dual-lp::utility-upper-used}, \eqref{lp::budget-constraint-used}, \eqref{lp::market-clear}, and \eqref{lp::endowment-budget}.
\end{proof}
\fi
\medskip
For the overall algorithm, we approximate the utilities $u_i$ by $\bar u_i^\xi$ as in \eqref{eq:bu}. We obtain the following similarly to Theorem~\ref{lem::fisher-algorithm-const-agent}. Note that the existence of an equilibrium is guaranteed for $\bar u_i^\xi$ by Theorem~\ref{thm::exist-ad}. \hide{ even though an exact equilibrium may not exist for the $u_i$'s.}
\begin{theorem}
In an Arrow Debreu market with $n$ agents, $m$ items,
and PLC utility functions $u_i$ with non-negative $a_{ij}^l$'s and $\sigma < 1$, we can compute a $\sigma$-approximate thrifty market equilibrium by solving $O(\left( \frac{n}{\sigma^2}\right)^n)$ linear programs, each in polynomial time in $n$, $m$, the bit-complexity of the $a_{ij}^l$'s, $\log(1/\sigma)$ and $e_i$'s.
\end{theorem}
\iffalse
\begin{proof}
Let us set $\delta=\sigma^2/(2n)$ and $\xi=\sigma/2$.
We first replace the utility functions $u_i$ by $ u_i^\xi$ as in Lemma~\ref{lem:CPLC-robust}. Then, we guess all combinations
$\tilde{u}_i = k_i \delta$, for $0 \leq k_i \leq \lceil \frac{1}{\delta}\rceil + 1$. We calculate the allocations $x$ as in \eqref{lp::cal-allocation}; if no such allocation exists, we proceed to the next guess. If $x$ is feasible to \eqref{lp::cal-allocation}, then we check if prices $p$ and budgets $w_i$ satisfying \eqref{dual-lp::utility-upper-used}, \eqref{lp::budget-constraint-used}, \eqref{lp::market-clear}, and \eqref{lp::endowment-budget} exist.
Theorems~\ref{thm::ad-pp} and \ref{thm::exist-ad} guarantee the existence of $x$, $p$, and $w_i$'s for at least one choice of the $\tilde u_i$'s.
This gives a $(n\delta/\xi,2\delta)$-approximate equilibrium for the utilities $u_i^\xi$, and by Lemma~\ref{lem::ad-u-1}, a
$(n\delta/\xi,2\delta+\xi)$-approximate equilibrium for the original utilities $u_i$. By the choice of $\delta$ and $\xi$, this is a $\sigma$-approximate equilibrium.
\end{proof}
\fi
\subsection{Fixed number of items}
In this section, we assume $a_{ij}^l \leq 1$ for any $i$, $j$ and $l$. The algorithm is more difficult as in Section~\ref{sec:Fisher-items}: we also rely on the robust approximate $\bar u_i^\xi$ as in the fixed number of agents case.
The benefit of using $\bar u_i^\xi$ is that we are able to lower bound the equilibrium prices:
\iffalse
We first compute an approximate Arrow Debreu market equilibrium for $\{u^{\xi}_i\}_i$, then we show this is also an approximate Arrow Debreu market equilibrium for $\{u_i\}_i$. Note that by Theorem~\ref{thm::exist-ad}, there always exists an exact Arrow Debreu market equilibrium for $\{u^{\xi}_i\}_i$. Let $(\{x^*_i\}_i, \{p_j^*\}_j)$ be the Arrow-Debreu market equilibrium for $\{u^{\xi}_i\}_i$ such that $\sum_j p^*_j = 1$.
We first show the following property of $(\{x^*_i\}_i, \{p^*_j\}_j)$.
\fi
\begin{lemma}\label{lem:min-price}
For $\xi>0$, let $(\{x^*_i\}_i, \{p^*_j\}_j)$ be a market equilibrium for the utilities $\bar u_i^\xi$ with $\sum_j p^*_j=1$. Then
$p^*_j \geq \frac{\xi}{m(m+\xi)}$ for all items $j$.
\end{lemma}
\begin{proof}
For a contradiction,
suppose there is an item $j$ such that $p^*_j < \frac{\xi}{m(m+\xi)}$. We must still have $p^*_j>0$: due to the form of $\bar u_i^\xi$: the marginal utility of every good is strictly positive with respect to any bundle, and therefore all prices at equilibrium are strictly positive.
Let us select the most expensive item $j'$; by the assumption on the sum of the prices, $p^*_{j'} \geq \frac{1}{m}$. Therefore,
\begin{equation}\label{eq:p-p-p}
\frac{\xi}{m p^*_j} > \left({1 + \frac{\xi}{m}}\right)\cdot\frac{1}{p^*_{j'}}\end{equation}
Consider an agent $i$ such that $x^*_{ij'} > 0$, and let $s_i = x^*_{ij'} p^*_{j'}>0$. Consider an alternative allocation $x'_i$ in which agent $i$ spends this $s_i$ amount of money on item $j$ instead of item $j'$:
\begin{align*}
x'_{ik} = \begin{cases}
x^*_{ik} \, , & \quad \text{if } k \neq j, j'\, ,\\
x^*_{ik} + \frac{s_i}{p^*_j}\, , & \quad \text{if } k = j\, ,\\
0\, , & \quad \text{if } k = j'\, .\\
\end{cases}.
\end{align*}
Then, for any $l$, from \eqref{eq:p-p-p} and the bound $a_{ij'}^l \le 1$ we see that
\begin{align*}
\left(a_{ij}^l + \frac{\xi}{m}\right) x'_{ij} + b_i^l &\geq \left(a_{ij}^l + \frac{\xi}{m}\right) x^*_{ij} + b_i^l + \left(a_{ij}^l + \frac{\xi}{m}\right) \frac{s_i}{p^*_j} - \left(a_{ij'}^l + \frac{\xi}{m}\right) \frac{s_i}{p^*_{j'}} \\
&\geq \left(a_{ij}^l + \frac{\xi}{m}\right) x^*_{ij} + b_i^l + \frac{\xi}{m} \frac{s_i}{p^*_j} - \left(1 + \frac{\xi}{m}\right) \frac{s_i}{p^*_{j'}} \\
&> \left(a_{ij}^l + \frac{\xi}{m}\right) x^*_{ij} + b_i^l
\end{align*}
This implies $x^*_i$ is not the optimal allocation for agent $i$, which gives a contradiction.
\end{proof}
Next, we give the algorithm.
\paragraph{Algorithm}
Similar to the Fisher-market, first, we enumerate ${p}_j = \delta k_j$ for all possible integers $k_j$ such that $0 \leq k_j \leq \left\lceil\frac{1}{\delta}\right\rceil + 1$ and $1 \leq \sum_j {p}_j \leq 1 + m\delta$. We then calculate the budget $w_i = {p}^\top e_{i}$. With this budget and given the prices, we calculate the optimal utility $V^\xi_i(p,w_i)$ for $\bar u^{\xi}_i(x_i)$; this can be found by solving a linear program.
Then, we calculate a feasible allocation $\{x_i\}_i$ by the following linear program:
\begin{equation}\label{lp::ad-const-item}
\begin{aligned}
& \bar u^{\xi}_i(x_i) \geq V^\xi_i( p,w_i) - \frac{\delta m (m+ \xi)^2}{\xi}&\forall i\\
& \sum_j x_{ij} {p}_j \leq w_i + \delta m &\forall i\\
& \sum_i x_{ij} =1&\forall j \\
&x_{ij} \geq 0 &\forall i,j.
\end{aligned}
\end{equation}
If there is a feasible allocation $\{x_i\}_i$ to \eqref{lp::ad-const-item}, then we output the solution $(\{x_i\}_i, \{{p}_j\}_j)$.
The following lemma ensures that if $\{{p}_j\}_j$ is close to $\{p^*_j\}_j$, then $x^*$ is a feasible solution to \eqref{lp::ad-const-item}.
\begin{lemma}
If $p^*_j \leq {p}_j \leq p^*_j+ \delta$ for all $j$, then for any $i$, $V^\xi_i(p,w_i) \leq \bar u^{\xi}_i(x^*_i) + \frac{\delta m (m + {\xi})^2}{\xi}$ and $\sum_j x^*_{ij} {p}_j \leq w_i + \delta m$. Additionally, $\sum_i x^*_{ij} = 1$.
\end{lemma}
\begin{proof}
Note that if $p^*_j \leq p_j \leq p^*_j + \delta$, $w_i \leq (p^*)^\top e_i+ \delta m $.
Since $a_{ij}^l\le 1$, the maximum amount of utility that can be obtained from $\varepsilon$ additional units of items is $\left(1+\frac{\xi}m\right)\varepsilon$. Moreover, $\delta m$ additional amount of money can buy at most $\delta m/\min_j p_j^*$ additional units of items.
Therefore,
\begin{align*}
V^\xi_i(p,w_i) - \bar u^{\xi}_i(x^*_i)&=V^\xi_i(p,w_i)-V^\xi_i(p,(p^*)^\top e_i ) \leq \left(1+\frac{\xi}m\right)\cdot \frac{\delta m}{\min_j p_j^*}\leq \frac{\delta m (1 +\xi)^2}{\xi}\, ,
\end{align*}
where the last inequality follows by Lemma~\ref{lem:min-price}.
Also, $\sum_j {p}_j x^*_{ij}\leq \sum_j p^*_j x^*_{ij} + \delta m = (p^*)^\top e_i + \delta m \leq p^\top e_i+ \delta m = w_i + \delta_i$. Finally, $\sum_i x^*_{ij}=1$ is true by the market equilibrium definition, using that all equilibrium prices must be positive, as previously noted.
\end{proof}
Therefore, we obtain the following theorem.
\begin{theorem}\label{thm::ad-fixed-items}
Given an Arrow Debreu market with $n$ agents, $m$ items,
and PLC utility functions $u_i$ such that $a_{ij}^l \in [0, 1]$ for any $i$, $j$ and $l$, we can compute a $(\sigma, \sigma)$-approximate thrifty market equilibrium by solving $O((12m^3 / \sigma^2)^m)$ linear programs, each in polynomial time in $n$, $m$, the bit-complexity of the $e_i$'s, $a_{ij}^l$'s, and $\log(1/\sigma)$.
\end{theorem}
\begin{proof} Let $\xi = \frac{\sigma}{2}$, $\delta = \frac{\sigma^2}{12 m^3}$, and $(\{x_i\}_i, \{p_j\}_j)$ be the approximate equilibrium calculated by the algorithm. Then,
\begin{align*}
u_i(x_i) &\geq u^{\xi}_i(x_i) - \xi ~~~~~\text{(by Lemma~\ref{lem::ad-u-1})}\\
&\geq V^\xi_i( p,w_i) - \xi- \frac{\delta m (m+ \xi)^2}{\xi} ~~~~~\text{(by \eqref{lp::ad-const-item})}\\
&\geq V_i( p,w_i) - \xi- \frac{\delta m (m+ \xi)^2}{\xi} ~~~~~\text{(by Lemma~\ref{lem::ad-u-1})}\\
&\geq V_i( p,w_i) -\sigma\, .
\end{align*}
Additionally, $\sum_j x_{ij} p_j \leq \sum_j e_{ij} p_j + \delta m \leq \sum_j e_{ij} p_j + \sigma$.
\end{proof}
\section{Approximate Fisher equilibrium for fixed number of agents}\label{sec:Fisher-agents}
In this section, we design a polynomial-time algorithm to compute an approximate equilibrium with constant number of agents for constrained PLC utility functions.
Recall that $V^{\max}_i$ is the maximum utility achievable on $[0,1]^m$, and $C^{\min}_i(p)$ is the minimum cost for achieving utility $V^{\max}_i$ at prices $p$. Also recall assumptions \eqref{eq:V-max} and \eqref{eq:V-max-pos}, that $V^{\max}_i\in (0,1]$ for all agents; we make this assumption throughout. The following class of utility functions plays a key role:
\begin{defi}[$\xi$-$\text{robust}$ utility function]\label{def::utility-nametwo}
A regular utility function $u_i$ is $\xi$-$\text{robust}$, if for any
bundle $x_i\in \mathbb{R}^m_+$, prices $p\in \mathbb{R}^m_+$ and $\sigma>0$
such that $p^\top x_i\le C^{\min}_i(p)-\sigma$, there exists a bundle $y\in\mathbb{R}^m_+$ such that $p^\top y\le p^\top x_i+\sigma$ and $u_i(y) \geq u_i(x_i)+\frac{\sigma \xi}{\sum_j p_j}$.
\end{defi}
For this class of utility functions, in Section~\ref{sec::cal-equilibrium-nametwo}, we show how to compute an approximate thrifty market equilibrium. However, not all $\text{regular}$ utilities are $\xi$-$\text{robust}$ for some $\xi > 0$. For example, $u_i(x_i) = 0$ is not $\xi$-$\text{robust}$ for any positive $\xi$, while $u_i(x_i) = \varepsilon \sum_j x_{ij}$
is $\varepsilon m $-$\text{robust}$ for $\varepsilon > 0$. In Section~\ref{sec::approx-nametwo}, we show how to approximate any $\text{regular}$ utilities by $\text{robust}$ utilities.
In the overall algorithm, we approximate the $\text{regular}$ utility functions by $\xi$-$\text{robust}$ utility functions. Then, we can calculate an approximate thrifty market equilibrium for these $\xi$-$\text{robust}$ utility functions. Finally, we show that the approximate market equilibrium we calculated will also be the approximate market equilibrium for the original utility functions (but not necessarily a thrifty one).
\subsection[{Approximate equilibrium for xi-robust utilities}]{Approximate equilibria for $\xi$-$\text{robust}$ utilities}\label{sec::cal-equilibrium-nametwo}
By Theorem~\ref{thm::fisher-exists}, we know there exists a thrifty market equilibrium for $\xi$-$\text{robust}$ utilities. Let $(x^*,p^*)$ denote a thrifty market equilibrium and let $u^*_i$ denote the utility achieved by agent $i$ at the equilibrium.
The algorithm has two steps: first, guess each agent's utility at equilibrium and compute a feasible allocation giving each agent at least the guessed utility, and second, compute the prices that, together with the calculated allocation, give an approximate market equilibrium. In Theorem~\ref{thm::fisher-market-constant-item-first}, we give a $(n\delta/\xi,2\delta)$-approximate thrifty equilibrium for some parameter $\delta>0$. This is achieved by solving $O(1/\delta^n)$
convex programs.
\subsubsection{Guessing utilities and computing the allocation}
We first guess agents' utilities at equilibrium by enumerating all possible utilities of each agent, $\tilde{u}_i = k_i \delta$, for $0 \leq k_i \leq \lceil \frac{1}{\delta}\rceil + 1$. Then, we compute a feasible allocation $x=(x_1,\dots,x_n)$ giving $\tilde{u}_i$ utility to agent $i$ using the following program:
\begin{equation}\label{lp::cal-allocation}
\begin{aligned}
& u_i(x_i) \geq \tilde{u}_i\, , &\forall i \\
&\sum_i x_{ij} \leq 1\, , &\forall j \\
& x \geq 0
\end{aligned}
\end{equation}
If \eqref{lp::cal-allocation} is infeasible, we move to the next utility profile.
The following lemma shows that if we have a right guess on the utilities, then, with the equilibrium price $p^*$, the spending of agent $i$ at $x_i$ should be similar to that at $x_i^*$.
\begin{lemma} \label{lem::budget-lower}
Assume the utility functions are $\xi$-$\text{robust}$, $u^*_i - \delta < \tilde{u}_i \leq u^*_i$, and $\{x_i\}_i$ is a feasible solution to \eqref{lp::cal-allocation}. Then,
\begin{enumerate}[(i)]
\item $\displaystyle{(p^*)^\top x^*_i - \frac{\delta \sum_i w_i}{\xi} \leq (p^*)^\top x_i \leq (p^*)^\top x^*_i + \frac{\delta n \sum_i w_i}{\xi}}$, and
\item $\displaystyle{\sum_j p_j^* \left(1 - \sum_i x_{ij}\right) \leq \frac{n\delta \sum_i w_i}{\xi}} $.
\end{enumerate}
\end{lemma}
\begin{proof}
We first consider the lower bound in {\em (i)}. Let us denote $\sigma= {\delta \sum_i w_i}/{\xi}$.
For a contradiction, assume $(p^*)^\top x^*_i -\sigma>(p^*)^\top x_i$.
Since this is a thrifty equilibrium,
$(p^*)^\top x^*_i= C_i(p^*,w_i)\le C^{\min}_i(p^*)$, since the optimal bundle $x_i^*$ in $[0,1]^m$.
By the $\xi$-robustness property, there exists a bundle $y$ such that
$(p^*)^\top y\le (p^*)^\top x_i+\sigma<(p^*)^\top x^*_i\le w_i$ and
\[
u_i(y)\ge u_i(x_i)+\frac{\sigma\xi}{\sum_j p^*_j}\ge u_i(x_i) +\frac{\delta \sum_i w_i}{\sum_j p^*_j}> u_i^*(x_i)-\delta+\delta= u_i^*(x_i)\, ,
\]
a contradiction since $u_i^*(x_i)$ is the maximum utility at budget $w_i$. The third inequality uses that all items with $p^*_j>0$ are fully sold, and therefore the sum of the prices is at most the sum of the budgets.
For the upper bound, note that $p^*_j = 0$ if $\sum_i x^*_{ij} < 1$. Therefore, $\sum_j p^*_j \left(\sum_i x^*_{ij}\right) \geq \sum_j p^*_j \left(\sum_i x_{ij}\right)$. Additionally, the lower bound give $\sum_j p^*_j x_{ij} \geq \sum_j p^*_j x^*_{ij} - \frac{\delta \sum_i w_i}{\xi}$ for each $i$, which completes the proof.
Part {\em (ii)} is immediate by summing up the lower bounds in part {\em (i)} for all $i$.
\end{proof}
\subsubsection{Computing the prices}
Assume that for the guesses $\{\tilde{u}_i\}_i$, we found an allocation $x$ that satisfies \eqref{lp::cal-allocation}, i.e., and allocation of the items that provides at least $\tilde{u}_i$ amount of utility to each $i$. In what follows, our goal is to find prices $p$ that form an approximate equilibrium with $x$.
This is the most challenging part of the algorithm. The prices have to satisfy the following three conditions.
\paragraph{First condition: utility upper bound}
If the guesses $\{\tilde{u}_i\}_i$ were approximately correct, then
the maximum utility $V_i(p,w_i)$ achievable at prices $p$ should be close to $\tilde{u}_i$ for each agent $i$.
Since the utility functions are constrained PLC, we can compute $V_i(p,w_i)$ as
\begin{equation*}
\begin{aligned}
&\max& q_i^\top z_i + s_i^\top t_i\\
&\text{ s.t. }& A_i z_i + B_i t_i\leq b_i \\
&& p^\top z_i\leq w_i\\
&& z_i\ge 0
\end{aligned}
\end{equation*}
The dual of this program is as follows, using variables $\gamma_i$ and $\beta_i$ for the first two constraints, respectively.
\begin{equation}\label{dual-lp::utility-upper}
\begin{aligned}
&\min& b_i^\top\gamma_i + w_i \beta_i \\
&\text{ s.t. }& A_i^{\top} \gamma_i + \beta_i p \geq q_i \\
&& B_i^\top \gamma_i = s_i \enspace \\
&& \gamma_i,\beta_i\ge
\end{aligned}
\end{equation}
For every feasible dual solution, the objective value provides an upper bound on the optimal utility agent $i$ can get. Therefore, $V_i(p,w_i)\le\tilde{u}_i + \delta$ if and only if there exists a feasible solution $(\gamma_i, \beta_i)$ to \eqref{dual-lp::utility-upper} such that $\gamma_i^\top b_i + \beta_i w_i\le\tilde{u}_i + \delta$.
However, if we also consider the prices $p$ as variables, the program is not linear anymore. For this reason, we use a variable substitution, by letting
$$\frac{1}{\beta_i} \triangleq \overline{\beta_i} \ \ \text{ and } \ \ \frac{\gamma_i}{\beta_i} \triangleq \overline{\gamma_i}$$ be the variables and we set a lower bound on $\frac{1}{\beta_i}$ such that the optimal solution of \eqref{dual-lp::utility-upper} doesn't change much.
\begin{lemma}\label{lem::utility-upper-used}
For $\delta\in (0,1)$, consider a feasible solution $(\overline{\gamma_i}, \overline{\beta_i}, p)$ to following program,
\begin{equation}\label{dual-lp::utility-upper-used}
\begin{aligned}
&b_i^\top \overline{\gamma_i}+w_i \leq \overline{\beta_i} (\tilde{u}_i + 2\delta)\\
& {A_i}^\top \overline{\gamma_i} + p \geq \overline{\beta_i} q_i \\
& {B_i}^\top \overline{\gamma_i} = \overline{\beta_i} s_i \\
&{w_i} \leq \overline{\beta_i}
\end{aligned}
\end{equation}
Then, the optimal utility for agent $i$ to achieve with price $p$ is at most $\tilde{u}_i + 2\delta$. Additionally, if $u^*_i - \delta < \tilde{u}_i \leq u^*_i$, then there exist $\overline{\gamma_i}$ and $\overline{\beta_i}$ such that $(\overline{\gamma_i}, \overline{\beta_i}, p^*)$ is a solution to this program.
\end{lemma}
\begin{proof}
First, if $(\overline{\gamma_i}, \overline{\beta_i}, p)$ is a feasible solution to \eqref{dual-lp::utility-upper-used}, then $(\beta_i = \frac{1}{\overline{\beta_i}}, \gamma_i = \frac{\overline{\gamma_i}}{\overline{\beta_i}}, p)$ is a feasible solution to \eqref{dual-lp::utility-upper}. Therefore, the optimal utility one can get at price $p$ is at most $b_i^\top \gamma_i + \beta_i w_i = \frac{1}{\overline{\beta_i}} (b_i^\top\overline{\gamma_i} +w_i) \leq \tilde{u}_i + 2\delta$.
For the second part, consider the optimal solution $(\gamma_i, \beta_i)$ to \eqref{dual-lp::utility-upper} with the price $p^*$. Then, clearly, $ b_i^\top \gamma_i + \beta_i w_i = u_i(x_i^*)$ and $(\gamma_i, \beta_i)$ is also a feasible solution with price $p^*$ and $w_i = 0$, which implies $b_i^\top \gamma_i \geq u_i(0) =0$. Combining with the fact that $b_i^\top \gamma_i + \beta_i w_i = u_i(x_i^*) \leq 1$, we get $\beta_i \leq \frac{1}{w_i}$. Therefore, if we consider the solution $\overline{\gamma_i} = \frac{\gamma_i}{\max\{\beta_i, \frac{\delta}{w_i} \}}$, $\overline{\beta_i} = \frac{1}{\max\{\beta_i, \frac{\delta}{w_i}\}}$, then it satisfies all conditions in \eqref{dual-lp::utility-upper-used} as $b_i^\top \gamma_i + \beta_i w_i = u_i(x_i^*)< \tilde{u}_i + \delta$.
\end{proof}
We note that this is the only part in the algorithm where we rely on the particular form of constrained PLC utilities; all other arguments work more generally, for regular utilities.
\paragraph{Second condition: budget constraint} The cost of the allocation at prices $p$ must not violate the budget constraints by much:
\begin{align}
p^\top x_i \leq w_i + \frac{n\delta \sum_i w_i}{\xi}, \quad\forall i\, . \numberthis \label{lp::budget-constraint-used}
\end{align}
\paragraph{Third condition: market clearing} The market needs to approximately clear:
\begin{align*}
\sum_j p_j \left( 1 - \sum_i x_{ij} \right) \leq \frac{n\delta \sum_i w_i}{\xi}. \numberthis \label{lp::market-clear}
\end{align*}
Lemma~\ref{lem::budget-lower} implies the following:
\begin{lemma}\label{lem::budget-upper-lp}
Assume that the utility functions are $\xi$-$\text{robust}$. If for all agents $i$, ${u}^*_i - \delta < \tilde{u}_i \leq {u}^*_i$, then for any allocation $x$ for which $\eqref{lp::cal-allocation}$ holds, the optimal prices $p^*$ satisfy \eqref{lp::budget-constraint-used} and \eqref{lp::market-clear}.
\end{lemma}
Note that \eqref{dual-lp::utility-upper-used}, \eqref{lp::budget-constraint-used}, and \eqref{lp::market-clear} are linear in $p$, $\overline{\beta}$, and $\overline{\gamma}$. Combining Lemmas~\ref{lem::utility-upper-used} and \ref{lem::budget-upper-lp}, we have the following:
\begin{theorem} \label{thm::fisher-market-constant-item-first}
Suppose the utility functions are $\xi$-$\text{robust}$. For any $\tilde{u}_i$, $x$ and $p$ such that \eqref{lp::cal-allocation}, \eqref{dual-lp::utility-upper-used}, \eqref{lp::budget-constraint-used}, and \eqref{lp::market-clear} holds, $(x,p)$ is a $(n\delta/\xi,2\delta)$-approximate market equilibrium.
Additionally, let $(x^*, p^*)$ be any thrifty market equilibrium. If ${u_i}(x^*_i) - \delta < \tilde{u}_i \leq {u}_i(x^*_i)$ for all $i$, then for any $x$ such that $\eqref{lp::cal-allocation}$ holds, $p^*$ is a solution to \eqref{dual-lp::utility-upper-used}, \eqref{lp::budget-constraint-used}, and \eqref{lp::market-clear}.
\end{theorem}
\subsection[Approximating regular by robust utilities]{Approximating $\text{regular}$ utilities by $\xi$-$\text{robust}$ utilities} \label{sec::approx-nametwo}
We introduce an approach to approximate regular utilities by $\xi$-$\text{robust}$ utilities. The construction works for the general class of regular functions; for constrained PLC utilities, we show that this operation yields a constrained PLC utility.
Consider a regular utility function $u_i:\mathbb{R}^m_+\to\mathbb{R}\cup\{-\infty\}$, and define the \emph{perspective function} with domain $\mathbb{R}^{m+1}_+$; see \cite[Chapter 5]{Rockafellar}.
\[
\hat u_i(x,\alpha)=\begin{cases}
\alpha u_i\left(\frac{x}{\alpha}\right)\, ,& \text{if } \alpha>0\, ,\\
\lim_{\alpha\to 0} \alpha u_i\left(\frac{x}{\alpha}\right)\, ,& \text{if }\alpha=0\, .\end{cases}\,
\]
If $u_i$ is concave and upper semicontinuous (that hold for regular utilities), then so is $\hat u_i$ \cite[Proposition 2.3(ii)]{Combettes2018}. Also note that $u_i$ is positively homogeneous.
For given $\xi>0$, we define $u_i^\xi:\mathbb{R}^m_+\to\mathbb{R}\cup\{-\infty\}$, where
\[
\begin{aligned}
u_i^\xi(x_i)=&\max& \hat u_i(x',\alpha)+\hat u_i(x'',1-\alpha)+(1-\alpha)\xi\\
&\text{ s.t. }&
\hat u_i(x'',1-\alpha)\ge (1-\alpha)V^{\max}_i\\
&&x'+x''=x_i\\
&&0\le\alpha\le 1\\
&&x',x''\ge 0 \enspace .
\end{aligned}
\]
Note that the maximum exists as the objective is convex over a compact domain.
\begin{lemma}\label{lem:perturb-close}
For every regular utility function $u_i$ and $\xi>0$, the following hold for $u_i^\xi$:
\begin{enumerate}[(i)]
\item $u_i(x_i)\le u_i^\xi(x_i)\le u_i(x_i) +\xi$.
\item
We have $\max_{x\in[0,1]^m} u_i^\xi(x)=V^{\max}+\xi$. For any price vector $p$, the minimum cost of achieving utility $V^{\max}_i+\xi$ for $u_i^\xi$ is the same as the minimum cost $C^{\min}_i(p)$ of achieving utility $V^{\max}_i$ for $u_i$.
\end{enumerate}
\end{lemma}
\begin{proof}
{\bf Part {\em (i)}:} The lower bound $u_i(x_i)\le u_i^\xi(x_i)$ holds since $x'=x_i$, $x''=0$, $\alpha=1$ is a feasible solution in the definition of $u_i^\xi(x_i)$. The upper bound follows by the concavity of $\hat u_i$. For any $x'+x''=x_i$ and $\alpha\in [0,1]$, we have
\[
\hat u_i(x',\alpha)+\hat u_i(x'',1-\alpha)+(1-\alpha)\xi\le \hat u_i\left(\frac{x_i}{2},\frac{1}2\right)+(1-\alpha)\xi\le u_i(x_i)+\xi\, .
\]
{\bf\noindent
Part {\em (ii)}:} By the previous part, $\max_{x\in[0,1]^m} u_i^\xi(x)\leV^{\max}+\xi$. Equality is achieved
for any $x_i\in [0,1]^m$ for which $u_i(x_i)=V^{\max}_i$ with the choice $x'=0$, $x''=x$, $\alpha=0$. For the second part, consider any price vector $p$. Note that the set $\{x_i\ |\ u_i^\xi(x_i) \geq V_i^* + \xi\}$ is the same as $\{x_i\ |\ u_i(x_i) \geq V_i^*\}$, which completes the proof.
\end{proof}
The next lemma asserts the key property for $\xi$-robustness:
\begin{lemma} \label{lem::utility-perturb-add}
Given prices $p\in\mathbb{R}^m_+$ and $\sigma> 0$, let $x_i\in\mathbb{R}^m_+$ be a bundle such that $p^\top x_i\le C^{\min}_i(p)-\sigma$. Then, there exists a bundle $y\in\mathbb{R}^m_+$ such that $p^\top y\le p^\top x_i+\sigma$, and
$u_i^\xi(y)\ge u_i^\xi(x_i)+\frac{\sigma \xi}{\sum_j p_j}$.
\end{lemma}
\begin{proof}
Let us use the notation $C=C^{\min}_i(p)$; by Lemma~\ref{lem:perturb-close}(ii), this is the minimum cost of a bundle of utility $V^{\max}_i+\xi$.
Let us use the combination $x_i=x'_i+x''_i$ and $\alpha\in[0,1]$ that gives the value of $u_i^\xi(x_i)$, that is,
\[
u_i^\xi(x_i)=\hat u_i(x',\alpha)+\hat u_i(x'',1-\alpha)+(1-\alpha)\xi,
\]
such that $\hat u_i(x'',1-\alpha)\ge (1-\alpha)V^{\max}_i$.
By definition, $p^\top x''\ge C$.
Thus, $\alpha p^\top x'+(1-\alpha)C\le p^\top x_i\le C-\sigma$, implying
\[
\alpha\ge \frac{\sigma}{C}\ge \frac{\sigma}{\sum_j p_j}\, ,
\]
where the last inequality uses $C$ is the cost of a bundle in $[0,1]^m$.
Let $z\in[0,1]^m$ be a bundle such that $u_i(z)=V^{\max}_i$ and $p^\top z=C$; such a bundle exists since $[0,1]^m$ is a compact domain.
Let
\[
\beta=\frac{\sigma}{\sum_j p_j}\, ,\quad
y'=\frac{\alpha-\beta}{\alpha}\cdot x'\, ,\quad
y''=x''+\beta z\, ,
\quad \mbox{and}\quad y=y'+y''\, .
\]
Note that
\[
p^\top y< p^\top x+\beta p^\top z= p^\top x+ \frac{\sigma C}{\sum_j p_j}\le p^\top x+ \sigma\, ,
\]
satisfying the required bound on the cost. The rest of the proof amounts to showing
$u_i^\xi(y)\ge u_i^\xi(x_i)+\frac{\sigma \xi}{\sum_j p_j}$.
\begin{claim}\label{cl:ypp-good}
$\hat u_i(y'',1-\alpha+\beta)\ge \hat u_i(x'',1-\alpha)+\betaV^{\max}_i\ge (1-\alpha+\beta)V^{\max}_i$.
\end{claim}
\begin{claimproof}
By the homogeneity and concavity of $\hat u_i$,
\[
\hat u_i(y'',1-\alpha+\beta)=2\hat u_i\left(\frac{y''}{2},\frac{1-\alpha+\beta}2\right)\ge \hat u_i(x'',1-\alpha)+\hat u_i(\beta z,\beta)\ge \hat u_i(x'',1-\alpha)+\betaV^{\max}_i\, .
\]
The last inequality in the claim follows by noting that also $\hat u_i(x'',1-\alpha)\ge (1-\alpha)V^{\max}_i$.
\end{claimproof}
\begin{claim} \label{cl:xp-bad}
$\hat u_i(y',\alpha-\beta)= \frac{\alpha-\beta}{\alpha} \hat u_i(x',\alpha)> \hat u_i(x',\alpha)-\beta V^{\max}_i$.
\end{claim}
\begin{claimproof}
The first inequality is by definition of $\hat u_i$. The second inequality is equivalent to $\hat u_i\left({x'},\alpha\right)< \alphaV^{\max}_i$.
Assume for a contradiction $\hat u_i\left({x'},\alpha\right)\ge \alphaV^{\max}_i$. Then, replacing $x''$ by $x'+x''$ and $\alpha$ by 0 results in a better combination using the concavity of $\hat u_i$ as in the previous claim.
\end{claimproof}
By Claim~\ref{cl:ypp-good}, $y=y'+y''$ is a feasible decomposition in
the definition of $u_i^\xi$ with coefficient $\alpha-\beta$. Further, note that
$\hat u_i(y',\alpha-\beta)= \frac{\alpha-\beta}{\alpha} \hat u_i(x',\alpha)$
We get
\[
\begin{aligned}
u_i^\xi(y)&\ge \hat u_i (y',\alpha-\beta)+ \hat u_i (y'',1-\alpha+\beta)+(1-\alpha+\beta)\xi \\
&\ge \hat u_i (y',\alpha-\beta)+ \hat u_i (x'',1-\alpha)+\betaV^{\max}_i+(1-\alpha+\beta)\xi\\
&\ge \hat u_i (x',\alpha)+ \hat u_i (x'',1-\alpha)+(1-\alpha+\beta)\xi\\
&\ge u_i^\xi(x_i)+\beta\xi=u_i^\xi(x_i)+\frac{\sigma\xi}{\sum_j p_j}
\, ,
\end{aligned}
\]
as required. The second inequality used Claim~\ref{cl:ypp-good} and the third inequality used Claim~\ref{cl:xp-bad}.
\end{proof}
Let us now turn to constrained PLC utilities.
\begin{lemma}\label{lem:CPLC-robust}
Let $u_i$ be a constrained PLC utility with $u_i(0)=0$ and $V^{\max}_i>0$, and $\xi>0$. Then, $u_i^\xi$ is also a constrained PLC utility, and is $\xi$-robust. The bit-length of the LP description of $u_i^\xi$ is polynomial in the LP description of $u_i$ and of $\log\xi$.
\end{lemma}
\begin{proof}
Recall the form of the constrained PLC utility as
\begin{align*}
u_i(x_i) =
\max_{t_i} q_i^\top x_i + s_i^\top t_i \text{ s.t. } A_i x_i + B_i t_i\leq b_i\, ,
\end{align*}
where the value is $-\infty$ if the problem is infeasible.
It is easy to verify that the following linear program gives an equivalent description of $ u^\xi_i$:
\begin{equation}\label{lp::nametwo-utility-constraint}
\begin{aligned}
u_i^\xi(x)&= q_i^\top x_i + s_i^\top t_i + (1 - \alpha) \xi\\
&A_i x'_i + B_i t'_i \leq \alpha b_i \\
&A_i x''_i + B_i t''_i \leq (1 - \alpha) b_i\\
& q_i^\top x''_i + s_i^\top t''_i \geq (1 - \alpha) V^{\max}_i\\
&x'_i + x''_i=x_i \\
& t'_i + t''_i =t_i\\
&x_i',x_i''\ge 0\\
& 1\ge \alpha \ge 0
\end{aligned}
\end{equation}
Hence, $u^\xi_i$ is also constrained PLC. If it is regular, then it is $\xi$-robust by Lemma~\ref{lem::utility-perturb-add}. By Lemma~\ref{lem:CPLC-regular}, regularity only requires $u^\xi_i(0)=0$ in this case.
This follows by Lemma~\ref{lem:perturb-close}(i) and the assumptions $u_i(0)=0<V^{\max}_i$. Finally, the statement on bit-complexity follows since $V^{\max}_i$ is the optimum value of a linear program formed by the LP defining $u_i$ and a box constraint. Therefore, $V^{\max}_i$ is polynomially bounded in the input.
\end{proof}
\begin{theorem}
\label{lem::fisher-algorithm-const-agent}
In a Fisher market with $n$ agents, $m$ items and regular constrained PLC utility functions and $\sigma<1$, we can find a $\sigma$-approximate market equilibrium by solving $O\left(\left(\frac{n}{\sigma^2}\right)^n\right)$ linear programs, each polynomially bounded in the input size.
\end{theorem}
\begin{proof}
Let us set $\delta=\sigma^2/(2n)$ and $\xi=\sigma/2$.
We first replace the utility functions $u_i$ by $ u_i^\xi$ as in Lemma~\ref{lem:CPLC-robust}. Then, we guess all combinations
$\tilde{u}_i = k_i \delta$, for $0 \leq k_i \leq \lceil \frac{1}{\delta}\rceil + 1$. We calculate the allocations $x$ as in \eqref{lp::cal-allocation}; if no such allocation exists, we proceed to the next guess. If $x$ is feasible to \eqref{lp::cal-allocation}, then we check if prices $p$ satisfying \eqref{dual-lp::utility-upper-used}, \eqref{lp::budget-constraint-used}, and \eqref{lp::market-clear} exist.
Theorem~\ref{thm::fisher-market-constant-item-first} guarantees the existence both $x$ and $p$ for at least one choice of the $\tilde u_i$'s.
This gives a $(n\delta/\xi,2\delta)$-approximate equilibrium for the utilities $u_i^\xi$, and by Lemma~\ref{lem:perturb-close}(i), a
$(n\delta/\xi,2\delta+\xi)$-approximate equilibrium for the original utilities $u_i$. By the choice of $\delta$ and $\xi$, this is a $\sigma$-approximate equilibrium.
\end{proof}
\section{Approximate thrifty Fisher market equilibrium for fixed number of items}
\section{Approximate Fisher equilibrium for fixed number of items}\label{sec:Fisher-items}
As a warm-up,
we give a simple algorithm for finding an $\varepsilon$-approximate thrifty market equilibrium in Fisher markets for a fixed number of items. The algorithm amounts to approximately solving $O(n\left(\frac{m}{\varepsilon}\right)^m)$ convex programs.
This is similar to the grid search approaches used, e.g.,~in \cite{Deng2002,HyllandZ79,KakadeKO04,Papadimitriou2000}.
We assume that the utility functions $u_i(x_i)$ are represented by value oracles. For given prices $p$, the maximum utility $V_i(p,w_i)$ and the thrifty cost $C_i(p,w_i)$
can be obtained as the optimal solution to convex programs. Using a convex programming algorithm such as the ellipsoid method, we can compute a $\varepsilon$-approximate optimal solutions in oracle-polynomial time in $n$, $m$, the bit-complexity of the vector $p$, $w_i$, $\log L$, and $\log(1/\varepsilon)$ \cite{gls}.
Further, we define the function $F:\mathbb{R}^m_+\to \mathbb{R}$ as the optimal solution to the following convex program in the variables $\{x_{i}\}_i$.
\begin{equation}\label{lp::const-items}
\begin{aligned}
F(p)=&\min \delta\\
&u_i(x_i) \geq V_i(p,w_i)-\delta, & \forall i \\
&\sum_i x_{ij} \leq 1, & \forall j \\
&\sum_j x_{ij} {p}_j \leq C_i(p,w_i) + \delta \sum_i w_i, & \forall i \\
&\sum_j p_j\left(1-\sum_{i}x_{ij}\right)\le \delta \sum_i w_i\\
&x,\delta \geq 0,
\end{aligned}
\end{equation}
To compute a $\varepsilon$-approximate solution for given prices $p$, we first find $(\varepsilon/2)$-approximate values for $V_i(p,w_i)$ for all $i$ and $(\varepsilon\sum_i w_i/2)$-approximate values for $C_i(p,w_i)$; then, we again use a convex programming algorithm to find a $(\varepsilon/2)$-approximate solution to the resulting program.
\begin{lemma}\label{lem:fixed-agent-main} If $F(p)\le \sigma$, then the prices $p$ and allocations $x_i$ give a $\sigma$-approximate thrifty market equilibrium.
If $(p^*,x^*)$ forms an exact thrifty market equilibrium, and prices $p\in\mathbb{R}^m$ satisfy $p^*_j\le p_j\le p^*_j+\frac{\sigma}{m}\sum_i w_i$, then $F(p)\le \sigma$.
\end{lemma}
\begin{proof}
The first claim is immediate by the definition of an approximate thrifty market equilibrium. For the second claim, $F(p^*)=0$ with the optimal solution $x^*$. We show that $(x^*,\sigma)$ is feasible to
\eqref{lp::const-items}, showing that $F(p)\le \sigma$.
Since $p\ge p^*$, we have $V_i(p,w_i)\le V_i(p^*,w_i)$, verifying the first constraint.
To verify the third constraint, we first show that $C_i(p,w_i)\ge C_i(p^*,w_i)$. This is immediate if $C_i(p,w_i)=w_i$. If $C_i(p,w_i)<w_i$, then $V_i(p,w_i)=\max_{x\in \mathbb{R}^m} V_i(x)$, the maximum utility without budget constraint; consequently, $V_i(p^*,w_i)=\max_{x\in \mathbb{R}^m} V_i(x)$. Purchasing such a maximum utility bundle cannot be cheaper at prices $p$, since $p\ge p^*$. Hence,
\[
\sum_j p_j x^*_{ij}\le \sum_j p^*_j x^*_{ij}+\left(\sum_j x^*_{ij}\right)\frac{\sigma}{m}\left(\sum_i w_i\right)\le C_i(p^*,w_i)+ \sigma \sum_i w_i\le C_i(p,w_i)+ \sigma \sum_i w_i\, .
\]
The last constraint in \eqref{lp::const-items}
follows by $\sum_j p_j\sum_i x^*_{ij}\ge \sum_j p^*_j\sum_i x^*_{ij}$, and $\sum_j p_j\le \sum_j p_j^*+ \sigma\left(\sum_i w_i\right)$.
\end{proof}
\begin{theorem} \label{thm::fisher-fix-item}
Given a Fisher market with $n$ agents, $m$ items,
and regular concave utility functions $u_i$ given by oracle access, we can compute a $\varepsilon$-approximate thrifty market equilibrium by approximately solving $O(n\left(\frac{m}{\varepsilon}\right)^m)$ convex programs, each in oracle-polynomial time in in $n$, $m$, the bit-complexity of the $w_i$'s, $\log L$, and $\log(1/\varepsilon)$.\footnote{This is essentially $(0, \epsilon)$-approximate equilibrium if we can solve the convex program~\eqref{lp::const-items} exactly; otherwise, we can get $(\lambda, \epsilon)$-approximate equilibrium for arbitrary $\lambda$ at an additional $\log{(1/\lambda)}$ factor.}
\end{theorem}
\begin{proof}
We enumerate all price vectors
${p}_j = k_j \frac{\varepsilon}{2m} \sum_i w_i$ for all integers $k_i$ such that $0 \leq k_j \leq \frac{2m}{\varepsilon} + 1$. For each price vector $p$, we find a $(\varepsilon/2)$-approximate solution to \eqref{lp::const-items}. We output any price vector $p$ for which a solution $(x,\delta)$ with $\delta\le\varepsilon$ is found. Theorem~\ref{thm::fisher-exists} and Lemma~\ref{lem:fixed-agent-main} guarantee the existence of such a solution.
\end{proof}
\section{Introduction}\label{sec:intro}
Market equilibrium is one of the most fundamental solution concepts in economics, where prices and allocations are such that demand meets supply when each agent gets her most preferred and affordable bundle of items. Due to the remarkable fairness and efficiency guarantees of equilibrium allocation, it is also one of the preferred solutions for fair division problems even though there may be no money involved in the latter case. A prominent example is competitive equilibrium with equal incomes (CEEI)~\cite{Varian74}, where a market is created by giving one dollar of virtual money to every agent.
In this paper, we focus on markets with divisible items. Extensive work in theoretical computer science over the last two decades has led to a deep understanding of the computational complexity of equilibria for the classical models of Fisher and exchange markets, introduced by Fisher~\cite{BrainardS00} and Walras~\cite{Walras74} respectively in the late nineteenth century. In a Fisher market, agents have fixed budgets to spend on items according to their preferences given by utility functions over bundles of items. CEEI is a special case of this model, where each agent has a budget of one dollar. In the exchange (also known as Arrow--Debreu) market model, the items are brought to the market by the agents, who can spend their revenue from selling their initial endowments.
Prevalent assumptions on the utility functions in the literature are {\em (a)} \emph{monotonicity}, i.e., getting a bundle containing more of each item may not decrease the utility, and {\em (b)} \emph{local non-satiation}, i.e., for every bundle of items, an arbitrary neighborhood contains a bundle with strictly higher utility. A prominent example where these assumptions do not hold is the \emph{one-sided matching market problem}, where each agent needs to be assigned \emph{exactly} one unit of fractional items in total. Hylland and Zeckhauser~\cite{HyllandZ79} introduced an elegant mechanism based on CEEI for the one-sided matching markets. However, more general allocation constraints remain largely unexplored.
In this paper, we consider the equilibrium computation problem when agents have \emph{constrained piecewise linear concave (PLC)} utility functions, defined as follows.
\begin{defi}\label{def:cplc}
The utility function $u_i:\mathbb{R}_+^m\to \mathbb{R}\cup\{-\infty\}$ of agent $i$ is \emph{constrained PLC} if it is given in the following form. For some $p_i,r_i\in\mathbb{N}$, let $A_i\in\mathbb{R}^{p_i\times m}$, $B_i\in\mathbb{R}^{p_i\times r_i}$, $q_i\in\mathbb{R}^m$, $s_i\in \mathbb{R}^{r_i}$,
\[
u_i(x_i)=\begin{cases}
\max_{t_i} q_i^\top x_i + s_i^\top t_i \text{ s.t. } A_i x_i + B_i t_i\leq b_i &\text{ if }\exists t_i:\, A_i x_i + B_i t_i\leq b_i\, , \\
-\infty &\text{ otherwise}.
\end{cases}
\]
\end{defi}
This general model includes the following well-studied examples:
\begin{itemize}
\setlength\itemsep{0em}
\item Matching markets \cite{AlaeiKT17,HyllandZ79,vazirani2021computational} in the form
$u_i(x_i) = \sum_j a_{ij} x_{ij}$ if $\sum_j x_{ij} = 1$, and $-\infty$ otherwise.
\item PLC utility functions (see e.g., \cite{DevanurK08,GargMV16,GargMVY17}) $u_i(x_i)=\min_\ell \{ \sum_j a_{ij}^l x_{ij} + b_i^l\}$ can be modeled as $u_i(x_i) = \max t \text{ s.t. } t \le \sum_j a_{ij}^l x_{ij} + b_i^l,\ \forall \ell$. This includes Leontief utilities as a special case.
\item Markets with satiation, where an agent may either have the maximum utility limit~\cite{ColeDGJMVY17,BeiGHM19} or consumption constraints~\cite{Mascolell82}, which can be easily captured through constrained PLC functions in most cases.
\end{itemize}
For the special case of PLC utilities, although the problem is PPAD-hard~\cite{ChenT09}\footnote{We note that even the subcases of PLC such as separable PLC is already PPAD-hard for both Fisher~\cite{ChenT09} and Arrow-Debreu models~\cite{ChenDDT09}, and Leontief is PPAD-hard for the Arrow-Debreu model~\cite{CodenottiSVY06}.}, Devanur and Kannan~\cite{DevanurK08} and Kakade, Kearns, and Ortiz~\cite{KakadeKO04} gave polynomial-time algorithms for computing exact and approximate equilibria, respectively, when the number of items is a constant. However, the other significant case of constantly many agents turns out to be much more challenging. In~\cite{DevanurK08} an algorithm is given for fixed number of agents with \emph{separable} PLC utilities, but the case with non-separable PLC utilities remained open. Moreover, apart from theoretical interest, designing simpler and faster algorithms for these cases is crucial for their applications.
\subsection{Our contributions}\label{sec:overview}
Our main result is a fixed parameter approximation scheme for computing an approximate equilibrium in Fisher model under constrained PLC utilities, where the parameters are the number of agents and the approximation accuracy. The main technical ideas are to use the stronger concept of \emph{thrifty} equilibria and to approximate the input utility functions by \emph{robust} utilities that have favorable marginal properties.
Before reviewing our algorithm for fixed number of agents, let us start with an easier algorithm for fixed number of items. In this case, a fairly simple grid search works over all possible price combinations with a small stepsize. This is applicable to the even more general class of \emph{regular} concave utilities (Theorem~\ref{thm::fisher-fix-item}). For each price combination, we compute the maximum utility of each agent at these prices, and check whether these utilities can be approximately attained by a feasible allocation also respecting the budget constraints. The existence of an equilibrium guarantees that we find a suitable solution for at least one price combination. This is similar to the grid search approaches used in \cite[Appendix B]{HyllandZ79} for matching markets, and for other markets in, e.g.,~\cite{Deng2002,KakadeKO04,Papadimitriou2000}.
The natural starting point for fixed number of agents is to perform a grid search over all possible combinations of utility values with a small stepsize. However, even after fixing the desired utility values for each agent, we need to find both allocations and prices, a significantly more challenging task. Our approach is to {\em (I)} first find an allocation of the items that meet the utility requirements of each agent, and then {\em (II)} compute prices for which these allocations form a market equilibrium.
Consider an equilibrium with allocations $x^*=\{x^*_{ij}\}_{i,j}$, prices $p^*=\{p^*_j\}_j$ and utility values $u^*=\{u^*_i\}_i$.
For such a two-stage grid search approach to work, a necessary requirement is that given approximate utility values $u^*_i-\delta\le \tilde u_i\le u_i^*$, $(x,p^*)$ must form an approximate market equilibrium for every allocation $x$ such that $u_i(x_i)\ge \tilde u_i$ for each agent $i$. This is not true for arbitrary utility functions: not only that $x$ may be very far from $x^*$, but more importantly, the approximate utility value $\tilde u_i$ could be obtained by paying much less than $p^\top x_i^*$.
To address this problem, we make further assumptions both on the utility functions $u_i$ as well as on the equilibrium $(x^*,p^*)$. We require \emph{robust} utility functions, where the change in the utility value is bounded by the change of the budget in a certain critical range of budgets. We then show that every constrained PLC utility function $u_i$ can be approximated by a $\xi$-robust constrained-PLC utility $u_i^\xi$ for any $\xi>0$. We run the algorithm for $u^\xi_i$; the resulting approximate equilibrium will also be an approximate equilibrium for the original $u_i$ with a slightly worse accuracy. The construction of the $u^\xi_i$'s relies on using \emph{perspective functions} of the $u_i$'s.
Robustness on its own however does not suffice. A curious phenomenon for constrained utilities is that an agent may not need to spend their entire budget to obtain their most preferred bundle. For example, if the most favored item has price less than 1 in a matching market, the optimal choice of the agent is to purchase the full unit of this item. We will need to require that $(x^*,p^*)$ is a \emph{thrifty} equilibrium: the agents do not only get their most preferred bundle of items, but purchase such a bundle at the cheapest possible costs. (In the matching market example, if there is a tie among most preferred items, all priced less than 1, the agent is only allowed to purchase the cheapest one.)
Fortunately, thriftiness can always be assumed (Theorem~\ref{thm::fisher-exists}): we show that a thrifty equilibrium always exists in the Fisher model for regular concave utilities mentioned above. The proof uses Kakutani's fixed point theorem. To the extent of our knowledge, existence of (even a non-thrifty) equilibrium is not implied by previous results for constrained PLC utilities.\footnote{We note that~\cite{VaziraniY11} shows NP-hardness of checking equilibrium existence in Fisher model under separable PLC utilities, which seems to require two conditions: first, the sum of prices must equal the sum of budgets, and second, they implicitly assume that the agents are thrifty. Hence, there is no contradiction.}
Let us now describe the algorithm for robust utilities. In stage {\em (I)}, we can find allocations delivering the utility guesses by solving a linear program. In stage {\em (II)}, the goal is to find prices $p$ that form an approximate equilibrium with $x$. The most challenging part is to ensure that the maximum utility profile available at $p$ is close to the guess $\tilde u_i$ for each agent $i$. This is achieved by considering the dual of the utility maximizing linear program, and applying a variable transformation. After these reductions, suitable prices can be found by linear programming (Theorem~\ref{lem::fisher-algorithm-const-agent}).
In the above algorithm, we assume that empty allocation is feasible, i.e., $u_i(0) = 0$. However, this is no longer true in matching markets where $u_i(0) = -\infty$, and hence the above algorithm does not directly apply here. We proceed with the natural approach by relaxing the matching constraints to $\sum_j x_{ij} \le 1$ for every $i$. For this relaxation to work, we need to add the requirement on both exact and approximate equilibria that the minimum price is $0$. This can be ensured by exploiting a natural price transformation in the problem.
We show that this approach works even for a more general model of PLC matching markets with $u_i(x_i) = \min_{\ell} \{\sum_j a_{ij}^l x_{ij} + b_i^l\}$ if $\sum_j x_{ij} = 1$ and $-\infty$ otherwise (Theorems~\ref{thm::plc-matching-items} and \ref{thm::plc-matching-agents}).
The papers~\cite{DevanurK08} and~\cite{AlaeiKT17} give polynomial-time algorithms for computing exact equilibria for the special cases mentioned earlier using a \emph{cell decomposition} technique. Note that in both PLC and matching markets, it is possible that all equilibria are irrational~\cite{Eaves76,vazirani2021computational}; exact equilibria in these works are represented as roots of polynomials.
The cell decomposition arguments partition the parameter space by polynomial surfaces such that in each cell it is easy to decide whether a solution in the particular configuration exists; the number of cells can be bounded using results from algebraic geometry. While the number of cells is polynomial, the results for fixed number of agents (for separable PLC in \cite{DevanurK08} and for matching markets in \cite{AlaeiKT17}) require solving $m^{\mathrm{poly}(n)}$ subproblems and thus may not be practical. In contrast, our algorithm is a fixed parameter scheme in $n$ and the accuracy $\varepsilon$; we need to solve $O((n/\varepsilon^2)^n)$ polynomial-size linear programs.\footnote{We note that $\varepsilon\le 1/(cn)$ is needed for a meaningful approximate equilibrium.} Hence, the complexity of finding an approximate equilibrium is much lower.
For matching markets, we also show that the set of equilibria is non-convex by a simple example of 3 agents and 3 items with tri-valued utility values $a_{ij} \in \{0, 1, 2\}$. To the best of our knowledge, this is the first proof of the non-convexity of equilibria in matching markets.\footnote{We note that~\cite{VaziraniY20-arxiv} presents an example to show non-convexity of equilibria in matching markets. However, their latest version~\cite{vazirani2021computational} does not contain that example, which seems to have only one equilibrium.} Moreover, our example is the simplest one can hope for as for both the bi-valued utility values and two agents case, the set of equilibria is convex; see e.g.,~\cite{GargTV20}.
Finally, we show that our algorithms also extend to the more general case of the Arrow-Debreu model under PLC utilities (Theorems~\ref{thm::ad-pp} and \ref{thm::ad-fixed-items}). The additional challenge here is to handle budgets that now depend on the prices. For both cases of fixed number of agents and fixed number of goods, we approximate the utilities by robust utilities. This can be done in a simpler way using the special form of the utilities, and in particular it guarantees a lower bound on the minimum price.
\subsection{Related work}\label{sec:rw}
Market equilibrium is an intensely studied concept with a variety of applications, so we briefly mention further relevant results.
For the classical Fisher model, polynomial-time algorithms are obtained when agents have linear~\cite{DevanurPSV08,Orlin10,Vegh16}, weak gross substitutes~\cite{CodenottiPV05}, and homogeneous utility functions~\cite{Eisenberg61}. For separable PLC utilities, the problem is PPAD-hard~\cite{ChenT09}.
For the constrained Fisher model, the most famous problem is the Hylland-Zeckhauser scheme for the one-sided matching markets, for which \cite{HyllandZ79} shows the existence of equilibrium, which is recently simplified~\cite{Braverman21}. For matching markets, polynomial-time algorithms are obtained for special cases of constantly many agents (or items)~\cite{AlaeiKT17} and dichotomous utilities~\cite{vazirani2021computational}. Settling its exact complexity is currently open.
Very recently,~\cite{JalotaPQY21} considers Fisher markets with additional linear constraints, which includes matching markets but not the PLC utilities studied in this paper. It gives a simple fixed-point iterative scheme that converges to an equilibrium in numerical experiments, among other structural results. In particular, it provides a non-convexity example with additional linear utilities, which we note is not a matching market example.
For the classical Arrow-Debreu model, polynomial-time algorithms are obtained when agents have linear~\cite{DuanGM16,DuanM15,GargV19,Jain07,Ye08} and weak gross substitutes~\cite{CodenottiPV05,BeiGH19,GargHV21} utilities, and beyond that, the problem is essentially PPAD-hard~\cite{ChenDDT09,ChenPY17,CodenottiSVY06,GargMVY17}.
For the constrained Arrow-Debreu model, an exact equilibrium may not exist even in the case of matching markets~\cite{HyllandZ79}. For this,~\cite{GargTV20} gives the existence of an approximate equilibrium and a polynomial-time algorithm for computing it under dichotomous utilities.
\paragraph{Overview} The rest of the paper is organized as follows. Section~\ref{sec:model} defines all models and definitions. Section~\ref{sec:Fisher-items} presents an algorithm for computing an approximate Fisher equilibrium under regular concave utilities for a fixed number of items. Section~\ref{sec:Fisher-agents} gives an algorithm for computing an approximate Fisher equilibrium under constrained PLC utilities for a fixed number of agents. Section~\ref{sec:mm} extends algorithms to PLC matching markets and presents an example showing the non-convexity of equilibria. Section~\ref{sec:ad} extends algorithms to the Arrow-Debreu market model. Finally, Section~\ref{sec::proof-existence-fisher} shows the existence of thrifty Fisher equilibrium under regular concave utilities.
\section{PLC Matching Markets}\label{sec:mm}
In the Hylland-Zeckhauser matching market equilibrium \cite{HyllandZ79}, agents have unit budgets and linear utilities with the additional restriction that every agent has to purchase exactly one unit of good.
We now consider the following generalization with PLC utilities for nonnegative values $a_{ij}^l,b_i^l\ge 0$.
\begin{align}\label{eq:mm-u-i}
u_i(x_i) = \begin{cases}
\min_l \left\{\sum_j a_{ij}^l x_{ij} + b_i^l \right\} \, , & \quad \text{if } \sum_j x_{ij} = 1\ ,\\
-\infty & \quad \text{otherwise.}
\end{cases}
\end{align}
Throughout this section, we assume $w_i=1$ for all agents, as standard in the matching market model. We also assume $n\le m$, i.e., there are at least as many items as agents that is necessary for feasibility.
We refer to this problem as the \emph{PLC matching market} problem.
Let
$\tilde V_i=\max_{x_i\in\mathbb{R}^m_+}u_i(x_i)$ be the maximum achievable utility of agent $i$; the matching constraint guarantees this is finite.
Similarly to \eqref{eq:V-max}, without loss of generality we can apply affine transformations to the utilities so that
\begin{equation}\label{eq:mm-scaling}\tilde V_i\le 1\quad\mbox{and}\quad \min_l b_i^l = 0\quad\mbox{for each agent }i.
\end{equation}
Note that, even though this utility function is constrained PLC, it is \emph{not regular}: $u_i(0)=-\infty$. For this reason, we cannot directly apply the results in Sections~\ref{sec:Fisher-items} and~\ref{sec:Fisher-agents}. The existence of an equilibrium is also not covered by Theorem~\ref{thm::fisher-exists}.
A key tool to tackle this model is the following price transformation with strong invariance properties that enables us to restrict our attention to (approximate) equilibria where $\min_j p_j=0$.
\begin{lemma}[\cite{vazirani2021computational}]\label{lem:price-transform}
For a PLC matching market model,
let $p\in\mathbb{R}^m_+$, and $r>0$ such that $p'_j=1+r(p_j-1)\ge 0$ for all items $j$. Then,
$D_i(p,1)=D_i(p',1)$ for every agent $i$.
Consequently, if there exists a market equilibrium
$(\{x^*_i\}_i, \{p^*_j\}_j)$, then there exists one with $\min_j p_j=0$.
\end{lemma}
\begin{proof}
Both $D_i(p,1)$ and $D_i(p',1)$ only contain bundles $x_i$ with
$\sum_j x_{ij}=1$.
Since $1-(p')^\top x_i=r(1-p^\top x_i)$ for such a bundle, the price of a bundle satisfies
$p^\top x_i\le 1$ if and only if it satisfies $(p')^\top x_i\le 1$. This implies $D_i(p,1)=D_i(p',1)$. For the second part, consider any market equilibrium
$(\{x^*_i\}_i, \{p^*_j\}_j)$. If there exists a good at price $p^*_j<1$, then we can select the largest $r$ value such that this transformation gives $\min_j p_j'=0$. The first part guarantees that $(\{x^*_i\}_i, \{p'_j\}_j)$ is also a market equilibrium. Otherwise, $p^*_j = 1$ for all $j$. In this case, setting $p_j = 0$ for all $j$ will also be a matching market equilibrium.
\end{proof}
In light of this transformation, we note that the $(\sigma,\lambda)$-approximate (thrifty) equilibrium concept as in Definition~\ref{def:approx-eq} is unsatisfactory. Assume $n=m$, i.e., the number of items is the same as the number of agents. Let $(\{x_{i}\}_{i}, \{p_j\}_j)$ be a $(\sigma,\lambda)$-approximate equilibrium. Then, for any choice of $0<\sigma'\le \sigma$, we can select $r>0$ such that $(\{x_{i}\}_{i}, \{p'_j\}_j)$ will be a $(\sigma',\lambda)$-approximate (thrifty) equilibrium. This is because $(p')^\top x_i$ becomes arbitrarily close to 1, and the third constraint is satisfied since $\sum_{i} x_{ij}=1$ for all $j$ follows if $n=m$.
In accordance with Lemma~\ref{lem:price-transform}, we will look for approximate (thrifty) equilibria with the additional requirement that $\min_j p_j=0$. In Section~\ref{sec:partial}, we show that approximate equilibrium results can be obtained by reducing to an associated partial matching market. In Section~\ref{sec:non-convexity}, we give a simple counterexample showing that the set of equilibria is non-convex already for the standard matching market model with three agents and three items.
\subsection{From partial to perfect matchings}\label{sec:partial}
Both for showing the existence of equilibria, as well as for the algorithms, we relax the perfect matching requirement $\sum_j x_{ij}=1$ to the \emph{partial} matching constraint
$\sum_j x_{ij}\le1$. That is, for the same parameters $a_{ij}^l,b_i^l$, we let
\begin{align}\label{eq:mmr-u-i}
u'_i(x_i) = \begin{cases}
\min_l \left\{\sum_j a_{ij}^l x_{ij} + b_i^l \right\} \, , & \quad \text{if } \sum_j x_{ij} \leq 1\, ,\\
-\infty & \quad \text{otherwise.}
\end{cases}
\end{align}
Using the assumption \eqref{eq:mm-scaling}, $u'_i(0)=0$, and therefore the $u'_i$'s are regular utilities. For a PLC matching market with utilities $u_i$ as in \eqref{eq:mm-u-i}, we will refer to the market that replaces the $u_i$'s by the $u'_i$'s as the associated \emph{PLC partial matching market}.
The next two lemmas show the close relationship between equilibria in these markets. In the proofs, we use $V_i(p,1)$ for the optimal utility for $u_i$ and $C_i(p,1)$ the minimum price of an optimal bundle; we let $V'_i(p,1)$ and $C'_i(p,1)$ denote the same for $u'_i$. Clearly, $V'_i(p,1)\ge V_i(p,1)$.
\begin{lemma}\label{lem::crp-fisher-matching}
Let $(\{x_{i}\}_{i}, \{p_j\}_j)$ be a thrifty PLC matching market equilibrium with $\min_j p_j=0$. Then, $(\{x_{i}\}_{i}, \{p_j\}_j)$ is also a thrifty market equilibrium in the associated PLC partial matching market.
\end{lemma}
\begin{proof}
Using that $p_k=0$ for some good $k$, for every $x'_i$ with $\sum_j x'_{ij}\le 1$ there exists a bundle $\tilde x_i\ge x'_i$ with $\sum_j \tilde x_{ij}= 1$ that has the same cost
and $u_i(\tilde x_i)\ge u_i'(x'_i)$. Consequently, $V'_i(p,1)= V_i(p,1)$, and by the same token, $C_i(p,1)=C'_i(p,1)$. The statement follows.
\end{proof}
In the other direction, we show that approximate (thrifty) equilibria in the associated PLC partial matching market have $\min_j p_j=0$, then this can be extended to the original PLC matching market. This also applies to exact equilibria with $\sigma=\lambda=0$.
\begin{lemma}\label{lem::build-matching-fisher}
For a PLC matching market, consider a $(\sigma, \lambda)$-approximate (thrifty) equilibrium
$(\{x'_i\}_i, \{p'_j\}_j)$ in the associated PLC partial matching market, and assume $\min_j p'_j=0$. Then, in $O(m)$ time
we can construct a $(2 \sigma, \lambda)$-approximate (thrifty) matching equilibrium $(\{{x}_i\}_i, \{p'_j\}_j)$ in the original market.
\end{lemma}
\begin{proof}
Given $(\{x'_i\}_i, \{p'_j\}_j)$, we arbitrarily assign those items which are not fully allocated to those agents such that $\sum_j x'_{ij} < 1$; this can be easily done in $O(m)$ time (recall $m\ge n$). Let $\{{x}_i\}_i$ denote the resulting allocations with $\sum_j x_{ij}=1$.
Recalling that all $w_i=1$, the approximate equilibrium means $p^\top x_i\le 1+n\sigma$ and $\sum_j p'_j (1 - \sum_i x'_{ij}) \leq \sigma \sum_i w_i=n\sigma$. Hence, the spending for each agent (after assignment) can be at most $2n\sigma+1$.
As in the previous proof, $\min_j p_j=0$ guarantees that $V_i(p,1)=V_i'(p,1)$ and $C_i(p, w_i)=C_i'(p, w_i)$.
The utility requirement follows since
$V_i(p,1)-\lambda= V'_i(p,1)-\lambda\le u'_i(x'_i)\le u_i(x_i)$.
Further, if $(\{x'_i\}_i, \{p'_j\}_j)$ was an approximate thrifty market equilibrium, then thriftiness for $(\{{x}_i\}_i, \{p_j\}_j)$ follows since the spending can only be increased by $n\sigma$.
\end{proof}
We can now derive the existence of an equilibrium, as well as algorithms for approximate equilibria, by making use of the results for PLC partial matchings that are regular utilities.
\begin{theorem} \label{thm::ext-matching}
In every PLC matching market, there exists a thrifty market equilibrium $(\{x_{i}\}_{i}, \{p_j\}_j)$
with $\min_j p_j=0$.
\end{theorem}
\begin{proof}
For the $u'_i$ utilities in the associated PLC partial matching market,
Theorem~\ref{thm::fisher-exists} guarantees the existence of an equilibrium $(\{x'_i\}_i, \{p'_j\}_j)$. If $\min_j p'_j=0$, then Lemma~\ref{lem::build-matching-fisher} for $\sigma=\lambda=0$ gives an equilibrium in the PLC matching market with the $u_i$'s. If $\min_j p'_j>0$, then all goods must be fully sold, hence $\sum_{i,j} x'_{ij}=m\ge n$. This cannot happen if $m>n$; and if $m=n$ this implies that all agents are getting one unit in $x'$, i.e., $\sum_{j} x'_{ij}=1$ for all $i$. Consequently, $(\{x'_i\}_i, \{p'_j\}_j)$ is already an equilibrium in the PLC matching market. By Lemma~\ref{lem:price-transform}, this can be transformed to one with $\min_j p_j=0$.
\end{proof}
For fixed number of items, we can thus use the algorithm in Section~\ref{sec:Fisher-items} for $u'_i$, and transform it using Lemma~\ref{lem::build-matching-fisher} for $u_i$. In order to find an approximate thrifty equilibrium for the $u'_i$'s with
$\min_j p_j=0$; we only enumerate over price combinations where one of the prices is 0. Theorem~\ref{thm::ext-matching} and Lemma~\ref{lem::crp-fisher-matching} guarantee the existence of such a solution.
\begin{theorem}[approximate thrifty PLC matching market equilibrium with fixed number of items]\label{thm::plc-matching-items}
Given a PLC matching market with $n$ agents, $m$ items,
and PLC utilities $\{u_i\}_i$, we can compute an $\varepsilon$-approximate thrifty PLC matching market equilibrium by solving $O(n\left(\frac{m}{\varepsilon}\right)^m)$ linear programs, each in polynomial time in the input size.
\end{theorem}
Similarly, for fixed number of agents, we can use the results in Section~\ref{sec:Fisher-agents} for $u'_i$ in conjunction with
Lemma~\ref{lem::build-matching-fisher} to compute an approximate PLC matching market equilibrium (but not necessarily a thrifty one). The only modification needed is that we fix the price of some good to $p_j=0$; this results in an additional factor $m$ in the running time.
\begin{theorem}[approximate PLC matching market equilibrium with fixed number of agents]\label{thm::plc-matching-agents}
Given a PLC matching market with $n$ agents, $m$ items,
and PLC utilities $\{u_i\}_i$, we can compute a $\sigma$-approximate PLC matching market equilibrium by solving $O\left(m \left( \frac{n}{\sigma^2} \right)^n\right)$ linear programs, each in polynomial time in the input size.
\end{theorem}
Finally, for the original Hylland-Zeckhauser model with linear utilities, we show that the stronger concept of an approximate \emph{thrifty} equilibrium can also be computed, by exploiting the simpler structure in this case.
\begin{theorem}[approximate thrifty matching market equilibrium with fixed number of agents]
Given a matching market with $n$ agents, $m$ items,
and linear utility function
\begin{align*}
u_i(x_i) = \begin{cases}\sum_j a_{ij} x_{ij}\, , & \quad \text{if } \sum_j x_{ij} = 1\, ,\\
-\infty & \quad \text{otherwise.}
\end{cases}
\end{align*}
we can compute a $\sigma$-approximate thrifty market equilibrium by solving $O\left(m \left( \frac{n}{\sigma^2} \right)^n\right)$ linear programs, each in polynomial time in the input size.
\end{theorem}
\begin{proof}
Similar to the PLC case, we first calculate a thrifty approximate equilibrium for the associated partial matching market such that $\min_j p_j = 0$ and then transform it into a thrifty approximate matching market equilibrium.
The transformed $\xi$-$\text{robust}$ utility ${u'_i}^{\xi}(x_i)$ used in the algorithm (see \eqref{lp::nametwo-utility-constraint})
can be written in the following simpler form. Let $J=\arg\max_j a_{ij}$, and
\begin{align*}
{u'_i}^{\xi}(x_i) = \begin{cases}
\sum_{j\notin J} a_{ij} x_{ij}+\sum_{j\in J}(a_{ij}+\xi)x_{ij} \, , & \quad \text{if } \sum_j x_{ij} \leq 1\, , \\
-\infty & \quad \text{otherwise}.
\end{cases} \numberthis \label{utility-matching-nametwo}
\end{align*}
Let us calculate an approximate thrifty market equilibrium $(\{x_{i}\}_{i}, \{p_j\}_j)$ for ${u'_i}^{\xi}$ as in Section~\ref{sec::cal-equilibrium-nametwo} with two slight modifications.
We first enumerate all possible $\tilde{u}_i$ for $\tilde{u}_i = \delta k_i$ for $0 \leq k_i \leq \lceil \frac{1 + \xi}{\delta} \rceil + 1$ and one $j$ such that $p_j = 0$; then, we calculate $\{x_i\}_i$ by \eqref{lp::cal-allocation}; and finally, we calculate the price $\{p_j\}_j$. When calculating the price, in addition to \eqref{dual-lp::utility-upper-used}, \eqref{lp::budget-constraint-used}, and \eqref{lp::market-clear}, we add constraints $p_j = 0$ and
\begin{equation}\label{eq:J}
p^\top x_i \leq p_{j'} + \frac{n^2 \delta}{\xi}
\quad \quad \forall j' \in J\, .
\end{equation}
Recall that $\frac{n^2 \delta}{\xi}=\frac{n \delta}{\xi}\sum_i w_i$ by the assumption that all budgets are 1.
This additional last inequality makes the difference compared to the general PLC algorithm. We exploit this in the following claim.
\begin{claim}
If $p^\top x_i \leq p_{j'} + \frac{n \delta}{\xi}\sum_i w_i$ for $j' \in J$; and $p^\top x_i \leq 1 + \frac{n^2 \delta}{\xi}$, then $p^\top x_i \leq C_i(p, 1) + \frac{n^2 \delta}{\xi}$. Additionally, let $(\{x^*_i\}_i, \{p^*_j\}_j)$ be any thrifty market equilibrium. If ${u}^*_i - \delta < \tilde{u}_i \leq {u}^*_i$ for all $i$, then for any $\{x_i\}_i$ such that $\eqref{lp::cal-allocation}$ holds, \eqref{eq:J} is also valid for $p^*$.\end{claim}
\begin{claimproof}
The first part follows as $C_i(p, 1) = \min\{1, \min_{j \in J} p_j\}$. The second part is true because, for $j' \in J$,
\begin{align*}
{p^*}^\top x_i &\leq {p^*}^\top x^*_i + \frac{n^2 \delta }{\xi} ~~~~~\text{(by Lemma~\ref{lem::budget-lower})} \\
&\leq p^*_{j'} + \frac{n^2 \delta}{\xi}. ~~~~~\text{(as ${p^*}^\top x^*_i = C_i(p^*, 1) \leq p_j'$) } \qedhere
\end{align*}
\end{claimproof}
Combining this observation with Theorem~\ref{thm::fisher-market-constant-item-first}, Lemma~\ref{lem::crp-fisher-matching}, and
Theorem~\ref{thm::ext-matching}, this procedure will output a $(\delta n/ \xi, \xi + 2\delta)$-approximate thrifty equilibrium for the associated partial matching market.
Finally, by Lemma~\ref{lem::build-matching-fisher}, we construct an approximate matching market equilibrium from the approximate Fisher market equilibrium.
The theorem follows by choosing $\delta = \sigma^2/(4n)$ and $\xi = \sigma/2$.
\end{proof}
\subsection{Non-convexity example}\label{sec:non-convexity}
In this section, we give a simple example which shows that the sets of allocations and prices are non-convex. The example consists of three agents, three items and the utilities are linear for these agents: $u_i(x_i) = \sum_j a_{ij} x_{ij}$. Each agent has a budget of $1$ dollar.
\begin{table}[h!]
\centering
\begin{tabular}{|c|c|c|c|}
\cline{1-4}
& item 1 & item 2 & item 3 \\ \cline{1-4}
agent 1 & 1 & 1 & 2 \\ \cline{1-4}
agent 2 & 0 & 1 & 2 \\ \cline{1-4}
agent 3 & 1 & 1 & 2 \\ \cline{1-4}
\end{tabular}
\caption{Utility matrix ($a_{ij}$)}
\end{table}
Given the utility functions, the following prices and allocations are two of the equilibria of the matching market.
\begin{table}[!htb]
\begin{minipage}{.5\linewidth}
\centering
\begin{tabular}{|c|c|c|c|}
\cline{1-4}
& item 1 & item 2 & item 3 \\ \cline{1-4}
agent 1 & 0.5 & 0 & 0.5 \\ \cline{1-4}
agent 2 & 0 & 1 & 0 \\ \cline{1-4}
agent 3 & 0.5 & 0 & 0.5 \\ \cline{1-4} \hline \hline
price & 0 & 1 & 2 \\ \cline{1-4}
\end{tabular}
\caption{Price 1 ($p^{(1)}$) and Allocation 1 ($x^{(1)}$)}
\end{minipage}%
\begin{minipage}{.5\linewidth}
\centering
\begin{tabular}{|c|c|c|c|}
\cline{1-4}
&item 1 & item 2 & item 3 \\ \cline{1-4}
agent 1 & 2/3 & 0 & 1/3 \\ \cline{1-4}
agent 2 & 0 & 2/3 & 1/3 \\ \cline{1-4}
agent 3 & 1/3 & 1/3 & 1/3 \\ \cline{1-4}\hline \hline
price & 0 & 0 & 3 \\ \cline{1-4}
\end{tabular}
\caption{Price 2 ($p^{(2)}$) and Allocation 2 ($x^{(2)}$)}
\end{minipage}
\end{table}
The following two lemmas show that neither the set of allocations nor the set of prices is convex.
\begin{lemma} $\frac{p^{(1)} + p^{(2)}}{2}$ is not an equilibrium price.
\end{lemma}
\begin{proof}
Note that $\frac{p^{(1)} + p^{(2)}}{2} = (0, 0.5, 2.5)$. In this case, both agent $1$ and agent $3$ will not be interested in item $2$. This implies agent $2$ will get item $2$ fully. However, given the price, agent $2$ will buy some of item $3$, which provides a contradiction.
\end{proof}
\begin{lemma}
$\frac{x^{(1)} +x^{(2)}}{2}$ is not an equilibrium allocation.
\end{lemma}
\begin{proof}
Note that in any equilibrium, the price of item $3$ should be strictly larger than $1$. This implies all agents will spend out all their budgets. Let the price of item $3$ be $1 + \alpha$ for some $\alpha > 0$. Since agent $1$ get $7/12$ of item $1$ and $5/12$ of item $3$, the price of item $1$ is $1 - \frac{5}{7} \alpha$. Similarly, since agent $2$ get $5/6$ of item $2$ and $1/6$ of item $3$, the price of item $2$ is $1 - \frac{1}{5} \alpha$. Since $\alpha > 0$, given the price $(1 - \frac{5}{7} \alpha, 1 - \frac{1}{5} \alpha, 1 + \alpha)$, agent $3$ will not buy item $2$, which contradicts allocation $\frac{x^{(1)} +x^{(2)}}{2}$.
\end{proof}
\section{Models and definitions}\label{sec:model}
Consider a market with $n$ agents and $m$ divisible items. We assume without loss of generality that there is a unit supply of each item.
Each agent $i$ has a concave utility function $u_i:\mathbb{R}_+^m\to \mathbb{R}\cup\{-\infty\}$.
\begin{defi}
We say that the utility function $u_i:\mathbb{R}_+^m\to \mathbb{R}\cup\{-\infty\}$ is \emph{regular}, if
\begin{itemize}
\setlength\itemsep{0em}
\item The function $u_i$ is concave and the domain $K_i=\{x_i\in\mathbb{R}^m_+:\, u_i(x_i)>-\infty\}$ is closed.
\item $u_i$ restricted to $K_i$ is Lipschitz continuous, i.e. $|u_i(x_i)-u_i(y_i)|\le L\|x_i-y_i\|_2$ for $x_i,y_i\in K_i$.
\item $u_i(0)=0$.
\end{itemize}
\end{defi}
We assume that the Lipschitz constant $L$ is the same for all utility functions and is known a priori. This will be relevant
for the computational complexity of (approximately) solving convex programs with objective $u_i$.
The main requirement in the assumption $u_i(0)=0$ is that $0\in K_i$, i.e., the empty allocation is feasible. If that holds, we can shift the utility function to $u_i(0)=0$. Our main focus will be on the constrained PLC utilities defined in the introduction.
\begin{lemma}\label{lem:CPLC-regular}
Every constrained PLC utility function $u_i$ (Definition~\ref{def:cplc}) with $u_i(0)=0$ is regular.
For the Lipschitz parameter $L$, $\log L$ is polynomially bounded in the bit-complexity of the input.
\end{lemma}
\begin{proof}
The first property is immediate, and the Lipschitz bound follows by \cite[Corollary 3.2a and Theorem 10.5]{schrijver1998theory}.
\end{proof}
For prices $p\in\mathbb{R}^m_+$ and a budget $w_i$, we define the optimal utility value
\[
V_i(p,w_i)=\max_{x_i\in\mathbb{R}_+^m}\left\{u_i(x_i):\, p^\top x_i\le w_i\right\}\ ,
\]
and the \emph{demand correspondence} as the set of utility maximizing bundles that can be purchased at the given budget:
\[
D_i(p,w_i)=\arg\max_{x_i\in\mathbb{R}^m_+}\left\{u_i(x_i):\, p^\top x_i\le w_i\right\}\, ,
\]
Let
\[
V^{\max}_i=\max_{ x_i\in [0,1]^m} u_i(x_i)\, .
\]
be the maximum utility value achievable by purchasing at most 1 unit from each item. Clearly, $V^{\max}_i\ge u_i(0)=0$. Throughout, we make the following normalization assumption:
\begin{equation}\label{eq:V-max}
V^{\max}_i\le 1 \quad\mbox{for each agent }i.
\end{equation}
\hide{If $V^{\max}_i>0$, this can be guaranteed by scaling (we give an interval instead of setting $V^{\max}_i=1$, since one can only approximately compute the value in general).} \hide{If $V^{\max}_i=0$, then by concavity we must have $u_i(x_i)\le 0$ for all $x_i\in\mathbb{R}^m_+$. We can remove such agents, as they can always be allocated $x_i=0$ at equilibrium.}
Let
\[
C_i(p,w_i)=\min_{x_i\in\mathbb{R}^m_+}\left\{p^\top x_i:\, x_i\in D_i(p,w_i) \right\}\,
\]
be the minimum cost of an optimal bundle; we call this the \emph{thrifty cost}. If the market satisfies non-satiation, then $C_i(p,w_i)=w_i$, but it can be strictly less otherwise. Note that if $C_i(p,w_i)<w_i$, then $V_i(p,w_i)=\max_{ x_i\in \mathbb{R}^m_+} u_i(x_i)$.
We define the \emph{thrifty demand correspondence} as the set of cheapest optimal bundles.
\[
D_i^t (p,w_i)=\arg\min_{x_i\in\mathbb{R}^m_+}\left\{p^\top x_i:\, x_i\in D_i(p,w_i) \right\}\, .
\]
Finally, we let
\[
C^{\min}_i(p)=\min_{x_i\in\mathbb{R}^m_+}\left\{p^\top x_i:\, x_i\in \mathbb{R}^m, u_i(x_i)\ge V^{\max}_i \right\}\,
\]
denote the minimum cost to achieve $V^{\max}_i$ at prices $p$. Note that we also allow bundles here that are not in $[0,1]^m$, i.e., may use more than one unit of an item.
\subsection{The Fisher market model}
In the Fisher market model, we are given $n$ agents and $m$ divisible items of unit supply each. Each agent has a budget $w_i$ and a regular utility function $u_i:\mathbb{R}_+^m\to \mathbb{R}\cup\{-\infty\}$. We assume \begin{equation}\label{eq:V-max-pos}
V^{\max}_i > 0 \quad\mbox{for each agent }i.
\end{equation}
\hide{If $V^{\max}_i>0$, this can be guaranteed by scaling (we give an interval instead of setting $V^{\max}_i=1$, since one can only approximately compute the value in general).} If $V^{\max}_i=0$, then by concavity we must have $u_i(x_i)\le 0$ for all $x_i\in\mathbb{R}^m_+$. We can remove such agents, as they can always be allocated $x_i=0$ at equilibrium.
\begin{defi}[Fisher equilibrium] In a Fisher market with utilities $\{u_i\}_i$ and budgets $\{w_i\}_i$, the allocations and prices $(\{x_{i}\}_{i}, \{p_j\}_j)$ form a \emph{market equilibrium} if
\begin{itemize}
\setlength\itemsep{0em}
\item $x_i \in D_i(p,w_i)$ for each agent $i$, i.e., each agent buys an optimal bundle subject to budget constraint;
\item the market clears, i.e., $\sum_i x_{ij} \leq 1$, and $\sum_i x_{ij} = 1$ if $p_j > 0$ for every item $j$.
\end{itemize}
Further, $(\{x_{i}\}_{i}, \{p_j\}_j)$ is a \emph{thrifty market equilibrium} if we require the stronger $x_i \in D^t_i(p,w_i)$ for each agent $i$.
\end{defi}
In Section~\ref{sec::proof-existence-fisher} we prove the following theorem, which shows that regular utilities suffice for the existence of an equilibrium.
\begin{theorem} \label{thm::fisher-exists}
If all agents' utility functions are regular, then a thrifty market equilibrium always exists.
\end{theorem}
\begin{defi}[approximate Fisher equilibrium] \label{def:approx-eq}
In a Fisher market with utilities $\{u_i\}_i$ and budgets $\{w_i\}_i$ that satisfies assumption \eqref{eq:V-max}, the allocations and prices
$(\{x_{i}\}_{i}, \{p_j\}_j)$ form a {\em $(\sigma,\lambda)$-approximate market equilibrium} if
\begin{itemize}
\setlength\itemsep{0em}
\item $u_i(x_i)\ge V_i(p,w_i)-\lambda$ ;
\item $ p^\top x_i \leq w_i + \sigma \sum_i w_i$;
\item $\sum_i x_{ij} \leq 1$, and $\sum_j p_j(1 - \sum_i x_{ij}) \leq \sigma \sum_i w_i$.
\end{itemize}
Similarly, a {\em$(\sigma,\lambda)$-approximate thrifty market equilibrium} satisfies $ p^\top x_i \leq C_i(p,w_i) + \sigma \sum_i w_i$ instead of the second constraint.
A $(\sigma,\sigma)$-approximate (thrifty) market equilibrium will be also referred to as a {\em $\sigma$-approximate (thrifty) market equilibrium}.
\end{defi}
Note that, in order to get a meaningful approximate equilibrium solution, one needs to select $\sigma<1/(cn)$ for some constant $c$, since the error term is $\sigma \sum_i w_i$.
\subsection{The Arrow-Debreu market model}
\input{arrow_debreu_model}
\section{Proof of Theorem~\ref{thm::fisher-exists}} \label{sec::proof-existence-fisher}
\section{Existence of a market equilibrium}\label{sec::proof-existence-fisher}
In this section, we prove Theorem~\ref{thm::fisher-exists}.
We are done if a market equilibrium with $p\equiv 0$ exists. Otherwise, we define a correspondence $F(x,p): \mathbb{R}^{n\times m}\times\mathbb{R}^m\to \mathbb{R}^{n\times m}\times\mathbb{R}^m$ where Kakutani's fixed point theorem can be used.
The domain $(x,p)$ for this correspondence is
\[S := \left\{ (x,p)\in \mathbb{R}^{n\times m}\times\mathbb{R}^m:\, x_{ij} \in [0, 1.1];\ p_j \geq 0;\ 0 \leq \sum_j p_j \leq \sum_i w_i\right\}\enspace,\]
Let
\[
H_i(p,w_i)=\arg\max\left\{u_i(x_i):\, x_i\in [0,1.1]^m\, , p^\top x_i\le w_i\right\}\, ,
\]
This differs from $D_i(p,w_i)$ used previously by restricting the bundles to $x_i\in [0,1.1]^m$.
For allocations $x$ and prices $p$, we define $F(x,p)\subseteq \mathbb{R}^{n\times m}\times\mathbb{R}^m$ as the set of pairs $(x', p')$ such that
\begin{itemize}
\item $x'_i\in H_i(p,w_i)$, and $x'_i$ minimizes $p^\top x'_i$ over $H_i(p,w_i)$, i.e., $x'_i$ is a thrifty optimal bundle.
\item $p' \in \arg \max \sum_{i,j} p'_j x_{ij}\text{ s.t. } p'_j \geq 0 \text{ and } 0 \leq \sum_j p'_j \leq \max\{ \min_i w_i, \sum_{i,j} p_j x_{ij}\} $. That is, $p'$ is supported only on the items in maximum demand at $x$.
\end{itemize}
\begin{lemma}
If there is no market equilibrium with $p\equiv 0$, then any fixed point of $F(x, p)$ is a market equilibrium.
\end{lemma}
\begin{proof}
Let $(\{x_i\}_{i}, \{p_j\}_j)$ be a fixed point, i.e., $(x,p) \in F(x,p)$. By the budget constraint, $\sum_{i,j} p_jx_{ij} \leq \sum_i w_i$. Note that by the second condition in the definition of $F(x,p)$, we must have either $\sum_j p_j=\min_i w_i$ or $\sum_j p_j =\sum_{i,j} p_j x_{ij}$.
\paragraph{Case I: $\min_i w_i \leq \sum_{i,j} p_j x_{ij}.$}
In this case, $\sum_j p_j = \sum_{i,j} p_j x_{ij}$, and
there exist at least one $x_{ij} > 0$. Therefore,
$\sum_j p_j = \sum_{i,j} p_j x_{ij} = \left(\max_j \sum_i x_{ij}\right) \sum_j p_j$,
implying $\max_j \sum_i x_{ij} = 1$ and $p_j > 0$ only if $\sum_i x_{ij} = 1$, which is the market clearing condition. Let us show that every agent is getting an optimal bundle, at the minimum possible price: $x_i\in D_i(p,w_i)$ and $p^\top x_i=C_i(p,w_i)$.
\begin{itemize}
\item If $x_i\notin D_i(p,w_i)$, then there exists $\tilde{x}_i$ within budget constraints such that $u_i(\tilde{x}_i) > u_i(x_i)$. Since $x_i\in [0,1]^m$,
we can find an $\varepsilon>0$ such that $(1 - \varepsilon) x_i + \varepsilon \tilde{x}_i \leq 1.1$. By convexity, $u_i((1 - \varepsilon) x_i + \varepsilon \tilde{x}_i) > u_i(x_i)$, contradicting $x_i \in H(p,w_i)$.
\item If $x_i\in D_i(p,w_i)$ but $p^\top x_i>C_i(p,w_i)$, then there exists $\tilde{x}_i$ such that $p^\top \tilde{x}_i < p^\top x_i$ and $u_i(\tilde{x}_i) = u_i(x_i)$. Similarly, for a small positive $\epsilon$ such that $(1 - \epsilon) x_i + \epsilon \tilde{x}_i \leq 1.1$, $u_i((1 - \epsilon) x_i + \epsilon \tilde{x}_i) \geq u_i(x_i)$ and $p^\top ((1 - \epsilon) x_i + \epsilon \tilde{x}_i) < p^\top x_i$, which violates the fact that $p^\top x_i$ minimized over $H(p,w_i)$.
\end{itemize}
Therefore, in this case, $(\{x_i\}_{i}, \{p_j\}_j)$ gives a thrifty market equilibrium.
\paragraph{Case II: $\min_i w_i > \sum_{i,j} x_{ij} p_j$.} In this case, $\sum_j p_j=\min_i w_i$.
We show that $p\equiv 0$ is a market equilibrium, contrary to the assumption.
Indeed, either $\sum_i x_{ij} = 0$ for all $j$, or
\[
\sum_j p_j = \min_i w_i > \sum_{i, j} x_{ij}p_j =\left( \max_j \sum_i x_{ij} \right) \sum p_j\, .
\]
In both cases, $\sum_i x_{ij} < 1$ for all $j$ and no one spent out their budget, $\sum_j x_{ij} p_j < \min_i w_i$. This implies all agents get their favorite bundle (without the budget constraint) while the total demand of each good is less than $1$.
However, in such a case $p\equiv 0$ gives an equilibrium.
\end{proof}
\begin{lemma}
There exists a fixed point of correspondence $F(x, p)$.
\end{lemma}
\begin{proof}
We show this using the Kakutani's fixed point theorem~\cite{kakutani1941generalization}.
First, it is easy to check for any $(x, p)$, $F(x,p)\neq\emptyset$ and convex. For $x$, these follow since by the regularity assumption $u_i(0)=0$; and therefore $H_i(p,w_i)$ amounts to maximizing a concave function over a nonempty compact
set. The nonemptyness and convexity of the feasible $p'$ values is immediate.
Finally, we need to show that the map $F$ is upper hemicontinuous. Consider a sequence of allocations and prices such that $\lim_{r \rightarrow \infty} (x^{(r)}, p^{(r)}) = (x, p)$, $({x'}_i^{(r)}, p'^{(r)}) \in F(x^{(r)}, p^{(r)})$, and $\lim_{r \rightarrow \infty} {x'}_i^{(r)} = x'_i$,
$\lim_{r \rightarrow \infty} {p'}_i^{(r)} = p'_i$.
Upper hemicontinuity requires $(x'_i,p'_i) \in F(x, p)$.
For the prices $p'$, this easily follows by the Maximum theorem\footnote{$\sum_{ij} x_{ij} p_j$ is a continuous function of $x$ and $p$; and $U(x, p) = \{p'_j \geq 0; 0 \leq \sum_j p'_j \leq \max\{ \min_i w_i, \sum_{i,j} x_{ij} p_j \}$ is an upper and lower continuous correspondence.}. So, we only need to show that $x'$ is also upper hemicontinuous.
We prove this by a contradiction.
Let $(\tilde{x}_i,p'_i)\in F(x, p)$, There are two cases.
\begin{itemize}
\item $u_i(\tilde{x}_i) > u_i(x'_i)$. We claim that $u_i({x'_i}^{(r)})$ will be no smaller than $\frac{u_i(\tilde{x}_i) + u_i(x'_i)}{2}$ if $r$ is big enough, which provides a contradiction.\footnote{Since ${x'_i}^{(r)} \in F(x^{(r)}, p^{(r)})$, ${x'_i}^{(r)} \in K_i$, the domain of $u_i$. By regularity, $K_i$ is closed, and $u_i$ is continuous of $K_i$, therefore $\lim_{r \rightarrow \infty} u_i({x'_i}^{(r)}) = u_i(x'_i)$.} This is because we can find a small $\varepsilon$, such that for $y_i=(1 - \varepsilon)\tilde x_i$, we have $u_i(y_i)\ge u_i(\tilde{x}_i) + \varepsilon u_i(0) \geq \frac{u_i(\tilde{x}_i) + u_i(x'_i)}{2}$. Additionally, we know that $p^\top y_i =(1 - \varepsilon) p^\top \tilde{x}_i$, which implies that $y^{(i)}$ is a feasible solution for iterate $p^{(r)}$ if $p^{(r)}$ is close enough to $p$. Therefore, the $u_i({x'_i}^{(r)}) \geq u_i(y_i) \geq \frac{u_i(\tilde{x}_i) + u_i(x'_i)}{2}$.
\item $u_i(\tilde{x}_i) = u_i(x'_i)$ but $p^\top \tilde{x}_i < p^\top x'_i$. In this case, for those $p^{(r)}$ which is close enough to $p$, $\tilde{x}_i$ is also a budget feasible allocation which maximized the utility function. This is because $p^\top \tilde{x}_i < p^\top x'_i \leq w_i$ and any better solution of $p^{(r)}$ will provide a solution (a convex combination of this better solution and $\tilde{x}_i$) of strictly better utility than $\tilde{x}_i$ at price $p$. Since $\tilde{x}_i$ is a budget feasible allocation which maximized the utility function for those $p^{(r)}$, $\sum_j {x'}^{(r)}_{ij} p^{(r)}_j \leq \sum_j \tilde{x}_{ij} p^{(r)}_j$. However, $ \sum_j x'_{ij} p_j = \lim_{r \rightarrow \infty} \sum_j {x'_{ij}}^{(r)} p^{(r)}_j \leq \lim_{r \rightarrow \infty} \sum_j \tilde{x}_{ij} p^{(r)}_j = \sum_j \tilde{x}_{ij} p_j$ which contradicts the fact that $p^\top \tilde{x}_i < p^\top x'_i$.
\end{itemize}
This completes the proof of Theorem~\ref{thm::fisher-exists}.
\end{proof}
| {'timestamp': '2021-07-14T02:03:06', 'yymm': '2107', 'arxiv_id': '2107.05700', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05700'} | arxiv |
\section{Introduction}
\subsection{Problem statement}
An adaptive search problem for a general \emph{search domain} $\mathcal{S}$ and an arbitrary \emph{adversary} can be formulated as follows.
The goal is to design an adaptive algorithm, also called a \emph{strategy}, that finds a \emph{target} that is initially unknown to the algorithm.
The process is divided into \emph{steps}: in each step the algorithm performs a \emph{query} and receives an \emph{answer}.
The adaptiveness is understood in a way that the subsequent actions of the algorithm depend on the already received answers.
Such a query-reply pair provides new information to the algorithm: it learns that some part of the search space $S\subseteq\mathcal{S}$ does not contain the target while its complement does.
It is interesting, both from theoretical and practical point of view, to have error-resilient algorithms for such search process.
This is modeled by the presence of noise: each reply can be erroneous with some fixed probability $0<p<\frac{1}{2}$, independently.
The performance of a strategy is measured by the number of the queries performed.
In general, the target is fixed prior to the beginning of the game.
This selection is either made in the \emph{adversarial model} (i.e., the adversary, knowing the algorithm, picks the target maximizing the strategy length) or in the randomized way, according to a public distribution $\mu$ of all possible targets (we call it the \emph{distributional model}).
The classical choice for the search domain $\mathcal{S}$ is a sorted array, which leads to the well known binary search algorithm.
In such case the natural queries are comparisons, although we point out that other queries, like arbitrary subsets, have also been studied.
Interestingly, it is possible to have algorithms for the noisy scenarios that are information-theoretic optimal (up to lower order terms), for the classical binary search see e.g. \cite{Ben-OrH08}.
A generalization of this search domain is to consider graph structures, which has been introduced first for trees~\cite{OnakP06} and then for general graphs~\cite{Emamjomeh-Zadeh:2015aa}.
For graphs, each query simply points to some vertex $v$ of the input graph $G$, and the answer either states that $v$ is the target, or provides a neighbor of $v$ that is closer to the target than $v$.
We remark that the graph setting is a natural generalization of the classical ``twenty questions game'' (attributed to R\'{e}nyi~\cite{Renyi61} and Ulam~\cite{Ulam76}).
\subsection{Motivation and earlier techniques}
Adaptive query algorithms play an important role in theoretical computer science, with classical binary search and its variations being the most fundamental example.
They also provide a foundation for more complex computational problems like sorting --- see e.g. \cite{Ben-OrH08} for a broader discussion.
Historically speaking, the classical binary search with erroneous comparisons (or more general queries as well) has received significant attention, also in a simpler noise setting where the number of errors is bounded by a constant that is known a priori to the algorithm.
The transition from sorted data (i.e., paths) to graph-like structures is natural both from the theoretical point of view and from the perspective of potential applications, e.g., in automatic software testing \cite{Ben-AsherFN99} or in machine learning \cite{Emamjomeh-ZadehK17}.
An interesting spectrum of applications of binary search can be found in designing a series of tests in biological experiments~\cite{Heinemeyer04}.
A typical technique for dealing with noisy search is the \emph{multiplicative weights update} (MWU): for each element $v$ the algorithm keeps a weight $\omega(v)$ that represents the likelihood that $v$ is the target.
Then $\omega(v)$ is appropriately scaled depending on the answer to the query.
This general tool is quite well understood and for further reading we refer to the survey of Arora et. al. \cite{AroraHK12}.
A special case of this approach is the Bayesian learning, in which initial weights describe the probability distribution of the target (so called \emph{prior distribution}) and later on $\omega(v)$ is updated according to conditional probabilities of the observed answers.
The process continues either until one element accumulates large enough likelihood of being the target, or until a predetermined number of queries has been performed.
Thus, the subject of the analysis in that setting is the estimation of the convergence rate of such process; see e.g. \cite{GhosalGV00,HoNDN20,ShenW01} for examples of such an analysis for general types of prior distributions.
We note that if a search model is not distributional (we do not know the prior probabilities), it often works very well to start with the uniform distribution and perform Bayesian updates anyway.
We remark that the authors of~\cite{Ben-OrH08} combine such Bayesian learning technique with a random shifting of the input sequence as a tool to actually ensure the uniform initial distribution.
We also note that such a random shifting will not work in the graph-theoretic setting due to the complex structure of the search space.
Moreover, a closer analysis of~\cite{Ben-OrH08} provides a framework that may give a tool for distributional graph search: each query is selected to maximize the amount of information to be learned.
Unfortunately, it turns out that this cannot be transferred to graph search, since the algorithm in~\cite{Ben-OrH08} strongly relies on the subtlety of the search model, where an incorrect answer, when negated, provides an opposite (correct) answer.
This property makes it possible to estimate expected information gain after each query.
In the graph search model, for each query there is more than one answer that constitutes an error, which makes such approach impossible.
For the graph-theoretic case with noise, the multiplicative weight update proved to work well \cite{DereniowskiTUW19,Emamjomeh-ZadehK17,Emamjomeh-Zadeh:2015aa} and we further advance this approach in our work.
The distributional noisy model has been considered to date for binary search only~\cite{DaganFKM18}, where the above-mentioned approaches are combined in the following way - the core of the method is a decision tree traversal.
To make the algorithm resilient to errors, a verification and backtracking mechanisms are added to the traversal.
In particular, two verification methods are used, depending on the cases selected for the algorithm: the separate majority vote and an observation that enough past queries had replies consistent with accepting the current one as correct.
A disadvantage of applying this technique in our context is that it is already quite complex in this restricted case of binary search.
\paragraph{Issue of proof correctness in \cite{Ben-OrH08}.}
To motivate our work further, we also point out two flaws in the state-of-the art noisy binary searching \cite{Ben-OrH08}. Firstly, the paper bounds the expected number of steps of the algorithm to be the total information needed divided by the \emph{expected} information gain. Such transition works (pushing expectancy to denominators) only through careful application of probabilistic tools, and might result in additional lower order terms.
Secondly, more serious issue can be found in the proof of Lemma~2.6 in~\cite{Ben-OrH08}: it takes all the queries asked by the algorithm, in sorted order of positions, denoted by $q_1 \le \cdots \le q_t$, and considers for some $x,y$ the set of queries corresponding to $q_x \le q_{x+1} \le \cdots \le q_{y-1}$ such that $q_x > s$, where $s$ denotes the target. Then, the number of `$<$' answers is given by a binomial distribution $B(y-x, 1-p)$. However, the issue is that while the answers to the particular queries are independent random variables, the \emph{position} of queries depends on the answers to the previous queries. Thus when taking a subset of queries based on their positions, we cannot claim their independence and use binomial distribution.
\subsection{Our contribution}
In an ideal scenario, there always exists a query such that each possible reply subdivides the search space evenly, thus maximizing the information gain to the algorithm.
In such a case the Bayesian updates are sufficient to get an optimal search time.
However, there are two obstacles that prevent us from a straightforward application of Bayesian updates.
First, typically perfect bisection of search space is not possible.
This actually occurs both for binary search with comparisons and for graphs since some elements may have large weights.
Thus, these problems can be seen more generally as a game of maximizing the information gain while performing queries.
Second problem to overcame, particularly in the graph search, is the fact that the adversarial scenario may be seen as one in which the target distribution is not known a priori to the algorithm.
In terms of development of the new methods, we introduce some new ideas that considerably simplify the analysis and lead to tight bounds.
One of those is our measure of progress: instead of keeping track how the total weight decreases after each query, we are interested how the total weight behaves with some elements excluded.
In the graph search it is enough to look at the vertex with the largest current weight and it turns out that for the remaining vertices the required weight drop occurs (cf. Lemma~\ref{lem:xT}).
Thus, only one vertex is excluded at any point from the weight analysis.
Interestingly, this vertex may be changing throughout the search.
We point out that this approach does not adopt the previously used idea of putting such problematic vertices aside to search through them at some later stage.
Instead, all vertices are uniformly treated throughout the entire search.
This way of measuring progress allows to conclude that the expected information gain in a single step is precisely the optimal $I(p) = 1 - H(p) = 1 + p \log_2 p + (1-p) \log_2 (1-p)$ (see the proof of Lemma~\ref{lem:graph-lv-distr}).
For binary search having only one excluded element seems to be infeasible.
We propose a strategy where the excluded elements accumulate over the search but an analogous bound for the remaining weight can be proved (cf. Equation~\eqref{eq:excluded-binsearch-bound} and the corresponding Lemma~\ref{lem:epoch-progress}).
A simple approach could be to find at each step the element that is the closest to perfect bisection of the weights, then query and exclude it.
However, that might lead to too many excluded elements, which the second phase of the algorithm might not be able to handle in a desirable time bound.
Thus, we propose the following approach: we process queries in epochs, where at the start of an epoch algorithm selects best possible bisecting element and excludes it. For the duration of the whole epoch the same query is repeated, updating the weights along the way.
This limits the number of excluded elements, at the cost of having possibly sub-optimal queries for the duration of the epoch. However, we are able to show bounds on the \emph{expected} weight drop (cf. Lemma~\ref{lem:epoch-progress}).
\medskip
Our results are summarized in Table~\ref{tab:res}.
For the graph searching we obtain the three following algorithmic results.
The algorithms achieving the stated query complexities are provided in subsequent Section~\ref{sec:graph-search}: Algorithms~\ref{alg:graph-adversarial}, \ref{alg:graph-las-vegas-distributional} and~\ref{alg:graph-las-vegas-adversarial} correspond to Theorems~\ref{thm:graph:worst-case}, \ref{thm:graph:lv-distr} and~\ref{thm:graph:lv-adversarial}, respectively.
\begin{theorem} \label{thm:graph:worst-case}
For an arbitrary graph $G$, a noise parameter $0<p<\frac{1}{2}$ and a confidence threshold $0 < \delta < \frac{1}{2}$, there exists an adaptive graph searching algorithm that after
$$\frac{1}{I(p)} \left( \log_2 n + \mathcal{O}(\sqrt{\log n \log \delta^{-1}}) + \mathcal{O}(\log \delta^{-1}) \right)$$
queries returns the target correctly with probability at least $1-\delta$.
\end{theorem}
\begin{theorem} \label{thm:graph:lv-distr}
For an arbitrary graph $G$, a noise parameter $0<p<\frac{1}{2}$ and a confidence threshold $0 < \delta < \frac{1}{2}$, there exists an adaptive Las Vegas graph searching algorithm that after the expected number of at most
$$\frac{1}{I(p)} \left( H(\mu) + \log_2 \delta^{-1} + 1 \right)$$
queries returns the target correctly with probability at least $1-\delta$, provided that an initial target distribution $\mu$ is given as an input.
\end{theorem}
\begin{theorem} \label{thm:graph:lv-adversarial}
For an arbitrary graph $G$, a noise parameter $0<p<\frac{1}{2}$ and a confidence threshold $0 < \delta < \frac{1}{2}$, there exists an adaptive Las Vegas graph searching algorithm that after the expected number of at most
$$\frac{1}{I(p)} \left( \log_2 n + \mathcal{O}(\log \log n) + \mathcal{O}(\log\delta^{-1}) \right)$$
queries returns the target correctly with probability at least $1-\delta$.
\end{theorem}
In the statements above, $H(\mu)$ is the entropy of the distribution defined as $H(\mu)=\sum_x\mu(x)\log_2\frac{1}{\mu(x)}$, and $I(p)=1-H(p)$ is the information function.
The binary search algorithms referred in the theorems below are in Section~\ref{sec:binary-search}: Algorithms~\ref{alg:binary-adversarial} and \ref{alg:las-vegas-distributional} correspond to Theorems~\ref{thm:bin:worst-case} and \ref{thm:bin:las-vegas:distr}.
\begin{theorem} \label{thm:bin:worst-case}
For any $0<p<\frac{1}{2}$ and a confidence threshold $0 < \delta < \frac{1}{2}$, there exists an adaptive binary search algorithm for any linear order that after
$$\frac{1}{I(p)} \left( \log_2 n + \mathcal{O}(\sqrt{\log n \log\delta^{-1}}) + \mathcal{O}(\log\delta^{-1}) \right)$$
queries returns the target correctly with probability at least $1-\delta$.
\end{theorem}
\begin{theorem} \label{thm:bin:las-vegas:distr}
For any $0<p<\frac{1}{2}$ and a confidence threshold $0 < \delta < \frac{1}{2}$, there exists an adaptive binary search Las Vegas algorithm for any linear order that after the expected number of
$$\frac{1}{I(p)} \left( H(\mu)+\mathcal{O}(H_2(\mu))+\mathcal{O}(\log\delta^{-1}) \right)$$
queries returns the target correctly with probability at least $1-\delta$, provided that an initial target distribution $\mu$ is given as an input.
\end{theorem}
Where in the last statement $H_2(\mu)=\sum_x\mu(x)\log_2\log_2\frac{1}{\mu(x)}$.
Using the random shifts as in \cite{Ben-OrH08}, the case when the input distribution is unknown can be turned into the uniform distribution scenario and thus Theorem~\ref{thm:bin:las-vegas:distr} gives the following.
\begin{corollary} \label{cor:bin:lv-adversarial}
For any $0<p<\frac{1}{2}$ and a confidence threshold $0 < \delta < \frac{1}{2}$, there exists an adaptive binary search Las Vegas algorithm that after the expected number of
$$\frac{1}{I(p)} \left( \log_2 n + \mathcal{O}(\log \log n) + \mathcal{O}(\log\delta^{-1}) \right)$$
queries returns the target correctly with probability at least $1-\delta$.
\end{corollary}
Our contribution can be summarized as follows.
In the graph scenario, we argue that the Bayesian updates technique is enough because the fact that no perfect bisection is possible can be handled on the level of the analysis, and is not imprinted in the algorithm.
Here the contribution lies in a much simpler analysis than in prior works.
Moreover, the analysis carries over to the remaining new results.
In particular, the distributional case has not been considered before for graphs, thus Theorem~\ref{thm:graph:lv-distr} gives a new bound.
The algorithm behind this theorem can be directly used to obtain a Las Vegas algorithm for the adversarial case (cf. Theorem~\ref{thm:graph:lv-adversarial}).
Here the twist lies in adjusting the confidence level appropriately and the details of the differences between these two settings are hidden in the analysis.
For the binary search, the Bayesian updates leave the algorithm with several candidates for the target.
This seems difficult to avoid and we leave it as our main open question whether a one-phase multiplicative update can be sufficient to find the target.
The new result for binary search is Theorem~\ref{thm:bin:worst-case} for the adversarial noisy case.
For the Las Vegas settings we provide Theorem~\ref{thm:bin:las-vegas:distr} and its direct Corollary~\ref{cor:bin:lv-adversarial}
which together give a simpler analysis than in prior works, correcting also some ambiguities present in the analysis in~\cite{Ben-OrH08}.
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
\bgroup\def1.5{1.5}
\begin{table}[htb]
\caption{The summary of the results}
\label{tab:res}
\centering
{
\small
\begin{tabular}{p{0.15\linewidth}c:c}
\toprule
\emph{The model} & \emph{Graph search} & \emph{Binary search} \\
\midrule
\multirow{2}{\linewidth}{Worst case:} & \multicolumn{2}{c}{$\frac{1}{I(p)}\left(\log_2 n + \mathcal{O}(\sqrt{\log n \log \delta^{-1}})+ \mathcal{O}(\log \delta^{-1})\right)$} \\
& (Thm.~\ref{thm:graph:worst-case}; simpler than in \cite{DereniowskiTUW19} \& \cite{Emamjomeh-Zadeh:2015aa}) & (Thm.~\ref{thm:bin:worst-case}; new result) \\
\cdashline{2-3}
\multirow{2}{\linewidth}{Las Vegas \& distributional:} & $\frac{1}{I(p)}(H(\mu)+\log_2\delta^{-1}+1)$ & $\frac{1}{I(p)}(H(\mu)+\mathcal{O}(H_2(\mu))+\mathcal{O}(\log\delta^{-1}))$ \\
& (Thm.~\ref{thm:graph:lv-distr}; new result) & (Thm.~\ref{thm:bin:las-vegas:distr}; correctly w.r.t: \cite{Ben-OrH08})\\
\cdashline{2-3}
\multirow{2}{\linewidth}{Las Vegas \& adversarial:} & \multicolumn{2}{c}{$\frac{1}{I(p)}(\log_2 n + \mathcal{O}(\log\log n) + \mathcal{O}(\log\delta^{-1}))$} \\
& (Thm.~\ref{thm:graph:lv-adversarial}; new result) & (Cor.~\ref{cor:bin:lv-adversarial}; correctly w.r.t: \cite{Ben-OrH08})\\
\bottomrule
\end{tabular}
}
\end{table}
\subsection{Related work}
There are many variants of the interactive query games, depending on the structure of queries and the way erroneous replies occur.
There is a substantial amount of literature that deals with fixed number of errors for arbitrary membership queries or comparison queries for binary search; we refer the reader to some surveys~\cite{Deppe2007,PELC200271}.
Among the most successful tools for tackling binary search with errors, there is the idea of a volume~\cite{Berlekamp68,RivestMKWS80}, which exploits the combinatorial structure of a possible distribution of errors.
A natural approach of analyzing decision trees has been also successfully applied, see e.g. \cite{FeigeRPU94}.
See \cite{BorgstromK93,Emamjomeh-Zadeh:2015aa} for examples of partitioning strategies into stages, where in each stage the majority of elements is eliminated and only few `problematic' ones remain.
For a different reformulation (and asymptotically optimal search results) of the noisy search see \cite{KarpK07}.
Although the adversarial and noisy models are most widely studied, some other ones are also considered.
As an example, we mention the (linearly) bounded error model in which it is guaranteed that the number of errors is a $r$-fraction, $r<\frac{1}{2}$, of (any initial prefix of) the number of queries, see e.g.~\cite{AslamD91,BorgstromK93,DhagatGW92}.
Interestingly, it might be the case that different models are so strongly related that a good bound for one of them provides also tight bounds for the other ones, see e.g. \cite{DereniowskiTUW19} for an example of such analysis.
The first results regarding distributional query search with fixed number of errors is due to Shannon~\cite{Shannon48} where is has been shown a strategy using up to $H(\mu)+1$ arbitrary queries on average.
The Shannon-Fano-Elias code takes $H(\mu)+2$ comparison queries on average.
The distributional version has been recently re-considered in \cite{DaganFKM18}, where it is also assumed that at most $k$ answers can be erroneous.
Then, an optimal strategy consists of $H(\mu)+kH_2(\mu)$ comparison queries up to an additive factor of $\mathcal{O}(k\log_2 k + kH_3(\mu))$, where $H_3(\mu)=\sum_{x}\mu(x)\log_2\log_2\log_2(1/\mu(x))$.
This generalizes the result of Rivest et al. for the uniform distribution~\cite{RivestMKWS80}, and improves the codes from~\cite{Shannon48}.
In view of the above, it is interesting to see what types of queries can be used for constructing effective strategies?
In~\cite{DaganFGM17} is is shown that there exists a `natural' set of $\mathcal{O}(rn^{1/r})$ queries allowing for construction of strategies of length $H(\mu)+r$, and it is also shown that this bound is asymptotically tight.
The theory of coding schemes for noisy communication is out of scope of this survey and we point to some recent works \cite{BravermanEGH16,GellesHKRW16,GellesMS14,Haeupler14,LeungNSTYY18}.
The first steps towards generalizing binary search to graph-theoretic setting are works on searching in partially ordered data \cite{Ben-AsherFN99,LaberMP02,LamY01}.
Specifically for the node search that we consider in this work, the first results are due to Onak and Parys for the case of trees~\cite{OnakP06} and the recent work of Emamjomeh-Zadeh et al. for general graphs \cite{Emamjomeh-ZadehK17,Emamjomeh-Zadeh:2015aa}.
In the former, an optimal linear-time algorithm for error-less case was given.
It has been shown in~\cite{Emamjomeh-Zadeh:2015aa} how to construct, for the noisy model with an input being an arbitrary graph of order $n$, a strategy of length at most
$\frac{1}{I(p)}\left(\log_2 n+\mathcal{O}(\frac{1}{C}\log_2 n + C^2 \log_2 \delta^{-1})\right)$, where $C=\max\left((\frac{1}{2}-p) \sqrt{\log_2 \log_2 n},1\right)$,
with the confidence threshold $\delta$.
The strategy has been simplified and the query complexity further improved in \cite{DereniowskiTUW19} to reach an upper bound on the query complexity:
$\frac{1}{I(p)}\left(\log_2 n + \widetilde\mathcal{O}(\sqrt{\log_2 n \log_2 \delta^{-1}}) + \mathcal{O}(\log_2 \delta^{-1})\right)$.
It is interesting to note that these strategies, when applied to lines, reach the optimal query complexities (up to lower order terms) for linear orders, thus matching the limits of binary search.\footnote{However one has to have in mind that graph queries applied to linear orders provide \emph{richer} set of replies: $\{<,>,=\}$, compared to $\{<,>\}$ in case of a binary search.}
We refer the reader to a description of few interesting potential applications of this graph searching framework in machine learning, particularly for problems like learning a ranking, a clustering or a classifier \cite{Emamjomeh-ZadehK17}.
Also, some generalizations with non-uniform query times (where the duration of querying each vertex is dictated by its weight) have been also considered~\cite{DereniowskiKUZ17}.
We finally also mention a somewhat related graph-theoretic model in which a walking agent is performing queries \cite{BoczkowskiKR18,HanusseIKN10}.
\section{Preliminaries} \label{sec:preliminaries}
Denote $p = \frac{1}{2} - \varepsilon$ be the noise parameter. It is useful to denote $\Gamma = \frac{1-p}{p} \approx 1+4\varepsilon$.
Whenever we refer to a \emph{search space}, we mean either an (undirected and unweighted) graph or a linear order.
This term will be used for definitions that are common for both.
Consequently, by an \emph{element} of a search space we mean a vertex or an integer, respectively.
In the following $n$ is the size of the search space, i.e., either the number of vertices in a graph or the number of integers in a linear order.
The strategies will maintain the weights $\omega(v)$ for the elements $v$ of a search space $V$.
For an arbitrary $0\leq c\leq 1$, $v$ is \emph{$c$-heavy} if $\omega(v)/\omega(V)\geq c$, where for any subset $U\subseteq V$ we write $\omega(U)=\sum_{u\in U}\omega(u)$.
$\frac{1}{2}$-heavy elements will play a special role and we refer to them as \emph{heavy} for brevity.
For the graph search, we will adopt a slightly weaker model in which an adaptive algorithm receives less information in some cases.
This is done in somewhat artificial way for purely technical reasons, i.e., to simplify several arguments during analysis.
In particular, the amount of information will depend on the current weights and the case when the algorithm receives less information than dictated by the graph searching model is when a heavy vertex is queried and the answer says that it is not the target.
\begin{adjustwidth}{\parindent}{}
\textbf{Graph queries model specifics.}
Suppose that a vertex $q$ is queried.
The reply either informs that $q$ is the target, which we call a \emph{yes-answer}.
Or, the reply gives a neighbor $u$ of $q$ that lies on the shortest path from $q$ to the target, and we call it a \emph{no-answer}.
However, for the sake of technical simplicity of the analysis, we if $q$ was \emph{heavy} and \emph{no-answer} was given, the algorithm reads it as a \emph{target is not $q$} reply (ignoring the direction the target might be).\footnote{This only makes the algorithms stronger, since it operates in a weaker replies model.}
\end{adjustwidth}
Note that any algorithmic guarantees for the above model carry over to the generic graph search model.
To adopt the above, we will say that a vertex $v$ is \emph{compatible} with the reply if and only if $v=q$ in case of a yes-answer, or the neighbor $u$ given in a no-answer when $q$ is not heavy lies on a shortest $q$-$v$ path.
Thus in particular, in case of a no-answer regarding a heavy $q$, no vertex is compatible.
The weight of an element $v$ at the end of step $t$ is denoted by $\omega_t(v)$, with $\omega_0(v)$ being the initial value.
The initial values are set by an algorithm depending on a particular model.
For distributional scenarios, the initial weight of each element equals its probability of being the target, that is, $\omega_0(v)=\mu(v)$ for each $v$.
For worsts case scenarios, the weights are set uniformly, $\omega(v)=\frac{1}{n}$ for each $v$.
We recall the Bayesian updates (Algorithm~\ref{alg:bayesian}) that are at the core of our strategies.
\begin{algoBox}{0.75}
\begin{algo} \label{alg:bayesian} \textup{(Bayesian updates.)}
\medskip
In a step $t+1$, for each element $v$ of the search space do:
\hspace*{15pt}if $v$ is compatible with the answer, then $w_{t+1}(v) \leftarrow w_t(v) \cdot (1-p)$,
\hspace*{15pt}if $v$ is not compatible with the answer, then $w_{t+1}(v) \leftarrow w_t(v) \cdot p$.
\end{algo}
\end{algoBox}
The algorithm relies on the fact that Bayesian updates keep the weights to be the conditional probabilities, that is:
at each step $\tau$ during the execution of algorithm,
\begin{equation*}\Pr(v=v^{*}\ \text{at step } \tau\ |\ \text{conditioned on received answers}) = \frac{w_{\tau}(v)}{w_{\tau}(V)}.\end{equation*}
Denoting by $d(u,v)$ the graph distance between $u$ and $v$, i.e., the length of the shortest path between these vertices,
$$q = \arg \min_{v \in V} \sum_{u \in V} d(u,v) \cdot \omega(u)$$
is called a \emph{median} of the graph.
For a query $v$ and a reply $u$ let us use $C(v, u)$ to denote a set of all vertices consistent with that reply, i.e $C(v, v) = \{v\}$ and $C(v, u) = \{x \in V | u \text{
lies on some shortest path from } v \text{ to } x \}$ for $v \neq u$.
We note a fundamental bisection property of a median:
\begin{lemma}[c.f. \cite{Emamjomeh-Zadeh:2015aa} Lemma 4] \label{lem:median-bisection}
If $q$ is a median, then $\max_{u \in N(q)} C(q, u) \le \omega(V)/2$.
\end{lemma}
\begin{proof}
Suppose towards the contradiction that $C(q, u) > \omega(V)/2$ for some $u \in N(q)$.
Observe that $\Phi(u) \leq \Phi(q) - \omega(C(q, u)) + \omega(V \setminus C(q, u))$ since by moving from $q$ to $u$ we get closer to all vertices in $C(q, u)$.
But $\Phi(q) - \omega(C(q, u)) + \omega(V \setminus C(q, u)) = \Phi(q) + \omega(V) - 2\omega(C(q, u)) < \Phi(q)$ by our assumption, hence $\Phi(u) < \Phi(v)$, which yields a contradiction.
\end{proof}
Let $X_1, X_2, \ldots, X_n$ be a sequence of i.i.d random variables.
We say that a random variable $N$ is a \emph{stopping time} (with respect to $X_1, X_2, \ldots, X_n$) if $\mathbbm{1}_{\{N \leq n\}}$ is a function of $X_1, X_2, \ldots, X_n$.
We will use the following version of Wald's identity.
\begin{theorem}\label{wald} (Wald's Identity)
Let $X_1, X_2, \ldots, X_n$ be i.i.d with finite mean, and $N$ be a stopping time with $\mathbb{E}[N] < \infty$. Then $\mathbb{E}[X_1 + \cdots + X_N] = \mathbb{E}[X_1]\mathbb{E}[N]$.
\end{theorem}
\section{Graph searching} \label{sec:graph-search}
We first analyze how the weights behave when in each step a median is queried and the Bayesian updates are made.
This analysis is independent of the weight initialization and thus is common for all following graph searching algorithms.
Essentially we prove that in expectation, that is in an amortized way, the total weight (with heaviest vertex excluded) decreases by half per step.
For some steps this can be concluded directly (cf. Lemma~\ref{lem21}).
Lemmas~\ref{lem23} and~\ref{lem22} then refer to an interval of queries to the same heavy vertex $x$.
If such an interval has the property that it ended (Lemma~\ref{lem22}), then the required weight drop can be claimed by the end of the interval.
For this, informally speaking, the crucial fact is that $x$ received many no-answers during this interval.
If a strategy is at a step that is within such interval, then Lemma~\ref{lem23} is used to make the claim on the total weight with the weight of $x$ excluded.
Hence, at any point of the strategy the weight decreased appropriately as shown in Lemma~\ref{lem:xT}.
\begin{lemma}[see also \cite{Emamjomeh-Zadeh:2015aa,DereniowskiTUW19}]
\label{lem21}
If in a step $t$ there is no heavy vertex, then
$$w_{t+1}(V) \le w_t(V)/2.$$
\end{lemma}
\begin{proof}
Let $q$ be a query and $u$ an answer in step $t$.
If $q \neq u$ then $\omega_{t}(C(q, u))\leq\omega_{t}(V)/2$ by Lemma \ref{lem:median-bisection} and in case $q = u$ we have $C(q, u)=\{q\}$ and thus the same bound holds.
Then in both cases,
$\omega_{t+1}(V) = (1-p)\cdot\omega_{t}(C(q, u))+p\cdot\omega_{t}(V \setminus C(q, u)) \leq \frac{1}{2}\omega_{t}(V)$.
\end{proof}
\begin{lemma}[see also \cite{DereniowskiTUW19}]
\label{lem22}
Consider an interval $I=\{\tau,\tau+1,\ldots,\tau+k-1\}$ of $k$ queries such that some $x$ is heavy in each query in $I$ and is not heavy at the sequence's last query. Then
$$w_{\tau+k}(V) \le w_{\tau}(V)/2^k.$$
\end{lemma}
\begin{proof}
First note that in each query in the interval $I$, the queried vertex is $x$.
Hence consider any two queries $i$ and $j$ in $I$ such that they receive different replies.
The contribution of these two queries is that for each vertex $v$, its weight is multiplicatively scaled down by $p(1-p)\leq\frac{1}{4}$.
Also, for a single no-answer in a query $i \in I$ we get
$$\omega_{i+1}(V)=p\omega_i(x)+(1-p)\omega_i(V\setminus\{x\}) \leq \omega_i(V)/2$$
because $\omega_i(x)\geq\omega_i(V\setminus\{x\})$ for the heavy vertex $x$.
By assumption, the number of no-answers is at least the number of yes-answers in $I$.
Thus, the overall weight drop is as claimed in the lemma.
\end{proof}
\begin{lemma}
\label{lem23}
Consider an interval $I=\{\tau,\tau+1,\ldots,\tau+k-1\}$ of $k$ queries such that some $x$ is heavy in each query in $I$, and $x$ remains heavy after the last query in $I$.
Then $$w_{\tau+k}(V \setminus \{x\}) \le w_{\tau}(V)/2^k.$$
\end{lemma}
\begin{proof}
Recall that in each query in the interval $I$, the queried vertex is $x$.
Assume that there were $a$ yes-answers in $I$ and $b$ no-answers, with $a+b=k$.
If $a \ge b$, then $\omega_{\tau+k}(V \setminus \{x\}) = p^a (1-p)^b \omega_{\tau}(V \setminus \{x\}) \le w_{\tau}(V)/2^k$.
If $a < b$, then we bound as follows:
$\omega_{\tau+k}(V \setminus \{x\}) \le \omega_{\tau+k}(x) = p^b (1-p)^a \omega_{\tau}(x) \le \omega_{\tau}(V)/2^k$.
\end{proof}
The bound in the next lemma immediately follows from Lemmas~\ref{lem21},~\ref{lem22} and~\ref{lem23}.
We say that an element $v$ is \emph{heaviest} if $\omega(v)\geq\omega(u)$ for each $u\in V$.
For each step $i$, we denote by $x_i$ a heaviest vertex at this step, breaking ties arbitrarily.
\begin{lemma} \label{lem:xT}
If the initial weights satisfy $\omega_0(V) = 1$, then
$$\omega_{\tau}(V \setminus \{x_{\tau}\}) \le \frac{1}{2^\tau}.$$
\end{lemma}
\begin{proof}
We consider the first $\tau$ queries and observe that they can be partitioned into a disjoint union of maximal intervals in which either there is a heavy vertex present (in the whole interval) or there is no heavy vertex (in the whole interval).
We apply Lemma~\ref{lem21} for intervals with no heavy vertex and Lemmas~\ref{lem22},~\ref{lem23} for intervals with heavy vertex present (note that Lemma~\ref{lem23} can be applied only to the last interval, if there exists a heavy vertex after we perform all $\tau$ queries).
\end{proof}
We note that $\omega_{\tau}(V \setminus \{x_{\tau}\})$ will be our key measure of progress, despite the fact that the $x_{\tau}$ may be changing throughout the search, i.e., $x_{\tau}$ does not have to be the target at some stages of the search.
When our strategies complete, however, $x_{\tau}$ is provably the target within the imposed confidence threshold.
\subsection*{Proof of Theorem~\ref{thm:graph:worst-case} (Worst-case strategy length)}
In this section we prove Theorem~\ref{thm:graph:worst-case}.
Take $Q$ to be the smallest positive integer for which $I(p)Q \ge \log_2 n + \sqrt{\frac{Q}{2} \ln \delta^{-1}} \log_2 \Gamma$.
One can verify that
\begin{equation} \label{eq:Q-worst-case}
Q = \frac{\log_2 n + \mathcal{O}(\sqrt{\log n \log \delta^{-1}}) + \mathcal{O}(\log \delta^{-1})}{I(p)}.
\end{equation}
The solution is through Lemma~\ref{quadratic} and by bounding $I(p) = \Theta(\varepsilon^2)$ and $\log_2 \Gamma = \Theta(\varepsilon)$.
Such $Q$ provides a sufficient strategy length in the adversarial scenario --- see Algorithm~\ref{alg:graph-adversarial}.
\begin{algoBox}{0.95}
\begin{algo} \label{alg:graph-adversarial} \textup{(Adversarial graph search.)}
\medskip
Initialization: $\omega_0(v)=\frac{1}{n}$ for each $v\in V$.\\
In each step: query the median and perform the Bayesian updates (Algorithm~\ref{alg:bayesian}).\\
Stop condition: perform exactly $Q$ queries with $Q$ as in \eqref{eq:Q-worst-case} and return the heaviest vertex.
\end{algo}
\end{algoBox}
\begin{lemma} \label{lem:graph:adv:target-bound}
If $v^{*}$ is the target, then after $\tau$ queries, with probability at least $1-\delta$ it holds
$$w_{\tau}(v^{*}) \ge \frac{1}{n} \Gamma^{- \sqrt{\frac{\tau}{2} \ln \delta^{-1}}} 2^{-H(p) \tau}.$$
\end{lemma}
\begin{proof}
After $\tau$ queries with at most $\ell$ erroneous replies, the weight of the target satisfies:
$$w_{\tau}(v^{*}) \ge \frac{1}{n} p^{\ell} (1-p)^{\tau-\ell} = \frac{1}{n} \Gamma^{p\tau - \ell} 2^{-H(p) \tau}.$$
Denote $a = \sqrt{\frac{\tau}{2}\ln \delta^{-1}}$.
Then by Hoeffding bound, with probability at least $1-\delta$ there is $p\tau - \ell \ge -a$.
Thus, after $\tau$ queries, the weight of the target satisfies, with probability $1-\delta$
$$w_{\tau}(v^{*}) \ge \frac1n \Gamma^{-a} 2^{-H(p)\tau},$$
from which the claim follows.
\end{proof}
The following implies Theorem~\ref{thm:graph:worst-case}.
\begin{corollary} \label{cor:graph:worst-case}
Algorithm~\ref{alg:graph-adversarial} returns the target correctly with probability $1-\delta$.
\end{corollary}
\begin{proof}
By Lemma~\ref{lem:graph:adv:target-bound} and the definition of $Q$ in~\eqref{eq:Q-worst-case}, the following holds with probability $1-\delta$:
$$\log_2 w_Q(v^{*}) \ge -\log_2 n - \sqrt{ \frac{Q}{2}\ln \delta^{-1}} \log_2 \Gamma - H(p)Q \ge -Q \ge \log_2 w_Q(V \setminus \{x_Q\}),$$
where the last inequality is due to Lemma~\ref{lem:xT}.
Since the weights of the vertices are non-negative at all times, the only way for this to happen is to have $v^{*} = x_Q$, that is the target being found correctly.
\end{proof}
\subsection*{Proof of Theorem~\ref{thm:graph:lv-distr} (Las Vegas distributional search)}
In this scenario the initial weights are set to be the given target distribution $\mu$, and the stopping condition requires that some vertex accumulates large enough weight --- see Algorithm~\ref{alg:graph-las-vegas-distributional}.
\begin{algoBox}{0.85}
\begin{algo} \label{alg:graph-las-vegas-distributional} \textup{(Las Vegas distributional graph search.)}
\medskip
Initialization: $\omega_0(v)=\mu(v)$ for each $v\in V$.\\
In each step: query the median and perform the Bayesian updates.\\
Stop condition: if for any $v$ in some step $t$ it holds $\frac{\omega_t(v)}{\omega_t(V)} \ge 1-\delta$, then return $v$.
\end{algo}
\end{algoBox}
\begin{lemma} \label{lem:graph-lv-distr}
For any $\delta < 1/2$, Algorithm~\ref{alg:graph-las-vegas-distributional} stops and outputs the target after the expected number of $\frac{1}{I(p)} (\log_2 \frac{1}{\mu(v^{*})} + \log_2 \frac{1}{\delta} + 1)$ steps.
\end{lemma}
\begin{proof}
We measure the progress at any given moment by a random variable $\zeta_t = t+\log_2 w_t(v^{*})$.
Observe that if the reply is erroneous in a step $t+1$, then $\zeta_{t+1} = \zeta_t + 1 + \log_2 p$, and if it is correct, then $\zeta_{t+1} = \zeta_t + 1 + \log_2 (1-p)$.
For the sake of bounding the number of steps of the algorithm, we assume it is simulated indefinitely.
Let $Q$ be the smallest integer such that $\zeta_Q \ge \log_2 \frac{1-\delta}{\delta}$.
By Lemma \ref{lem:xT} we have that $\zeta_Q = \log_2 \frac{w_Q(v^{*})}{2^{-Q}} \le \log_2 \frac{w_Q(v^{*})}{w(V \setminus \{x_Q\})}$, thus $\frac{w_Q(v^{*})}{w(V \setminus \{x_Q\})} \ge \frac{1-\delta}{\delta} > 1$ since $\delta < 1/2$.
But if for any $t$ there is $\frac{w_t(v^{*})}{w_t(V \setminus \{x_t\})} > 1$, then $x_t = v^{*}$, since $w_t(v^{*}) > w_t(V \setminus \{x_t\})$ implies $v^{*} \not\in V \setminus \{x_t\}$.
Thus we deduce that $x_Q = v^{*}$.
Additionally, from $\frac{w_Q(v^{*})}{w(V \setminus \{v^{*}\})} \ge \frac{1-\delta}{\delta}$ we get that $v^{*}$ is $(1-\delta)$-heavy, hence $Q$ bounds the strategy length.
From $\zeta_{t+1} \in \{\zeta_t + 1 + \log_2 p, \zeta_t + 1 + \log_2 (1-p)\}$ and the minimality of $Q$ we deduce $\zeta_Q \le \log_2 \frac{1-\delta}{\delta} + 1 + \log_2(1-p) \le \log_2 \frac1{\delta} + 1$.
In particular
\begin{equation} \label{eq:zetaQ}
\mathbb{E}[\zeta_Q] \leq \log_2 \frac1{\delta} + 1.
\end{equation}
Let $X_t = \zeta_t - \zeta_{t-1}$ and observe that $\mathbb{E}[X_t] = p(1 + \log_2 p) + (1-p)(1 +\log_2 (1-p)) = I(p)$.
Note that trivially $Q \leq \lceil \frac{\log_2 \frac{1-\delta}{\delta} - \log_2 \mu(v^{*})}{1 + \log_2 p} \rceil$, hence in particular $\mathbb{E}[Q] < \infty$.
Also, $X_i$'s are independent and $Q$ is a stopping time.
Therefore, by using Wald's identity (Theorem \ref{wald}) we get
$$\mathbb{E}[\zeta_Q] - \zeta_0 = \mathbb{E}[\zeta_Q - \zeta_0] = \mathbb{E}[X_1 + \cdots + X_Q] = \mathbb{E}[Q]I(p).$$
Thus, by~\eqref{eq:zetaQ} and $\zeta_0 = \log_2 \mu(v^{*})$, we have
$$1 + \log_2 \frac1{\delta} \ge \mathbb{E}[\zeta_Q] = \zeta_0 + \mathbb{E}[Q] I(p),$$ which results in a bound
$$\mathbb{E}[Q] \le \frac{\log_2 1/\mu(v^{*}) + \log_21/\delta + 1}{I(p)}.\qedhere$$
\end{proof}
Lemma~\ref{lem:graph-lv-distr} implies Theorem~\ref{thm:graph:lv-distr} by taking expectation over all possible target locations according to the input distribution $\mu$.
\subsection*{Proof of Theorem \ref{thm:graph:lv-adversarial} (Las Vegas adversarial search)}
The adversarial setting is resolved by taking the uniform initial target distribution and scaling down the threshold as shown in Algorithm~\ref{alg:graph-las-vegas-adversarial}.
\begin{algoBox}{0.9}
\begin{algo} \label{alg:graph-las-vegas-adversarial} \textup{(Las Vegas adversarial graph search.)}
\medskip
Run algorithm \ref{alg:graph-las-vegas-distributional} with $\mu(v) = \frac{1}{n}$ for all $v$ and confidence threshold $\delta' = \Theta(\frac{\delta^2 }{(\log n+\log 1/\delta)^2}).$
\end{algo}
\end{algoBox}
\begin{lemma} \label{lem:graph:lv-adversarial}
Algorithm~\ref{alg:graph-las-vegas-adversarial} finds the target correctly with probability at least $1-\delta$ after expected number of $\frac{1}{I(p)}(\log_2 n + \mathcal{O}(\log \log n) + \mathcal{O}(\log 1/\delta))$ queries.
\end{lemma}
\begin{proof}
The time bound applies from Theorem~\ref{thm:graph:lv-distr}.
We argue about the correctness.
Denote by $A \le \frac{\log \frac{1-\delta'}{\delta'}}{\log \frac{1-p}{p}}+1$ the number of yes-answers required to go from a vertex being $1/2$-heavy to being $(1-\delta')$-heavy. For now assume that $A \ge 2$, we will deal with the other case later.
For a non-target vertex $u$ to be declared by the algorithm as the target, it has to observe a suffix of the strategy being a random walk on a 1-dimensional discrete grid $[0, \ldots, A]$ and transition probabilities $p$ for $i \to i+1$ and $1-p$ for $i \to i-1$.
We consider a random walk starting at position $A/2$ and ending when reaching either $0$ or $A$ and call it a \emph{subphase} (w.l.o.g. we can assume that $A$ is even).
Any execution of the algorithm can be partitioned into maximal in terms of containment, disjoint subphases.
Each subphase starts when one particular heavy vertex $v$ receives $A/2$ more yes-answers than no-answers within the interval in which $v$ is heavy.
Then, a subphase ends when either the algorithm declares $v$ to be the target or $v$ stops being heavy.
By the standard analysis of the gamblers ruin problem, each subphase (where the heavy vertex is not the target) has failure probability $\delta''= \frac{1}{1+\left(\frac{1-p}{p}\right)^{A/2}} \le \frac{1}{1+\sqrt{\frac{1-\delta'}{\delta'}}} = O(\sqrt{\delta'})$.
Let us denote by a random variable $D$ the number of subphases in the execution of the algorithm. Let $F_i$ be the length of $i$-th subphase.
By the standard analysis of the gamblers ruin problem,
$$\mathbb{E}[F_i] = \frac{A/2}{1-2p} - \frac{A}{1-2p}\frac{1}{1 + (\frac{1-p}{p})^{A/2}} \ge \frac{A/2}{1-2p}\left(1 - \frac{2}{1 + \sqrt{\frac{1-\delta'}{\delta'}}}\right) = \Omega\left(\frac{1}{\varepsilon^2}\right),$$
where the asymptotic holds since w.l.o.g. $\delta' < 1/3$, and also since if $\varepsilon < 1/3$, then $A = \Omega(1/\varepsilon)$, and otherwise $A \ge 2 = \Omega(1/\varepsilon)$.
Let $F = F_1 + \cdots + F_D$ be the total length of all subphases.
Observe that $D$ is a stopping time, hence we have $\mathbb{E}[F] = \mathbb{E}[D] \cdot \Omega(\frac{1}{\varepsilon^2})$ by Theorem \ref{wald}.
By Theorem~\ref{thm:graph:lv-distr}, $\mathbb{E}[Q]=\mathcal{O}(\varepsilon^{-2}(\log n+\log\delta'^{-1}))$ holds for the strategy length $Q$.
Since $F \le Q$, $\mathbb{E}[D] = \mathcal{O}(\log n+\log 1/\delta') = \mathcal{O}(\log n + \log 1/\delta)$.
By application of the union bound, the error probability for the whole procedure is bounded by $\delta'' \mathbb{E}[D] \le \delta$ for appropriately chosen constant in the definition of $\delta'$.
We now deal with case of $A\le1$. This requires $p < \delta'$, and $\varepsilon > 1/3$ (since if $\varepsilon<1/3$, appropriate choice of constant in $\delta'$ enforces $A\ge2$) and so the expected strategy length is $\mathbb{E}[Q] = O(\log n + \log 1/\delta)$. By the union bound, algorithm receives a single erroneous response with probability at most $p \mathbb{E}[Q] \le \delta' \mathbb{E}[Q] = O(\delta^2/(\log n + \log 1/\delta)) = O(\delta)$.
\end{proof}
\section{Binary search} \label{sec:binary-search}
The strategies for binary search setting will be partitioned into epochs.
By an \emph{epoch} we mean a sequence of queries to the same element.
The lengths of the epochs are fixed in advance and oblivious to responses of the adversary.
However, we allow for different epochs to be of different lengths - the length of $i$-th epoch is denoted by $E_i$ (thus the $i$-th epoch starts at step $\sum_{j<i}E_i+1$ and ends at step $\sum_{j\leq i}E_i$).
After each query we perform Bayesian updates using Algorithm~\ref{alg:bayesian}.
The element to be queried is selected as follows:
at the start of the execution of the algorithm, all elements are \emph{unmarked}, and in the process of execution we gradually mark some elements.
Denote the set of \emph{marked} elements in step $i$ by $M_i$ (we write $M$ when the current step is clear from the context).
At the start of an epoch, we find an element $q \not\in M$, which we call \emph{central}, such that
$\omega(\{i<q\}\setminus M)\leq\frac{1}{2}\omega(V\setminus M)$ and $\omega(\{i>q\}\setminus M)\leq\frac{1}{2}\omega(V\setminus M)$.
This element is the one repeatedly queried in the epoch.
We fix the length of $i$-th epoch, for each $i\geq 1$, to be
\begin{equation} \label{eq:epoch-lengths}
E_i = \max(\frac{1}{16}\varepsilon^{-2} i^{-\frac23}, 1).
\end{equation}
Algorithm~\ref{alg:epochs} shows how the general framework of using epochs in our strategies.
\begin{algoBox}{0.9}
\begin{algo} \label{alg:epochs} \textup{(Epochs in binary search.)}
\medskip
Initialization: $M\leftarrow\emptyset$, set the initial weights.\\
Run epoch $i$: query the central element $q$ for $E_i$ steps, performing the Bayesian updates.\\
End epoch $i$: mark $q$ by adding it to $M$, $M\leftarrow M\cup\{q\}$, and proceed to the next epoch.
\end{algo}
\end{algoBox}
In order to turn Algorithm~\ref{alg:epochs} into a particular strategy, we will provide weight initialization and a stopping condition.
We note that the stopping condition will not affect the starting points of the epochs but it may simply end the strategy during some epoch.
As a result of the execution of the Algorithm~\ref{alg:epochs} we get set $M$ of all the elements that we have queried.
For each particular strategy we will ensure that the number of queries is large enough such that $v^{*} \in M$.
On the other hand we will always be able to bound the size of $M$ efficiently.
That way, we will be able to treat $M$ as a set of "potential targets" and the target selection will be done by performing another binary search within the set $M$.
For that we will use the algorithm of Feige et. al. \cite{FeigeRPU94} of query complexity $\mathcal{O}(\frac{1}{I(p)}(\log n + \log\delta^{-1}))$.
\medskip
We start the analysis of the running time by determining the expected weight drop during the search.
To that end we scrutinize the behavior of the random variable $w_{\tau}(V \setminus M_{\tau})$ (weight of the unmarked vertices) by analyzing a \emph{coupled process} which we denote $W_t$.
It is defined as follows: for an epoch of length $k$ that starts in step $\tau$ and in which $x$ $<$-answers{} and $y$ $>$-answers{} occurred, with $x+y=k$, we denote
$W_{\tau+k}^- = W_{\tau} (1-p)^xp^y/2$, $W_{\tau+k}^+ = W_{\tau} (1-p)^yp^x/2$
and
$W_{\tau+k} = W_{\tau+k}^- + W_{\tau+k}^+.$
Since $w_{\tau+k}(V \setminus M_{\tau+k}) \le w_{\tau}(V \setminus M_{\tau}) \frac{(1-p)^xp^y + (1-p)^yp^x}{2}$ and $W_{\tau+k} = W_{\tau} \frac{(1-p)^xp^y + (1-p)^yp^x}{2}$, we obtain the following property
\begin{equation}\label{eq:excluded-binsearch-bound}
w_{\tau}(V \setminus M_{\tau}) \le W_{\tau}.
\end{equation}
\begin{lemma} \label{lem:epoch-progress}
Let $\tau$ be the start of an epoch of length $k$. Assume $k=\mathcal{O}(\varepsilon^{-2})$.
Then
\begin{equation}\mathbb{E}[W_{\tau+k}] \le \frac{1}{2^k}(1+\mathcal{O}(\varepsilon^4k^2))W_{\tau}.\end{equation}
\end{lemma}
\begin{proof}
We can assume without loss of generality that $v^{*} < q$. We denote the number of $<$-answers{} by $x$ and $>$-answers{} by $y$.
We have then
$$\mathbb{E}[W_{\tau+k}^-] = \frac{W_{\tau}}{2}\left(2(1-p) p\right)^k = \frac{W_{\tau}}{2} 2^{-k} \left(1 - 4\varepsilon^2\right)^k,$$
$$\mathbb{E}[W_{\tau+k}^+] = \frac{W_{\tau}}{2}\left((1-p)^2 + p^2 \right)^k = \frac{W_{\tau}}{2} 2^{-k} \left(1 + 4\varepsilon^2\right)^k,$$
and
$$\mathbb{E}[W_{\tau+k}] = \frac{W_{\tau}}{2} 2^{-k} \left( \left(1 - 4\varepsilon^2\right)^k+ \left(1 + 4\varepsilon^2\right)^k \right)=2^{-k}(1+\mathcal{O}(\varepsilon^4k^2)) W_{\tau}.\qedhere$$
\end{proof}
The total length of the first $f$ epochs is then $E_1+\cdots+E_f = \Theta(\max(f^{\frac13}\varepsilon^{-2}, f))$.
So in $Q$ queries there are $f= \mathcal{O}(\min(1+\varepsilon^6Q^3,Q))$ epochs.
We now bound the expected change of $W$ in $Q$ queries, applying Lemma~\ref{lem:epoch-progress} to each epoch:
\begin{equation}
\mathbb{E}[W_Q] = \prod_{i=1}^f 2^{-E_i} (1+\mathcal{O}(\varepsilon^4 E_i^2)) \le 2^{-Q} \prod_{i=1}^{\infty} (1+\mathcal{O}(i^{-4/3})) \le C 2^{-Q} \label{eq:C}
\end{equation}
for large enough $C$. By application of Markov's inequality, we reach a following corollary.
\begin{corollary} \label{lem:C-bound}
With probability at least $1-\delta$ it holds $W_Q \le w_0(V) \cdot \frac{C}{\delta} 2^{-Q}$ for any $\delta>0$.
\end{corollary}
\subsection*{Theorem~\ref{thm:bin:worst-case}: Worst-case strategy length} \label{sec:bin-search:worst-case}
The strategy has a priori determined length $Q$ of the part comprised of epochs leaving the candidate set of potential targets $M_Q$:
\begin{equation} \label{eq:bin-adv}
Q = \frac{1}{I(p)} \left( \log_2 n + \mathcal{O}(\log \delta^{-1}) + \mathcal{O}(\sqrt{\log \delta^{-1} \log n}) \right).
\end{equation}
Recall that the epochs' lengths are set in \eqref{eq:epoch-lengths}.
We argue (cf. Lemma~\ref{lem:bin-adv}) that after $Q$ steps the target is in $M_Q$ with sufficient probability.
Since the $Q$ is chosen so that the size of $M_Q$ is polylogarithmic in $n$ and $\delta^{-1}$, any search algorithm of complexity $\mathcal{O}(\varepsilon^{-2}(\log n+\log\delta^{-1}))$ is sufficient to finish the search; we use the one in \cite{FeigeRPU94}.
See Algorithm~\ref{alg:binary-adversarial} for a formal statement.
\begin{algoBox}{0.87}
\begin{algo} \label{alg:binary-adversarial} \textup{(Adversarial binary search.)}
\medskip
Initialization: $w_0(v) \leftarrow \frac1n$ for each element $v$.\\
Execute Algorithm~\ref{alg:epochs} for exactly $Q$ steps with $Q$ as in~\eqref{eq:bin-adv}.\\
Run the algorithm from \cite{FeigeRPU94} with confidence threshold $\delta/3$ to find the target in $M_Q$.
\end{algo}
\end{algoBox}
\begin{lemma} \label{lem:bin-adv}
For any $\delta>0$, Algorithm~\ref{alg:binary-adversarial} finds the target correctly with probability at least $1-\delta$ in $\frac{1}{I(p)} \left( \log_2 n + \mathcal{O}(\log\delta^{-1}) + \mathcal{O}(\sqrt{\log n \log\delta^{-1}}) \right)$ steps.
\end{lemma}
\begin{proof}
By Corollary~\ref{lem:C-bound}, with probability $1-\delta/3$ we have
$$w_Q(V \setminus M_Q) \le W_Q \le\frac{3 C}{\delta} 2^{-Q}.$$
We set $Q$ so that
\begin{equation}\label{eq2}
\frac1n \Gamma^{-\sqrt{\frac{Q}{2} \ln 3/\delta}}2^{-H(p)Q} > \frac{3 C}{\delta} 2^{-Q}.
\end{equation}
By using similar arguments as in Lemma~\ref{lem:graph:adv:target-bound}, with probability at least $1-2\delta/3$ it holds $w_Q(v^{*}) > w_Q(V \setminus M_Q)$.
This is possible only if $v^{*} \in M_Q$.
Since $|M_Q| = \mathcal{O}(\log^3 n + \log^3 1/\delta)$, the algorithm of Feige et. al. \cite{FeigeRPU94} finds the target correctly in $\mathcal{O}(\frac{1}{I(p)}(\log |M_Q| + \log 1/\delta)) = \mathcal{O}(\frac{1}{I(p)} (\log \log n + \log 1/\delta))$ steps with probability $1-\delta/3$.
The confidence threshold follows then from the union bound.
To finalize the proof, we observe that \eqref{eq2} requires
$$I(p) Q > \sqrt{\frac{Q}{2} \ln 3/\delta} \log_2 \Gamma + \log_2 \left(\frac{3 C}{\delta}\right).$$
This can be solved to obtain $Q$ as in~\eqref{eq:bin-adv} through Lemma~\ref{quadratic} and by bounding $I(p) = \Theta(\varepsilon^2)$ and $\log_2 \Gamma = \Theta(\varepsilon)$.
\end{proof}
\subsection{Theorem~\ref{thm:bin:las-vegas:distr}: Las Vegas distributional search} \label{sec:bin-search:las-vegas}
The lengths of the epochs remain the same, that is as in \eqref{eq:epoch-lengths}.
The stop condition (for the execution of Algorithm~\ref{alg:epochs}) mimics the one for the graph case but takes the entire set of marked elements into account --- see Algorithm~\ref{alg:las-vegas-distributional}.
\begin{algoBox}{0.87}
\begin{algo} \label{alg:las-vegas-distributional} \textup{(Las Vegas distributional binary search.)}
\medskip
Initialization: $\omega_0(v)\leftarrow\mu(v)$ for each $v\in V$.\\
Execute Algorithm~\ref{alg:epochs} until in some step $t$ it holds $\frac{\omega_t(M_t)}{\omega_t(V)} \ge 1-\delta/2$.\\
Run the algorithm from \cite{FeigeRPU94} with confidence threshold $\delta/2$ to find the target in $M_Q$.
\end{algo}
\end{algoBox}
The correctness of Algorithm~\ref{alg:las-vegas-distributional} follows from the fact that at the time of finishing Algorithm~\ref{alg:epochs} at a step $t$, we have $\Pr[v^{*} \in M_t] = \frac{w(M_t)}{w(V)} \ge 1-\delta/2$.
Then the following search in the set $M_t$ incurs the additional error of at most $\delta/2$.
Theorem~\ref{thm:bin:las-vegas:distr} hence follows from the lemma below and taking expectation over possible target locations.
\begin{lemma}
Algorithm~\ref{alg:las-vegas-distributional} terminates after the expected number of $\frac{1}{I(p)} (\log_2 \frac{1}{\mu(v^{*})}+\mathcal{O}(\log \frac{1}{\delta}) + \mathcal{O}(\log \log \frac{1}{\mu(v^{*})}) )$ steps.
\end{lemma}
\begin{proof}
We measure the progress at any given step by a random variable $\zeta_t = \log_2 \frac{w_t(v^{*})}{W_t}$.
If the answer in step $t+1$ is erroneous, then $\zeta_{t+1} = \zeta_t + 1 + \log_2 p$ and otherwise $\zeta_{t+1} = \zeta_t + 1 + \log_2(1-p)$.
For the sake of bounding the number of steps of the algorithm, we consider the first part of the algorithm running indefinitely.
Let $Q$ be the smallest integer such that $\zeta_Q \ge \log_2 \frac{1 - \delta/2}{\delta/2}$.
We have $\frac{w_{t+1}(v^{*})}{w_t(v^{*})} \le 1-p$ due to Bayesian updates.
Additionally, if $p\ge 1/4$ then $\frac{W_{t+1}}{W_t} \ge p \ge 1/4$, and if $p<1/4$ then each epoch is of length $1$, so $\frac{W_{t+1}}{W_t} = 1/2$.
Hence, $$\zeta_{t+1} - \zeta_t = \log_2 \frac{w_{t+1}(v^{*})/w_t(v^{*})}{W_{t+1}/W_t} \le \log_2 4(1-p) \le 2.$$
Specifically, $\zeta_Q \le \zeta_{Q-1}+2 \le \log_2\frac{1 - \delta/2}{\delta/2}+2 \le \log_2\frac{1}{\delta} +3$.
Denote $\eta_{i+1} = \log_2 w_{i+1}(v^{*}) - \log_2 w_i(v^{*})$. We have $\eta$'s to be identically distributed with $\mathbb{E}[\eta_i] = -H(p)$.
Thus,
\begin{equation} \label{eq:wQ}
\mathbb{E}[\log_2 w_Q(v^{*})] = \log_2 \mu(v^{*}) - \mathbb{E}[Q] H(p).
\end{equation}
Using \eqref{eq:C} we bound
\begin{equation} \label{eq:WQ}
\mathbb{E}[\log_2 W_Q] \le -\mathbb{E}[Q] + \log_2 \mathbb{E}[ 2^Q W_Q] \le -\mathbb{E}[Q] + \log_2 C.
\end{equation}
We have by \eqref{eq:wQ} and \eqref{eq:WQ},
$$3+\log_2\frac{1}{\delta} \ge \mathbb{E}[\zeta_Q] = \mathbb{E}[\log_2 w_Q(v^{*})] - \mathbb{E}[\log_2 W_Q] \ge \log_2 \mu(v^{*}) - \mathbb{E}[Q]H(p) + \mathbb{E}[Q] - \log_2 C $$
and so
$$\mathbb{E}[Q] \le \frac{\log_2 1/\mu(v^{*})+\log_21/\delta + \mathcal{O}(1)}{I(p)}.$$
Since $|M_Q| = \mathcal{O}(\log^3 \frac{1}{\mu(v^{*})} + \log^3 \frac{1}{\delta})$, the algorithm of Feige et. al. \cite{FeigeRPU94} finds the target correctly in $\mathcal{O}(\frac{1}{I(p)}(\log |M_Q| + \log \frac{1}{\delta})) = \mathcal{O}(\frac{1}{I(p)} (\log \log \frac{1}{\mu(v^{*})} + \log \frac{1}{\delta}))$ steps with probability $1-\delta/2$.
\end{proof}
| {'timestamp': '2021-07-14T02:05:43', 'yymm': '2107', 'arxiv_id': '2107.05753', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05753'} | arxiv |
\section{\label{sec:introduction}Introduction}
Motivations for developing artificial spiking neural systems include efficient hardware implementations of brain-inspired algorithms and construction of large-scale systems for studying the mechanisms of cognition. While most efforts toward these ends employ semiconductor hardware based on silicon transistors \cite{lide2015,indiveri2011neuromorphic,merolla2014million,davies2018loihi,scpo2017}, superconducting electronics have also received considerable attention. Superconducting circuits based on Josephson junctions (JJs, \cite{vatu1998,ka1999}) have strengths that make them appealing for neural systems, including high speed, low energy consumption per operation, and native thresholding/spiking behaviors. In particular, two-junction superconducting quantum intereference devices (SQUIDs) are ubiquitous in superconducting electronics, and several efforts aim to utilize SQUIDs for various neuromorphic operations \cite{hago1991,hiak1991,mina1994,mina1995,rilo1997,crsc2010,onma2011,chca2013,yaum2013,sele2017,kafu2018,sh2018,scdo2018,scdo2018b,tose2019}.
As shown in Fig.\,\ref{fig:squid_response}(a), a SQUID has two inputs: a bias current (typically DC) that sets the operating point of the device and a flux input coil. The response of the SQUID to the flux input is peculiar in that it is periodic, as shown in Fig.\,\ref{fig:squid_response}(b). One way to use a SQUID as a neuromorphic component is to collect the inputs from many synapses or dendrites and apply them as flux to the SQUID loop. The response then has a threshold that depends on the applied bias current, $I_b$, and is maximal at an applied flux of $\Phi_0/2$, where $\Phi_0 = h/2e \approx 2$\,mV$\cdot$ps is the magnetic flux quantum. In this work, we consider the ramifications of limiting the maximum applied flux to this value of $\Phi_0/2$ so the response is monotonic with applied signal.
\begin{figure*}[t!]
\centering
\includegraphics[width=17.2cm]{_fig__squid_response.pdf}
\caption{(a) SQUID circuit with DC current bias ($I_b$ through each JJ) and flux input ($\Phi_{\mathrm{a}}$) through a transformer. (b) SQUID response function. $R_{fq}$ is the rate of flux-quantum production due to the voltage developed at the node indicated by a red dot in part (a) as a function of the applied flux to the SQUID loop in units of the magnetic flux quantum $\Phi_0 = h/2e$. Different curves correspond to different bias conditions.}
\label{fig:squid_response}
\end{figure*}
Fan-in has recently been analyzed in superconducting neuromorphic circuits wherein single-flux quanta are used as signals between neurons \cite{schneider2020fan}. However, that work was not concerned with the case in which analog synaptic signals integrated and stored over time could drive a SQUID beyond the first half period of its response function. In the present study, we analyze fan-in in the context of leaky-integrator neuronal circuits that were originally designed for use in large-scale superconducting optoelectronic systems \cite{shbu2017,sh2019,sh2020,sh2021}. However, the conclusions of this paper should be applicable to a wide variety of SQUID neurons.
In this work, we use the following component definitions. A \textit{synapse} is a circuit that receives a single input from another neuron and produces an electrical current circulating in a storage loop. A \textit{dendrite} is a circuit that receives an input proportional to the electrical output of one or more synapses and/or dendrites, performs a transfer function on the sum of the inputs, and produces an electrical current circulating in a storage loop as the output. A \textit{neuron cell body} (also known as a \textit{soma}) receives input proportional to the electrical output of one or more synapses and/or dendrites, performs a threshold operation on the sum of the inputs, and produces an output pulse if the threshold is exceeded. Outputs from the neuron cell body are routed to many downstream synapses. \textit{Fan-in} is the collection and localization of multiple synaptic or dendritic signals into a dendrite or neuron cell body.
\section{\label{sec:model}Model}
We begin by considering the simple SQUID circuit shown in Fig.\,\ref{fig:squid_response}(a). The weighted sum of synaptic signals is represented by the applied flux ($\Phi_\mathrm{a}$) to the SQUID loop. Upon reaching a threshold value of applied flux ($\Phi_\mathrm{a}^\mathrm{th}$), the SQUID produces a train of fluxons. Fig.\,\ref{fig:squid_response}(b) shows the relationship between the rate of fluxon production ($R_\mathrm{fq}$) and $\Phi_\mathrm{a}^\mathrm{th}$. $\Phi_\mathrm{a}^\mathrm{th}$ depends on $I_b$ and corresponds to the $x$-intercepts in the figure. The generated fluxon train can be used in multiple ways depending on the neuromorphic context. For instance, each fluxon produced could be interpreted as an entire action potential, for use in either rate or temporal coding schemes \cite{scdo2018b, sele2017}. Alternatively, the rate of fluxon production could be treated as an analog output that triggers another thresholding device (such as an optical transmitter) that drives action potentials downstream \cite{sh2019}. In any of these contexts, however, maintaining a monotonic response is desirable. We will first treat the point-neuron case (synapses are connected directly to the neuron cell body), discuss its limitations, and then investigate how an active dendritic arbor mitigates these concerns.
\subsection{\label{sec:point_neuron}Point neurons with a SQUID soma}
As seen in Fig.\,\ref{fig:squid_response}(b), restricting the applied flux to the range $0 \le \Phi_{\mathrm{a}} \le \Phi_0/2$ would enforce monotonicity. However, restricting the signal requires a large fraction of synapses to be active to reach threshold. The largest signal that can be applied to the SQUID occurs when all $n$ synapses are active and maximally weighted. Suppose a maximally weighted synapse applies $\Phi_\mathrm{sy}$ of flux to the SQUID. To ensure monotonicity, we set this maximum possible signal equal to $\Phi_0/2$:
\begin{equation}
n\Phi_\mathrm{sy} = \frac{\Phi_0}{2}.
\end{equation}
To reach threshold, a critical number $p$ of synaptic inputs must be active. For simplicity, we assume that each active input supplies $\Phi_\mathrm{sy}$ of flux. If the applied flux necessary to reach threshold is $\Phi_\mathrm{a}^\mathrm{th}$, then
\begin{equation}
\label{eq:delta_phi}
\Phi_\mathrm{a}^\mathrm{th} = p\,\Phi_\mathrm{sy} = \frac{p\,\Phi_0}{2n}.
\end{equation}
At threshold, the induced current is equal to the difference between $I_\mathrm{c}$ and $I_\mathrm{b}$, where $I_\mathrm{b}$ is the current through one of the JJs when no flux is applied to the loop. For a SQUID with total inductance $L_{\mathrm{tot}}^{\mathrm{sq}}$, this implies that $\Phi_\mathrm{a}^\mathrm{th} = L^{\mathrm{sq}}_{\mathrm{tot}}(I_\mathrm{c} - I_\mathrm{b})$. We can rewrite Eq.\,\ref{eq:delta_phi} in terms of the critical and bias currents and rearrange to find the minimum fraction of synapses that must be active to reach threshold:
\begin{equation}
\frac{p}{n} = \frac{2L^{\mathrm{sq}}_{\mathrm{tot}}(I_{\mathrm{c}}-I_{\mathrm{b}})}{\Phi_0}.
\end{equation}
$L^{\mathrm{sq}}_{\mathrm{tot}}$ is a function of flux in the SQUID through the variable inductance of JJs. For a typical SQUID near threshold, $L^{\mathrm{sq}}_{\mathrm{tot}} \approx \frac{\Phi_0}{I_{\mathrm{c}}}(\frac{3\pi + 2}{4\pi})$ (see Appendix \ref{apx:squid}), resulting in the expression
\begin{equation}
\label{eq:fraction_active}
\frac{p}{n} = \frac{3\pi + 2}{2\pi} \left( 1-\frac{I_b}{I_c} \right).
\end{equation}
Equation \ref{eq:fraction_active} gives the fraction of maximally weighted synapses that must be active to drive the SQUID to threshold. When one limits the total signal that can be applied to a SQUID to $\Phi_0/2$ to maintain a monotonic response, the threshold activity fraction is dependent only on the ratio $I_b/I_c$. Noise prohibits biasing with $I_b$ arbitrarily close to $I_c$. The effects of noise in superconducting neurons warrant further investigation, but $I_{\mathrm{b}}/I_{\mathrm{c}} = 0.7$ is typical of digital superconducting systems. This value corresponds to a minimum threshold activity of about 55\%. $I_\mathrm{b}/I_\mathrm{c} = 0.9$ would represent an aggressive operating point, and would require $p/n \approx 18\%$. Such an activity level is higher than that observed in biology, where 1\% - 16\% of neurons may be active at any time due to power considerations as well as implications of sparse coding \cite{laughlin2003communication}. As stated in Ref.\,\onlinecite{laughlin2003communication}, ``Sparse coding schemes, in which a small proportion of cells signal at any one time, use little energy for signaling but have high representational capacity, because there are many different ways in which a small number of signals can be distributed among a large number of neurons.'' We next consider how performing fan-in with an active dendritic tree comprised of SQUIDs alters the calculation.
\subsection{\label{sec:dendritic_tree}Fan-in with an active dendritic tree}
Biological neurons are not accurately modeled as point neurons. Instead, synaptic inputs are passed through an arbor of active dendrites that performs numerous computations \cite{mel1994information,loha2005,stsp2015}, including intermediate threshold functions between subsets of synapses and the soma \cite{sava2017} and detection of synaptic sequences \cite{haah2016}. Active dendrites can be significant for adaptation and plasticity \cite{majo2005,sjostrom2008dendritic}, can dramatically increase information storage capacity relative to point neurons \cite{poirazi2001impact}, and when modulated by inhibitory neurons, the dendritic tree can induce a given neuron to perform distinct computations at different times, enabling a given structural network to dynamically realize myriad functional networks \cite{bu2006}. Discussion of dendrites in superconducting neural hardware is found in Ref. \onlinecite{sh2020}.
A schematic of a dendritic tree is shown in Fig.\,\ref{fig:dendritic_tree}(a). The architecture consists of input synapses (shown in blue), multiple levels of dendritic hierarchy (yellow), and the final cell body (green). These components have been defined in Sec.\,\ref{sec:introduction}, and all three can be implemented with SQUID circuits, a self-similarity that facilitates scalable design and fabrication. A specific circuit implementation is given in Sec.\,\ref{sec:Loops}.
\begin{figure}[htb]
\centering
\includegraphics[width=8.6cm]{_fig__dendritic_tree.pdf}
\caption{Dendritic tree. (a) Schematic illustration of the tree structure with blue synapses input to yellow dendrites. The neuronal cell body is shown in green with fan-out to downstream synapses. The fan-in factor ($n$) is labeled, as is the hierarchy level ($h$), total depth of hierarchy ($H$), and the total number of synapses ($N$). (b) The fan-in factor as a function of the total number of synapses in a neuron for several values of the depth of the hierarchy. $N$, $n$, and $H$ must be integers if a homogeneous tree is used.}
\label{fig:dendritic_tree}
\end{figure}
We restrict attention to a homogeneous dendritic tree of the form shown in Fig.\,\ref{fig:dendritic_tree}(a), wherein all dendrites receive the same number of inputs, $n$, which we refer to as the \textit{fan-in factor}. The neuron cell body resides at level zero of the dendritic hierarchy, and synapses reside at level $H$, so the total number of synapses is $n^H \equiv N$. In Fig.\,\ref{fig:dendritic_tree}(a) we show a tree with fan-in factor $n = 2$ and three levels of hierarchy for a total of $N = 8$ synapses. For a homogeneous dendritic tree, the relationship between number of synapses, fan-in factor, and hierarchy is plotted in Fig.\,\ref{fig:dendritic_tree}(b). Biological neurons are less uniform and more complex, but homogeneous trees should be a good starting point for artificial systems.
Equation \ref{eq:fraction_active} is applicable to any dendrite or neuron cell body in the dendritic tree, provided the maximum applied flux is limited to $\Phi_0/2$. Working backward from the cell body, one can calculate that the minimum number of active synapses required to drive the neuron cell body to threshold is $P = p^H$, and the fraction of synaptic activity for threshold is at least
\begin{equation}
\label{eq:fraction_active__hierarchy}
\frac{P}{N} = \left( \frac{p}{n} \right)^H = \left[ \frac{3\pi + 2}{2\pi} \left( 1-\frac{I_b}{I_c} \right) \right]^H.
\end{equation}
Equation \ref{eq:fraction_active} is recovered as the special case of $H = 1$. The exponential dependence of threshold activity fraction on $H$ implies that dendritic trees can improve fan-in even with limited depth of the tree. This is illustrated in Fig.\,\ref{fig:results}, where the activity fraction as a function of bias is plotted for dendritic trees of varying depth. We see that the point neuron case ($H=1$) requires the highest activity fraction, but that the situation improves quickly with depth of dendritic tree. For instance, with $H=5$ and a conventional biasing of $0.7\,I_\mathrm{c}$, only 5\% of synapses need be active --- an order-of-magnitude improvement over the case of the point neuron. If $I_b/I_c$ can be pushed to $0.9$, a tree depth of only $H = 3$ is required to achieve sub-1\% threshold activity fraction. For biologically realistic fan-in of $10^4$ synapses, this dendritic tree would require dendrite fan-in of $n \approx 22$ and about 485 intermediate dendrites. Considering that every synapse requires a SQUID \cite{sh2020,khan2021modeling}, the additional hardware fraction for the dendritic tree is minor and area estimates of such hardware is found in appendix B of Ref.\,\cite{prsh2021}. These biological values are abjectly impossible for point neurons whose applied flux is limited to the range of monotonic response, providing a physical motivation for the use of dendritic trees in superconducting neurons.
\begin{figure}[tb]
\centering
\includegraphics[width=8.6cm]{_fig__fraction.pdf}
\caption{The fraction of synapses required to be saturated to drive a neuron to threshold as a function of the normalized bias to dendrites and the cell body. This result depends on enforcing the condition that input flux is limited to $\Phi_0/2$ and that all $I_c$ values are identical, but the result is independent of $I_c$ and the total number of synapses in the neuron, $N$.}
\label{fig:results}
\end{figure}
In addition to the benefits of the sparse coding model, the lower activity fraction associated with an active dendritic tree also benefits the dynamic range of possible thresholds. Many homeostatic mechanisms involve the tuning of the bias point in response to network activity. Ideally, this bias point could be tuned over a wide range. By allowing lower bias points for the same activity fraction, dendrtic trees allow the threshold of a neuron to be tuned over a wider range than that of a point neuron.
The energy consumption of the dendritic arbor itself also deserves consideration. For future superconducting systems, dynamic power should dominate static power consumption. The total fraction of all units (synapses, dendrites, and soma) that must be active to reach threshold is given by
\begin{equation}
\label{eq:fraction_active__dendrites}
\frac{P_\mathrm{tot}}{N_\mathrm{tot}} = \frac{\sum_{h = 0}^H p^h}{\sum_{h = 0}^H n^h}.
\end{equation}
The energy consumption of synapses and dendrites is unlikely to be the same for most technologies. In the optoelectronic case, for example, synaptic events are likely to cost significantly more power than an active dendrite. Additionally, it can be shown that the total number of active units is likely to be higher in the point neuron case for almost all reasonable bias conditions as the number of added dendrites is compensated for by the greatly reduced number of active synapses.
\section{Loop Neuron Circuits}
\label{sec:Loops}
\begin{figure}[b!]
\includegraphics[width=8.6cm]{_fig__circuit.pdf}
\caption{(a) Circuit under consideration. Input dendritic integration (DI) loops couple signal into the dendritic collection (DC) loop via transformers. The net induced signal in the DC loop couples into the dendritic receiving (DR) loop, which is a SQUID. This SQUID is embedded in its own DI loop, which performs leaky integration on the accumulated signal. (b) Schematic of physical layout of circuit with components playing the roles of the circuit elements in (a). Circuit elements and loops are labeled to be consistent with the text.}
\label{fig:circuit}
\end{figure}
Neuronal circuits based on superconducting loops have been proposed in prior work, particularly with regard to optoelectronic systems \cite{sh2019}. We show here an application of these fan-in considerations to the specific case of loop neurons. A circuit diagram is shown in Fig.\,\ref{fig:circuit}. The dendritic integration (DI) loop integrates signals from activity present at that dendrite (or synapse). The saturation current of the DI loop corresponds to the maximally weighted active synapse discussed in the previous section. A mutual inductor ($M^\mathrm{dc|di}$) couples this signal into a second loop, called the dendritic collection (DC) loop. This loop is not strictly necessary, but allows for a more standardized design procedure, as discussed below. The DC loop applies flux $\Phi_\mathrm{a}^\mathrm{dr}$ (the weighted contribution of afferent signals) through $M^\mathrm{dr|dc}$ to the dendritic receiving (DR) loop. The DR loop forms the active component of the dendrite that has been the subject of our discussion thus far. Its output, a train of fluxons, is then coupled into another DI loop, allowing the chain to continue indefinitely. A schematic layout is provided in Fig.\,\ref{fig:circuit}\,(b) to provide physical intuition about the circuit.
Still, the question remains: How do we limit the applied flux $\Phi_\mathrm{a}^\mathrm{dr}$ to enforce monotocity in practice? For this circuit, a careful choice of inductances is all that is required. The mathematical details are given in Appendices \ref{apx:squid} and \ref{apx:inductance_constraint}, but ultimately only a single constraint amongst all of the inductances is necessary (Eq.\,\ref{eq:inductance_constraint}). Additionally, the intermediate DC loop allows the monotonic condition to be met across a wide range of fan-in factors with only $L^{\mathrm{di2}}$ being a function $n$. This means that the SQUID and its input coil need not be redesigned for different choices of $n$. The consequences of the DC loop are further explored in Appendix\,\ref{apx:alternative_scenarios}.
\section{\label{sec:discussion}Discussion}
We have considered the implications of limiting the maximum flux input to all SQUIDs so the response is monotonically increasing. It is found that limiting the applied flux introduces a constraint on the activity fraction of synapses required to reach threshold, and the addition of a dendritic tree ameliorates the situation. This behavior is independent of most details of the circuit (such as whether or not a collection loop is used). The physical arguments presented here in favor of dendritic trees are derived from this decision to limit the applied flux to handle the ostensible ``worst-case'' scenario in which all synaptic inputs are fully saturated simultaneously. It is fair to question whether it is necessary to design our circuits around this extreme situation. The monotonicity issue could, for instance, be solved by immediately resetting all post-synaptic potentials to zero upon threshold. This is the standard behavior exhibited by most leaky integrate-and-fire models. However, implementing such a mechanism in superconducting hardware without compromising the speed and efficiency of superconducting neurons appears challenging. Additionally, we have argued elsewhere \cite{sh2020} that SQUID dendrites provide numerous opportunities for active, analog dendritic processing independent of the fan-in benefits described here. In that context, enforcement of monotonicity appears necessary. For these reasons, we contend that the best course of action is to allow synaptic signals to decay naturally without regard to thresholding events (which also preserves information) while limiting the applied flux in the manner described.
Still, one could argue we are over-preparing for the worst case scenario. Perhaps we could leave the maximum possible applied flux to each SQUID unrestricted, and instances wherein SQUIDs are driven past a half-period of their response function will be sufficiently rare that we can ignore them in design. For general cognitive activity, we are likely to seek networks balanced at a critical point \cite{stanley1999scaling,bata1987,bata1988} between excessive synchronization (order) and insufficient correlation (disorder). When cognitive circuits are poised close to this critical point, neuronal avalanches \cite{beggs2003neuronal} or cell assemblies \cite{plenz2007organizing,buzsaki2010neural} are observed to be characterized by a power-law \cite{be2007} or log-normal \cite{buzsaki2014log} distribution of sizes. A great deal of contemporary research \cite{tomen2019functional} indicates that operation near this critical point is advantageous for maximizing dynamic range \cite{kico2006,shya2009} and the number of accessible metastable states \cite{haldeman2005critical} while supporting long-range correlations in network activity \cite{kism2009}. With either power-law or log-normal distributions, network activity engaging many neurons is less probable than activity involving few neurons, but periods of activity involving large numbers of neurons are not so improbable as to be neglected and may be crucial episodes for information integration across the network. The probability of large events does not decay exponentially and must therefore be accommodated in hardware.
We reiterate that the primary assumption entering the derivation of Eq.\,\ref{eq:fraction_active} is that the maximum applied signal is limited to a certain value. We have considered the ramifications in the specific context of SQUID components, but similar considerations may apply to other hardware. We encourage the reader to consider whether similar arguments may affect their favorite neuromorphic thresholding elements. We also note that limiting the applied flux to $\Phi_0/2$ may not always be advisable. From the activation function of Fig.\,\ref{fig:squid_response}(b) it is evident a dendrite with two synapses performs XOR if each synapse couples $\Phi_0/2$ into the receiving SQUID. When both synapses are active, the device operates outside the monotonic response. We hope this article does not stifle the investigation of the full neural utility of engineered SQUID responses.
\section*{Acknowledgements}
We thank Dr. Ken Segall and Dr. Michael Schneider for helpful discussions.
| {'timestamp': '2021-07-14T02:06:42', 'yymm': '2107', 'arxiv_id': '2107.05777', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05777'} | arxiv |
\section{Introduction}
\subsection{Inflated Structures}
Inflated structures have been used for decades in habitats, antennas, wings, and more \cite{Veldman2005}. They are constructed of a skin material that holds load only when inflated. Large structures are commonly a series of smaller tubular components sewn together to create complex shapes \cite{Veldman2005}. A beam bending model utilized in this paper was developed by Comer \textit{et al}. for the design of inflatable re-entry vehicles \cite{Comer1963,Fichter1905,Leonard1960}.
When under load, inflated beams exhibit some unique behaviors compared to standard beams. Wrinkles form near the root of the beam, and as the body material wrinkles, it no longer carries tension \cite{Leonard1960,Veldman2005,Comer1963}. This is shown in Fig. \ref{cantilever_beam} as the slack region. As the load increases, the slack region propagates around the beam, and $\theta_0$ increases. As $\theta_0$ approaches $\pi$, the beam will buckle and collapse, behaving like a hinge \cite{Veldman2005,Leonard1960}.
\subsection{Everted Tubes}
Everted tubes are a subclass of soft robots that grow via tip extension. The robot body is stored within a pressure vessel, usually on a reel, and is deployed as the system is pressurized \cite{Hawkes2017,Blumenschein2020}. Pressure forces at the tip pull the body material outwards, allowing the robot body to grow to arbitrary lengths. Growth via eversion passively extends the body in the direction of least resistance, allowing it to grow in cluttered and sensitive environments. Everted tubes have been used for exploration, antenna construction, and in medical applications \cite{Hawkes2017,Saxena2020,Slade2017}.
Everted tubes can be constructed from a variety of materials, including thermoplastics (TPU, LDPE), Thermosets, Thermo-coated fabrics, Thermoset-coated fabrics, and uncoated fabrics \cite{Blumenschein2020}. Thermoplastics are the easiest to prototype, as they often can be purchased in manufactured tube shapes of multiple sizes and thicknesses. However, they have the lowest burst pressures and have been shown to fatigue quickly \cite{Blumenschein2020}. Fabricating tubes from thermoset-coated fabrics requires a more involved manufacturing process; they must be sewn and sealed using adhesive. The structure of woven fabric prevents holes from rapidly propagating through the body, preventing bursting, making it ideal for navigating abrasive and rough environments \cite{Blumenschein2020}.
\begin{figure}
\centerline{\includegraphics[width=1\columnwidth]{combined_cantilever.png}}
\caption{ \textit{Top:} An everted cantilever beam with length, L; internal pressure, p; and external load, Q. Note the coordinate frame is centered at the tip of the beam. \textit{Bottom:} An everted silicone coated nylon beam carrying a cantilevered tip load. } \label{cantilever_beam}
\end{figure}
\subsection{Everted Tube Kinematics and Modeling}
Everted tubes have been modeled as inflated beams in many applications. Many studies have utilized the transverse and axial buckling equations derived in \cite{Comer1963,Fichter1905} to model their behavior. They have also been used to compute smooth retraction forces \cite{Coad2020retraction} and describe kinetic wall interactions \cite{Haggerty2019}, and they have been validated in \cite{Luong2019,Hawkes2017,Greer2017}.
Many novel kinematic capabilities of vine robots have been recently developed, including active steering, smooth retraction, tip-mounted graspers, and dynamically reconfigurable joints \cite{Blumenschein2020,Coad2020,Hawkes2017,Exarchos2021,Do2020,Greer2017}. These works use external devices along a robot's body to increases its operating workspace and capabilities. However, these rigid additions limit the robot's ability to squeeze through tight spaces since they cannot be crushed and re-inflated, thus hampering some of the benefits of the soft nature of everted tubes.
Greer \textit{et al}. provide a differential kinematic model of the free growth of everted tubes. This algorithm accurately describes glancing and head-on growth around obstacles \cite{Greer2018}. These kinematics have been extended by Haggerty \textit{et al.}, who describe the kinetic interactions between an everted tube and wall. The reaction force will cause transverse buckling if the incident tube angle is greater than a theoretical minimum \cite{Haggerty2019}. After a tube buckles from this transverse loading, it can freely grow along the wall while behaving like a hinge \cite{Leonard1960,Haggerty2019}. In an environment with many obstacles, sections of tube between contact points behave as independent beams \cite{Luong2019}. Everted tubes have also been modeled as Cosserat Rods: Selvaggio \textit{et al}. uses this model to determine the reachable workspace of an everted tube actuated by series Pneumatic Artificial Muscles (sPAM) \cite{Selvaggio2020}. This algorithm utilizes obstacles within the environment to increase the reachability of goal poses. Selvaggio \textit{et al}. also used the closed-form solution of an externally loaded cantilever Cosserat rod to predict applied environmental forces on such obstacles \cite{Selvaggio2020}.
In this work, we demonstrate a method for solving the beam model introduced by Comer \textit{et al}. We use this solution to compare the performance of straight and everted cantilever beams under three different variable loading conditions and validate that everted tubes can be modeled as inflated beams. Current everted tube research uses the maximum axial and transverse loading conditions outlined by \cite{Comer1963,Fichter1905} but have not validated beam deflections or curvatures at loads less than critical loading conditions \cite{Haggerty2019,Luong2019,Greer2017}. Beam deflection was also used to determine an everted tube's curvature, which we have extended to estimate everted tube pose from environmental interactions. Selvaggio \textit{et al}. estimated this pose using an externally loaded cantilever Cosserat rod for an everted tube with actuation along the length.
\section{Methods}
A rotary eversion device was adapted from designs outlined on \url{vinerobots.org} and by \cite{Hawkes2017}. A 2L pneumatic tank was used to act as a pressure transient filter. Pressure is measured with a gauge pressure transducer (Honeywell, SSCDANN150PG2A3) and filtered using a four frame moving average sampled at 300 Hz. Data was collected on two different eversion devices with pressure transducers calibrated to read within 0.345 kPa, which is within the 2\% error band of the transducer.
\subsection{Model Derivation}
This study uses the model developed by Comer \textit{et al}. for an inflated cantilever beam with a length much greater than its radius \cite{Comer1963}. The beam model, as applied to an everted tube, is shown in figure \ref{cantilever_beam}. The curvature
\begin{equation} \label{curvature_eq}
\frac{d^{2}y}{dx^2} =
\begin{cases}
\frac{Qx}{EtR^3\pi} & 0<x<\frac{\pi p R^3}{2Q}\\
\frac{Qx}{EtR^3}\frac{2}{2\pi - 2\theta_0 + sin(2\theta_0)} & \frac{\pi p R^3}{2Q}<x<L
\end{cases}
\end{equation}
describes the vertical displacement within the wrinkled and unwrinkled region of the beam. x is the distance along the beam measured from the tip, Q is the applied tip load, E is the Young's Modulus of the material; R is the beam's radius, and t is the material thickness. It is important to note that the origin of the beam is defined at the free end, shown in Fig. \ref{cantilever_beam}, where the load is applied. Displacement downwards is defined in the positive $y$ direction.
This curvature equation is similar to the standard cantilever beam equation of $\kappa = \frac{M}{EI}$, where the inertia of a thin-walled cylinder is $I=\pi R^3t$. $\theta_0$ is the wrinkle angle around the beam, shown in figure \ref{cantilever_beam}. Wrinkle angle is numerically approximated from eq. \ref{wrinkle_angle_eq} using a 5\textsuperscript{th} order polynomial and is described as function of $\frac{Qx}{pR^3}$, eq. \ref{th0_fn}. This process is outlined by \cite{Veldman2005}.
\begin{equation}\label{wrinkle_angle_eq}
\frac{Qx}{pR^3} = \frac{\pi ( 2\pi - 2\theta_{0} + sin(2\theta_{0})}{4[sin(\theta_0) + (\pi - \theta_0)cos(\theta_0)]}
\end{equation}
The problem is simplified by non-dimensionalizing the position in the x and y direction. The following substitutions:
\begin{equation}\label{xi}
\xi = (\frac{Q}{p R^3})x,
\end{equation}
\begin{equation}\label{eta}
\eta = (\frac{Q^2 Et}{p^3 R^3})y.
\end{equation}
\begin{equation} \label{th0_fn}
\theta_0 = f(\frac{Qx}{p R^3}) = f(\xi)
\end{equation}
give a non-dimensional model for curvature:
\begin{equation} \label{curvature_nd}
\frac{d^2\eta}{d\xi^2} =
\begin{cases}
\frac{\xi}{\pi} & \frac{\pi}{2}>\xi>0\\
\xi \frac{2}{2\pi - 2\theta_0 + sin(\theta_0)} & \pi>\xi>\frac{\pi}{2}
\end{cases}.
\end{equation}
We solve the beam by decomposing the non-dimensional model into a system of first order equations by $\eta_1$ and $\eta_2$, where $ \eta_1 = \eta, \; \eta_2=\frac{d\eta}{d\xi}$:
\begin{equation} \label{nd_sys}
\frac{d}{d\xi} \begin{bmatrix} \eta_1 \\ \eta_2
\end{bmatrix} =
\begin{bmatrix}
\eta_2 \\ \begin{cases}
\xi \frac{2}{2\pi - 2\theta_0 + sin(\theta_0)}
& \pi>\xi>\frac{\pi}{2}\\
\frac{\xi}{\pi} & \frac{\pi}{2}>\xi>0
\end{cases}
\end{bmatrix}.
\end{equation}
Using the initial conditions described in \cite{Comer1963}, a solution can be found. The initial conditions are that the displacement and slope at the root ($x=L$) of the beam are both zero. The system is solved by numerically solving the initial value problem backward, simulating from $x=L$ to $x=0$. Matlab's ODE solver function, ode45, was used to solve
$$
\eta(\xi(L)) = 0, \;\;\;
\frac{d\eta(\xi(L))}{d\xi} = 0
$$
$$ \xi(L) = \frac{QL}{pR^3}.
$$
\subsection{Mechanics of Materials}
Two different beam materials were used to validate the inflated beam model: Silicone Coated Nylon (Seattle Fabrics, Seattle, WA, USA) and 2.54 cm diameter with 2mil (0.05mm) wall thickness Low-Density-PolyEthylene (LDPE) tubing (ULINE, Pleasant Prairie, WI, USA).
The Silicone Coated Nylon had a measured thickness of 0.12 mm. Beams were sewn to a 2.54 cm diameter and sealed using Seam Grip WP (Gear Aid, Bellingham, WA, USA). The LDPE tubing held a significant amount of memory from its manufacturing and storage on a large reel, giving all inflated tubes a nominal curvature. To eliminate the curvature in the plastic was annealed by hanging vertically and stretched by weights in a sunny enclosed patio.
Each material was tensile tested, the stress and strain were computed using a video extensometer and digital image correlation. Materials were stretched at a rate of 5mm/min. Both annealed and un-annealed LDPE samples were tested to ensure that the annealing process did not affect the mechanical properties of the plastic. The Young’s modulus was measured between the maximum and minimum stress within the beam during the following conditions: length of 0.357 m, internal pressure of 10.34 kPa, and applied tip load of 0.155 N. The minimum stress is the longitudinal stress of a pressure vessel and the maximum axial stress at the root of the loaded cantilever beam ($x=L$), outlined in \cite{Comer1963}:
\begin{equation} \label{max_stress}
\sigma_m = \frac{QL}{tR^2}\frac{2(1+cos(\theta_0))}{2\pi-2\theta_0+sin(2\theta_0)}.
\end{equation}
\subsection{Parameter Variation}
The model was validated by comparing the tip deflection of straight and everted tubes. Straight tubes are defined as traditional cylindrical thin-walled inflated beam. In contrast everted tubes have an inner lumen, or tail, connecting back to the spindle, shown in Fig. \ref{cantilever_beam}. Tests varied the independent values of eq. \ref{eta}: beam length (L), internal pressure (p), and external load (Q). Silicone coated nylon and annealed LDPE were the two tube materials used. The tip displacement is $y_d = \eta \frac{p^3 R^6}{Q^2 E t}$ for $\xi(0)$. Transverse buckling occurred when the beam collapsed to the floor under the test conditions.
For beams under variable tip load, a 0.368 m beam with a 1.27 cm radius and 10.34 kPa internal pressure was loaded at the tip by weights of increasing mass. The tip displacement was measured between every increase in weight, the weight was also removed between increases. The beam was loaded until it experienced transverse buckling and collapsed. Collapse conditions were compared to the theoretical critical values \cite{Comer1963}:
\begin{equation} \label{collapse_conditions}
Q_{max} = \frac{\pi p R^3}{L}
\end{equation}
A new plastic beam was used after each collapse to avoid fatigue and plastic deformation between trials. Because the nylon had a significantly higher stiffness, beams were depressurized and re-oriented after every collapse to mitigate any seam dependent deflection.
Everted and straight beams of variable length were evaluated by pressurizing to 10.34 kPa and tip loading with a 0.155 N, tip deflection was measured. This process was repeated for beams of increasing length until the beam collapsed under load. Beams were similarly replaced or re-oriented after each collapse. Collapse conditions were compared to the theoretical max length.
Beams of varying internal pressure were also evaluated using a constant length of 0.357 m and mass of 0.155 N. The tube's internal pressure was decreased from 27.58 kPa until collapse occurred. All beams were depressurized and unloaded between each trial.
Eq. \ref{collapse_conditions} was used to determine additional critical buckling conditions, max length ($L_{max}$) and minimum internal pressure ($P_{min}$).
\subsection{Curvature Evaluation}
Annealed LDPE everted beams of variable length, and constant pressure of 10.34 kPa were loaded with a 0.155 N tip load. Each beam was marked with a series of black dots at 2.54 cm increments. Images were taken before and during loading. Their relative vertical displacement was measured using an image mask in Matlab (Fig. \ref{loaded_beam}). Displacement at discrete locations along the beam was compared with the inflated beam model. The tip slope was determined from the two distal-most markers and compared with the modeled beam slope, $\eta_2$, at the tip.
\begin{figure}[t!]
\centerline{\includegraphics[width=1\columnwidth]{beam_curvature.jpg}}
\caption{Everted inflated cantilever beam with and without a tip load. An image mask was used to determine the centroid of each marker to determine relative displacements along the beam.}
\label{loaded_beam}
\end{figure}
\subsection{Curvature Evaluation From Environmental Interactions}
The model was used to predict tube curvature from environmental interactions. An annealed LDPE everted tube was tip-displaced a fixed amount. Given constant parameters of length and internal pressure, the theoretical load at the tip was iteratively determined, and the curvature estimated from the model. A tube with tip displacement greater than the theoretical maximum was modeled as buckled, and the curvature was approximated as a straight line between tip and base, as presented in \cite{Luong2019}.
\section{Results}
\subsection{Materials Testing}
Annealed and non-annealed LDPE samples were loaded to between 10\% and 12\% strain. The Young's Modulus was determined from the elastic region, $<2\%$ strain, to be 199 MPa and 243 MPa for the non-annealed and annealed samples, respectively. All subsequent simulations use the average across all LDPE conditions, 227 MPa. The Young's Modulus of silicone coated nylon was linear within the max/min stress region, consistent with \cite{Leonard1960}, and measured to be 495 MPa.
\begin{figure}[t!]
\centerline{\includegraphics[width=1\columnwidth]{instron_results.png}}
\caption{Stress-strain performance of the tested materials. \textit{Top:} LDPE results, a comparison between the annealed and unannealed material shows approximately the same Young’s modulus of 227MPa. \textit{Bottom:} Silicone coated nylon was strained up to 10\%, the data shows that this is still in the elastic region. The Young’s Modulus was calculated within experimental stress values.
}
\label{instron_results}
\end{figure}
\subsection{Model Validation: Variable Tip Load}
A constant length, constant pressure, cantilever beam under variable tip load was tested. Fig. \ref{var_load} shows measured tip deflection against applied tip load. A solid blue line shows the theoretical tip deflection until the theoretical buckling condition and displacement. Absolute error was calculated as the difference between the model and measured tip deflection at a specific load. Beam collapse conditions are shown with $\square$ and $\triangle$ markers and evaluated as a percentage of the theoretical maximum load condition. Buckling displacement is the measured tip deflection at the loading condition just before the experimental buckling condition. Everted and straight nylon beams had average absolute tip deflection errors of 19.3 and 16 mm, respectively. The everted beams collapsed at 88\% of the theoretical maximum load, while the straight tubes collapsed at 107\% of the theoretical maximum. The LDPE tubes had a lower absolute tip deflection error of 2.2 and 3.8 mm for everted and straight tubes, respectively. On average, everted LDPE beams collapsed at 80\% of the theoretical maximum load at an average displacement of 0.039 m (SD: 7 mm). Straight LDPE beams collapsed at 106\% of the theoretical maximum load at an average displacement of 0.056 m (SD: 5 mm). The theoretical maximum displacement at $Q_{max}$ is 0.088 m.
\begin{figure}[t!]
\centerline{\includegraphics[width=1\columnwidth]{variable_load_summary_max_disp.png}}
\caption{Tip deflection of straight and everted inflated beams under variable load at a constant length of 0.357 m and constant pressure of 10.34 kPa. The $\square$ and $\triangle$ markers represent the load at which the beam collapsed. \textit{Top:} Silicone coated nylon beam.
\textit{Bottom:} Annealed LDPE beam.
}
\label{var_load}
\end{figure}
\subsection{Model Validation: Variable Beam Length}
A constant pressure, constant load cantilever beam with variable length was tested (Fig. \ref{var_len}). A solid blue line shows the theoretical tip deflection until the theoretical buckling length and displacement. Absolute error was calculated as the difference between the model and measured tip deflection at a specific beam lengths. Collapse conditions are shown with $\square$ and $\triangle$ markers and evaluated as a percentage of the theoretical maximum length. Buckling displacement is the measured tip deflection at the beam length just before the experimental buckling length. Everted and straight nylon beams had absolute tip deflection errors of 12.9 and 8.3 mm, respectively. The everted beams collapsed at 88\% of the theoretical maximum load, while the straight tubes collapsed at 106\% of the theoretical maximum. The LDPE tubes had lower absolute tip deflection errors of 2.5 and 8.6 mm for everted and straight, respectively. Everted LDPE beams collapsed at 77\% of the theoretical maximum load at an average displacement of 0.029 m (SD: 4 mm). Straight LDPE beams collapsed at 102\% of the theoretical maximum load at an average displacement of 0.054 m (SD: 3 mm). The theoretical maximum displacement at $L_{max}$ is 0.119 m.
\begin{figure}[t!]
\centerline{\includegraphics[width=.925\columnwidth]{variable_length_summary_max_disp.jpg}}
\caption{Tip deflection of straight and everted beams under constant 15.8 g load, pressurized to 10.34 kPa under variable lengths.The $\square$ and $\triangle$ markers represent the load at which the beam collapsed. \textit{Top:} Silicone coated nylon beam.
\textit{Bottom:} Annealed LDPE beam.
}
\label{var_len}
\end{figure}
\subsection{Model Validation: Variable Pressure}
A constant load, constant length cantilever beam with variable internal pressure was tested. The results are shown in Fig. \ref{var_pres} which plots tip deflection against internal pressure. A solid blue line shows the theoretical tip deflection from the theoretical minimum internal pressure to the deflection at 30kPa. Absolute error was calculated as the difference between the modeled and measured tip deflection at a specific internal pressure. Collapse conditions are shown with $\square$ and $\triangle$ markers and evaluated as a percentage of the theoretical minimum pressure. Buckling displacement is the measured tip deflection at the internal pressure just before the experimental buckling pressure. Everted and straight nylon beams had an absolute tip deflection error of 29.1 and 12.9 mm, respectively. Nylon everted beams, on average, collapsed at 116\% of the theoretical minimum pressure while the straight beams collapsed at 93\% of the theoretical minimum. LDPE tubes had a lower absolute tip deflection of error of 9.3 and 8.2 mm for everted and straight beams, respectively. The everted LDPE beams collapsed at 120\% of the theoretical minimum pressure at a displacement of 0.038m (SD: 1 mm). Straight beams collapsed at 77\% of the theoretical minimum at a displacement of 0.034m (SD: 1 mm). The theoretical maximum displacement at ($P_{min})$ is 0.0747m.
\begin{figure}[t!]
\centerline{\includegraphics[width=.925\columnwidth]{variable_pressure_summary_max_disp.png}}
\caption{Tip deflection of straight and everted beams of variable pressure under constant 0.155 N load and length of 0.357 m. The $\square$ and $\triangle$ markers represent the load at which the beam collapsed. \textit{Top:} Silicone coated nylon beam.
\textit{Bottom:} Annealed LDPE beam.
}
\label{var_pres}
\end{figure}
\begin{figure*}[t!]
\centerline{\includegraphics[width=0.99\textwidth]{curvature_summary_long.jpg}}
\caption{Modeled and measured curvature for everted LDPE beams of length 0.254, 0.305, 0.330, and 0.356 m. Each beam was under a 0.155 N load and pressurized to 10.34 kPa. }
\label{curvature}
\end{figure*}
\subsection{Model Validation: Curvature Under Load}
The curvature of an everted cantilever beam of variable length is shown in Fig. \ref{curvature}. The origin is located at the tip of the beam, and the plot shows distance from the tip against relative displacement. The absolute displacement error was computed as the difference between the measured vertical displacement and modeled vertical displacement at discrete locations along the length of the beam. The average displacement error was computed to be 1.1, 1.5, 2.6 and 4.9 mm for beams of length 0.254, 0.305, 0.330, and 0.356m. While the absolute error increases with beam length, the relative tip displacement error is 14\%, 11.8\%, 12.4\%, and 18.5\%. The tip slope error, $\frac{dy}{dx}$, was measured to be 0.011, 0.017, 0.012, and 0.02 rad for the given lengths.
\subsection{Estimating Curvature from Environmental Interaction}
An inflated beam's curvature was estimated from a known tip displacement by iteratively solving for the theoretical applied load, given constant beam parameters. Absolute error was calculated from the difference between the estimated curvature and the measured curvature. Figure \ref{obstacle} shows the beams interaction with an obstacle relative to its nominal unloaded position. For tip displacements of 17, 21, and 34 mm an absolute error of 0.7, 0.7, and 0.9 mm and relative error of 20\%, 17\% and 15\% was calculated, respectively. The curvature of beams displaced greater than their theoretical max, determined using eq. \ref{collapse_conditions}, were modeled as a straight line between the tip and base. This straight-line approximation of buckled beams recorded average absolute errors of 1.1 and 1.4 mm and relative error of 4.5\% and 3\%.
\begin{figure*}[t!]
\centerline{\includegraphics[width=1\textwidth]{obstacle_interraction_long.jpg}}
\caption{A comparison of the modeled and measured curvature for beams deflected by an obstacle in the environment. A beam 0.305 m in length and pressurized to 10.34 kPa was deflected to a known distance. Its curvature was measured using a series of markers spaced 2.54 cm apart. Given the tip displacement, length, and pressure, the applied force and curvature were estimated.}
\label{obstacle}
\end{figure*}
\section{Discussion}
\subsection{Tip Deflection Validation}
The deflection model provided by Comer \textit{et al}. best fit the tip deflections of the annealed LDPE tubes with an average tip deflection error of 6 mm for both straight and everted beams. The measured tip deflection of silicone coated nylon did not match the magnitude predicted in the model with an average tip deflection error of 16.4 mm for both straight and everted beams. The model held the same shape as the experimental tip deflection data. In this cantilever application, modeled nylon tubes exhibited an effective stiffness of approximately 25\% of the measured value. The data shows that $E_{model} = .25E_{longitudinal}$, where $E_{longitudinal}$ is the Young's Modulus computed from the tensile test. This is likely due to the direction of the applied load on the weave pattern of the nylon. Silicone coated nylon can be thought of as a composite material whose Young's Modulus is not constant with respect to the angle of the applied load. Tensile testing yielded the stiffness in the longitudinal direction. Cantilever loading applies transverse stress on the beam, a loading condition where $E_{transverse}<E_{longitudinal}$. For a structure where the load may be applied in an arbitrary direction with respect to the weave, performance consistent with the maximum material properties determined from longitudinal testing cannot be expected.
In all cases, the everted and straight tubes showed approximately the same tip deflection throughout each experiment. Although in all experiments, everted tubes collapsed at conditions before the theoretical max/min and straight tubes collapsed after. Across all experiments, everted nylon tubes buckled 86\% of the theoretical buckling condition while everted LDPE tubes collapsed at 79\% of the theoretical buckling condition. On average, straight nylon tubes buckled at 107\% of the theoretical buckling condition and straight LDPE tubes collapsed at 110\% of the theoretical buckling condition. This could be due to wrinkles or fatigue generated in the material during the eversion process. Recall that as $\lim_{\theta_0\to\pi}$ the beam collapses \cite{Veldman2005}. It is possible that material creasing during eversion contributed wrinkle propagation when under load. The deflection of an inflated cantilever beam model is valid for homogeneous materials such as LDPE. The modeled beam's deflection held true until near collapse, but the collapse condition may not be accurately determined by the model. A beam's collapse may be defined better by a maximum displacement. Across all LDPE tests, beams collapsed at a consistent displacement rather than load. In nearly all conditions, everted tubes collapsed at a smaller displacement than straight tubes.
\subsection{Beam Curvature Validation}
The curvature of an everted tube was validated using both a transverse gravity load and external lateral displacement. Tubes under a transverse gravity load had a relative tip displacement error of 14.2\%, and tubes under an external lateral displacement had a relative curvature error of 17.3\%. Tubes externally displaced greater than the theoretical maximum were approximated as a straight line and showed an error of 3.75\%. Longer tubes showed greater absolute tip displacement error but all beams had similar relative tip error. Tip slope computation showed a similar error trend across beams of variable length. The accuracy of this value can be increased by increasing the quality of the image tracking system.
Predicting curvature from environmental displacements implies that the model may be used to accurately estimate interaction forces with the wall given a specific tip deflection. Allowing a user to determine applied forces in a known sensitive environment such as an archaeological dig site, \cite{Coad2020}, or within the body \cite{Slade2017, Saxena2020}.
\begin{figure}[h]
\centerline{\includegraphics[width=.75\columnwidth]{pose_estimate_sml.png}}
\caption{Tip pose estimation from static tip deflection}
\label{pose_estimation}
\end{figure}
\subsection{Pose Estimation from Environment}
The static pose of the tip of an everted tube can be estimated using tip deflection. The tip reference frame is calculated using the differential kinematics model derived by \cite{Greer2018}:
\begin{equation} \label{p_dot_vec}
\dot{\vec{p}} = u\frac{||\vec{p}-\vec{c_n}||}{\hat{t}\cdot(\vec{p}-\vec{c_n})}
\end{equation}
Given an obstacle within an environment, tip translation is determined by :
\begin{equation} \label{trans_l}
^{\vec{c_n}}\mathbf{t}_{\vec{p}} = \vec{p},
\end{equation}
where $\hat{t}$ is the unit vector parallel to the surface of the obstacle, $u$ is the eversion growth rate, $\hat{p}$ is the tip location, and $c_n$ is the nearest contact point. In the case of Fig. \ref{pose_estimation} $c_n$ is the everter base. The curvature at the tip or heading, $\eta_2$ when $\xi=0$, gives the rotation angle of the tip coordinate frame:
\begin{equation} \label{rot_vec}
^{\vec{c_n}}\mathbf{R}_{\vec{p}} = \eta_2 \frac{p^2 R^3}{QEt}
\end{equation}
From tip translation and tip slope, a planar and homogeneous transformation matrix can be determined. This process is similarly computed in Selvaggio \textit{et al}. \cite{Selvaggio2020}, where the everted tube is modeled as a Cosserat rod. Forces applied to the obstacle can also be computed from the pose.
\subsection{Applications}
Understanding the static behavior of everted beams will help give insight into their kinematic behavior. This work can support the algorithms derived in several published works.
Tip slope angle could also be useful in determining transverse buckling while growing along a wall. If a tube is incident to a wall at an angle greater than the minimum incident angle described by Haggerty \textit{et al}. \cite{Haggerty2019}, transverse buckling occurs and the tube grows along the wall. If a tube is incident to the wall at an angle less than the determined minimum incident angle, the static beam will bend according to the model described by \cite{Comer1963} and will behave as shown in Fig. \ref{obstacle}. In this instance, tip slope angle should be considered when computing incident angle. Transverse buckling may occur when tip slope is considered. This insight could help understand a tube's kinematic behavior very close to buckling conditions.
Retraction without buckling of an everted tube is greatly influenced by the tube's curvature \cite{Coad2020retraction}. The curvature model derived in this paper can provide an analytical solution to assist in computing retraction forces.
Everted tubes in previous path planning algorithms have been modeled as straight lines between obstacles and discrete pivot points \cite{Greer2018}. The inflated beam model allows for the beam's curvature to be computed and included in these kinematic models.
\subsection{Limitations and Future Work}
While the solution of an inflated cantilever beam is easy to compute and useful in static conditions, it does not have a closed-form solution. Determining theoretical max tip deflection or applied wall force from tip deflection requires iterative solving, which may be too slow for real-time control.
In the future, bi-axial testing of composite tube materials should be conducted to improve models of transverse buckling. Additionally, experiments should be done to extend these models to better describe the kinematics of everted tubes. Active pressure control should be studied for the kinematic control of everted tubes, thus maintaining the benefits of soft robots.
\section{Conclusion}
This study validates the current assumption that an everted tube can be modeled like an inflated beam. Our results confirm that the deflection and curvature of an LDPE everted tube can be accurately modeled using inflated beam theory. Beams composed of composite materials, like silicone-coated nylon, are not as accurately modeled. However, the model overestimates the exact buckling condition across all materials tested. Data indicates that everted tube buckling was better described by a maximum displacement rather than a maximum loading condition. The model can be iteratively solved to determine curvature from environmental displacements and applied loads to the environment.
\section{Acknowledgements}
This work was supported by the UW Burke Center for Entrepreneurship's Prototype Fund and UW CoMotion's Innovation Gap Fund. Thanks Mark Gerges and the UW MACS lab for 3D printing assitance.
\bibliographystyle{IEEEtran}
| {'timestamp': '2021-07-14T02:05:31', 'yymm': '2107', 'arxiv_id': '2107.05748', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05748'} | arxiv |
\section{Mathematical Function Implementation Background}
\label{sec:implementations}
While the mathematics behind approximating transcendental functions
is well understood,
numerous choices, like approximation method,
polynomial order, table size, and range reduction strategy,
all impact both accuracy and speed.
\begin{figure}
\begin{subfigure}{0.60\textwidth}
\includegraphics[width=\textwidth]{images/poly.pdf}
\caption{Polynomial approximation and error}
\label{fig:poly}
\end{subfigure} \hfill%
\begin{subfigure}{0.315\textwidth}
\includegraphics[width=\textwidth]{images/table.pdf}
\caption{Table approximation}
\label{fig:table-approx}
\end{subfigure}
\caption{
Approximations $P(x)$ of an arbitrary function $f(x)$.
A order-1 polynomial approximation is shown on the left;
a $4$-entry table based approximation is shown on the right.
In the middle, an illustration of the equioscillation theorem:
the polynomial approximation is optimal
error reaches its highest value the maximum
number of times.
}
\label{fig:approx}
\end{figure}
\begin{figure}
\begin{subfigure}{0.48\textwidth}
\scriptsize
\begin{verbatim}
double ml2_raw_wide_sin_13(double x){
double x2 = x * x;
double pa, pa1, pa3, pa5, pa7, pa9, pa11, pa13;
pa13 = 0x1.52a851954275cp-33;
pa11 = -0x1.ae00bdd2a86a8p-26 + x2 * pa13;
pa9 = 0x1.71dce463cf737p-19 + x2 * pa11;
pa7 = -0x1.a019fce360596p-13 + x2 * pa9;
pa5 = 0x1.11111109020a6p-7 + x2 * pa7;
pa3 = -0x1.5555555540916p-3 + x2 * pa5;
pa1 = 0x1.ffffffffffdc9p-1 + x2 * pa3;
pa = x * pa1;
return pa;
}
\end{verbatim}
\caption{An order-13 polynomial function approximation}
\label{fig:poly-based}
\end{subfigure}%
\hfill%
\begin{subfigure}{0.48\textwidth}
\scriptsize
\begin{verbatim}
double sin_table[255];
void fill_table() {
for(i=0; i<255; i++){
theta = (double)(i-127)*M_PI/127.0;
sin_table[i] = sin(theta);
}
}
double table_sin(double x){
int index = (x*127.0/M_PI) + 127;
return sin_table[index];
}
\end{verbatim}
\caption{A size-255 table-based function approximation}
\label{fig:table-based}
\end{subfigure}
\caption{
Two possible approximations of \F{sin} for $x \in [-\pi, \pi]$.
The one on the left uses an order-13 order polynomial
and achieves an absolute error of \nScarySinError
and a run time of \nScarySinTime on our reference machine.
The on on the right
is the table based implementation used by POV-Ray,
with an absolute error of $0.02473$
and a run time of \nPovRayTableImplTime.}
\end{figure}
\subsection{Approximating over an Interval}
The core technique in implementing a mathematical function
is approximating a function $f$ over a small input range $I$.
One method is to find a polynomial $P(x)$ that approximates $f$.
While techniques like Taylor series and Chebyshev approximations,
which optimize for the average case, are better known,
implementations usually optimize for worst-case errors.
The Remez exchange algorithm~\cite{remez},
which solves for local minima and maxima of $f(x) - P(x)$
by the Chebyshev equioscillation theorem~\cite{equioscillation},
is the standard way of deriving coefficients for $P$
that minimize worst-case error.
\Cref{fig:poly} illustrates this approach.
Remez exchange is implemented in the the Sollya tool~\cite{sollya},
which additionally uses the LLL algorithm~\cite{lll}
to tune the coefficients for the floating-point domain.
The end result of this process is an implementation
similar to the one shown in \Cref{fig:poly-based}.
The number of terms in the polynomial is the key parameter to this process;
an implementation can approximate a target functions like $\sin$ or $\exp$
with anywhere from one to dozens of terms,
offering a spectrum with higher-order approximations
being more accurate but also slower.
The input interval $I$ is also an important input;
generally speaking, wider input intervals yield worse approximations.
Even once a polynomial is found, there are more choices to make.
For example, the polynomial
\(
P(x) = a_0 + a_1 \cdot x + a_2 \cdot x^2 + \dotsb
\)
is usually evaluated via Horner's rule,
\(
P(x) = a_0 + x\cdot(a_1 + x\cdot(a_2 + x\cdot(\dotsb)))
\),
but there are other evaluation schemes as well,
like Estrin’s Method for parallelization with SIMD
or compensated summation for higher accuracy.
Table-based implementations are an alternative to pure polynomial approximation.
In a table-based implementation,
the interval $I$ is split into many smaller intervals,
often hundreds or thousands of them,
and then some uniform method is used to approximate the function
on each of those smaller intervals.
A simple table-based implementation like this
tabulates $f(x)$ for evenly spaced $x$ values,
like the $\sin$ table in the back of an old-school math textbook;
such an implementation is shown in \Cref{fig:table-based}.
A more sophisticated approach
may store polynomial coefficients in the table,
or use complex interpolation schemes to fill in intermediate values.
Just as with polynomial implementations,
a table-based scheme has many parameters for the implementor to choose:
table size, interpolation scheme, subdivision algorithm, and so on;
and again, these parameters affect both speed and accuracy,
and may depend on machine-specific parameters like cache size.
\subsection{Range Reduction}
Neither polynomial nor table-based approximation
works well over a large input interval $I$,
so the most challenging part of approximating a mathematical function
is making sure the function can be applied to an arbitrary input.
This is called \textit{range reduction and reconstruction}.
Range reduction and reconstruction bookend the polynomial or table,
transforming the input to lie within the polynomial or table's input range
and then adjusting the output to fit the original input.
\begin{figure}
\hfill%
\begin{minipage}[c]{.56\textwidth}
\includegraphics[width=\textwidth]{images/range_reduction.pdf}
\end{minipage}\hfill
\begin{minipage}[c]{0.38\textwidth}
\caption{
\small
Range reduction and reconstruction for \F{sin}.
The input point, somewhere along the input domain, is mapped via range reduction
into the interval $[0,\pi/2]$ for evaluation, then mapped back via
reconstruction to the correct output value.
This reduction takes advantage of the cyclic nature of \F{sin}, the symmetry of
the sections of \F{sin} above and below $y=0$, and the mirror symmetry
present in each half cycle.
Reconstruction of \F{sin} needs only determine the correct sign of the output.
}
\end{minipage}\hfill
\label{fig:range}
\end{figure}
Consider implementing \F{sin} over a large range.
Since \F{sin} is periodic, $\sin(x) = \sin(x \bmod 2\pi)$;
and furthermore, $x \bmod 2\pi$ is bounded
to the range $[0, 2\pi]$.
Thus, \F{sin} can be implemented over a large range
by using a polynomial or table for the range $[0, 2\pi]$
and \emph{reducing} other inputs to lie within that range.
We can take advantage of other symmetries
to restrict the range further.
For example, $\sin(x) = -\sin(x - \pi)$;
for inputs $x \in [\pi, 2\pi]$ the right hand side of this equation
calls $\sin$ on inputs $x - \pi \in [0, \pi]$.
So, a polynomial or table fit to $[0, \pi]$ is enough,
but in this case a \emph{reconstruction} step is necessary
to take the output on the reduced input
(in this case, $\sin(x - \pi)$)
and compute from it the output for the original input
(in this case, by negating the reduced output).
Both reduction and reconstruction are shown in \cref{fig:range}.
Other identities, like the double-angle formula,
can also be used for range reduction,
and the same general principle
of using function identities to reduce the input range
can apply to $\log$, $\exp$, or any other functions
with identities to leverage.
Reducing the interval $I$ that the polynomial or table is fit to
usually makes the approximation itself
either more accurate or faster (by using fewer terms).
But range reduction and reconstruction
can slow the implementation down
and add error of their own.
Traditionally, math libraries have used higher-precision arithmetic,
such as in Cody \& Waite reduction~\cite{cody-waite},
to implement range reduction with no error.
This maximizes accuracy, especially for very large inputs
(imagine computing $\F{sin}(10^{10})$),
but is also very slow because it requires computing $x \bmod 2\pi$
in very high precision using thousands of bits of $\pi$.
But range reduction can also trade accuracy for speed.
For example, $x \bmod 2\pi$ can be computed
by just evaluating $x - \lfloor x / 2 \pi \rfloor$ in double precision.
This introduces errors
(from approximating $\pi$ and from division)
but is significantly faster than high-precision arithmetic.
There are also intermediate choices with more or less error.
Thus, the choice of range reduction
again presents a trade-off between accuracy and speed.
\end{document}
\section{Leveraging Restricted Input Ranges}
\label{sec:ranges}
As discussed in \Cref{ssec:libraries},
there are advantages to reduced range function implementations:
by skipping range reduction entirely,
or by using faster but less accurate range reductions,
a function implementation can be dramatically sped up
without meaningfully increasing its error.
However, restricted-range implementations can only be safely used
by proving that its input lies within that restricted range.
\subsection{Modeling Input Ranges}
When a function is called in a floating-point expression,
the range of inputs it is called on
depends on not only the mathematical value of the input expression
but also on how much error that input is computed with.
This dependence means that
choosing a rougher approximation for one part of a computation
can change what implementations are available in a later part of the computation.
Determining where a reduced-range implementation can be used
is therefore like flattening a rug with a bump in it---%
as soon as one part is fixed another part pushes back up---%
because replacing one function implementation with another
will also change the range of its output
and thus the valid implementations of other function calls.
Yet the advantages of reduced-range implementations
are too large to pass up.
Formally, consider a sequence of function assignments
$\tilde{x}_n := \tilde{f_n}(\tilde{x}_{n-a_n}, \tilde{x}_{n-b_n}, \ldots)$,
except that the function $\tilde{f}_n$ is only valid
when its first argument is in the range $[d_1, d_2]$
(functions with range restrictions on other arguments work analogously).
Since $\tilde{f_n}$ is in fact called on $\tilde{x}_{n-a_n}$,
we must establish that $d_1 < \tilde{x}_{n-a_n} < d_2$.
Following the idea of the error Taylor series,
\[
|\tilde{x}_{n-a_n} - x_{n-a_n}| \leq
\sum_i A^n_i \varepsilon_{f_i} + \sum_i B^n_i \delta_{f_i}
+ o(\varepsilon^2)
\]
where the $A^n_i$ and $B^n_i$ constants
are as defined in \Cref{sec:error-and-cost-models}.
For now, ignore the higher-order terms.
Now, suppose $x_{n-a_n}$,
the true mathematical value of $\tilde{x}_{n - a_n}$,
is bounded within $[a_1, a_2]$ for all $x \in I$;
OpTuner\xspace computes these bounds using Gelpia.
The requirement $d_1 < \tilde{x}_{n-a_n} < d_2$ can then be rewritten:
\newcommand{\operatorname{\Longleftrightarrow}\;}{\operatorname{\Longleftrightarrow}\;}
\begin{align}
&d_1 < x_{n-a_n} \pm \left( \sum_i A^n_i \varepsilon_{f_i} + \sum_i B^n_i \delta_{f_i} \right)< d_2 \nonumber\\
\operatorname{\Longleftrightarrow}\;& d_1 < a_1 - \left(\sum_i A^n_i \varepsilon_{f_i} + \sum_i B^n_i \delta_{f_i} \right) \land
a_2 + \left( \sum_i A^n_i \varepsilon_{f_i} + \sum_i B^n_i \delta_{f_i} \right) < d_2 \nonumber \\
\operatorname{\Longleftrightarrow}\;& \left(\sum_i A^n_i \varepsilon_{f_i} + \sum_i B^n_i \delta_{f_i}\right) < a_1-d_1
\land \left(\sum_i A^n_i \varepsilon_{f_i} + \sum_i B^n_i \delta_{f_i}\right) < d_2 - a_2 \nonumber \\
\operatorname{\Longleftrightarrow}\;& \left(\sum_i A^n_i \varepsilon_{f_i} + \sum_i B^n_i \delta_{f_i}\right) < \min(a_1-d_1, d_2 - a_2)
\label{inputvalid}
\end{align}
Define the constant $S_{i,j}$
to be the right hand side value, $\min(a_1 - d_1, d_2 - a_2)$,
for using implementation $\tilde{f}_j$ at use site $i$.
Crucially, the right hand side value
depends only on the function input range $[d_1, d_2]$
and the argument's error-free range $[a_1, a_2]$.
Thus, the final inequality of \Cref{inputvalid}
is a linear inequality over the same $\varepsilon$ and $\delta$ variables
as the integer linear program in \Cref{sec:optimization}.
OpTuner\xspace adds the following inequality
to the integer linear program:
\[
\newcommand{\eqnbox}[1]{\fbox{\textsc{#1}}\;}
\eqnbox{InRange} t_{i,j} \implies \sum_k A^i_k \varepsilon_k + \sum_k B^i_k \delta_k < S_{i,j},
\]
The implication can also be written as a pure ILP statement,
but the ILP solver OpTuner\xspace uses, Z3,
supports implication statements like these directly.
Note that in some cases, the constant $S_{i,j}$ can be negative,
meaning that $\tilde{f}_j$ cannot be used.
Just like with OpTuner\xspace's use of the linear error model,
a post-pass is necessary
to take into account the higher-order terms
that OpTuner\xspace ignores during ILP solving.
This post-pass recomputes the input range
using the most accurate rounding model
and with higher-order terms bounded using Lagrange's theorem,
and removes the point from the speed-accuracy Pareto curve
if adding the higher-order terms makes the chosen implementations invalid.
In practice this occurs for \nBenchDomainViolationRate of points,
mostly at the far end of the Pareto curve where error is already high.
\subsection{Implementing New Restricted-range Libraries}
\label{ssec:bounding}
To test OpTuner\xspace's support for restricted input ranges,
we used MetaLibm to implement custom restricted-range versions
of $\sin$, $\cos$, $\tan$, $\exp$, and $\log$.
Our implementations are based on those of \citet{faster-math-functions,even-faster-math-functions}:
they fit a polynomial of 1--\nMaxTerms terms
using over a function-specific core interval $I$,
and then use either no range reduction
or a custom, simplified range reduction
without higher-precision arithmetic operations.
Since these range reductions use simplified arithmetic,
they are accurate over roughly 1--50 multiples of $I$,
with an accuracy/input range trade-off
on top of the accuracy/speed trade-off.
Traditionally, restricted-range implementations
are hidden from library users
because it is too easy to misuse them.
Because OpTuner\xspace is sound, this fear no longer applies.
Implementing these functions
was relatively straightforward thanks to MetaLibm,
but deriving accuracy bounds was more challenging.
Inaccuracy---error---comes from three sources:
algorithmic error, or
the difference between the polynomial and the function being implemented;
rounding error, or
the error of evaluating the polynomial in floating-point arithmetic;
and reduction error
from error in the range reduction and reconstruction steps.
To derive a sound bound
we bound each type of error separately and then sum them,
once for the $\varepsilon$ parameter
and once for the $\delta$ parameter.
The algorithmic error is a purely mathematical artifact,
and Sollya can compute it automatically
(it is computed in the inner loop of the Remez exchange algorithm).
To bound the rounding error we use FPTaylor
with the most accurate \F{fp-power2} error model.
While FPTaylor's bounds are very tight they can in rare cases
be edged out by manual error analysis,
such as \citet{horner-bound}'s bound
on the rounding error of a Horner-form polynomial.
To get the best possible bound
we use the tigher of FPTaylor's and Oliver's bound,
since both are sound error estimates.
The reduction error, however, is harder to analyze.
Range reduction typically involves a mix
of integer and floating-point computations,
so to bound it we use the approach of Lee, Sharma, and Aiken~\citep{verbit}.
In mixed integer-floating point computations
the integer values are constant
for some range of floating-point values;
for example, when rounding a floating-point value to an integer;
all of the float values in the range $[0.5,1.5]$ round to $1$.
A single mixed-integer-floating-point computation
is therefore broken down into multiple computations
only floating-point variables and integer constants,
where different computations are used for different $x$ values.
Our restricted-range implementations
compute $k = \lfloor x / \pi \rfloor$;
this expression for $k$ is monotonic
so a fixed $k$ values corresponds to an interval of $x$ values.
The error of the remaining floating-point operations
is computed using FPTaylor,
and FPTaylor is again used
to determine how the approximating polynomial modulates that error.
Aggregating across all $k$ values results in the overall reduction error.
Generally, larger $k$ values lead to larger input ranges
but also greater error.
To account for this, we give a single implementation
multiple accuracy specifications (as if it were multiple functions)
with narrower input ranges having lower error.
On the 8-core machine used for this paper,
verifying the bounds for the complete collection
of \nOptunerImpls custom implementations
of \F{exp}, \F{log}, \F{sin}, \F{cos}, and \F{tan}
takes approximately \nTotalGenerationTime.
On average, for each implementation,
generating the approximating polynomial takes \nSollyaAvg,
verifying its accuracy without range reduction
takes \nErrorVerrifyAvg,
and verifying its accuracy with range reduction
takes an additional \nReductionErrorAvg
for each $k$ bound.
Importantly,
though verifying these implementations takes a lot of time,
it only needs to be done once,
and the resulting implementations and accuracy bounds
are distributed with OpTuner\xspace.
\end{document}
\section{Evaluation}
\label{sec:evaluation}
We evaluate whether OpTuner\xspace
can automatically select function implementations
to achieve a trade-off between speed and accuracy.
The data is gathered on a machine
with an Intel i7-4793K processor and 32GB of DDR3 memory
running Debian 10.10 (Buster), GCC 8.3.0, GLibC 2.28, Sollya 7.0, and Python 3.7.3.
\subsection{Methodology}
\label{sec:methodology}
\begin{figure*}
\setlength{\tabcolsep}{2pt}
\begin{minipage}[t]{0.78\linewidth}
\begin{tabular}{lll}
\textbf{Function} $\sin(x)$ &
\textbf{Function} $\cos(x)$ &
\textbf{Function} $\tan(x)$ \\
{\color{orange}$\bullet$}: $D = [-62.83, 64.40]$ &
{\color{orange}$\bullet$}: $D = [-62.83, 64.40]$ &
{\color{orange}$\bullet$}: $D = [-39.26, 40.05]$ \\
{\color{blue}$\bullet$}: $D = [-1.571, 1.571]$ &
{\color{blue}$\bullet$}: $D = [-1.571, 1.571]$ &
{\color{blue}$\bullet$}: $D = [-0.1, 0.89]$ \\
{\color{cyan}$\bullet$}: $D = [-3.142, 3.142]$ &
{\color{cyan}$\bullet$}: $D = [-3.142, 3.142]$ &
\\
\fbox{\includegraphics[width=0.30\linewidth]{images/Table_2_sin.png}} &
\fbox{\includegraphics[width=0.30\linewidth]{images/Table_2_cos.png}} &
\fbox{\includegraphics[width=0.30\linewidth]{images/Table_2_tan.png}}
\end{tabular}
\end{minipage}%
\hfill%
\begin{minipage}[t]{0.20\linewidth}
\scriptsize
\textbf{Legend} \\[0.025in]
{\color{green!60!black}$\bullet$}: Standard libraries \\
{\color{purple}$\bullet$}: MetaLibm \F{exp} \\[0.025in]
Custom: \\
{\color{orange}$\bullet$}: mild range reduction \\
{\color{blue}$\bullet$}: no range reduction \\
{\color{cyan}$\bullet$}: no range reduction \\
\end{minipage}
\vspace{0.5cm}
\begin{minipage}{0.52\linewidth}
\begin{tabular}{ll}
\textbf{Function} $\exp(x)$ &
\textbf{Function} $\log(x)$ \\
{\color{orange}$\bullet$}: $D = [-34.75, 35.45]$ &
{\color{orange}$\bullet$}: $D = [\float{1.5}{-4}, 4096]$ \\
{\color{blue}$\bullet$}: $D = [-0.1, 0.79]$ &
{\color{blue}$\bullet$}: $D = [0.65, 1.6]$ \\
\fbox{\includegraphics[width=0.45\linewidth]{images/Table_2_exp.png}} &
\fbox{\includegraphics[width=0.45\linewidth]{images/Table_2_log.png}} \\
\end{tabular}
\end{minipage}%
\hfill%
\begin{minipage}{0.45\linewidth}
\caption{
The available implementations for OpTuner\xspace.
Accuracy is shown in log-scale on the horizontal axis,
while runtime is plotted on the vertical axis.
The plot's bottom border represents a runtime of 0,
while the dashed line is a break in the vertical axis
with CRLibM lying above the break.
Note that the synthesized implementations
with simplified range reduction are significantly faster.
}
\label{fig:functions}
\end{minipage}
\end{figure*}
We evaluate OpTuner\xspace on \nBenchmarks benchmarks
from the FPBench suite~\cite{fpbench} as well as
the \F{haskell} benchmark suite from Herbie 1.5~\cite{herbie},
originally extracted from Haskell packages via a compiler plugin.
Specifically, we select all benchmarks
that use the \F{exp}, \F{log}, \F{sin}, \F{cos}, or \F{tan} functions
and do not contain loops or tensors (which OpTuner\xspace does not support).
Within these benchmarks \F{exp}, \F{log}, \F{sin}, \F{cos}, and \F{tan} are
used a collective \nBenchmarkUseSites times;
the only other library function called is a single use of \F{atan},
for which we use the GLibC implementation.
Thirteen benchmarks have a single input, ten have two inputs, eleven have three
inputs, and the remainder have four or more inputs.
Some of the benchmarks come equipped with input ranges defined for them,
but, for those that did not,
we choose input ranges that avoid domain errors such as division by zero.
OpTuner\xspace tunes these benchmarks using a total
of \nOptunerImpls implementations
of library functions \F{exp}, \F{log}, \F{sin}, \F{cos}, and \F{tan}
drawn from
the standard mathematical libraries
and parameterized MetaLibm implementations
described in \Cref{ssec:libraries}.
\Cref{fig:functions} plots the accuracies and costs
for standard mathematical libraries (in green);
MetaLibm's parameterized \F{exp} implementation (in purple);
and OpTuner\xspace's custom, range-restricted implementations
(in blue, cyan, and orange).
The various implementations span
from half an ulp of error to a relative error of $10\%$,
and the fastest implementation
is usually about $5\times$ faster than GLibC
while the slowest is usually about $5\times$ slower.
In between these extremes,
there is a smooth trade-off between speed and accuracy.
\subsection{Results}
\begin{figure}
\begin{subfigure}{.5\linewidth}
\includegraphics[width=\linewidth]{images/zoomed_aggregate.png}
\caption{High-accuracy configurations}
\label{fig:aggregatezoom}
\end{subfigure}%
\begin{subfigure}{.5\linewidth}
\includegraphics[width=\linewidth]{images/aggregate.png}
\caption{All configurations of any accuracy}
\label{fig:aggregate}
\end{subfigure}
\caption{
OpTuner\xspace's optimized implementations of \nBenchmarks benchmarks.
Each point's accuracy and runtime is normalized
so that using the GLibC implementations for each function
gives a speedup and relative error of $1\times$.}
\label{fig:bothaggregates}
\end{figure}
\Cref{fig:bothaggregates} contains all \nBenchmarks
speed-accuracy Pareto curves,
with \nBenchImpls configurations in total.
In the plot, each line represents a single benchmark,
and each heavy dot along that line
is a configuration produced by OpTuner\xspace.
The benchmarks are
normalized so that the ``standard'' implementation
that uses GlibC for each use site is at $(1, 1)$.
On the left, in \Cref{fig:aggregatezoom},
are all benchmark implementations
with error no more than $10\times$ larger
than the standard implementation.
Note that even with just one decimal digit more error,
speedups of $50\%$, $100\%$
and sometimes even $150\%$ are possible.
Note also the cluster of points
below and to the left of $(1, 1)$.
These points represent configurations that are
more accurate but also slower than GLibC,
generally using the correctly-rounded CRLibM functions.
A few points in the plot are above and to the left of $(1, 1)$:
these configurations are both faster and more accurate than GLibC,
generally by mixing CRLibM and custom implementations.
In this case, OpTuner\xspace is truly offering speed for free.
All told, \Cref{fig:aggregatezoom} shows
than OpTuner\xspace can produce impressive speedups
with minimal expertise or knowledge of numerical analysis.
The right-hand plot, in \Cref{fig:aggregate},
instead focuses on applications tolerant of significant error,
such as POV-Ray.
Here, implementations with dramatically higher error are plotted,
and correspondingly larger speedups are achieved.
The points on this figure generally use
OpTuner\xspace's custom implementations,
which are the fastest ones available.
The speedups here are as large as \nBenchmarkLargeSpeedup.
However, the available speedup is limited
in benchmarks that use mathematical operations
that OpTuner\xspace does not tune
and in benchmarks with few use sites.
For an average benchmark, therefore,
the maximum speedup reaches \nBenchmarkAvgMaxSpeedup.
Of course, by the logic of the Pareto curve,
this maximum speedup comes with minimal accuracy,
and not all applications are as error-tolerant as POV-Ray.
Nevertheless, the figure shows that most benchmarks' Pareto curves
feature a steady upward slope,
meaning that
decreasing accuracy consistently buys increasing speed.
Many applications could fruitfully use OpTuner\xspace
to explore the possibilities that this trade-off offers.
On most benchmarks OpTuner\xspace runs in a few minutes.
OpTuner\xspace's run time depends on several factors:
the number of use sites;
the complexity of the expression;
the number of input arguments;
and in a few cases the input range used.
On our test machine,
\nBenchmarksUnderThreeMinutes of the \nBenchmarks benchmarks complete in under three minutes
and \nBenchmarksUnderTenMinutes complete in under ten.
The remaining four benchmarks contain the most use sites and thus have
the most output configurations to verify and time.
OpTuner\xspace generates output configurations incrementally,
so for these slowest benchmarks,
users would have OpTuner\xspace's first configurations available much sooner,
usually a few minutes in.
\subsection{Detailed Analysis}
A close inspection of the OpTuner\xspace's selected configurations
demonstrates that these speedups often come from noticing
use sites that have little impact on accuracy.
Consider the benchmark \F{problem\_3\_3\_2},
originally from a mathematical textbook~\cite{nmse}:
\[
\begin{array}{l}
\K{require}\: 0 \le \mathit{x} \le 0.75 \land 0 \le \mathit{eps} \le 0.0078125\\
\K{return}\: \tan(\mathit{x} + \mathit{eps}) - \tan(\mathit{x})
\end{array}
\]
OpTuner\xspace mixes GLibC's \F{tan} for the first call and VDT's \F{tan} for the second
to give a \nDetailedOneSpeedup speedup over pure GLibC while only increasing
relative error from \nDetailedOneErrorGlibc to \nDetailedOneErrorChosen.
The first call to \F{tan} has a larger argument than the second
call to \F{tan}, and due to \F{tan}'s steep increase in the region just to the
right of $0$ this gives the first call a higher impact on overall accuracy.
OpTuner\xspace notices this and uses a more accurate implementation for
the first call than the second call.
OpTuner\xspace's optimizations can be even more subtle;
consider this complex sine benchmark:
\[
\begin{array}{l}
\K{require}\:0 \le \mathit{re} \le 10 \land 0 \le \mathit{im} \le 10\\
\K{return}\: (0.5 \cdot \sin(\mathit{re})) \cdot (\exp(-\mathit{im}) - \exp(\mathit{im}))
\end{array}
\]
The second call to \F{exp} requires more accuracy than the first
because $\mathit{im}$ is positive,
so the first \F{exp} returns smaller values than the second
and thus has less impact on the expression's error.
Meanwhile, the output of the \F{sin} call
is multiplied $\exp(-\mathit{im}) + \exp(\mathit{im})$
and its error is thus magnified.
In view of these effects,
OpTuner\xspace selects a high accuracy \F{sin} (such as CRLibM's)
and two different \F{exp} implementations
(say, order-9 and order-12 custom implementations)
along the speed-accuracy Pareto curve.
This unintuitive mix of implementations leads to a \nDetailedTwoSpeedup speedup
over an all GlibC configuration while only increasing error from
\nDetailedTwoErrorGlibc to \nDetailedTwoErrorChosen.
These same patterns occur far along the speed-accuracy Pareto curve.
Consider the \F{logexp} benchmark:
\[
\begin{array}{l}
\K{require}\:0 \le x \le 8 \\
\K{return}\: \log(1 + \exp (x))
\end{array}
\]
At lower accuracies OpTuner\xspace will select
VDT's float variation of \F{log}
and a custom order-7 \F{exp} implementation.
This yields a speedup of \nDetailedThreeSpeedup,
paid for an accuracy drop from \nDetailedThreeErrorGlibc to \nDetailedThreeErrorChosen.
As in all these examples, the most important thing to note
is the extensive expertise and time commitment necessary
to do a similar optimizations by hand.
\end{document}
\section{Conclusion}
\label{sec:conclusion}
OpTuner\xspace makes floating-point computations faster
by choosing the right implementation
of library functions like \F{exp} or \F{sin}.
OpTuner\xspace uses a linear error model
and integer linear programming
to select the best implementations to use
(from among standard mathematical libraries
and generated implementations)
for each use of a library function in a floating-point expression.
It then verifies the optimal configurations
and presents the user with a speed-accuracy Pareto curve
summarizing the available optimization options.
Across \nBenchmarks benchmarks,
OpTuner\xspace demonstrates speedups of up to \nBenchmarkLargeSpeedup,
with speedups of \nBenchmarkSafeSpeedup available
at negligible accuracy increases.
OpTuner\xspace thus demonstrates the possibilities
of a hitherto-underexplored avenue
for floating-point program optimization.
\end{document}
\section{Error and cost models}
\label{sec:error-and-cost-models}
The input to OpTuner\xspace is a floating-point expression $\tilde{E}$,
with no loops or control flow,
over some number of floating-point inputs;
for simplicity, this section refers to a single input $x_0$,
though generalizing to multiple inputs is straightforward.
In addition to the expression $\tilde{E}$,
the input must also contain an interval $I$
that the input $x_0$ is drawn from.
The core idea behind OpTuner\xspace,
as described in \Cref{sec:big-idea},
is the linear error model for a floating-point expression.
To compute the error model OpTuner\xspace uses error Taylor series~\cite{fptaylor}.
\subsection{Error model}
Take a floating-point expression $\tilde{E}$
generated by the grammar $e ::= \tilde{f}(e, e, \ldots) \mid x_0$.
In this paper, variables with tildes, like $\tilde{x}_i$,
represent floating-point values,
and the same variables without tildes, like $x_i$,
represent their true mathematical value
when computed without rounding error.
Each $\tilde{f}$ thus implements of some underlying function $f$;
floating-point constants like \F{PI}
can be considered zero-argument functions.
Transform the expression $\tilde{E}$ to a linear sequence of function calls
$\tilde{x}_n := \tilde{f_n}(\tilde{x}_{n-a_n}, \tilde{x}_{n-b_n}, \ldots)$,
where later function calls
may use the results of earlier calls as arguments,
and where the value of the expression as a whole
is the value of the last variable in the sequence, $\tilde{x}_N$.
By \cref{rdmodel},
$\tilde{x}_n = f_n(\tilde{x}_{n-a_n}, \tilde{x}_{n-b_n}, \ldots)(1 + \varepsilon_n) + \delta_n$.
Note that $\tilde{x}_N$ is thus a function of the $\varepsilon_n$s and $\delta_n$s.
When all $\varepsilon_n = \delta_n = 0$,
the result is $x_n$ computed without any error;
but $\varepsilon_n$ and $\delta_n$ are not equal to zero.
Instead they are small, unkown values
bounded by constants $\varepsilon_{f_n}$ and $\delta_{f_n}$.
Define the constants
\[
A^k_n = \max_{x \in I} \left( \frac{\partial \tilde{x}_k}{\partial \varepsilon_n}
\left[\begin{array}{l}0 / \varepsilon \\ 0 / \delta \end{array}\right] \right)
\;\text{and}\;
B^k_n = \max_{x \in I} \left( \frac{\partial \tilde{x}_k}{\partial \delta_n}
\left[\begin{array}{l}0 / \varepsilon \\ 0 / \delta \end{array}\right] \right)
\]
and $A_n = A^N_n$ and $B_n = B^N_n$.
Note that these constants are real numbers
and can be computed
by a one-dimensional global nonlinear optimization;
or, for expressions with multiple variables,
over as many dimensions as there are input variables.
Then the error of $\tilde{E}$ is:
\begin{equation}\label{errmodelformal}
|\tilde{x}_N - x_N| \le \sum_n A_n \varepsilon_{f_n} + \sum_n B_n
\delta_{f_n} + o(\varepsilon^2).
\end{equation}
Here, the $o(\varepsilon^2)$ term represents
the quadratic and higher-order terms
of the error Taylor series.
It can be bounded using Lagrange's theorem,
\[
o(\varepsilon^2) \le
\max_{x \in I} \left(
\sum_{u, v \in \{\varepsilon, \delta\}}
\sum_{i,j}
\frac{\partial^2 x_k}{\partial u_i \partial v_i}
\left[\begin{array}{l}0 / \varepsilon \\ 0 / \delta \end{array}\right]
u_{f_i}
v_{f_j}
\right),
\]
where the sums range over all pairs of $\varepsilon/\delta$ variables.
Importantly, since this bound involves higher powers
of the $\varepsilon_f$s and $\delta_f$s,
it tends to be insignificantly small.
It is necessary for soundness,
but is not particularly important for estimating the error.
\Cref{errmodelformal},
including the Lagrange bound for the higher-order terms,
is the traditional use of error Taylor series.
OpTuner\xspace instead drops the higher-order terms
and considers the remaining linear terms as
a function of the $\varepsilon$ and $\delta$ variables
that estimates $\tilde{E}$'s error
in terms of the function implementations it uses.
Note that typically, an expression contains operators
like addition and multiplication that OpTuner\xspace cannot tune.
In this case
some of the $\varepsilon$ and $\delta$s are fixed
and OpTuner\xspace folds those resulting terms into a constant.
\subsection{Cost model}
The complement to the linear error model is a linear cost model,
which estimates the speed of the expression
given the implementations chosen for each function call.
OpTuner\xspace uses a simple cost model:
\[
\mathit{cost} = \sum_n c_{f_n},
\]
where $c_f$ is the average runtime of the function implementation $\tilde{f}$.
To measure $c_f$, each implementation
is compiled and run
on \nTimingInputs random valid inputs
in a tight loop for \nTimingElapsed.
To try to get maximally accurate timings.
we use multiple measurements, input pre-generation, core binding,
and the \texttt{-O3 -march=native -mtune=native -DNDEBUG} compiler flags.
Normally, a simple sum of average runtimes is too simplistic:
it ignores the complexities of modern CPUs
and the details of input-dependent control flow.
Several factors make this model more appropriate in our setting.
OpTuner\xspace's goal is to find
all Pareto-optimal trade-offs between the error and cost models,
so the cost model only needs to be a \textit{relative order},
not a precise prediction of runtimes.
Plus, mathematical function implementations usually
have rare, easily-branch-predicted control flow;
use few if any data structures or complex memory access patterns;
and are generally compute-bound.
That makes average runtimes more meaningful
than for general-purpose code.
Finally, since OpTuner\xspace only changes the implementation of mathematical functions,
any computation outside a function implementation
will be the same across all configurations.
The cost model thus does not need to model those costs,
and is only predicting the costs of calls to shared libraries.
One caveat is necessary for achieving good results with this cost model:
the linear sequence of function calls $x_n = \tilde{f}_n(x_{n-a_n}, x_{n-b_n}, \ldots)$
must contain no duplicate entries representing common subexpressions.
Compilers commonly perform common subexpression elimination
to avoid recomputing the same expression twice.
Thus, if two subexpressions both compute $f(x_1, x_2)$,
and the first subexpression uses implementation $\tilde{f}_a$
while the second uses implementation $\tilde{f}_b$,
the cost is $c_a + c_b$ if these implementations are different
but only $c_a$ is both implementations are the more accurate of the two.
In other words, when common subexpressions exist,
it's best to use the same, more accurate implementation at both sites.
OpTuner\xspace thus performs common subexpression elimination
when converting expressions to a linear sequence of function calls,
and the cost and error models are built on this deduplicated sequence,
ensuring that common subexpressions use the same implementations.
\subsection{Mathematical Libraries}
\label{ssec:libraries}
\newcommand{\mr}[2]{\multirow{#1}{*}{#2}}
\newcommand{\mrd}[2]{\multirow{#1}{2em}{#2}}
\begin{figure}
\begin{subfigure}[t]{0.5\linewidth}
{\footnotesize
\begin{tabular}[t]{|c|l|r|r|l|} \hline
Func & Domain & Error & Cost & Library \\ \hline
\mr{5}{exp} & \mrd{5}{$[-1.79e^{308},$ $709.78]$} & 0.5 & 54.02 & CRLibM \\ \cline{3-5}
& & \mr{3}{1.0} & 10.71 & GLibC \\ \cline{4-5}
& & & 10.70 & OpenLibm \\ \cline{4-5}
& & & 10.78 & AMD LibM \\ \cline{3-5}
& & 5.0 & 5.32 & VDT \\ \hline
\mr{5}{log} & \mrd{5}{$[5.0e^{-324},$ $1.79e^{30}]$} & 0.5 & 32.93 & CRLibM \\ \cline{3-5}
& & \mr{3}{1.0} & 8.53 & GLibC \\ \cline{4-5}
& & & 8.53 & OpenLibm \\ \cline{4-5}
& & & 8.36 & AMD LibM \\ \cline{3-5}
& & 5.0 & 5.99 & VDT \\ \hline
\mr{6}{sin} & \mrd{5}{$[-1.79e^{308},$ $1.79e^{308}]$} & 0.5 & 35.27 & CRLibM \\ \cline{3-5}
& & \mr{3}{1.0} & 8.76 & GLibC \\ \cline{4-5}
& & & 8.76 & OpenLibm \\ \cline{4-5}
& & & 7.56 & AMD LibM \\ \cline{3-5}
& & 5.0 & 4.42 & VDT \\ \cline{2-5}
& \mr{1}{\tiny$[-0.78, 0.78]$} & 5.0 & 1.82 & VDT \\ \hline
\mr{6}{cos} & \mrd{5}{$[-1.79e^{308},$ $1.79e^{308}]$} & 0.5 & 34.35 & CRLibM \\ \cline{3-5}
& & \mr{3}{1.0} & 8.84 & GLibC \\ \cline{4-5}
& & & 8.82 & OpenLibm \\ \cline{4-5}
& & & 7.19 & AMD LibM \\ \cline{3-5}
& & 5.0 & 4.20 & VDT \\ \cline{2-5}
& \mr{1}{\tiny$[-0.78, 0.78]$} & 5.0 & 2.04 & VDT \\ \hline
\mr{5}{tan} & \mrd{5}{$[-1.79e^{308},$ $1.79e^{308}]$} & 0.5 & 80.20 & CRLibM \\ \cline{3-5}
& & \mr{3}{1.0} & 15.81 & GLibC \\ \cline{4-5}
& & & 16.00 & OpenLibm \\ \cline{4-5}
& & & 28.66 & AMD LibM \\ \cline{3-5}
& & 5.0 & 8.90 & VDT \\ \hline
\end{tabular}
}
\subcaption{Double precision implementations}
\end{subfigure}\hfill%
\begin{subfigure}[t]{0.5\linewidth}
{\footnotesize
\begin{tabular}[t]{|c|l|r|r|l|} \hline
Func & Domain & Error & Cost & Library \\ \hline
\mr{5}{expf} & \mrd{5}{$[-3.40e^{38},$ $88.72]$} & $\float{2.68}{8}$ & 5.06 & RLibM \\ \cline{3-5}
& & \mr{3}{$\float{4.03}{8}$} & 8.46 & GLibC \\ \cline{4-5}
& & & 4.86 & OpenLibm \\ \cline{4-5}
& & & 4.68 & AMD LibM \\ \cline{3-5}
& & $\float{1.76}{10}$ & 5.20 & VDT \\ \hline
\mr{5}{logf} & \mrd{5}{$[1.40e^{-45},$ $3.40e^{38}]$} & $\float{2.68}{8}$ & 6.26 & RLibM \\ \cline{3-5}
& & \mr{3}{$\float{2.76}{8}$} & 7.15 & GLibC \\ \cline{4-5}
& & & 7.13 & OpenLibm \\ \cline{4-5}
& & & 5.88 & AMD LibM \\ \cline{3-5}
& & $\float{5.45}{8}$ & 5.80 & VDT \\ \hline
\mr{6}{sinf} & \mrd{5}{$[-3.40e^{38},$ $3.40e^{38}]$} & \mr{3}{$\float{2.16}{9}$} & 7.13 & GLibC \\ \cline{4-5}
& & & 7.10 & OpenLibm \\ \cline{4-5}
& & & 7.64 & AMD LibM \\ \cline{3-5}
& & $\float{1.74}{10}$ & 4.69 & VDT \\ \cline{2-5}
& \mr{1}{\tiny $[-0.785, 0.785]$} & $\float{1.74}{10}$ & 1.60 & VDT \\ \hline
\mr{6}{cosf} & \mrd{5}{$[-3.40e^{38},$ $3.40e^{38}]$} & \mr{3}{$\float{2.16}{9}$} & 7.13 & GLibC \\ \cline{4-5}
& & & 7.10 & OpenLibm \\ \cline{4-5}
& & & 6.76 & AMD LibM \\ \cline{3-5}
& & $\float{1.74}{10}$ & 4.47 & VDT \\ \cline{2-5}
& \mr{1}{\tiny $[-0.785, 0.785]$} & $\float{1.74}{10}$ & 1.93 & VDT \\ \hline
\mr{5}{tanf} & \mrd{5}{$[-3.40e^{38},$ $3.40e^{38}]$} & \mr{3}{$\float{5.37}{8}$} & 8.50 & GLibC \\ \cline{4-5}
& & & 8.49 & OpenLibm \\ \cline{4-5}
& & & 7.03 & AMD Libm \\ \cline{3-5}
& & $\float{1.77}{10}$ & 8.32 & VDT \\ \hline
\end{tabular}
}
\subcaption{Single precision implementations}
\end{subfigure}
\caption{
The standard library implementations available to OpTuner\xspace.
Errors were found via documentation and source code comments
and are given in ``units in the last place'';
the actual $\varepsilon_f$ and $\delta_f$ values
are the listed error times $2^{-52}$ for $\varepsilon_f$ and $2^{-1022}$ for $\delta_f$.
There is a general trade-off between speed and accuracy,
though with a lot of heterogeneity between libraries and functions.
}
\label{fig:table}
\end{figure}
Implementations of mathematical functions
are usually gathered into libraries
that provide a large collection of functions
all at a similar point in the speed-accuracy trade-off.
These libraries broadly cover a spectrum
from faster, less-accurate implementations
to slower, more-accurate ones.
OpTuner\xspace ships with support for many of the most popular libraries,
covering a range of accuracies and speeds;
\Cref{fig:table} lists these libraries
and their error and cost model parameters
$D$, $\varepsilon_f$, $\delta_f$, and $c_f$.
The golden standard for function implementation are correctly rounded
implementations.
These yield the true mathematical result, rounded to floating-point;
this value is unique,
so all correctly-rounded libraries produce identical answers on all inputs.
Unfortunately, achieving this accuracy is still a topic of active research.
CRLibM provides correctly-rounded implementations
of many math functions in double precision,
but it is quite slower, usually by a factor of $5$--$10\times$,
than a traditional implementation.
Work on reducing this overhead is ongoing.
The recently-published RLibM library
achieves correct rounding and speed comparable to alternative libraries
using techniques from program synthesis and verification.
However, its techniques do not scale to 64-bit implementations,
so RLibM only provides 32-bit implementations
and furthermore only for a small set of mathematical functions
not including, for example, \F{sin} and \F{cos}.
Ultimately, neither CRLibM or Rlibm is (currently) in common use, showing that
most users have already decided on higher speed in exchange for lower
accuracy.
Standard system math libraries aim for nearly-correct rounding.
These libraries, which include GLibC, OpenLibm, and AMD Libm,
aim to achieve the highest possible performance
while allowing the least- or even second-least-significant bit to be incorrect.
Being marginally less accurate than CRLibM and RLibM
often allows them to be dramatically faster.
Consequently, these libraries are appropriate for general-purpose code,
where speed is a top-level concern
but where programmers do not have the expertise
to optimize the speed-accuracy trade-off further.
Different libraries in this category
use different implementation strategies
in order to achieve maximum speed,
including (often) custom implementations
for specific hardware architectures or generations.
For example, GLibC has roughly a dozen
architecture-specific implementations of the main mathematical functions.
In some domains, greater speed and lower accuracy are required;
for such programs, special-purpose mathematical libraries exist.
For example, the VDT library, developed by CERN,
allows for up to 3 incorrect bits,
two more than the standard system library
(more in single precision).
In exchange for lower accuracy,
VDT can be up to twice as fast
as the corresponding GLibC function
and also has some vectorization advantages.
VDT uses Pad\'e approximations (a variant on polynomial approximations)
and tunes them to slightly lower accuracy in order to achieve this speedup.
Finally, some applications are best run
at a speed-accuracy trade-off not represented
by any of the above libraries.
For such cases, MetaLibm provides a metaprogramming framework
ideal for generating new function implementations.
MetaLibm provides easy access to polynomial generation with Sollya,
a convenient cross-compilation mechanism,
and utility routines useful for writing function implementations.
Of particular interest is that MetaLibm implementations
can be parameterized;
for example, MetaLibm's \F{exp} implementation
can be parameterized by any number of polynomial terms.
Besides the specific implementations that ship with MetaLibm,
such as the parameterized \F{exp} implementation,
users can also use MetaLibm to write their own custom implementations.
Some libraries also provide multiple implementations of the same function
for tuning purposes.
The simplest case of this is providing different implementations
for single- and double-precision arguments:
single-precision versions are fundamentally less accurate due to rounding,
so different parameter choices are advised.
The single-precision versions also usually have a narrow input range.
Usually the single-precision version is not implemented independently;
instead it uses a truncated and rounded form
of the polynomial used for the double function.
(This is not optimal, but economizes on the high cost
of developing a novel function implementation.)
Some libraries also provide function implementations
valid over only a certain input range,
which allows those implementations to skip (or simplify) range reduction.
For example, the VDT library internally
contains implementations of \F{sin} and \F{cos} which are valid
only on the reduced range $[-\pi/2, \pi/2]$.
These types of implementations are intended to be used with external range
reduction, and are often not exposed at a library level, but using them
directly can lead to generous advantages in speed.
The bar to using these implementations
is proving that the input will be in the reduced range.
\end{document}
\section{Selecting optimal implementations}
\label{sec:optimization}
Between the various libraries listed above,
and the parameterized implementations from MetaLibm,
there are dozens of implementations
of \F{sin}, \F{cos}, \F{tan}, \F{exp}, and \F{log},
which makes selecting the right one a chore.
OpTuner\xspace uses its error and cost models
to encode the implementation selection problem
as an integer linear program
and select the right configurations automatically.
\subsection{Encoding Configuration Selection}
\begin{figure}
\newcommand{\eqnbox}[1]{\fbox{\textsc{#1}}\;}
\begin{mathpar}
\eqnbox{DefVar}
t_{i,j} \in \{ 0, 1 \} \and
\eqnbox{PickOne}
\sum_j t_{i, j} = 1 \and
\eqnbox{SetEps}
\varepsilon_i = \sum_j t_{i,j} \varepsilon_{f_j} \land
\delta_i = \sum_j t_{i,j} \delta_{f_j} \and
\eqnbox{MinErr}
\min \sum_i A_i \varepsilon_i + \sum_i B_i \delta_i \and
\eqnbox{SetCost}
c_i = \sum_j t_{i,j} c_{f_j} \and
\eqnbox{MinCost}
\min \sum_i c_i
\end{mathpar}
\caption{And integer-linear-program formulation of the implementation
selection problem.}
\label{fig:ilp-form}
\end{figure}
A valid implementation selection
must minimize both overall error and execution time
while making a discrete choice of implementation for each use site.
This naturally fits the integer linear programming paradigm;
a full integer linear program is given in \Cref{fig:ilp-form}.
The key decision variables for the linear program
are boolean variables that determine
which implementation is used at each use site:
$n \times m$ boolean variables $t_{i,j}$,
where $t_{i,j}$ is true if use site $i$ uses implementation $f_j$
(\textsc{DefVar}).
Note that for a fixed $i$, the $t_{i,j}$ sum to 1 (\textsc{PickOne}).
The two key constraints on these decision variables
are to minimize the error and cost models.
First, the $\varepsilon_i$, $\delta_i$, and cost $c_i$
of the chosen implementation for each use site $i$
are computed (\textsc{SetEps} and \textsc{SetCost}).
Note that these constraints embed
the $\varepsilon_f$, $\delta_f$, and $c_f$ constants
for the available implementations of each function.
Then, the error and cost models are minimized
in the integer linear program.
The cost model is just the sum of per-use-site costs,
so is simple to express (\textsc{MinCost}).
The error model, on the other hand,
is the linear expression described in \Cref{sec:error-and-cost-models}.
In our implementation
error Taylor series are computed
with FPTaylor~\cite{fptaylor}
and each optimization problem is solved
using the Gelpia~\cite{gelpia}
sound global nonlinear optimization engine.
To solve these constraints,
the integer-linear-program solver
must support two additional features.
The $\varepsilon_{f_j}$ and $\delta_{f_j}$ coefficients
in this linear program
typically vary dramatically in magnitude,
(rounding error can differ dramatically
between implementations).
Unfortunately, many common ILP solvers
produce errors or invalid solutions
when coefficients vary so widely,
likely due to rounding error inside the solver itself.
An exact rational ILP solver is thus necessary.
Furthermore, the error and cost models
are usually at odds with one another and
cannot be minimized simultaneously.
Instead of a single solution to the conflicting goals
there is a set of points where decreasing error must increase cost,
and vice versa.
The ILP solver in question must implement
a Pareto mode which can find this set automatically.
(Repeated ILP queries with a varying error bound also work,
but an in-solver Pareto mode is typically much more efficient.)
OpTuner\xspace uses Z3 as its ILP solver~\cite{z3};
Z3 uses exact rational arithmetic
and has an efficient Pareto mode.
A particularly handy aspect of Z3's Pareto modes
is that the points are generated sequentially, not all at once,
so users can start exploring OpTuner\xspace-suggested configurations
even while OpTuner\xspace is still running.
\subsection{Verification and Timing}
The Pareto-optimal solutions
to the integer linear program in \Cref{fig:ilp-form}
are Pareto-optimal for OpTuner\xspace's error and cost \textit{models}.
But \textit{modeled} and \textit{real} speed and accuracy,
differ enough to shift the position of the points.
OpTuner\xspace thus recomputes true error and measures actual speed in a post pass.
OpTuner\xspace's error model simplifies floating-point error in several ways.
For one, \cref{rdmodel} mildly overestimates floating point error.
Dropping higher-order terms from the error Taylor form
then underestimates error
when the $\varepsilon$ and $\delta$ values are large---%
that is, for particularly inaccurate function implementations.
Then, linearizing the error model in \cref{linearform}
overapproximates by ignoring correlations between different terms.
So, OpTuner\xspace recalculates the accuracy
of all configurations returned by the ILP solver
using FPTaylor's most accurate \F{fp-power2} mode.%
\footnote{
Unfortunately, incorporating fixes into the optimization problem
would require mixed, global optimization
with both linear and quadratic constraints (MIQP)
which is too difficult and slow for available solvers.
}
Since the recalculation is working with a fixed implementation selection,
the higher-order and correlation terms can be included
and a sound worst-case error bound can be returned.
OpTuner\xspace's cost model also oversimplifies.
Needless to say, modern CPUs are complex,
with features like out-of-order execution and branch prediction
that OpTuner\xspace's cost model ignores.
Runtime also typically depends on the larger application context;
a table-based function implementation runs much faster
if the table stays resident in cache.
OpTuner\xspace thus measures the speed
of each configuration returned by the ILP solver.
To make sure the measurement is accurate,
OpTuner\xspace uses the maximum-speed compiler flags,
averages multiple measurements,
pre-generates random valid inputs,
and binds the timing program to a core,
just like when computing $c_f$ for each implementation.
After accuracies are recalculated and speeds measured,
it is possible for some configurations returned by the ILP solver
to no longer be on the Pareto frontier---%
that is, for one of the returned points
to in fact be both faster and more accurate than another.
OpTuner\xspace filters out such points
by sorting returned points by actual speed,
and removing any points whose accuracy is not monotonically increasing.
This filtering is just a convenience for the user,
and removes, on average, only $26\%$ of the points.
Usually, the points removed by this process are still
quite close to the Pareto frontier;
however, removing these points
means the user needs to explore fewer configurations
and can find a good configuration more quickly.
\end{document}
\section{Case Study}
\label{sec:case_study}
Ray tracers are complex, numerically intense software
that can run for hours or even days:
the perfect target for OpTuner\xspace.
Moreover, ray tracers are naturally tolerant of inaccuracy
since they produce an image with only eight bits per color channel
and the resulting images are often further compressed by image and video codecs.
We therefore conducted a case study applying OpTuner\xspace to an expression extracted
from POV-Ray~\cite{povray},
a full-featured, widely-used, and mature ray tracer
in continuous development since 1992.
Searching POV-Ray's source code for calls to \F{sin} and \F{cos}
directed us to a custom table-based implementations
the two mathematical functions.
Related comments, commented-out code, and older releases
revealed that the developers of the 3.5 release, likely around 2004,
concluded that the system implementations of these functions
were too slow for their use case, and so wrote custom implementations
to exploit two features of their use case:
that POV-Ray only calls \F{sin} and \F{cos} with inputs between $-\pi$ and $\pi$;
and that POV-Ray can tolerate significant inaccuracy in the result.
These custom implementations are used to compute the following expression,
which is the input to OpTuner\xspace:
\begin{equation}\label{povprog}
\begin{array}{l}
\K{require}\: \theta, \phi \in [-\pi, \pi] \land n_x, n_y, n_z \in [-1, 1] \\
\K{let}\: c = \cos(\theta), d_y = \sin(\theta) \\
\K{let}\: d_x = c \cdot \cos(\phi), d_z = c \cdot \sin(\phi) \\
\K{return}\: n_x \cdot d_x + n_y \cdot d_y + n_z \cdot d_z
\end{array}
\end{equation}
This expression is the ``photon incidence computation'' in POV-Ray's ``caustics'' module.
Caustics are light effects like the lensing effects of glass or the
pattern at the bottom of a swimming pool;
to model these, POV-Ray shoots virtual photons at the scene
and calculates how these photons move using the photon incidence computation.
The expression above computes the reflected energy
of an incoming photon (with direction given by $\theta$ and $\phi$)
reflected from a surface with normal vector $n$.
Millions of photon paths must be used to achieve realistic results,
so photon incidence computation is a bottleneck,
responsible for as much as \nPovRayPhotonsPercent of POV-Ray's total runtime
when caustics are enabled.%
\footnote{
Speed is so important to POV-Ray
that the caustics model FAQ includes advice
on tuning the number of photons to trade off
between quality and run time~\cite{povray-wiki}.
Many POV-Ray scene files don't even enable caustics,
lowering the quality of the resulting render.
}
\subsection{Changing Function Implementations}
\begin{figure}
\begin{subfigure}[t]{.48\linewidth}
\includegraphics[width=\linewidth]{images/double_all_glibc.png}
\caption{\F{grenadine} rendered using GLibC \F{sin} and \F{cos}.}
\label{fig:grenadine-glibc}
\end{subfigure}%
\hfill%
\begin{subfigure}[t]{.48\linewidth}
\includegraphics[width=\linewidth]{images/double_all_const.png}
\caption{Same with $\F{sin}(x) = x$ and $\F{cos}(x) = -x$.}
\label{fig:grenadine-crappy}
\end{subfigure}%
\caption{
Two renderings of the \F{grenadine} scene using POV-Ray.
On the left, the reference rendering
uses GLibC's implementations of \F{sin} and \F{cos},
which is accurate but quite slow.
On the right, using crude approximations of \F{sin} and \F{cos}
is much faster, but leads to obvious visual artifacts
(look at the the orange slice, cocktail surface, and glass bottom).
We tested several variations and $\F{cos}(x) = -x$
was the fastest ``crude'' approximation.
}
\label{fig:grenadines}
\end{figure}
Developing a custom \F{sin} and \F{cos} implementation
for use in just this computation was a sharp insight
on the part of the POV-Ray developers.
Photon incidence spends almost all of its time
inside the \F{sin} and \F{cos} functions,
and the custom \F{sin} and \F{cos} implementations
are \nPovProgTableSpeedup faster%
\footnote{
Timing measurements in this section refer specifically to the version of POV-Ray
included in the SPEC 2017 benchmark suite,
though both modern versions as well as versions going back to 2004
contain code substantially similar to that discussed.}
than the system GLibC libraries.
These custom implementations use 255-entry tables
of \F{sin} and \F{cos} values between $-\pi$ and $\pi$,
similar to that shown in \Cref{fig:table-based}.
Of course, due to the limited size of the tables,
the custom \F{sin} and \F{cos} are also
significantly less accurate than the system libraries;
but the increased speed was worth it
to the POV-Ray developers.
This optimization demonstrates the expertise
that the POV-Ray developers are fortunate enough to poses.
But can we do better---can we find
even faster and more accurate implementations of \F{sin} and \F{cos}
for this particular expression?
For example, $\sin(x) \approx x$, at least for $x \approx 0$;
implementing \F{sin} and \F{cos} with such crude approximations
speeds up POV-Ray by another \nPovRayConstSpeedup
over and above the POV-Ray developers' version.
But now the cost in accuracy is too steep:
a standard test scene, \F{grenadine},
rendered with this ultra-fast \F{sin} implementation
looks like \Cref{fig:grenadine-crappy},
with unrealistic highlights and lighting effects
where glass interacts with the water in the drink or in the orange.
The resulting render is
very different from the ground truth in \Cref{fig:grenadine-glibc}
and looks worse than without caustics enabled at all.
Fortunately, there are dozens of implementations of \F{sin}
between the extremes of GLibC and $\sin(x) \approx x$.
OpTuner\xspace's linear \textit{error models} provide a simple way
to quantify the effect of different function implementations
and thereby search this space of possibilities.
OpTuner\xspace computes \Cref{povprog}'s error model as:
\begin{equation}\label{errmodel}
\mathcal{E} =
1.41 \varepsilon_{c1}
+ \varepsilon_{s1}
+ \varepsilon_{c2}
+ \varepsilon_{s2}
+ 1.41 \delta_{c1}
+ \delta_{s1}
+ \delta_{c2}
+ \delta_{s2}
+ \float{2.09}{-15}
\end{equation}
Here, $\mathcal{E}$ is the overall error of \Cref{povprog}
and the $\varepsilon$ and $\delta$ variables
measure the accuracy of each call to \F{sin} and \F{cos}.
For any given choice of \F{sin} and \F{cos} implementations,
\Cref{errmodel} estimates the impact
of that choice on accuracy, which can be used
to efficiently search for good implementation choices.
Note that unlike the error models in \Cref{sec:big-idea},
this error model includes a constant term, \float{2.09}{-15}.
This constant term represents error due from operators
that OpTuner\xspace cannot tune, in this case addition and multiplication.
\begin{figure}
\begin{subfigure}{.31\linewidth}
\includegraphics[width=\linewidth]{images/double_all_povray_diff.png}
\caption{Errors from POV-Ray's table-based \F{sin} and \F{cos}.}
\end{subfigure}%
\hfill%
\begin{subfigure}{.31\linewidth}
\includegraphics[width=\linewidth]{images/double_optuner_77_diff.png}
\caption{Errors from OpTuner\xspace's suggested configuration.}
\end{subfigure}%
\hfill%
\begin{minipage}{.31\linewidth}
\caption{
Differences from the reference rendering
for two tuned versions of POV-Ray.
On the left, POV-Ray's table-based \F{sin} and \F{cos}
has significant, easily-visible errors.
On the right, the chosen OpTuner\xspace configuration
produces minimal errors yet retains
almost all of the table-based version's speed.
OpTuner\xspace makes finding such configurations easy.
}
\label{fig:grenadine-compare}
\end{minipage}
\end{figure}
Plugging some values into the model gives a good feel
for the scale of errors from using differing implementations.
For the double precision implementations of both \F{sin} an \F{cos} provided by
GLibC the corresponding $\varepsilon$ and $\delta$ are
$\float{2.22}{-16}$ and $\float{5}{-324}$.
Using these values gives an overall error of $\float{3.07}{-15}$,
which goes some way toward explaining
why using GLibC generates the correct render in \Cref{fig:grenadine-glibc}.
The POV-Ray developers' implementations
have $\varepsilon = 0$ and $\delta = 0.02473$,
leading to an overall error of $0.11$,
$\float{3.56}{13}$ times larger than GLibC,
explaining some of the errors seen in \Cref{fig:grenadine-compare}.
The crude approximations of $\sin(x) = x$ and $\cos(x) = -x$,
meanwhile, produce an error of $16.28$
(for a value actually between $-1$ and $1$),
which explains the terrible rendering in \Cref{fig:grenadine-crappy}.
In other words, the error model makes it easy
to estimate how choosing certain function implementations
impacts the error of a floating-point expression.
\subsection{How OpTuner\xspace Works}
The error model is convenient
for sketching out the benefits of alternative function implementations.
Yet with two calls to \F{sin} and two calls to \F{cos},
each of which could use a different implementation,
\cref{povprog} has millions of possible configurations.
What's needed is a tool that uses \cref{errmodel}
to automatically elevate implementation choices
that optimally trade speed for accuracy.
OpTuner\xspace does just this.
Since only the application developers can decide
how much accuracy to trade for speed,
OpTuner\xspace outputs a \textit{speed-accuracy Pareto curve},
where each point on the curve
is the most accurate configuration possible at a given speed.
To derive this curve,
OpTuner\xspace combines the error model above
with a simple profiled \textit{cost model}
that estimates the time to evaluate each function implementation.
Importantly, both the error and cost models are linear,
which allows OpTuner\xspace to phrase the choice of implementation
as an integer linear program.
OpTuner\xspace can then use an off-the-shelf ILP solver
to compute points along the speed-accuracy Pareto curve.
For example, OpTuner\xspace can tune POV-Ray's photon incidence computation
against a collection of \nSinImpls \F{sin} implementations
and \nCosImpls \F{cos} implementations,
a space of \nPovRayPossible possible configurations.
Out of this vast search space,
OpTuner\xspace produces the speed-accuracy Pareto curve
shown in \Cref{fig:povray-expression},
with just \nPovProgConfigs configurations,
in \nPovProgOptunerTime.
Automating implementation selection with OpTuner\xspace
also makes novel optimizations possible.
For example,
a function implementations that is only called
on a restricted range of inputs
can often be faster without being less accurate.%
\footnote{Handling large input ranges
usually uses higher-precision arithmetic,
such as with Cody-Waite range reduction~\cite{cody-waite},
which is complex and expensive.}
OpTuner\xspace automates this optimization
by extending the integer linear program
to also compute bounds on the value of any expression,
allowing it to use restricted-range implementations
when their arguments are in range.
To make use of this,
OpTuner\xspace includes custom, reduced-range implementations
of \F{exp}, \F{log}, \F{sin}, \F{cos}, and \F{tan}
that are much faster than traditional, full range, implementations.
Normally, reduced-range implementations are dangerous,
since using them on out-of-range inputs can lead to disasterous results.
But the sound error bounds computed by OpTuner\xspace
make this complex and dangerous optimization easy and safe.
\subsection{Results}
The \nPovProgConfigs configurations chosen by OpTuner\xspace
are shown in \Cref{fig:povray-expression}.
Each point in that plot is a configuration---%
a choice of library implementation for each call to \F{sin} and \F{cos}---%
and its location on the plot gives that configuration's speed
and worst-case accuracy bound.
These configurations range from
an extreme-accuracy configuration,
which uses the verified CRLibM library for each call site
and is \nPovProgCrlibmAccuracyIncrease more accurate
and \nPovProgCrlibmSlowdown slower than GLibC,
to an extreme-speed configuration,
which uses custom implementations
and is \nPovProgFastSpeedup faster and
\nPovProgFastAccuracyDecrease less accurate than GLibC
(that is, it has a relative error of \nPovProgFastRelativeError).
Somewhere in between these extremes
is the red starred point in \Cref{fig:povray-expression},
which uses custom order 13/15 implementations for the \F{sin} calls
and a custom order 14 implementation for \F{cos},
all fit to the $[-\pi, \pi]$ input range.
This configuration is \nPovProgLosslessSpeedup faster
and \nPovProgLosslessAccuracyDecrease less accurate
than the GLibC configuration;
that makes it both faster and more accurate
than the POV-Ray developers' custom table-based \F{sin} and \F{cos},
shown with a green star in \Cref{fig:povray-expression}.
\begin{figure}
\begin{subfigure}{0.48\linewidth}
\includegraphics[width=\linewidth]{images/case_study_expression.png}
\caption{Speed-accuracy Pareto curve for \Cref{povprog}}
\label{fig:povray-expression}
\end{subfigure}%
\hfill%
\begin{subfigure}{0.48\linewidth}
\includegraphics[width=\linewidth]{images/case_study_end_to_end.png}
\caption{Speed-accuracy Pareto curve for POV-Ray}
\label{fig:povray-end2end}
\end{subfigure}
\caption{Speed vs. accuracy for various configurations of \Cref{povprog}.
On the left, speed and accuracy for just \Cref{povprog};
on the right, speed and accuracy for POV-Ray as a whole
(on the \F{grenadine} scene).
Speedup is normalized to the all-GLibC configuration.
OpTuner\xspace's configurations are marked in blue and red,
while the POV-Ray developers' custom implementation
is marked with a green star.
OpTuner\xspace's tuned configurations are both faster and more accurate
than the developers' custom implementation.
The orange circle in the graph on the right
relates to future work described in \Cref{sec:cs-methods}.
}
\end{figure}
Using OpTuner\xspace's suggested configurations
can lead to end-to-end application speedups.
We produced modified versions of POV-Ray
for each of OpTuner\xspace's suggested configurations
and plotted both their overall run time
and the quality of their outputs in \Cref{fig:povray-end2end}.%
\footnote{
Image quality is measured using
the structural similarity index measure~\cite{ssim},
a standard measure of image quality.
In particular, we use the SPEC 2017 benchmarking harness
to measure both SSIM and runtime.
More details of the methodology are given
in \Cref{sec:cs-methods}
}
POV-Ray is a naturally-error-tolerant program
as shown by the blue streak on the left-hand-side of the figure:
OpTuner\xspace's \nPovRaySatConfigs most accurate configurations
all render the reference image exactly.
Likewise, there's a limit to how much POV-Ray can be sped up
just by changing function implementation,
for Amdahl's-law-like reasons.
The red starred configuration hits both these limits,
with results identical to the reference rendering,
but produced roughly \nPovRayLosslessSpeedup faster.
By contrast, the green starred point,
which is the POV-Ray developers' implementation,
is both slower and has noticable errors
(\Cref{fig:grenadine-compare}).
Of course, it is up to the POV-Ray developers to decide
how much accuracy loss is acceptable
and how large a speed-up makes up for a given level of error.
But here, OpTuner\xspace's proposed configurations
are simultaneously faster and more accurate.
Moreover, the point marked in red is not the only option
produced by OpTuner\xspace;
the developers can experiment with different configurations
and easily find one that is faster and less accurate
if they so desire.
\end{document}
\section{Introduction}
\label{sec:introduction}
Floating-point arithmetic is foundational for scientific, engineering,
and mathematical software.
This is because, while floating-point arithmetic is approximate,
most applications tolerate minute errors~\cite{cern}.
In fact, a speed-accuracy trade-off
is ever-present in numerical software engineering:
mixed-and lower-precision floating-point~\cite{fptuner,precimonious,salsa,hifptuner},
alternative numerical representations~\cite{bfloat16,posit,block-numbers},
quantized or fixed-point arithmetic~\cite{fixed},
rewriting~\cite{pherbie},
and various forms of lossy compression~\cite{fpcompression1,fpcompression2}
all promise faster but less accurate programs.
In each case,
the challenge is helping the numerical software engineer
apply the technique
and explore the trade-offs available.
The implementation of library functions like \F{sin}, \F{exp}, or \F{log}
is one instance of this ever-present speed-accuracy trade-off.
Traditional library implementations, such as those in GLibC,
guarantee that all but maybe the last bit are correct.
This high accuracy comes at a cost:
these traditional implementations tend to be slow.
Recent work shows that substantial speed-ups are possible%
~\cite{cern,metalibm,daisy-libm,vanover}
if the accuracy requirement is relaxed.
But achieving that speed-up in practice is challenging,
because it requires carefully selecting
among alternate function implementations~\cite{intel,cern,amd,openlibm},
and proving accuracy bounds for the tuned program.
All this requires manual effort and deep expertise,
along with a substantial investment of time and effort.
We propose OpTuner\xspace, a sound, automatic tool
for exploring the speed-accuracy trade-offs of library function implementations.
For any floating-point expression,
OpTuner\xspace selects the best \F{exp}, \F{log}, \F{sin}, \F{cos}, or \F{tan}
implementation to use for each call site in the program
and presents the user with a speed-accuracy Pareto curve.
This Pareto curve
shows only the best-in-class tuned implementations,
condensing millions of possible configurations
into a few dozen that the user can rapidly explore
to speed up their computation.
Each point on the curve is also annotated
with a rigorously-derived sound error bound
allowing non-experts to understand
its impact on the accuracy of their code.
OpTuner\xspace's key insight
is that error Taylor series, a state of the art technique
for bounding floating-point error,
can be extended to derive
a \textit{linear error model}
that predicts the error of the expression
based on the error of the individual function implementations used.
This linear error model is combined
with a simple, linear, cost model for expression run time
to create an integer linear program
whose discrete variables encode the choice
of function implementation for each use site.
An off-the-shelf integer linear programming solver
is then be used to rapidly search
through millions of possible implementation choices
to find the points along the speed-accuracy Pareto curve
for the input expression.
The error and speed is then verified by timed execution and computation of a
sound error bound before being
presented to the user.
One of the benefits of this approach
is that OpTuner\xspace can perform optimizations
too difficult or nit-picky for humans to perform.
We illustrate this
by introducing custom implementations
for \F{exp}, \F{log}, \F{sin}, \F{cos}, and \F{tan}
that are only valid on a restricted range of inputs.
The restricted range allows
the use of simplified range reduction methods
that are much faster than a traditional implementation.
Using these new implementations requires proving
that their input is within a certain range of values,
even when taking into account
the rounding error incurred computing that input.
We extend OpTuner\xspace to automatically perform such proofs,
and therefore transparently mix
these range-restricted implementations with existing libraries
to achieve even better speed-accuracy trade-offs.
We evaluate OpTuner\xspace on \nBenchmarks standard benchmarks
from the FPBench 2.0~\cite{fpbench} and Herbie 1.5 suites~\cite{herbie}.
OpTuner\xspace tunes these benchmarks using
\nOptunerImpls implementations
of \F{sin}, \F{cos}, \F{tan}, \F{exp}, and \F{log},
ranging in accuracy across \nOptunerImplErrorOrders different orders of magnitude
and with speeds that vary by a factor of \nOptunerImplSpeed.
OpTuner\xspace can provide a speedup of \nBenchmarkSafeSpeedup
while maintaining high accuracy,
and for error-tolerant applications
the OpTuner\xspace-optimized benchmarks
are up to \nBenchmarkLargeSpeedup faster
than ones that use the GLibC implementations.
To highlight the benefits of OpTuner\xspace,
we perform a case study with the POV-Ray ray tracer.
POV-Ray is a state-of-the-art CPU ray tracer
and part of the SPEC 2017 benchmark collection.
We find that POV-Ray
spends a substantial portion of its runtime
inside calls to \F{sin} and \F{cos},
and the POV-Ray developers
maintain custom \F{sin} and \F{cos} implementations
that are faster but less accurate
in order to achieve acceptable speed.
We show that OpTuner\xspace can automate this kind of optimization,
achieving an end-to-end \nPovRayLosslessSpeedup speed-up
with no loss in output quality.
This is both faster and higher quality
than the POV-Ray developers' own efforts.
Moreover, other points on OpTuner\xspace's speed-accuracy Pareto curve
could be useful to the POV-Ray developers
or even to users with complex geometries.
\medskip
\noindent
In summary, our main insight
is that error Taylor series can be used
to derive a \textit{linear error model}
for the accuracy of a floating-point expression
in terms of the function implementations it uses.
That allows us to construct OpTuner\xspace, a tool with:
\begin{itemize}
\item Accuracy specifications for widely used mathematical libraries (\Cref{sec:implementations});
\item Automatically-derived linear cost models for error and runtime (\Cref{sec:error-and-cost-models});
\item An integer linear formulation of the implementation selection problem (\Cref{sec:optimization});
\item Extensions to handle function implementations with restricted input ranges (\Cref{sec:ranges});
\item Fast, range-restricted implementations of \F{exp}, \F{log}, \F{sin}, \F{cos}, and \F{tan}.
\end{itemize}
\Cref{sec:evaluation} demonstrates
that by leveraging these components
OpTuner\xspace can dramatically speed up standard floating-point benchmarks
with minimal loss of accuracy.
\end{document}
\section{Appendix: Case Study Methodology}
\label{sec:cs-methods}
To evaluate POV-Ray's speed and accuracy
for different function implementation configurations,
we leveraged the SPEC 2017 benchmark suite,
which includes POV-Ray.
SPEC 2017 includes a standard compilation harness
and a standard quality measure,
the structural similarity index measure~\cite{ssim},
which assigns each $8\times8$ pixel block a score from $-1$ to $+1$,
with $+1$ indicating an exact match.
The minimum block score is then used to evaluate image quality,
with scores over \nSpecThreshold considered acceptable.
The benchmark scene used by SPEC does not use the photons feature,
but POV-Ray ships many standard scenes to demonstrate its capabilities,
and we use one of those, \F{grenadine},
to avoid creating our own contrived example.
The version of POV-Ray included in SPEC 2017
includes and uses the custom \F{sin} and \F{cos} implementations
described in \Cref{sec:case_study}.
These implementations are quite simplistic;
a condensed version of \F{sin} is shown in \Cref{fig:table-based}.
The input $x$ is converted to an integer from $0$ to $254$
by simple linear transformation:
$i = (x / \pi + 1) * 127$, rounded down.
Then a hard-coded table is used to look up $\sin((i - 127)*\pi / 127) \pi$.
This implementation is quite inaccurate---%
$i$ only has 8 bits of information---%
but is also quite fast, likely because during a tight loop
the hard-coded table stays loaded in cache.
OpTuner\xspace's fastest implementations, meanwhile, are all polynomial-based.
Nonetheless, some of the configurations it finds
are both faster and more accurate than the POV-Ray implementations,
suggesting that OpTuner\xspace could have helped the POV-Ray developers
speed up caustics.
One challenge in this evaluation is the choice of baseline.
SPEC uses POV-Ray's custom table-based implementations
to generate its reference image,
but as mentioned above those implementations are inaccurate.
We therefore modified POV-Ray
to use the \F{sin} and \F{cos} implementations from GLibC,
which POV-Ray had historically used
(prior to the development of the custom table-based implementations),
and used that implementation
to generate our reference images as well as our performance baseline.
We also verified
that a rendering using CRLibM's~\cite{crlibm} \F{sin} and \F{cos}
produces the exact same image;
since CRLibM is maximally accurate,
this further justifies the use of GLibC as a baseline.
Code comments in the POV-Ray source code
confirm that before POV-Ray added
its custom \F{sin} and \F{cos} implementations,
it used GLibC (or other system math library) implementations,
making this baseline historically plausible.
To use OpTuner\xspace with POV-Ray,
we first extracted the expression seen in \Cref{povprog}
and recorded it in FPCore, OpTuner\xspace's input language.
The bounds on the input variables were easily established
since the angle values were already known to be bounded
and the $n$ values come from a unit normal.
We then ran OpTuner\xspace to generate the configurations
along the speed-accuracy Pareto curve.
For each resulting configuration,
we produced a patched version of POV-Ray
by injecting the source code
for all of OpTuner\xspace's supported implementations into POV-Ray
and using macros and compiler flags to select which one is used.
The SPEC harness was then used
to determine both the speedup and the quality of the resulting rendering.
This allows us to measure OpTuner\xspace's outputs
not just in terms of the isolated extracted expression
but also in end-to-end real terms
for a large and performance-sensitive software project.
Besides the change in function implementations,
the POV-Ray developers made a second change
to the photon incidence computation,
again trading away accuracy to gain speed,
but in this case by modifying the storage format
instead of by changing the implementation of functions.
Specifically, instead of storing incidence angles as double-precision values,
as prior POV-Ray releases and commented-out code did,
they changed some internal data structures
to store the index $i$ directly.
Since indices can be stored in a single byte,
this reduces the memory used for the photon table%
\footnote{It also seems to reduce padding and alignment issues,
since double-precision values have to be 8-byte aligned on our system.}
which speeds POV-Ray up by a further \nPovRayCharSpeedup,
resulting in the speed and accuracy shown by the orange circle
in \Cref{fig:povray-end2end}.
This is faster than the best speed-up achievable
by tuning function implementations alone.
OpTuner\xspace only supports double-precision computation
and cannot make storage optimizations,
so it cannot directly propose a similar optimization.
That said, we did make some ad-hoc modifications to OpTuner\xspace
to generate error models for 8-bit inputs
and to produce a speed-accuracy Pareto curve with them.
OpTuner\xspace is again able to find configurations
both faster and more accurate than that used in POV-Ray.
This is possible because POV-Ray's implementation
is still inaccurate, even for 8-bit inputs,
because when building the table it evaluates \F{sin}
at the location corresponding to index $i$,
instead of the location corresponding to $i + \frac12$.
These results are tentative:
our ``8-bit'' function implementations are just
wrapped versions of our double-precision implementations,
and OpTuner\xspace's support for 8-bit values is limited.
That said, these results suggest that
precision tuning along the lines of FPTuner~\cite{fptuner} or POP~\cite{pop}
could be combined with OpTuner\xspace's tuning of function implementations
to suggest even faster and more accurate configurations.
\end{document}
\section{The Big Idea in One Formula}
\label{sec:big-idea}
Floating-point arithmetic deterministically
approximates real-number arithmetic.
The error of this approximation
is given the rounding model
$y(1 + \varepsilon) + \delta$,
which formally states
\begin{equation}\label{rdmodel}
\forall\:x \in D,
\exists\:|\varepsilon_x| \le \varepsilon_f,
|\delta_x| \le \delta_f,
\quad
\tilde{f}(x) = f(x) (1 + \varepsilon_x) + \delta_x,
\end{equation}
In other words,
a floating-point computation $\tilde{f}(x)$
is equal to its true mathematical value $f(x)$,
but with a relative error of $\varepsilon_x$
(bounded by $\varepsilon_f$)
and an absolute error of $\delta_x$
(bounded by $\delta_f$).
Both $\varepsilon_x$ and $\delta_x$ are necessary
to bound the error for both normal and subnormal numbers.%
\footnote{This is more important in our context
than in traditional uses of error Taylor series,
because $\delta_f$ can be quite large
for some function implementations.}
The constants $\varepsilon_f$ and $\delta_f$,
depend on the particular function implementation $\tilde{f}$
and characterize its accuracy.
\subsection{Error Taylor Series}
\label{ssec:aspec}
\Cref{rdmodel} bounds the error of a single call to $f$,
but a floating-point expressions calls multiple functions,
and their errors interact to affect
the \emph{overall} error of that expression.
Consider the composition $\tilde{f}(\tilde{g}(x))$.
Expanding according to \cref{rdmodel} yields
\begin{equation}\label{exfn}
\tilde{f}(\tilde{g}(x)) = f(g(x)(1 + \underbrace{\varepsilon_1) + \delta_1}_{\text{from }\tilde{g}})(1 + \underbrace{\varepsilon_2) + \delta_2}_{\text{from }\tilde{f}}
\end{equation}
Here, the $\varepsilon_1$, $\delta_1$, $\varepsilon_2$, and $\delta_2$ terms
are variables bounded by constants $\varepsilon_f$, $\delta_f$, $\varepsilon_g$, and $\delta_g$
that characterize the error of $\tilde{f}$ and $\tilde{g}$.%
\footnote{The difference between, say, $\varepsilon_1$ and $\varepsilon_f$
is subtle---the first represents the actual rounding error,
while the second represents a worst-case error bound.
The reader can ignore likely the difference without much harm.}
Error Taylor series are a state-of-the-art technique
to bound the maximum error of this expression
based on the insight
that the $\varepsilon$ and $\delta$ parameters are always small.
The core idea is to expand \Cref{exfn}
as a Taylor series in the $\varepsilon$s and $\delta$s:
\[
\tilde{f}(\tilde{g}(x)) =
f(g(x)) + f'(g(x))g(x)\varepsilon_1 + f'(g(x))\delta_1
+ f(g(x))\varepsilon_2 + \delta_2 + o(\varepsilon^2)
\]
The first term in this Taylor series represents the exact output,
so the other terms represent the error.
Ignore for a moment the higher-order terms represented by $o(\varepsilon^2)$ as
they are usually insignificant;
the other four linear terms are called
the \textit{first-order error} of the computation.
Since these four terms are linear
in the $\varepsilon$ and $\delta$ terms,
the maximum error occurs
when each $\varepsilon$ and $\delta$
has the largest possible magnitude
and the same sign as the term it is multiplied by:
\begin{equation}\label{taylorform}
|\tilde{f}(\tilde{g}(x)) - f(g(x))| \le
\max_x \left( |f'(g(x))g(x)| \varepsilon_g \\ +
|f'(g(x))| \delta_g +
|f(g(x))| \varepsilon_f +
| 1 | \delta_f + o(\varepsilon^2) \right)
\end{equation}
Note that $\varepsilon_f$ and similar are constants, not variables,
so bounding the maximum error of the linear terms
just requires optimizing a complicated function of $x$,
which can be done using a global nonlinear optimization package.
The higher-order terms can also be bounded,
via Lagrange's theorem for the remainder of a Taylor series,
again using global non-linear optimization.%
\footnote{
Typically, the higher-order terms are too small to make a difference,
but they are necessary to establish a sound error bound.}
Error Taylor series thus provide
an elegant, rigorous, and relatively accurate way
to bound the error of an arbitrary floating-point expression.
Recent work
focuses on automating this idea~\cite{fptaylor}
and scaling it larger programs~\cite{satire}.
\subsection{The Idea}
OpTuner\xspace's key insight is to treat $\varepsilon_f$ and $\delta_f$
not as constants but as variables.
By triangle inequality,
\begin{multline}\label{linearform}
| \tilde{f}(\tilde{g}(x)) - f(g(x)) | \le
\max_x \left( |f'(g(x))g(x)| \varepsilon_g + |f'(g(x))| \delta_g + |f(g(x))|
\varepsilon_f + | 1 | \delta_f \right) \le \\
\underbrace{\left( \max_x |f'(g(x))g(x)| \right)}_{\text{constant }A_1} \varepsilon_g
+ \underbrace{\left( \max_x |f'(g(x))| \right)}_{\text{constant }B_1} \delta_g
+ \underbrace{\left( \max_x |f(g(x))| \right)}_{\text{constant }A_2} \varepsilon_f
+ \underbrace{\left( \max_x | 1 | \right)}_{\text{constant }B_2} \delta_f
\end{multline}
The coefficients $A_i$ and $B_i$
in front of each $\varepsilon_f$ and $\delta_g$
are numbers that can be directly computed
using a global nonlinear optimizer.
This simple rearrangement thus
converts the error Taylor series from a simple numeric bound
to a linear \emph{error model}
that gives the accuracy of the overall expression
in terms of the errors of each individual function implementation.%
\footnote{
This derivation focuses on bounding absolute error,
but an analogous error form can be derived for the relative error
by divided each coefficient by $|f(g(x))|$.}
OpTuner\xspace uses this linear error model in an integer linear program
to search for optimal speed-accuracy trade-offs
and then presents those trade-offs to the user.
\end{document}
\section{Related Work}
\label{sec:relwork}
Implementing mathematical functions in floating point has a long history.
\citet{kahan, kahan-log}, \citet{higham},
\citet{muller}, and \citet{cody-waite}
all made monumental contributions to the field.
These authors all leveraged earlier work on approximation theory
developed by mathematicians like Pafnutiy Chebyshev
and Charles-Jean de la Vall\'ee Poussin.
Robin Green's recent talks on the topic~[\citeyear{faster-math-functions,even-faster-math-functions}]
are a good introduction to and survey of the field.
Standard library implementations tend to be accurate
to within 1 or a few ulps~\cite{glibc-accuracy},
but some implementations have been produced
with a ``gold-standard'' accuracy of a half ulp,
including MPFR~\cite{mpfr} and CRLibm~\cite{crlibm}.
Most implementations of library functions like \F{exp} or \F{sin}
are manually verified, and bugs are sometimes discovered~\cite{intel-sin,faster-math-functions}.
However, a few of the Intel Math Kernel Library implementations
of functions like \F{log}, \F{sin}, and \F{tan} have been verified
with semi-automated methods~\cite{verified-math-h},
and some verified synthesis techniques are available~\cite{jay-p-lim}.
OpTuner\xspace could these libraries or any other libraries.
Using lower-accuracy library function implementations
is an established, if infrequent, program optimization technique.
The CERN math library
used in OpTuner\xspace, VDT \cite{cern},
was created to allow developers to manually tune this tradeoff.
VDT is also carefully optimized for SIMD support,
which OpTuner\xspace does not currently attempt.
There are other similar libraries that OpTuner\xspace does not yet incorporate
such as
Intel MKL~\cite{mkl}, CEPHES~\cite{cephes},
and VC's math functions~\cite{vc}.
\citet{daisy-libm} have attempted to automate
the implementation selection problem
in the Daisy numerical compiler~\cite{daisy}.
In a certain sense,
these authors approach a similar problem to OpTuner\xspace, but in reverse.
In their approach,
Daisy starts by analyzing the user's expression
to derive an accuracy bound for each call to a library function.
Daisy then leverages MetaLibm's
parametric implementations~\cite{metalibm}
to generate a custom implementation for this accuracy bound.
We experimented with using MetaLibm in a similar way.
However, we ultimately found that enumerating the space
of possible library function implementations was a superior approach,
not only because it searches over
a broader range of implementation choices
than MetaLibm's parameterized implementations
but also because it allows for much more accurate error estimation
and thus greater speedups.
Daisy also returns a single implementation,
while OpTuner\xspace returns the full speed-accuracy Pareto curve.
While not specific to floating point, the Green framework~\cite{green-frame}
does allow replacing math functions with faster variations in the spirit of
approximate computing.
Instead of relying on error analysis, the code under test must be accompanied
by a quality of service metric.
Green provides statistical metrics but does not guarantee worst case behavior.
Another downside of this approach is that it scales linearly
in the number of possible implementation configurations,
which itself grows combinatorially in the number of available implementations and call sites.
Several tools attempt to
speeding up floating point computation
by computing intermediate values to lower precision.
Precimonious~\cite{precimonious} approaches the problem by sampling points and
dynamically testing the speed and error while lowering precision of
intermediates in a random search.
Blame Analysis~\cite{prec-blame}
instead dynamically determines which intermediates have low impact on error,
and then select those intermediates as candidates for lowering.
HiFPTuner~\cite{hifptuner} improves further upon this method
by performing a static analysis of the expression
to group intermediates and hierarchically search the space of precisions.
CRAFT~\cite{lam} is similar to this line of work,
but performs the dynamic analysis at a binary level.
None of these tools can guarantee a sound error bound.
FPTuner~\cite{fptuner}, on the other hand, performs precision tuning
while also guaranteeing an overall error bound.
Its use of error Taylor forms and integer linear programming
was an inspiration for OpTuner\xspace.
Optimizing value precision is orthogonal to OpTuner\xspace's purpose,
and could potentially integrated into OpTuner\xspace.
Other tools improve the accuracy of a floating point expression without an explicit
concern for speed.
The Herbie~\cite{herbie} and Salsa~\cite{salsa} tools
attempt to increase the accuracy of a floating-point expression
by rewriting it using algebraic and analytic identities.
While these tools do not consider speed,
they do sometimes discover rewrites
that both increase accuracy and improve runtime~\cite{herbie}.
More recently, the Herbie authors have added support
for combining rewriting with precision tuning
to explore the speed-accuracy trade-off of lower-precision arithmetic~\cite{pherbie}.
Finally, the \textsc{Stoke} tool uses stochastic search over assembly instructions
to improve runtime without much reducing accuracy~\cite{stoke-fp}.
While this sometimes discovers valuable algebraic rearrangements,
this approach cannot implement a complex library function like \F{exp} or \F{sin}.
\textsc{Stoke} also cannot bound the worst-case error
of its tuned floating-point expressions;
it can only bound the difference between the original and optimized version.
In any case, none of these tools currently considers
changing the implementation of library functions as OpTuner\xspace does.
Integrating OpTuner\xspace with these tools
would likely discover new speedups and further refine
the speed-accuracy Pareto curves discovered.
\end{document}
| {'timestamp': '2021-07-14T02:05:51', 'yymm': '2107', 'arxiv_id': '2107.05761', 'language': 'en', 'url': 'https://arxiv.org/abs/2107.05761'} | arxiv |
\section{Introduction}
The field of boosting has been started from a classic question in learning theory asking whether classifiers that are just slightly better than random guessing can be used to create a classifier with arbitrarily high accuracy when given enough training data.
This question was initially asked by Kearns and Valiant \citep{kearns1988learning,kearns1994cryptographic} and ignited the line of research that eventually lead to the development of AdaBoost~\citep{freund1997decision}, the prototype boosting algorithm to date.
AdaBoost carefully combines the predictions of several inaccurate classifiers trained with a focus on different parts of the training data to come up with a voting classifier that performs well everywhere.
We quantify the performance of an inaccurate learner by its \emph{advantage} $\gamma$ over random guessing.
Said loosely, a $\gamma$\emph{-weak learner} will correctly classify new data points with probability at least $1/2+\gamma$.
In contrast, given $0< \varepsilon,\delta < 1$ and enough training data a \emph{strong learner} outputs with probability $1-\delta$ over the choice of the training data and possible random choices of the algorithm a hypothesis that correctly classifies new data points with probability at least $1-\varepsilon$.
The number of samples $m(\varepsilon,\delta)$ such that the learning algorithm achieves the desired accuracy and confidence levels is called the \emph{sample complexity}.
The sample complexity is the key metric for the performance of a strong learner and depends on the weak learner's advantage $\gamma$, the weak learner's flexibility measured in terms of the VC-dimension, as well as $\varepsilon$ and $\delta$.
Essentially, a construction with low sample complexity makes the most out of the available training data.
AdaBoost~\citep{freund1997decision} is the classic algorithm for constructing a strong learner from a $\gamma$-weak learner.
If the weak learner outputs a hypothesis from a base set of hypotheses $\mathcal{H}$, then AdaBoost constructs a strong learner by taking a weighted majority vote among several hypotheses $h_1,\dots,h_t$ from $\mathcal{H}$.
Each of these hypotheses is obtained by invoking the $\gamma$-weak learning algorithm on differently weighted versions of a set of training samples $S$.
The number of samples required by AdaBoost for strong learning depends both on the advantage $\gamma$ of the weak learner and the complexity of the hypothesis set $\mathcal{H}$.
If we let $d$ denote the VC-dimension of $\mathcal{H}$, i.e. the cardinality of the largest set of data points $x_1,\dots,x_d$ such that every classification of $x_1,\dots,x_d$ can be realized by a hypothesis $h \in \mathcal{H}$, then it is known that AdaBoost is a strong learner, which for error $\varepsilon$ and failure probability $\delta$, requires
\begin{align}
\label{eq:ada}
O\left(\frac{d \ln(1/(\varepsilon \gamma)) \ln(d/(\varepsilon \gamma))}{\varepsilon \gamma^2} + \frac{\ln(1/\delta)}{\varepsilon} \right),
\end{align}
samples.
This sample complexity is state-of-the-art for producing a strong learner from a $\gamma$-weak learner.
However, is this the best possible sample complexity? This is the main question we ask and answer in this work.
First, we present a new algorithm for constructing a strong learner from a weak learner and prove that it requires only
\begin{align*}
O\left(\frac{d}{\varepsilon \gamma^2} + \frac{\ln(1/\delta)}{\varepsilon} \right)
\end{align*}
samples.
In addition to improving over AdaBoost by two logarithmic factors, we complement our new algorithm by a lower bound, showing that any algorithm for converting a $\gamma$-weak learner to a strong learner requires
\begin{align*}
\Omega\left(\frac{d}{\varepsilon \gamma^2} + \frac{\ln(1/\delta)}{\varepsilon}\right)
\end{align*}
samples.
Combining these two results, we have a tight bound on the sample complexity of weak to strong learning.
In the remainder of the section, we give a more formal introduction to weak and strong learning as well as present our main results and survey previous work.
\subsection{Weak and strong learning}
Consider a binary classification task in which there is an unknown concept $c : \mathcal{X} \to \{-1,1\}$ assigning labels to a ground set $\mathcal{X}$. The goal is to learn or approximate $c$ to high accuracy.
Formally, we assume that there is an unknown but fixed data distribution $\mathcal{D}$ over $\mathcal{X}$.
A learning algorithm then receives a set $S$ of i.i.d. samples $x_1,\dots,x_m$ from $\mathcal{D}$ together with their labels $c(x_1),\dots,c(x_m)$ and produces a hypothesis $h$ with $h \approx c$ based on $S$ and the labels.
To measure how well $h$ approximates $c$, it is assumed that a new data point $x$ is drawn from the same unknown distribution $\mathcal{D}$, and the goal is to minimize the probability of mispredicting the label of $x$.
We say that a learning algorithm is a weak learner if it satisfies the following:
\begin{definition}
\label{def:weak}
Let $\mathcal{C} \subseteq \mathcal{X} \to \{-1,1\}$ be a set of concepts and $\mathcal{A}$ a learning algorithm. We say that $\mathcal{A}$ is a $\gamma$\emph{-weak learner} for $\mathcal{C}$, if there is a constant $\delta_0 < 1$ and an integer $m_0 \in \mathbb{N}$, such that for every distribution $\mathcal{D}$ over $\mathcal{X}$ and every concept $c \in \mathcal{C}$, when given $m_0$ i.i.d. samples $S=x_1,\dots,x_{m_0}$ from $\mathcal{D}$ together with their labels $c(x_1),\dots,c(x_{m_0})$, it holds with probability at least $1-\delta_0$ over the sample $S$ and the randomness of $\mathcal{A}$, that $\mathcal{A}$ outputs a hypothesis $h : \mathcal{X} \to \{-1,1\}$ such that
\begin{align*}
\mathcal{L}_{\mathcal{D}}(h) ~=~ \Pr_{x \sim \mathcal{D}}\big[h(x) \neq c(x)\big] ~\leq~ 1/2-\gamma.
\end{align*}
\end{definition}
A $\gamma$-weak learner thus achieves an advantage of $\gamma$ over random guessing when given $m_0$ samples.
Note that $\mathcal{A}$ knows neither the distribution $\mathcal{D}$, nor the concrete concept $c \in \mathcal{C}$ but achieves the advantage $\gamma$ for all $\mathcal{D}$ and $c$.
In contrast, a strong learner can obtain arbitrarily high accuracy:
\begin{definition}
Let $\mathcal{C} \subseteq \mathcal{X} \to \{-1,1\}$ be a set of concepts and $\mathcal{A}$ a learning algorithm. We say that $\mathcal{A}$ is a \emph{strong learner} for $\mathcal{C}$, if for all $0 < \varepsilon, \delta < 1$, there is some number $m(\varepsilon,\delta)$ such that for every distribution $\mathcal{D}$ over $\mathcal{X}$ and every concept $c \in \mathcal{C}$, when given $m=m(\varepsilon,\delta)$ i.i.d. samples $S=x_1,\dots,x_{m}$ from $\mathcal{D}$ together with their labels $c(x_1),\dots,c(x_{m})$, it holds with probability at least $1-\delta$ over the sample $S$ and the randomness of $\mathcal{A}$, that $\mathcal{A}$ outputs a hypothesis $h : \mathcal{X} \to \{-1,1\}$ such that
\begin{align*}
\mathcal{L}_{\mathcal{D}}(h) ~=~ \Pr_{x \sim \mathcal{D}}\big[h(x) \neq c(x)\big] ~\leq~ \varepsilon.
\end{align*}
\end{definition}
The definition of a strong learner is essentially identical to the classic notion of $(\varepsilon,\delta)$-PAC learning in the realizable setting.
Unlike the $\gamma$-weak learner, we here require the learner to output a classifier with arbitrarily high accuracy ($\varepsilon$ small) and confidence ($\delta$ small) when given enough samples $S$.
Kearns and Valiant \citep{kearns1988learning,kearns1994cryptographic} asked whether one can always obtain a strong learner when given access only to a $\gamma$-weak learner for a $\gamma > 0$.
This was answered affirmatively by \citet{schapire1990strength} and is the motivation behind the design of AdaBoost~\citep{freund1997decision}.
If we let $\mathcal{H}$ denote the set of hypotheses that a $\gamma$-weak learner may output from, then AdaBoost returns a \emph{voting} classifier $f(x) = \sign(\sum_{i=1}^t \alpha_i h_i(x))$ where each $h_i \in \mathcal{H}$ is the output of the $\gamma$-weak learner when trained on some carefully weighted version of the training set $S$ and each $\alpha_i$ is a real-valued weight. In terms of sample complexity $m(\varepsilon,\delta)$, AdaBoost can be shown to require the number of samples stated in \cref{eq:ada}.
There are several ways to prove this.
For instance, it can be argued that when given $m$ samples, AdaBoost combines only $t = O(\gamma^{-2} \ln m)$ hypotheses $h_1,\dots,h_t$ from $\mathcal{H}$ in order to produce an $f$ that perfectly classifies all the training data $S$, i.e. $f(x_i)=c(x_i)$ for all $x_i \in S$. Using that the class $\mathcal{H}^t$ can generate at most $O(\binom{m}{d}^t)$ distinct classifications of $m$ points (i.e. its growth function is bounded by this), one can intuitively invoke classic generalization bounds for PAC-learning in the realizable case to conclude that the hypothesis $f$ satisfies
\begin{align}
\label{eq:adagen}
\mathcal{L}_\mathcal{D}(f) ~\leq~ O\left(\frac{t d \ln(m/d) + \ln(1/\delta)}{m} \right)
~=~ O\left(\frac{d \ln(m/d) \ln m}{\gamma^2 m} + \frac{\ln(1/\delta)}{m}\right)
\end{align}
with probability at least $1-\delta$ over $S$ (and potentially the randomness of the weak learner).
Using $\mathcal{L}_\mathcal{D}(f) = \varepsilon$ and solving \cref{eq:adagen} for $m$ gives the sample complexity stated in \cref{eq:ada}.
This is the best sample complexity bound of any weak to strong learner prior to this work.
Our main upper bound result is a new algorithm with better sample complexity than AdaBoost and other weak to strong learners.
It guarantees the following:
\begin{theorem}
\label{thm:finalintro}
Assume we are given access to a $\gamma$-weak learner for some $0 < \gamma < 1/2$, using a base hypothesis set $\mathcal{H} \subseteq \mathcal{X} \to \{-1,1\}$ of VC-dimension $d$.
Then there is a universal constant $\alpha>0$ and an algorithm $\mathcal{A}$, such that $\mathcal{A}$ is a strong learner with sample complexity $m(\varepsilon,\delta)$ satisfying
\begin{align*}
m(\varepsilon,\delta) ~\leq~ \alpha \cdot \left(\frac{d \gamma^{-2}}{\varepsilon} + \frac{\ln(1/\delta)}{\varepsilon}\right).
\end{align*}
\end{theorem}
We remark that it is often required that a strong learner runs in polynomial time given a polynomial-time weak learner.
This is indeed the case for our new algorithm.
Next, we complement our algorithm from \cref{thm:finalintro} by the following lower bound:
\begin{theorem}
\label{thm:lowerintro}
There is a universal constant $\alpha > 0$ such that for all integers $d \in \mathbb{N}$ and every $0 < \gamma < 1/80$, there is a finite set $\mathcal{X}$, a concept class $\mathcal{C} \subset \mathcal{X} \to \{-1,1\}$ and a hypothesis set $\mathcal{H} \subseteq \mathcal{X} \to \{-1,1\}$ of VC-dimension at most $d$, such that for every $(\varepsilon,\delta)$ with $0 < \varepsilon < 1$ and $0 < \delta < 1/3$, there is a distribution $\mathcal{D}$ over $\mathcal{X}$ such that the following holds:
\begin{enumerate}
\item For every $c \in \mathcal{C}$ and every distribution $\mathcal{D}'$ over $\mathcal{X}$, there is an $h \in \mathcal{H}$ with \\
$\Pr_{x \sim \mathcal{D}'}[h(x) \neq c(x)] \leq 1/2-\gamma$.
\item For any algorithm $\mathcal{A}$, there is a concept $c \in \mathcal{C}$ such that $\mathcal{A}$ requires at least
\begin{align*}
m ~\geq~ \alpha \cdot \left(\frac{d \gamma^{-2}}{\varepsilon} + \frac{\ln(1/\delta)}{\varepsilon}\right)
\end{align*}
samples $S$ and labels $c(S)$ to guarantee $\mathcal{L}_\mathcal{D}(h_S) \leq \varepsilon$ with probability at least $1-\delta$ over $S$, where $h_S$ is the hypothesis produced by $\mathcal{A}$ on $S$ and $c(S)$.
\end{enumerate}
\end{theorem}
The first statement of \cref{thm:lowerintro} says that the concept class $\mathcal{C}$ can be $\gamma$-weakly learned.
The second point then states that any learner requires as many samples as our new algorithm.
Moreover, the lower bound does not require the algorithm to even use a $\gamma$-weak learner, nor does it need to run in polynomial time for the lower bound to apply.
Furthermore, the algorithm is even allowed to use the full knowledge of the set $\mathcal{C}$ and the distribution $\mathcal{D}$. The only thing it does not know is which concept $c \in \mathcal{C}$ provides the labels $c(S)$ to the training samples.
In the next section, we present the overall ideas in our new algorithm, as well as a new generalization bound for voting classifiers that is key to our algorithm.
Finally, we sketch the main ideas in the lower bound.
\subsection{Main ideas and voting classifiers}
One of the key building blocks in our new algorithm are voting classifiers.
To formally introduce voting classifiers, define from a hypothesis set $\mathcal{H} \subseteq \mathcal{X} \to \{-1,1\}$ the set of all convex combination $\Delta(\mathcal{H})$ of hypotheses in $\mathcal{H}$. That is, $\Delta(\mathcal{H})$ contains all functions $f$ of the form $f(x) = \sum_{i=1}^t \alpha_i h_i(x)$ with $\alpha_i > 0$ and $\sum_i \alpha_i = 1$. AdaBoost can be thought of as producing a voting classifier $g(x) =\sign(f(x))$ for an $f \in \Delta(\mathcal{H})$ by appropriate normalization of the weights it uses.
Classic work on understanding the surprisingly high accuracy of AdaBoost introduced the notion of \emph{margins}~\citep{bartlett1998margin}.
For a function $f \in \Delta(\mathcal{H})$, and a sample $x$ with label $y$, the margin of $f$ on $(x,y)$ is $yf(x)$. Notice that the margin is positive if and only if $\sign(f(x))$ correctly predicts the label $y$ of $x$. It was empirically observed that AdaBoost produces voting classifiers $g(x) = \sign(f(x))$ where $f$ has large margins. This inspired multiple generalization bounds based on the margins of a voting classifier, considering both the minimum and the $k$-th margin \citep{grove1998boosting,breiman1999prediction,bennett2000column,ratsch2002maximizing,ratsch2005efficient,mathiasen2019optimal}.
The simplest bound when all margins are assumed to be at least $\gamma$, is Breiman's min margin bound:
\begin{theorem}[\citet{breiman1999prediction}]
Let $c \in \mathcal{X} \to \{-1,1\}$ be an unknown concept, $\mathcal{H} \subseteq \mathcal{X} \to \{-1,1\}$ a hypothesis set of VC-dimension $d$ and $\mathcal{D}$ an arbitrary distribution over $\mathcal{X}$.
With probability at least $1-\delta$ over a set of $m$ samples $S \sim \mathcal{D}^m$, it holds for every voting classifier $g(x) = \sign(f(x))$ with $f \in \Delta(\mathcal{H})$ satisfying $c(x)f(x) \geq \gamma$ on all $x \in S$, that:
\begin{align*}
\mathcal{L}_\mathcal{D}(g) =
O\brackets{\frac{d \ln(m/d) \ln m}{\gamma^2 m}}
\end{align*}
\end{theorem}
The resemblance to the generalization performance of AdaBoost in \cref{eq:adagen} is no coincidence. Indeed, a small twist to AdaBoost, presented in the AdaBoost$^*_\nu$ algorithm~\citep{ratsch2005efficient}, ensures that the voting classifier produced by AdaBoost$^*_\nu$ from a $\gamma$-weak learner has all margins at least $\gamma/2$. This gives an alternative way of obtaining the previous best sample complexity in \cref{eq:ada}. We remark that more refined generalization bounds based on margins exist, such as the $k$-th margin bound by \citet{gao2013doubt} which is known to be near-tight~\citep{marginsGradient}.
These bounds take the whole sequence of margins $c(x_i)f(x_i)$ of all samples $x_i \in S$ into account, not only the smallest. However, none of these bounds leads to better generalization from a $\gamma$-weak learner.
We note that the notion of margins has not only been considered in the context of boosting algorithms but also plays a key role in understanding the generalization performance of Support Vector Machines, see e.g. the recent works~\citep{svmUpper, svmLower} giving tight SVM generalization bounds in terms of margins.
In our new algorithm, we make use of a voting classifier with good margins as a subroutine. Concretely, we invoke AdaBoost$^*_\nu$ to obtain margins of at least $\gamma/2$ on all training samples. At first sight, this seems to incur logarithmic losses, at least if the analysis by Breiman is tight.
Moreover, \citet{kasper2019lowerBoundBoosting} proved a generalization lower bound showing that there are voting classifiers with margins~$\gamma$ on all training samples, but where at least one of the logarithmic factors in the generalization bound must occur.
To circumvent this, we first notice that the lower bound only applies when $m$ is sufficiently larger than $d \gamma^{-2}$.
We carefully exploit this loophole and prove a new generalization bound for voting classifiers:
\begin{theorem}
\label{thm:constantgen}
Let $c \in \mathcal{X} \to \{-1,1\}$ be an unknown concept, $\mathcal{H} \subseteq \mathcal{X} \to \{-1,1\}$ a hypothesis set of VC-dimension $d$ and $\mathcal{D}$ an arbitrary distribution over $\mathcal{X}$.
There is a universal constant $\alpha > 0$, such
that with probability at least $1-\delta$ over a set of $m \geq \alpha(d \gamma^{-2} + \ln(1/\delta))$ samples $S \sim \mathcal{D}^m$, every voting classifier $g(x) = \sign(f(x))$ with $f \in \Delta(\mathcal{H})$ satisfying $c(x)f(x) \geq \gamma$ on all $x \in S$ achieves
\begin{align*}
\mathcal{L}_\mathcal{D}(g) \leq \tfrac{1}{200}.
\end{align*}
\end{theorem}
The value $1/200$ is arbitrary and chosen to match the requirements in the proof of \cref{thm:finalintro}.
Notice how our new generalization bound avoids the logarithmic factors when aiming merely at generalization error $1/200$.
Breiman's bound would only guarantee that $d \gamma^{-2} \ln(1/\gamma) \ln(d/\gamma)$ samples suffice for such a generalization error.
While the focus of previous work on generalization bounds was not on the constant error case, we remark that any obvious approaches to modify the previous proofs could perhaps remove the $\ln m$ factor but not the $\ln(m/d)$ factor.
The $\ln(m/d)$ factor turns into $\Theta(\ln(1/\gamma))$ when solving for $m$ in $d \ln(m/d)/(\gamma^{2}m)=1/200$ and is insufficient for our purpose.
With the new generalization bound on hand, we can now construct our algorithm for producing a strong learner from a $\gamma$-weak learner.
Here we use as template the sample optimal algorithm by \citet{hanneke2016optimal} for PAC learning in the realizable case (which improved over a previous near-tight result by \citet{simonPAC}).
Given a training set $S$, his algorithm carefully constructs a number of sub-samples $S_1,S_2,\dots,S_k$ of $S$ and trains a hypothesis $h_i$ on each $S_i$ using empirical risk minimization. As the final classifier, he returns the voter $g(x) = \sign\!\big((1/k)\sum_{i=1}^k h_i(x)\big)$.
For our new algorithm, we use Hanneke's approach to construct sub-samples $S_1,\dots,S_k$ of a training set $S$.
We then run AdaBoost$^*_\nu$ on each $S_i$ to produce a voting classifier $g_i(x) = \sign(f_i(x))$ for an $f_i \in \Delta(\mathcal{H})$ with margins $\gamma/2$ on all samples in $S_i$.
We finally return the voter $h(x) = \sign((1/k)\sum_{i=1}^k g_i(x))$.
Our algorithm thus returns a majority of majorities.
To prove that our algorithm achieves the desired sample complexity $m(\varepsilon,\delta)$ claimed in \cref{thm:finalintro}, we then revisit Hanneke's proof and show that it suffices for his argument that the base learning algorithm (in his case empirical risk minimization, in our case AdaBoost$^*_\nu$) achieves an error of at most $1/200$ when given $\tau$ samples. If this is the case, then his proof can be modified to show that the final error of the output voter drops to $O(\tau/m)$.
Plugging in the $\tau = \alpha(d\gamma^{-2} + \ln(1/\delta))$ from our new generalization bound in \cref{thm:constantgen} completes the proof.
Let us remark that a lower bound by \citet{kasper2019lowerBoundBoosting} shows the existence of a voting classifier with simultaneously large margins and a generalization error with an additional log-factor.
It is thus conceivable that a simple majority vote is not sufficient and a majority of majorities is indeed necessary, although the lower bound only guarantees the \emph{existence} of a `bad' voter with good margins and not that \emph{all} such voters are `bad'.
In the following, we start by proving our new generalization bound (\cref{thm:constantgen}) in \cref{sec:constantgen}.
We then proceed in \cref{sec:hanneke} to present our new algorithm and show that it gives the guarantees in \cref{thm:finalintro}.
Finally, in \cref{sec:lowerBound} we give the proof of the lower bound in \cref{thm:lowerintro}.
\section{New margin-based generalization bounds for voting classifiers}
\label{sec:constantgen}
In this section, we prove the new generalization bound stated in \cref{thm:constantgen}.
For ease of notation, we write that $\mathcal{D}$ is a distribution over $\mathcal{X} \times \{-1,1\}$ (and not just a distribution over $\mathcal{X}$) and implicitly assume that the label of each $x \in \mathcal{X}$ is $c(x)$ for the unknown concept $c$.
Moreover, for a voting classifier $g(x) = \sign(f(x))$ with $f \in \Delta(\mathcal{H})$, we simply refer to $f$ as the voting classifier and just remark that one needs to take the sign to make a prediction.
Finally, we think of the sample $S$ as a set of pairs $(x_i,y_i)$ with $x_i \in \mathcal{X}$ and $y_i = c(x_i) \in \{-1,1\}$.
The key step in the proof of \cref{thm:constantgen} is to analyze the
generalization performance for a voting classifier obtained by
combining randomly drawn hypotheses among the hypotheses
$h_1,\dots,h_t$ making up a voting classifier $f = \sum_i \alpha_i
h_i$ from $\Delta(\mathcal{H})$.
We then relate that to the generalization performance of $f$ itself.
Formally, we define a distribution $\mathcal{D}_{f\!,t}$ for every $f$ and look at a random hypothesis from $\mathcal{D}_{f\!,t}$.
We start by defining this distribution.
Let $f(x) = \sum_h \alpha_h h(x) \in \Delta(\mathcal{H})$ be a voting classifier.
Let $\mathcal{D}_f$ be the distribution over $\mathcal{H}$ (the base hypotheses used in $f$) where $h$ has probability $\alpha_h$.
Consider drawing $t$ i.i.d. hypotheses $h'_1,\dots,h'_t$ from $\mathcal{D}_f$ and then throwing away each $h'_i$ independently with probability $1/2$.
Let $t'$ be the number of remaining hypotheses, denote them $h_1,\dots,h_{t'}$, and let $g = \frac{1}{t'}\sum_{i=1}^{t'} h_i$.
One can think of $g$ as a sub-sampled version of $f$ with replacement.
Denote by $\mathcal{D}_{f\!,t}$ the distribution over $g$.
\paragraph{Key properties of $\bm{\mathcal{D}_{\!f\!,\,t}}$.}
In the following, we analyze how a random $g$ from $\mathcal{D}_{f\!,t}$ behaves and show that while it behaves similar to $f$ it produces with good probability predictions that are big in absolute value (even if $f(x)\approx 0$).
First, we note that predictions made by a random $g$ are often close to those made by $f$.
The proof uses a standard concentration bound and is given in supplementary material.
\begin{lemma}
\label{lem:closeapprox}
For any $x \in \mathcal{X}$, any $f \in \Delta(\mathcal{H})$ and any $\mu > 0$:
\(
\Pr_{g \sim \mathcal{D}_{f\!,t}}[|f(x)-g(x)| \geq \mu] < 5 e^{-\mu^2t/32}.
\)
\end{lemma}
Next, $g$ rarely makes predictions $g(x)$ that are small in absolute value:
\begin{lemma}
\label{lem:smallunlikely}
For any $x \in \mathcal{X}$, any $f \in \Delta(\mathcal{H})$ and any $\mu \geq 1/t$:
\(
\Pr_{g \sim \mathcal{D}_{f\!,t}}[|g(x)| \leq \mu] ~\leq~ 2 \mu \sqrt{t}.
\)
\end{lemma}
\cref{lem:smallunlikely} states that even if $f(x) \approx 0$ for an unseen sample, $g(x)$ will still be large with good probability.
Thus we can think of $g$ as having large margins (perhaps negative) also on unseen data.
This is crucial for bounding the generalization error.
The proof follows from an invocation of Erd\H{o}s' improved Littlewood-Offord lemma~\citep{erdos:littlewood}.
\begin{proof}
Let $h'_1,\dots,h'_t$ be the hypotheses sampled in the first step of drawing $g$.
Define $\sigma_i$ to be $1$ if $h'_i$ is sampled in $g$ and $-1$ otherwise.
That is, we have
\[
g(x) = \frac{1}{|\{i : \sigma_i = 1\}|} \sum_{i : \sigma_i = 1}h'_i(x).
\]
Let $\Gamma = \sum_{i=1}^t h'_i(x)$. Then
\begin{align*}
\Gamma + \sum_{i=1}^t \sigma_i h'_i(x)
~=~& \sum_{i : \sigma_i = 1}h'_i(x) + \sum_{i : \sigma_i = -1} h'_i(x) + \sum_{i=1}^t
\sigma_i h'_i(x) \\
=~& 2\sum_{i : \sigma_i=1} h'_i(x) \\
=~& 2t' g(x).
\end{align*}
Therefore, $|g(x)| \leq \mu$ if and only if
\[
\left|\frac{\Gamma +
\sum_i \sigma_i h'_i(x)}{2t'}\right| \leq \mu.
\]
Since $t' \leq t$, this implies
\[
\left|\frac{\Gamma +
\sum_i \sigma_i h'_i(x)}{2t}\right| \leq \mu.
\]
Hence, we have $\Pr\big[|g(x)| \leq \mu\big] \leq \Pr\big[\sum_i \sigma_i h'_i(x) \in -\Gamma \pm 2t \mu\big]$.
By Erd\"os' improved Littlewood-Offord lemma, as long as $2 t\mu \geq 2$, this happens with probability at most $2t\mu\binom{t}{\lfloor t/2 \rfloor}2^{-t}$.
The central binomial coefficient satisfies $\binom{t}{\lfloor t/2 \rfloor} \leq 2^{t}/\sqrt{\pi t/2} \leq 2^{t}/\sqrt{t}$ and thus the probability is at most $2t\mu/\sqrt{t} = 2 \mu\sqrt{t}$.
\end{proof}
As the last property, we look at the out-of-sample and in-sample error of a random $g$ and start with relating the generalization error of $f$ to that of a random $g$.
To formalize this, define for any distribution $\mathcal{D}$, the loss $\mathcal{L}^t_\mathcal{D}(f) := \Pr_{{(x,y) \sim \mathcal{D}, \,g\sim \mathcal{D}_{f\!,t}}}\big[yg(x) \leq 0\big]$ and when writing $\mathcal{L}^t_S(f)$ we implicitly assume $S$ to also denote the uniform distribution over all $(x,y)\in S$.
We then have the following lemma which is proven in the supplementary material:
\begin{lemma}
\label{lem:similarerror}
For any distribution $\mathcal{D}$ over $\mathcal{X} \times \{-1,1\}$, any $t \geq 36$ and any voting classifier $f \in \Delta(\mathcal{H})$ for a hypothesis set $\mathcal{H} \subset \mathcal{X} \to \{-1,1\}$, we have
\(
\mathcal{L}_\mathcal{D}(f) \leq 3\mathcal{L}_\mathcal{D}^t(f).
\)
\end{lemma}
Moreover, if $f$ has margins $\gamma$ on all training samples $(x,y)
\in S$, then $g$ is correct on most of $S$ provided that we set $t$ big enough:
\begin{lemma}
\label{lem:ginsample}
Let $S$ be a set of $m$ samples in $\mathcal{X} \times \{-1,1\}$ and assume $f$ is a voting classifier with $yf(x) \geq \gamma$ for all $(x,y) \in S$. For $t \geq 1024 \gamma^{-2}$, we have
\(
\mathcal{L}_S^t(f) \leq 1/1200. \)
\end{lemma}
\begin{proof}
By \cref{lem:closeapprox}, it holds for all $(x,y) \in S$, that $|f(x)-g(x)| \geq \gamma$ with probability at most $5 \exp\!\big({-\gamma}^2 t/32\big) \!\leq 5e^{-32} \!\ll 1/1200$.
Since $yf(x) \geq \gamma$, this implies $\sign\!\big(g(x)\big)=\sign\!\big(f(x)\big)=y.$
\end{proof}
The last ingredient for the proof of \cref{thm:constantgen} is to relate $\mathcal{L}_S^t(f)$ and $\mathcal{L}_\mathcal{D}^t(f)$.
For the proof we use \cref{lem:smallunlikely} to infer that with good probability $\abs{g(x)} = \Omega(\gamma)$, i.e. has large absolute value.
We use this to argue that $\sign(g)$ often belongs to a class with small VC-dimension and then apply a growth-function argument to relate $\mathcal{L}_S^t(f)$ and $\mathcal{L}_\mathcal{D}^t(f)$.
Formally, we prove the following lemma.
\begin{lemma}
\label{lem:supf}
Let $\mathcal{D}$ be an arbitrary distribution over $\mathcal{X} \times \{-1,1\}$ and let $\mathcal{H} \subset \mathcal{X} \to \{-1,1\}$ be a hypothesis set of VC-dimension $d$.
There is a universal constant $\alpha > 0$ such that for any $t\in \mathbb{N}$ and any $m \geq \alpha td$, it holds that:
\[
\Pr_S\Big[\sup_{f \in \Delta(\mathcal{H})} |\mathcal{L}^t_S(f) -
\mathcal{L}^t_\mathcal{D}(f)| > \tfrac{1}{1200}\Big] ~\leq~ \alpha \cdot \exp(-m/\alpha).
\]
\end{lemma}
Before we prove \cref{lem:supf}, we show how to use it to prove \cref{thm:constantgen}.
Since we are only aiming to prove the generalization of voting classifiers $f$ with $yf(x) \geq \gamma$ for all samples $(x,y) \in S$, \cref{lem:ginsample} tells us that such $f$ have small $\mathcal{L}_S^t(f)$ when $t \geq 1024 \gamma^{-2}.$
We thus fix $t = 1024 \gamma^{-2}$ and get that $\mathcal{L}_S^t(f) \leq 1/1200$ from \cref{lem:ginsample}.
By \cref{lem:supf}, with probability at least $1-\alpha\exp(-m/\alpha)$ over the sample $S$, we have for all $f \in \Delta(\mathcal{H})$ that $|\mathcal{L}^t_S(f) - \mathcal{L}^t_\mathcal{D}(f)| \leq 1/1200$ and thus $\mathcal{L}^t_\mathcal{D}(f) \leq 1/600$.
Finally, \cref{lem:similarerror} gives us that $\mathcal{L}_\mathcal{D}(f) \leq 3 \mathcal{L}^t_\mathcal{D}(f)$ for all $f \in \Delta(\mathcal{H})$.
Together we thus have $\mathcal{L}_\mathcal{D}^t(f) \leq 1/600 \Rightarrow \mathcal{L}_\mathcal{D}(f) \leq 1/200$ for any $m \geq \alpha td \geq \alpha'd\gamma^{-2}$ where $\alpha'>0$ is a universal constant.
By observing that $\alpha\exp(-m/\alpha) < \delta$ for $m \geq \alpha\ln(\alpha/\delta)$, this completes the proof of \cref{thm:constantgen}.
What remains is thus to prove \cref{lem:supf} which we do in the remainder of this section.
\subsection{Relating \texorpdfstring{$\bm{\mathcal{L}_S^t \big(f\big)}$}{in-sample loss} and \texorpdfstring{$\bm{\mathcal{L}_\mathcal{D}^t\big(f\big)}$}{out-of-sample loss}}
The last remaining step to show \cref{thm:constantgen} is thus to relate $\mathcal{L}_S^t(f)$ to $\mathcal{L}_\mathcal{D}^t(f)$, i.e. to prove \cref{lem:supf}.
In the proof, we rely on the classic approach for showing generalization for classes $\mathcal{H}$ of bounded VC-dimension and introduce a \emph{ghost} set that only exists for the sake of analysis.
In addition to the sample $S$, we thus consider a \emph{ghost} set $S'$ of another $m$ i.i.d. samples from $\mathcal{D}$.
This allows us to prove:
\begin{lemma}
\label{lem:ghost}
For $m \geq 2400^2$ any $t$ and any $f,$ it holds that:
\[
\Pr_S\Big[\sup_{f \in \Delta(\mathcal{H})} |\mathcal{L}^t_S(f) -
\mathcal{L}^t_\mathcal{D}(f)| > \tfrac{1}{1200}\Big] ~\leq~ 2\cdot \Pr_{S,S'}\Big[\sup_{f \in \Delta(\mathcal{H})}
|\mathcal{L}^t_S(f) - \mathcal{L}^t_{S'}(f)| > \tfrac{1}{2400}\Big].
\]
\end{lemma}
As the proof is standard, it can be found in the supplementary material.
We thus only need to bound $\Pr_{S,S'}[\sup_{f \in \Delta(\mathcal{H})} |\mathcal{L}^t_S(f) - \mathcal{L}^t_{S'}(f)| > 1/2400]$.
To do this, consider drawing a data set $P$ of $2m$ i.i.d. samples from $\mathcal{D}$ and then drawing $S$ as a set of $m$ uniform samples from $P$ without replacement and letting $S'$ be the remaining samples.
Then $S$ and $S'$ have the same distribution as if they were drawn as two independent sets of $m$ i.i.d. samples each.
From here on, we thus think of $S$ and $S'$ as being sampled via $P$.
Now consider a fixed set $P$ in the support of $\mathcal{D}^{2m}$ and define $\Delta^\mu_\delta(\mathcal{H},P)$ as the set of voting
classifiers $f \in \Delta(\mathcal{H})$ for which $\Pr_{(x,y) \sim P}[|f(x)|
\geq \mu] \geq 1-\delta$.
These are the voting classifiers that make predictions of large absolute value on most of \emph{both} $S$ and $S'$ (if $\delta \ll 1/2$).
The crucial point, and the whole reason for introducing $g$, is that regardless of what $f$ is, a random $g \sim \mathcal{D}_{f\!,t}$ often lies in the set $\Delta^\mu_\delta(\mathcal{H},P)$:
\begin{lemma}
\label{lem:inc}
For any data set $P$, parameters $0 < \delta < 1$ and $t$, and every $\mu \leq \delta/(9600 \sqrt{t})$, we have
$\Pr_{g \sim \mathcal{D}_{f\!,t}}[g \notin \Delta^\mu_\delta(\mathcal{H},P)] \leq 1/4800$.
\end{lemma}
\begin{proof}
Define an indicator $X_i$ for each $(x_i,y_i) \in P$ taking the value $1$
if $|g(x_i)| \leq \mu$.
By \cref{lem:smallunlikely}, we have $\E[\sum_i X_i] \leq |P|\,2 \mu \sqrt{t} \leq |P|\,\delta/4800$.
By Markov's inequality
$\Pr[\sum_i X_i \geq \delta |P|] \leq 1/4800$.
\end{proof}
If we had just considered $f$, we had no way of arguing that $f$ makes predictions of large absolute value on $S'$, since the only promise we are given is that it does so on $S$.
That $g$ makes predictions of large absolute value even outside of $S$ is crucial for bounding the generalization error in the following.
Let us now define $\hat{\Delta}_\delta^\mu(P) = \sign\big(\Delta_\delta^\mu(\mathcal{H},P)\big)$ which means that $\hat{\Delta}_\delta^\mu(P)$ contains all the hypotheses that are obtained by voting classifiers in $\Delta_{\delta}^\mu(\mathcal{H},P)$ when taking the sign.
Since $g$ is in $\Delta_{\delta}^\mu(\mathcal{H},P)$ except with probability $1/4800$ by \cref{lem:inc}, we can prove:
\begin{lemma}
\label{lem:relategrowth}
For any $0 < \delta < 1$, every $t$, and every $\mu \leq \delta/(9600 \sqrt{t})$, we have
\[
\Pr_{S,S'}\Big[\sup_{f \in \Delta(\mathcal{H})} \abs{\mathcal{L}^t_S(f) - \mathcal{L}^t_{S'}(f)} >
\tfrac{1}{2400}\Big] ~\leq~ \sup_P 2 \abs{\hat{\Delta}_\delta^\mu(P)}\, \exp\big(-2m/9600^2\big).
\]
\end{lemma}
Again, the proof of the lemma can be found in the supplementary material.
What \cref{lem:relategrowth} gives us, is that it relates the generalization error to the growth function $|\hat{\Delta}_\delta^\mu(P)|$.
The key point is that $\hat{\Delta}_\delta^\mu(P)$ was obtained from voting classifiers with predictions of large absolute value on all but a $\delta$ fraction of points in $P$.
This implies that we can bound the VC-dimension of $\hat{\Delta}_\delta^\mu(P)$ when restricted to the point set $P$ using Rademacher complexity:
\begin{lemma}
\label{lem:vc}
Let $\mathcal{H}$ be a hypothesis set of VC-dimension $d$.
For any $\delta,\mu>0$ and point set $P$, we have that the largest subset $P'$ of $P$ that $\hat{\Delta}_\delta^\mu(P) = \sign\big(\Delta_\delta^\mu(\mathcal{H},P)\big)$ can shatter, has size at most $|P'| = d' < \max\{2\delta |P|,\, 4\alpha^2 \mu^{-2}d\}$, where $\alpha>0$ is a universal constant.
\end{lemma}
\begin{proof}
Recall that the VC-dimension of $\mathcal{H}$ is $d$.
Thus the Rademacher complexity of $\mathcal{H}$ for any point set $P'$ is:
\[
\expectation_{\sigma \in P' \to \{-1,1\}}\left[ \frac{1}{|P'|} \sup_{h \in \mathcal{H}}
\left|\sum_{x \in P'} h(x)\sigma(x)\right|\right] ~<~ \alpha\sqrt{\frac{d}{|P'|}}
\]
for a universal constant $\alpha>0$ (see e.g. \citep{wellner2013weak}).
Assume $P' \subseteq P$ with $|P'|=d'$ can be shattered.
Fix any labeling $\sigma \in P' \to \{-1,1\}$.
Let $h_\sigma \in \hat{\Delta}_\delta^\mu(P)$ be the hypothesis generating the dichotomy $\sigma$ (which exists since $P'$ is shattered).
Since $h_\sigma \in \hat{\Delta}_\delta^\mu(P)$, there must be some $g \in \Delta^\mu_\delta(\mathcal{H},P)$ such that $h_\sigma = \sign(g)$ on the point set $P'$.
If $|P'| \geq 2\delta |P|$, then by definition of $\Delta^\mu_\delta(\mathcal{H},P)$, there are at least $|P'|- \delta|P| \geq |P'|/2$ points $x \in P'$ for which $|g(x)| \geq \mu$.
This means that $(1/|P'|)\sum_{x \in P'} g(x)\sigma(x) \geq
(1/2)\mu$.
But $g(x)$ is a convex combination of hypotheses from $\mathcal{H}$, hence there is also a hypothesis $h \in \mathcal{H}$ for which $(1/|P'|)\sum_{x\in P'} h(x) \sigma(x) \geq (1/2)\mu$.
Since this holds for all $\sigma$, by the bound on the Rademacher complexity, we conclude $\alpha \sqrt{d/|P'|} > (1/2)\mu \implies |P'| < 4\alpha^2 \mu^{-2} d$.
We thus conclude that the largest set that $\hat{\Delta}_\delta^\mu(P)$ can shatter, has size less than $\max\!\big\{2\delta |P|,~ 4\alpha^2 \mu^{-2}d\big\}$.
\end{proof}
We remark that it was crucial to introduce the random hypothesis $g$, since all we are promised about the original hypothesis $f$ is that it has large margins on $S$, i.e. on only half the points in $P$.
That case would correspond to $\delta = 1/2$ in \cref{lem:vc} and would mean that we could potentially shatter all of $P$.
In order for the bound to be useful, we thus need $\delta \ll 1/2$ and thus large margins on much more than half of $P$ (which we get by using $g$).
For a $0 < \delta < 1$ to be determined, let us now fix $\mu = \delta/(9600 \sqrt{t})$ and assume that the number of samples $m$ satisfies $m
\geq \max\{ \alpha^2 \mu^{-2} d/\delta,~2400^2\}$ where $\alpha$ is the constant from \cref{lem:vc}. By \cref{lem:relategrowth}, we have
\[
\Pr_{S,S'}\Big[\sup_{f \in \Delta(\mathcal{H})} |\mathcal{L}^t_S(f) - \mathcal{L}^t_{S'}(f)| >
\tfrac{1}{2400}\Big] ~\leq~ \sup_P 2 |\hat{\Delta}_\delta^\mu(P)|\, \exp(-2m/9600^2).
\]
\cref{lem:vc} gives us that the largest subset $P' \subseteq P$ that $\hat{\Delta}_\delta^\mu(P)$ shatters has size at most $d' < \max\{2\delta |P|,\, 4\alpha^2 \mu^{-2}d\}$.
By our assumption on $m$, the term $2 \delta |P| = 4 \delta m$ is at least $4c^2 \mu^{-2} d$ and thus $2\delta |P| = 4\delta m$ takes the maximum in the bound on $d'$.
By the Sauer-Shelah lemma, we have that $|\hat{\Delta}_\delta^\mu(P)| \leq \sum_{i=0}^{4 \delta m-1} \binom{2m}{i}$. For $\delta \leq 1/4$, this is at most $\binom{2m}{4 \delta m} \leq (e \delta^{-1}/2)^{4 \delta m} = \exp \brackets{4 \delta m \ln(e\delta^{-1}/2)}$.
As conclusion we have:
\[
\Pr_{S,S'}\Big[\sup_{f \in \Delta(\mathcal{H})} |\mathcal{L}^t_S(f) - \mathcal{L}^t_{S'}(f)| > \tfrac{1}{2400}\Big]
~\leq~ 2 \exp ({4 \delta m \ln(e\delta^{-1}/2)})\exp(-2m/9600^2).
\]
Let us now fix $\delta = 10^{-10}$. We then have
\begin{align*}
&2 \exp\big({4 \delta m \ln(e\delta^{-1}/2)}\big)\exp(-2m/9600^2) \\
~=~ &2 \exp\big({m(4 \delta \ln(e \delta^{-1}/2) - 2/9600^2)}\big) \\
~\leq~ &2 \exp\big({-m/10^{8}}\big)
\end{align*}
where the last step is a numerical calculation.
By \cref{lem:ghost}, this in turn implies:
\[
\Pr_S\Big[\sup_{f \in \Delta(\mathcal{H})} \big|\mathcal{L}^t_S(f) -
\mathcal{L}^t_\mathcal{D}(f)\big| > \tfrac{1}{1200}\Big] ~\leq~ 4 \exp(-m/ 10^{8}).
\]
Since we only required $m
\geq \max\{ \alpha^2 \mu^{-2} d/\delta,2400^2\}$ and we had $\mu = \delta/(9600 \sqrt{t})$, this is satisfied for $m \geq \alpha't d$ for a large enough constant $\alpha'>0$.
This completes the proof of \cref{lem:supf} and thus also finishes the proof of \cref{thm:constantgen}.
\section{Weak to strong learning}
\label{sec:hanneke}
\label{sec:hannekeFull}
\begin{algorithm}[t]
\DontPrintSemicolon
\KwIn{Sets $A$ and $B$}
\eIf{$|A| \leq 3$}{
\Return{$A \cup B$}
}
{
Let $A_0$ denote the first $|A|-3\lfloor |A|/4 \rfloor$ elements of $A$, $A_1$ the next $\lfloor |A|/4 \rfloor$ elements, $A_2$ the next $\lfloor |A|/4 \rfloor$ elements, and $A_3$ the remaining $\lfloor |A|/4 \rfloor$ elements.\\
\Return{Sub-Sample$(A_0,A_2 \!\cup\! A_3 \!\cup\! B)$ $\cup$ Sub-Sample$(A_0,A_1 \!\cup\! A_3 \!\cup\! B)$ $\cup$ Sub-Sample$(A_0,A_1 \!\cup\! A_2 \!\cup\! B)$}
}
\caption{\textit{Sub-Sample}($A,B$)~ (\citet{hanneke2016optimal})}\label{alg:subsample}
\end{algorithm}
\begin{algorithm}[t]
\DontPrintSemicolon
\KwIn{Set $S$ of $m$ samples.}
$\{C_1,\dots,C_k\} = \textit{Sub-Sample}(S,\emptyset)$
\tcp*{Create highly overlapping subsamples of $S$}
\For{$i=1,\dots,k$}{
$h_i = \mathcal{A}^*_{\nu}(C_i)$
\tcp*{Run AdaBoost$_\nu^*$ on all those sub-samples}
}
\Return $h(x) = \sign\big(\sum_{i=1}^k h_i(x)\big)$.
\tcp*{Return unweighted majority vote}
\caption{Optimal weak-to-strong learner}\label{alg:final}
\end{algorithm}
In this section, we give our algorithm for obtaining a strong learner from a $\gamma$-weak learner with optimal sample complexity and prove that it achieves the announced sample complexity.
The following theorem is essentially a restatement of \cref{thm:finalintro} from the introduction.
Optimality then follows by combining the theorem with the lower bound that we prove in \cref{sec:lowerBoundFull}.
\begin{theorem}
\label{thm:finalSupplement}
Assume we are given access to a $\gamma$-weak learner for a $0 < \gamma < 1/2$, using base hypothesis set $\mathcal{H} \subseteq \mathcal{X} \to \{-1,1\}$ of VC-dimension $d$.
Then there is a universal constant $\alpha>0$ and an algorithm $\mathcal{A}$, such that for every $0 < \delta < 1$ and every distribution $\mathcal{D}$ over $\mathcal{X} \times \{-1,1\}$, it holds with probability at least $1-\delta$ over a set of $m$ samples $S \sim \mathcal{D}^m$, that $\mathcal{A}$ on $S$ outputs a classifier $h_S = \mathcal{A}(S) \in \mathcal{X} \to \{-1,1\}$ with
\[
\mathcal{L}_\mathcal{D}(h_S) ~\leq~ \alpha \cdot \frac{d \gamma^{-2} + \ln(1/\delta)}{m}.
\]
\end{theorem}
\cref{thm:finalintro} follows by setting $\varepsilon = \mathcal{L}_\mathcal{D}(h_S)$ and solving for $m$ and letting the label in the distribution $\mathcal{D}$ be $c(x)$ for every $x \in \mathcal{X}$.
The algorithm obtaining those guarantees is as follows:
Let $\mathcal{A}^*_{\nu}$ be an algorithm that on a sample $S$ outputs a classifier $g = \sign(f)$, where $f$ is a voting classifier with margins at least $\gamma/2$ on all samples in $S$ such as AdaBoost$_\nu^*$ \citep{ratsch2005efficient}. Given a set $S$ of $m$ i.i.d. samples from an unknown distribution $\mathcal{D}$, we run $\mathcal{A}^*_{\nu}$ on a number of samples $C_1,C_2,\ldots,C_k \subset S$ obtaining hypotheses $h_1,h_2,\dots,h_k$.
We then return the (unweighted) majority vote among $h_1,\dots,h_k$ as our final hypothesis $h^*$.
The subsets~$C_i$ are chosen by the algorithm \textit{Sub-Sample} (shown in \cref{alg:subsample}) as in the optimal PAC learning algorithm by \citet{hanneke2016optimal}.
The final algorithm (\cref{alg:final}) calls $\mathcal{A}^*_{\nu}$ on all subsets returned by \cref{alg:subsample} and returns the majority vote.
Note that the final hypothesis returned by \cref{alg:final} is a majority of majorities since $\mathcal{A}^*_{\nu}$ already returns a voting classifier.
In the remainder of the section, we prove that \cref{alg:final} has the guarantees of \cref{thm:finalSupplement}.
The proof follows that of \citet{hanneke2016optimal} pretty much uneventfully, although carefully using that a generalization error of $1/200$ suffices for each call of $\mathcal{A}^*_{\nu}$.
The key observation is that each of the recursively generated sub-samples in \cref{alg:subsample} leaves out a subset $A_i$ of the training data, whereas the two other recursive calls always include all of $A_i$ in their sub-samples.
If one considers a hypothesis $h$ trained on the data leaving out $A_i$, then $A_i$ serves as an independent sample from $\mathcal{D}$.
This implies that if $h$ has large error probability over $\mathcal{D}$, then many of the samples in $A_i$ will be classified incorrectly by $h$.
Now, since the two other recursive calls always include $A_i$, any hypothesis $h'$ trained on a sub-sample from those calls will have margin at least $\gamma/2$ on all points misclassified by $h$ in $A_i$.
But the generalization bound in \cref{thm:lowerintro} then implies that $h'$ makes a mistake only with probability $1/200$ on \emph{the conditional distribution} $\mathcal{D}(\, \cdot \mid h \textrm{ errs})$.
Thus, the probability that they both err at the same time is at most the probability that $h$ errs, times $1/200$.
Applying this reasoning inductively gives the conclusion that it is very unlikely that the majority of all trained hypotheses err at the same time which then finishes the proof.
\subsection{Proof of Optimal Strong Learning}
For simplicity, we assume $m$ is a power of $4$. This can easily be ensured by rounding $m$ down to the nearest power of $4$ and ignoring all excess samples. This only affects the generalization bound by a constant factor.
With $m$ being a power of $4$ we can observe from \cref{alg:subsample} that the cardinalities of all recursively generated sets $A_0$ (which are the input to the next level of the recursion) are also powers of $4$.
Hence we can ignore all roundings.
Let $\mathcal{C} \subseteq \mathcal{X} \to \{-1,1\}$ be a concept class and assume there is a $\gamma$-weak learner for $\mathcal{C}$ using hypothesis set $\mathcal{H}$ of VC-dimension $d$.
Let $\mathcal{A}^*_{\nu}$ be an algorithm that on a sample $S$ consistent with a concept $c \in \mathcal{C}$, computes a voting classifier $f \in \Delta(\mathcal{H})$ with $yf(x) \geq \gamma/2$ for all $(x,y) \in S$ and returns as its output hypothesis $g(x) = \sign(f(x))$.
We could e.g. let $\mathcal{A}^*_{\nu}$ be AdaBoost$_\nu^*$.
For a sample $S$, we use the notation $\mathcal{M}_{\gamma}(S)$ to denote the set of hypotheses $g(x) = \sign(f(x))$ for an $f \in \Delta(\mathcal{H})$ satisfying $yf(x) \geq \gamma$ for all $(x,y) \in S$.
The set $\mathcal{M}_{\gamma}(S)$ is thus the set of all voting classifiers obtained by taking the sign of a voter that has margins at least $\gamma$ on all samples in $S$.
By definition, the output hypothesis $g$ of $\mathcal{A}^*_{\nu}$ on a set of samples $S$ always lies in $\mathcal{M}_{\gamma/2}(S)$.
Let $c \in \mathcal{C}$ be an unknown concept in $\mathcal{C}$ and let $\mathcal{D}$ be an arbitrary distribution over $\mathcal{X}$.
Let \mbox{$S = \{(x_i,c(x_i))\}_{i=1}^m \in (\mathcal{X} \times \{-1,1\})^m$} be a set of $m$ samples with each $x_i$ an i.i.d. sample \mbox{from $\mathcal{D}$}.
Let $S_{1:k}$ denote the first $k$ samples of $S$. Let $c'\geq 4$ be a constant to be determined later.
We will prove by induction that for every $m' \in \mathbb{N}$ that is a power of $4$, for every $\delta' \in (0,1)$, and every finite sequence $B'$ of samples in $\mathcal{X} \times \{-1,1\}$ with $y_i = c(x_i)$ for each $(x_i,y_i) \in B'$, with probability at least $1-\delta'$, the classifier
\begin{align*}
&\hat{h}_{m',B'} \,=\, \sign\left(\sum_{C_i \in \textit{ Sub-Sample}(S_{1:m'},B')} \!\mathcal{A}^*_{\nu}(C_i)\right)
\intertext{satisfies}
&\mathcal{L}_\mathcal{D}(\hat{h}_{m',B'}) ~\leq~ \frac{c'}{m'}\left(d\gamma^{-2} + \ln(1/\delta')\right).\addtocounter{equation}{1}\tag{\theequation}{}
\label{eq:induc}
\end{align*}
The conclusion of \cref{thm:finalSupplement} follows by letting $B'=\emptyset$ and $m'=m$ (and recalling that we assume $m$ is a power of $4$).
Thus what remains is to give the inductive proof.
As the base case, consider any $m' \in \mathbb{N}$ with $m' \leq c'$ and $m'$ a power of $4$. In this case, the bound $c'(d \gamma^{-2} + \ln(1/\delta'))/m'$ is at least $d \gamma^{-2} \geq 1$ and $\mathcal{L}_\mathcal{D}(\hat{h}_{m',B'}) \leq 1$ obviously holds.
For the inductive step, take as inductive hypothesis that, for some $m \in \mathbb{N}$ with $m > c'$ and $m$ a power of $4$, it holds for all $m' \in \mathbb{N}$ with $m' < m$ and $m'$ a power of $4$, that for every $\delta' \in (0,1)$ and every finite sequence $B'$ of samples in $\mathcal{X} \times \{-1,1\}$ with $y_i = c(x_i)$ for each $(x_i,y_i) \in B'$, with probability at least $1-\delta'$, \cref{eq:induc} holds. We need to prove that the inductive hypothesis also holds for $m'=m$.
Fix a $\delta \in (0,1)$ and any finite sequence $B$ of points in $\mathcal{X} \times \{-1,1\}$ with $y_i = c(x_i)$ for each $(x_i,y_i)$ in $B$.
Since $m > c' \geq 4$ we have that \textit{Sub-Sample}$(S_{1:m},B)$ returns in Step 5 of \cref{alg:subsample}.
Let $A_0,A_1,A_2,A_3$ be as defined in Step 4 of \cref{alg:subsample}.
Also define $B_1 = A_2 \cup A_3 \cup B,$ \mbox{$B_2 = A_1 \cup A_3 \cup B,~ B_3 = A_1 \cup A_2 \cup B$}, and for each $i \in \{1,2,3\}$, denote
\[
h_i \,=\, \sign\left( \sum_{C_i \in \textit{ Sub-Sample}(A_0,B_i)} \!\mathcal{A}^*_{\nu}(C_i)\right).
\]
Note that the $h_i$'s correspond to the majority vote classifiers trained on the sub-samples of the three recursive calls in \cref{alg:subsample}.
Moreover, notice that $h_i = \hat{h}_{m/4, B_i}$.
Therefore, the inductive hypothesis may be used on $h_1,h_2,h_3$ to conclude that for each $i \in \{1,2,3\}$, there is an event $E_i$ of probability at least $1-\delta/9$, on which
\begin{align}
\mathcal{L}_\mathcal{D}(h_i) ~\leq~ \frac{c'}{|A_0|}\left(d\gamma^{-2} + \ln(9/\delta)\right) \leq \frac{4c'}{m}\left(d\gamma^{-2} + \ln(1/\delta) + 3\right) \leq \frac{12c'}{m}\left(d\gamma^{-2} + \ln(1/\delta)\right).
\label{eq:subi}
\end{align}
Here we chose the probability $1-\delta/9$ in order to perform a union bound in the end of the induction step which is possible since the inductive hypothesis holds for every $\delta'$.
Next, define $\Err(h_i)$ as the set of points $x \in \mathcal{X}$ for which $h_i(x) \neq c(x)$.
Now fix an $i \in \{1,2,3\}$ and denote by $\{(Z_{i,1},c(Z_{i,1})), \dots, (Z_{i,N_i}, c(Z_{i,N_i})\} = A_i \cap (\Err(h_i) \times \{-1,1\})$, where $N_i = |A_i \cap (\Err(h_i) \times \{-1,1\})|$.
Said in words, the set $\{(Z_{i,j},c(Z_{i,j})\}_{j=1}^{N_i}$ is the subset of samples in $A_i$ on which $h_i$ makes a mistake.
Notice that $h_i$ is not trained on any samples from $A_i$ ($B_i$ excludes $A_i$), hence $h_i$ and $A_i$ are independent.
Therefore, given $h_i$ and $N_i$, the samples $Z_{i,1},\dots,Z_{i,N_i}$ are conditionally independent samples with distribution $\mathcal{D}(\cdot \mid \Err(h_i))$ (provided $N_i > 0$).
From Theorem~6 in the main paper, we get that there is an event $E_i'$ of probability at least $1-\delta/9$, such that if $N_i \geq c''\big(d\gamma^{-2} + \ln(1/\delta)\big)$, then every $h \in \mathcal{M}_{\gamma/2}\big(\big\{(Z_{i,j},c(Z_{i,j}))\big\}_{j=1}^{N_i}\big)$ satisfies
\[
\mathcal{L}_{\mathcal{D}(\cdot \mid \Err(h_i))}(h) ~\leq~ \tfrac{1}{200}.
\]
Note that this is a key step where our proof differs from Hanneke's original proof since we exploit that a bound of $\tfrac{1}{200}$ on the generalization error suffices for the rest of the proof.
We continue by observing that for each $j \in \{1,2,3\} \setminus \{i\}$, the set $B_j$ contains $A_i$ and this remains the case in all recursive calls of \textit{Sub-Sample}($A_0,B_i$).
Thus for $\{C_1,\dots,C_k\} = \textit{Sub-Sample}( A_0,B_j)$, it holds for all $C_k$ that $\mathcal{A}^*_{\nu}(C_k) \in \mathcal{M}_{\gamma/2}(B_j) \Rightarrow \mathcal{A}^*_{\nu}(C_k) \in \mathcal{M}_{\gamma/2}(A_0) \Rightarrow \mathcal{A}^*_{\nu}(C_k) \in \mathcal{M}_{\gamma/2}\big(\{(Z_{i,j},c(Z_{i,j}))\}_{j=1}^{N_i}\big)$.
Thus on the event $E_i'$, if $N_i > c''\big(d\gamma^{-2} + \ln(1/\delta)\big)$, then it holds for all $j \in \{1,2,3\}\setminus \{i\}$ and all $C_k \in \textit{Sub-Sample}(A_0,B_j)$, that the hypothesis $h = \mathcal{A}^*_{\nu}(C_k)$ satisfies
\begin{align*}
\Pr_{x \sim \mathcal{D}}\big[h_i(x) \neq c(x) \land h(x) \neq c(x)\big]
~=~ &\mathcal{L}_\mathcal{D}(h_i) \cdot \mathcal{L}_{\mathcal{D}(\cdot \mid \Err(h_i))}(h) \\
\leq~ &\tfrac{1}{200} \mathcal{L}_\mathcal{D}(h_i).
\end{align*}
Assume now that $\mathcal{L}_\mathcal{D}(h_i) \geq \big((10/7)c''(d\gamma^{-2} + \ln(1/\delta)) + 23\ln(9/\delta)\big)/(m/4) \geq 23\ln(9/\delta)/|A_i|$.
Using that $h_i$ and $A_i$ are independent, it follows by a Chernoff bound that
\begin{align*}
\Pr\big[N_i \geq (7/10) \mathcal{L}_\mathcal{D}(h_i)|A_i|\big]
~\geq~ &1-\exp\big({-}(3/10)^2 \mathcal{L}_\mathcal{D}(h_i)|A_i|/2\big) \\
\geq~ &1-\exp\big({-}(3/10)^2 \cdot 23 \ln(9/\delta)/2\big) \\
>~ &1-\delta/9.
\end{align*}
Thus there is an event $E''_i$ of probability at least $1-\delta/9$, on which, if $\mathcal{L}_\mathcal{D}(h_i) \geq \big((10/7)c''(d\gamma^{-2} + \ln(1/\delta)) + 23\ln(9/\delta)\big)/(m/4)$ then
\[
N_i \geq \tfrac{7}{10}\mathcal{L}_\mathcal{D}(h_i)|A_i| ~=~ \tfrac{7}{10}\mathcal{L}_\mathcal{D}(h_i)\cdot m/4 ~\geq~ c''(d\gamma^{-2} + \ln(1/\delta)).
\]
Combining it all, we have that on the event $E_i \cap E'_i \cap E''_i$, which occurs with probability at least $1-\delta/3$, if $\mathcal{L}_\mathcal{D}(h_i) \geq \big((10/7)c''(d\gamma^{-2} + \ln(1/\delta)) + 23\ln(9/\delta)\big)/(m/4)$, then every $h = \mathcal{A}^*_{\nu}(C_k)$ for a $C_k \in \textit{Sub-Sample}(A_0,B_j)$ with $j \neq i$ has:
\begin{align*}
\Pr_{x \sim \mathcal{D}}\big[h_i(x) \neq c(x) \wedge h(x) \neq c(x)\big] ~&\leq~ \tfrac{1}{200} \mathcal{L}_\mathcal{D}(h_i)\\
\intertext{By \cref{eq:subi}, this is at most}
\Pr_{x \sim \mathcal{D}}\big[h_i(x) \neq c(x) \wedge h(x) \neq c(x)\big] ~&\leq~ \frac{1}{200}\cdot\frac{12c'}{m} \left(d \gamma^{-2} + \ln(1/\delta)\right) \\ &\leq~ \frac{c'}{16m} \left(d \gamma^{-2} + \ln(1/\delta)\right).
\intertext{On the other hand, if $\mathcal{L}_\mathcal{D}(h_i) < \big(c''(d\gamma^{-2} + \ln(1/\delta)) + 23\ln(9/\delta)\big)/(m/4)$, then }
\Pr_{x \sim \mathcal{D}}\big[h_i(x) \neq c(x) \wedge h(x) \neq c(x)\big] ~&\leq~ \mathcal{L}_\mathcal{D}(h_i) \\
&\leq~ \big(c''(d\gamma^{-2} + \ln(1/\delta)) + 23\ln(9/\delta)\big)/(m/4) \\
&\leq~ 4c''(d \gamma^{-2} + 24\ln(1/\delta) + 23\ln 9)/m
\end{align*}
Using that $23\cdot \ln 9 < 51 \leq 51 d \gamma^{-2}$, the above is at most $204c''(d \gamma^{-2} + \ln(1/\delta))/m$. Fixing the constant $c'$ to $c' \geq (16 \cdot 204)c''$, this is at most
\begin{align*}
\frac{c'}{16m} \left(d \gamma^{-2} + \ln(1/\delta)\right).
\end{align*}
We conclude that on the event $\bigcap_{i=1,2,3} \{E_i \cap E'_i \cap E''_i\}$, which occurs with probability at least $1-\delta$ by a union bound, it holds for all $i$ and all $C_k \in \text{Sub-Sample}(A_0,B_j)$ with $j \neq i$ that the hypothesis $h = \mathcal{A}^*_{\nu}(C_k)$ satisfies:
\begin{align*}
\Pr_{x \sim \mathcal{D}}\big[h_i(x) \neq c(x) \wedge h(x) \neq c(x)\big] ~&\leq~ \frac{c'}{16m} \left(d \gamma^{-2} + \ln(1/\delta)\right).
\end{align*}
Now consider an $x$ on which $\hat{h}_{m,B}$ errs. On such an $x$, the majority among the classifiers
\begin{align*}
\bigcup_{C_i \in \textit{ Sub-Sample}(S_{1:m},B)} \big\{\mathcal{A}^*_{\nu}(C_i)\big\} ~=~ \bigcup_{i =1,2,3} ~\bigcup_{C_k \in \textit{ Sub-Sample}(S_{1:m/4},B_i)} \big\{\mathcal{A}^*_{\nu}(C_k)\big\}.
\end{align*}
errs. For the majority to err, there must be an $i \in \{1,2,3\}$ for which the majority of
\begin{align*}
\bigcup_{C_k \in \textit{ Sub-Sample}(S_{1:m/4},B_i)} \big\{\mathcal{A}^*_{\nu}(C_k)\big\}.
\end{align*}
errs. This is equivalent to $h_i(x) \neq c(x)$. Furthermore, even when all of the classifiers in
\begin{align*}
\bigcup_{C_k \in \textit{ Sub-Sample}(S_{1:m/4},B_i)} \big\{\mathcal{A}^*_{\nu}(C_k)\big\}.
\end{align*}
err, there still must be another $(1/6)$-fraction of all the classifiers
\begin{align*}
\bigcup_{i =1,2,3} ~\bigcup_{C_k \in \textit{ Sub-Sample}(S_{1:m/4},B_i)} \big\{\mathcal{A}^*_{\nu}(C_k)\big\}.
\end{align*}
that err. This follows since each of the three recursive calls in \textit{Sub-Sample} generated equally many classifiers/samples. It follows that if we pick a uniform random $i \in \{1,2,3\}$ and a uniform random hypothesis $h$ in
\begin{align*}
\bigcup_{j \in \{1,2,3\} \setminus \{i\}} ~\bigcup_{C_k \in \textit{ Sub-Sample}(S_{1:m/4},B_j)} \{\mathcal{A}^*_{\nu}(C_k)\}.
\end{align*}
then with probability at least $(1/3)(1/6)(3/2) = 1/12$, we have that $h_i(x) \neq c(x) \wedge h(x) \neq c(x)$. It follows by linearity of expectation that on the event $\bigcap_{i=1,2,3} \{E_i \cap E'_i \cap E''_i\}$, we have:
\begin{align*}
\mathcal{L}_\mathcal{D}(\hat{h}_{m,B}) ~\leq~ 12 \cdot \frac{c'}{16m}\left(d \gamma^{-2} + \ln(1/\delta)\right) ~<~ \frac{c'}{m}\left(d \gamma^{-2} + \ln(1/\delta)\right).
\end{align*}
This completes the inductive proof and shows \cref{thm:finalSupplement}.
In total there are $k = 3^{\lceil\log_4(m)\!\rceil} \approx m^{0.79}$ calls to the weak learner, each with a sub-sample of linear size.
Since AdaBoost$_\nu^*$ runs in polynomial time on its input, given that the weak learner is polynomial, \cref{alg:final} is polynomial under the same condition.
Let us also remark that in \cref{thm:constantgen} we have a failure probability $\delta_0>0$, while the analysis of AdaBoost$_\nu^*$ assumes $\delta_0 = 0$, i.e. that the weak learner always achieves an advantage of at least $\gamma$.
If one knows $\gamma$ in advance, this is not an issue as AdaBoost$_\nu^*$ only calls the weak learner on distributions over the training data $S$ and one can thus compute the advantage from the training data.
After in expectation $1/(1-\delta_0)$ invocations of the weak learner, we thus get a hypothesis with advantage $\gamma$.
\section{Lower bound}
\label{sec:lowerBound}
\label{sec:lowerBoundFull}
In this section, we prove the following lower bound:
\begin{theorem}
\label{thm:lower}
There is a universal constant $\alpha > 0$ such that for all integers $d \in \mathbb{N}$ and every $0 < \gamma < 1/80$, there is a finite set $\mathcal{X}$, a concept class $\mathcal{C} \subset \mathcal{X} \to \{-1,1\}$ and a hypothesis set $\mathcal{H} \subseteq \mathcal{X} \to \{-1,1\}$ of VC-dimension at most $d$, such that for every integer $m \in \mathbb{N}$ and $0 < \delta < 1/3$, there is a distribution $\mathcal{D}$ over $\mathcal{X}$ such that the following holds:
\begin{enumerate}
\item For every $c \in \mathcal{C}$ and every distribution $\mathcal{D}'$ over $\mathcal{X}$, there is an $h \in \mathcal{H}$ with
\[
\Pr_{x \sim \mathcal{D}'}\big[h(x) \neq c(x)\big] ~\leq~ 1/2-\gamma.
\]
\item For any algorithm $\mathcal{A}$, there is a concept $c \in \mathcal{C}$ such that with probability at least $\delta$ over a set of $m$ samples $S \sim \mathcal{D}^m$, the classifier $\mathcal{A}(S) \in \mathcal{X} \to \{-1,1\}$ produced by $\mathcal{A}$ on $S$~and~$c(S)$ must have
\[
\mathcal{L}_\mathcal{D}(\mathcal{A}(S)) ~\geq~ \alpha \cdot \frac{d \gamma^{-2} + \ln(1/\delta)}{m}.
\]
\end{enumerate}
\end{theorem}
\cref{thm:lower} immediately implies \cref{thm:lowerintro} by solving the equation in the second statement for $\varepsilon = \mathcal{L}_\mathcal{D}(\mathcal{A}(S))$.
The proof of the term $\ln(1/\delta)/m$ in the lower bound follows from previous work.
In particular, we could let $\mathcal{C} = \mathcal{H}$ and invoke the tight lower bounds for PAC-learning in the realizable setting \citep{ehrenfeucht1989general}.
Thus, we let $\delta=1/3$ and only prove that the loss of $\mathcal{A}(S)$ is at least $\alpha d /(\gamma^{2} m)$ with probability $1/3$ over $S$ when $\abs{S}=m$ for some weakly learnable concept class $\mathcal{C}$.
This proof uses a construction from \citet{kasper2019lowerBoundBoosting} to obtain a hypothesis set $\mathcal{H}$ over a domain $\mathcal{X} = \{x_1,\dots,x_u\}$ of cardinality $u=\alpha d \gamma^{-2}$ such that a constant fraction of all concepts in $\mathcal{X} \to \{-1,1\}$ can be $\gamma$-weakly learned from $\mathcal{H}$.
We then create a distribution $\mathcal{D}$ where the first point $x_1$ is sampled with probability $1-u/(4m)$ and with the remaining probability, we receive a uniform sample among $x_2,\dots,x_u$.
The key point is that we only expect to see $1 + m \cdot u/(4m) \approx u/4$ distinct points from $\mathcal{X}$ in a sample $S$ of cardinality $m$.
Thus, if we consider a random concept that can be $\gamma$-weakly learned, the labels it assigns to points not in the sample are almost uniform random and independent.
This in turn implies that the best any algorithm $\mathcal{A}$ can do is to guess the labels of points in $\mathcal{X} \setminus S$.
In that way, $\mathcal{A}$ fails with constant probability if we condition on receiving a sample other than $x_1$.
This happens with probability $u/(4m) = 4\alpha d \gamma^{-2}/m$ and the lower bound follows.
To formally carry out the intuitive argument, we first argue that for a random concept $c \in \mathcal{C}$, the Shannon entropy of $c$ is high, even conditioned on $S$ and the labels $c(S)$.
Secondly, we argue that if $\mathcal{A}(S)$ has a small error probability under $\mathcal{D}$, then it must be the case that the hypothesis $\mathcal{A}(S)$ reveals a lot of information about $c$, i.e. the entropy of $c$ is small conditioned on $\mathcal{A}(S)$.
Since $\mathcal{A}(S)$ is a function of $S$ and $c(S)$, the same holds if we condition on $S$ and $c(S)$.
This contradicts that $c$ has high entropy and thus we conclude that $\mathcal{A}(S)$ cannot have a small error probability.
For the proof, we make use of the following lemma by \citet{kasper2019lowerBoundBoosting} to construct the `hard' hypothesis set $\mathcal{H}$ and concept class $\mathcal{C}$:
\begin{lemma}[\citet{kasper2019lowerBoundBoosting}]
\label{lem:randH}
For every $\gamma \in (0,1/40), \delta \in (0,1)$ and integers $k \leq u$, there exists a distribution $\mu = \mu(u,d,\gamma,\delta)$ over a hypothesis set $\mathcal{H} \subset \mathcal{X} \to \{-1,1\}$, where $\mathcal{X}$ is a set of size $u$, such that the following holds.
\begin{enumerate}
\item For all $\mathcal{H} \in \supp(\mu)$, we have $|\mathcal{H}|=N$; and
\item For every labeling $\ell \in \{-1,1\}^u$, if no more than $k$ points $x \in \mathcal{X}$ satisfy $\ell(x) = -1$, then
\[
\Pr_{\mathcal{H} \sim \mu}\big[\exists f \in \Delta(\mathcal{H}) : \forall x \in \mathcal{X} : \ell(x)f(x) \geq \gamma\big] ~\geq~ 1-\delta.
\]
where $N = \Theta\big(\gamma^{-2} \ln u \ln(\gamma^{-2} \ln u \delta^{-1}) e^{\Theta(\gamma^2 k)}\big)$.
\end{enumerate}
\end{lemma}
To prove \cref{thm:lower} for a given $\gamma \in (0,1/80)$ and $m,d \in \mathbb{N}$, let $u=k$ for a $u$ to be determined.
Invoke \cref{lem:randH} with $\delta=1/2$ and $\gamma'=2\gamma$ to conclude that there exists a hypothesis set $\mathcal{H}$ such that among all labelings $\ell \in \{-1,1\}^u$, at least half of them satisfy:
\[
\exists f \in \Delta(\mathcal{H}) : \forall x \!\in\! \mathcal{X}:\, \ell(x)f(x) \geq 2\gamma.
\]
Moreover, we have $N = |\mathcal{H}| = \Theta\big(\gamma^{-2} \ln u \ln(\gamma^{-2} \ln u) e^{\Theta(\gamma^2 u)}\big)$.
Let the concept class $\mathcal{C}$ be the set of such labelings.
For the given VC-dimension $d$, we need to bound the VC-dimension of $\mathcal{H}$ by $d$.
For this, note that the VC-dimension is bounded by $\lg |\mathcal{H}| = \Theta(\gamma^2 u)$.
We thus choose $u=\Theta(\gamma^{-2} d)$ which implies the claimed VC-dimension of $\mathcal{H}$.
Next, we have to argue that any concept $c \in \mathcal{C}$ can be $\gamma$-weakly learned from $\mathcal{H}$.
That is, the first statement of \cref{thm:lower} holds for $\mathcal{H}$, $\mathcal{C}$.
To see this, we must show that for every distribution $\mathcal{D}$ over $\mathcal{X}$, there is a hypothesis $h \in \mathcal{H}$ such that $\Pr_{x \sim \mathcal{D}}[h(x) = c(x)] \geq 1/2 + \gamma$.
To argue that this is indeed the case, let $f \in \Delta(\mathcal{H})$ satisfy $\forall x\! \in\! \mathcal{X} : \, c(x)f(x) \geq 2\gamma$.
Such an $f$ exists by definition of $\mathcal{C}$.
Then, $\E_{x \sim \mathcal{D}}[c(x)f(x)] \geq 2\gamma$.
Since $f(x)$ is a convex combination of hypotheses from $\mathcal{H}$, it follows that there is a hypothesis $h \in \mathcal{H}$ also satisfying $\E_{x \sim \mathcal{D}}[c(x)h(x)] \geq 2\gamma$.
But
\begin{align*}
\E_{x \sim \mathcal{D}}[c(x)h(x)] ~&=~ \sum_{x \in \mathcal{X}} \mathcal{D}(x) c(x) h(x) \\
&=~ \sum_{x \in \mathcal{X} \colon c(x)=h(x)} \!\mathcal{D}(x) ~- \sum_{x \in \mathcal{X} \colon c(x) \neq h(x)} \!\mathcal{D}(x)\\
&=~ \Pr_{x \sim \mathcal{D}}[c(x)=h(x)] - \Pr_{x \sim \mathcal{D}}[c(x) \neq h(x)] \\
&=~ \Pr_{x \sim \mathcal{D}}[c(x)=h(x)] - (1-\Pr_{x \sim \mathcal{D}}[c(x)=h(x)] )\\
&=~ 2 \Pr_{x \sim \mathcal{D}}[c(x)=h(x)] - 1.
\end{align*}
Hence, $2\cdot \Pr_{x \sim \mathcal{D}}[c(x)=h(x)] - 1 \geq 2\gamma \implies \Pr_{x \sim \mathcal{D}}[c(x)=h(x)] \geq 1/2 + \gamma$ as claimed.
We have thus constructed $\mathcal{H}$ and $\mathcal{C}$ satisfying the first statement of \cref{thm:lower}, where $\mathcal{C}$ contains at least half of all possible labelings of the points $\mathcal{X} = \{x_1,\dots,x_u\}$ with $u = \Theta(\gamma^{-2} d)$. For the remainder of the proof, we assume $u$ is at least some large constant, which is true for $\gamma$ small enough.
What remains is to establish the second statement of \cref{thm:lower}.
For this, we first define the hard distribution $\mathcal{D}$ over $\mathcal{X}$.
The distribution $\mathcal{D}$ returns the point $x_1$ with probability $1-(u-1)/4m$ and with the remaining probability $(u-1)/4m$ it returns a uniform random sample $x_i$ among $x_2,\dots,x_u$.
Also, let $c$ be a uniform random concept drawn from $\mathcal{C}$.
Let $\mathcal{A}$ be any (possibly randomized) learning algorithm that on a set of samples $S$ from $\mathcal{X}$ and a labeling $\ell(S)$ of $S$ that is consistent with at least one concept $c \in \mathcal{C}$ (i.e. $\ell(S)=c(S)$), outputs a hypothesis $h_{S,\ell(S)}$ in $\mathcal{X} \to \{-1,1\}$.
The algorithm $\mathcal{A}$ is not constrained to output a hypothesis from $\Delta(\mathcal{H})$ or $\mathcal{H}$, but instead may output any desirable hypothesis in $\mathcal{X} \to \{-1,1\}$, using the full knowledge of $\mathcal{C}$, $\ell(S)$, $\mathcal{H}$ and the promise that $c \in \mathcal{C}$.
Our goal is to show that
\begin{align}
\label{eq:goallower}
\E_{c\sim \mathcal{C}}\left[\Pr_{S \sim \mathcal{D}^m}\left[\Pr_{x \sim \mathcal{D}}[h_{S,c(S)}(x) \neq c(x)] \geq \alpha'\frac{d \gamma^{-2}}{m}\right]\right] \geq 1/3
\end{align}
where $c\sim \mathcal{C}$ denotes the uniform random choice of $c$.
Notice that if this is the case, there must exist a concept $c$ for which
\begin{align*}
\Pr_{S \sim \mathcal{D}^m}\left[\Pr_{x \sim \mathcal{D}}[h_{S,c(S)}(x) \neq c(x)] \geq \alpha'\frac{d \gamma^{-2}}{m}\right] \geq 1/3.
\end{align*}
To establish \cref{eq:goallower}, we start by observing that for any randomized algorithm $\mathcal{A}$, there is a deterministic algorithm $\mathcal{A}'$ obtaining a smaller than or equal value of the left hand side of \cref{eq:goallower} (by Yao's principle).
Thus, we assume from here on that $\mathcal{A}$ is deterministic.
The main idea in our proof is to first show that conditioned on the set $S$ and label $c(S)$, the concept~$c$ is still largely unknown. We formally measure this by arguing that the binary Shannon entropy of~$c$ is large conditioned on $S$ and $c(S)$. Next, we argue that if a learning algorithm often manages to produce an accurate hypothesis from $S$ and $c(S)$, then that reveals a lot of information about $c$, i.e. the entropy of $c$ is small conditioned on $S$ and $c(S)$. This contradicts the first statement and thus the algorithm cannot produce an accurate hypothesis. We now proceed with the two steps.
\paragraph{Large conditional entropy.}
Consider the binary Shannon entropy of the uniform random $c$ conditioned on $S$ and $c(S)$, denoted $H(c \mid S, c(S))$.
We know that $H(c) = \lg |\mathcal{C}| \geq \lg(2^u/2) = u-1$.
The random variable $c$ is independent of $S$, hence $H(c \mid S) = H(c)$.
We therefore have $H(c \mid S,c(S)) \geq H(c \mid S) - H(c(S) \mid S) = u-1-H(c(S) \mid S)$.
For a fixed $s \in \mathcal{X}^m$, let $p_s = \Pr_{S \sim \mathcal{D}^m}[S=s]$.
Then $H(c(S) \mid S) = \sum_{s \in \mathcal{X}^m} p_s H(c(S) \mid S=s) \leq \sum_{s \in \mathcal{X}^m} p_s |s|$, where the last step follows from the fact that, conditioned on $s$, the labeling $c(s)$ consists of $|s|$ signs.
Note that the size of the set $|s|$ is possibly smaller than $m$ due to repetitions.
Now notice that $\Pr[|S| > u/3]$ is exponentially small in $u$ since each of the $m$ samples from $\mathcal{D}$ is among $x_2,\dots,x_u$ with probability only $(u-1)/(4m)$.
Therefore, we get $H(c(S) \mid S) \leq u/3 + \exp(-\Omega(u))u \leq u/2-1$.
It follows that
\begin{align}
\label{eq:highentropy}
H(c \mid S,c(S)) ~\geq~ u-1-(u/2-1) ~=~ u/2.
\end{align}
\paragraph{Accuracy implies low entropy.}
Now assume that $h_{S,c(S)}$ is such that $\Pr_{x \sim \mathcal{D}}[h_{S,c(S)} \neq c(x)] < \alpha'd\gamma^{-2}/m$ for a sufficiently small constant $\alpha'$.
Any point $x_i$ where $c(x_i)$ disagrees with $h_{S,c(S)}(x_i)$ adds at least $1/(4m)$ to $\Pr_{x \sim \mathcal{D}}[h_{S,c(S)} \neq c(x)]$ (the point $x_1$ would add more), hence $h_{S,c(S)}$ makes a mistake on at most $\alpha'd\gamma^{-2}/m \cdot (4m) = 4 \alpha' d \gamma^{-2}$ points.
Recalling that $u = \Theta(d \gamma^{-2})$, we get that for $\alpha'$ small enough, this is less than $u/100$.
Thus, conditioned on $\Pr_{x \sim \mathcal{D}}[h_{S,c(S)} \neq c(x)] < \alpha'd\gamma^{-2}/m$, we get that the entropy of $c(S)$ is no more than $\lg \left( \sum_{i=0}^{u/100} \binom{u}{i} \right)$ since $c(S)$ is within a Hamming ball of radius $u/100$ from $h_{S,c(S)}$.
Now $\sum_{i=0}^{u/100} \binom{u}{i} \leq 2^{H_b(1/100) u}$, where $H_b$ is the binary entropy of a Bernoulli random variable with success probability $1/100$.
Numerical calculations give $H_b(1/100) = (1/100)\lg_2(100) + (99/100)\lg_2(100/99) < 0.09$.
Thus
\begin{align}
\label{eq:lowentropy}
H\Big(\,c\, \Big\arrowvert\, h_{S,c(S)},\, \Pr_{x \sim \mathcal{D}}[h_{S,c(S)} \neq c(x)] < \alpha'd\gamma^{-2}/m\Big) ~\leq~ 0.09 u.
\end{align}
Now let $X_{S,c}$ be an indicator random variable for the event that $\Pr_{x \sim \mathcal{D}}[h_{S,c(S)} \neq c(x)] < \alpha'd\gamma^{-2}/m$.
Then $H(c \mid S,c(S)) \leq H(c \mid S, c(S), h_{S,c(S)}, X_{S,c}) + H(X_{S,c})$.
Here we remark that we add $h_{S,c(S)}$ in the conditioning for free since it depends only on $S$ and $c(S)$.
Adding $X_{S,c}$ costs at most its entropy which satisfies $H(X_{S,c}) \leq 1$. Since removing variables that we condition on only increases entropy, we get $H(c \mid S,c(S)) \leq H(c \mid h_{S,c(S)}, X_{S,c}) + 1$. Now observe that $H(c \mid h_{S,c(S)}, X_{S,c}) = \Pr[X_{S,c}=1] H(c \mid h_{S,c(S)}, X_{S,c}=1) + \Pr[X_{S,c}=0] H(c \mid h_{S,c(S)}, X_{S,c}=0)$.
The latter entropy we simply bound by $u$ and the former is bounded by $0.09u$ by \cref{eq:lowentropy}.
Thus $H(c \mid S,c(S)) \leq 1 + \Pr[X_{S,c}=1]0.09u + (1-\Pr[X_{S,c}=1])u$.
\paragraph{Combining the bounds.}
Combining the above with \cref{eq:highentropy} we conclude that
\begin{align*}
1 +\Pr[X_{S,c}=1]0.09u + (1-\Pr[X_{S,c}=1])u ~\geq~ u/2.
\end{align*}
It follows that $\Pr[X_{S,c}=1] \leq 2/3$.
This completes the proof since
\begin{align*}
\E_{c\sim \mathcal{C}}\left[\Pr_{S \sim \mathcal{D}^m}\left[\Pr_{x \sim \mathcal{D}}[h_{S,c(S)}(x) \neq c(x)] \geq \alpha'\frac{d \gamma^{-2}}{m}\right]\right]
~&=~ \E_{c\sim \mathcal{C}} \big[\E_{S \sim \mathcal{D}^m}[(1-X_{S,c})]\big] ~=~ 1-\Pr[X_{S,c}=1]
\end{align*}
and thus
\begin{align*}
\E_{c\sim \mathcal{C}}\left[\Pr_{S \sim \mathcal{D}^m}\left[\Pr_{x \sim \mathcal{D}}[h_{S,c(S)}(x) \neq c(x)] \geq \alpha'\frac{d \gamma^{-2}}{m}\right]\right] ~&\geq~ \frac{1}{3}.
\end{align*}
This finishes the proof of \cref{thm:lower}.
\section{Conclusion}
Overall, we presented a new weak to strong learner with a sample complexity that removes two logarithmic factors from the best-known bound.
By accompanying the algorithm with a matching lower bound, we showed that the achieved sample complexity of our algorithm is indeed optimal.
Our algorithm uses the same sub-sampling technique as \citet{hanneke2016optimal} and computes a voting classifier with large margins for each sample for example with AdaBoost$_\nu^*$ \citep{ratsch2005efficient}.
The analysis of our algorithm uses a new generalization bound for voting classifiers with large margins.
Although we determined the exact sample complexity of weak to strong learning (up to multiplicative constants), there are a few connected open problems.
Currently, our construction uses $3^{\log_4(m)} \approx m^{0.79}$ many sub-samples of linear size as input to AdaBoost$_\nu^*$.
For very large datasets, it would be great to reduce the number and size of these calls.
Next, the output of our algorithm is a majority vote over majority voters.
It is unclear whether a simple voter could achieve the same bounds.
Last, it would be intriguing to see what can still be proven for voting classifiers that have margins $\gamma$ on most, but not all, data points.
\newpage
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2022-06-09T02:10:46', 'yymm': '2206', 'arxiv_id': '2206.01563', 'language': 'en', 'url': 'https://arxiv.org/abs/2206.01563'} | arxiv |
\section{Introduction}
\label{sec:intro}
The \textsc{Chase} is a widely applicable technique for reasoning with constraints. It takes a parameter $\ast$ and an object $\bigcirc$ as input, and forms a result that corresponds to the combination of both. In this way, the parameter is incorporated into the object, so that $\ast$ is explicitly contained in $\bigcirc$, denoted $\text{\textsc{Chase}}_\ast(\bigcirc) = \text{\textcircled{$\ast$}}$. The versatile applicability of the \textsc{Chase} is due to the fact that one can pass different types of objects and parameters as input. Instead of considering queries and instances separately (as other implementations do), ChaTEAU generalizes both to a \textsc{Chase} object. Similarly, the \textsc{Chase} parameter in ChaTEAU generalizes dependencies, queries, and views by treating them uniformly as logic formulas.
Applying the \textsc{Chase} to instances \cite{BMKPTMS17} and queries \cite{DPT99} behaves in a similar manner, because the structure of queries and instances is also quite similar. However, existing \textsc{Chase} tools such as PDQ~\cite{BLT14}, Llunatic \cite{GMPS20}, or Graal \cite{BLMRS15} are limited to specific use cases, e.g., semantic optimization, data cleaning and exchange, or query answering with existential rules.
These different use cases can be reduced to the processing of instances and queries.
With ChaTEAU (\textsc{\textbf{Cha}se} for \textbf{T}ransforming, \textbf{E}volving, and \textbf{A}dapting databases and queries, \textbf{U}niversal Approach) we have developed and implemented a universal \textsc{Chase} tool that abstracts instances and queries to a general \textsc{Chase} object and parameter. The software, examples, and further information are available at our Git repository\footnote{Git repository: \url{https://git.informatik.uni-rostock.de/ta093/ChaTEAU-demo}}.
The uniform treatment of \textsc{Chase} use cases and variants in ChaTEAU makes it ideal for embedding it in different applications, e.g., for data exchange, data cleaning, or query reformulations with constraints.
For specific applications, additional extensions such as provenance or a second \textsc{Backchase}-phase may be necessary. These extensions are being added gradually to ChaTEAU and can be selected individually depending on the target use case. We are currently integrating \textbf{\textit{where}}-, \textbf{\textit{why}}- and \textbf{\textit{how}}-provenance \cite{HDL17} to provide provenance-supported applications as well.
\paragraph{\textbf{Structure of the article:}}
Section ~\ref{sec:generalization} describes our \textsc{Chase} generalization; Section \ref{sec:features} discusses the ChaTEAU implementation. Finally, the ChaTEAU demonstration and GUI are presented in Section \ref{sec:demo}, using a concrete example.
\section{Generalization of the \textsc{Chase}}
\label{sec:generalization}
Recall that the \textsc{Chase} modifies a given object $\bigcirc$, called \textit{\textsc{Chase} object}, by incorporating a parameter $\ast$ (the \textit{\textsc{Chase} parameter}), which we can write as $\text{\textsc{Chase}}_\ast(\bigcirc) = \text{\textcircled{$\ast$}}$. While $\bigcirc$ can represent both queries and instances, we understand $\ast$ as set of constraints formalized as (s-t) tgds and/or egds. An \textit{equality generating dependency (egd)} is a formula of the form $\forall \textbf{x}(\phi(\textbf{x}) \rightarrow (x_1 = x_2))$. A formula of the form $\forall \textbf{x}(\phi(\textbf{x}) \rightarrow \exists \textbf{y} : \psi(\textbf{x}, \textbf{y}))$ is called \textit{(source-to-target) tuple generating dependency ((s-t) tgd)} with $\phi$ (\textit{body}) and $\psi$ (\textit{head}) conjunctions of atomic formulas over a source and target schema, respectively. If the source and target schemas are the same, the constraint is simply a tgd. As their names suggest, egds and tgds derive new equalities and new tuples (with $\exists$-quantified variables), respectively.
First approaches to extend the \textit{Standard \textsc{Chase}} \cite{BMKPTMS17} to arbitrary objects and parameters can be found in \cite{AH19}. Note that the \textsc{Chase} parameter $\ast$ either represents intra-database dependencies (as tgds or egds) or inter-database dependencies (as s-t tgds). The hierarchy in Figure \ref{fig:formalisations} shows how other dependencies can be represented as either (s-t) tgds or egds.
The \textsc{Chase} object $\bigcirc$ is either a query $Q$ or a database instance $I$. In both cases, variables and null values can be replaced by other variables and null values or constants. The variable substitution rules depend on certain conditions. Let's have a closer look at them.
\paragraph{\textbf{\textsc{Chase} Parameter}}
The \textsc{Chase} parameter $\ast$ consists of a set of dependencies $\Sigma$ in the form of egds or (s-t) tgds. These are generalizations of the classical \textit{functional dependencies (FD)} and \textit{join dependencies (JD)}. Any condition that can be written as a set of (s-t) tgds and egds can be used as a \textsc{Chase} parameter. This includes views,
queries, and integrity constraints as seen in Figure \ref{fig:formalisations}.
\paragraph{\textbf{\textsc{Chase} Object}}
The database tuple $\textsc{student}(3,\text{'Max'},\text{'Math'})$ and the query atom $\textsc{student}(y_\text{id},x_\text{name},\text{'Math'})$ are very similar in structure. A \textsc{Chase} object is an abstraction of both. The tuple consists of constants ($c_i$) and null values ($\eta_1$) while the expression contains (implicitly) $\forall$-quantified variables ($x_i$), $\exists$-quantified variables ($y_i$) and constants ($c_i$).
A database \textit{instance} $I$ over schema $R$ consists of finite relations $R^I_1, ..., R^I_k$, where each relation $R_i^I$ has the same arity as the relation symbol $R_i$. Each tuple $(x_1, ..., x_n)$ in $R^I_i$ consists of constants $c_i$ or null values $\eta_i$.
A \textit{conjunctive query} is a first-order formula of the form $\exists y : \phi(x,y) \rightarrow \psi(x)$ with $\phi(x,y)$ a conjunction of logic atoms (the \textit{body}) and $\psi(x)$ a single atom (the \textit{head}). The terms in $\phi$ are $\forall$-quantified or $\exists$-quantified variables, or constants. The head $\psi$ must not contain $\exists$-variables.
A query $Q$ can be transformed into a \textit{frozen instance} $I_Q$, in which each atom of $Q$'s body is represented as a tuple in $I_Q$~\cite{DNR08}. There are different ways to deal with the variables in $Q$. Often $\exists$-variables are transformed into null values and $\forall$-variables are treated as \textit{labeled null} values or special constants. For the transformation of a conjunctive query $Q$ into a generalized instance, the atoms in the body have to be written as generalized tuples. We create tuples with $\exists$- and $\forall$-variables, e.g., as follows:
\begin{eqnarray*}
Q & = & \exists y_\text{id}: \textsc{student}(y_\text{id},x_\text{name},\text{'Math'}) \rightarrow (x_\text{name}) \\
I_Q & = & \{\textsc{student}(y_\text{id},x_\text{name},\text{'Math'})\}.
\end{eqnarray*}
These generalized tuples can be extended to a generalized instance, as described in Definition \ref{def:instance}. While ChaTEAU can handle general s-t tgds, here we focus on queries, which can be seen as s-t tgds with a single atom in the head.
\begin{definition}
\label{def:instance}
Let $I$ be an instance and $Q$ a conjunctive query. A \textit{generalized instance} is either:
\begin{itemize}
\item a set of (conventional) relations $R^I_1, ..., R^I_k$, i.e., where tuples consist of constants and null values, or
\item a set of generalized tuples, consisting of the atoms of $\phi(x,y)$, with constants, $\forall$-variables, and $\exists$-variables.
\end{itemize}
\end{definition}
\paragraph{\textbf{The \textsc{Chase} for Generalized Instances}}
Due to the different kinds of \textsc{Chase} objects $O_i$, the \textsc{Chase} steps $I_{O_i} \rightarrow I_{O_{i+1}}$ have to be generalized too, when using (s-t) tgds and egds. In ChaTEAU, we thus extend the Standard \textsc{Chase} \cite{BMKPTMS17} to a \textit{\textsc{Chase} for generalized instances} (see Algorithm \ref{alg:CHASE}).
The main task of the \textsc{Chase} is to infer new facts. To this end, we need to find mappings (\textit{homomorphisms}) between the dependencies $\Sigma$ and the \textsc{Chase} object $O$. Using these, the \textsc{Chase} maps a set of dependencies $\Sigma$ into $O$. The result is a modified \textsc{Chase} object $O'$. Between $O$ and $O'$ we also have a homomorphism.
\begin{definition}
Let $\phi(\textbf{x})$ be the body and $\psi(\textbf{x},\textbf{y})$ the head of a dependency. Let $I_{O_1}$ and $I_{O_2}$ be generalized instances. We define the following possible substitution rules:
\begin{enumerate}
\item a constant can be mapped to itself: $c_i \mapsto c_i$
\item a null value can be mapped to a constant, itself, or another null value: $\eta_i \mapsto c_j \mid \eta_i \mid \eta_j$
\item an $\exists$-variable can be mapped to a constant, itself, a null value, or another $\exists$- or $\forall$-variable: \\
(a) $y_i \mapsto c_j \mid \eta_j \mid y_i \mid x_j$ \hspace{1cm} (b) $y_i \mapsto c_j \mid y_i \mid y_j \mid x_j$
\item a $\forall$-variable can be mapped to a constant, a null value, itself, or another $\forall$- or $\exists$-variable: \\
(a) $x_i \mapsto c_j \mid \eta_j \mid x_i \mid y_j$ \hspace{1.05cm} (b) $x_i \mapsto c_j \mid x_i$
\end{enumerate}
Now a \textit{homomorphism} $h: \phi(\textbf{x}) \rightarrow I_{O_1}$ is a mapping that satisfies (1) and (4a); a \textit{homomorphism} $h: \psi(\textbf{x},\textbf{y}) \rightarrow I_{O_2}$ is a mapping that satisfies (1), (3a), and (4a); and a \textit{homomorphism} $h: I_{O_1} \rightarrow I_{O_2}$ is a mapping that satisfies (1), (2), (3b), and (4b).
\end{definition}
\begin{figure}[t]
\centering
\includegraphics[width=0.4\textwidth]{ChaTEAU-dependencies}
\caption{Constraints hierarchy and how they are formalized}
\label{fig:formalisations}
\end{figure}
Tgds insert new tuples to instances or add atoms to a query body. These changes are created by applying a particular homomorphism, called \textit{trigger}, from the tgd-body to the generalized instance. Egds equate variables by applying a homomorphism from the egd-body to the generalized instance. An \textit{active trigger} is one that (1) creates new tuples or expressions by applying an (s-t) tgd, or (2) leads to a new equation of variables or null values by applying an egd.
\begin{definition}
\label{def:trigger}
A \textit{trigger} is a homomorphism $h$ from a dependency body to a generalized instance, i.e., $h : \phi(\textbf{x}) \rightarrow I_O$.
An \textit{active trigger} is a trigger that satisfies for a
\begin{itemize}
\item[(1)] tgd: no extension of $h$ to an homomorphism $\psi(\textbf{x},\textbf{y}) \rightarrow I_O$,
\item[(2)] egd: $h(x_1) \neq h(x_2)$.
\end{itemize}
\end{definition}
If no new tuples or equals are created during a \textsc{Chase} execution, the trigger is not active. However, if an $\exists$-variable is contained in the tgd-head, we always have an active trigger.
These variables will map to new null values or $\exists$-variables, depending on the type of \textsc{Chase} object.
We extend the Standard \textsc{Chase} to generalized instances. This new \textsc{Chase} version modifies a generalized instance by a sequence of \textsc{Chase} steps until all dependencies are satisfied.
\begin{definition}
Let $h : \phi(\textbf{x}) \rightarrow I_{O_i}$ be an active trigger for a dependency $\sigma$ and a generalized instance $I_{O_i}$. The modification of $I_{O_i}$ to $I_{O_{i+1}}$ by applying $\sigma$ under $h$ is called \textit{\textsc{Chase} step}.
\end{definition}
\begin{definition
Let $\Sigma$ be a set of dependencies and $I_{O_0}$ a generalized instance. The (finite) \textit{\textsc{Chase} for generalized instances} is a finite sequence of \textsc{Chase} steps $I_{O_i} \rightarrow I_{O_{i+1}}$ ($0 \le i \le n$) with
\begin{itemize}
\item $I_{O_n} = \bot$ (\textsc{Chase} fails),
\item $I_{O_n} = I_{O_{n+1}}$, i.e. exists an homomorphism $h: I_{O_n} \rightarrow I_{O_{n+1}}$ with $h(z_j) = z_j$ and $z_j \in \{c_j, \eta_j, x_j, y_j\}$.
\end{itemize}
\end{definition}
Finally, the result calculated with the \textsc{Chase} on generalized instances must be interpreted. Applying an egd, the \textsc{Chase} on instances fails if different constants are matched to each other, and returns $\bot$, whereas the \textsc{Chase} on queries returns $\emptyset$. The \textsc{Chase} result on $Q$ corresponds to the transformation of $I_{Q_n}$ into a new query $Q'$. For this, the tuples of $I_{Q_n}$ form a conjunction of atoms in the body of $Q'$. The query head is formed by applying the composition of all homomorphism collected during the \textsc{Chase}-execution. Thus, the \textsc{Chase} implemented in ChaTEAU works on arbitrary s-t tgds.
\begin{algorithm}
\caption{\textsc{Chase} for generalized instances ($\Sigma$, $I_{O_0}$)}
\label{alg:CHASE}
\begin{algorithmic}[1]
\REQUIRE set of dependencies $\Sigma$, a database instance $I_{O_0}$
\ENSURE modified database instance $I_{O_n}$
\WHILE{$I_{O_j} \neq \bot$ \AND $I_{O_{j-1}}\neq I_{O_j}$}
\FORALL{trigger $h$ for $\sigma \in \Sigma$}
\IF {\textcolor{red}{$h$ is an active trigger}}
\IF {$\sigma$ is a tgd}
\STATE extending $h$ and adding new tuples to instance $I_{O_j}$
\ELSIF {$\sigma$ is an egd}
\IF {values compared are different constants}
\STATE $I_{O_{j+1}} = \bot$
\ELSE
\STATE substitute null values and variables by other null values, variables, or constants
\ENDIF
\ENDIF
\ENDIF
\ENDFOR
\ENDWHILE
\end{algorithmic}
\end{algorithm}
\section{ChaTEAU}
\label{sec:features}
ChaTEAU runs on different types of \textsc{Chase} parameters and objects, which are automatically recognized and processed accordingly. Different constraint and termination checks are applied. The results of these tests and of the individual \textsc{Chase} steps are stored in a log.
\paragraph{\textbf{Input and Output}}
Input and output of instances, queries, and constraints to ChaTEAU is done through special XML files. The input file defines the schema, consisting of the relation schemas and dependencies (the \textsc{Chase} parameter), as well as an instance or a query (the \textsc{Chase} object).
\paragraph{\textbf{Termination}}
Inserting tuples that contain null values may cause non-termination of execution. This happens whenever tgds interact and trigger each other and generate new null values each time they are used. Conditions that guarantee a fixed point of a \textsc{Chase} sequence exists are called \textit{termination conditions}, and several of these can be found in \cite{GST11}. ChaTEAU implements five of them: rich acyclicity, weak acyclicity, safety, acyclicity, and acyclicity with egd rewriting.
Acyclicity is a very powerful condition based on constraint rewriting \cite{GST11}, which is extensible and easy to implement. Commonly found is the test for weak acyclicity, such as in Llunatic \cite{GMPS20} or Graal \cite{BLMRS15}. It can be expanded to rich acyclicity and safety without much effort. Additionally, we decided to implement acyclicity with egd rewriting to better handle the problem of egds which are ignored in most termination criteria \cite{GST11}.
\begin{figure}[b]
\centering
\includegraphics[width=.95\columnwidth]{VLDB-ChaTEAU-Overview.pdf}
\caption{Overview of ChaTEAU (zoomable in pdf version)}
\label{fig:ChaTEAUoverview}
\end{figure}
\paragraph{\textbf{API}}
ChaTEAU is a stand-alone application for the \textsc{Chase}. It is implemented as a Maven project and can easily be accessed through the GUI presented in Section \ref{sec:demo}. In addition, ChaTEAU can be accessed via its API, making it easy to employ it as building block or library for developing other \textsc{Chase}-based applications.
In our research project \textit{ProSA} \cite{AH19}, e.g., we combine provenance management with the \textsc{Chase} algorithm to compute the inverses of evaluation queries.
ProSA is a tool that employs a variant of the \textsc{Chase} on instances, called \textsc{Chase}\&\textsc{Backchase}, so ChaTEAU is called twice: once for the \textsc{Chase} and once for the \textsc{Backchase}~\cite{Aug20}.
\paragraph{\textbf{Further development of ChaTEAU}}
We extended ChaTEAU further by adding additional features. For example, \textbf{\textit{where}}-, \textbf{\textit{why}}-, and \textbf{\textit{how}}-provenance \cite{HDL17} --- as needed for ProSA --- have already been implemented. However, provenance is not part of the \textsc{Chase} itself, but is required for integration into ProSA or other applications. Therefore, this feature can only be used via the API, and not through the GUI. Other extensions such as a general attribute-constant comparisons or the integration of negated atoms and relations are still in progress. We are also continuing work on new ChaTEAU applications, as presented in \cite{AH19}.
\section{Demonstration}
\label{sec:demo}
The ChaTEAU GUI (see Figure \ref{fig:ChaTEAUoverview}) is divided into four tabs: \texttt{Start} (\pgfkeys{/csteps/inner color=black}\pgfkeys{/csteps/outer color=yellow}\pgfkeys{/csteps/fill color=yellow}\Circled{\textbf{1}}), \texttt{Tests} (\Circled{\textbf{2}}), \texttt{\textsc{Chase}} (\Circled{\textbf{3}}) and \texttt{Log} (\Circled{\textbf{4}}). The demo starts by opening a special XML file called \textit{ChaTEAU file} (\pgfkeys{/csteps/inner color=white}\pgfkeys{/csteps/outer color=ao(english)}\pgfkeys{/csteps/fill color=ao(english)}\Circled{\textbf{a}}). It contains the \textsc{Chase} parameters as a set of dependencies and the \textsc{Chase} object. The ChaTEAU system automatically determines whether the object is a query or an instance and adjusts the associated tags (\pgfkeys{/csteps/inner color=white}\pgfkeys{/csteps/outer color=red}\pgfkeys{/csteps/fill color=red}\Circled{\textbf{A}} and \Circled{\textbf{B}}) accordingly. Before executing the \textsc{Chase} in the third step (\pgfkeys{/csteps/inner color=black}\pgfkeys{/csteps/outer color=yellow}\pgfkeys{/csteps/fill color=yellow}\Circled{\textbf{3}}), termination and constraint checks are performed (\Circled{\textbf{2}}). A variety of tests can be selected and executed sequentially. The relevant log can be found on the last tab (\Circled{\textbf{4}}).
We will navigate in ChaTEAU using the two buttons \texttt{Previous step} (\pgfkeys{/csteps/inner color=white}\pgfkeys{/csteps/outer color=blue}\pgfkeys{/csteps/fill color=blue}\Circled{\textbf{I}}) and \texttt{Next \!\!step} (\Circled{\textbf{II}}) at the bottom of the window. Within the upper right corner of each tab, there is an option to save or execute something (\pgfkeys{/csteps/inner color=white}\pgfkeys{/csteps/outer color=ao(english)}\pgfkeys{/csteps/fill color=ao(english)}\Circled{\textbf{a}} -- \Circled{\textbf{e}}).
\subsection{\textsc{Chase} on Instances}
Even though the \textsc{Chase} on instances and queries works the same in ChaTEAU, we present them as separate use cases.
We start with an example for chasing instances. Both examples can be found in the corresponding demo repository.
\paragraph{\textbf{Start}}
Instead of manually entering formulas, the fields for the \textsc{Chase} object (\texttt{Input}) and parameter (\texttt{Dependencies}) are automatically generated from the selected XML file.
We consider an instance (object) and a query (parameter) formalized as an s-t tgd that generates a table of grades from a student and a participant table. Thus, known attributes like \textsc{id} and \textsc{module} are adopted and new null values for \textsc{semester} and \textsc{score} are introduced. In addition, all students not named Max are filtered out.
\begin{NR
\footnotesize
\textbf{Instance:}
\vspace{-0.38cm}
\begin{eqnarray*}
\hspace{3.125cm} \scriptstyle \{\text{participant}(2,3,4), \ \text{ participant}(7,3,\#N\_\text{semester}\_1), \\
\scriptstyle \text{student}(3, \text{'Max'}, \text{'Math'}), \ \text{ student}(\#N\_\text{id}\_1, \text{'Max'}, \text{'Math'}), \ \text{student}(7, \text{'Mia'}, \#N\_\text{course}\_1) \}
\end{eqnarray*}
\footnotesize \textbf{Dependencies:}
\begin{eqnarray*}
\scriptstyle \text{participant}(\#V\_\text{module}\_1, \#V\_\text{id}\_1, \#V\_\text{semester}\_1), \
\text{student}(\#V\_\text{id}\_1, \text{'Max'}, \#V\_\text{course}\_1) \\
\scriptstyle -> \text{grade}(\#V\_\text{module}\_1, \#V\_\text{id}\_1, \#E\_\text{semester}\_1, \#E\_\text{score}\_1)
\end{eqnarray*}
\end{NR}
\paragraph{\textbf{Termination}}
ChaTEAU implements five common termination tests, from which the user can choose. When the button \texttt{Run select\-ed checks} (\Circled{\textbf{b}}) is pressed, all checks will be run. The process can be repeated as often as desired (e.g. with different termination checks).
In our example, the \textsc{Chase} terminates according to all five criteria. Also the constraint check is successful.
\begin{NR
\scriptsize
tgds are richly acyclic -> Standard \textsc{Chase} will definitely terminate. \\
tgds are weakly acyclic -> Standard \textsc{Chase} will definitely terminate. \\
tgds are safe -> Standard \textsc{Chase} will definitely terminate. \\
Constraint rewriting shows that tgds are acyclic -> \textsc{Chase} will definitely terminate. \\
Constraint rewriting shows that tgds/egds are acyclic -> \textsc{Chase} will definitely terminate. \\
Constraints are defined correctly.
\end{NR}
\paragraph{\textbf{\textsc{Chase} Execution}}
The key part of ChaTEAU is the \textsc{Chase} application in the third tab. In addition to the input (\pgfkeys{/csteps/inner color=white}\pgfkeys{/csteps/outer color=red}\pgfkeys{/csteps/fill color=red}\Circled{\textbf{A}} and \Circled{\textbf{B}}), we also see the \textsc{Chase} result (\Circled{\textbf{C}}) here, which can be saved (\pgfkeys{/csteps/inner color=white}\pgfkeys{/csteps/outer color=ao(english)}\pgfkeys{/csteps/fill color=ao(english)}\Circled{\textbf{d}}). Despite negative termination tests, the \textsc{Chase} can still be executed. In this case, an alert appears. If the \textsc{Chase} is still running, it can be stopped by clicking the {Start \textsc{Chase}} button (\pgfkeys{/csteps/inner color=white}\pgfkeys{/csteps/outer color=ao(english)}\pgfkeys{/csteps/fill color=ao(english)}\Circled{\textbf{c}}) again, which is now labeled as a {Stop} button. The \textsc{Chase} steps can be reviewed in the log (\pgfkeys{/csteps/inner color=black}\pgfkeys{/csteps/outer color=yellow}\pgfkeys{/csteps/fill color=yellow}\Circled{\textbf{4}}).
Our result instance by applying \textsc{Chase} matches the result of the SQL query \texttt{SELECT * FROM participant NATURAL JOIN student WHERE name = 'Max'} to the instance defined above:
\begin{NR
\footnotesize
\textbf{Result (instance):}
\begin{eqnarray*}
& & \scriptstyle \text{grade}(7,3,\#N\_\text{semester}\_2,\#N\_\text{score}\_1), \ \text{grade}(2,3,\#N\_\text{semester}\_3,\#N\_\text{score}\_2)
\end{eqnarray*}
\end{NR}
\paragraph{\textbf{Logging}} The \textsc{Chase} execution is finished after three steps (\pgfkeys{/csteps/inner color=black}\pgfkeys{/csteps/outer color=yellow}\pgfkeys{/csteps/fill color=yellow}\Circled{\textbf{1}}~--~\Circled{\textbf{3}}). The log offers additional information such as the results of the single \textsc{Chase} steps after application of a (s-t) tgd or egd and details regarding the termination checks carried out. The log is especially suitable for debugging and is saved using \pgfkeys{/csteps/inner color=white}\pgfkeys{/csteps/outer color=ao(english)}\pgfkeys{/csteps/fill color=ao(english)}\Circled{\textbf{e}}.
\subsection{\textsc{Chase} on Queries}
Thus ChaTEAU provides, depending on the CHASE object $\bigcirc$ an instance or query extended by the specified parameter $\ast$. We continue with an example for chasing queries.
\paragraph{\textbf{Start}}
We consider a query (object) and a constraint (parameter) formalized as egd. The egd replaces the $\exists$-quantified variable $\#E\_\text{course}\_1$ with the $\forall$-quantified variable $\#V\_\text{course}\_1$ by equating the attributes $\#V\_\texttt{course}\_1$ and $\#V\_\text{course}\_2$.
\begin{NR
\footnotesize
\textbf{Query:}
\begin{eqnarray*}
\scriptstyle \text{student}(\#V\_\text{id}\_1, \#V\_\text{name}\_1, \#E\_\text{course}\_1), \ \scriptstyle \text{student}(\#E\_\text{id}\_1, \#V\_\text{name}\_1, \#V\_\text{course}\_1) \\
\scriptstyle -> \ (\#V\_\text{id}\_1, \#V\_\text{name}\_1, \#V\_\text{course}\_1)
\end{eqnarray*}
\footnotesize
\textbf{Dependencies:}
\begin{eqnarray*}
\scriptstyle \text{student}(\#V\_\text{id}\_1, \#V\_\text{name}\_1, \#V\_\text{course}\_1),
\ \text{student}(\#V\_\text{id}\_1, \#V\_\text{name}\_1, \#V\_\text{course}\_2) \\
\scriptstyle -> \ \#V\_\text{course}\_1 \ = \ \#V\_\text{course}\_2
\end{eqnarray*}
\end{NR}
\paragraph{\textbf{Termination and Logging}}
Both termination and logging behave as for instances. All six checks are satisfied.
\paragraph{\textbf{\textsc{Chase} Execution}}
Applying the CHASE provides the substitution of $\#E\_\text{course}\_1$ described above. As a result, the body has changed, while the head remains the same.
\begin{NR
\footnotesize
\textbf{Result (query):}
\begin{eqnarray*}
\scriptstyle \text{student}(\#V\_\text{id}\_1, \#V\_\text{name}\_1, \#V\_\text{course}\_1), \ \text{student}(\#V\_\text{id}\_2, \#V\_\text{name}\_1, \#V\_\text{course}\_2)) \\
\scriptstyle \quad -> \ (\#V\_\text{id}\_1, \#V\_\text{name}\_1, \#V\_\text{course}\_1)
\end{eqnarray*}
\end{NR}
\section{Conclusion}
\label{sec:conclusion}
The \textsc{Chase} implemented in ChaTEAU can be applied to queries and instances. Cha\-TEAU combines these two approaches by incorporating a set of views, queries, and dependencies formalized as (s-t) tdgs and egds, called \textsc{Chase} parameter, into a general \textsc{Chase} object. For this, queries can be interpreted as frozen instances. This also means that a different treatment of queries and instances is no longer needed. ChaTEAU thus offers a versatile implementation of a family of reasoning algorithms, which can be easily integrated into other \textsc{Chase}-based applications such as ProSA \cite{AH19}.
\begin{acks}
We thank all the students who were involved in developing Cha\-TEAU. In particular, we would like to mention Martin Jurklies, Fabian Renn, Florian Rose, Michael Albus, Eduard Buch, Lukas Görtz, Moritz Hanzig, Eric Maier, Rocco Flach and Chris Röhrs. We also thank Bertram Ludäscher for comments and suggestions.
\end{acks}
| {'timestamp': '2022-06-06T02:16:32', 'yymm': '2206', 'arxiv_id': '2206.01643', 'language': 'en', 'url': 'https://arxiv.org/abs/2206.01643'} | arxiv |
\section*{Extended Abstract}
Vaccination hesitancy has been a threat to public health since a long time~\cite{wolfe2002anti}, and it is currently being fueled by the large spreading of misinformation in many social media~\cite{broniatowski2018weaponized}. Attitudes against vaccination usually rise around fake news or conspiracy theories, but according to moral psychology they are shaped by individual moral preferences.
The \textit{Moral Foundations Theory} (MFT) ~\cite{graham2013moral} explains individual variations in moral preferences using five dimensions (foundations): harm, fairness, loyalty, authority and purity, and it has been shown that these foundations underlie human judgements on politics, religion and social cooperation~\cite{haidt2012righteous, curry2016morality}. In this work we assess the moral preferences expressed in the pro- and anti-vax discourses in a large dataset of Facebook comments. We show that significant differences exist in some moral dimensions between these two groups, and we suggest that these differences should be taken into account when designing vaccination campaigns.
Previous evidence that moral values are related to individual attitudes towards vaccination can be found in~\cite{amin2017association}, where the authors used a sample of $1,000$ parents in the US and found that parents with higher vaccine hesitancy tended to have higher levels of the purity and liberty foundations. Surprisingly, they also found that the harm/care foundation, traditionally addressed in vaccination campaigns, did not have a significant impact on vaccine hesitancy. A similar study by~\cite{rossen2019accepters} was performed in Australia based on an online questionnaire administered to $296$ individuals. The authors found that vaccine rejecters showed significantly lower values of authority and significantly higher levels of purity, liberty and fairness.
Regarding the vaccination discourse in Facebook,~\cite{klimiuk2021vaccine} categorized a set of $\approx 20,000$ comments about vaccination in Poland, and they found that the main categories related with vaccine hesitancy were --in decreasing order of importance-- conspiracy theories, falsehoods, and concerns regarding safety and effectiveness of vaccines. Similar clusters were obtained by~\cite{hoffman2019s} with a sample of $197$ individuals in Facebook in the US. Both works discuss narrative strategies to
raise awareness on the importance of immunization.
\begin{table}[h]\centering
\caption{\label{statistics}Dataset statistics.}
\begin{tabular}{lcccc}
\toprule
&\multicolumn{1}{c}{PRO-Vaccination pages} & \multicolumn{1}{c}{ANTI-Vaccination pages} \\
\midrule
Pages & $101$ & $85$ \\
Original Posts & $52,894$ & $24,615$ \\
Original Comments & $215,341$ & $391,764$ \\
Filtered Comments & $170,954$ & $286,111$ \\
\bottomrule
\end{tabular}
\end{table}
The aim of this work is to provide more evidence on the impact of moral traits in vaccine hesitancy as expressed in social media, by analyzing a large volume of Facebook pages, posts and comments about vaccination. Though Facebook is currently diminishing its share in the social media landscape, it is still the most used social media in the general population and is a well-known target of misinformation campaigns~\cite{allcott2019trends}.
Recent efforts by Facebook Inc. to tackle fake news have certainly decreased their proliferation by adding a quality control\footnote{In particular, in March 2019 Facebook took a series of measures to specifically address vaccine misinformation (\url{https://about.fb.com/news/2019/03/combatting-vaccine-misinformation/}).} However, the large historical volume of posts and conversations remaining in many of its public pages constitutes a relevant source of data for studying the anti-vaccination discourse. \\
Here we analyzed a set of $607,105$ comments in $186$ pro- and anti-vaccination pages in the period Jan, 2012-Jun 2019. A summary of the dataset is shown in the upper part of Table~\ref{statistics}.
As many posts bring up discussions between pro-vax and anti-vax users, we can find comments from both user groups interlaced among the replies. In order to tell apart both groups, we trained a classifier that, based on the comment's text, can predict the type of attitude that it denotes: pro-vax, anti-vax or non-specified.
Our classifier is composed of three parallel stages: an LSTM neural network, a named entity recognition stage based on TAGME~\cite{ferragina2010tagme} and a page class stage. The outputs are finally concatenated and used as input to a dense layer with a tanh activation function predicting which of the $3$ groups the comment belongs to. The architecture, depicted in Figure FIG, was implemented in Keras~\cite{chollet2015keras}, and its design and configuration is inspired by~\cite{lin2018acquiring}. The size of the LSTM hidden state was configured in 100 and the final dense layer has size 3. Words were transformed using the 100-dimensional pre-trained GloVe embeddings~\cite{pennington2014glove}.
The ground-truth for training was composed of $3000$ comments which were manually tagged as pro-vax, anti-vax or non-specified. The cross-validated prediction results on this set are shown in Figure~\ref{figuras} (top-left) in terms of the ROC curve (Receiver Operating Characteristic). We chose the AUC measure as a metric for our model due to its high unbalance; The baseline accuracy for the area under this curve is 0.50, which represents the accuracy of a random classifier (coin flip). We obtained a cross-validated AUC (area under the ROC curve) of $0.84$
\begin{figure}[t]
\caption{\label{figuras}Performance of the models in terms of the Receiver Operating Characteristic curve and its AUC (area under the ROC curve).}
\includegraphics[width=0.5\textwidth]{figures/PRO-NON-ANTI_roc.pdf}
\includegraphics[width=0.5\textwidth]{figures/6MV_roc.pdf}
\includegraphics[width=0.5\textwidth]{figures/12MV_POSITIVE_roc.pdf}
\includegraphics[width=0.5\textwidth]{figures/12MV_NEGATIVE_roc.pdf}
\end{figure}
\begin{table}[h]\centering
\caption{Presence and polarity of the six moral foundations in the different comments groups (pro-vax, anti-vax, and non-relevant).}
\begin{tabular}{ l c c c c c c c c c }
\toprule
&
\multicolumn{3}{ c }{Moral Presence (\%) {\ }} &
\multicolumn{3}{ c }{Positive polarity (\%) {\ }} &
\multicolumn{3}{ c }{Negative polarity (\%) {\ }}\\
\cmidrule(lr){2-4}\cmidrule(lr){5-7}\cmidrule(lr){8-10}
& { ~ } \itshape PRO & \itshape ANTI & \itshape NON & { ~ } \itshape PRO & \itshape ANTI & \itshape NON & { ~ } \itshape PRO & \itshape ANTI & \itshape NON \itshape \\
\midrule
Authority { ~ } & 51.34 & 50.83 & 14.66 & 39.79 & 31.57 & 13.59 & 32.64 & 44.57 & 7.43\\
Liberty { ~ }& 22.84 & 26.23 & 18.13 & 36.47 & 45.96 & 25 & 11.98 & 4.93 & 6.54\\
Loyalty { ~ }& 9.39 & 9.09 & 5.25 & 16.6 & 21.27 & 5.88 & 12.85 & 10.22 & 4.48\\
Care { ~ }& 44.27 & 41.38 & 7.21 & 32.48 & 28.47 & 14.45 & 5.05 & 1.67 & 5.37\\
Fairness { ~ }& 31.08 & 39.35 & 6.42 & 31.65 & 37.72 & 8.88 & 13.43 & 5.87 & 8.24\\
Purity { ~ }& 31.09 & 22.64 & 26.52 & 13.04 & 12.54 & 19.22 & 31.5 & 15.91 & 49.23\\
\bottomrule
\multicolumn{10}{p{6in}}{Note. Values represent the percentage of comments that, being predicted as of that group (pro-vax, anti-vax, or non-relevant) express the respective moral. }
\end{tabular}
\label{table_presence_valence}
\end{table}
\begin{table}[h]\centering
\caption{\label{table_rocs}Accuracy of the LSTM predictors for each of the six moral foundations, expressed in terms of the area under the receiver operating characteristic (AUC).}
\begin{tabular}{lccc}
\toprule
&\multicolumn{1}{ c }{Moral presence {\ }} &
\multicolumn{1}{ c }{Positive polarity {\ }} &
\multicolumn{1}{ c }{Negative polarity {\ }}\\
\midrule
Authority { ~ } & 0.67 & 0.59 & 0.63\\
Liberty { ~ } & 0.79 & 0.75 & 0.69\\
Loyalty { ~ } & 0.57 & 0.55 & 0.53\\
Care { ~ } & 0.70 & 0.61 & 0.46 \\
Fairness { ~ } & 0.63 & 0.65 & 0.51\\
Purity { ~ } & 0.66 & 0.58 & 0.69\\
\bottomrule
\end{tabular}
\end{table}
We applied this trained model to the unlabeled part of the dataset, and performed a characterization of the moral traits expressed in pro- and anti-vax comments. For each pro- and anti-vax comment in the training set, we annotated the presence of each of the morals, and in case a moral was present, we annotated the polarity of its content (i.e., if the moral was positively and/or negatively expressed). For example, a comment expressing that ``unvaccinated children shouldn't be allowed to go to public school'' has a negative polarity of the liberty foundation. Instead, a comment pointing out that ``each person has the right to choose if they should be vaccinated'' expresses the same moral, but with a positive polarity.
Using these samples, we trained one LSTM model for predicting the presence of each moral, and another one for predicting their positive and/or negative polarity. After applying the trained model to the full dataset, the percentage of comments predicted as expressing each moral is detailed in Table~\ref{table_presence_valence}. The performance of the classifiers is shown in Table~\ref{table_rocs} in terms of the AUC and illustrated in Figure~\ref{figuras}. We observe that some of the AUC's are quite low (we consider that an AUC is acceptable if it is above 0.65, which represents a clear distinction from a random classifier). This might be due to the low number of training samples and the difficulty of the learning task (consider that the expression of a moral might be underlying and not quite explicit in a comment). However, among those morals whose prediction is acceptable, we observe that pro-vax comments are more commonly expressing anti-liberty arguments, while anti-vax comments express pro-liberty ones; also, these expressions are much more common than in comments predicted as non vaccination-related. We also observe that purity is expressed more frequently with a negative polarity by pro-vax comments than by anti-vax comments. Interestingly, these two facts were precisely the ones found by~\cite{amin2017association} as the main differences in morals between pro-vax and anti-vax respondents in their study on vaccination hesitancy. Finally, and though not as significant as the previous ones, we find that pro-vax comments express more frequently a positive polarity of authority, while anti-vax comments express more frequently a negative value of it.
Indeed, several studies have shown that persuasive appeals in line with the moral traits endorsed by an audience can shift their attitudes on several issues. This kind of experiments framed by the Moral Foundations Theory has been performed, e.g., in the context of environmental consciousness~\cite{feinberg2013moral, kidwell2013getting} and donation to charities~\cite{goenka2019charities}.
We think that these results might help designing and framing vaccination campaigns by focusing on the liberty and authority traits (e.g., by remarking that vaccination gives people more freedom, by allowing them to perform their activities with safety, or by giving a clear picture of how scientific studies are validated and can be reproduced by peers). This can be of particular interest in the current COVID-19 pandemic context, in which misinformation campaigns are putting into risk the herd immunity goal and probably constitute the highest threat to global public health~\cite{larson2018biggest}.
| {'timestamp': '2022-06-06T02:15:19', 'yymm': '2206', 'arxiv_id': '2206.01598', 'language': 'en', 'url': 'https://arxiv.org/abs/2206.01598'} | arxiv |
\section{Introduction}
With the rapidly growing adoption of machine learning (ML) models in real-world applications, the algorithmic decisions of ML models can potentially have a significant societal impact on building trustworthy AI systems for real-world applications, especially for some application domains such as healthcare, education, and finance, etc. Many ML models, especially deep learning models, work as black-box models that lack explainability and thus inhibit their adoption in some critical applications and hamper the trust in machine learning/AI systems. To address these challenges, eXplainable AI (XAI) is an emerging field in machine learning and AI, aiming to explain how those black-box decisions of AI systems are made. Such explanations can improve the transparency, persuasiveness, and trustworthiness of AI systems and help AI developers and practitioners to debug and improve model performance ~\citep{doshivelez2017rigorous,Kusner2017,Lipton2016}.
To this end, we develop OmniXAI (short for Omni eXplainable AI), an open-source library for explainable AI to provide omni-way explainability for a variety of machine learning models.
\begin{figure}[!ht]
\center
\includegraphics[width=1.0\linewidth]{figures/ml_pipeline.png}
\caption{OmniXAI offers explainablity for different stages in a standard ML workflow.}
\label{fig:ml_pipeline}
\end{figure}
As shown in Figure~\ref{fig:ml_pipeline}, OmniXAI offers a one-stop solution for analyzing different stages in a standard ML workflow in real-world applications, and provides a comprehensive family of explanation methods, including high-quality implementations of various model-agnostic and model-specific explanation methods. In data analysis and exploration, OmniXAI can analyze feature correlations and data imbalance issues, helping developers quickly remove redundant features and discover potential bias issues. In feature engineering, OmniXAI can identify important features by analyzing relationships between features and targets, helping them understand data properties and do feature preprocessing. In model training and evaluation, OmniXAI provides various explanations, e.g., feature-attribution explanation, counterfactual explanation, gradient-based explanation, to comprehensively analyze the behavior of a model designed for tabular, vision, NLP, or time-series tasks. It helps to debug the model when wrong predictions occur or the model behavior is not as expected, and gathers more valuable information for improving feature engineering. After the model is deployed, OmniXAI opens ``black boxes'' and generates explanations for each model decision so that domain experts can analyze the decisions and explanations to determine which actions to take.
Compared with other existing explanation libraries, e.g., IBM’s AIX360~\citep{aix360-sept-2019}, Microsoft’s InterpretML \citep{nori2019interpretml}, DALEX \citep{JMLR:v22:20-1473} and Alibi \citep{JMLR:v22:21-0017}, our library has a comprehensive list of XAI capabilities and unique features including:
\begin{itemize}
\item \textbf{Support data analysis/exploration}: we support feature analysis and selection, e.g., feature correlations, data imbalance issues, selecting important features.
\item \textbf{Support popular machine learning frameworks}: we support the most popular machine learning frameworks or models, e.g., PyTorch, Tensorflow, scikit-learn and customized black-box models.
\item \textbf{Support most popular explanation methods}: Many explanation methods, e.g., feature-attribution explanation, counterfactual explanation, partial dependence plots, etc., are included for analyzing different aspects of a machine learning model.
\item \textbf{Support counterfactual explanations}: An efficient counterfactual explanation algorithm called MACE (model-agnostic counterfactual explanation) \citep{mace} designed for tabular and time-series data is included in the library. For text data, we include a method based on Polyjuice \cite{wu-etal-2021-polyjuice} for text classification and question-answering tasks.
\item \textbf{Support gradient-based explanations}: Integrated-gradient \citep{10.5555/3305890.3306024}, Grad-CAM \citep{Grad-CAM2019} and Grad-CAM's variants \citep{8354201} are supported.
\item \textbf{Support image, text, and time-series data}: OmniXAI provides multiple explanation methods for a diverse set of tasks,
e.g., Grad-CAM for vision tasks, integrated-gradient for NLP tasks, counterfactual for time-series tasks.
\item \textbf{Easy-to-use}: Users only need to write a few lines of code to generate various kinds of explanations, and OmniXAI supports Jupyter Notebook environments.
\item \textbf{Easy-to-extend}: Developers can add new explanation algorithms easily by implementing a single class inherited from the explainer base class.
\item \textbf{A GUI dashboard}: OmniXAI provides a visualization tool for users to examine the generated explanations and compare interpretability algorithms.
\end{itemize}
Table~\ref{table_1} shows the supported interpretability algorithms in OmniXAI\footnote{SHAP accepts black-box models for tabular data, PyTorch/Tensorflow models for image data, transformer models for text data. Counterfactual explanation accepts black-box models for tabular data and PyTorch/Tensorflow models for image data.}, and Table~\ref{table_2} shows the comparison between OmniXAI and other existing XAI toolkits/libraries in literature. Our library supports all of these methods with a unified interface.
\begin{table}[!ht]
\caption{The supported interpretability algorithms in OmniXAI}\vspace{-0.2in}
\label{table_1}
\center
\begin{small}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
Method & Model Type & Exp Type & EDA & Tabular & Image & Text & TS \\ \hline
Feature analysis & NA & Global & \cmark & & & &\\ \hline
Feature selection & NA & Global & \cmark & & & & \\ \hline
Partial dependence plot & Black box & Global & & \cmark & & & \\ \hline
Sensitivity analysis & Black box & Global & & \cmark & & & \\ \hline
LIME & Black box & Local & & \cmark & \cmark & \cmark & \\ \hline
SHAP & Black box* & Local & & \cmark & \cmark & \cmark & \cmark \\ \hline
Integrated gradient & Torch or TF & Local & & \cmark & \cmark & \cmark & \\ \hline
Counterfactual & Black box* & Local & & \cmark & \cmark & \cmark & \cmark \\ \hline
Contrastive explanation & Torch or TF & Local & & & \cmark & & \\ \hline
Grad-CAM & Torch or TF & Local & & & \cmark & & \\ \hline
Learning to explain & Black box & Local & & \cmark & \cmark & \cmark & \\ \hline
Linear models & Linear models & Global/local & & \cmark & & & \\ \hline
Tree models & Tree models & Global/local & & \cmark & & & \\ \hline
\end{tabular}
\end{small}
\end{table}
\begin{table}[!ht]
\caption{Comparison between OmniXAI and other XAI libraries.}\vspace{-0.2in}
\label{table_2}
\center
\begin{small}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
Data Type & Method & OmniXAI & InterpretML & AIX360 & Eli5 & Captum & Alibi \\ \hline
Tabular & LIME & \cmark & \cmark & \cmark & & \cmark & \\ \hline
& SHAP & \cmark & \cmark & \cmark & & \cmark & \cmark \\ \hline
& PDP & \cmark & \cmark & & & & \\ \hline
& Sensitivity & \cmark & \cmark & & & & \\ \hline
& Integrated gradient & \cmark & & & & \cmark & \cmark \\ \hline
& Counterfactual & \cmark & & & & & \cmark \\ \hline
& Linear models & \cmark & \cmark & \cmark & \cmark & & \cmark \\ \hline
& Tree models & \cmark & \cmark & \cmark & \cmark & & \cmark \\ \hline
& L2X & \cmark & & & & & \\ \hline
Image & LIME & \cmark & & & & \cmark & \\ \hline
& SHAP & \cmark & & & & \cmark & \\ \hline
& Integrated gradient & \cmark & & & & \cmark & \cmark \\ \hline
& Grad-CAM & \cmark & & & \cmark & \cmark & \\ \hline
& CEM & \cmark & & \cmark & & & \cmark \\ \hline
& Counterfactual & \cmark & & & & & \cmark \\ \hline
& L2X & \cmark & & & & & \\ \hline
Text & LIME & \cmark & & & \cmark & \cmark & \\ \hline
& SHAP & \cmark & & & & \cmark & \\ \hline
& Integrated gradient & \cmark & & & & \cmark & \cmark \\ \hline
& Counterfactual & \cmark & & & & & \\ \hline
& L2X & \cmark & & & & & \\ \hline
Timeseries & SHAP & \cmark & & & & & \\ \hline
& Counterfactual & \cmark & & & & & \\ \hline
\end{tabular}
\end{small}
\end{table}
The library includes a family of popular model-agnostic explanations methods (such as LIME~\citep{Ribeiro2016}, SHAP~\citep{NIPS2017_7062}, L2X~\citep{chen2018learning}) and model-specific ones (e.g., integrated-gradient (IG)~\citep{10.5555/3305890.3306024}), which generate local explanations and can support multiple data types and tasks.
For tabular data, OmniXAI includes two methods for global explanations, i.e., partial dependence plot (PDP)~\citep{hastie01statisticallearning} and Morris sensitivity analysis~\citep{10.2307/1269043} for analyzing how each feature affects model outcomes, and two counterfactual explanation methods, i.e., CE~\citep{wachter2018a} which can only handle continuous-valued features, and MACE~\citep{mace} which is a model-agnostic method that can handle both continuous-valued and categorical features.
For image data, OmniXAI also supports Grad-CAM~\citep{Grad-CAM2019}, Grad-CAM++ \citep{8354201} for explaining deep learning models on image domains, the contrastive explanation method (CEM) that finds pertinent negatives and pertinent positives for explanations, and the counterfactual explanation method CE~\citep{wachter2018a}. Note that both CEM and CE only support the classification tasks.
For text data, in addition to the generic explanation methods (such as LIME, SHAP, and IG), OmniXAI also supports a counterfactual explanation method which is based on the pretrained model ``Polyjuice''~\citep{wu-etal-2021-polyjuice} for both classification and QA tasks.
Finally, for time-series data, OmniXAI supports explanation techniques for both time-series anomaly detection and time-series forecasting. Specifically, it provides a SHAP-based method and an optimization-based counterfactual explanation method MACE for both time-series anomaly detection and forecasting.
\section{Library Design}
Our key design principle is to provide a simple but unified interface allowing users to apply multiple explanation methods and visualize the corresponding generated explanations at the same time. This aims to make our library easy-to-use (generating explanations by writing a few lines of codes), easy-to-extend (adding new explanation methods easily without affecting the library framework), and easy-to-compare (visualizing the explanation results to compare multiple explanation methods). The library has five key components:
\begin{itemize}
\item \textbf{Data classes} -- ``omnixai.data'': This package contains the data classes for representing tabular data, image data, text data, and time-series data. For example, the explainers for tabular data use an instance of ``omnixai.data.tabular'' as one of their inputs. The library provides simple constructors for creating instances of these classes from numpy arrays, pandas dataframes, pillow images, or strings.
\item \textbf{Preprocessing modules} -- ``omnixai.preprocessing'': This package contains various pre-processing functions for different data types. For example, it provides 1) one-hot encoding and ordinal encoding for categorical features, 2) KBins, standard normalization, min-max normalization, rescaling, NaN-filling for continuous-valued features, 3) rescaling, normalization, resizing for image data, and 4) the TF-IDF transformation and token-to-id transformation for text data.
\item \textbf{Explanation methods} -- ``omnixai.explainers'': This is the main package in the library, which contains all the supported explainers. The explainers are categorized into four groups: 1) ``omnixai.explainers.data'' for data exploration/analysis, including feature correlation analysis, feature selection, etc., 2) ``omnixai.explainers.tabular'' for tabular data, e.g., global explanations such as PDP~\citep{hastie01statisticallearning}, local explanations such as LIME~\citep{Ribeiro2016}, SHAP~\citep{NIPS2017_7062}, MACE~\citep{mace}, 3) ``omnixai.explainers.vision'' for vision tasks, e.g., integrated-gradient \citep{10.5555/3305890.3306024},
Grad-CAM \citep{Grad-CAM2019}, contrastive explanation \citep{dhurandhar2018explanations}, counterfactual explanation \citep{wachter2018a}, and 4) ``omnixai.explainers.nlp'' for NLP tasks, e.g., LIME, integrated-gradient (IG).
For each group, the explainers are further categorized into ``model-agnostic'', ``model-specific'' and ``counterfactual''. A ``model-agnostic'' explainer can handle black-box ML models, i.e., only requiring a prediction function without knowing model details. A ``model-specific'' explainer requires some information of ML models, e.g., whether the model is differentiable, whether the model is a linear model or a tree-based model. ``Counterfactual'' is a special group for counterfactual explanation methods.
\item \textbf{Explanation results} -- ``omnixai.explanations'': This package contains the classes for explanation results. For example, the class ``FeatureImportance'' is used for storing feature-importance/attribution explanations. All of these classes provide plotting functions for visualization, e.g., ``plot'' using ``Matplotlib'', ``plotly\_plot'' using ``Plotly Dash'' and ``ipython\_plot'' for Jupyter Notebook.
\item \textbf{Visualization tools} -- ``omnixai.visualization'': This package contains a dashboard for visualization implemented using Plotly Dash. The dashboard supports both global explanations and local explanations. It provides a convenient way to compare and analyze multiple explanation results.
\end{itemize}
Figure \ref{fig:class} demonstrates the main architecture of the library.
The package ``omnixai.explainers'' contains four special explainers, namely ``TabularExplainer'', ``VisionExplainer'', ``NLPExplainer'' and ``TimeseriesExplainer'', inherited from ``AutoExplainerBase'' acting as the factories of the supported explainers. They provide a unified API for generating explanations with multiple explainers.
\begin{figure}[t]
\center
\includegraphics[width=1.0\linewidth]{figures/class.png}
\caption{The main architecture of OmniXAI.}
\label{fig:class}
\end{figure}
To initialize them, one only needs to specify the following parameters:
\begin{itemize}
\item \textbf{The names of the explainers to apply}: e.g., ``shap'' for SHAP, ``pdp'' for PDP, ``gradcam'' for Grad-CAM.
\item \textbf{The machine learning model to explain}: e.g., a scikit-learn model, a tensorflow model, a pytorch model, or a black-box prediction function.
\item \textbf{The pre-processing function}: e.g., converting raw input features into the model inputs, and feature processing.
\item \textbf{The post-processing function (optional)}: e.g., converting model outputs into class probabilities for classification tasks if the outputs are logits.
\end{itemize}
The class ``AutoExplainerBase'' will automatically check whether a chosen explainer is model-agnostic or model-specific and whether it generates local explanations or global explanations, and then determine how to call the method ``explain'' in the class ``ExplainerBase'' correctly to generate explanations. The generated explanations are stored in the explanation classes derived from ``ExplanationBase'' which has one method for extracting raw explanation results and three methods for visualization. One can call ``plot'', ``plotly\_plot'' or ``ipython\_plot'' to visualize the explanations generated by each explainer separately, or launch a dashboard to visualize all the explanations at the same time to obtain more insights about the underlying model.
\begin{figure}[!ht]
\center
\includegraphics[width=0.8\linewidth]{figures/pipeline.png}
\caption{The pipeline for generating explanations in OmniXAI}
\label{fig:pipeline}
\end{figure}
Figure \ref{fig:pipeline} shows the pipeline for generating explanations.
Suppose we have a machine learning model to explain with the training dataset ``tabular\_data'' and the feature processing function ``transformer.transform''. Here is the sample code for creating a ``TabularExplainer''.
\lstinputlisting[language=Python]{example_1.py}
In this example, LIME, SHAP, and MACE generate local explanations while PDP generates global explanations. Given the test instances, ``explainer.explain'' returns the local explanations generated by the three methods, and ``explainer.explain\_global'' returns the global explanations generated by PDP.
\lstinputlisting[language=Python]{example_2.py}
Finally, given the generated explanations, we provide visualization tools to visualize the results.
A dashboard can be configured by setting the test instances, the generated local explanations, the generated global explanations, the class names, and additional parameters for visualization (e.g., only plotting the selected features in PDP).
\lstinputlisting[language=Python]{example_3.py}
\section{Supported Explanation Methods}
There are two types of explanation methods, i.e., model-agnostic and model-specific. ``Model-agnostic'' means the methods can explain the decisions made by a black-box machine learning model without knowing the model details. ``Model-specific'' means the methods require some knowledge about the model to generate explanations, e.g., whether the model is a linear model or whether the model is differentiable w.r.t. its inputs. Model-specific methods provide more explanations about the decisions, e.g., the decision paths in a decision tree model.
\subsection{Model-agnostic Explanation}
The library treats all the methods for data analysis as model-agnostic methods because they analyze training/test data directly without using trained machine learning models, e.g., feature correlation analysis. Besides data analysis, some popular model-agnostic explanation methods, e.g., LIME~\citep{Ribeiro2016}, SHAP~\citep{NIPS2017_7062}, L2X~\citep{chen2018learning}, Partial Dependence Plots (PDP)~\citep{hastie01statisticallearning}, and Morris sensitivity analysis~\citep{10.2307/1269043} are included in the library. LIME, SHAP, and L2X generate local explanations, i.e., explaining a particular decision, while PDP and sensitivity analysis generate global explanations, i.e., explaining model behavior in general.
\subsection{Model-specific Explanation}
The model-specific methods in the library include gradient-based methods, e.g., the integrated-gradient (IG) method~\citep{10.5555/3305890.3306024}, Grad-CAM~\citep{Grad-CAM2019}, etc., and the contrastive explanation method (CEM)~\citep{dhurandhar2018explanations}. These methods need to compute the gradients of model outputs with respect to model inputs or particular internal layers, and thus require that the models to explain are neural networks implemented by PyTorch or Tensorflow. Different from gradient-based methods, CEM solves an optimization problem to compute pertinent negatives and pertinent positives for explanation, which can utilize numerical gradients instead of analytical gradients during optimization. Because computing numerical gradients is relatively expensive with high-dimensional data, our current CEM only supports differentiable models and thus is classified as a model-specific method. Future work will make CEM support gradient estimation methods for high-dimensional data.
\subsection{Counterfactual Explanation}
Counterfactual explanation interprets a model's decision on a query instance by generating counterfactual examples that have minimal changes w.r.t the query instance’s features to yield a predefined output~\citep{Wachter2017CounterfactualEW,Moraffah2020,Byrne2019}. It can not only explain the outcome of a model's decision but also provide insight on how to change the outcome in the future. Although such methods can be grouped into ``model-agnostic'' and ``model-specific'', we highlight them by creating a separate package in the library.
For tabular and time-series data, we recommend the recent MACE method~\citep{mace} to generate counterfactual examples. MACE is a novel framework of model-agnostic counterfactual explanation, adopting a newly designed pipeline that can efficiently handle black-box machine learning models on a large number of feature values.
For image data, we choose the algorithm discussed in the paper~\citep{wachter2018a}. This algorithm solves the following optimization problem given a query instance ${\bf x}$:
\begin{equation}
\min_{{\bf x}'}\max_{\lambda} \lambda\mathcal{H}(f_y({\bf x}') - \max_{y' \neq y}f_{y'}({\bf x}')) + \|({\bf x}' - {\bf x})\|_1,
\end{equation}
where $\mathcal{H}$ is the hinge loss function, $f_y({\bf x})$ represents the predicted class probability of sample ${\bf x}$ and label $y$, and the L1-norm regularization term is applied to encourage sparse modifications. Intuitively, it finds a counterfactual example ${\bf x}'$ with a different predicted label from ${\bf x}$ and minimum changes of ${\bf x}$. This approach can also be applied to tabular data if all the features are continuous-valued.
For text data, we utilize the pretrained model ``Polyjuice''~\citep{wu-etal-2021-polyjuice} to generate a set of potential counterfactual examples for classification tasks and question-answering tasks, and then these examples are sorted based on whether the predicted labels/results are different from the original labels/results and the distances to the original texts.
\section{Experiments}
In this section, we present four sets of experiments to demonstrate the four major types of XAI capabilities in our library to deal with four types of real data.
\subsection{XAI for Tabular Data: Income Prediction}
The first experiment is to explain tabular data of an income prediction task. The dataset used in this example is the Adult dataset\footnote{https://archive.ics.uci.edu/ml/datasets/adult} including 14 features, e.g., age, workclass, education. The goal is to predict whether income exceeds \$50K per year on census data. We trained an XGBoost classifier~\citep{Chen:2016:XST:2939672.2939785} for this task, and then OmniXAI is applied to generate explanations for each prediction given test instances.
\begin{figure}[t]
\center
\includegraphics[width=0.99\linewidth]{figures/example_1.png}
\caption{Dashboard visualization for income prediction}
\label{fig:income}
\end{figure}
Figure \ref{fig:income} shows the explanation results generated by multiple explainers given a test instance, e.g., LIME, SHAP, MACE, and PDP. One can easily compare the feature-attribution explanations generated by LIME and SHAP, i.e., the predicted class is ``$\leq 50k$'' because ``Hours per week = 18'' (less than normal working hours), ``Capital gain = 0'' (no additional asset income), and ``Captial loss'' (people whose income is larger than 50k may have more investments). MACE generates counterfactual examples, exploring ``what-if'' scenarios and obtaining more insights of the underlying ML model, e.g., if ``Capital gain'' increases from 0 to 6249, the predicted class will be ``$\ge 50k$'' instead of ``$\leq 50k$''. PDP explains the overall model behavior, e.g., income will increase as ``Age'' increase from 20 to 45 while income will decrease when ``Age'' increase from 45 to 80, longer working hours per week may lead to a higher income, and married people have a higher income (this is a potential bias in the dataset). From this dashboard, one can easily understand why such a prediction is made, whether there are potential issues in the dataset, and whether to do more feature processing/selection.
\subsection{XAI for Vision: Image Classification}
The second experiment is to explain an image classification task. We choose a ResNet~\citep{DBLP:journals/corr/HeZRS15} pretrained on ImageNet~\citep{deng2009imagenet}. Here is the sample code:
\lstinputlisting[language=Python]{example_4.py}
Figure \ref{fig:image_classification_2} shows the explanations generated by multiple explainers, e.g., Grad-CAM, Integrated-gradient, LIME.
The top predicted label of this test instance is ``bull\_mastiff''. These explainers explain the top predicted label by default (one can also set other labels to explain), e.g., integrated-gradient highlights the regions corresponding to ``bull\_mastiff''. Note that besides generating explanations with different explainers, OmniXAI can also generate explanations with the same explainer but different parameters. In this example, we apply Grad-CAM with different parameters, e.g., the target layer of ``gradcam0'' is ``layer4[-1]'' while the target layer of ``gradcam3'' is ``layer4[-3]'', and the label to explain for the first Grad-CAM explainer is ``bull\_mastiff'' (the top one label) while the label for the second Grad-CAM explainer is ``tiger\_cat''.
\begin{figure}[t]
\center
\includegraphics[width=0.8\linewidth]{figures/example_3.png}
\caption{Dashboard visualization for image classification}
\label{fig:image_classification_2}
\end{figure}
\begin{figure}[t]
\center
\includegraphics[width=0.9\linewidth]{figures/example_4.png}
\caption{Dashboard visualization for text classification}
\label{fig:text_classification}
\end{figure}
\subsection{XAI for NLP: Sentiment Classification}
The third experiment is to demonstrate the explanation for NLP tasks. Specifically, we consider a sentiment classification task on the IMDB dataset where the goal is to predict whether a user review is positive or negative. We train a text CNN model for this classification task using PyTorch, and then apply OmniXAI to generate explanations for each prediction given test instances. Suppose the processing function that converts the raw texts into the inputs of the model is "preprocess", and we want to analyze word/token importance and generate counterfactual examples. The following code shows how to do this:
\lstinputlisting[language=Python]{example_5.py}
Figure \ref{fig:text_classification} shows the explanation results generated by LIME, Integrated gradient (IG) and counterfactual explanation. Clearly, LIME and IG show that the word “great” has the largest word/token importance score, which implies that the sentence “What a great movie! if you have no taste.” is classified as “positive” because it contains “great”. The counterfactual method generates several counterfactual examples for this test sentence, e.g., “what a terrible movie! if you have no taste.”, helping us understand more about the model behavior.
\begin{figure}[t]
\center
\includegraphics[width=0.9\linewidth]{figures/example_5.png}
\caption{Dashboard visualization for time-series anomaly detection.}
\label{fig:timeseries}
\end{figure}
\subsection{XAI for Time-Series: Anomaly Detection}
The last experiment is to explain time-series data. We consider a univariate time-series anomaly detection task. We use a simple statistics-based detector for demonstration, e.g., a window of time-series is detected as an anomaly according to some threshold estimated from the training data. Suppose we have detector ``detector'', training data ``train\_df'' and a test instance ``test\_df''. The following code shows how to apply OmniXAI in anomaly detection:
\lstinputlisting[language=Python]{example_6.py}
Figure \ref{fig:timeseries} shows the explanation results generated by SHAP and MACE. The dash lines demonstrate the importance scores and the counterfactual examples, respectively. SHAP shows the most important timestamps that make this test instance detected as an anomaly. MACE provides a counterfactual example showing that it will not be detected as an anomaly if the metric values from 20:00 to 00:00 are around 2.0. From these two explanations, one can clearly understand the reason why the model considers it as an anomaly.
\section{Broader Impacts and Responsible Use}
The adoption of OmniXAI in real-world applications potentially can yield a broad range of positive impacts. OmniXAI offers a set of comprehensive and effective tools to interpret AI models and explain their decisions to improve the transparency and trustworthiness of AI systems, thus helping developers and users understand the logic behind the decisions. AI models sometimes may make unsatisfying or wrong decisions in real-world applications due to the data shift, sampling, labeling bias or other real data complexities. Explaining why an AI model fails is thus important and necessary, which is the key to keeping users confident in AI systems and help developers improve model performance. OmniXAI can be used to analyze various aspects of AI models and help developers figure out the issues and causes when a wrong decision occurs so that developers can quickly understand the reasons behind failures and improve the models accordingly. We encourage researchers, data scientists, and ML practitioners to adopt OmniXAI in real-world applications for positive impacts, e.g., improving transparency, accuracy, bias and fairness of AI/ML models.
While OmniXAI has many potential positive impacts, the misuse of OmniXAI may result in negative impacts. We encourage users and readers to read the detailed discussion and the guidelines for the responsible use of explainable ML in \citep{Patrick2019}.
In particular, the OmniXAI library should not be used to explain misused AI/ML models or any unethical use case. It also should not be used to enable hacking of models through public prediction API, or stealing black-box models or breaking privacy policies~\citep{Rudin2018,Florian2016,Reza2019}.
For practical uses in real-world applications, we recommend using multiple explainers supported in OmniXAI, e.g., SHAP for feature-attribution explanation, MACE for counterfactual explanation, PDP for global explanation or ``glass'' models such as linear or tree-based models, for explaining a particular model decision to reduce the risk of adversarial manipulation. Finally, we note that while OmniXAI can help to understand and improve the sociological bias when used properly, it is not guaranteed to detect all kinds of sociological biases, which could be further improved in future work.
\section{Conclusions and Future Work}
We present OmniXAI, a comprehensive open-source library for explainable AI, which provides omni-way explanation capabilities to address many of the pain points in understanding and interpreting the decisions made by machine learning models. It supports various data types and tasks, and provides unified, easily extensible interfaces for a wide range of explanation methods, e.g., feature-attribution explanation, counterfactual explanation, gradient-based explanation, etc. It also includes a GUI dashboard for users to examine explanation results and compare different interpretable algorithms. We will continue our efforts to improve OmniXAI. Some planned future work includes adding more techniques for data analysis (e.g., detecting mislabeled samples and bias issues), adding more latest interpretable ML algorithms especially for NLP and time-series, and adding supports for other types of data and tasks. We will also improve the dashboard and user interface to make it easier to use and more comprehensive. Finally, we welcome any feedback and suggestions for improvement, and encourage contributions from the open-source communities.
\section*{Acknowledgements}
We would like to thank our colleagues and leadership teams from Salesforce who have provided strong support, advice, and contributions to this project. We also want to thank our ethical AI team especially for Anna Bethke for the valuable feedback on this work.
| {'timestamp': '2022-06-29T02:09:45', 'yymm': '2206', 'arxiv_id': '2206.01612', 'language': 'en', 'url': 'https://arxiv.org/abs/2206.01612'} | arxiv |